[meld/ui-next] Move Close to a GAction
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld/ui-next] Move Close to a GAction
- Date: Sat, 23 Mar 2019 02:00:06 +0000 (UTC)
commit b7126f064340e9afb5513c9c433423373f3ce45e
Author: Kai Willadsen <kai willadsen gmail com>
Date: Mon Feb 18 07:16:44 2019 +1000
Move Close to a GAction
This also relocates the Preferences menu item to the main app section,
which is where most app-menu-retirement mockups have it.
data/ui/meldapp-ui.xml | 1 -
meld/accelerators.py | 1 +
meld/meldwindow.py | 9 +++------
meld/resources/gtk/menus.ui | 10 +++++++---
4 files changed, 11 insertions(+), 10 deletions(-)
---
diff --git a/data/ui/meldapp-ui.xml b/data/ui/meldapp-ui.xml
index 037a89a8..799f9768 100644
--- a/data/ui/meldapp-ui.xml
+++ b/data/ui/meldapp-ui.xml
@@ -2,7 +2,6 @@
<menubar name="Menubar">
<menu action="FileMenu">
<menuitem action="Recent" />
- <menuitem action="Close" />
</menu>
<menu action="EditMenu">
<menuitem action="Undo"/>
diff --git a/meld/accelerators.py b/meld/accelerators.py
index efeb5322..c5f32974 100644
--- a/meld/accelerators.py
+++ b/meld/accelerators.py
@@ -10,6 +10,7 @@ def register_accels(app: Gtk.Application):
('view.save', '<Primary>S'),
('view.save-all', '<Primary><Shift>L'),
('view.save-as', '<Primary><Shift>S'),
+ ('win.close', '<Primary>W'),
("win.stop", "Escape"),
)
for (name, accel) in view_accels:
diff --git a/meld/meldwindow.py b/meld/meldwindow.py
index 56e0b1d5..39b00831 100644
--- a/meld/meldwindow.py
+++ b/meld/meldwindow.py
@@ -57,9 +57,6 @@ class MeldWindow(Gtk.ApplicationWindow):
actions = (
("FileMenu", None, _("_File")),
- ("Close", Gtk.STOCK_CLOSE, None, None,
- _("Close the current file"),
- self.on_menu_close_activate),
("EditMenu", None, _("_Edit")),
("Undo", Gtk.STOCK_UNDO, None, "<Primary>Z",
@@ -138,7 +135,7 @@ class MeldWindow(Gtk.ApplicationWindow):
# Manually handle GAction additions
actions = (
- ("close", self.on_menu_close_activate),
+ ("close", self.action_close),
("new-tab", self.on_action_new_tab_activate),
("stop", self.action_stop),
)
@@ -259,7 +256,7 @@ class MeldWindow(Gtk.ApplicationWindow):
else:
page = None
- self.actiongroup.get_action("Close").set_sensitive(bool(page))
+ self.lookup_action('close').set_enabled(bool(page))
if not isinstance(page, MeldDoc):
for action in ("Cut", "Copy", "Paste",
"Find", "FindNext", "FindPrevious", "Replace",
@@ -343,7 +340,7 @@ class MeldWindow(Gtk.ApplicationWindow):
# FIXME: Need error handling, but no sensible display location
log.exception(f'Error opening recent file {uri}')
- def on_menu_close_activate(self, *extra):
+ def action_close(self, *extra):
i = self.notebook.get_current_page()
if i >= 0:
page = self.notebook.get_nth_page(i)
diff --git a/meld/resources/gtk/menus.ui b/meld/resources/gtk/menus.ui
index df5c5783..8a0f8709 100644
--- a/meld/resources/gtk/menus.ui
+++ b/meld/resources/gtk/menus.ui
@@ -65,14 +65,18 @@
</submenu>
</section>
<section>
- <attribute name="id">preferences-section</attribute>
+ <attribute name="id">window-section</attribute>
<item>
- <attribute name="label" translatable="yes">_Preferences</attribute>
- <attribute name="action">app.preferences</attribute>
+ <attribute name="label" translatable="yes">_Close</attribute>
+ <attribute name="action">win.close</attribute>
</item>
</section>
<section>
<attribute name="id">application-section</attribute>
+ <item>
+ <attribute name="label" translatable="yes">_Preferences</attribute>
+ <attribute name="action">app.preferences</attribute>
+ </item>
<item>
<attribute name="label" translatable="yes">_Help</attribute>
<attribute name="action">app.help</attribute>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]