[nautilus/wip/cdavis/use-flap: 12/13] window: Use NautilusGtkPlacesSidebar directly




commit 94ba087d0967c95c15f12f09b6dc64b8aaa5a445
Author: Christopher Davis <christopherdavis gnome org>
Date:   Sat Jul 9 12:55:30 2022 -0400

    window: Use NautilusGtkPlacesSidebar directly
    
    Get rid of the middleman; Use `g_type_ensure()` to
    initialize the type.

 src/nautilus-window.c               | 21 ++++++---------------
 src/resources/ui/nautilus-window.ui |  7 ++++---
 2 files changed, 10 insertions(+), 18 deletions(-)
---
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 67d6b7edf..675c32613 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -108,8 +108,7 @@ struct _NautilusWindow
 
     /* Side Pane */
     int side_pane_width;
-    GtkWidget *sidebar;            /* container for the GtkPlacesSidebar */
-    GtkWidget *places_sidebar;     /* the actual GtkPlacesSidebar */
+    GtkWidget *places_sidebar;
     GVolume *selected_volume;     /* the selected volume in the sidebar popup callback */
     GFile *selected_file;     /* the selected file in the sidebar popup callback */
 
@@ -851,7 +850,7 @@ side_pane_notify_position_callback (GObject    *object,
 static void
 setup_side_pane_width (NautilusWindow *window)
 {
-    g_return_if_fail (window->sidebar != NULL);
+    g_return_if_fail (window->places_sidebar != NULL);
 
     window->side_pane_width =
         g_settings_get_int (nautilus_window_state,
@@ -1076,7 +1075,7 @@ nautilus_window_hide_sidebar (NautilusWindow *window)
 
     g_return_if_fail (NAUTILUS_IS_WINDOW (window));
 
-    gtk_widget_hide (window->sidebar);
+    gtk_widget_hide (window->places_sidebar);
 }
 
 void
@@ -1086,7 +1085,7 @@ nautilus_window_show_sidebar (NautilusWindow *window)
 
     g_return_if_fail (NAUTILUS_IS_WINDOW (window));
 
-    gtk_widget_show (window->sidebar);
+    gtk_widget_show (window->places_sidebar);
     setup_side_pane_width (window);
 }
 
@@ -2181,18 +2180,10 @@ nautilus_window_init (NautilusWindow *window)
     GtkEventController *controller;
 
     g_type_ensure (NAUTILUS_TYPE_TOOLBAR);
+    g_type_ensure (NAUTILUS_TYPE_GTK_PLACES_SIDEBAR);
     gtk_widget_init_template (GTK_WIDGET (window));
     nautilus_notebook_setup (GTK_NOTEBOOK (window->notebook));
 
-    window->places_sidebar = nautilus_gtk_places_sidebar_new ();
-    g_object_set (window->places_sidebar,
-                  "vexpand", TRUE,
-                  "visible", 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),
@@ -2268,7 +2259,7 @@ nautilus_window_class_init (NautilusWindowClass *class)
                                                  "/org/gnome/nautilus/ui/nautilus-window.ui");
     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, notebook);
     gtk_widget_class_bind_template_child (wclass, NautilusWindow, tab_menu);
     gtk_widget_class_bind_template_child (wclass, NautilusWindow, toast_overlay);
diff --git a/src/resources/ui/nautilus-window.ui b/src/resources/ui/nautilus-window.ui
index 95a3ac438..2242e0ef6 100644
--- a/src/resources/ui/nautilus-window.ui
+++ b/src/resources/ui/nautilus-window.ui
@@ -47,10 +47,11 @@
                 <property name="vexpand">True</property>
                 <property name="hexpand">True</property>
                 <child>
-                  <object class="GtkBox" id="sidebar">
+                  <object class="NautilusGtkPlacesSidebar" id="places_sidebar">
                     <property name="visible">False</property>
-                    <property name="orientation">vertical</property>
-                    <property name="spacing">6</property>
+                    <property name="vexpand">True</property>
+                    <property name="show-other-locations">True</property>
+                    <property name="show-starred-location">True</property>
                   </object>
                 </child>
                 <child>


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