[gnome-robots] Fix New Game, Help, and Quit accelerators



commit 150e9814938dd76ed3700d6bc46d276603760f2f
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Fri Jan 3 20:01:33 2020 -0600

    Fix New Game, Help, and Quit accelerators
    
    These broke in
    https://gitlab.gnome.org/GNOME/gnome-robots/commit/50a5a071907083c7a7fb28b2ec352724ca5047dc.
    
    Fixes #10 and also fixes #11

 data/app-menu.ui   | 2 --
 src/gnome-robots.c | 7 +++++++
 2 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/data/app-menu.ui b/data/app-menu.ui
index f887d02..4153c87 100644
--- a/data/app-menu.ui
+++ b/data/app-menu.ui
@@ -6,7 +6,6 @@
       <item>
         <attribute name="label" translatable="yes">_New Game</attribute>
         <attribute name="action">app.new-game</attribute>
-        <attribute name="accel">&lt;Primary&gt;n</attribute>
       </item>
       <item>
         <attribute name="label" translatable="yes">_Scores</attribute>
@@ -21,7 +20,6 @@
       <item>
         <attribute name="label" translatable="yes">_Help</attribute>
         <attribute name="action">app.help</attribute>
-        <attribute name="accel">F1</attribute>
       </item>
       <item>
         <attribute name="label" translatable="yes">_About Robots</attribute>
diff --git a/src/gnome-robots.c b/src/gnome-robots.c
index 2958de2..ac70ba2 100644
--- a/src/gnome-robots.c
+++ b/src/gnome-robots.c
@@ -344,6 +344,9 @@ activate (GtkApplication *app, gpointer user_data)
   GtkSizeGroup *size_group;
   GtkStyleContext *style_context;
   GamesScoresDirectoryImporter *importer;
+  const gchar *new_game_accels[] = { "<Primary>n", NULL };
+  const gchar *help_accels[] = { "F1", NULL };
+  const gchar *quit_accels[] = { "<Primary>q", NULL };
 
   headerbar = gtk_header_bar_new ();
   gtk_header_bar_set_title (GTK_HEADER_BAR (headerbar), _("Robots"));
@@ -368,6 +371,10 @@ activate (GtkApplication *app, gpointer user_data)
   g_action_map_add_action_entries (G_ACTION_MAP (app), app_entries, G_N_ELEMENTS (app_entries), app);
   g_action_map_add_action_entries (G_ACTION_MAP (window), win_entries, G_N_ELEMENTS (win_entries), app);
 
+  gtk_application_set_accels_for_action (app, "app.new-game", new_game_accels);
+  gtk_application_set_accels_for_action (app, "app.help", help_accels);
+  gtk_application_set_accels_for_action (app, "app.quit", quit_accels);
+
   make_cursors ();
 
   game_area = gtk_drawing_area_new ();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]