[devhelp] Retire app menu: first step
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devhelp] Retire app menu: first step
- Date: Fri, 12 Oct 2018 12:52:28 +0000 (UTC)
commit 52ed7d1c9fe97326a3fa5f755266734b71b4f73c
Author: Sébastien Wilmet <swilmet gnome org>
Date: Fri Oct 12 13:22:39 2018 +0200
Retire app menu: first step
First step to follow the GNOME goal:
https://gitlab.gnome.org/GNOME/Initiatives/issues/4
No longer create the app menu. In Devhelp there was already the code to
create the window menu containing the app actions (used e.g. on Xfce).
src/dh-app.c | 40 ++--------------------------------------
src/dh-window.c | 47 +++++------------------------------------------
2 files changed, 7 insertions(+), 80 deletions(-)
---
diff --git a/src/dh-app.c b/src/dh-app.c
index 26f280c1..65f5bfd4 100644
--- a/src/dh-app.c
+++ b/src/dh-app.c
@@ -47,7 +47,7 @@ add_menu_action_infos (DhApp *app)
const AmtkActionInfoEntry entries[] = {
/* action, icon, label, accel, tooltip */
- /* App menu */
+ /* Actions related to the whole application */
{ "app.new-window", NULL, N_("New _Window"), "<Control>n",
N_("Open a new window") },
{ "app.preferences", NULL, N_("_Preferences") },
@@ -57,7 +57,7 @@ add_menu_action_infos (DhApp *app)
{ "app.quit", NULL, N_("_Quit"), "<Control>q",
N_("Close all windows") },
- /* Window menu */
+ /* Actions related to the current main window */
{ "win.show-sidebar", NULL, N_("_Side Panel"), "F9",
N_("Toggle side panel visibility") },
{ "win.print", NULL, N_("_Print"), "<Control>p" },
@@ -422,41 +422,6 @@ setup_additional_accelerators (GtkApplication *app)
gtk_application_set_accels_for_action (app, "win.show-window-menu", accels);
}
-static void
-create_app_menu_if_needed (GtkApplication *app)
-{
- GMenu *app_menu;
- GMenu *section;
- AmtkFactory *factory;
-
- if (!gtk_application_prefers_app_menu (app))
- return;
-
- app_menu = g_menu_new ();
- factory = amtk_factory_new (NULL);
-
- section = g_menu_new ();
- amtk_gmenu_append_item (section, amtk_factory_create_gmenu_item (factory, "app.new-window"));
- amtk_gmenu_append_section (app_menu, NULL, section);
-
- section = g_menu_new ();
- amtk_gmenu_append_item (section, amtk_factory_create_gmenu_item (factory, "app.preferences"));
- amtk_gmenu_append_section (app_menu, NULL, section);
-
- section = g_menu_new ();
- amtk_gmenu_append_item (section, amtk_factory_create_gmenu_item (factory, "win.shortcuts-window"));
- amtk_gmenu_append_item (section, amtk_factory_create_gmenu_item (factory, "app.help"));
- amtk_gmenu_append_item (section, amtk_factory_create_gmenu_item (factory, "app.about"));
- amtk_gmenu_append_item (section, amtk_factory_create_gmenu_item (factory, "app.quit"));
- amtk_gmenu_append_section (app_menu, NULL, section);
-
- g_object_unref (factory);
- g_menu_freeze (app_menu);
-
- gtk_application_set_app_menu (app, G_MENU_MODEL (app_menu));
- g_object_unref (app_menu);
-}
-
static void
dh_app_startup (GApplication *application)
{
@@ -470,7 +435,6 @@ dh_app_startup (GApplication *application)
add_action_infos (app);
add_action_entries (app);
setup_additional_accelerators (GTK_APPLICATION (app));
- create_app_menu_if_needed (GTK_APPLICATION (app));
}
static void
diff --git a/src/dh-window.c b/src/dh-window.c
index 2b1f596e..8ee0e08f 100644
--- a/src/dh-window.c
+++ b/src/dh-window.c
@@ -468,38 +468,7 @@ add_actions (DhWindow *window)
}
static GMenuModel *
-create_window_menu_simple (void)
-{
- GMenu *menu;
- GMenu *section;
- AmtkFactory *factory;
-
- menu = g_menu_new ();
- factory = amtk_factory_new (NULL);
-
- section = g_menu_new ();
- amtk_gmenu_append_item (section, amtk_factory_create_gmenu_item (factory, "win.show-sidebar"));
- amtk_gmenu_append_section (menu, NULL, section);
-
- section = g_menu_new ();
- amtk_gmenu_append_item (section, amtk_factory_create_gmenu_item (factory, "win.print"));
- amtk_gmenu_append_item (section, amtk_factory_create_gmenu_item (factory, "win.find"));
- amtk_gmenu_append_section (menu, NULL, section);
-
- section = g_menu_new ();
- amtk_gmenu_append_item (section, amtk_factory_create_gmenu_item (factory, "win.zoom-in"));
- amtk_gmenu_append_item (section, amtk_factory_create_gmenu_item (factory, "win.zoom-out"));
- amtk_gmenu_append_item (section, amtk_factory_create_gmenu_item (factory, "win.zoom-default"));
- amtk_gmenu_append_section (menu, NULL, section);
-
- g_object_unref (factory);
- g_menu_freeze (menu);
-
- return G_MENU_MODEL (menu);
-}
-
-static GMenuModel *
-create_window_menu_plus_app_menu (void)
+create_menu (void)
{
GMenu *menu;
GMenu *section;
@@ -552,8 +521,7 @@ init_header_bar (DhWindow *window)
GtkStyleContext *style_context;
GtkWidget *back_button;
GtkWidget *forward_button;
- GtkApplication *app;
- GMenuModel *window_menu;
+ GMenuModel *menu;
GtkWidget *new_tab_button;
g_assert (priv->header_bar == NULL);
@@ -584,14 +552,9 @@ init_header_bar (DhWindow *window)
gtk_menu_button_set_direction (priv->window_menu_button, GTK_ARROW_NONE);
gtk_header_bar_pack_end (priv->header_bar, GTK_WIDGET (priv->window_menu_button));
- app = GTK_APPLICATION (g_application_get_default ());
- if (gtk_application_prefers_app_menu (app))
- window_menu = create_window_menu_simple ();
- else
- window_menu = create_window_menu_plus_app_menu ();
-
- gtk_menu_button_set_menu_model (priv->window_menu_button, window_menu);
- g_object_unref (window_menu);
+ menu = create_menu ();
+ gtk_menu_button_set_menu_model (priv->window_menu_button, menu);
+ g_object_unref (menu);
/* New tab button */
new_tab_button = gtk_button_new_from_icon_name ("tab-new-symbolic", GTK_ICON_SIZE_BUTTON);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]