summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGünther Wagner <info@gunibert.de>2022-02-01 21:59:54 +0100
committerGünther Wagner <info@gunibert.de>2022-02-01 22:18:07 +0100
commit51b5ed4003c8d074e6edbbd946524d30e1b84ad5 (patch)
tree10fd8c202a19b226910cbd7fcbe3243051fd0113
parent9c4e1e0619d220347e58e43c9fed5b42566bcf16 (diff)
downloadlibrest-51b5ed4003c8d074e6edbbd946524d30e1b84ad5.tar.gz
demo: add about dialog
-rw-r--r--examples/demo/demo-main.c42
-rw-r--r--examples/demo/demo-window.ui14
2 files changed, 55 insertions, 1 deletions
diff --git a/examples/demo/demo-main.c b/examples/demo/demo-main.c
index b31d7dc..8f12404 100644
--- a/examples/demo/demo-main.c
+++ b/examples/demo/demo-main.c
@@ -19,6 +19,7 @@
*/
#include <gtk/gtk.h>
+#include <glib/gi18n.h>
#include <adwaita.h>
#include <gtksourceview/gtksource.h>
#include "demo-window.h"
@@ -37,6 +38,38 @@ on_activate (GApplication *app, gpointer user_data)
gtk_window_present (active_window);
}
+static void
+show_about (GSimpleAction *action,
+ GVariant *state,
+ gpointer user_data)
+{
+ const char *authors[] = {
+ "Günther Wagner",
+ NULL
+ };
+
+ const char *artists[] = {
+ "Günther Wagner",
+ NULL
+ };
+
+ GtkApplication *app = GTK_APPLICATION (user_data);
+ GtkWindow *window = gtk_application_get_active_window (app);
+
+ gtk_show_about_dialog (window,
+ "program-name", _("Librest Demo"),
+ "title", _("About Librest Demo"),
+ /* "logo-icon-name", "org.gnome.RestDemo", */
+ "copyright", "Copyright © 2022 Günther Wagner",
+ "comments", _("Tour of the features in Librest"),
+ "website", "https://gitlab.gnome.org/GNOME/librest",
+ "license-type", GTK_LICENSE_LGPL_2_1,
+ "authors", authors,
+ "artists", artists,
+ "translator-credits", _("translator-credits"),
+ NULL);
+}
+
gint
main (gint argc,
gchar *argv[])
@@ -47,7 +80,14 @@ main (gint argc,
g_set_prgname ("librest-demo");
g_set_application_name ("librest-demo");
- GtkApplication *app = gtk_application_new ("org.gnome.RestDemo", G_APPLICATION_FLAGS_NONE);
+ static GActionEntry app_entries[] = {
+ { "about", show_about, NULL, NULL, NULL },
+ };
+
+ AdwApplication *app = adw_application_new ("org.gnome.RestDemo", G_APPLICATION_FLAGS_NONE);
+ g_action_map_add_action_entries (G_ACTION_MAP (app),
+ app_entries, G_N_ELEMENTS (app_entries),
+ app);
g_signal_connect (app, "activate", G_CALLBACK (on_activate), NULL);
return g_application_run (G_APPLICATION (app), argc, argv);
diff --git a/examples/demo/demo-window.ui b/examples/demo/demo-window.ui
index 1216714..6134770 100644
--- a/examples/demo/demo-window.ui
+++ b/examples/demo/demo-window.ui
@@ -1,6 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk" version="4.0"/>
+ <menu id="primary_menu">
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">_About Librest Demo</attribute>
+ <attribute name="action">app.about</attribute>
+ </item>
+ </section>
+ </menu>
<template class="DemoWindow" parent="AdwApplicationWindow">
<property name="title">Librest Demo</property>
<property name="default-width">900</property>
@@ -13,6 +21,12 @@
<property name="orientation">vertical</property>
<child>
<object class="GtkHeaderBar" id="headerbar">
+ <child type="end">
+ <object class="GtkMenuButton">
+ <property name="menu-model">primary_menu</property>
+ <property name="icon-name">open-menu-symbolic</property>
+ </object>
+ </child>
</object>
</child>
<child>