From 15450ddd3497689cee62c2e83ec03e6b3e226573 Mon Sep 17 00:00:00 2001 From: Nick Schermer Date: Fri, 26 Feb 2010 14:08:23 +0100 Subject: [PATCH] Move the panel_return macros to the private header. Not code that is suitable for plugin developers. Also drop the I_() macro and use g_intern_static_string directly. --- common/panel-builder.c | 1 + common/panel-private.h | 27 ++++++++++++++ common/panel-xfconf.c | 1 + libxfce4panel/xfce-arrow-button.c | 2 +- libxfce4panel/xfce-panel-macros.h | 41 ++-------------------- libxfce4panel/xfce-panel-plugin-provider.c | 7 ++-- libxfce4panel/xfce-panel-plugin.c | 26 +++++++------- panel/main.c | 1 + panel/panel-dbus-client.c | 1 + panel/panel-dbus-service.c | 3 +- panel/panel-dialogs.c | 2 ++ panel/panel-itembar.c | 4 ++- panel/panel-module-factory.c | 5 ++- panel/panel-plugin-external.c | 5 ++- panel/panel-preferences-dialog.c | 3 ++ plugins/actions/actions.c | 4 ++- plugins/clock/clock.h | 1 + plugins/pager/pager.c | 1 + plugins/separator/separator.c | 1 + plugins/showdesktop/showdesktop.c | 1 + plugins/systray/systray-manager.c | 12 ++++--- plugins/systray/systray-socket.c | 1 + plugins/tasklist/tasklist.c | 1 + wrapper/wrapper-module.c | 1 + 24 files changed, 87 insertions(+), 65 deletions(-) diff --git a/common/panel-builder.c b/common/panel-builder.c index 2ec43965..312bde71 100644 --- a/common/panel-builder.c +++ b/common/panel-builder.c @@ -20,6 +20,7 @@ #include #endif +#include #include diff --git a/common/panel-private.h b/common/panel-private.h index 40f6164b..ccdb5fca 100644 --- a/common/panel-private.h +++ b/common/panel-private.h @@ -19,6 +19,33 @@ #ifndef __PANEL_PRIVATE_H__ #define __PANEL_PRIVATE_H__ +/* support macros for debugging (improved macro for better position indication) */ +#ifndef NDEBUG +#define panel_assert(expr) g_assert (expr) +#define panel_assert_not_reached() g_assert_not_reached () +#define panel_return_if_fail(expr) G_STMT_START { \ + if (G_UNLIKELY (!(expr))) \ + { \ + g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, \ + "%s (%s): expression '%s' failed.", G_STRLOC, G_STRFUNC, \ + #expr); \ + return; \ + }; }G_STMT_END +#define panel_return_val_if_fail(expr,val) G_STMT_START { \ + if (G_UNLIKELY (!(expr))) \ + { \ + g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, \ + "%s (%s): expression '%s' failed.", G_STRLOC, G_STRFUNC, \ + #expr); \ + return (val); \ + }; }G_STMT_END +#else +#define panel_assert(expr) G_STMT_START{ (void)0; }G_STMT_END +#define panel_assert_not_reached() G_STMT_START{ (void)0; }G_STMT_END +#define panel_return_if_fail(expr) G_STMT_START{ (void)0; }G_STMT_END +#define panel_return_val_if_fail(expr,val) G_STMT_START{ (void)0; }G_STMT_END +#endif + /* handling flags */ #define PANEL_SET_FLAG(flags,flag) G_STMT_START{ ((flags) |= (flag)); }G_STMT_END #define PANEL_UNSET_FLAG(flags,flag) G_STMT_START{ ((flags) &= ~(flag)); }G_STMT_END diff --git a/common/panel-xfconf.c b/common/panel-xfconf.c index 6a328336..2c52a5dd 100644 --- a/common/panel-xfconf.c +++ b/common/panel-xfconf.c @@ -20,6 +20,7 @@ #include #endif +#include #include #include diff --git a/libxfce4panel/xfce-arrow-button.c b/libxfce4panel/xfce-arrow-button.c index 6b834de1..e730b564 100644 --- a/libxfce4panel/xfce-arrow-button.c +++ b/libxfce4panel/xfce-arrow-button.c @@ -125,7 +125,7 @@ xfce_arrow_button_class_init (XfceArrowButtonClass * klass) * This value also determines the direction of the popup menu. **/ arrow_button_signals[ARROW_TYPE_CHANGED] = - g_signal_new (I_("arrow-type-changed"), + g_signal_new (g_intern_static_string ("arrow-type-changed"), G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (XfceArrowButtonClass, arrow_type_changed), diff --git a/libxfce4panel/xfce-panel-macros.h b/libxfce4panel/xfce-panel-macros.h index ce1ad039..be7624be 100644 --- a/libxfce4panel/xfce-panel-macros.h +++ b/libxfce4panel/xfce-panel-macros.h @@ -27,50 +27,13 @@ G_BEGIN_DECLS -/* support macros for debugging (improved macro for better position indication) */ -#ifndef NDEBUG -#define panel_assert(expr) g_assert (expr) -#define panel_assert_not_reached() g_assert_not_reached () -#define panel_return_if_fail(expr) G_STMT_START { \ - if (G_UNLIKELY (!(expr))) \ - { \ - g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, \ - "%s (%s): expression '%s' failed.", G_STRLOC, G_STRFUNC, \ - #expr); \ - return; \ - }; }G_STMT_END -#define panel_return_val_if_fail(expr,val) G_STMT_START { \ - if (G_UNLIKELY (!(expr))) \ - { \ - g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, \ - "%s (%s): expression '%s' failed.", G_STRLOC, G_STRFUNC, \ - #expr); \ - return (val); \ - }; }G_STMT_END -#else -#define panel_assert(expr) G_STMT_START{ (void)0; }G_STMT_END -#define panel_assert_not_reached() G_STMT_START{ (void)0; }G_STMT_END -#define panel_return_if_fail(expr) G_STMT_START{ (void)0; }G_STMT_END -#define panel_return_val_if_fail(expr,val) G_STMT_START{ (void)0; }G_STMT_END -#endif - -/* canonical representation for static strings */ -#ifndef I_ -#define I_(string) (g_intern_static_string ((string))) -#endif - /* xfconf channel for plugins */ #define XFCE_PANEL_PLUGIN_CHANNEL_NAME ("xfce4-panel") -/* macro for opening an XfconfChannel for plugin */ +/* macro for opening an XfconfChannel for plugins */ #define xfce_panel_plugin_xfconf_channel_new(plugin) \ xfconf_channel_new_with_property_base (XFCE_PANEL_PLUGIN_CHANNEL_NAME, \ - xfce_panel_plugin_get_property_base (XFCE_PANEL_PLUGIN (plugin))); - -/* this is defined in glib 2.13.0 */ -#ifndef G_PARAM_STATIC_STRINGS -#define G_PARAM_STATIC_STRINGS (G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB) -#endif + xfce_panel_plugin_get_property_base (XFCE_PANEL_PLUGIN (plugin))) G_END_DECLS diff --git a/libxfce4panel/xfce-panel-plugin-provider.c b/libxfce4panel/xfce-panel-plugin-provider.c index 487938d2..9ab54063 100644 --- a/libxfce4panel/xfce-panel-plugin-provider.c +++ b/libxfce4panel/xfce-panel-plugin-provider.c @@ -22,6 +22,8 @@ #include +#include + #include #include #include @@ -51,7 +53,8 @@ xfce_panel_plugin_provider_get_type (void) if (G_UNLIKELY (type == 0)) { - type = g_type_register_static_simple (G_TYPE_INTERFACE, I_("XfcePanelPluginProvider"), + type = g_type_register_static_simple (G_TYPE_INTERFACE, + g_intern_static_string ("XfcePanelPluginProvider"), sizeof (XfcePanelPluginProviderIface), xfce_panel_plugin_provider_class_init, 0, NULL, 0); @@ -67,7 +70,7 @@ xfce_panel_plugin_provider_class_init (gpointer klass, gpointer klass_data) { provider_signals[PROVIDER_SIGNAL] = - g_signal_new (I_("provider-signal"), + g_signal_new (g_intern_static_string ("provider-signal"), G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (XfcePanelPluginProviderIface, provider_signal), diff --git a/libxfce4panel/xfce-panel-plugin.c b/libxfce4panel/xfce-panel-plugin.c index be436550..bd9ab949 100644 --- a/libxfce4panel/xfce-panel-plugin.c +++ b/libxfce4panel/xfce-panel-plugin.c @@ -194,7 +194,7 @@ xfce_panel_plugin_class_init (XfcePanelPluginClass *klass) * See also: xfce_panel_plugin_menu_show_about(). **/ plugin_signals[ABOUT] = - g_signal_new (I_("about"), + g_signal_new (g_intern_static_string ("about"), G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (XfcePanelPluginClass, about), @@ -214,7 +214,7 @@ xfce_panel_plugin_class_init (XfcePanelPluginClass *klass) * xfce_titled_dialog_new (). **/ plugin_signals[CONFIGURE_PLUGIN] = - g_signal_new (I_("configure-plugin"), + g_signal_new (g_intern_static_string ("configure-plugin"), G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (XfcePanelPluginClass, configure_plugin), @@ -232,7 +232,7 @@ xfce_panel_plugin_class_init (XfcePanelPluginClass *klass) * See also #XfceHVBox. **/ plugin_signals[FREE_DATA] = - g_signal_new (I_("free-data"), + g_signal_new (g_intern_static_string ("free-data"), G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (XfcePanelPluginClass, free_data), @@ -252,7 +252,7 @@ xfce_panel_plugin_class_init (XfcePanelPluginClass *klass) * See also: #XfceHVBox. **/ plugin_signals[ORIENTATION_CHANGED] = - g_signal_new (I_("orientation-changed"), + g_signal_new (g_intern_static_string ("orientation-changed"), G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (XfcePanelPluginClass, orientation_changed), @@ -278,7 +278,7 @@ xfce_panel_plugin_class_init (XfcePanelPluginClass *klass) * Since: 4.8 **/ plugin_signals[REMOVED] = - g_signal_new (I_("removed"), + g_signal_new (g_intern_static_string ("removed"), G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (XfcePanelPluginClass, removed), @@ -298,7 +298,7 @@ xfce_panel_plugin_class_init (XfcePanelPluginClass *klass) * See also: xfce_panel_plugin_save_location(). **/ plugin_signals[SAVE] = - g_signal_new (I_("save"), + g_signal_new (g_intern_static_string ("save"), G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (XfcePanelPluginClass, save), @@ -322,7 +322,7 @@ xfce_panel_plugin_class_init (XfcePanelPluginClass *klass) * g_signal_connect (plugin, "size-changed", G_CALLBACK (gtk_true), NULL); **/ plugin_signals[SIZE_CHANGED] = - g_signal_new (I_("size-changed"), + g_signal_new (g_intern_static_string ("size-changed"), G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (XfcePanelPluginClass, size_changed), @@ -340,7 +340,7 @@ xfce_panel_plugin_class_init (XfcePanelPluginClass *klass) * this signal to change the arrow direction of buttons. **/ plugin_signals[SCREEN_POSITION_CHANGED] = - g_signal_new (I_("screen-position-changed"), + g_signal_new (g_intern_static_string ("screen-position-changed"), G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (XfcePanelPluginClass, screen_position_changed), @@ -715,7 +715,7 @@ xfce_panel_plugin_button_press_event (GtkWidget *widget, gtk_menu_set_screen (menu, gtk_widget_get_screen (widget)); /* if the menu is block, some items are insensitive */ - item = g_object_get_data (G_OBJECT (menu), I_("properties-item")); + item = g_object_get_data (G_OBJECT (menu), g_intern_static_string ("properties-item")); gtk_widget_set_sensitive (item, plugin->priv->menu_blocked == 0); /* popup the menu */ @@ -881,7 +881,7 @@ xfce_panel_plugin_menu_get (XfcePanelPlugin *plugin) item = gtk_image_menu_item_new_from_stock (GTK_STOCK_PROPERTIES, NULL); g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (xfce_panel_plugin_show_configure), plugin); - g_object_set_data (G_OBJECT (menu), I_("properties-item"), item); + g_object_set_data (G_OBJECT (menu), g_intern_static_string ("properties-item"), item); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); if (PANEL_HAS_FLAG (plugin->priv->flags, PLUGIN_FLAG_SHOW_CONFIGURE)) gtk_widget_show (item); @@ -890,7 +890,7 @@ xfce_panel_plugin_menu_get (XfcePanelPlugin *plugin) item = gtk_image_menu_item_new_from_stock (GTK_STOCK_ABOUT, NULL); g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (xfce_panel_plugin_show_about), plugin); - g_object_set_data (G_OBJECT (menu), I_("about-item"), item); + g_object_set_data (G_OBJECT (menu), g_intern_static_string ("about-item"), item); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); if (PANEL_HAS_FLAG (plugin->priv->flags, PLUGIN_FLAG_SHOW_ABOUT)) gtk_widget_show (item); @@ -1511,7 +1511,7 @@ xfce_panel_plugin_menu_show_configure (XfcePanelPlugin *plugin) { /* get and show the properties item */ menu = xfce_panel_plugin_menu_get (plugin); - item = g_object_get_data (G_OBJECT (menu), I_("properties-item")); + item = g_object_get_data (G_OBJECT (menu), g_intern_static_string ("properties-item")); if (G_LIKELY (item)) gtk_widget_show (item); } @@ -1544,7 +1544,7 @@ xfce_panel_plugin_menu_show_about (XfcePanelPlugin *plugin) { /* get and show the about item */ menu = xfce_panel_plugin_menu_get (plugin); - item = g_object_get_data (G_OBJECT (menu), I_("about-item")); + item = g_object_get_data (G_OBJECT (menu), g_intern_static_string ("about-item")); if (G_LIKELY (item)) gtk_widget_show (item); } diff --git a/panel/main.c b/panel/main.c index 8d925f1d..f70c7e09 100644 --- a/panel/main.c +++ b/panel/main.c @@ -41,6 +41,7 @@ #include #include +#include #include #include #include diff --git a/panel/panel-dbus-client.c b/panel/panel-dbus-client.c index e1b9186e..4b9c6d48 100644 --- a/panel/panel-dbus-client.c +++ b/panel/panel-dbus-client.c @@ -22,6 +22,7 @@ #include #include +#include #include #include #include diff --git a/panel/panel-dbus-service.c b/panel/panel-dbus-service.c index a2068a00..1eb84413 100644 --- a/panel/panel-dbus-service.c +++ b/panel/panel-dbus-service.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -116,7 +117,7 @@ panel_dbus_service_class_init (PanelDBusServiceClass *klass) * Emitted when an external plugin property should be updated. **/ dbus_service_signals[PROPERTY_CHANGED] = - g_signal_new (I_("property-changed"), + g_signal_new (g_intern_static_string ("property-changed"), G_TYPE_FROM_CLASS (gobject_class), G_SIGNAL_RUN_LAST, 0, NULL, NULL, diff --git a/panel/panel-dialogs.c b/panel/panel-dialogs.c index f7b86e73..707857f6 100644 --- a/panel/panel-dialogs.c +++ b/panel/panel-dialogs.c @@ -26,6 +26,8 @@ #include #include + +#include #include #include diff --git a/panel/panel-itembar.c b/panel/panel-itembar.c index 1ae9b498..50903c22 100644 --- a/panel/panel-itembar.c +++ b/panel/panel-itembar.c @@ -22,6 +22,8 @@ #include #include + +#include #include #include @@ -154,7 +156,7 @@ panel_itembar_class_init (PanelItembarClass *klass) gtkcontainer_class->set_child_property = panel_itembar_set_child_property; itembar_signals[CHANGED] = - g_signal_new (I_("changed"), + g_signal_new (g_intern_static_string ("changed"), G_TYPE_FROM_CLASS (gobject_class), G_SIGNAL_RUN_LAST, 0, NULL, NULL, diff --git a/panel/panel-module-factory.c b/panel/panel-module-factory.c index cb619d4b..82e198bd 100644 --- a/panel/panel-module-factory.c +++ b/panel/panel-module-factory.c @@ -30,6 +30,9 @@ #include #include + +#include + #include #include @@ -95,7 +98,7 @@ panel_module_factory_class_init (PanelModuleFactoryClass *klass) * Emitted when the unique status of one of the modules changed. **/ factory_signals[UNIQUE_CHANGED] = - g_signal_new (I_("unique-changed"), + g_signal_new (g_intern_static_string ("unique-changed"), G_TYPE_FROM_CLASS (gobject_class), G_SIGNAL_RUN_LAST, 0, NULL, NULL, diff --git a/panel/panel-plugin-external.c b/panel/panel-plugin-external.c index 3850403c..601ca5eb 100644 --- a/panel/panel-plugin-external.c +++ b/panel/panel-plugin-external.c @@ -23,8 +23,11 @@ #include #include #include -#include #include + +#include +#include + #include #include diff --git a/panel/panel-preferences-dialog.c b/panel/panel-preferences-dialog.c index 814364af..5b93dd38 100644 --- a/panel/panel-preferences-dialog.c +++ b/panel/panel-preferences-dialog.c @@ -23,6 +23,9 @@ #include #include #include + +#include + #include #include diff --git a/plugins/actions/actions.c b/plugins/actions/actions.c index 60df52f8..3ddc88c8 100644 --- a/plugins/actions/actions.c +++ b/plugins/actions/actions.c @@ -24,9 +24,11 @@ #include #include #include +#include + +#include #include #include -#include #include "actions.h" #include "actions-dialog_ui.h" diff --git a/plugins/clock/clock.h b/plugins/clock/clock.h index 166345e2..cd223fd7 100644 --- a/plugins/clock/clock.h +++ b/plugins/clock/clock.h @@ -22,6 +22,7 @@ #include #include #include +#include G_BEGIN_DECLS diff --git a/plugins/pager/pager.c b/plugins/pager/pager.c index da647352..31799218 100644 --- a/plugins/pager/pager.c +++ b/plugins/pager/pager.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include diff --git a/plugins/separator/separator.c b/plugins/separator/separator.c index f72c1f22..da75d61a 100644 --- a/plugins/separator/separator.c +++ b/plugins/separator/separator.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include diff --git a/plugins/showdesktop/showdesktop.c b/plugins/showdesktop/showdesktop.c index b85815f9..a8c50fad 100644 --- a/plugins/showdesktop/showdesktop.c +++ b/plugins/showdesktop/showdesktop.c @@ -22,6 +22,7 @@ #endif #include +#include #include "showdesktop.h" diff --git a/plugins/systray/systray-manager.c b/plugins/systray/systray-manager.c index c218f23c..b4e40ec4 100644 --- a/plugins/systray/systray-manager.c +++ b/plugins/systray/systray-manager.c @@ -35,6 +35,8 @@ #include #include +#include + #include #include @@ -155,7 +157,7 @@ systray_manager_class_init (SystrayManagerClass *klass) gobject_class->finalize = systray_manager_finalize; systray_manager_signals[ICON_ADDED] = - g_signal_new (I_("icon-added"), + g_signal_new (g_intern_static_string ("icon-added"), G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, @@ -164,7 +166,7 @@ systray_manager_class_init (SystrayManagerClass *klass) GTK_TYPE_SOCKET); systray_manager_signals[ICON_REMOVED] = - g_signal_new (I_("icon-removed"), + g_signal_new (g_intern_static_string ("icon-removed"), G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, @@ -173,7 +175,7 @@ systray_manager_class_init (SystrayManagerClass *klass) GTK_TYPE_SOCKET); systray_manager_signals[MESSAGE_SENT] = - g_signal_new (I_("message-sent"), + g_signal_new (g_intern_static_string ("message-sent"), G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, @@ -185,7 +187,7 @@ systray_manager_class_init (SystrayManagerClass *klass) G_TYPE_LONG); systray_manager_signals[MESSAGE_CANCELLED] = - g_signal_new (I_("message-cancelled"), + g_signal_new (g_intern_static_string ("message-cancelled"), G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, @@ -195,7 +197,7 @@ systray_manager_class_init (SystrayManagerClass *klass) G_TYPE_LONG); systray_manager_signals[LOST_SELECTION] = - g_signal_new (I_("lost-selection"), + g_signal_new (g_intern_static_string ("lost-selection"), G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, diff --git a/plugins/systray/systray-socket.c b/plugins/systray/systray-socket.c index b9d299a1..a37acb59 100644 --- a/plugins/systray/systray-socket.c +++ b/plugins/systray/systray-socket.c @@ -35,6 +35,7 @@ #include #include +#include #include "systray-socket.h" diff --git a/plugins/tasklist/tasklist.c b/plugins/tasklist/tasklist.c index a66e34f3..08449743 100644 --- a/plugins/tasklist/tasklist.c +++ b/plugins/tasklist/tasklist.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include "tasklist-widget.h" diff --git a/wrapper/wrapper-module.c b/wrapper/wrapper-module.c index 632438fa..b08be16d 100644 --- a/wrapper/wrapper-module.c +++ b/wrapper/wrapper-module.c @@ -24,6 +24,7 @@ #include #endif +#include #include