diff options
Diffstat (limited to 'multiload')
-rw-r--r-- | multiload/data/org.mate.panel.applet.multiload.gschema.xml.in | 3 | ||||
-rw-r--r-- | multiload/src/global.h | 4 | ||||
-rw-r--r-- | multiload/src/load-graph.c | 4 | ||||
-rw-r--r-- | multiload/src/main.c | 9 | ||||
-rw-r--r-- | multiload/src/properties.c | 60 |
5 files changed, 45 insertions, 35 deletions
diff --git a/multiload/data/org.mate.panel.applet.multiload.gschema.xml.in b/multiload/data/org.mate.panel.applet.multiload.gschema.xml.in index 9f199bc3..01e6658d 100644 --- a/multiload/data/org.mate.panel.applet.multiload.gschema.xml.in +++ b/multiload/data/org.mate.panel.applet.multiload.gschema.xml.in @@ -24,7 +24,8 @@ <default>false</default> <summary>Enable disk load graph</summary> </key> - <key name="speed" type="i"> + <key name="speed" type="u"> + <range min="50" max="60000"/> <default>500</default> <summary>Applet refresh rate in milliseconds</summary> </key> diff --git a/multiload/src/global.h b/multiload/src/global.h index da3383c4..558bcf67 100644 --- a/multiload/src/global.h +++ b/multiload/src/global.h @@ -24,6 +24,10 @@ G_BEGIN_DECLS #define VIEW_LOADAVG_KEY "view-loadavg" #define VIEW_DISKLOAD_KEY "view-diskload" +#define REFRESH_RATE_KEY "speed" +#define REFRESH_RATE_MIN 50 +#define REFRESH_RATE_MAX 60000 + typedef struct _MultiloadApplet MultiloadApplet; typedef struct _LoadGraph LoadGraph; typedef void (*LoadGraphDataFunc) (int, int [], LoadGraph *); diff --git a/multiload/src/load-graph.c b/multiload/src/load-graph.c index 953dc5b2..3d00eba1 100644 --- a/multiload/src/load-graph.c +++ b/multiload/src/load-graph.c @@ -411,8 +411,8 @@ load_graph_new (MultiloadApplet *ma, guint n, const gchar *label, g->name = name; g->n = n; g->id = id; - g->speed = MAX (speed, 50); - g->size = MAX (size, 10); + g->speed = speed; + g->size = MAX (size, 10); g->pixel_size = mate_panel_applet_get_size (ma->applet); g->tooltip_update = FALSE; g->multiload = ma; diff --git a/multiload/src/main.c b/multiload/src/main.c index e2cfe6bd..12363fe8 100644 --- a/multiload/src/main.c +++ b/multiload/src/main.c @@ -361,14 +361,15 @@ multiload_create_graphs(MultiloadApplet *ma) [graph_diskload] = { _("Disk Load"), VIEW_DISKLOAD_KEY, "diskload", diskload_n, GetDiskLoad } }; - gint speed, size; + gint size; + guint speed; guint net_threshold1; guint net_threshold2; guint net_threshold3; gint i; - speed = g_settings_get_int (ma->settings, "speed"); - size = g_settings_get_int (ma->settings, "size"); + speed = CLAMP (g_settings_get_uint (ma->settings, REFRESH_RATE_KEY), REFRESH_RATE_MIN, REFRESH_RATE_MAX); + size = CLAMP (g_settings_get_int (ma->settings, "size"), 10, 400); net_threshold1 = CLAMP (g_settings_get_uint (ma->settings, "netthreshold1"), MIN_NET_THRESHOLD1, MAX_NET_THRESHOLD1); net_threshold2 = CLAMP (g_settings_get_uint (ma->settings, "netthreshold2"), MIN_NET_THRESHOLD2, MAX_NET_THRESHOLD2); net_threshold3 = CLAMP (g_settings_get_uint (ma->settings, "netthreshold3"), MIN_NET_THRESHOLD3, MAX_NET_THRESHOLD3); @@ -380,8 +381,6 @@ multiload_create_graphs(MultiloadApplet *ma) { net_threshold3 = net_threshold2 + 1; } - speed = MAX (speed, 50); - size = CLAMP (size, 10, 400); for (i = 0; i < graph_n; i++) { diff --git a/multiload/src/properties.c b/multiload/src/properties.c index c1ee09b6..9da7b271 100644 --- a/multiload/src/properties.c +++ b/multiload/src/properties.c @@ -28,7 +28,6 @@ #define PROP_AVG 4 #define PROP_DISK 5 -#define PROP_SPEED 6 #define PROP_SIZE 7 #define PROP_NET_THRESHOLD1 8 #define PROP_NET_THRESHOLD2 9 @@ -140,30 +139,37 @@ property_toggled_cb(GtkWidget *widget, gpointer name) } static void -spin_button_changed_cb(GtkWidget *widget, gpointer name) +on_speed_spin_button_value_changed (GtkSpinButton *spin_button, + gpointer user_data) +{ + MultiloadApplet *ma = user_data; + gint value; + gint i; + + value = gtk_spin_button_get_value_as_int (spin_button); + g_settings_set_uint (ma->settings, REFRESH_RATE_KEY, (guint) value); + for (i = 0; i < graph_n; i++) { + load_graph_stop (ma->graphs[i]); + ma->graphs[i]->speed = (guint) value; + if (ma->graphs[i]->visible) + load_graph_start (ma->graphs[i]); + } +} + +static void +spin_button_changed_cb (GtkWidget *widget, + gpointer name) { MultiloadApplet *ma; gint value; gint prop_type, i; - ma = g_object_get_data(G_OBJECT(widget), "MultiloadApplet"); - prop_type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "prop_type")); - value = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget)); + ma = g_object_get_data (G_OBJECT (widget), "MultiloadApplet"); + prop_type = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "prop_type")); + value = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget)); switch(prop_type) { - case PROP_SPEED: - g_settings_set_int (ma->settings, (gchar *)name, value); - for (i = 0; i < graph_n; i++) - { - load_graph_stop(ma->graphs[i]); - ma->graphs[i]->speed = value; - if (ma->graphs[i]->visible) - load_graph_start(ma->graphs[i]); - } - - break; - case PROP_SIZE: for (i = 0; i < graph_n; i++) { @@ -569,19 +575,20 @@ fill_properties(GtkWidget *dialog, MultiloadApplet *ma) gtk_box_pack_start (GTK_BOX (control_hbox), hbox, TRUE, TRUE, 0); gtk_widget_show (hbox); - spin_button = gtk_spin_button_new_with_range(50, 10000, 50); + spin_button = gtk_spin_button_new_with_range (REFRESH_RATE_MIN, + REFRESH_RATE_MAX, + 50); gtk_label_set_mnemonic_widget (GTK_LABEL (label), spin_button); - g_object_set_data(G_OBJECT(spin_button), "MultiloadApplet", ma); - g_object_set_data(G_OBJECT(spin_button), "prop_type", - GINT_TO_POINTER(PROP_SPEED)); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin_button), - (gdouble)g_settings_get_int (ma->settings, "speed")); - g_signal_connect(G_OBJECT(spin_button), "value_changed", - G_CALLBACK(spin_button_changed_cb), "speed"); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin_button), + (gdouble) CLAMP (g_settings_get_uint (ma->settings, REFRESH_RATE_KEY), + REFRESH_RATE_MIN, + REFRESH_RATE_MAX)); + g_signal_connect (GTK_SPIN_BUTTON (spin_button), "value_changed", + G_CALLBACK (on_speed_spin_button_value_changed), ma); gtk_size_group_add_widget (spin_size, spin_button); gtk_box_pack_start (GTK_BOX (hbox), spin_button, FALSE, FALSE, 0); - if ( ! g_settings_is_writable (ma->settings, "speed")) { + if ( ! g_settings_is_writable (ma->settings, REFRESH_RATE_KEY)) { hard_set_sensitive (label, FALSE); hard_set_sensitive (hbox, FALSE); } @@ -592,7 +599,6 @@ fill_properties(GtkWidget *dialog, MultiloadApplet *ma) g_free(label_text); - 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); |