[nautilus/wip/antoniof/three-menus-no-more: 7/7] toolbar-view-menu.ui: Move into files-view.ui




commit a8d743177da7109ed432ea5206758ead20599d88
Author: António Fernandes <antoniof gnome org>
Date:   Mon Aug 1 00:04:31 2022 +0100

    toolbar-view-menu.ui: Move into files-view.ui
    
    This is not used by the toolbar anymore and this is much simpler.

 po/POTFILES.in                                 |  1 -
 src/nautilus-files-view.c                      | 17 ++-----
 src/resources/nautilus.gresource.xml           |  1 -
 src/resources/ui/nautilus-files-view.ui        | 60 ++++++++++++++++++++++++
 src/resources/ui/nautilus-toolbar-view-menu.ui | 63 --------------------------
 5 files changed, 63 insertions(+), 79 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index ab1b37ba2..c3542b022 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -88,7 +88,6 @@ src/resources/ui/nautilus-properties-window.ui
 src/resources/ui/nautilus-rename-file-popover.ui
 src/resources/ui/nautilus-search-popover.ui
 src/resources/ui/nautilus-toolbar.ui
-src/resources/ui/nautilus-toolbar-view-menu.ui
 src/resources/ui/nautilus-window.ui
 src/gtk/nautilusgtkplacesview.c
 src/gtk/nautilusgtkplacesviewrow.c
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index ca0d54b23..098bece1f 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -247,6 +247,8 @@ typedef struct
     GtkWidget *stack;
 
     GtkWidget *sort_menu_button;
+    GMenuModel *sort_menu;
+
     GtkWidget *scrolled_window;
 
     /* Empty states */
@@ -258,8 +260,6 @@ typedef struct
     guint floating_bar_set_passthrough_timeout_id;
     GtkWidget *floating_bar;
 
-    GMenuModel *sort_menu;
-
     /* Exposed menus, for the path bar etc. */
     GMenuModel *extensions_background_menu;
     GMenuModel *templates_menu;
@@ -3301,8 +3301,6 @@ nautilus_files_view_finalize (GObject *object)
     /* We don't own the slot, so no unref */
     priv->slot = NULL;
 
-    g_clear_object (&priv->sort_menu);
-
     g_hash_table_destroy (priv->non_ready_files);
     g_hash_table_destroy (priv->pending_reveal);
 
@@ -9484,6 +9482,7 @@ nautilus_files_view_class_init (NautilusFilesViewClass *klass)
                                                  "/org/gnome/nautilus/ui/nautilus-files-view.ui");
 
     gtk_widget_class_bind_template_child_private (widget_class, NautilusFilesView, sort_menu_button);
+    gtk_widget_class_bind_template_child_private (widget_class, NautilusFilesView, sort_menu);
     gtk_widget_class_bind_template_child_private (widget_class, NautilusFilesView, overlay);
     gtk_widget_class_bind_template_child_private (widget_class, NautilusFilesView, stack);
     gtk_widget_class_bind_template_child_private (widget_class, NautilusFilesView, empty_view_page);
@@ -9538,7 +9537,6 @@ static void
 nautilus_files_view_init (NautilusFilesView *view)
 {
     NautilusFilesViewPrivate *priv;
-    GtkBuilder *builder;
     NautilusDirectory *scripts_directory;
     NautilusDirectory *templates_directory;
     GtkEventController *controller;
@@ -9571,10 +9569,6 @@ nautilus_files_view_init (NautilusFilesView *view)
 
     priv = nautilus_files_view_get_instance_private (view);
 
-    /* Toolbar menu */
-    builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/ui/nautilus-toolbar-view-menu.ui");
-    priv->sort_menu = G_MENU_MODEL (g_object_ref (gtk_builder_get_object (builder, "sort_section")));
-
     g_signal_connect (view,
                       "end-file-changes",
                       G_CALLBACK (on_end_file_changes),
@@ -9588,14 +9582,9 @@ nautilus_files_view_init (NautilusFilesView *view)
                       G_CALLBACK (on_parent_changed),
                       NULL);
 
-    g_object_unref (builder);
-
     g_type_ensure (NAUTILUS_TYPE_FLOATING_BAR);
     gtk_widget_init_template (GTK_WIDGET (view));
 
-    gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (priv->sort_menu_button),
-                                    priv->sort_menu);
-
     controller = gtk_event_controller_scroll_new (GTK_EVENT_CONTROLLER_SCROLL_VERTICAL |
                                                   GTK_EVENT_CONTROLLER_SCROLL_DISCRETE);
     gtk_widget_add_controller (priv->scrolled_window, controller);
