Index: libxfce4panel/xfce-panel-plugin.h
===================================================================
--- libxfce4panel/xfce-panel-plugin.h (revision 25717)
+++ libxfce4panel/xfce-panel-plugin.h (working copy)
@@ -39,27 +39,8 @@
*
* See also: Panel Plugin interface
**/
-#define XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL(construct) \
- gint \
- main (gint argc, gchar **argv) \
- { \
- GtkWidget *plugin; \
- \
- gtk_init (&argc, &argv); \
- \
- plugin = xfce_external_panel_plugin_new (argc, argv, \
- (XfcePanelPluginFunc)construct); \
- \
- if (G_UNLIKELY (plugin == NULL)) \
- return 1; \
- \
- g_signal_connect_after (G_OBJECT (plugin), "destroy", \
- G_CALLBACK (gtk_main_quit), NULL); \
- gtk_widget_show (plugin); \
- \
- gtk_main (); \
- return 0; \
- }
+#define XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL(construct) \
+ XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL_FULL(construct,NULL,NULL)
/**
* XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL_WITH_CHECK
@@ -75,30 +56,67 @@
*
* See also: Panel Plugin interface
**/
-#define XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL_WITH_CHECK(construct,check) \
- gint \
- main (gint argc, gchar **argv) \
- { \
- GtkWidget *plugin; \
- XfcePanelPluginCheck test = (XfcePanelPluginCheck)check; \
- \
- gtk_init (&argc, &argv); \
- \
- if (G_UNLIKELY (test(gdk_screen_get_default()) == FALSE)) \
- return 2; \
- \
- plugin = xfce_external_panel_plugin_new (argc, argv, \
- (XfcePanelPluginFunc)construct); \
- \
- if (G_UNLIKELY (plugin == NULL)) \
- return 1; \
- \
- g_signal_connect_after (G_OBJECT (plugin), "destroy", \
- G_CALLBACK (gtk_main_quit), NULL); \
- gtk_widget_show (plugin); \
- \
- gtk_main (); \
- return 0; \
+#define XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL_WITH_CHECK(construct,check) \
+ XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL_FULL(construct,NULL,check)
+
+/**
+ * XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL_FULL
+ * @construct : name of a function that can be cast to #XfcePanelPluginFunc
+ * @init : name of a function that can be case to #XfcePanelPluginPreInit
+ * or NULL
+ * @check : name of a function that can be cast to #XfcePanelPluginCheck
+ * or NULL
+ *
+ * Registers and initializes the plugin. This is the only thing that is
+ * required to create a panel plugin.
+ *
+ * The @init argument should be a function that takes two parameters:
+ *
+ * gboolean init( int argc, char **argv );
+ *
+ * The @check functions is run aftern gtk_init() and before creating the
+ * plugin; it takes one argument and should return FALSE if plugin creation
+ * is not possible:
+ *
+ * gboolean check( GdkScreen *screen );
+ *
+ * See also: Panel Plugin interface
+ **/
+#define XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL_FULL(construct,init,check) \
+ gint \
+ main (gint argc, gchar **argv) \
+ { \
+ GtkWidget *plugin; \
+ XfcePanelPluginFunc create = (XfcePanelPluginFunc)construct \
+ XfcePanelPluginPreInit preinit = (XfcePanelPluginPreInit)init; \
+ XfcePanelPluginCheck test = (XfcePanelPluginCheck)check; \
+ \
+ if ( init ) \
+ { \
+ if (G_UNLIKELY (init(argc,argv) == FALSE)) \
+ return 3; \
+ } \
+ \
+ gtk_init (&argc, &argv); \
+ \
+ if ( test ) \
+ { \
+ if (G_UNLIKELY (test(gdk_screen_get_default()) == FALSE)) \
+ return 2; \
+ } \
+ \
+ plugin = xfce_external_panel_plugin_new (argc, argv, create); \
+ \
+ if (G_UNLIKELY (plugin == NULL)) \
+ return 1; \
+ \
+ g_signal_connect_after (G_OBJECT (plugin), "destroy", \
+ G_CALLBACK (gtk_main_quit), NULL); \
+ \
+ gtk_widget_show (plugin); \
+ gtk_main (); \
+ \
+ return 0; \
}
/**
Index: libxfce4panel/xfce-panel-plugin-iface.h
===================================================================
--- libxfce4panel/xfce-panel-plugin-iface.h (revision 25717)
+++ libxfce4panel/xfce-panel-plugin-iface.h (working copy)
@@ -49,14 +49,32 @@
typedef void (*XfcePanelPluginFunc) (XfcePanelPlugin *plugin);
/**
+ * XfcePanelPluginPreInit:
+ * @argc : number of arguments to the plugin
+ * @argv : argument array
+ *
+ * Callback function that is run in an external plugin before gtk_init(). It should
+ * return FALSE if the plugin is not available for whatever reason. It should be given
+ * as the argument to the registration macro.
+ *
+ * The main purpose of this callback is to allow multithreadd plugins to call
+ * g_threads_init().
+ *
+ * See also: XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL_FULL()
+ **/
+typedef gboolean (*XfcePanelPluginPreInit) (int argc, char **argv);
+
+/**
* XfcePanelPluginCheck:
+ * @screen : the #GdkScreen the panel is running on
*
* Callback function that is run before creating a plugin. It should return
- * if the plugin is not available for whatever reason. It should be given as
- * the argument to the registration macros.
+ * FALSE if the plugin is not available for whatever reason. It should be
+ * given as the argument to the registration macros.
*
- * See also: XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL_WITH_CHECK() and
- * XFCE_PANEL_PLUGIN_REGISTER_INTERNAL_WITH_CHECK()
+ * See also: XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL_WITH_CHECK(),
+ * XFCE_PANEL_PLUGIN_REGISTER_INTERNAL_WITH_CHECK() and
+ * XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL_FULL()
**/
typedef gboolean (*XfcePanelPluginCheck) (GdkScreen *screen);