From 51b5ed4003c8d074e6edbbd946524d30e1b84ad5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Wagner?= Date: Tue, 1 Feb 2022 21:59:54 +0100 Subject: demo: add about dialog --- examples/demo/demo-main.c | 42 +++++++++++++++++++++++++++++++++++++++++- examples/demo/demo-window.ui | 14 ++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) (limited to 'examples') 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 +#include #include #include #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 @@ + +
+ + _About Librest Demo + app.about + +
+