[nautilus/wip/antoniof/gtk4-preparation-placessidebar: 2/2] window: Construct the sidebar from code




commit 29592d68e9752f1bfb03b10998bc9bce26ada109
Author: António Fernandes <antoniof gnome org>
Date:   Tue Dec 14 02:05:49 2021 +0000

    window: Construct the sidebar from code
    
    Our in-tree places sidebar cannot be used in a GtkBuilder UI template.
    
    Construct it from code to allow this app to run again.

 src/nautilus-window.c               | 25 +++++++++++++++++++++----
 src/resources/ui/nautilus-window.ui | 11 -----------
 2 files changed, 21 insertions(+), 15 deletions(-)
---
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index f3f778f93..df48f7158 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -2688,6 +2688,27 @@ nautilus_window_init (NautilusWindow *window)
     g_type_ensure (NAUTILUS_TYPE_NOTEBOOK);
     gtk_widget_init_template (GTK_WIDGET (window));
 
+    window->places_sidebar = nautilus_gtk_places_sidebar_new ();
+    g_object_set (window->places_sidebar,
+                  "vexpand", TRUE,
+                  "visible", TRUE,
+                  "populate-all", TRUE,
+                  "show-other-locations", TRUE,
+                  "show-starred-location", TRUE,
+                  NULL);
+    gtk_box_append (GTK_BOX (window->sidebar), window->places_sidebar);
+
+    g_signal_connect_object (window->places_sidebar,
+                             "show-other-locations-with-flags",
+                             G_CALLBACK (places_sidebar_show_other_locations_with_flags),
+                             window,
+                             G_CONNECT_SWAPPED);
+    g_signal_connect_object (window->places_sidebar,
+                             "show-starred-location",
+                             G_CALLBACK (places_sidebar_show_starred_location),
+                             window,
+                             G_CONNECT_SWAPPED);
+
     g_signal_connect (window, "notify::is-maximized",
                       G_CALLBACK (on_is_maximized_changed), NULL);
 
@@ -2752,7 +2773,6 @@ nautilus_window_class_init (NautilusWindowClass *class)
     gtk_widget_class_bind_template_child (wclass, NautilusWindow, toolbar);
     gtk_widget_class_bind_template_child (wclass, NautilusWindow, content_paned);
     gtk_widget_class_bind_template_child (wclass, NautilusWindow, sidebar);
-    gtk_widget_class_bind_template_child (wclass, NautilusWindow, places_sidebar);
     gtk_widget_class_bind_template_child (wclass, NautilusWindow, main_view);
     gtk_widget_class_bind_template_child (wclass, NautilusWindow, notebook);
     gtk_widget_class_bind_template_child (wclass, NautilusWindow, in_app_notification_undo);
@@ -2764,9 +2784,6 @@ nautilus_window_class_init (NautilusWindowClass *class)
     gtk_widget_class_bind_template_child (wclass, NautilusWindow, notification_operation_open);
     gtk_widget_class_bind_template_child (wclass, NautilusWindow, notification_operation_close);
 
-    gtk_widget_class_bind_template_callback (wclass, places_sidebar_show_other_locations_with_flags);
-    gtk_widget_class_bind_template_callback (wclass, places_sidebar_show_starred_location);
-
     signals[SLOT_ADDED] =
         g_signal_new ("slot-added",
                       G_TYPE_FROM_CLASS (class),
diff --git a/src/resources/ui/nautilus-window.ui b/src/resources/ui/nautilus-window.ui
index a5f9bd641..407014ecc 100644
--- a/src/resources/ui/nautilus-window.ui
+++ b/src/resources/ui/nautilus-window.ui
@@ -20,17 +20,6 @@
                 <property name="visible">False</property>
                 <property name="orientation">vertical</property>
                 <property name="spacing">6</property>
-                <child>
-                  <object class="NautilusGtkPlacesSidebar" id="places_sidebar">
-                    <property name="vexpand">True</property>
-                    <property name="visible">True</property>
-                    <property name="populate-all">True</property>
-                    <property name="show-other-locations">True</property>
-                    <property name="show-starred-location">True</property>
-                    <signal name="show-other-locations-with-flags" 
handler="places_sidebar_show_other_locations_with_flags" object="NautilusWindow" swapped="yes" />
-                    <signal name="show-starred-location" handler="places_sidebar_show_starred_location" 
object="NautilusWindow" swapped="yes" />
-                  </object>
-                </child>
               </object>
               <packing>
                <property name="resize">False</property>


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