summaryrefslogtreecommitdiff
path: root/src
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 /src
parent11d56d5d0e8e3ccb7798cd3aac4ade4c2e066a1c (diff)
downloadeom-23748971577ddff3731eab86de92f367c598cb70.tar.bz2
eom-23748971577ddff3731eab86de92f367c598cb70.tar.xz
Use GLib's new g_clear_signal_handler() function to simplify code
Diffstat (limited to 'src')
-rw-r--r--src/eom-metadata-sidebar.c5
-rw-r--r--src/eom-scroll-view.c13
-rw-r--r--src/eom-thumb-view.c25
3 files changed, 30 insertions, 13 deletions
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);
}