[gtk/about-polish: 1/2] demos: Brush up about dialogs
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/about-polish: 1/2] demos: Brush up about dialogs
- Date: Fri, 7 Aug 2020 02:19:47 +0000 (UTC)
commit 87a8fda163d419ee3e271787a40a60d5e83172a0
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Aug 6 22:17:36 2020 -0400
demos: Brush up about dialogs
Show OS info, and generally polish this here and there.
demos/gtk-demo/main.c | 8 ++++++++
demos/icon-browser/iconbrowserapp.c | 8 ++++++++
demos/print-editor/print-editor.c | 27 +++++++++++++++++++++++----
demos/widget-factory/widget-factory.c | 15 +++++++++++++++
4 files changed, 54 insertions(+), 4 deletions(-)
---
diff --git a/demos/gtk-demo/main.c b/demos/gtk-demo/main.c
index 21fc5f187c..95541fcfd9 100644
--- a/demos/gtk-demo/main.c
+++ b/demos/gtk-demo/main.c
@@ -146,10 +146,16 @@ activate_about (GSimpleAction *action,
NULL
};
char *version;
+ char *os_name;
+ char *os_version;
GString *s;
s = g_string_new ("");
+ os_name = g_get_os_info (G_OS_INFO_KEY_NAME);
+ os_version = g_get_os_info (G_OS_INFO_KEY_VERSION_ID);
+ if (os_name && os_version)
+ g_string_append_printf (s, "OS\t%s %s\n\n", os_name, os_version);
g_string_append (s, "System libraries\n");
g_string_append_printf (s, "\tGLib\t%d.%d.%d\n",
glib_major_version,
@@ -184,6 +190,8 @@ activate_about (GSimpleAction *action,
g_string_free (s, TRUE);
g_free (version);
+ g_free (os_name);
+ g_free (os_version);
}
static void
diff --git a/demos/icon-browser/iconbrowserapp.c b/demos/icon-browser/iconbrowserapp.c
index 31466c73dc..d214939c07 100644
--- a/demos/icon-browser/iconbrowserapp.c
+++ b/demos/icon-browser/iconbrowserapp.c
@@ -50,6 +50,8 @@ about_activated (GSimpleAction *action,
char *icon_theme;
char *version;
GString *s;
+ char *os_name;
+ char *os_version;
g_object_get (gtk_settings_get_default (),
"gtk-icon-theme-name", &icon_theme,
@@ -57,6 +59,10 @@ about_activated (GSimpleAction *action,
s = g_string_new ("");
+ os_name = g_get_os_info (G_OS_INFO_KEY_NAME);
+ os_version = g_get_os_info (G_OS_INFO_KEY_VERSION_ID);
+ if (os_name && os_version)
+ g_string_append_printf (s, "OS\t%s %s\n\n", os_name, os_version);
g_string_append (s, "System libraries\n");
g_string_append_printf (s, "\tGLib\t%d.%d.%d\n",
glib_major_version,
@@ -91,6 +97,8 @@ about_activated (GSimpleAction *action,
g_string_free (s, TRUE);
g_free (version);
g_free (icon_theme);
+ g_free (os_name);
+ g_free (os_version);
}
static GActionEntry app_entries[] =
diff --git a/demos/print-editor/print-editor.c b/demos/print-editor/print-editor.c
index 4bd88b0c4a..338274a7eb 100644
--- a/demos/print-editor/print-editor.c
+++ b/demos/print-editor/print-editor.c
@@ -1,6 +1,7 @@
#include <config.h>
#include <math.h>
#include <pango/pangocairo.h>
+#include <glib/gi18n.h>
#include <gtk/gtk.h>
static GtkWidget *main_window;
@@ -597,8 +598,23 @@ activate_about (GSimpleAction *action,
char *setting;
char **backends;
int i;
-
- sysinfo = g_string_new ("System libraries\n");
+ char *os_name;
+ char *os_version;
+ const char *authors[] = {
+ "Alexander Larsson",
+ NULL
+ };
+ const char *maintainers[] = {
+ "The GTK Team",
+ NULL
+ };
+
+ os_name = g_get_os_info (G_OS_INFO_KEY_NAME);
+ os_version = g_get_os_info (G_OS_INFO_KEY_VERSION_ID);
+ sysinfo = g_string_new ("");
+ if (os_name && os_version)
+ g_string_append_printf (sysinfo, "OS\t%s %s\n\n", os_name, os_version);
+ g_string_append (sysinfo, "System libraries\n");
g_string_append_printf (sysinfo, "\tGLib\t%d.%d.%d\n",
glib_major_version,
glib_minor_version,
@@ -614,8 +630,9 @@ activate_about (GSimpleAction *action,
g_object_get (gtk_settings_get_default (), "gtk-print-backends", &setting, NULL);
backends = g_strsplit (setting, ",", -1);
+ g_string_append (sysinfo, "\t");
for (i = 0; backends[i]; i++)
- g_string_append_printf (sysinfo, "\t%s\n", backends[i]);
+ g_string_append_printf (sysinfo, "%s ", backends[i]);
g_strfreev (backends);
g_free (setting);
@@ -632,11 +649,13 @@ activate_about (GSimpleAction *action,
"license-type", GTK_LICENSE_LGPL_2_1,
"website", "http://www.gtk.org",
"comments", "Program to demonstrate GTK printing",
- "authors", (const char *[]){ "Alexander Larsson", NULL },
+ "authors", authors,
"logo-icon-name", "org.gtk.PrintEditor4.Devel",
"title", "About GTK Print Editor",
"system-information", sysinfo->str,
NULL);
+ gtk_about_dialog_add_credit_section (GTK_ABOUT_DIALOG (g_object_get_data (G_OBJECT (main_window),
"gtk-about-dialog")),
+ _("Maintained by"), maintainers);
g_string_free (sysinfo, TRUE);
g_free (version);
diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c
index 885b81bd6d..4265cf5322 100644
--- a/demos/widget-factory/widget-factory.c
+++ b/demos/widget-factory/widget-factory.c
@@ -255,11 +255,21 @@ activate_about (GSimpleAction *action,
"Cosimo Cecchi",
NULL
};
+ const char *maintainers[] = {
+ "The GTK Team",
+ NULL
+ };
char *version;
+ char *os_name;
+ char *os_version;
GString *s;
s = g_string_new ("");
+ os_name = g_get_os_info (G_OS_INFO_KEY_NAME);
+ os_version = g_get_os_info (G_OS_INFO_KEY_VERSION_ID);
+ if (os_name && os_version)
+ g_string_append_printf (s, "OS\t%s %s\n\n", os_name, os_version);
g_string_append (s, "System libraries\n");
g_string_append_printf (s, "\tGLib\t%d.%d.%d\n",
glib_major_version,
@@ -292,8 +302,13 @@ activate_about (GSimpleAction *action,
"system-information", s->str,
NULL);
+ gtk_about_dialog_add_credit_section (GTK_ABOUT_DIALOG (g_object_get_data (G_OBJECT
(gtk_application_get_active_window (app)), "gtk-about-dialog")),
+ _("Maintained by"), maintainers);
+
g_string_free (s, TRUE);
g_free (version);
+ g_free (os_name);
+ g_free (os_version);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]