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




commit 88a1ea2c9d4cb601722394ed826310bbbfa82c52
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 30fce4789..0da09dc83 100644
--- a/src/nautilus-view-icon-controller.c
+++ b/src/nautilus-view-icon-controller.c
@@ -1291,8 +1291,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);
 }
 
@@ -1611,30 +1609,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]