summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrbuj <[email protected]>2021-10-25 00:28:08 +0200
committerrbuj <[email protected]>2021-10-25 00:28:08 +0200
commit2db36fae3cdb572828e6ceb00fa4d8164916d68a (patch)
tree5a0a980255a0bf2bd240399f76d2744088f41125
parent87d115e7d125929b3f1b380b756f7d16c85a1f49 (diff)
downloadeom-g_clear_signal_handler.tar.bz2
eom-g_clear_signal_handler.tar.xz
Use GLib's new g_clear_signal_handler() function to simplify codeg_clear_signal_handler
-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.c6
-rw-r--r--src/eom-scroll-view.c13
-rw-r--r--src/eom-thumb-view.c25
5 files changed, 47 insertions, 18 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 ba31937..8c93222 100644
--- a/src/eom-metadata-sidebar.c
+++ b/src/eom-metadata-sidebar.c
@@ -263,12 +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 f35e022..427f106 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 bc1184e..b021da3 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);
}