From fd824a7e03a8303801db03abf59fbdd5dfe3e39a Mon Sep 17 00:00:00 2001 From: Scott Balneaves Date: Tue, 1 Jan 2013 15:11:12 -0600 Subject: Fix Issue #14 --- src/org.mate.system-monitor.gschema.xml.in.in | 56 +++++++++++++++++++++++++-- src/procman.cpp | 22 ++++++++++- 2 files changed, 73 insertions(+), 5 deletions(-) diff --git a/src/org.mate.system-monitor.gschema.xml.in.in b/src/org.mate.system-monitor.gschema.xml.in.in index 3caadc7..3c2a75b 100644 --- a/src/org.mate.system-monitor.gschema.xml.in.in +++ b/src/org.mate.system-monitor.gschema.xml.in.in @@ -53,19 +53,67 @@ <_description>0 for the System Info, 1 for the processes list, 2 for the resources and 3 for the disks list - '#FF6E00' + '#FF0000' <_summary>Default graph cpu color - '#CB0C29' + '#0000FF' <_summary>Default graph cpu color - '#49A835' + '#FFFF00' <_summary>Default graph cpu color - '#2D7DB3' + '#00FF00' + <_summary>Default graph cpu color + + + '#FF6600' + <_summary>Default graph cpu color + + + '#6600CC' + <_summary>Default graph cpu color + + + '#990000' + <_summary>Default graph cpu color + + + '#000099' + <_summary>Default graph cpu color + + + '#FFCC00' + <_summary>Default graph cpu color + + + '#009900' + <_summary>Default graph cpu color + + + '#CC6600' + <_summary>Default graph cpu color + + + '#330099' + <_summary>Default graph cpu color + + + '#CC0066' + <_summary>Default graph cpu color + + + '#00FFCC' + <_summary>Default graph cpu color + + + '#FFCC99' + <_summary>Default graph cpu color + + + '#339999' <_summary>Default graph cpu color diff --git a/src/procman.cpp b/src/procman.cpp index 9c683ef..14f3465 100644 --- a/src/procman.cpp +++ b/src/procman.cpp @@ -66,6 +66,18 @@ ProcData* ProcData::get_instance() return &instance; } +static gboolean +has_key (gchar **keys, const gchar *key) +{ + gchar **loop = keys; + + while (*loop) { + if (!strcmp (*loop++, key)) + return TRUE; + } + + return FALSE; +} static void tree_changed_cb (GSettings *settings, const gchar *key, gpointer data) @@ -177,7 +189,15 @@ static void color_changed_cb (GSettings *settings, const gchar *key, gpointer data) { ProcData * const procdata = static_cast(data); - const gchar *color = g_settings_get_string (settings, key); + gchar **keys; + gchar *color = NULL; + + keys = g_settings_list_keys (settings); + if (has_key (keys, key)) + color = g_settings_get_string (settings, key); + else + color = "#FFFFFF"; /* white default color */ + g_strfreev (keys); if (g_str_has_prefix (key, "cpu-color")) { for (int i = 0; i < procdata->config.num_cpus; i++) { -- cgit v1.2.1