From 1daac19072f117579cc1cad37bb940d7f07ffea8 Mon Sep 17 00:00:00 2001 From: Bruce Cowan <bruce@bcowan.me.uk> Date: Fri, 14 Oct 2022 20:19:08 +0100 Subject: [PATCH] Use automatic primary menu keyboard shortcut --- data/gtk/window.blp | 3 ++- src/main.c | 3 --- src/rugby-app-window.c | 12 ------------ 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/data/gtk/window.blp b/data/gtk/window.blp index be6e32a..8f7a6b1 100644 --- a/data/gtk/window.blp +++ b/data/gtk/window.blp @@ -24,8 +24,9 @@ template RugbyAppWindow : Adw.ApplicationWindow { } [end] - MenuButton menu_button { + MenuButton { direction: none; + primary: true; menu-model: app_menu; tooltip-text: "Main Menu"; } diff --git a/src/main.c b/src/main.c index b80e79c..50a7d64 100644 --- a/src/main.c +++ b/src/main.c @@ -68,9 +68,6 @@ on_startup (GApplication *app, app_entries, G_N_ELEMENTS (app_entries), app); - gtk_application_set_accels_for_action (GTK_APPLICATION (app), - "win.show-primary-menu", - (const char*[]) { "F10", NULL }); gtk_application_set_accels_for_action (GTK_APPLICATION (app), "app.prefs", (const char*[]) { "<Ctrl>comma", NULL }); diff --git a/src/rugby-app-window.c b/src/rugby-app-window.c index 956cdf8..eb422ff 100644 --- a/src/rugby-app-window.c +++ b/src/rugby-app-window.c @@ -18,7 +18,6 @@ struct _RugbyAppWindow AdwApplicationWindow parent; GtkWidget *scorespin; - GtkWidget *menu_button; GtkWidget *stack; GtkWidget *empty_page; GtkWidget *list_page; @@ -109,15 +108,6 @@ activate_score_changed (G_GNUC_UNUSED GSimpleAction *action, g_assert_not_reached (); } -static void -activate_show_primary_menu (G_GNUC_UNUSED GSimpleAction *action, - G_GNUC_UNUSED GVariant *parameter, - gpointer user_data) -{ - RugbyAppWindow *self = RUGBY_APP_WINDOW (user_data); - gtk_menu_button_popup (GTK_MENU_BUTTON (self->menu_button)); -} - static void rugby_app_window_dispose (GObject *object) { @@ -133,7 +123,6 @@ rugby_app_window_init (RugbyAppWindow *self) const GActionEntry win_entries[] = { { .name = "score-changed", .activate = activate_score_changed, .parameter_type = "s" }, - { .name = "show-primary-menu", .activate = activate_show_primary_menu }, }; g_action_map_add_action_entries (G_ACTION_MAP (self), @@ -157,7 +146,6 @@ rugby_app_window_class_init (RugbyAppWindowClass *klass) "/uk/me/bcowan/Rugby/gtk/window.ui"); gtk_widget_class_bind_template_child (widget_class, RugbyAppWindow, scorespin); - gtk_widget_class_bind_template_child (widget_class, RugbyAppWindow, menu_button); gtk_widget_class_bind_template_child (widget_class, RugbyAppWindow, stack); gtk_widget_class_bind_template_child (widget_class, RugbyAppWindow, empty_page); gtk_widget_class_bind_template_child (widget_class, RugbyAppWindow, list_page); -- GitLab