[nautilus/wip/antoniof/new-list-view-continuation: 11/19] view-icon-controller: Use g_signal_connect_object()




commit a9da690938262440c0e88162553521e6dc079bc0
Author: António Fernandes <antoniof gnome org>
Date:   Wed Apr 6 00:58:35 2022 +0100

    view-icon-controller: Use g_signal_connect_object()
    
    I forgot to disconnect from the clipboard signal.
    
    Let's use the _object() variant everywhere to make sure the signals are
    disconnected when the view goes away.

 src/nautilus-view-icon-controller.c | 41 +++++++++++++++++++------------------
 1 file changed, 21 insertions(+), 20 deletions(-)
---
diff --git a/src/nautilus-view-icon-controller.c b/src/nautilus-view-icon-controller.c
index 3020d77ca..87a7ebc2c 100644
--- a/src/nautilus-view-icon-controller.c
+++ b/src/nautilus-view-icon-controller.c
@@ -1254,8 +1254,6 @@ dispose (GObject *object)
     g_clear_handle_id (&self->scroll_to_file_handle_id, g_source_remove);
     g_clear_handle_id (&self->prioritize_thumbnailing_handle_id, g_source_remove);
 
-    g_signal_handlers_disconnect_by_data (nautilus_preferences, self);
-
     G_OBJECT_CLASS (nautilus_view_icon_controller_parent_class)->dispose (object);
 }
 
@@ -1581,30 +1579,33 @@ nautilus_view_icon_controller_class_init (NautilusViewIconControllerClass *klass
 static void
 nautilus_view_icon_controller_init (NautilusViewIconController *self)
 {
-    GdkClipboard *clipboard;
-
     gtk_widget_add_css_class (GTK_WIDGET (self), "view");
     gtk_widget_add_css_class (GTK_WIDGET (self), "nautilus-grid-view");
     set_click_mode_from_settings (self);
 
-    g_signal_connect_swapped (nautilus_preferences,
-                              "changed::" NAUTILUS_PREFERENCES_DEFAULT_SORT_ORDER,
-                              G_CALLBACK (on_default_sort_order_changed),
-                              self);
-    g_signal_connect_swapped (nautilus_preferences,
-                              "changed::" NAUTILUS_PREFERENCES_DEFAULT_SORT_IN_REVERSE_ORDER,
-                              G_CALLBACK (on_default_sort_order_changed),
-                              self);
+    g_signal_connect_object (nautilus_preferences,
+                             "changed::" NAUTILUS_PREFERENCES_DEFAULT_SORT_ORDER,
+                             G_CALLBACK (on_default_sort_order_changed),
+                             self,
+                             G_CONNECT_SWAPPED);
+    g_signal_connect_object (nautilus_preferences,
+                             "changed::" NAUTILUS_PREFERENCES_DEFAULT_SORT_IN_REVERSE_ORDER,
+                             G_CALLBACK (on_default_sort_order_changed),
+                             self,
+                             G_CONNECT_SWAPPED);
 
     set_captions_from_preferences (self);
-    g_signal_connect_swapped (nautilus_icon_view_preferences,
-                              "changed::" NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS,
-                              G_CALLBACK (on_captions_preferences_changed),
-                              self);
-
-    clipboard = gdk_display_get_clipboard (gdk_display_get_default ());
-    g_signal_connect_object (clipboard, "changed",
-                             G_CALLBACK (on_clipboard_owner_changed), self, 0);
+    g_signal_connect_object (nautilus_icon_view_preferences,
+                             "changed::" NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS,
+                             G_CALLBACK (on_captions_preferences_changed),
+                             self,
+                             G_CONNECT_SWAPPED);
+
+    g_signal_connect_object (gdk_display_get_clipboard (gdk_display_get_default ()),
+                             "changed",
+                             G_CALLBACK (on_clipboard_owner_changed),
+                             self,
+                             0);
 }
 
 NautilusViewIconController *


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