[nautilus/wip/antoniof/gtk4-preparation-popovers: 40/45] batch-rename-dialog: Import menu models into template file




commit bd1bf1cc11906cb190364263ff203af3ee8d8a20
Author: António Fernandes <antoniof gnome org>
Date:   Wed Dec 22 16:20:46 2021 +0000

    batch-rename-dialog: Import menu models into template file
    
    Having the menu models in a separate file is keeping us from setting
    them as properties directly in the template UI definition.

 po/POTFILES.in                                     |  1 -
 src/nautilus-batch-rename-dialog.c                 |  7 +-
 src/resources/nautilus.gresource.xml               |  1 -
 .../ui/nautilus-batch-rename-dialog-menu.ui        | 95 ----------------------
 src/resources/ui/nautilus-batch-rename-dialog.ui   | 90 ++++++++++++++++++++
 5 files changed, 92 insertions(+), 102 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index f8e019d93..ad6bdd4f1 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -75,7 +75,6 @@ src/nautilus-window.c
 src/nautilus-window-slot.c
 src/nautilus-x-content-bar.c
 src/resources/gtk/help-overlay.ui
-src/resources/ui/nautilus-batch-rename-dialog-menu.ui
 src/resources/ui/nautilus-batch-rename-dialog.ui
 src/resources/ui/nautilus-column-chooser.ui
 src/resources/ui/nautilus-compress-dialog.ui
diff --git a/src/nautilus-batch-rename-dialog.c b/src/nautilus-batch-rename-dialog.c
index 916de2b23..b74c911be 100644
--- a/src/nautilus-batch-rename-dialog.c
+++ b/src/nautilus-batch-rename-dialog.c
@@ -1943,10 +1943,12 @@ nautilus_batch_rename_dialog_class_init (NautilusBatchRenameDialogClass *klass)
     gtk_widget_class_bind_template_child (widget_class, NautilusBatchRenameDialog, format_mode_button);
     gtk_widget_class_bind_template_child (widget_class, NautilusBatchRenameDialog, add_button);
     gtk_widget_class_bind_template_child (widget_class, NautilusBatchRenameDialog, add_popover);
+    gtk_widget_class_bind_template_child (widget_class, NautilusBatchRenameDialog, add_tag_menu);
     gtk_widget_class_bind_template_child (widget_class, NautilusBatchRenameDialog, numbering_order_label);
     gtk_widget_class_bind_template_child (widget_class, NautilusBatchRenameDialog, scrolled_window);
     gtk_widget_class_bind_template_child (widget_class, NautilusBatchRenameDialog, numbering_order_popover);
     gtk_widget_class_bind_template_child (widget_class, NautilusBatchRenameDialog, numbering_order_button);
+    gtk_widget_class_bind_template_child (widget_class, NautilusBatchRenameDialog, numbering_order_menu);
     gtk_widget_class_bind_template_child (widget_class, NautilusBatchRenameDialog, numbering_revealer);
     gtk_widget_class_bind_template_child (widget_class, NautilusBatchRenameDialog, conflict_box);
     gtk_widget_class_bind_template_child (widget_class, NautilusBatchRenameDialog, conflict_label);
