[devhelp/wip/swilmet/misc: 3/13] window: use g_signal_connect_object()



commit 8df6b36c3d223499331fc7a2e65d8a7df7ba1914
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sun Nov 15 15:09:20 2015 +0100

    window: use g_signal_connect_object()
    
    For the "screen-changed" signal, a later commit will change it to
    override the class pointer in class_init(), since the signal is
    connected on its own object (and so it was also useless to disconnect
    the signal by hand, since when the object is destroyed, it's more
    difficult for it to still send signals...).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=758141

 src/dh-window.c |   31 ++++++++++---------------------
 1 files changed, 10 insertions(+), 21 deletions(-)
---
diff --git a/src/dh-window.c b/src/dh-window.c
index b65dca3..bfc597c 100644
--- a/src/dh-window.c
+++ b/src/dh-window.c
@@ -55,8 +55,6 @@ typedef struct {
         DhLink         *selected_search_link;
         DhSettings     *settings;
         GtkSettings    *gtk_settings;
-        guint           fonts_changed_id;
-        gulong          screen_changed_id;
         gulong          xft_dpi_changed_id;
 
 } DhWindowPrivate;
@@ -609,14 +607,17 @@ dh_window_init (DhWindow *window)
 
         /* handle settings */
         priv->settings = dh_settings_get ();
-        priv->fonts_changed_id = g_signal_connect (priv->settings,
-                                                   "fonts-changed",
-                                                   G_CALLBACK (settings_fonts_changed_cb),
-                                                   window);
+        g_signal_connect_object (priv->settings,
+                                 "fonts-changed",
+                                 G_CALLBACK (settings_fonts_changed_cb),
+                                 window,
+                                 0);
+
         /* monitor GdkScreen and GtkSettings for DPI changes */
-        priv->screen_changed_id =
-                g_signal_connect (window, "screen-changed",
-                                  G_CALLBACK (screen_changed_cb), NULL);
+        g_signal_connect (window,
+                          "screen-changed",
+                          G_CALLBACK (screen_changed_cb),
+                          NULL);
 
         /* we can't get the GdkScreen for the widget here, so get the
          * GtkSettings associated to the default one instead for now */
@@ -656,18 +657,6 @@ dh_window_dispose (GObject *object)
 
         priv = dh_window_get_instance_private (window);
 
-        if (priv->fonts_changed_id) {
-                if (priv->settings && g_signal_handler_is_connected (priv->settings, priv->fonts_changed_id))
-                        g_signal_handler_disconnect (priv->settings, priv->fonts_changed_id);
-                priv->fonts_changed_id = 0;
-        }
-
-        if (priv->screen_changed_id) {
-                if (g_signal_handler_is_connected (window, priv->screen_changed_id))
-                        g_signal_handler_disconnect (window, priv->screen_changed_id);
-                priv->screen_changed_id = 0;
-        }
-
         if (priv->xft_dpi_changed_id) {
                 if (priv->gtk_settings != NULL && g_signal_handler_is_connected (priv->gtk_settings, 
priv->xft_dpi_changed_id))
                         g_signal_handler_disconnect (priv->gtk_settings, priv->xft_dpi_changed_id);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]