[Xfce4-commits] <xfce4-panel:devel> Move the object register macros to the macros file.
Nick Schermer
noreply at xfce.org
Tue Nov 17 14:18:04 CET 2009
Updating branch refs/heads/devel
to 2d56bd415a7a8b680c8b1354c090fab7a7c7976d (commit)
from 91dfd3d3f37c27e82efd136a986c421fef99785e (commit)
commit 2d56bd415a7a8b680c8b1354c090fab7a7c7976d
Author: Nick Schermer <nick at xfce.org>
Date: Tue Nov 17 14:05:17 2009 +0100
Move the object register macros to the macros file.
libxfce4panel/libxfce4panel.h | 181 ------------------------------------
libxfce4panel/xfce-panel-macros.h | 182 +++++++++++++++++++++++++++++++++++++
2 files changed, 182 insertions(+), 181 deletions(-)
diff --git a/libxfce4panel/libxfce4panel.h b/libxfce4panel/libxfce4panel.h
index db5ac82..0be57fa 100644
--- a/libxfce4panel/libxfce4panel.h
+++ b/libxfce4panel/libxfce4panel.h
@@ -34,187 +34,6 @@ G_BEGIN_DECLS
#undef LIBXFCE4PANEL_INSIDE_LIBXFCE4PANEL_H
-/* register a resident panel plugin */
-#define XFCE_PANEL_DEFINE_PLUGIN_RESIDENT(TypeName, type_name, args...) \
- _XPP_DEFINE_PLUGIN (TypeName, type_name, TRUE, args)
-
-/* register a panel plugin that can unload the module */
-#define XFCE_PANEL_DEFINE_PLUGIN(TypeName, type_name, args...) \
- _XPP_DEFINE_PLUGIN (TypeName, type_name, FALSE, args)
-
-#define XFCE_PANEL_DEFINE_TYPE(TypeName, type_name, TYPE_PARENT) \
- static gpointer type_name##_parent_class = NULL; \
- static GType type_name##_type = 0; \
- \
- static void type_name##_init (TypeName *self); \
- static void type_name##_class_init (TypeName##Class *klass); \
- static void type_name##_class_intern_init (gpointer klass) \
- { \
- type_name##_parent_class = g_type_class_peek_parent (klass); \
- type_name##_class_init ((TypeName##Class*) klass); \
- } \
- \
- GType \
- type_name##_get_type (void) \
- { \
- return type_name##_type; \
- } \
- \
- void \
- type_name##_register_type (XfcePanelTypeModule *type_module) \
- { \
- GType plugin_define_type_id; \
- static const GTypeInfo plugin_define_type_info = \
- { \
- sizeof (TypeName##Class), \
- NULL, \
- NULL, \
- (GClassInitFunc) type_name##_class_intern_init, \
- NULL, \
- NULL, \
- sizeof (TypeName), \
- 0, \
- (GInstanceInitFunc) type_name##_init, \
- NULL, \
- }; \
- \
- plugin_define_type_id = \
- g_type_module_register_type (G_TYPE_MODULE (type_module), TYPE_PARENT, \
- "Xfce" #TypeName, &plugin_define_type_info, 0); \
- \
- type_name##_type = plugin_define_type_id; \
- }
-
-#define _XPP_DEFINE_PLUGIN(TypeName, type_name, resident, args...) \
- GType xfce_panel_module_init (GTypeModule *type_module, gboolean *make_resident); \
- \
- XFCE_PANEL_DEFINE_TYPE (TypeName, type_name, XFCE_TYPE_PANEL_PLUGIN) \
- \
- G_MODULE_EXPORT GType \
- xfce_panel_module_init (GTypeModule *type_module, \
- gboolean *make_resident) \
- { \
- typedef void (*XppRegFunc) (GTypeModule *module); \
- XppRegFunc reg_funcs[] = { type_name##_register_type, args }; \
- guint i; \
- \
- /* whether to make this plugin resident */ \
- if (make_resident != NULL) \
- *make_resident = resident; \
- \
- /* register the plugin types */ \
- for (i = 0; i < G_N_ELEMENTS (reg_funcs); i++) \
- (* reg_funcs[i]) (type_module); \
- \
- return type_name##_get_type (); \
- }
-
-typedef void (*XfcePanelPluginFunc) (XfcePanelPlugin *plugin);
-
-typedef gboolean (*XfcePanelPluginPreInit) (gint argc, gchar **argv);
-
-typedef gboolean (*XfcePanelPluginCheck) (GdkScreen *screen);
-
-typedef GTypeModule XfcePanelTypeModule;
-
-/**
- * XFCE_PANEL_PLUGIN_REGISTER:
- * construct_func : name of the function that points to an
- * #XfcePanelPluginFunc function.
- *
- * Since: 4.8
- **/
-#define XFCE_PANEL_PLUGIN_REGISTER(construct_func) \
- XFCE_PANEL_PLUGIN_REGISTER_EXTENDED (construct_func, /* foo */, /* foo */)
-
-/**
- * XFCE_PANEL_PLUGIN_REGISTER_WITH_CHECK:
- * construct_func : name of the function that points to an
- * #XfcePanelPluginFunc function.
- * check_func : name of the function that points to an
- * #XfcePanelPluginCheck function.
- *
- * Since: 4.8
- **/
-#define XFCE_PANEL_PLUGIN_REGISTER_WITH_CHECK(construct_func, check_func) \
- XFCE_PANEL_PLUGIN_REGISTER_EXTENDED (construct_func, /* foo */, \
- if (G_LIKELY ((*check_func) (xpp_screen) == TRUE)))
-
-/**
- * XFCE_PANEL_PLUGIN_REGISTER_FULL:
- * construct_func : name of the function that points to an
- * #XfcePanelPluginFunc function.
- * preinit_func : name of the function that points to an
- * #XfcePanelPluginPreInit function.
- * check_func : name of the function that points to an
- * #XfcePanelPluginCheck function.
- *
- * Since: 4.8
- **/
-#define XFCE_PANEL_PLUGIN_REGISTER_FULL(construct_func, preinit_func, check_func) \
- XFCE_PANEL_PLUGIN_REGISTER_EXTENDED (construct_func, \
- G_MODULE_EXPORT gboolean xfce_panel_module_preinit (gint argc, gchar **argv); \
- \
- G_MODULE_EXPORT gboolean \
- xfce_panel_module_preinit (gint argc, \
- gchar **argv) \
- { \
- return (*preinit_func) (argc, argv); \
- }, \
- \
- if (G_LIKELY ((*check_func) (xpp_screen) == TRUE)))
-
-/* <private> */
-#define XFCE_PANEL_PLUGIN_REGISTER_EXTENDED(construct_func, PREINIT_CODE, CHECK_CODE) \
- static void \
- xfce_panel_module_realize (XfcePanelPlugin *xpp) \
- { \
- panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (xpp)); \
- \
- g_signal_handlers_disconnect_by_func (G_OBJECT (xpp), \
- G_CALLBACK (xfce_panel_module_realize), NULL); \
- \
- (*construct_func) (xpp); \
- } \
- \
- PREINIT_CODE \
- \
- G_MODULE_EXPORT XfcePanelPlugin * \
- xfce_panel_module_construct (const gchar *xpp_name, \
- gint xpp_unique_id, \
- const gchar *xpp_display_name, \
- const gchar *xpp_comment, \
- gchar **xpp_arguments, \
- GdkScreen *xpp_screen); \
- G_MODULE_EXPORT XfcePanelPlugin * \
- xfce_panel_module_construct (const gchar *xpp_name, \
- gint xpp_unique_id, \
- const gchar *xpp_display_name, \
- const gchar *xpp_comment, \
- gchar **xpp_arguments, \
- GdkScreen *xpp_screen) \
- { \
- XfcePanelPlugin *xpp = NULL; \
- \
- panel_return_val_if_fail (GDK_IS_SCREEN (xpp_screen), NULL); \
- panel_return_val_if_fail (xpp_name != NULL && xpp_unique_id != -1, NULL); \
- \
- CHECK_CODE \
- { \
- xpp = g_object_new (XFCE_TYPE_PANEL_PLUGIN, \
- "name", xpp_name, \
- "unique-id", xpp_unique_id, \
- "display-name", xpp_display_name, \
- "comment", xpp_comment, \
- "arguments", xpp_arguments, NULL); \
- \
- g_signal_connect_after (G_OBJECT (xpp), "realize", \
- G_CALLBACK (xfce_panel_module_realize), NULL); \
- } \
- \
- return xpp; \
- }
-
G_END_DECLS
#endif /* !__LIBXFCE4PANEL__ */
diff --git a/libxfce4panel/xfce-panel-macros.h b/libxfce4panel/xfce-panel-macros.h
index be7624b..768de9e 100644
--- a/libxfce4panel/xfce-panel-macros.h
+++ b/libxfce4panel/xfce-panel-macros.h
@@ -24,9 +24,18 @@
#define __XFCE_PANEL_MACROS_H__
#include <glib.h>
+#include <libxfce4panel/xfce-panel-plugin.h>
G_BEGIN_DECLS
+typedef void (*XfcePanelPluginFunc) (XfcePanelPlugin *plugin);
+
+typedef gboolean (*XfcePanelPluginPreInit) (gint argc, gchar **argv);
+
+typedef gboolean (*XfcePanelPluginCheck) (GdkScreen *screen);
+
+typedef GTypeModule XfcePanelTypeModule;
+
/* xfconf channel for plugins */
#define XFCE_PANEL_PLUGIN_CHANNEL_NAME ("xfce4-panel")
@@ -35,6 +44,179 @@ G_BEGIN_DECLS
xfconf_channel_new_with_property_base (XFCE_PANEL_PLUGIN_CHANNEL_NAME, \
xfce_panel_plugin_get_property_base (XFCE_PANEL_PLUGIN (plugin)))
+/* register a resident panel plugin */
+#define XFCE_PANEL_DEFINE_PLUGIN_RESIDENT(TypeName, type_name, args...) \
+ _XPP_DEFINE_PLUGIN (TypeName, type_name, TRUE, args)
+
+/* register a panel plugin that can unload the module */
+#define XFCE_PANEL_DEFINE_PLUGIN(TypeName, type_name, args...) \
+ _XPP_DEFINE_PLUGIN (TypeName, type_name, FALSE, args)
+
+#define XFCE_PANEL_DEFINE_TYPE(TypeName, type_name, TYPE_PARENT) \
+ static gpointer type_name##_parent_class = NULL; \
+ static GType type_name##_type = 0; \
+ \
+ static void type_name##_init (TypeName *self); \
+ static void type_name##_class_init (TypeName##Class *klass); \
+ static void type_name##_class_intern_init (gpointer klass) \
+ { \
+ type_name##_parent_class = g_type_class_peek_parent (klass); \
+ type_name##_class_init ((TypeName##Class*) klass); \
+ } \
+ \
+ GType \
+ type_name##_get_type (void) \
+ { \
+ return type_name##_type; \
+ } \
+ \
+ void \
+ type_name##_register_type (XfcePanelTypeModule *type_module) \
+ { \
+ GType plugin_define_type_id; \
+ static const GTypeInfo plugin_define_type_info = \
+ { \
+ sizeof (TypeName##Class), \
+ NULL, \
+ NULL, \
+ (GClassInitFunc) type_name##_class_intern_init, \
+ NULL, \
+ NULL, \
+ sizeof (TypeName), \
+ 0, \
+ (GInstanceInitFunc) type_name##_init, \
+ NULL, \
+ }; \
+ \
+ plugin_define_type_id = \
+ g_type_module_register_type (G_TYPE_MODULE (type_module), TYPE_PARENT, \
+ "Xfce" #TypeName, &plugin_define_type_info, 0); \
+ \
+ type_name##_type = plugin_define_type_id; \
+ }
+
+#define _XPP_DEFINE_PLUGIN(TypeName, type_name, resident, args...) \
+ GType xfce_panel_module_init (GTypeModule *type_module, gboolean *make_resident); \
+ \
+ XFCE_PANEL_DEFINE_TYPE (TypeName, type_name, XFCE_TYPE_PANEL_PLUGIN) \
+ \
+ G_MODULE_EXPORT GType \
+ xfce_panel_module_init (GTypeModule *type_module, \
+ gboolean *make_resident) \
+ { \
+ typedef void (*XppRegFunc) (GTypeModule *module); \
+ XppRegFunc reg_funcs[] = { type_name##_register_type, args }; \
+ guint i; \
+ \
+ /* whether to make this plugin resident */ \
+ if (make_resident != NULL) \
+ *make_resident = resident; \
+ \
+ /* register the plugin types */ \
+ for (i = 0; i < G_N_ELEMENTS (reg_funcs); i++) \
+ (* reg_funcs[i]) (type_module); \
+ \
+ return type_name##_get_type (); \
+ }
+
+/**
+ * XFCE_PANEL_PLUGIN_REGISTER:
+ * construct_func : name of the function that points to an
+ * #XfcePanelPluginFunc function.
+ *
+ * Since: 4.8
+ **/
+#define XFCE_PANEL_PLUGIN_REGISTER(construct_func) \
+ XFCE_PANEL_PLUGIN_REGISTER_EXTENDED (construct_func, /* foo */, /* foo */)
+
+/**
+ * XFCE_PANEL_PLUGIN_REGISTER_WITH_CHECK:
+ * construct_func : name of the function that points to an
+ * #XfcePanelPluginFunc function.
+ * check_func : name of the function that points to an
+ * #XfcePanelPluginCheck function.
+ *
+ * Since: 4.8
+ **/
+#define XFCE_PANEL_PLUGIN_REGISTER_WITH_CHECK(construct_func, check_func) \
+ XFCE_PANEL_PLUGIN_REGISTER_EXTENDED (construct_func, /* foo */, \
+ if (G_LIKELY ((*check_func) (xpp_screen) == TRUE)))
+
+/**
+ * XFCE_PANEL_PLUGIN_REGISTER_FULL:
+ * construct_func : name of the function that points to an
+ * #XfcePanelPluginFunc function.
+ * preinit_func : name of the function that points to an
+ * #XfcePanelPluginPreInit function.
+ * check_func : name of the function that points to an
+ * #XfcePanelPluginCheck function.
+ *
+ * Since: 4.8
+ **/
+#define XFCE_PANEL_PLUGIN_REGISTER_FULL(construct_func, preinit_func, check_func) \
+ XFCE_PANEL_PLUGIN_REGISTER_EXTENDED (construct_func, \
+ G_MODULE_EXPORT gboolean xfce_panel_module_preinit (gint argc, gchar **argv); \
+ \
+ G_MODULE_EXPORT gboolean \
+ xfce_panel_module_preinit (gint argc, \
+ gchar **argv) \
+ { \
+ return (*preinit_func) (argc, argv); \
+ }, \
+ \
+ if (G_LIKELY ((*check_func) (xpp_screen) == TRUE)))
+
+/* <private> */
+#define XFCE_PANEL_PLUGIN_REGISTER_EXTENDED(construct_func, PREINIT_CODE, CHECK_CODE) \
+ static void \
+ xfce_panel_module_realize (XfcePanelPlugin *xpp) \
+ { \
+ panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (xpp)); \
+ \
+ g_signal_handlers_disconnect_by_func (G_OBJECT (xpp), \
+ G_CALLBACK (xfce_panel_module_realize), NULL); \
+ \
+ (*construct_func) (xpp); \
+ } \
+ \
+ PREINIT_CODE \
+ \
+ G_MODULE_EXPORT XfcePanelPlugin * \
+ xfce_panel_module_construct (const gchar *xpp_name, \
+ gint xpp_unique_id, \
+ const gchar *xpp_display_name, \
+ const gchar *xpp_comment, \
+ gchar **xpp_arguments, \
+ GdkScreen *xpp_screen); \
+ G_MODULE_EXPORT XfcePanelPlugin * \
+ xfce_panel_module_construct (const gchar *xpp_name, \
+ gint xpp_unique_id, \
+ const gchar *xpp_display_name, \
+ const gchar *xpp_comment, \
+ gchar **xpp_arguments, \
+ GdkScreen *xpp_screen) \
+ { \
+ XfcePanelPlugin *xpp = NULL; \
+ \
+ panel_return_val_if_fail (GDK_IS_SCREEN (xpp_screen), NULL); \
+ panel_return_val_if_fail (xpp_name != NULL && xpp_unique_id != -1, NULL); \
+ \
+ CHECK_CODE \
+ { \
+ xpp = g_object_new (XFCE_TYPE_PANEL_PLUGIN, \
+ "name", xpp_name, \
+ "unique-id", xpp_unique_id, \
+ "display-name", xpp_display_name, \
+ "comment", xpp_comment, \
+ "arguments", xpp_arguments, NULL); \
+ \
+ g_signal_connect_after (G_OBJECT (xpp), "realize", \
+ G_CALLBACK (xfce_panel_module_realize), NULL); \
+ } \
+ \
+ return xpp; \
+ }
+
G_END_DECLS
#endif /* !__XFCE_PANEL_MACROS_H__ */
More information about the Xfce4-commits
mailing list