[libadwaita/wip/exalm/demo: 3/12] demo: Add an about dialog




commit 5edf3989b86fbb6017aa85d937eb401424941852
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Wed Oct 13 15:25:56 2021 +0500

    demo: Add an about dialog

 demo/adw-demo-window.ui |  4 ++++
 demo/adwaita-demo.c     | 50 +++++++++++++++++++++++++++++++++++++++++++++++++
 demo/meson.build        |  2 ++
 3 files changed, 56 insertions(+)
---
diff --git a/demo/adw-demo-window.ui b/demo/adw-demo-window.ui
index 770a1e78..206347aa 100644
--- a/demo/adw-demo-window.ui
+++ b/demo/adw-demo-window.ui
@@ -9,6 +9,10 @@
         <attribute name="label" translatable="yes">_Preferences</attribute>
         <attribute name="action">app.preferences</attribute>
       </item>
+      <item>
+        <attribute name="label" translatable="yes">_About Adwaita Demo</attribute>
+        <attribute name="action">app.about</attribute>
+      </item>
     </section>
   </menu>
   <menu id="sample_menu">
diff --git a/demo/adwaita-demo.c b/demo/adwaita-demo.c
index 48f95356..d49ab358 100644
--- a/demo/adwaita-demo.c
+++ b/demo/adwaita-demo.c
@@ -1,3 +1,4 @@
+#include <glib/gi18n.h>
 #include <gtk/gtk.h>
 #include <adwaita.h>
 
@@ -17,6 +18,54 @@ show_preferences (GSimpleAction *action,
   gtk_window_present (GTK_WINDOW (preferences));
 }
 
+static void
+show_about (GSimpleAction *action,
+            GVariant      *state,
+            gpointer       user_data)
+{
+  const char *authors[] = {
+    "Adrien Plazas",
+    "Alexander Mikhaylenko",
+    "Guido Günther",
+    "Julian Sparber",
+    "Yetizone",
+    "Zander Brown",
+    NULL
+  };
+
+  const char *artists[] = {
+    "GNOME Design Team",
+    NULL
+  };
+
+  GtkApplication *app = GTK_APPLICATION (user_data);
+  GtkWindow *window = gtk_application_get_active_window (app);
+  g_autofree char *version;
+
+  version = g_strdup_printf ("%s\nRunning against libadwaita %d.%d.%d, GTK %d.%d.%d",
+                             ADW_VERSION_S,
+                             adw_get_major_version (),
+                             adw_get_minor_version (),
+                             adw_get_micro_version (),
+                             gtk_get_major_version (),
+                             gtk_get_minor_version (),
+                             gtk_get_micro_version ());
+
+  gtk_show_about_dialog (window,
+                         "program-name", _("Adwaita Demo"),
+                         "title", _("About Adwaita Demo"),
+                         "logo-icon-name", "org.gnome.Adwaita1.Demo",
+                         "version", version,
+                         "copyright", "Copyright © 2017–2021 Purism SPC",
+                         "comments", _("Tour of the features in Libadwaita"),
+                         "website", "https://gitlab.gnome.org/GNOME/libadwaita";,
+                         "license-type", GTK_LICENSE_LGPL_2_1,
+                         "authors", authors,
+                         "artists", artists,
+                         "translator-credits", _("translator-credits"),
+                         NULL);
+}
+
 static void
 show_window (GtkApplication *app)
 {
@@ -35,6 +84,7 @@ main (int    argc,
   int status;
   static GActionEntry app_entries[] = {
     { "preferences", show_preferences, NULL, NULL, NULL },
+    { "about", show_about, NULL, NULL, NULL },
   };
 
   app = adw_application_new ("org.gnome.Adwaita1.Demo", G_APPLICATION_NON_UNIQUE);
diff --git a/demo/meson.build b/demo/meson.build
index 798b23cf..9239178e 100644
--- a/demo/meson.build
+++ b/demo/meson.build
@@ -1,5 +1,7 @@
 if get_option('examples')
 
+subdir('data')
+
 adwaita_demo_resources = gnome.compile_resources(
    'adwaita-demo-resources',
    'adwaita-demo.gresources.xml',


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