[nautilus] nautilus-batch-rename-dialog-menu.ui: Convert .ui files that use GMenu to a separate file



commit f6b54c36dbccabeaf3c80c92f7cc44ce2b0beb36
Author: Sumaid Syed <sumaidsyed gmail com>
Date:   Tue Jan 15 19:08:24 2019 +0530

    nautilus-batch-rename-dialog-menu.ui: Convert .ui files that use GMenu to a separate file
    
    The UI file nautilus-batch-rename-dialog.ui uses GMenu.
    
    Glade currently does not support <menu> sections but
    UI files with <menu> sections need to be edited.
    
    Seperate Menu files into a different file
    nautilus-batch-rename-dialog-menu.ui.
    
    Closes https://gitlab.gnome.org/GNOME/nautilus/issues/566

 src/nautilus-batch-rename-dialog.c                 |  9 +-
 src/resources/nautilus.gresource.xml               |  1 +
 .../ui/nautilus-batch-rename-dialog-menu.ui        | 95 ++++++++++++++++++++++
 src/resources/ui/nautilus-batch-rename-dialog.ui   | 90 --------------------
 4 files changed, 103 insertions(+), 92 deletions(-)
---
diff --git a/src/nautilus-batch-rename-dialog.c b/src/nautilus-batch-rename-dialog.c
index d5722e06c..bc456c7d2 100644
--- a/src/nautilus-batch-rename-dialog.c
+++ b/src/nautilus-batch-rename-dialog.c
@@ -2043,6 +2043,8 @@ nautilus_batch_rename_dialog_finalize (GObject *object)
         g_clear_object (&dialog->conflict_cancellable);
     }
 
+    g_clear_object (&dialog->numbering_order_menu);
+    g_clear_object (&dialog->add_tag_menu);
     g_list_free (dialog->original_name_listbox_rows);
     g_list_free (dialog->arrow_listbox_rows);
     g_list_free (dialog->result_listbox_rows);
@@ -2120,12 +2122,10 @@ nautilus_batch_rename_dialog_class_init (NautilusBatchRenameDialogClass *klass)
     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_revealer);
-    gtk_widget_class_bind_template_child (widget_class, NautilusBatchRenameDialog, numbering_order_menu);
     gtk_widget_class_bind_template_child (widget_class, NautilusBatchRenameDialog, conflict_box);
     gtk_widget_class_bind_template_child (widget_class, NautilusBatchRenameDialog, conflict_label);
     gtk_widget_class_bind_template_child (widget_class, NautilusBatchRenameDialog, conflict_up);
     gtk_widget_class_bind_template_child (widget_class, NautilusBatchRenameDialog, conflict_down);
-    gtk_widget_class_bind_template_child (widget_class, NautilusBatchRenameDialog, add_tag_menu);
     gtk_widget_class_bind_template_child (widget_class, NautilusBatchRenameDialog, numbering_label);
 
     gtk_widget_class_bind_template_callback (widget_class, file_names_widget_on_activate);
@@ -2232,6 +2232,7 @@ nautilus_batch_rename_dialog_init (NautilusBatchRenameDialog *self)
 {
     TagData *tag_data;
     guint i;
+    g_autoptr (GtkBuilder) builder = NULL;
 
     gtk_widget_init_template (GTK_WIDGET (self));
 
@@ -2251,6 +2252,10 @@ 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 e2bd0870e..e89c9c78f 100644
--- a/src/resources/nautilus.gresource.xml
+++ b/src/resources/nautilus.gresource.xml
@@ -19,6 +19,7 @@
     <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 alias="gtk/ui/nautilusgtkplacesview.ui">../gtk/nautilusgtkplacesview.ui</file>
     <file alias="gtk/ui/nautilusgtkplacesviewrow.ui">../gtk/nautilusgtkplacesviewrow.ui</file>
     <file alias="icons/thumbnail_frame.png">../../icons/thumbnail_frame.png</file>
diff --git a/src/resources/ui/nautilus-batch-rename-dialog-menu.ui 
b/src/resources/ui/nautilus-batch-rename-dialog-menu.ui
new file mode 100644
index 000000000..640cfa154
--- /dev/null
+++ b/src/resources/ui/nautilus-batch-rename-dialog-menu.ui
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<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>
+</interface>
+
diff --git a/src/resources/ui/nautilus-batch-rename-dialog.ui 
b/src/resources/ui/nautilus-batch-rename-dialog.ui
index 85ebe13a8..e00c209c0 100644
--- a/src/resources/ui/nautilus-batch-rename-dialog.ui
+++ b/src/resources/ui/nautilus-batch-rename-dialog.ui
@@ -407,72 +407,6 @@
       </object>
     </child>
   </template>
-  <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>
   <object class="GtkPopover" id="add_popover">
     <property name="position">bottom</property>
     <property name="relative-to">add_button</property>
@@ -482,30 +416,6 @@
     <property name="visible">True</property>
     <property name="icon_name">object-select-symbolic</property>
   </object>
-  <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>
   <object class="GtkPopover" id="numbering_order_popover">
     <property name="position">bottom</property>
     <property name="relative-to">numbering_order_button</property>


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