[meld] meldwindow: Manually handle app menu for non-Gnome shells (bgo#725430)
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] meldwindow: Manually handle app menu for non-Gnome shells (bgo#725430)
- Date: Mon, 14 Jul 2014 21:50:56 +0000 (UTC)
commit c253e13d1a44bf76c82e04bb43aba7f12df85e85
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sun Mar 30 07:27:43 2014 +1000
meldwindow: Manually handle app menu for non-Gnome shells (bgo#725430)
Since we don't have a global application menu bar (due to limitations
of GMenuModel, and having to totally redesign all of our menus and
rewrite associated code because of GtkUIManager deprecation), this
commit adds a fallback that manually recreates the application menu
in a UIManager-compatible form, and inserts it into the appropriate
(new) placeholder.
data/ui/appmenu-fallback.xml | 12 ++++++++++++
data/ui/meldapp-ui.xml | 1 +
meld/meldwindow.py | 33 +++++++++++++++++++++++++++++++++
3 files changed, 46 insertions(+), 0 deletions(-)
---
diff --git a/data/ui/appmenu-fallback.xml b/data/ui/appmenu-fallback.xml
new file mode 100644
index 0000000..17c6db4
--- /dev/null
+++ b/data/ui/appmenu-fallback.xml
@@ -0,0 +1,12 @@
+<ui>
+ <menubar name="Menubar">
+ <placeholder name="AppMenuPlaceholder">
+ <menu action="AppMenu">
+ <menuitem action="Preferences"/>
+ <menuitem action="Help"/>
+ <menuitem action="About"/>
+ <menuitem action="Quit"/>
+ </menu>
+ </placeholder>
+ </menubar>
+</ui>
diff --git a/data/ui/meldapp-ui.xml b/data/ui/meldapp-ui.xml
index 43e8041..3cde9bd 100644
--- a/data/ui/meldapp-ui.xml
+++ b/data/ui/meldapp-ui.xml
@@ -1,5 +1,6 @@
<ui>
<menubar name="Menubar">
+ <placeholder name="AppMenuPlaceholder" />
<menu action="FileMenu">
<menuitem action="New" />
<menuitem action="Save" />
diff --git a/meld/meldwindow.py b/meld/meldwindow.py
index 6638c25..d4b64ce 100644
--- a/meld/meldwindow.py
+++ b/meld/meldwindow.py
@@ -149,6 +149,39 @@ class MeldWindow(gnomeglade.Component):
self.ui = Gtk.UIManager()
self.ui.insert_action_group(self.actiongroup, 0)
self.ui.add_ui_from_file(ui_file)
+
+ # Manually handle shells that don't show an application menu
+ gtk_settings = Gtk.Settings.get_default()
+ if not gtk_settings.props.gtk_shell_shows_app_menu:
+ from meldapp import app
+
+ def make_app_action(name):
+ def app_action(*args):
+ app.lookup_action(name).activate(None)
+ return app_action
+
+ app_actions = (
+ ("AppMenu", None, _("_Meld")),
+ ("Quit", Gtk.STOCK_QUIT, None, None, _("Quit the program"),
+ make_app_action('quit')),
+ ("Preferences", Gtk.STOCK_PREFERENCES, _("Prefere_nces"), None,
+ _("Configure the application"),
+ make_app_action('preferences')),
+ ("Help", Gtk.STOCK_HELP, _("_Contents"), "F1",
+ _("Open the Meld manual"), make_app_action('help')),
+ ("About", Gtk.STOCK_ABOUT, None, None,
+ _("About this application"), make_app_action('about')),
+ )
+
+ app_actiongroup = Gtk.ActionGroup(name="AppActions")
+ app_actiongroup.set_translation_domain("meld")
+ app_actiongroup.add_actions(app_actions)
+ self.ui.insert_action_group(app_actiongroup, 0)
+
+ ui_file = gnomeglade.ui_file("appmenu-fallback.xml")
+ self.ui.add_ui_from_file(ui_file)
+ self.widget.set_show_menubar(False)
+
self.tab_switch_actiongroup = None
self.tab_switch_merge_id = None
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]