[geary] Avoid critical errors when creating multiple application menus
- From: Robert Schroll <rschroll src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary] Avoid critical errors when creating multiple application menus
- Date: Fri, 20 Mar 2015 22:50:53 +0000 (UTC)
commit 98be06db89d3fdabe67fb14d1026ede83d01076d
Author: Robert Schroll <rschroll gmail com>
Date: Fri Mar 20 18:19:04 2015 -0400
Avoid critical errors when creating multiple application menus
First, create a composer action corresponding to the app menu, instead
of reusing the one from the controller. Second, create the menu from a
MenuModel, instead of from a UIManager, so we can have many of them.
https://bugzilla.gnome.org/show_bug.cgi?id=746504
src/client/application/geary-controller.vala | 6 ++++--
src/client/components/main-toolbar.vala | 7 ++-----
src/client/composer/composer-headerbar.vala | 9 ++++-----
src/client/composer/composer-widget.vala | 1 +
ui/composer.glade | 7 +++++++
ui/toolbar_menu.ui | 13 -------------
6 files changed, 18 insertions(+), 25 deletions(-)
---
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index 39e2330..27724bc 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -98,6 +98,8 @@ public class GearyController : Geary.BaseObject {
public LoginDialog? login_dialog { get; private set; default = null; }
+ public MenuModel app_menu { get; private set; }
+
private Geary.Account? current_account = null;
private Gee.HashMap<Geary.Account, Geary.App.EmailStore> email_stores
= new Gee.HashMap<Geary.Account, Geary.App.EmailStore>();
@@ -597,7 +599,7 @@ public class GearyController : Geary.BaseObject {
} catch (Error e) {
error("Unable to parse app_menu.interface: %s", e.message);
}
- MenuModel menu = (MenuModel) builder.get_object("app-menu");
+ app_menu = (MenuModel) builder.get_object("app-menu");
// We'd *like* to always export an app menu and just let the shell
// decide whether to display it or not. Unfortunately Mint (Cinnamon,
@@ -605,7 +607,7 @@ public class GearyController : Geary.BaseObject {
// application, even if you didn't have one otherwise, if you export
// the app menu. So, we only export it if the shell claims to show it.
if (Gtk.Settings.get_default().gtk_shell_shows_app_menu)
- GearyApplication.instance.set_app_menu(menu);
+ GearyApplication.instance.set_app_menu(app_menu);
}
private void open_account(Geary.Account account) {
diff --git a/src/client/components/main-toolbar.vala b/src/client/components/main-toolbar.vala
index 1dfc5a4..a9eeb52 100644
--- a/src/client/components/main-toolbar.vala
+++ b/src/client/components/main-toolbar.vala
@@ -61,11 +61,6 @@ public class MainToolbar : Gtk.Box {
Gtk.Menu mark_menu = (Gtk.Menu)
GearyApplication.instance.ui_manager.get_widget("/ui/ToolbarMarkMenu");
mark_menu.foreach(GtkUtil.show_menuitem_accel_labels);
- // Setup the application menu.
- GearyApplication.instance.load_ui_file("toolbar_menu.ui");
- Gtk.Menu application_menu = (Gtk.Menu)
GearyApplication.instance.ui_manager.get_widget("/ui/ToolbarMenu");
- application_menu.foreach(GtkUtil.show_menuitem_accel_labels);
-
// Toolbar setup.
Gee.List<Gtk.Button> insert = new Gee.ArrayList<Gtk.Button>();
@@ -140,6 +135,8 @@ public class MainToolbar : Gtk.Box {
// Application button. If we exported an app menu, we don't need this.
if (!Gtk.Settings.get_default().gtk_shell_shows_app_menu) {
insert.clear();
+ Gtk.Menu application_menu = new Gtk.Menu.from_model(
+ GearyApplication.instance.controller.app_menu);
insert.add(conversation_header.create_menu_button("emblem-system-symbolic",
application_menu, GearyController.ACTION_GEAR_MENU));
conversation_header.add_end(conversation_header.create_pill_buttons(insert));
diff --git a/src/client/composer/composer-headerbar.vala b/src/client/composer/composer-headerbar.vala
index 7b67dcc..3c8f46f 100644
--- a/src/client/composer/composer-headerbar.vala
+++ b/src/client/composer/composer-headerbar.vala
@@ -91,11 +91,10 @@ public class ComposerHeaderbar : PillHeaderbar {
// Application button for when taking over main header bar. If we exported an app menu,
// we don't need this.
if (!Gtk.Settings.get_default().gtk_shell_shows_app_menu) {
- Gtk.Menu application_menu = (Gtk.Menu) GearyApplication.instance.ui_manager.get_widget(
- "/ui/ToolbarMenu");
- application_menu.foreach(GtkUtil.show_menuitem_accel_labels);
- Gtk.Button menu_button = create_menu_button("emblem-system-symbolic", application_menu,
- GearyController.ACTION_GEAR_MENU);
+ Gtk.Menu application_menu = new Gtk.Menu.from_model(
+ GearyApplication.instance.controller.app_menu);
+ Gtk.Button menu_button = create_menu_button(null, application_menu,
+ ComposerWidget.ACTION_GEAR_MENU);
add_end(menu_button);
bind_property("state", menu_button, "visible", BindingFlags.SYNC_CREATE,
(binding, source_value, ref target_value) => {
diff --git a/src/client/composer/composer-widget.vala b/src/client/composer/composer-widget.vala
index 03d7870..18b5332 100644
--- a/src/client/composer/composer-widget.vala
+++ b/src/client/composer/composer-widget.vala
@@ -68,6 +68,7 @@ public class ComposerWidget : Gtk.EventBox {
public const string ACTION_SEND = "send";
public const string ACTION_ADD_ATTACHMENT = "add attachment";
public const string ACTION_ADD_ORIGINAL_ATTACHMENTS = "add original attachments";
+ public const string ACTION_GEAR_MENU = "gear menu";
private const string DRAFT_SAVED_TEXT = _("Saved");
private const string DRAFT_SAVING_TEXT = _("Saving");
diff --git a/ui/composer.glade b/ui/composer.glade
index 47268e9..7e730c0 100644
--- a/ui/composer.glade
+++ b/ui/composer.glade
@@ -236,6 +236,13 @@
<property name="icon_name">edit-copy-symbolic</property>
</object>
</child>
+ <child>
+ <object class="GtkAction" id="gear menu">
+ <property name="label" translatable="yes">Application Menu</property>
+ <property name="icon_name">emblem-system-symbolic</property>
+ </object>
+ <accelerator key="F10"/>
+ </child>
</object>
<object class="GtkBox" id="composer">
<property name="visible">True</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]