[nautilus: 1/2] toolbar : Add close button to location entry



commit 09f6b6611bfab3999241322793ef4205880424e1
Author: Karuna Grewal <karunagrewal98 gmail com>
Date:   Tue Dec 26 12:55:54 2017 +0530

    toolbar : Add close button to location entry
    
    Due to the absence of an obvious way to close location entry
    a close button is added to the location entry container which
    can be used to close it.
    
    Fixes : https://gitlab.gnome.org/GNOME/nautilus/issues/63

 src/nautilus-toolbar.c               | 16 +++++++++++++++-
 src/resources/ui/nautilus-toolbar.ui |  3 +++
 2 files changed, 18 insertions(+), 1 deletion(-)
---
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
index a6d01b8cb..d975d9c43 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -93,6 +93,7 @@ struct _NautilusToolbar
 
     GtkWidget *forward_button;
     GtkWidget *back_button;
+    GtkWidget *location_entry_close_button;
 
     NautilusProgressInfoManager *progress_manager;
 
@@ -125,7 +126,7 @@ toolbar_update_appearance (NautilusToolbar *self)
                           g_settings_get_boolean (nautilus_preferences,
                                                   NAUTILUS_PREFERENCES_ALWAYS_USE_LOCATION_ENTRY);
 
-    gtk_widget_set_visible (self->location_entry,
+    gtk_widget_set_visible (self->location_entry_container,
                             show_location_entry);
     gtk_widget_set_visible (self->path_bar,
                             !show_location_entry);
@@ -869,6 +870,13 @@ undo_manager_changed (NautilusToolbar *self)
     update_menu_item (self->redo_button, self, "redo", redo_active, redo_label);
 }
 
+static void
+on_location_entry_close (GtkWidget       *close_button,
+                         NautilusToolbar *self)
+{
+    nautilus_toolbar_set_show_location_entry (self, FALSE);
+}
+
 static gboolean
 on_location_entry_populate_popup (GtkEntry  *entry,
                                   GtkWidget *widget,
@@ -941,6 +949,12 @@ nautilus_toolbar_init (NautilusToolbar *self)
     self->location_entry = nautilus_location_entry_new ();
     gtk_container_add (GTK_CONTAINER (self->location_entry_container),
                        self->location_entry);
+    self->location_entry_close_button = gtk_button_new_from_icon_name ("window-close-symbolic",
+                                                                        GTK_ICON_SIZE_BUTTON);
+    gtk_container_add (GTK_CONTAINER (self->location_entry_container),
+                       self->location_entry_close_button);
+    g_signal_connect (self->location_entry_close_button, "clicked",
+                      G_CALLBACK (on_location_entry_close), self);
 
     self->progress_manager = nautilus_progress_info_manager_dup_singleton ();
     g_signal_connect (self->progress_manager, "new-progress-info",
diff --git a/src/resources/ui/nautilus-toolbar.ui b/src/resources/ui/nautilus-toolbar.ui
index ef384223e..59d3fea04 100644
--- a/src/resources/ui/nautilus-toolbar.ui
+++ b/src/resources/ui/nautilus-toolbar.ui
@@ -68,6 +68,9 @@
     </child>
     <child>
       <object class="GtkBox" id="location_entry_container">
+        <style>
+          <class name="linked"/>
+        </style>
       </object>
       <packing>
         <property name="pack-type">start</property>


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