@@ -2077,7 +2079,6 @@ nautilus_batch_rename_dialog_init (NautilusBatchRenameDialog *self)
 {
     TagData *tag_data;
     guint i;
-    g_autoptr (GtkBuilder) builder = NULL;
 
     gtk_widget_init_template (GTK_WIDGET (self));
 
@@ -2097,10 +2098,6 @@ nautilus_batch_rename_dialog_init (NautilusBatchRenameDialog *self)
 
     self->mode = NAUTILUS_BATCH_RENAME_DIALOG_FORMAT;
 
-    builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/ui/nautilus-batch-rename-dialog-menu.ui");
-    self->numbering_order_menu = g_object_ref_sink (G_MENU (gtk_builder_get_object (builder, 
"numbering_order_menu")));
-    self->add_tag_menu = g_object_ref_sink (G_MENU (gtk_builder_get_object (builder, "add_tag_menu")));
-
     gtk_popover_bind_model (GTK_POPOVER (self->numbering_order_popover),
                             G_MENU_MODEL (self->numbering_order_menu),
                             NULL);
diff --git a/src/resources/nautilus.gresource.xml b/src/resources/nautilus.gresource.xml
index ccb2ef6ff..9c8c3758e 100644
--- a/src/resources/nautilus.gresource.xml
+++ b/src/resources/nautilus.gresource.xml
@@ -20,7 +20,6 @@
     <file>ui/nautilus-starred-is-empty.ui</file>
     <file>gtk/help-overlay.ui</file>
     <file>ui/nautilus-batch-rename-dialog.ui</file>
-    <file>ui/nautilus-batch-rename-dialog-menu.ui</file>
     <file>ui/nautilus-properties-window.ui</file>
     <file>ui/nautilus-file-properties-change-permissions.ui</file>
     <file>ui/nautilus-file-conflict-dialog.ui</file>
diff --git a/src/resources/ui/nautilus-batch-rename-dialog.ui 
b/src/resources/ui/nautilus-batch-rename-dialog.ui
index 8920e4b20..eb9d9406b 100644
--- a/src/resources/ui/nautilus-batch-rename-dialog.ui
+++ b/src/resources/ui/nautilus-batch-rename-dialog.ui
@@ -1,5 +1,95 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
+  <menu id="add_tag_menu">
+    <section>
+      <attribute name="label" translatable="yes">Automatic Numbers</attribute>
+      <item>
+        <attribute name="label" translatable="yes">1, 2, 3, 4</attribute>
+        <attribute name="action">dialog.add-numbering-no-zero-pad-tag</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">01, 02, 03, 04</attribute>
+        <attribute name="action">dialog.add-numbering-one-zero-pad-tag</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">001, 002, 003, 004</attribute>
+        <attribute name="action">dialog.add-numbering-two-zero-pad-tag</attribute>
+      </item>
+    </section>
+    <section>
+      <attribute name="label" translatable="yes">Metadata</attribute>
+      <item>
+        <attribute name="label" translatable="yes">Creation Date</attribute>
+        <attribute name="action">dialog.add-creation-date-tag</attribute>
+        <attribute name="hidden-when">action-disabled</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Camera Model</attribute>
+        <attribute name="action">dialog.add-equipment-tag</attribute>
+        <attribute name="hidden-when">action-disabled</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Season Number</attribute>
+        <attribute name="action">dialog.add-season-tag</attribute>
+        <attribute name="hidden-when">action-disabled</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Episode Number</attribute>
+        <attribute name="action">dialog.add-episode-tag</attribute>
+        <attribute name="hidden-when">action-disabled</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Track Number</attribute>
+        <attribute name="action">dialog.add-track-number-tag</attribute>
+        <attribute name="hidden-when">action-disabled</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Artist Name</attribute>
+        <attribute name="action">dialog.add-artist-name-tag</attribute>
+        <attribute name="hidden-when">action-disabled</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Title</attribute>
+        <attribute name="action">dialog.add-title-tag</attribute>
+        <attribute name="hidden-when">action-disabled</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Album Name</attribute>
+        <attribute name="action">dialog.add-album-name-tag</attribute>
+        <attribute name="hidden-when">action-disabled</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">Original File Name</attribute>
+        <attribute name="action">dialog.add-original-file-name-tag</attribute>
+      </item>
+    </section>
+  </menu>
+  <menu id="numbering_order_menu">
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">Original Name (Ascending)</attribute>
+        <attribute name="action">dialog.numbering-order-changed</attribute>
+        <attribute name="target">name-ascending</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Original Name (Descending)</attribute>
+        <attribute name="action">dialog.numbering-order-changed</attribute>
+        <attribute name="target">name-descending</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">First Modified</attribute>
+        <attribute name="action">dialog.numbering-order-changed</attribute>
+        <attribute name="target">first-modified</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Last Modified</attribute>
+        <attribute name="action">dialog.numbering-order-changed</attribute>
+        <attribute name="target">last-modified</attribute>
+      </item>
+    </section>
+  </menu>
   <template class="NautilusBatchRenameDialog" parent="GtkDialog">
     <property name="resizable">True</property>
     <property name="modal">True</property>


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