diff --git a/src/resources/nautilus.gresource.xml b/src/resources/nautilus.gresource.xml
index 3a6abce9a..69dc9ee6f 100644
--- a/src/resources/nautilus.gresource.xml
+++ b/src/resources/nautilus.gresource.xml
@@ -6,7 +6,6 @@
     <file>ui/nautilus-app-chooser.ui</file>
     <file>ui/nautilus-pathbar-context-menu.ui</file>
     <file>ui/nautilus-toolbar.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>
     <file>ui/nautilus-create-folder-dialog.ui</file>
diff --git a/src/resources/ui/nautilus-files-view.ui b/src/resources/ui/nautilus-files-view.ui
index db5e68779..767183dc3 100644
--- a/src/resources/ui/nautilus-files-view.ui
+++ b/src/resources/ui/nautilus-files-view.ui
@@ -12,6 +12,7 @@
         <property name="halign">start</property>
         <property name="valign">start</property>
         <property name="always-show-arrow">true</property>
+        <property name="menu-model">sort_menu</property>
         <property name="label">Sort</property>
         <style>
           <class name="caption-heading"/>
@@ -52,4 +53,63 @@
       </object>
     </child>
   </template>
+  <menu id="sort_menu">
+    <item>
+      <attribute name="action">view.sort</attribute>
+      <attribute name="target" type="(sb)">('name',false)</attribute>
+      <attribute name="label" translatable="yes" context="Sort Criterion" comments="This is used to sort by 
name in the toolbar view menu">_A-Z</attribute>
+      <attribute name="hidden-when">action-disabled</attribute>
+    </item>
+    <item>
+      <attribute name="action">view.sort</attribute>
+      <attribute name="target" type="(sb)">('name',true)</attribute>
+      <attribute name="label" translatable="yes" context="Sort Criterion" comments="This is used to sort by 
name, in descending order in the toolbar view menu">_Z-A</attribute>
+      <attribute name="hidden-when">action-disabled</attribute>
+    </item>
+    <item>
+      <attribute name="action">view.sort</attribute>
+      <attribute name="target" type="(sb)">('modification date',true)</attribute>
+      <attribute name="label" translatable="yes">Last _Modified</attribute>
+      <attribute name="hidden-when">action-disabled</attribute>
+    </item>
+    <item>
+      <attribute name="action">view.sort</attribute>
+      <attribute name="target" type="(sb)">('modification date',false)</attribute>
+      <attribute name="label" translatable="yes">_First Modified</attribute>
+      <attribute name="hidden-when">action-disabled</attribute>
+    </item>
+    <item>
+      <attribute name="action">view.sort</attribute>
+      <attribute name="target" type="(sb)">('size',true)</attribute>
+      <attribute name="label" translatable="yes">_Size</attribute>
+      <attribute name="hidden-when">action-disabled</attribute>
+    </item>
+    <item>
+      <attribute name="action">view.sort</attribute>
+      <attribute name="target" type="(sb)">('type',false)</attribute>
+      <attribute name="label" translatable="yes">_Type</attribute>
+      <attribute name="hidden-when">action-disabled</attribute>
+    </item>
+    <item>
+      <attribute name="action">view.sort</attribute>
+      <attribute name="target" type="(sb)">('trashed',true)</attribute>
+      <attribute name="label" translatable="yes">Last _Trashed</attribute>
+      <attribute name="hidden-when">action-disabled</attribute>
+      <attribute name="nautilus-menu-item">last_trashed</attribute>
+    </item>
+    <item>
+      <attribute name="action">view.sort</attribute>
+      <attribute name="target" type="(sb)">('recency',true)</attribute>
+      <attribute name="label" translatable="yes">Recency</attribute>
+      <attribute name="hidden-when">action-disabled</attribute>
+      <attribute name="nautilus-menu-item">recency</attribute>
+    </item>
+    <item>
+      <attribute name="action">view.sort</attribute>
+      <attribute name="target" type="(sb)">('search_relevance',true)</attribute>
+      <attribute name="label" translatable="yes">Relevance</attribute>
+      <attribute name="hidden-when">action-disabled</attribute>
+      <attribute name="nautilus-menu-item">relevance</attribute>
+    </item>
+  </menu>
 </interface>


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