diff options
-rw-r--r-- | applets/clock/clock-location-tile.c | 12 | ||||
-rw-r--r-- | mate-panel/panel-menu-items.c | 144 | ||||
-rw-r--r-- | mate-panel/panel-toplevel.c | 38 |
3 files changed, 89 insertions, 105 deletions
diff --git a/applets/clock/clock-location-tile.c b/applets/clock/clock-location-tile.c index b70f467c..4d0fc217 100644 --- a/applets/clock/clock-location-tile.c +++ b/applets/clock/clock-location-tile.c @@ -140,8 +140,16 @@ clock_location_tile_finalize (GObject *g_obj) priv = clock_location_tile_get_instance_private (this); if (priv->location) { - g_signal_handler_disconnect (priv->location, priv->location_weather_updated_id); - priv->location_weather_updated_id = 0; +#if GLIB_CHECK_VERSION(2,62,0) + g_clear_signal_handler (&priv->location_weather_updated_id, + priv->location); +#else + if (priv->location_weather_updated_id != 0) { + g_signal_handler_disconnect (priv->location, + priv->location_weather_updated_id); + priv->location_weather_updated_id = 0; + } +#endif g_clear_object (&priv->location); } diff --git a/mate-panel/panel-menu-items.c b/mate-panel/panel-menu-items.c index 785acee4..dfa3d7ce 100644 --- a/mate-panel/panel-menu-items.c +++ b/mate-panel/panel-menu-items.c @@ -59,6 +59,7 @@ #include "panel-schemas.h" #define MAX_BOOKMARK_ITEMS 100 +#define N_MENU_ITEM_SIGNALS 9 struct _PanelPlaceMenuItemPrivate { GtkWidget *menu; @@ -73,15 +74,7 @@ struct _PanelPlaceMenuItemPrivate { GFileMonitor *bookmarks_monitor; GVolumeMonitor *volume_monitor; - gulong drive_changed_id; - gulong drive_connected_id; - gulong drive_disconnected_id; - gulong volume_added_id; - gulong volume_changed_id; - gulong volume_removed_id; - gulong mount_added_id; - gulong mount_changed_id; - gulong mount_removed_id; + gulong signal_id [N_MENU_ITEM_SIGNALS]; guint use_image : 1; }; @@ -1264,6 +1257,7 @@ static void panel_place_menu_item_finalize (GObject *object) { PanelPlaceMenuItem *menuitem = (PanelPlaceMenuItem *) object; + guint i; g_clear_object (&menuitem->priv->caja_desktop_settings); g_clear_object (&menuitem->priv->caja_prefs_settings); @@ -1274,50 +1268,18 @@ panel_place_menu_item_finalize (GObject *object) g_clear_object (&menuitem->priv->bookmarks_monitor); } - if (menuitem->priv->drive_changed_id) - g_signal_handler_disconnect (menuitem->priv->volume_monitor, - menuitem->priv->drive_changed_id); - menuitem->priv->drive_changed_id = 0; - - if (menuitem->priv->drive_connected_id) - g_signal_handler_disconnect (menuitem->priv->volume_monitor, - menuitem->priv->drive_connected_id); - menuitem->priv->drive_connected_id = 0; - - if (menuitem->priv->drive_disconnected_id) - g_signal_handler_disconnect (menuitem->priv->volume_monitor, - menuitem->priv->drive_disconnected_id); - menuitem->priv->drive_disconnected_id = 0; - - if (menuitem->priv->volume_added_id) - g_signal_handler_disconnect (menuitem->priv->volume_monitor, - menuitem->priv->volume_added_id); - menuitem->priv->volume_added_id = 0; - - if (menuitem->priv->volume_changed_id) - g_signal_handler_disconnect (menuitem->priv->volume_monitor, - menuitem->priv->volume_changed_id); - menuitem->priv->volume_changed_id = 0; - - if (menuitem->priv->volume_removed_id) - g_signal_handler_disconnect (menuitem->priv->volume_monitor, - menuitem->priv->volume_removed_id); - menuitem->priv->volume_removed_id = 0; - - if (menuitem->priv->mount_added_id) - g_signal_handler_disconnect (menuitem->priv->volume_monitor, - menuitem->priv->mount_added_id); - menuitem->priv->mount_added_id = 0; - - if (menuitem->priv->mount_changed_id) - g_signal_handler_disconnect (menuitem->priv->volume_monitor, - menuitem->priv->mount_changed_id); - menuitem->priv->mount_changed_id = 0; - - if (menuitem->priv->mount_removed_id) - g_signal_handler_disconnect (menuitem->priv->volume_monitor, - menuitem->priv->mount_removed_id); - menuitem->priv->mount_removed_id = 0; + for (i = 0; i < N_MENU_ITEM_SIGNALS; i++) { +#if GLIB_CHECK_VERSION(2,62,0) + g_clear_signal_handler (&menuitem->priv->signal_id [i], + menuitem->priv->volume_monitor); +#else + if (menuitem->priv->signal_id [i] != 0) { + g_signal_handler_disconnect (menuitem->priv->volume_monitor, + menuitem->priv->signal_id [i]); + menuitem->priv->signal_id [i] = 0; + } +#endif + } g_clear_object (&menuitem->priv->volume_monitor); @@ -1341,6 +1303,7 @@ panel_place_menu_item_init (PanelPlaceMenuItem *menuitem) GFile *bookmark; char *bookmarks_filename; GError *error; + guint i; menuitem->priv = panel_place_menu_item_get_instance_private (menuitem); @@ -1406,42 +1369,45 @@ panel_place_menu_item_init (PanelPlaceMenuItem *menuitem) menuitem->priv->volume_monitor = g_volume_monitor_get (); - menuitem->priv->drive_changed_id = g_signal_connect (menuitem->priv->volume_monitor, - "drive-changed", - G_CALLBACK (panel_place_menu_item_drives_changed), - menuitem); - menuitem->priv->drive_connected_id = g_signal_connect (menuitem->priv->volume_monitor, - "drive-connected", - G_CALLBACK (panel_place_menu_item_drives_changed), - menuitem); - menuitem->priv->drive_disconnected_id = g_signal_connect (menuitem->priv->volume_monitor, - "drive-disconnected", - G_CALLBACK (panel_place_menu_item_drives_changed), - menuitem); - menuitem->priv->volume_added_id = g_signal_connect (menuitem->priv->volume_monitor, - "volume-added", - G_CALLBACK (panel_place_menu_item_volumes_changed), - menuitem); - menuitem->priv->volume_changed_id = g_signal_connect (menuitem->priv->volume_monitor, - "volume-changed", - G_CALLBACK (panel_place_menu_item_volumes_changed), - menuitem); - menuitem->priv->volume_removed_id = g_signal_connect (menuitem->priv->volume_monitor, - "volume-removed", - G_CALLBACK (panel_place_menu_item_volumes_changed), - menuitem); - menuitem->priv->mount_added_id = g_signal_connect (menuitem->priv->volume_monitor, - "mount-added", - G_CALLBACK (panel_place_menu_item_mounts_changed), - menuitem); - menuitem->priv->mount_changed_id = g_signal_connect (menuitem->priv->volume_monitor, - "mount-changed", - G_CALLBACK (panel_place_menu_item_mounts_changed), - menuitem); - menuitem->priv->mount_removed_id = g_signal_connect (menuitem->priv->volume_monitor, - "mount-removed", - G_CALLBACK (panel_place_menu_item_mounts_changed), - menuitem); + i = 0; + menuitem->priv->signal_id [i++] = + g_signal_connect (menuitem->priv->volume_monitor, "drive-changed", + G_CALLBACK (panel_place_menu_item_drives_changed), + menuitem); + menuitem->priv->signal_id [i++] = + g_signal_connect (menuitem->priv->volume_monitor, "drive-connected", + G_CALLBACK (panel_place_menu_item_drives_changed), + menuitem); + menuitem->priv->signal_id [i++] = + g_signal_connect (menuitem->priv->volume_monitor, "drive-disconnected", + G_CALLBACK (panel_place_menu_item_drives_changed), + menuitem); + menuitem->priv->signal_id [i++] = + g_signal_connect (menuitem->priv->volume_monitor, "volume-added", + G_CALLBACK (panel_place_menu_item_volumes_changed), + menuitem); + menuitem->priv->signal_id [i++] = + g_signal_connect (menuitem->priv->volume_monitor, "volume-changed", + G_CALLBACK (panel_place_menu_item_volumes_changed), + menuitem); + menuitem->priv->signal_id [i++] = + g_signal_connect (menuitem->priv->volume_monitor, "volume-removed", + G_CALLBACK (panel_place_menu_item_volumes_changed), + menuitem); + menuitem->priv->signal_id [i++] = + g_signal_connect (menuitem->priv->volume_monitor, "mount-added", + G_CALLBACK (panel_place_menu_item_mounts_changed), + menuitem); + menuitem->priv->signal_id [i++] = + g_signal_connect (menuitem->priv->volume_monitor, "mount-changed", + G_CALLBACK (panel_place_menu_item_mounts_changed), + menuitem); + menuitem->priv->signal_id [i++] = + g_signal_connect (menuitem->priv->volume_monitor, "mount-removed", + G_CALLBACK (panel_place_menu_item_mounts_changed), + menuitem); + + g_assert (i == N_MENU_ITEM_SIGNALS); } diff --git a/mate-panel/panel-toplevel.c b/mate-panel/panel-toplevel.c index c6f19c0b..4930a3c3 100644 --- a/mate-panel/panel-toplevel.c +++ b/mate-panel/panel-toplevel.c @@ -2661,27 +2661,37 @@ panel_toplevel_reverse_arrows (PanelToplevel *toplevel) static void panel_toplevel_disconnect_attached (PanelToplevel *toplevel) { - int i; + guint i; +#if GLIB_CHECK_VERSION(2,62,0) for (i = 0; i < N_ATTACH_TOPLEVEL_SIGNALS; i++) { - if (!toplevel->priv->attach_toplevel_signals [i]) - continue; - - g_signal_handler_disconnect ( - toplevel->priv->attach_toplevel, - toplevel->priv->attach_toplevel_signals [i]); - toplevel->priv->attach_toplevel_signals [i] = 0; + g_clear_signal_handler (&toplevel->priv->attach_toplevel_signals [i], + toplevel->priv->attach_toplevel); } for (i = 0; i < N_ATTACH_WIDGET_SIGNALS; i++) { - if (!toplevel->priv->attach_widget_signals [i]) - continue; + g_clear_signal_handler (&toplevel->priv->attach_widget_signals [i], + toplevel->priv->attach_widget); + } +#else + for (i = 0; i < N_ATTACH_TOPLEVEL_SIGNALS; i++) { + if (toplevel->priv->attach_toplevel_signals [i] != 0) { + g_signal_handler_disconnect (toplevel->priv->attach_toplevel, + toplevel->priv->attach_toplevel_signals [i]); + toplevel->priv->attach_toplevel_signals [i] = 0; + } + } - g_signal_handler_disconnect ( - toplevel->priv->attach_widget, - toplevel->priv->attach_widget_signals [i]); - toplevel->priv->attach_widget_signals [i] = 0; + for (i = 0; i < N_ATTACH_WIDGET_SIGNALS; i++) { + g_clear_signal_handler (&toplevel->priv->attach_widget_signals [i], + toplevel->priv->attach_widget); + if (toplevel->priv->attach_widget_signals [i] != 0) { + g_signal_handler_disconnect (toplevel->priv->attach_widget, + toplevel->priv->attach_widget_signals [i]); + toplevel->priv->attach_widget_signals [i] = 0; + } } +#endif } static void |