summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrbuj <[email protected]>2021-10-25 00:28:08 +0200
committerLuke from DC <[email protected]>2022-09-11 17:51:44 +0000
commit23748971577ddff3731eab86de92f367c598cb70 (patch)
tree784201ccdf344e318016211689e5ca67c404a30e
parent11d56d5d0e8e3ccb7798cd3aac4ade4c2e066a1c (diff)
downloadeom-23748971577ddff3731eab86de92f367c598cb70.tar.bz2
eom-23748971577ddff3731eab86de92f367c598cb70.tar.xz
Use GLib's new g_clear_signal_handler() function to simplify code
-rw-r--r--plugins/fullscreen/eom-fullscreen-plugin.c12
-rw-r--r--plugins/statusbar-date/eom-statusbar-date-plugin.c9
-rw-r--r--src/eom-metadata-sidebar.c5
-rw-r--r--src/eom-scroll-view.c13
-rw-r--r--src/eom-thumb-view.c25
5 files changed, 47 insertions, 17 deletions
diff --git a/plugins/fullscreen/eom-fullscreen-plugin.c b/plugins/fullscreen/eom-fullscreen-plugin.c
index 653a725..b2565a1 100644
--- a/plugins/fullscreen/eom-fullscreen-plugin.c
+++ b/plugins/fullscreen/eom-fullscreen-plugin.c
@@ -119,8 +119,7 @@ eom_fullscreen_plugin_activate (EomWindowActivatable *activatable)
eom_debug (DEBUG_PLUGINS);
- plugin->signal_id = g_signal_connect (G_OBJECT (view),
- "button-press-event",
+ plugin->signal_id = g_signal_connect (view, "button-press-event",
G_CALLBACK (on_button_press),
plugin->window);
}
@@ -131,7 +130,14 @@ eom_fullscreen_plugin_deactivate (EomWindowActivatable *activatable)
EomFullscreenPlugin *plugin = EOM_FULLSCREEN_PLUGIN (activatable);
GtkWidget *view = eom_window_get_view (plugin->window);
- g_signal_handler_disconnect (view, plugin->signal_id);
+#if GLIB_CHECK_VERSION(2,62,0)
+ g_clear_signal_handler (&plugin->signal_id, view);
+#else
+ if (plugin->signal_id != 0) {
+ g_signal_handler_disconnect (view, plugin->signal_id);
+ plugin->signal_id = 0;
+ }
+#endif
}
static void
diff --git a/plugins/statusbar-date/eom-statusbar-date-plugin.c b/plugins/statusbar-date/eom-statusbar-date-plugin.c
index 81b65f2..322277d 100644
--- a/plugins/statusbar-date/eom-statusbar-date-plugin.c
+++ b/plugins/statusbar-date/eom-statusbar-date-plugin.c
@@ -195,7 +195,14 @@ eom_statusbar_date_plugin_deactivate (EomWindowActivatable *activatable)
GtkWidget *statusbar = eom_window_get_statusbar (window);
GtkWidget *view = eom_window_get_thumb_view (window);
- g_signal_handler_disconnect (view, plugin->signal_id);
+#if GLIB_CHECK_VERSION(2,62,0)
+ g_clear_signal_handler (&plugin->signal_id, view);
+#else
+ if (plugin->signal_id != 0) {
+ g_signal_handler_disconnect (view, plugin->signal_id);
+ plugin->signal_id = 0;
+ }
+#endif
gtk_container_remove (GTK_CONTAINER (statusbar), plugin->statusbar_date);
}
diff --git a/src/eom-metadata-sidebar.c b/src/eom-metadata-sidebar.c
index 982a937..9b8fc8b 100644
--- a/src/eom-metadata-sidebar.c
+++ b/src/eom-metadata-sidebar.c
@@ -263,11 +263,16 @@ eom_metadata_sidebar_set_image (EomMetadataSidebar *sidebar, EomImage *image)
if (image == priv->image)
return;
+#if GLIB_CHECK_VERSION(2,62,0)
+ g_clear_signal_handler (&priv->thumb_changed_id,
+ priv->image);
+#else
if (priv->thumb_changed_id != 0) {
g_signal_handler_disconnect (priv->image,
priv->thumb_changed_id);
priv->thumb_changed_id = 0;
}
+#endif
if (priv->image)
g_object_unref (priv->image);
diff --git a/src/eom-scroll-view.c b/src/eom-scroll-view.c
index 24a1f0f..3fc64d4 100644
--- a/src/eom-scroll-view.c
+++ b/src/eom-scroll-view.c
@@ -87,8 +87,8 @@ struct _EomScrollViewPrivate {
/* actual image */
EomImage *image;
- guint image_changed_id;
- guint frame_changed_id;
+ gulong image_changed_id;
+ gulong frame_changed_id;
GdkPixbuf *pixbuf;
cairo_surface_t *surface;
@@ -188,15 +188,20 @@ free_image_resources (EomScrollView *view)
priv = view->priv;
- if (priv->image_changed_id > 0) {
+#if GLIB_CHECK_VERSION(2,62,0)
+ g_clear_signal_handler (&priv->image_changed_id, priv->image);
+ g_clear_signal_handler (&priv->frame_changed_id, priv->image);
+#else
+ if (priv->image_changed_id != 0) {
g_signal_handler_disconnect (priv->image, priv->image_changed_id);
priv->image_changed_id = 0;
}
- if (priv->frame_changed_id > 0) {
+ if (priv->frame_changed_id != 0) {
g_signal_handler_disconnect (priv->image, priv->frame_changed_id);
priv->frame_changed_id = 0;
}
+#endif
if (priv->image != NULL) {
eom_image_data_unref (priv->image);
diff --git a/src/eom-thumb-view.c b/src/eom-thumb-view.c
index 3a2ddf4..0b28440 100644
--- a/src/eom-thumb-view.c
+++ b/src/eom-thumb-view.c
@@ -78,7 +78,7 @@ struct _EomThumbViewPrivate {
gint end_thumb; /* the last visible thumbnail */
GtkWidget *menu; /* a contextual menu for thumbnails */
GtkCellRenderer *pixbuf_cell;
- gint visible_range_changed_id;
+ guint visible_range_changed_id;
GtkOrientation orientation;
gint n_images;
@@ -167,17 +167,24 @@ eom_thumb_view_dispose (GObject *object)
priv->visible_range_changed_id = 0;
}
- model = gtk_icon_view_get_model (GTK_ICON_VIEW (object));
-
- if (model && priv->image_add_id != 0) {
- g_signal_handler_disconnect (model, priv->image_add_id);
- priv->image_add_id = 0;
+#if GLIB_CHECK_VERSION(2,62,0)
+ if ((model = gtk_icon_view_get_model (GTK_ICON_VIEW (object))) != NULL) {
+ g_clear_signal_handler (&priv->image_add_id, model);
+ g_clear_signal_handler (&priv->image_removed_id, model);
}
+#else
+ if ((model = gtk_icon_view_get_model (GTK_ICON_VIEW (object))) != NULL) {
+ if (priv->image_add_id != 0) {
+ g_signal_handler_disconnect (model, priv->image_add_id);
+ priv->image_add_id = 0;
+ }
- if (model && priv->image_removed_id) {
- g_signal_handler_disconnect (model, priv->image_removed_id);
- priv->image_removed_id = 0;
+ if (priv->image_removed_id != 0) {
+ g_signal_handler_disconnect (model, priv->image_removed_id);
+ priv->image_removed_id = 0;
+ }
}
+#endif
G_OBJECT_CLASS (eom_thumb_view_parent_class)->dispose (object);
}