demos: Brush up about dialogs

Show OS info, and generally polish this here and there.
This commit is contained in:
Matthias Clasen 2020-08-06 22:17:36 -04:00
parent 79e6269058
commit 87a8fda163
4 changed files with 53 additions and 3 deletions

View File

@ -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

View File

@ -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[] =

View File

@ -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;
char *os_name;
char *os_version;
const char *authors[] = {
"Alexander Larsson",
NULL
};
const char *maintainers[] = {
"The GTK Team",
NULL
};
sysinfo = g_string_new ("System libraries\n");
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);

View File

@ -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