[geary/wip/gtkactions: 4/4] Add exported actions to app menu
- From: Charles Lindsay <clindsay src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/gtkactions: 4/4] Add exported actions to app menu
- Date: Wed, 11 Dec 2013 02:21:01 +0000 (UTC)
commit 1692c6ee014d63d444f07e7c096c0afc46c9858c
Author: Charles Lindsay <chaz yorba org>
Date: Tue Dec 10 18:18:55 2013 -0800
Add exported actions to app menu
src/client/application/geary-action-adapter.vala | 2 +-
src/client/application/geary-application.vala | 7 +++-
src/client/application/geary-controller.vala | 25 ++++++++++++--
ui/CMakeLists.txt | 1 +
ui/app_menu.interface | 40 ++++++++++++++++++++++
5 files changed, 69 insertions(+), 6 deletions(-)
---
diff --git a/src/client/application/geary-action-adapter.vala
b/src/client/application/geary-action-adapter.vala
index b54cd92..707f395 100644
--- a/src/client/application/geary-action-adapter.vala
+++ b/src/client/application/geary-action-adapter.vala
@@ -18,9 +18,9 @@ public class Geary.ActionAdapter : BaseObject {
private delegate void RecursionGuardFunc();
public Action action { get { return _action; } }
+ public Gtk.Action gtk_action { get; private set; }
private SimpleAction _action;
- private Gtk.Action gtk_action;
private bool recursing = false;
public ActionAdapter(Gtk.Action gtk_action) {
diff --git a/src/client/application/geary-application.vala b/src/client/application/geary-application.vala
index ea40f01..cf192b6 100644
--- a/src/client/application/geary-application.vala
+++ b/src/client/application/geary-application.vala
@@ -292,11 +292,14 @@ along with Geary; if not, write to the Free Software Foundation, Inc.,
}
}
+ public File get_ui_file(string filename) {
+ return get_resource_directory().get_child("ui").get_child(filename);
+ }
+
// Loads a UI file (in the ui directory) into the specified UI manager.
public void load_ui_file_for_manager(Gtk.UIManager ui, string ui_filename) {
try {
- ui.add_ui_from_file(get_resource_directory().get_child("ui").get_child(
- ui_filename).get_path());
+ ui.add_ui_from_file(get_ui_file(ui_filename).get_path());
} catch(GLib.Error error) {
warning("Unable to create Gtk.UIManager: %s".printf(error.message));
}
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index d667703..944dbbf 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -389,6 +389,14 @@ public class GearyController : Geary.BaseObject {
ACTION_FORWARD_MESSAGE,
ACTION_DELETE_MESSAGE,
};
+ const string[] exported_actions = {
+ ACTION_ACCOUNTS,
+ ACTION_PREFERENCES,
+ ACTION_DONATE,
+ ACTION_HELP,
+ ACTION_ABOUT,
+ ACTION_QUIT,
+ };
Gtk.ActionGroup action_group = GearyApplication.instance.actions;
@@ -405,11 +413,22 @@ public class GearyController : Geary.BaseObject {
Gtk.ToggleActionEntry[] toggle_action_entries = create_toggle_actions();
action_group.add_toggle_actions(toggle_action_entries, this);
- // Don't worry about toggle actions in our action list.
- foreach (Geary.ActionAdapter a in GearyApplication.instance.action_adapters)
- GearyApplication.instance.add_action(a.action);
+ foreach (Geary.ActionAdapter a in GearyApplication.instance.action_adapters) {
+ if (a.action.name in exported_actions)
+ GearyApplication.instance.add_action(a.action);
+ }
GearyApplication.instance.ui_manager.insert_action_group(action_group, 0);
+
+ Gtk.Builder builder = new Gtk.Builder();
+ try {
+ builder.add_from_file(
+ GearyApplication.instance.get_ui_file("app_menu.interface").get_path());
+ } catch (Error e) {
+ error("Unable to parse app_menu.interface: %s", e.message);
+ }
+ MenuModel menu = (MenuModel) builder.get_object("app-menu");
+ GearyApplication.instance.set_app_menu(menu);
}
private void open_account(Geary.Account account) {
diff --git a/ui/CMakeLists.txt b/ui/CMakeLists.txt
index f1a5644..a6d5767 100644
--- a/ui/CMakeLists.txt
+++ b/ui/CMakeLists.txt
@@ -4,6 +4,7 @@ install(FILES accelerators.ui DESTINATION ${UI_DEST})
install(FILES account_list.glade DESTINATION ${UI_DEST})
install(FILES account_cannot_remove.glade DESTINATION ${UI_DEST})
install(FILES account_spinner.glade DESTINATION ${UI_DEST})
+install(FILES app_menu.interface DESTINATION ${UI_DEST})
install(FILES composer.glade DESTINATION ${UI_DEST})
install(FILES composer_accelerators.ui DESTINATION ${UI_DEST})
install(FILES find_bar.glade DESTINATION ${UI_DEST})
diff --git a/ui/app_menu.interface b/ui/app_menu.interface
new file mode 100644
index 0000000..6ecd0c4
--- /dev/null
+++ b/ui/app_menu.interface
@@ -0,0 +1,40 @@
+<interface>
+ <menu id='app-menu'>
+ <section>
+ <item>
+ <attribute name='label' translatable='yes'>A_ccounts</attribute>
+ <attribute name='action'>app.GearyAccounts</attribute>
+ <attribute name='accel'><Primary>M</attribute>
+ </item>
+ <item>
+ <attribute name='label' translatable='yes'>_Preferences</attribute>
+ <attribute name='action'>app.GearyPreferences</attribute>
+ <attribute name='accel'><Primary>E</attribute>
+ </item>
+ </section>
+ <section>
+ <item>
+ <attribute name='label' translatable='yes'>_Donate</attribute>
+ <attribute name='action'>app.GearyDonate</attribute>
+ </item>
+ </section>
+ <section>
+ <item>
+ <attribute name='label' translatable='yes'>_Help</attribute>
+ <attribute name='action'>app.GearyHelp</attribute>
+ <attribute name='accel'>F1</attribute>
+ </item>
+ <item>
+ <attribute name='label' translatable='yes'>_About</attribute>
+ <attribute name='action'>app.GearyAbout</attribute>
+ </item>
+ </section>
+ <section>
+ <item>
+ <attribute name='label' translatable='yes'>_Quit</attribute>
+ <attribute name='action'>app.GearyQuit</attribute>
+ <attribute name='accel'><Primary>Q</attribute>
+ </item>
+ </section>
+ </menu>
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]