[nautilus/wip/antoniof/gtk4-preparation-step-container-api: 2/9] toolbar: Unify toolbar UI definitions




commit e74a26f6b25ab51b48872c674777b20a85782406
Author: António Fernandes <antoniof gnome org>
Date:   Tue Nov 23 20:53:16 2021 +0000

    toolbar: Unify toolbar UI definitions
    
    The toolbar's UI definition is split among two files because we used to
    have a NautilusContainerMaxWidth between them, which is not GtkBuildable.
    
    With out custom container gone from the toolbar, we can simplify this,
    while also reduce the usage of GtkContainer API, which is gone in GTK4.

 src/nautilus-toolbar.c                        | 16 ++----
 src/resources/nautilus.gresource.xml          |  1 -
 src/resources/ui/nautilus-toolbar-switcher.ui | 73 ---------------------------
 src/resources/ui/nautilus-toolbar.ui          | 44 +++++++++++++---
 4 files changed, 40 insertions(+), 94 deletions(-)
---
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
index 3875aecc1..cd0cb368e 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -67,7 +67,6 @@ struct _NautilusToolbar
     GtkWidget *location_entry_container;
     GtkWidget *search_container;
     GtkWidget *toolbar_switcher;
-    GtkWidget *toolbar_switcher_container;
     GtkWidget *path_bar;
     GtkWidget *location_entry;
 
@@ -891,18 +890,8 @@ on_location_entry_focus_changed (GObject    *object,
 static void
 nautilus_toolbar_constructed (GObject *object)
 {
-    g_autoptr (GtkBuilder) builder = NULL;
     NautilusToolbar *self = NAUTILUS_TOOLBAR (object);
 
-    builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/ui/nautilus-toolbar-switcher.ui");
-    self->toolbar_switcher = GTK_WIDGET (gtk_builder_get_object (builder, "toolbar_switcher"));
-    self->search_container = GTK_WIDGET (gtk_builder_get_object (builder, "search_container"));
-    self->path_bar_container = GTK_WIDGET (gtk_builder_get_object (builder, "path_bar_container"));
-    self->location_entry_container = GTK_WIDGET (gtk_builder_get_object (builder, 
"location_entry_container"));
-
-    gtk_container_add (GTK_CONTAINER (self->toolbar_switcher_container),
-                       self->toolbar_switcher);
-
     self->path_bar = g_object_new (NAUTILUS_TYPE_PATH_BAR, NULL);
     gtk_container_add (GTK_CONTAINER (self->path_bar_container),
                        self->path_bar);
@@ -1231,7 +1220,10 @@ nautilus_toolbar_class_init (NautilusToolbarClass *klass)
     gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, app_menu);
     gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, back_button);
     gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, forward_button);
-    gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, toolbar_switcher_container);
+    gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, toolbar_switcher);
+    gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, search_container);
+    gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, path_bar_container);
+    gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, location_entry_container);
 
     gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, view_menu_zoom_section);
     gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, view_menu_undo_redo_section);
diff --git a/src/resources/nautilus.gresource.xml b/src/resources/nautilus.gresource.xml
index bb0cf3ea1..a0cd28876 100644
--- a/src/resources/nautilus.gresource.xml
+++ b/src/resources/nautilus.gresource.xml
@@ -5,7 +5,6 @@
     <file compressed="true">ui/nautilus-search-popover.ui</file>
     <file>ui/nautilus-pathbar-context-menu.ui</file>
     <file>ui/nautilus-toolbar.ui</file>
-    <file>ui/nautilus-toolbar-switcher.ui</file>
     <file>ui/nautilus-toolbar-view-menu.ui</file>
     <file>ui/nautilus-column-chooser.ui</file>
     <file>ui/nautilus-list-view-column-editor.ui</file>
diff --git a/src/resources/ui/nautilus-toolbar.ui b/src/resources/ui/nautilus-toolbar.ui
index d012fa827..a1e6fccec 100644
--- a/src/resources/ui/nautilus-toolbar.ui
+++ b/src/resources/ui/nautilus-toolbar.ui
@@ -439,17 +439,48 @@
         <property name="can_focus">False</property>
         <property name="spacing">6</property>
         <child>
-          <object class="GtkBox" id="toolbar_switcher_container">
+          <object class="GtkStack" id="toolbar_switcher">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="valign">center</property>
+            <property name="hexpand">False</property>
+            <property name="transition_type">crossfade</property>
             <child>
-              <placeholder/>
+              <object class="GtkBox" id="path_bar_container">
+                <property name="can_focus">False</property>
+                <property name="valign">center</property>
+                <style>
+                  <class name="path-bar-box"/>
+                </style>
+              </object>
+              <packing>
+                <property name="name">pathbar</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkBox" id="location_entry_container">
+                <property name="can_focus">False</property>
+                <style>
+                  <class name="linked"/>
+                </style>
+              </object>
+              <packing>
+                <property name="name">location</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkBox" id="search_container">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="orientation">vertical</property>
+              </object>
+              <packing>
+                <property name="name">search</property>
+                <property name="position">2</property>
+              </packing>
             </child>
           </object>
-          <packing>
-            <property name="position">0</property>
-          </packing>
         </child>
         <child>
           <object class="GtkToggleButton" id="search_button">
@@ -477,9 +508,6 @@
           </packing>
         </child>
       </object>
-      <packing>
-        <property name="pack_type">end</property>
-      </packing>
     </child>
     <child>
       <object class="GtkBox" id="navigation_box">


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