summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Catanzaro <mcatanzaro@gnome.org>2016-09-17 16:18:25 -0500
committerMichael Catanzaro <mcatanzaro@gnome.org>2016-09-17 16:18:25 -0500
commit37736ac2daca6ad6dc959840facf9fa9ca74d219 (patch)
treef7f25d2909404868a672ad9d7a767cf61a5898d7
parent63821eade07fe0f7aaf5ff21d8718cb611dc9055 (diff)
downloadepiphany-37736ac2daca6ad6dc959840facf9fa9ca74d219.tar.gz
shell: add simple app menu in web app mode
A side effect of this commit is that Ctrl+Q now works in app mode. That's nice!
-rw-r--r--src/ephy-shell.c28
-rw-r--r--src/resources/epiphany-application-menu.ui13
2 files changed, 33 insertions, 8 deletions
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 9cf3ff54b..206333953 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -251,6 +251,11 @@ static GActionEntry app_entries[] = {
{ "quit", quit_application, NULL, NULL, NULL },
};
+static GActionEntry app_mode_app_entries[] = {
+ { "about", show_about, NULL, NULL, NULL },
+ { "quit", quit_application, NULL, NULL, NULL },
+};
+
static GActionEntry app_normal_mode_entries[] = {
{ "reopen-closed-tab", reopen_closed_tab, NULL, NULL, NULL },
};
@@ -290,6 +295,7 @@ ephy_shell_startup (GApplication *application)
{
EphyEmbedShell *embed_shell = EPHY_EMBED_SHELL (application);
EphyEmbedShellMode mode;
+ GtkBuilder *builder;
G_APPLICATION_CLASS (ephy_shell_parent_class)->startup (application);
@@ -299,11 +305,13 @@ ephy_shell_startup (GApplication *application)
G_CALLBACK (download_started_cb),
application);
- mode = ephy_embed_shell_get_mode (embed_shell);
+ builder = gtk_builder_new ();
+ gtk_builder_add_from_resource (builder,
+ "/org/gnome/epiphany/epiphany-application-menu.ui",
+ NULL);
+ mode = ephy_embed_shell_get_mode (embed_shell);
if (mode != EPHY_EMBED_SHELL_MODE_APPLICATION) {
- GtkBuilder *builder;
-
g_action_map_add_action_entries (G_ACTION_MAP (application),
app_entries, G_N_ELEMENTS (app_entries),
application);
@@ -320,14 +328,18 @@ ephy_shell_startup (GApplication *application)
G_BINDING_SYNC_CREATE);
}
- builder = gtk_builder_new ();
- gtk_builder_add_from_resource (builder,
- "/org/gnome/epiphany/epiphany-application-menu.ui",
- NULL);
+
gtk_application_set_app_menu (GTK_APPLICATION (application),
G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu")));
- g_object_unref (builder);
+ } else {
+ g_action_map_add_action_entries (G_ACTION_MAP (application),
+ app_mode_app_entries, G_N_ELEMENTS (app_mode_app_entries),
+ application);
+ gtk_application_set_app_menu (GTK_APPLICATION (application),
+ G_MENU_MODEL (gtk_builder_get_object (builder, "app-mode-app-menu")));
}
+
+ g_object_unref (builder);
}
static void
diff --git a/src/resources/epiphany-application-menu.ui b/src/resources/epiphany-application-menu.ui
index bb0da5979..80840e170 100644
--- a/src/resources/epiphany-application-menu.ui
+++ b/src/resources/epiphany-application-menu.ui
@@ -39,6 +39,19 @@
</section>
<section>
<item>
+ <attribute name="label" translatable="yes">_About</attribute>
+ <attribute name="action">app.about</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Quit</attribute>
+ <attribute name="action">app.quit</attribute>
+ <attribute name="accel">&lt;Primary&gt;q</attribute>
+ </item>
+ </section>
+ </menu>
+ <menu id="app-mode-app-menu">
+ <section>
+ <item>
<attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
<attribute name="action">app.shortcuts</attribute>
<attribute name="accel">&lt;Primary&gt;F1</attribute>