[gthumb] add app menu entries to the gear menu if the app menu is not supported
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] add app menu entries to the gear menu if the app menu is not supported
- Date: Fri, 15 Sep 2017 17:27:07 +0000 (UTC)
commit 5f536f52928dcd692dfbf95f08fefa7c4f0efdc6
Author: Paolo Bacchilega <paobac src gnome org>
Date: Fri Sep 15 19:04:16 2017 +0200
add app menu entries to the gear menu if the app menu is not supported
gthumb/gth-application.c | 21 +++++++++++++++------
gthumb/gth-browser-actions-entries.h | 17 +++++++++++++++++
gthumb/gth-browser.c | 15 +++++++++++++++
gthumb/gth-browser.h | 3 +++
gthumb/resources/gears-menu.ui | 6 ++++++
5 files changed, 56 insertions(+), 6 deletions(-)
---
diff --git a/gthumb/gth-application.c b/gthumb/gth-application.c
index 15a93c9..0ba7ee1 100644
--- a/gthumb/gth-application.c
+++ b/gthumb/gth-application.c
@@ -152,18 +152,27 @@ static const GActionEntry app_menu_entries[] = {
static void
_gth_application_initialize_app_menu (GApplication *application)
{
- GtkBuilder *builder;
-
g_action_map_add_action_entries (G_ACTION_MAP (application),
app_menu_entries,
G_N_ELEMENTS (app_menu_entries),
application);
- builder = _gtk_builder_new_from_resource ("app-menu.ui");
- gtk_application_set_app_menu (GTK_APPLICATION (application),
- G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu")));
+ if (gtk_application_prefers_app_menu (GTK_APPLICATION (application))) {
+ GtkBuilder *builder;
+
+ builder = _gtk_builder_new_from_resource ("app-menu.ui");
+ gtk_application_set_app_menu (GTK_APPLICATION (application),
+ G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu")));
+
+ g_object_unref (builder);
+ }
+ else {
+ const char * const new_window_accel[] = { "<Primary>n", NULL };
+ const char * const quit_accel[] = { "<Primary>q", NULL };
- g_object_unref (builder);
+ gtk_application_set_accels_for_action (GTK_APPLICATION (application), "app.new-window",
new_window_accel);
+ gtk_application_set_accels_for_action (GTK_APPLICATION (application), "app.quit", quit_accel);
+ }
}
diff --git a/gthumb/gth-browser-actions-entries.h b/gthumb/gth-browser-actions-entries.h
index 1b2c904..fb228db 100644
--- a/gthumb/gth-browser-actions-entries.h
+++ b/gthumb/gth-browser-actions-entries.h
@@ -81,4 +81,21 @@ static const GthAccelerator gth_browser_accelerators[] = {
};
+static const GthMenuEntry gears_preferences_action_entries[] = {
+ { N_("_Preferences"), "app.preferences" }
+};
+
+
+static const GthMenuEntry gears_help_action_entries[] = {
+ { N_("Keyboard Shortcuts"), "app.shortcuts" },
+ { N_("_Help"), "app.help" },
+ { N_("_About"), "app.about" }
+};
+
+
+static const GthMenuEntry gears_close_action_entries[] = {
+ { N_("_Quit"), "app.quit" }
+};
+
+
#endif /* GTH_BROWSER_ACTION_ENTRIES_H */
diff --git a/gthumb/gth-browser.c b/gthumb/gth-browser.c
index 7b7f85f..7fd8ede 100644
--- a/gthumb/gth-browser.c
+++ b/gthumb/gth-browser.c
@@ -4538,6 +4538,9 @@ gth_browser_init (GthBrowser *browser)
gth_browser_add_menu_manager_for_menu (browser, GTH_BROWSER_MENU_MANAGER_GEARS, G_MENU
(menu));
gth_browser_add_menu_manager_for_menu (browser,
GTH_BROWSER_MENU_MANAGER_GEARS_FOLDER_ACTIONS, G_MENU (gtk_builder_get_object (builder, "folder-actions")));
gth_browser_add_menu_manager_for_menu (browser, GTH_BROWSER_MENU_MANAGER_GEARS_OTHER_ACTIONS,
G_MENU (gtk_builder_get_object (builder, "other-actions")));
+ gth_browser_add_menu_manager_for_menu (browser,
GTH_BROWSER_MENU_MANAGER_GEARS_PREFERENCES_ACTIONS, G_MENU (gtk_builder_get_object (builder,
"preferences-actions")));
+ gth_browser_add_menu_manager_for_menu (browser, GTH_BROWSER_MENU_MANAGER_GEARS_HELP_ACTIONS,
G_MENU (gtk_builder_get_object (builder, "help-actions")));
+ gth_browser_add_menu_manager_for_menu (browser, GTH_BROWSER_MENU_MANAGER_GEARS_CLOSE_ACTIONS,
G_MENU (gtk_builder_get_object (builder, "close-actions")));
_gtk_window_add_accelerators_from_menu ((GTK_WINDOW (browser)), menu);
g_object_unref (builder);
@@ -4550,6 +4553,18 @@ gth_browser_init (GthBrowser *browser)
gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar),
browser->priv->header_sections[GTH_BROWSER_HEADER_SECTION_EDITOR_APPLY]);
gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar),
browser->priv->header_sections[GTH_BROWSER_HEADER_SECTION_EDITOR_COMMANDS]);
+ if (! gtk_application_prefers_app_menu (gtk_window_get_application (GTK_WINDOW (browser)))) {
+ gth_menu_manager_append_entries (gth_browser_get_menu_manager (browser,
GTH_BROWSER_MENU_MANAGER_GEARS_PREFERENCES_ACTIONS),
+ gears_preferences_action_entries,
+ G_N_ELEMENTS (gears_preferences_action_entries));
+ gth_menu_manager_append_entries (gth_browser_get_menu_manager (browser,
GTH_BROWSER_MENU_MANAGER_GEARS_HELP_ACTIONS),
+ gears_help_action_entries,
+ G_N_ELEMENTS (gears_help_action_entries));
+ gth_menu_manager_append_entries (gth_browser_get_menu_manager (browser,
GTH_BROWSER_MENU_MANAGER_GEARS_CLOSE_ACTIONS),
+ gears_close_action_entries,
+ G_N_ELEMENTS (gears_close_action_entries));
+ }
+
/* browser navigation */
gth_browser_add_header_bar_button (browser,
diff --git a/gthumb/gth-browser.h b/gthumb/gth-browser.h
index a0bae0a..b589264 100644
--- a/gthumb/gth-browser.h
+++ b/gthumb/gth-browser.h
@@ -37,6 +37,9 @@ G_BEGIN_DECLS
#define GTH_BROWSER_MENU_MANAGER_GEARS "gears"
#define GTH_BROWSER_MENU_MANAGER_GEARS_FOLDER_ACTIONS "gears.folder-actions"
#define GTH_BROWSER_MENU_MANAGER_GEARS_OTHER_ACTIONS "gears.other-actions"
+#define GTH_BROWSER_MENU_MANAGER_GEARS_PREFERENCES_ACTIONS "gears.preferences-actions"
+#define GTH_BROWSER_MENU_MANAGER_GEARS_HELP_ACTIONS "gears.help-actions"
+#define GTH_BROWSER_MENU_MANAGER_GEARS_CLOSE_ACTIONS "gears.close-actions"
#define GTH_BROWSER_MENU_MANAGER_FILE "file"
#define GTH_BROWSER_MENU_MANAGER_FILE_SCREEN_ACTIONS "file.screen-actions"
#define GTH_BROWSER_MENU_MANAGER_FILE_OPEN_ACTIONS "file.open-actions"
diff --git a/gthumb/resources/gears-menu.ui b/gthumb/resources/gears-menu.ui
index 7b5f0da..f66d380 100644
--- a/gthumb/resources/gears-menu.ui
+++ b/gthumb/resources/gears-menu.ui
@@ -44,5 +44,11 @@
</section>
<section id="other-actions">
</section>
+ <section id="preferences-actions">
+ </section>
+ <section id="help-actions">
+ </section>
+ <section id="close-actions">
+ </section>
</menu>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]