[nautilus/antoniof/hide-path-border-on-small-windows: 6/8] toolbar: Remove pathbar border on small windows



commit 080400bd243ab86d82954eaff0c866c3ac97f3f2
Author: António Fernandes <antoniof gnome org>
Date:   Wed Aug 1 21:57:44 2018 +0100

    toolbar: Remove pathbar border on small windows
    
    The border is necessary for the centered look in wide windows.
    
    However, in small windows, it's only visual noise.
    
    So, show borders only when the window is wide enough for the pathbar
    container to grow to the maximum width. Also, remove the margin after
    the search button, which looks weird now.
    
    Related to https://gitlab.gnome.org/GNOME/nautilus/issues/548

 src/nautilus-toolbar.c               | 29 +++++++++++++++++++++++++++++
 src/resources/css/Adwaita.css        |  3 +++
 src/resources/ui/nautilus-toolbar.ui |  1 -
 3 files changed, 32 insertions(+), 1 deletion(-)
---
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
index fa7e56d4c..fb0d2d4c0 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -845,6 +845,31 @@ undo_manager_changed (NautilusToolbar *self)
     update_menu_item (self->redo_button, self, "redo", redo_active, redo_label);
 }
 
+static void
+on_notify_width_maximized (NautilusContainerMaxWidth *container,
+                           GParamSpec                *pspec,
+                           gpointer                   user_data)
+{
+    NautilusToolbar *self;
+    GtkStyleContext *context;
+    gboolean width_maximized;
+
+    self = NAUTILUS_TOOLBAR (user_data);
+    context = gtk_widget_get_style_context (self->path_bar_container);
+    width_maximized = nautilus_container_max_width_get_width_maximized (container);
+
+    g_return_if_fail (gtk_style_context_has_class (context, "width-maximized") != width_maximized);
+
+    if (width_maximized)
+    {
+        gtk_style_context_add_class (context, "width-maximized");
+    }
+    else
+    {
+        gtk_style_context_remove_class (context, "width-maximized");
+    }
+}
+
 static void
 on_location_entry_close (GtkWidget       *close_button,
                          NautilusToolbar *self)
@@ -908,6 +933,10 @@ nautilus_toolbar_constructed (GObject *object)
     self->path_bar = g_object_new (NAUTILUS_TYPE_PATH_BAR, NULL);
     gtk_container_add (GTK_CONTAINER (self->path_bar_container),
                        self->path_bar);
+    g_signal_connect (self->toolbar_switcher_container_max_width,
+                      "notify::width-maximized",
+                      G_CALLBACK (on_notify_width_maximized),
+                      self);
 
     self->location_entry = nautilus_location_entry_new ();
     gtk_container_add (GTK_CONTAINER (self->location_entry_container),
diff --git a/src/resources/css/Adwaita.css b/src/resources/css/Adwaita.css
index c1cf11071..635fe5795 100644
--- a/src/resources/css/Adwaita.css
+++ b/src/resources/css/Adwaita.css
@@ -69,6 +69,9 @@
 .path-bar button:not(:backdrop):hover { box-shadow: inset 0 -3px @borders; }
 
 .path-bar-box {
+  transition: border 200ms;
+}
+.path-bar-box.width-maximized {
   border: 1px @borders solid;
   border-radius: 3px;
 }
diff --git a/src/resources/ui/nautilus-toolbar.ui b/src/resources/ui/nautilus-toolbar.ui
index f8bb6f92d..b447065aa 100644
--- a/src/resources/ui/nautilus-toolbar.ui
+++ b/src/resources/ui/nautilus-toolbar.ui
@@ -317,7 +317,6 @@
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <property name="halign">center</property>
-        <property name="margin_end">24</property>
         <property name="spacing">6</property>
         <child>
           <object class="GtkBox" id="toolbar_switcher_container">


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