[nautilus/wip/antoniof/three-menus-no-more: 5/7] toolbar: Drop view menu




commit c677a304bfe2c76162897b7ccdfecb17bf7d70bc
Author: António Fernandes <antoniof gnome org>
Date:   Sun Jul 31 21:56:49 2022 +0100

    toolbar: Drop view menu
    
    There are a few reasons to drop the view menu:
    
      * We already have primary (hamburger) and secondary (ellipsis) menus
      * It holds only sort options now, which are broken in list view dure
        to GTK not exposing the last clicked column header.
      * The button doesn't indicate the current sort order.
      * The grid view has already grown its own sort menu.
      * It's disconnected from the current folder, despite its sorting
        options being per-folder.
      * It shares tooltip with the view toggle button.
    
    This is also going to allow to a few followup cleanups and make
    adaptiveness easier.

 src/nautilus-toolbar.c               | 20 +++-----------------
 src/resources/ui/nautilus-toolbar.ui | 15 +--------------
 2 files changed, 4 insertions(+), 31 deletions(-)
---
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
index 27a5f6402..131ebdf82 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -71,8 +71,7 @@ struct _NautilusToolbar
     GtkWidget *operations_revealer;
     GtkWidget *operations_icon;
 
-    GtkWidget *view_split_button;
-    GMenuModel *view_menu;
+    GtkWidget *view_toggle_button;
 
     GtkWidget *app_button;
     GMenuModel *undo_redo_section;
@@ -1179,8 +1178,7 @@ nautilus_toolbar_class_init (NautilusToolbarClass *klass)
     gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, operations_popover);
     gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, operations_list);
     gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, operations_revealer);
-    gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, view_menu);
-    gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, view_split_button);
+    gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, view_toggle_button);
     gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, app_button);
     gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, undo_redo_section);
     gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, back_button);
@@ -1276,19 +1274,7 @@ on_slot_toolbar_menu_sections_changed (NautilusToolbar    *self,
 
     new_sections = nautilus_window_slot_get_toolbar_menu_sections (slot);
 
-    gtk_widget_set_sensitive (self->view_split_button, (new_sections != NULL));
-    if (new_sections == NULL)
-    {
-        return;
-    }
-
-    /* Let's assume that sort section is the first item
-     * in view_menu, as per nautilus-toolbar.ui. */
-
-    sort_item = g_menu_item_new_from_model (self->view_menu, 0);
-    g_menu_remove (G_MENU (self->view_menu), 0);
-    g_menu_item_set_section (sort_item, new_sections->sort_section);
-    g_menu_insert_item (G_MENU (self->view_menu), 0, sort_item);
+    gtk_widget_set_sensitive (self->view_toggle_button, (new_sections != NULL));
 }
 
 
diff --git a/src/resources/ui/nautilus-toolbar.ui b/src/resources/ui/nautilus-toolbar.ui
index e42bb2c46..b1d71ee5f 100644
--- a/src/resources/ui/nautilus-toolbar.ui
+++ b/src/resources/ui/nautilus-toolbar.ui
@@ -3,17 +3,6 @@
   <requires lib="gtk" version="4.0"/>
   <object class="GtkPopoverMenu" id="back_menu"/>
   <object class="GtkPopoverMenu" id="forward_menu"/>
-  <menu id="view_menu">
-    <section>
-      <attribute name="label" translatable="yes" context="menu item" comments="Translators: a menu item in a 
group of sorting options in a toolbar menu, with criterions such as &quot;A-Z&quot; or &quot;Last 
Modified&quot;.">Sort</attribute>
-      <!--
-           Sort section.
-
-           The toolbar code assumes this is the second item of this menu model.
-           Its contents is provided by the view.
-      -->
-    </section>
-  </menu>
   <menu id="app_menu">
     <section>
       <item>
@@ -219,12 +208,10 @@
           </object>
         </child>
         <child type="end">
-          <object class="AdwSplitButton" id="view_split_button">
+          <object class="GtkToggleButton" id="view_toggle_button">
             <property name="halign">center</property>
             <property name="valign">center</property>
-            <property name="tooltip_text" translatable="yes" comments="Translators: This is a noun, meaning 
the options pertaining to the view.">View options</property>
             <property name="action_name">slot.files-view-mode-toggle</property>
-            <property name="menu-model">view_menu</property>
             <binding name="icon-name">
               <lookup name="icon-name">
                 <lookup name="window-slot">NautilusToolbar</lookup>


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