[nautilus/wip/coreyberla/window-dispose: 5/7] toolbar: Drop :window property




commit 48ddf1cc93d180469a545470115aafe01e17955c
Author: António Fernandes <antoniof gnome org>
Date:   Thu Sep 1 21:10:47 2022 +0100

    toolbar: Drop :window property
    
    Toolbar holds a reference to the window, which owns the toolbar.
    
    This reference cycle is problematic, so drop the property and just
    peek the window by walking up the hierarchy.
    
    Long term we should just dismantle NautilusToolbar completely, by
    moving most logic to each their respective control and manage
    everything from NautilusWindow.

 src/nautilus-toolbar.c | 20 +++++---------------
 src/nautilus-window.c  |  3 ---
 2 files changed, 5 insertions(+), 18 deletions(-)
---
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
index 4c1eb8cae..aad0fd3d0 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -72,7 +72,7 @@ struct _NautilusToolbar
 
 enum
 {
-    PROP_WINDOW = 1,
+    PROP_0,
     PROP_SHOW_LOCATION_ENTRY,
     PROP_WINDOW_SLOT,
     PROP_SEARCHING,
@@ -117,10 +117,13 @@ update_action (NautilusToolbar *self,
                const char      *action_name,
                gboolean         enabled)
 {
+    GtkWidget *window;
     GAction *action;
 
+    window = gtk_widget_get_ancestor (GTK_WIDGET (self), NAUTILUS_TYPE_WINDOW);
+
     /* Activate/deactivate */
-    action = g_action_map_lookup_action (G_ACTION_MAP (self->window), action_name);
+    action = g_action_map_lookup_action (G_ACTION_MAP (window), action_name);
     g_simple_action_set_enabled (G_SIMPLE_ACTION (action), enabled);
 }
 
@@ -355,12 +358,6 @@ nautilus_toolbar_set_property (GObject      *object,
 
     switch (property_id)
     {
-        case PROP_WINDOW:
-        {
-            self->window = g_value_get_object (value);
-        }
-        break;
-
         case PROP_SHOW_LOCATION_ENTRY:
         {
             nautilus_toolbar_set_show_location_entry (self, g_value_get_boolean (value));
@@ -451,13 +448,6 @@ nautilus_toolbar_class_init (NautilusToolbarClass *klass)
     oclass->finalize = nautilus_toolbar_finalize;
     oclass->constructed = nautilus_toolbar_constructed;
 
-    properties[PROP_WINDOW] =
-        g_param_spec_object ("window",
-                             "The NautilusWindow",
-                             "The NautilusWindow this toolbar is part of",
-                             NAUTILUS_TYPE_WINDOW,
-                             G_PARAM_WRITABLE |
-                             G_PARAM_STATIC_STRINGS);
     properties[PROP_SHOW_LOCATION_ENTRY] =
         g_param_spec_boolean ("show-location-entry",
                               "Whether to show the location entry",
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index f1e1e341a..51a7db0de 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -1350,9 +1350,6 @@ setup_toolbar (NautilusWindow *window)
     GtkWidget *path_bar;
     GtkWidget *location_entry;
 
-
-    g_object_set (window->toolbar, "window", window, NULL);
-
     /* connect to the pathbar signals */
     path_bar = nautilus_toolbar_get_path_bar (NAUTILUS_TOOLBAR (window->toolbar));
 


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