summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--multiload/global.h7
-rw-r--r--multiload/main.c29
-rw-r--r--multiload/properties.c37
3 files changed, 35 insertions, 38 deletions
diff --git a/multiload/global.h b/multiload/global.h
index 5e93be0a..c22bddad 100644
--- a/multiload/global.h
+++ b/multiload/global.h
@@ -17,6 +17,13 @@ G_BEGIN_DECLS
#define MAX_NET_THRESHOLD2 999999999
#define MAX_NET_THRESHOLD3 1000000000
+#define VIEW_CPULOAD_KEY "view-cpuload"
+#define VIEW_MEMLOAD_KEY "view-memload"
+#define VIEW_NETLOAD_KEY "view-netload"
+#define VIEW_SWAPLOAD_KEY "view-swapload"
+#define VIEW_LOADAVG_KEY "view-loadavg"
+#define VIEW_DISKLOAD_KEY "view-diskload"
+
typedef struct _MultiloadApplet MultiloadApplet;
typedef struct _LoadGraph LoadGraph;
typedef void (*LoadGraphDataFunc) (int, int [], LoadGraph *);
diff --git a/multiload/main.c b/multiload/main.c
index b670e019..e0d50a31 100644
--- a/multiload/main.c
+++ b/multiload/main.c
@@ -351,16 +351,17 @@ static void
multiload_create_graphs(MultiloadApplet *ma)
{
struct { const char *label;
+ const char *visibility_key;
const char *name;
int num_colours;
LoadGraphDataFunc callback;
} graph_types [graph_n] = {
- [graph_cpuload] = { _("CPU Load"), "cpuload", cpuload_n, GetLoad },
- [graph_memload] = { _("Memory Load"), "memload", memload_n, GetMemory },
- [graph_netload2] = { _("Net Load"), "netload2", 6, GetNet },
- [graph_swapload] = { _("Swap Load"), "swapload", swapload_n, GetSwap },
- [graph_loadavg] = { _("Load Average"), "loadavg", 3, GetLoadAvg },
- [graph_diskload] = { _("Disk Load"), "diskload", diskload_n, GetDiskLoad }
+ [graph_cpuload] = { _("CPU Load"), VIEW_CPULOAD_KEY, "cpuload", cpuload_n, GetLoad },
+ [graph_memload] = { _("Memory Load"), VIEW_MEMLOAD_KEY, "memload", memload_n, GetMemory },
+ [graph_netload2] = { _("Net Load"), VIEW_NETLOAD_KEY, "netload2", 6, GetNet },
+ [graph_swapload] = { _("Swap Load"), VIEW_SWAPLOAD_KEY, "swapload", swapload_n, GetSwap },
+ [graph_loadavg] = { _("Load Average"), VIEW_LOADAVG_KEY, "loadavg", 3, GetLoadAvg },
+ [graph_diskload] = { _("Disk Load"), VIEW_DISKLOAD_KEY, "diskload", diskload_n, GetDiskLoad }
};
gint speed, size;
@@ -387,27 +388,13 @@ multiload_create_graphs(MultiloadApplet *ma)
for (i = 0; i < graph_n; i++)
{
- gboolean visible;
- char *key;
-
- /* This is a special case to handle migration from an
- * older version of netload to a newer one in the
- * 2.25.1 release. */
- if (i == graph_netload2) {
- key = g_strdup ("view-netload");
- } else {
- key = g_strdup_printf ("view-%s", graph_types[i].name);
- }
- visible = g_settings_get_boolean (ma->settings, key);
- g_free (key);
-
ma->graphs[i] = load_graph_new (ma,
graph_types[i].num_colours,
graph_types[i].label,
i,
speed,
size,
- visible,
+ g_settings_get_boolean (ma->settings, graph_types[i].visibility_key),
graph_types[i].name,
graph_types[i].callback);
}
diff --git a/multiload/properties.c b/multiload/properties.c
index c1717e72..214ce27f 100644
--- a/multiload/properties.c
+++ b/multiload/properties.c
@@ -401,79 +401,82 @@ fill_properties(GtkWidget *dialog, MultiloadApplet *ma)
check_box = gtk_check_button_new_with_mnemonic(_("_Processor"));
ma->check_boxes[0] = check_box;
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_box),
- g_settings_get_boolean (ma->settings, "view-cpuload"));
+ g_settings_get_boolean (ma->settings, VIEW_CPULOAD_KEY));
g_object_set_data(G_OBJECT(check_box), "MultiloadApplet", ma);
g_object_set_data(G_OBJECT(check_box), "prop_type", GINT_TO_POINTER(PROP_CPU));
g_signal_connect(G_OBJECT(check_box), "toggled",
- G_CALLBACK(property_toggled_cb), "view-cpuload");
+ G_CALLBACK(property_toggled_cb), VIEW_CPULOAD_KEY);
gtk_box_pack_start (GTK_BOX (control_hbox), check_box, FALSE, FALSE, 0);
- if ( ! g_settings_is_writable (ma->settings, "view-cpuload"))
+ if ( ! g_settings_is_writable (ma->settings, VIEW_CPULOAD_KEY))
hard_set_sensitive (check_box, FALSE);
check_box = gtk_check_button_new_with_mnemonic(_("_Memory"));
ma->check_boxes[1] = check_box;
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_box),
- g_settings_get_boolean (ma->settings, "view-memload"));
+ g_settings_get_boolean (ma->settings, VIEW_MEMLOAD_KEY));
g_object_set_data(G_OBJECT(check_box), "MultiloadApplet", ma);
g_object_set_data(G_OBJECT(check_box), "prop_type", GINT_TO_POINTER(PROP_MEM));
g_signal_connect(G_OBJECT(check_box), "toggled",
- G_CALLBACK(property_toggled_cb), "view-memload");
+ G_CALLBACK(property_toggled_cb), VIEW_MEMLOAD_KEY);
gtk_box_pack_start (GTK_BOX (control_hbox), check_box, FALSE, FALSE, 0);
- if ( ! g_settings_is_writable (ma->settings, "view-memload"))
+ if ( ! g_settings_is_writable (ma->settings, VIEW_MEMLOAD_KEY))
hard_set_sensitive (check_box, FALSE);
check_box = gtk_check_button_new_with_mnemonic(_("_Network"));
ma->check_boxes[2] = check_box;
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_box),
- g_settings_get_boolean (ma->settings, "view-netload"));
+ g_settings_get_boolean (ma->settings, VIEW_NETLOAD_KEY));
g_object_set_data(G_OBJECT(check_box), "MultiloadApplet", ma);
g_object_set_data(G_OBJECT(check_box), "prop_type", GINT_TO_POINTER(PROP_NET));
g_signal_connect(G_OBJECT(check_box), "toggled",
- G_CALLBACK(property_toggled_cb), "view-netload");
+ G_CALLBACK(property_toggled_cb), VIEW_NETLOAD_KEY);
gtk_box_pack_start (GTK_BOX (control_hbox), check_box, FALSE, FALSE, 0);
- if ( ! g_settings_is_writable (ma->settings, "view-netload"))
+ if ( ! g_settings_is_writable (ma->settings, VIEW_NETLOAD_KEY))
hard_set_sensitive (check_box, FALSE);
check_box = gtk_check_button_new_with_mnemonic (_("S_wap Space"));
ma->check_boxes[3] = check_box;
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_box),
- g_settings_get_boolean (ma->settings, "view-swapload"));
+ g_settings_get_boolean (ma->settings, VIEW_SWAPLOAD_KEY));
g_object_set_data(G_OBJECT(check_box), "MultiloadApplet", ma);
g_object_set_data(G_OBJECT(check_box), "prop_type", GINT_TO_POINTER(PROP_SWAP));
g_signal_connect(G_OBJECT(check_box), "toggled",
- G_CALLBACK(property_toggled_cb), "view-swapload");
+ G_CALLBACK(property_toggled_cb), VIEW_SWAPLOAD_KEY);
gtk_box_pack_start (GTK_BOX (control_hbox), check_box, FALSE, FALSE, 0);
- if ( ! g_settings_is_writable (ma->settings, "view-swapload"))
+ if ( ! g_settings_is_writable (ma->settings, VIEW_SWAPLOAD_KEY))
hard_set_sensitive (check_box, FALSE);
check_box = gtk_check_button_new_with_mnemonic(_("_Load"));
ma->check_boxes[4] = check_box;
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_box),
- g_settings_get_boolean (ma->settings, "view-loadavg"));
+ g_settings_get_boolean (ma->settings, VIEW_LOADAVG_KEY));
g_object_set_data(G_OBJECT(check_box), "MultiloadApplet", ma);
g_object_set_data(G_OBJECT(check_box), "prop_type", GINT_TO_POINTER(PROP_AVG));
g_signal_connect(G_OBJECT(check_box), "toggled",
- G_CALLBACK(property_toggled_cb), "view-loadavg");
+ G_CALLBACK(property_toggled_cb), VIEW_LOADAVG_KEY);
gtk_box_pack_start(GTK_BOX(control_hbox), check_box, FALSE, FALSE, 0);
- if ( ! g_settings_is_writable (ma->settings, "view-loadavg"))
+ if ( ! g_settings_is_writable (ma->settings, VIEW_LOADAVG_KEY))
hard_set_sensitive (check_box, FALSE);
check_box = gtk_check_button_new_with_mnemonic(_("_Harddisk"));
ma->check_boxes[5] = check_box;
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_box),
- g_settings_get_boolean (ma->settings, "view-diskload"));
+ g_settings_get_boolean (ma->settings, VIEW_DISKLOAD_KEY));
g_object_set_data (G_OBJECT (check_box), "MultiloadApplet", ma);
g_object_set_data (G_OBJECT (check_box), "prop_type",
GINT_TO_POINTER (PROP_DISK));
g_signal_connect (G_OBJECT (check_box), "toggled",
- G_CALLBACK (property_toggled_cb), "view-diskload");
+ G_CALLBACK (property_toggled_cb), VIEW_DISKLOAD_KEY);
gtk_box_pack_start (GTK_BOX (control_hbox), check_box, FALSE, FALSE, 0);
+ if ( ! g_settings_is_writable (ma->settings, VIEW_DISKLOAD_KEY))
+ hard_set_sensitive (check_box, FALSE);
+
category_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_box_pack_start (GTK_BOX (categories_vbox), category_vbox, TRUE, TRUE, 0);
gtk_widget_show (category_vbox);