From 560ccfcd138936fdcae591aa212c01fa58606a79 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 31 Mar 2013 20:28:19 -0400 Subject: [PATCH] info: Switch around GNOME and distro information This makes the distribution logo prominent, and puts GNOME version information in the small print. https://bugzilla.gnome.org/show_bug.cgi?id=695691 --- panels/info/cc-info-panel.c | 97 ++++++++++++++++++++++++++++++++++----------- panels/info/info.ui | 77 +++++++++++++++++++++++++---------- 2 files changed, 128 insertions(+), 46 deletions(-) diff --git a/panels/info/cc-info-panel.c b/panels/info/cc-info-panel.c index 67f9b5d..6baee67 100644 --- a/panels/info/cc-info-panel.c +++ b/panels/info/cc-info-panel.c @@ -511,48 +511,92 @@ cc_info_panel_class_init (CcInfoPanelClass *klass) } static char * +get_item (const char *buffer, const char *name) +{ + char *label, *start, *end, *result; + char end_char; + + result = NULL; + start = NULL; + end = NULL; + label = g_strconcat (name, "=", NULL); + if ((start = strstr (buffer, label)) != NULL) + { + start += strlen (label); + end_char = '\n'; + if (*start == '"') + { + start++; + end_char = '"'; + } + + end = strchr (start, end_char); + } + + if (start != NULL && end != NULL) + { + result = g_strndup (start, end - start); + } + + g_free (label); + + return result; +} + +static char * get_os_type (void) { - int bits; char *buffer; + char *pretty_name; char *name; char *result; + char *version; + result = NULL; name = NULL; - + version = NULL; if (g_file_get_contents ("/etc/os-release", &buffer, NULL, NULL)) { - char *start, *end; - - start = end = NULL; - if ((start = strstr (buffer, "PRETTY_NAME=\"")) != NULL) - { - start += strlen ("PRETTY_NAME=\""); - end = strchr (start, '"'); - } + pretty_name = get_item (buffer, "PRETTY_NAME"); + name = get_item (buffer, "NAME"); + version = get_item (buffer, "VERSION_ID"); - if (start != NULL && end != NULL) - { - name = g_strndup (start, end - start); - } + g_free (buffer); + } - g_free (buffer); + if (pretty_name) + { + result = g_strdup (pretty_name); } + else if (name && version) + { + result = g_strconcat (name, " ", version, NULL); + } + else if (name) + { + result = g_strdup (name); + } + + g_free (pretty_name); + g_free (name); + g_free (version); + + return result; +} + +static char * +get_os_description (void) +{ + int bits; + gchar *result; if (GLIB_SIZEOF_VOID_P == 8) bits = 64; else bits = 32; - /* translators: This is the name of the OS, followed by the type - * of architecture, for example: - * "Fedora 18 (Spherical Cow) 64-bit" or "Ubuntu (Oneric Ocelot) 32-bit" */ - if (name) - result = g_strdup_printf (_("%s %d-bit"), name, bits); - else - result = g_strdup_printf (_("%d-bit"), bits); - - g_free (name); + /* translators: This is the the type of OS architecture, eg: "64-bit" or "32-bit" */ + result = g_strdup_printf (_("%d-bit"), bits); return result; } @@ -1579,6 +1623,11 @@ info_panel_setup_overview (CcInfoPanel *self) gtk_label_set_text (GTK_LABEL (widget), text ? text : ""); g_free (text); + widget = WID ("os_description_label"); + text = get_os_description (); + gtk_label_set_text (GTK_LABEL (widget), text ? text : ""); + g_free (text); + get_primary_disc_info (self); widget = WID ("graphics_label"); diff --git a/panels/info/info.ui b/panels/info/info.ui index c7b193a..74f3c98 100644 --- a/panels/info/info.ui +++ b/panels/info/info.ui @@ -237,13 +237,14 @@ True False - 18 + 6 vertical True False - GnomeLogoVerticalMedium.svg + 128 + fedora-logo-icon False @@ -252,11 +253,12 @@ - + True False Version 3.0 True + 24 @@ -320,19 +322,35 @@ + + True + False + 1 + OS Type + os_description_label + + + + 3 + 4 + + + True False 1 - Base system - os_type_label + GNOME + version_label - 4 - 5 + 5 + 6 @@ -347,8 +365,8 @@ - 6 - 7 + 7 + 8 @@ -392,7 +410,7 @@ - + True False 0 @@ -402,8 +420,23 @@ 1 2 - 4 - 5 + 3 + 4 + + + + + True + False + 0 + Unknown + True + + + 1 + 2 + 5 + 6 @@ -417,8 +450,8 @@ 1 2 - 6 - 7 + 7 + 8 @@ -500,8 +533,8 @@ - 3 - 4 + 4 + 5 @@ -529,8 +562,8 @@ 1 2 - 3 - 4 + 4 + 5 @@ -548,8 +581,8 @@ - 5 - 6 + 6 + 7 @@ -563,8 +596,8 @@ 1 2 - 5 - 6 + 6 + 7 -- 1.8.3.1