[gtk/matthiasc/for-master] icon-browser: Add a gear menu
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master] icon-browser: Add a gear menu
- Date: Mon, 27 Apr 2020 02:01:00 +0000 (UTC)
commit 91c7b24815f9a3eee6856f44c2565da0c5cdf278
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Apr 26 21:59:28 2020 -0400
icon-browser: Add a gear menu
Add an about dialog, and make the inspector available.
demos/icon-browser/iconbrowserapp.c | 69 ++++++++++++++++++++++++++++++++++++-
demos/icon-browser/window.ui | 19 ++++++++++
2 files changed, 87 insertions(+), 1 deletion(-)
---
diff --git a/demos/icon-browser/iconbrowserapp.c b/demos/icon-browser/iconbrowserapp.c
index 8c7591fc1a..f5b7c76844 100644
--- a/demos/icon-browser/iconbrowserapp.c
+++ b/demos/icon-browser/iconbrowserapp.c
@@ -1,3 +1,4 @@
+#include "config.h"
#include <gtk/gtk.h>
#include "iconbrowserapp.h"
@@ -28,9 +29,75 @@ quit_activated (GSimpleAction *action,
g_application_quit (G_APPLICATION (app));
}
+static void
+inspector_activated (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer app)
+{
+ gtk_window_set_interactive_debugging (TRUE);
+}
+
+static void
+about_activated (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ GtkApplication *app = user_data;
+ const gchar *authors[] = {
+ "The GTK Team",
+ NULL
+ };
+ char *icon_theme;
+ char *version;
+ GString *s;
+
+ g_object_get (gtk_settings_get_default (),
+ "gtk-icon-theme-name", &icon_theme,
+ NULL);
+
+ 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, "\tPango\t%s\n",
+ pango_version_string ());
+ 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, "\nIcon theme\n\t%s", icon_theme);
+ 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 Icon Browser",
+ "version", version,
+ "copyright", "© 1997—2020 The GTK Team",
+ "license-type", GTK_LICENSE_LGPL_2_1,
+ "website", "http://www.gtk.org",
+ "comments", "Program to browse themed icons",
+ "authors", authors,
+ "logo-icon-name", "org.gtk.Demo4",
+ "title", "About GTK Icon Browser",
+ "system-information", s->str,
+ NULL);
+
+ g_string_free (s, TRUE);
+ g_free (version);
+ g_free (icon_theme);
+}
+
static GActionEntry app_entries[] =
{
- { "quit", quit_activated, NULL, NULL, NULL }
+ { "quit", quit_activated, NULL, NULL, NULL },
+ { "inspector", inspector_activated, NULL, NULL, NULL },
+ { "about", about_activated, NULL, NULL, NULL }
};
static void
diff --git a/demos/icon-browser/window.ui b/demos/icon-browser/window.ui
index 16707599ba..ffe6612f32 100644
--- a/demos/icon-browser/window.ui
+++ b/demos/icon-browser/window.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 Icon Browser</attribute>
+ <attribute name="action">app.about</attribute>
+ </item>
+ </section>
+ </menu>
<object class="IconStore" id="store"/>
<object class="GtkTreeModelFilter" id="filter_model">
<property name="child-model">store</property>
@@ -36,6 +48,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>
<child type="end">
<object class="GtkToggleButton" id="search">
<style>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]