Skip to content

Commit 8c2b7ee

Browse files
committed
data: Move gear menu to resource loading
This is using the implicit loading of the `gtk/menus.ui` resource.
1 parent d71e3b9 commit 8c2b7ee

4 files changed

Lines changed: 35 additions & 32 deletions

File tree

data/ui/application.ui

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -44,32 +44,4 @@ Josef Vybíral</property>
4444
</object>
4545
</child>
4646
</object>
47-
<menu id="gear-menu">
48-
<section>
49-
<item>
50-
<attribute name="label" translatable="yes">_Preferences</attribute>
51-
<attribute name="action">app.preferences</attribute>
52-
</item>
53-
</section>
54-
<section>
55-
<item>
56-
<attribute name="label" translatable="yes">_Help</attribute>
57-
<attribute name="action">app.help</attribute>
58-
<attribute name="accel">F1</attribute>
59-
</item>
60-
<item>
61-
<attribute name="label" translatable="yes">Keyboard Shortcuts</attribute>
62-
<attribute name="action">win.show-help-overlay</attribute>
63-
</item>
64-
<item>
65-
<attribute name="label" translatable="yes">_About</attribute>
66-
<attribute name="action">app.about</attribute>
67-
</item>
68-
<item>
69-
<attribute name="label" translatable="yes">_Quit</attribute>
70-
<attribute name="action">app.quit</attribute>
71-
<attribute name="accel">&lt;Primary&gt;q</attribute>
72-
</item>
73-
</section>
74-
</menu>
7547
</interface>

meld/meldwindow.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,8 @@ def __init__(self):
222222
def do_realize(self):
223223
Gtk.ApplicationWindow.do_realize(self)
224224

225-
# FIXME: Ideally we'd get the menu from resources, but we'd need to...
226-
# have resources.
227-
builder = meld.ui.util.get_builder("application.ui")
228-
menu = builder.get_object("gear-menu")
225+
app = self.get_application()
226+
menu = app.get_menu_by_id("gear-menu")
229227
self.gear_menu_button.set_popover(
230228
Gtk.Popover.new_from_model(self.gear_menu_button, menu))
231229

meld/resources/gtk/menus.ui

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<interface>
3+
<menu id="gear-menu">
4+
<section>
5+
<attribute name="id">preferences-section</attribute>
6+
<item>
7+
<attribute name="label" translatable="yes">_Preferences</attribute>
8+
<attribute name="action">app.preferences</attribute>
9+
</item>
10+
</section>
11+
<section>
12+
<attribute name="id">application-section</attribute>
13+
<item>
14+
<attribute name="label" translatable="yes">_Help</attribute>
15+
<attribute name="action">app.help</attribute>
16+
</item>
17+
<item>
18+
<attribute name="label" translatable="yes">Keyboard Shortcuts</attribute>
19+
<attribute name="action">win.show-help-overlay</attribute>
20+
</item>
21+
<item>
22+
<attribute name="label" translatable="yes">_About</attribute>
23+
<attribute name="action">app.about</attribute>
24+
</item>
25+
<item>
26+
<attribute name="label" translatable="yes">_Quit</attribute>
27+
<attribute name="action">app.quit</attribute>
28+
<attribute name="accel">&lt;Primary&gt;q</attribute>
29+
</item>
30+
</section>
31+
</menu>
32+
</interface>

meld/resources/meld.gresource.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<gresources>
33
<gresource prefix="/org/gnome/meld">
44
<file>gtk/help-overlay.ui</file>
5+
<file>gtk/menus.ui</file>
56
<file>icons/16x16/actions/meld-change-apply-left.png</file>
67
<file>icons/16x16/actions/meld-change-apply-right.png</file>
78
<file>icons/16x16/actions/meld-change-copy.png</file>

0 commit comments

Comments
 (0)