Xfce Wiki

Sub domains
 

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
dev:howto:panel_plugins [2008/04/18 15:58] 125.40.123.215dev:howto:panel_plugins [2024/03/26 18:11] (current) – [Testing and Releasing the plugin] gael
Line 1: Line 1:
 ====== Xfce Panel Plugins How To ====== ====== Xfce Panel Plugins How To ======
-{{wiki:package.png  }} [[http://foo-projects.org/~nick/packages/xfce4-sample-plugin.tar.bz2|下载]] the external sample pluginYou can also [[http://svn.xfce.org/svn/goodies/xfce4-sample-plugin/trunk/|checkout]] the goodies svn. +<note tip>You can find the sample plugin [[https://gitlab.xfce.org/panel-plugins/xfce4-sample-plugin|on GitLab]]. There is also [[https://gitlab.xfce.org/itsManjeet/xfce4-python-sample-plugin|Python version]].</note>
  
 ===== Introduction ===== ===== Introduction =====
Line 7: Line 6:
 Starting from version 4.4 the Xfce Panel support two types of plugins: internal and external.  Starting from version 4.4 the Xfce Panel support two types of plugins: internal and external. 
 The internal plugins are loadable modules, using the  The internal plugins are loadable modules, using the 
-[[http://developer.gnome.org/doc/API/2.0/glib/glib-Dynamic-Loading-of-Modules.html|GModule]]+[[https://developer.gnome.org/glib/stable/glib-Dynamic-Loading-of-Modules.html|GModule]]
 interface. External plugins are separate programs that are embedded into the panel using the  interface. External plugins are separate programs that are embedded into the panel using the 
-[[http://developer.gnome.org/doc/API/2.0/gtk/GtkPlug.html|GtkPlug]] and  +[[https://developer.gnome.org/gtk3/stable/GtkPlug.html|GtkPlug]] and  
-[[http://developer.gnome.org/doc/API/2.0/gtk/GtkSocket.html|GtkSocket]] mechanism.+[[https://developer.gnome.org/gtk3/stable/GtkSocket.html|GtkSocket]] mechanism.
  
 In order to handle these plugins the plugin system was entirely rewritten, along with the rest  In order to handle these plugins the plugin system was entirely rewritten, along with the rest 
 of the panel framework. This file describes the way plugin writers should interact with this system. of the panel framework. This file describes the way plugin writers should interact with this system.
  
-The API documentation is installed with the panel and also available from +The [[:api_documentation|API documentation]] is installed with the panel and also available from 
 http://www.xfce.org/documentation/api/ http://www.xfce.org/documentation/api/
 +
  
  
Line 35: Line 35:
   X-XFCE-Module=<plugin_name>   X-XFCE-Module=<plugin_name>
   X-XFCE-Module-Path=<prefix>/lib/xfce4/panel-plugins   X-XFCE-Module-Path=<prefix>/lib/xfce4/panel-plugins
 +
 +For instance, 
 +
 +  X-XFCE-Module=quicklauncher
 +  X-XFCE-Module-Path=/usr/lib/xfce4/panel-plugins
  
 If the module should have no more than 1 instance running at the same time, you add this line: If the module should have no more than 1 instance running at the same time, you add this line:
Line 40: Line 45:
   X-XFCE-Unique=true   X-XFCE-Unique=true
  
 +If the plugin is compatible with GTK+ 3, you need to add this line:
 +
 +  X-XFCE-API=2.0
  
 ===== Library ===== ===== Library =====
Line 46: Line 54:
 line like this: line like this:
  
-  XDT_CHECK_PACKAGE ([LIBXFCE4PANEL], [libxfce4panel-1.0], [4.3.99.2])+  XDT_CHECK_PACKAGE ([LIBXFCE4PANEL], [libxfce4panel-2.0], [4.12.0])
  
 The above assumes that you are using the xfce4-dev-tools package, which you really should,  The above assumes that you are using the xfce4-dev-tools package, which you really should, 
Line 56: Line 64:
 required headers (''gtk'' and ''libxfce4util''): required headers (''gtk'' and ''libxfce4util''):
  
-  #include <libxfce4panel/xfce-panel-plugin.h>+  #include <libxfce4panel/libxfce4panel.h>
  
 ===== Plugin Registration ===== ===== Plugin Registration =====
  
-To register a plugin with the plugin system there are two macros available that should be used,  +To register a plugin with the plugin system there is one macro available that should be used, instead of using the library functions directly
-instead of using the library functions directly; one for internal plugins and one for external plugins.+  XFCE_PANEL_PLUGIN_REGISTER(construct); 
 +   
 +Older versions use the following two deprecated macros, one for internal plugins and one for external plugins.
  
   XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL(construct);   XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL(construct);
Line 267: Line 277:
  
 For creating a release you need to run ''./autogen.sh && make distcheck''. Fix all warnings and errors in make distcheck before distributing the package. For creating a release you need to run ''./autogen.sh && make distcheck''. Fix all warnings and errors in make distcheck before distributing the package.
 +
 +To help development, you can also test plugins without installing them on panel's prefix (e.g. /usr). As for 4.19.4, you can install the plugin in a directory of XDG_DATA_DIRS or in XDG_HOME_DIR, and the panel should find it. In particular, a default plugin installation in /usr/local with a panel in /usr should work on its own (or a plugin installation in ~/.local without root permissions).
 +
 +You can also directly run plugins from the source so you don't need to overwrite a plugin version from your distribution. To accomplish this, build the plugin with make and then follow these steps:
 +
 +  * Create a symbolic link from your plugin binary to the panel's prefix installation, e.g. ''ln -s /home/johndoe/where/your/src/is/panel-plugin/.libs/libyourplugin.so /usr/lib/xfce4/panel-plugins/libyourplugin-git.so''
 +  * Copy ''/usr/share/xfce4/panel/plugins/yourplugin.desktop'' to ''/usr/share/xfce4/panel/plugins/yourplugin-git.desktop''
 +  * Edit the latter to point at 'yourplugin-git' instead of 'yourplugin': modify the ''Name'' entry to distinguish your instance and ''X-XFCE-Module'' to match the symbolic link, i.e. ''yourplugin-git''.
 +  * If you're porting a plugin to GTK+ 3, make sure to add ''X-XFCE-API=2.0'' to the desktop-git file.
 +
 +An example:
 +
 +<code>
 +$cat /usr/share/xfce4/panel/plugins/diskperf-git.desktop
 +[Xfce Panel]
 +Type=X-XFCE-PanelPlugin
 +Encoding=UTF-8
 +Name=Disk Performance Monitor (git)
 +Comment=Show disk performance
 +Icon=drive-harddisk
 +X-XFCE-Internal=FALSE
 +X-XFCE-Module=diskperf-git
 +X-XFCE-API=2.0
 +</code>
 +
 +Now the 'git' version of the panel plugin should be available in the 'add plugin' panel dialog. Whenever you make changes and compile the plugin, all you need to do is to add the plugin to panel again or simply refresh the panel ''xfce4-panel -r''.
  
 ===== Debugging ===== ===== Debugging =====
-One can use Valgrind to debug external plugins, using the technique described [[:howto/panel_plugin_debug|here]].+One can use GDB and Valgrind to debug external plugins, using the technique described [[https://docs.xfce.org/xfce/xfce4-panel/debugging|here]].