[meld/deprecation-cleanup: 38/48] data: Move gear menu to resource loading



commit 8c2b7ee87a280ff5775b47d2d8ef2faead2bf1bb
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sun Dec 2 09:26:24 2018 +1000

    data: Move gear menu to resource loading
    
    This is using the implicit loading of the `gtk/menus.ui` resource.

 data/ui/application.ui            | 28 ----------------------------
 meld/meldwindow.py                |  6 ++----
 meld/resources/gtk/menus.ui       | 32 ++++++++++++++++++++++++++++++++
 meld/resources/meld.gresource.xml |  1 +
 4 files changed, 35 insertions(+), 32 deletions(-)
---
diff --git a/data/ui/application.ui b/data/ui/application.ui
index 3ea321dd..bb972d99 100644
--- a/data/ui/application.ui
+++ b/data/ui/application.ui
@@ -44,32 +44,4 @@ Josef Vybíral</property>
       </object>
     </child>
   </object>
-  <menu id="gear-menu">
-    <section>
-      <item>
-        <attribute name="label" translatable="yes">_Preferences</attribute>
-        <attribute name="action">app.preferences</attribute>
-      </item>
-    </section>
-    <section>
-      <item>
-        <attribute name="label" translatable="yes">_Help</attribute>
-        <attribute name="action">app.help</attribute>
-        <attribute name="accel">F1</attribute>
-      </item>
-      <item>
-        <attribute name="label" translatable="yes">Keyboard Shortcuts</attribute>
-        <attribute name="action">win.show-help-overlay</attribute>
-      </item>
-      <item>
-        <attribute name="label" translatable="yes">_About</attribute>
-        <attribute name="action">app.about</attribute>
-      </item>
-      <item>
-        <attribute name="label" translatable="yes">_Quit</attribute>
-        <attribute name="action">app.quit</attribute>
-        <attribute name="accel">&lt;Primary&gt;q</attribute>
-      </item>
-    </section>
-  </menu>
 </interface>
diff --git a/meld/meldwindow.py b/meld/meldwindow.py
index 36bbf575..d19a1548 100644
--- a/meld/meldwindow.py
+++ b/meld/meldwindow.py
@@ -222,10 +222,8 @@ class MeldWindow(Gtk.ApplicationWindow):
     def do_realize(self):
         Gtk.ApplicationWindow.do_realize(self)
 
-        # FIXME: Ideally we'd get the menu from resources, but we'd need to...
-        # have resources.
-        builder = meld.ui.util.get_builder("application.ui")
-        menu = builder.get_object("gear-menu")
+        app = self.get_application()
+        menu = app.get_menu_by_id("gear-menu")
         self.gear_menu_button.set_popover(
             Gtk.Popover.new_from_model(self.gear_menu_button, menu))
 
diff --git a/meld/resources/gtk/menus.ui b/meld/resources/gtk/menus.ui
new file mode 100644
index 00000000..cd985ab5
--- /dev/null
+++ b/meld/resources/gtk/menus.ui
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <menu id="gear-menu">
+    <section>
+      <attribute name="id">preferences-section</attribute>
+      <item>
+        <attribute name="label" translatable="yes">_Preferences</attribute>
+        <attribute name="action">app.preferences</attribute>
+      </item>
+    </section>
+    <section>
+      <attribute name="id">application-section</attribute>
+      <item>
+        <attribute name="label" translatable="yes">_Help</attribute>
+        <attribute name="action">app.help</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Keyboard Shortcuts</attribute>
+        <attribute name="action">win.show-help-overlay</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">_About</attribute>
+        <attribute name="action">app.about</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">_Quit</attribute>
+        <attribute name="action">app.quit</attribute>
+        <attribute name="accel">&lt;Primary&gt;q</attribute>
+      </item>
+    </section>
+  </menu>
+</interface>
diff --git a/meld/resources/meld.gresource.xml b/meld/resources/meld.gresource.xml
index 138b0de4..1ecc635c 100644
--- a/meld/resources/meld.gresource.xml
+++ b/meld/resources/meld.gresource.xml
@@ -2,6 +2,7 @@
 <gresources>
   <gresource prefix="/org/gnome/meld">
     <file>gtk/help-overlay.ui</file>
+    <file>gtk/menus.ui</file>
     <file>icons/16x16/actions/meld-change-apply-left.png</file>
     <file>icons/16x16/actions/meld-change-apply-right.png</file>
     <file>icons/16x16/actions/meld-change-copy.png</file>


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