diff --git a/panels/info/cc-info-panel.c b/panels/info/cc-info-panel.c index da1a8aad6..c9b3c47cc 100644 --- a/panels/info/cc-info-panel.c +++ b/panels/info/cc-info-panel.c @@ -162,6 +162,175 @@ load_gnome_version (char **version, return ret; }; +static char * +get_graphics_info_lspci (void) +{ + GError *error; + GRegex *re; + GMatchInfo *match_info; + char *output; + GString *info; + + info = g_string_new (NULL); + + error = NULL; + g_spawn_command_line_sync ("lspci -nn", &output, NULL, NULL, &error); + if (error != NULL) + { + g_warning ("Unable to get graphics info: %s", error->message); + g_error_free (error); + return NULL; + } + + re = g_regex_new ("^[^ ]+ VGA compatible controller [^:]*: ([^([]+).*$", G_REGEX_MULTILINE, 0, &error); + if (re == NULL) + { + g_warning ("Error building regex: %s", error->message); + g_error_free (error); + goto out; + } + + g_regex_match (re, output, 0, &match_info); + while (g_match_info_matches (match_info)) + { + char *device; + + device = g_match_info_fetch (match_info, 1); + g_string_append_printf (info, "%s ", device); + g_free (device); + + g_match_info_next (match_info, NULL); + } + + g_match_info_free (match_info); + g_regex_unref (re); + + out: + g_free (output); + + return g_string_free (info, FALSE); +} + +static char * +get_graphics_info_glxinfo (void) +{ + GError *error; + GRegex *re; + GMatchInfo *match_info; + char *output; + GString *info; + + info = g_string_new (NULL); + + error = NULL; + g_spawn_command_line_sync ("glxinfo -l", &output, NULL, NULL, &error); + if (error != NULL) + { + g_warning ("Unable to get graphics info: %s", error->message); + g_error_free (error); + return NULL; + } + + re = g_regex_new ("^OpenGL renderer string: (.+)$", G_REGEX_MULTILINE, 0, &error); + if (re == NULL) + { + g_warning ("Error building regex: %s", error->message); + g_error_free (error); + goto out; + } + + g_regex_match (re, output, 0, &match_info); + while (g_match_info_matches (match_info)) + { + char *device; + + device = g_match_info_fetch (match_info, 1); + g_string_append_printf (info, "%s ", device); + g_free (device); + + g_match_info_next (match_info, NULL); + } + g_match_info_free (match_info); + g_regex_unref (re); + + out: + g_free (output); + + return g_string_free (info, FALSE); +} + +typedef struct +{ + char *regex; + char *replacement; +} ReplaceStrings; + +static char * +prettify_info (const char *info) +{ + char *pretty; + int i; + static const ReplaceStrings rs[] = { + { "Mesa DRI ", ""}, + { "Intel[(]R[)]", "Intel\302\256"}, + { "Core[(]TM[)]", "Core\342\204\242"}, + { "Graphics Controller", "Graphics"}, + }; + + pretty = g_markup_escape_text (info, -1); + + for (i = 0; i < G_N_ELEMENTS (rs); i++) + { + GError *error; + GRegex *re; + char *new; + + error = NULL; + + re = g_regex_new (rs[i].regex, 0, 0, &error); + if (re == NULL) + { + g_warning ("Error building regex: %s", error->message); + g_error_free (error); + continue; + } + + new = g_regex_replace_literal (re, + pretty, + -1, + 0, + rs[i].replacement, + 0, + &error); + + g_regex_unref (re); + + if (error != NULL) + { + g_warning ("Error replacing %s: %s", rs[i].regex, error->message); + g_error_free (error); + continue; + } + + g_free (pretty); + pretty = new; + } + + return pretty; +} + +static char * +get_graphics_info (void) +{ + char *info; + + info = get_graphics_info_glxinfo (); + if (info == NULL) + info = get_graphics_info_lspci (); + + return info; +} + static void cc_info_panel_get_property (GObject *object, guint property_id, @@ -440,6 +609,7 @@ cc_info_panel_init (CcInfoPanel *self) glibtop_mem mem; const glibtop_sysinfo *info; char *text; + char *pretty; self->priv = INFO_PANEL_PRIVATE (self); @@ -478,7 +648,9 @@ cc_info_panel_init (CcInfoPanel *self) widget = WID (self->priv->builder, "processor_label"); text = get_cpu_info (info); - gtk_label_set_text (GTK_LABEL (widget), text ? text : ""); + pretty = prettify_info (text); + gtk_label_set_markup (GTK_LABEL (widget), pretty ? pretty : ""); + g_free (pretty); g_free (text); widget = WID (self->priv->builder, "os_type_label"); @@ -491,6 +663,13 @@ cc_info_panel_init (CcInfoPanel *self) gtk_label_set_text (GTK_LABEL (widget), text ? text : ""); g_free (text); + text = get_graphics_info (); + pretty = prettify_info (text); + widget = WID (self->priv->builder, "graphics_label"); + gtk_label_set_markup (GTK_LABEL (widget), pretty ? pretty : ""); + g_free (text); + g_free (pretty); + widget = WID (self->priv->builder, "info_vbox"); gtk_widget_reparent (widget, (GtkWidget *) self); } diff --git a/panels/info/info.ui b/panels/info/info.ui index d197a1d23..66db5ee3c 100644 --- a/panels/info/info.ui +++ b/panels/info/info.ui @@ -1,26 +1,28 @@ - + - + False True + False 10 - vertical 12 True + False 20 True - vertical + False 18 True + False GnomeLogoVerticalMedium.svg @@ -32,10 +34,11 @@ True - Version 3.0 + False + Version 3.0 True - + @@ -47,12 +50,14 @@ True - 5 + False + 6 3 12 5 + False True 1 Device name: @@ -61,6 +66,7 @@ True + False 1 Memory: @@ -72,6 +78,7 @@ True + False 1 Processor: @@ -83,30 +90,32 @@ True + False 1 OS type: - - 3 - 4 - - - - - True - 1 - Disk: - 4 5 + + + True + False + 1 + Disk: + + + 5 + 6 + + True True - + 12 False @@ -118,8 +127,9 @@ True + False 0 - 2 GB + Unknown True @@ -132,8 +142,9 @@ True + False 0 - AmTel Duo Core 2.2 GHz + Unknown True @@ -146,22 +157,9 @@ True + False 0 - 32-bit - True - - - 1 - 2 - 3 - 4 - - - - - True - 0 - 80 GB (4 GB free) + Unknown True @@ -171,10 +169,26 @@ 5 + + + True + False + 0 + Unknown + True + + + 1 + 2 + 5 + 6 + + True - + False + 2 @@ -185,7 +199,8 @@ True - + False + 2 @@ -198,7 +213,8 @@ True - + False + 2 @@ -211,7 +227,48 @@ True - + False + + + + 2 + 3 + 4 + 5 + GTK_FILL + + + + + True + False + + + + 2 + 3 + 5 + 6 + GTK_FILL + + + + + True + False + 1 + Graphics: + + + 3 + 4 + + + + + True + False + 2 @@ -222,16 +279,18 @@ - + True - + False + 0 + Unknown + True - 2 - 3 - 4 - 5 - GTK_FILL + 1 + 2 + 3 + 4 @@ -245,12 +304,15 @@ + True + True 0 True + False end @@ -258,6 +320,7 @@ True True True + False False @@ -272,6 +335,7 @@ True True True + False False