[gnome-control-center/gnome-3-22] info: Split off CPU and graphics strings cleanup
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/gnome-3-22] info: Split off CPU and graphics strings cleanup
- Date: Wed, 16 Nov 2016 16:07:06 +0000 (UTC)
commit a0378a1608ad3958642e81c3375062d54213369b
Author: Bastien Nocera <hadess hadess net>
Date: Wed Nov 16 15:07:10 2016 +0100
info: Split off CPU and graphics strings cleanup
https://bugzilla.gnome.org/show_bug.cgi?id=774240
panels/info/Makefile.am | 4 +-
panels/info/cc-info-panel.c | 72 ++------------------------------
panels/info/info-cleanup.c | 95 +++++++++++++++++++++++++++++++++++++++++++
panels/info/info-cleanup.h | 23 ++++++++++
4 files changed, 125 insertions(+), 69 deletions(-)
---
diff --git a/panels/info/Makefile.am b/panels/info/Makefile.am
index 6e6f460..492fcb1 100644
--- a/panels/info/Makefile.am
+++ b/panels/info/Makefile.am
@@ -20,7 +20,9 @@ libinfo_la_SOURCES = \
cc-info-panel.c \
cc-info-panel.h \
gsd-disk-space-helper.h \
- gsd-disk-space-helper.c
+ gsd-disk-space-helper.c \
+ info-cleanup.h \
+ info-cleanup.c
libinfo_la_LIBADD = $(PANEL_LIBS) $(INFO_PANEL_LIBS)
diff --git a/panels/info/cc-info-panel.c b/panels/info/cc-info-panel.c
index 209f07c..c2eb48a 100644
--- a/panels/info/cc-info-panel.c
+++ b/panels/info/cc-info-panel.c
@@ -22,6 +22,7 @@
#include "cc-info-panel.h"
#include "cc-info-resources.h"
+#include "info-cleanup.h"
#include <glib.h>
#include <glib/gi18n.h>
@@ -214,71 +215,6 @@ load_gnome_version (char **version,
return ret;
};
-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<sup>\302\256</sup>"},
- { "Core[(]TM[)]", "Core<sup>\342\204\242</sup>"},
- { "Atom[(]TM[)]", "Atom<sup>\342\204\242</sup>"},
- { "Graphics Controller", "Graphics"},
- };
-
- if (*info == '\0')
- return NULL;
-
- pretty = g_markup_escape_text (info, -1);
- pretty = g_strchug (g_strchomp (pretty));
-
- 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 void
graphics_data_free (GraphicsData *gdata)
{
@@ -318,7 +254,7 @@ get_renderer_from_session (void)
return NULL;
}
- renderer = prettify_info (g_variant_get_string (renderer_variant, NULL));
+ renderer = info_cleanup (g_variant_get_string (renderer_variant, NULL));
g_variant_unref (renderer_variant);
return renderer;
@@ -348,7 +284,7 @@ get_renderer_from_helper (gboolean discrete_gpu)
if (renderer == NULL || *renderer == '\0')
goto out;
- ret = prettify_info (renderer);
+ ret = info_cleanup (renderer);
out:
g_free (renderer);
@@ -772,7 +708,7 @@ get_cpu_info (const glibtop_sysinfo *info)
g_hash_table_destroy (counts);
- ret = prettify_info (cpu->str);
+ ret = info_cleanup (cpu->str);
g_string_free (cpu, TRUE);
return ret;
diff --git a/panels/info/info-cleanup.c b/panels/info/info-cleanup.c
new file mode 100644
index 0000000..05c162e
--- /dev/null
+++ b/panels/info/info-cleanup.c
@@ -0,0 +1,95 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2010 Red Hat, Inc
+ * Copyright (C) 2008 William Jon McCann <jmccann redhat com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <config.h>
+
+#include <glib.h>
+#include "info-cleanup.h"
+
+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<sup>\302\256</sup>"},
+ { "Core[(]TM[)]", "Core<sup>\342\204\242</sup>"},
+ { "Atom[(]TM[)]", "Atom<sup>\342\204\242</sup>"},
+ { "Graphics Controller", "Graphics"},
+ };
+
+ if (*info == '\0')
+ return NULL;
+
+ pretty = g_markup_escape_text (info, -1);
+ pretty = g_strchug (g_strchomp (pretty));
+
+ 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;
+}
+
+char *
+info_cleanup (const char *input)
+{
+ return prettify_info (input);
+}
diff --git a/panels/info/info-cleanup.h b/panels/info/info-cleanup.h
new file mode 100644
index 0000000..cbc8d54
--- /dev/null
+++ b/panels/info/info-cleanup.h
@@ -0,0 +1,23 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2010 Red Hat, Inc
+ * Copyright (C) 2008 William Jon McCann <jmccann redhat com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <glib.h>
+
+char *info_cleanup (const char *input);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]