[gtk/gtk-demo-inspector] gtk-demo: Add a gear menu



commit f6afa3d03fc5889fc7cd36ba99c993f1e64888ba
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Apr 16 20:34:59 2019 -0400

    gtk-demo: Add a gear menu
    
    Modernize the about dialog, and make it available
    from a gear menu, together with a way to bring up
    the inspector.

 demos/gtk-demo/main.c  | 42 ++++++++++++++++++++++++++++++++++++------
 demos/gtk-demo/main.ui | 19 +++++++++++++++++++
 2 files changed, 55 insertions(+), 6 deletions(-)
---
diff --git a/demos/gtk-demo/main.c b/demos/gtk-demo/main.c
index dd9754d4bc..f37ca001bb 100644
--- a/demos/gtk-demo/main.c
+++ b/demos/gtk-demo/main.c
@@ -45,22 +45,43 @@ activate_about (GSimpleAction *action,
     "The GTK Team",
     NULL
   };
+  char *version;
+  GString *s;
+
+  s = g_string_new ("");
+
+  g_string_append (s, "System libraries\n");
+  g_string_append_printf (s, "\tGLib\t%d.%d.%d\n",
+                          glib_major_version,
+                          glib_minor_version,
+                          glib_micro_version);
+  g_string_append_printf (s, "\tGTK\t%d.%d.%d\n",
+                          gtk_get_major_version (),
+                          gtk_get_minor_version (),
+                          gtk_get_micro_version ());
+  g_string_append_printf (s, "\nA link can apppear here: <http://www.gtk.org>");
+
+  version = g_strdup_printf ("%s\nRunning against GTK %d.%d.%d",
+                             PACKAGE_VERSION,
+                             gtk_get_major_version (),
+                             gtk_get_minor_version (),
+                             gtk_get_micro_version ());
 
   gtk_show_about_dialog (GTK_WINDOW (gtk_application_get_active_window (app)),
                          "program-name", "GTK Demo",
-                         "version", g_strdup_printf ("%s,\nRunning against GTK %d.%d.%d",
-                                                     PACKAGE_VERSION,
-                                                     gtk_get_major_version (),
-                                                     gtk_get_minor_version (),
-                                                     gtk_get_micro_version ()),
-                         "copyright", "(C) 1997-2013 The GTK Team",
+                         "version", version,
+                         "copyright", "© 1997—2019 The GTK Team",
                          "license-type", GTK_LICENSE_LGPL_2_1,
                          "website", "http://www.gtk.org";,
                          "comments", "Program to demonstrate GTK widgets",
                          "authors", authors,
                          "logo-icon-name", "org.gtk.Demo4",
                          "title", "About GTK Demo",
+                         "system-information", s->str,
                          NULL);
+
+  g_string_free (s, TRUE);
+  g_free (version);
 }
 
 static void
@@ -84,6 +105,14 @@ activate_quit (GSimpleAction *action,
     }
 }
 
+static void
+activate_inspector (GSimpleAction *action,
+                    GVariant      *parameter,
+                    gpointer       user_data)
+{
+  gtk_window_set_interactive_debugging (TRUE);
+}
+
 static void
 window_closed_cb (GtkWidget *window, gpointer data)
 {
@@ -1200,6 +1229,7 @@ main (int argc, char **argv)
   static GActionEntry app_entries[] = {
     { "about", activate_about, NULL, NULL, NULL },
     { "quit", activate_quit, NULL, NULL, NULL },
+    { "inspector", activate_inspector, NULL, NULL, NULL },
   };
 
   /* Most code in gtk-demo is intended to be exemplary, but not
diff --git a/demos/gtk-demo/main.ui b/demos/gtk-demo/main.ui
index 59310762a9..bf70a37be6 100644
--- a/demos/gtk-demo/main.ui
+++ b/demos/gtk-demo/main.ui
@@ -1,5 +1,17 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
+  <menu id="gear_menu">
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">_Inspector</attribute>
+        <attribute name="action">app.inspector</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">_About GTK Demo</attribute>
+        <attribute name="action">app.about</attribute>
+      </item>
+    </section>
+  </menu>
   <object class="GtkTreeStore" id="treestore">
     <columns>
       <column type="gchararray"/>
@@ -35,6 +47,13 @@
             </child>
           </object>
         </child>
+        <child type="end">
+          <object class="GtkMenuButton" id="gear_menu_button">
+            <property name="valign">center</property>
+            <property name="menu-model">gear_menu</property>
+            <property name="icon-name">open-menu-symbolic</property>
+          </object>
+        </child>
       </object>
     </child>
     <child>


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