[gnome-robots: 1/2] menus: Update for GNOME 3.32 recommendations



commit 50a5a071907083c7a7fb28b2ec352724ca5047dc
Author: Jeremy Bicha <jbicha ubuntu com>
Date:   Thu Dec 6 16:49:49 2018 -0500

    menus: Update for GNOME 3.32 recommendations
    
    https://gitlab.gnome.org/GNOME/Initiatives/wikis/App-Menu-Retirement

 data/app-menu.ui   | 17 ++++++-----------
 src/gnome-robots.c | 11 ++++++++++-
 2 files changed, 16 insertions(+), 12 deletions(-)
---
diff --git a/data/app-menu.ui b/data/app-menu.ui
index e94f4bd..f887d02 100644
--- a/data/app-menu.ui
+++ b/data/app-menu.ui
@@ -1,37 +1,32 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <requires lib="gtk+" version="3.12"/>
-  <menu id="app-menu">
+  <menu id="primary-menu">
     <section>
       <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">_Preferences</attribute>
-        <attribute name="action">app.preferences</attribute>
-      </item>
       <item>
         <attribute name="label" translatable="yes">_Scores</attribute>
         <attribute name="action">app.scores</attribute>
       </item>
     </section>
     <section>
+      <item>
+        <attribute name="label" translatable="yes">_Preferences</attribute>
+        <attribute name="action">app.preferences</attribute>
+      </item>
       <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</attribute>
+        <attribute name="label" translatable="yes">_About Robots</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>
 </interface>
diff --git a/src/gnome-robots.c b/src/gnome-robots.c
index 3281c4c..fabdec1 100644
--- a/src/gnome-robots.c
+++ b/src/gnome-robots.c
@@ -339,7 +339,8 @@ create_category_from_key (const char *key, gpointer user_data)
 static void
 activate (GtkApplication *app, gpointer user_data)
 {
-  GtkWidget *errordialog, *vbox, *hbox, *label, *button, *gridframe;
+  GtkWidget *errordialog, *vbox, *hbox, *label, *button, *gridframe, *icon;
+  GMenu *appmenu;
   GtkSizeGroup *size_group;
   GtkStyleContext *style_context;
   GamesScoresDirectoryImporter *importer;
@@ -348,6 +349,14 @@ activate (GtkApplication *app, gpointer user_data)
   gtk_header_bar_set_title (GTK_HEADER_BAR (headerbar), _("Robots"));
   gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (headerbar), TRUE);
 
+  appmenu = gtk_application_get_menu_by_id (app, "primary-menu");
+  button = gtk_menu_button_new ();
+  icon = gtk_image_new_from_icon_name ("open-menu-symbolic", GTK_ICON_SIZE_BUTTON);
+  gtk_button_set_image (GTK_BUTTON (button), icon);
+  gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), (GMenuModel *) appmenu);
+  gtk_widget_show (button);
+  gtk_header_bar_pack_end (GTK_HEADER_BAR (headerbar), button);
+
   window = gtk_application_window_new (app);
   gtk_window_set_titlebar (GTK_WINDOW (window), headerbar);
   g_signal_connect (GTK_WINDOW (window), "configure-event", G_CALLBACK (window_configure_event_cb), NULL);


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