diff options
author | rbuj <[email protected]> | 2020-07-21 13:33:09 +0200 |
---|---|---|
committer | raveit65 <[email protected]> | 2020-07-26 11:11:51 +0200 |
commit | 88e553e3b557b5a4f92199aeddf8b0e5bb7868a8 (patch) | |
tree | 0bf79ed3a4758f8fca7d35a34abbe8bc7e84186b /multiload | |
parent | 626b731a6bcd701bf16b1164972eb11af344271c (diff) | |
download | mate-applets-88e553e3b557b5a4f92199aeddf8b0e5bb7868a8.tar.bz2 mate-applets-88e553e3b557b5a4f92199aeddf8b0e5bb7868a8.tar.xz |
multiload: set and check the ranges for all network thresholds
Diffstat (limited to 'multiload')
-rw-r--r-- | multiload/global.h | 6 | ||||
-rw-r--r-- | multiload/main.c | 6 | ||||
-rw-r--r-- | multiload/org.mate.panel.applet.multiload.gschema.xml.in | 3 | ||||
-rw-r--r-- | multiload/properties.c | 6 |
4 files changed, 15 insertions, 6 deletions
diff --git a/multiload/global.h b/multiload/global.h index ea8b6330..9074e2fc 100644 --- a/multiload/global.h +++ b/multiload/global.h @@ -12,6 +12,12 @@ G_BEGIN_DECLS #define NCPUSTATES 5 #define NGRAPHS 6 +#define MIN_NET_THRESHOLD1 10 +#define MIN_NET_THRESHOLD2 11 +#define MIN_NET_THRESHOLD3 12 +#define MAX_NET_THRESHOLD1 999999998 +#define MAX_NET_THRESHOLD2 999999999 +#define MAX_NET_THRESHOLD3 1000000000 typedef struct _MultiloadApplet MultiloadApplet; typedef struct _LoadGraph LoadGraph; diff --git a/multiload/main.c b/multiload/main.c index db7ef3cc..45756891 100644 --- a/multiload/main.c +++ b/multiload/main.c @@ -378,9 +378,9 @@ multiload_create_graphs(MultiloadApplet *ma) speed = g_settings_get_int (ma->settings, "speed"); size = g_settings_get_int (ma->settings, "size"); - net_threshold1 = g_settings_get_uint (ma->settings, "netthreshold1"); - net_threshold2 = g_settings_get_uint (ma->settings, "netthreshold2"); - net_threshold3 = g_settings_get_uint (ma->settings, "netthreshold3"); + 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); if (net_threshold1 >= net_threshold2) { net_threshold1 = net_threshold2 - 1; diff --git a/multiload/org.mate.panel.applet.multiload.gschema.xml.in b/multiload/org.mate.panel.applet.multiload.gschema.xml.in index 53bf8c76..9f199bc3 100644 --- a/multiload/org.mate.panel.applet.multiload.gschema.xml.in +++ b/multiload/org.mate.panel.applet.multiload.gschema.xml.in @@ -98,14 +98,17 @@ <summary>Indicator color</summary> </key> <key name="netthreshold1" type="u"> + <range min="10" max="999999998"/> <default>1000000</default> <summary>Network threshold 1 in bytes</summary> </key> <key name="netthreshold2" type="u"> + <range min="11" max="999999999"/> <default>10000000</default> <summary>Network threshold 2 in bytes</summary> </key> <key name="netthreshold3" type="u"> + <range min="12" max="1000000000"/> <default>100000000</default> <summary>Network threshold 3 in bytes</summary> </key> diff --git a/multiload/properties.c b/multiload/properties.c index 8849943c..d8299cde 100644 --- a/multiload/properties.c +++ b/multiload/properties.c @@ -723,7 +723,7 @@ fill_properties(GtkWidget *dialog, MultiloadApplet *ma) spin_size = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); - spin_button = gtk_spin_button_new_with_range(10, 1000000000, 5); + spin_button = gtk_spin_button_new_with_range (MIN_NET_THRESHOLD1, MAX_NET_THRESHOLD1, 5); 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", @@ -759,7 +759,7 @@ 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(10, 1000000000, 5); + spin_button = gtk_spin_button_new_with_range (MIN_NET_THRESHOLD2, MAX_NET_THRESHOLD2, 5); 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", @@ -794,7 +794,7 @@ 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(10, 1000000000, 5); + spin_button = gtk_spin_button_new_with_range (MIN_NET_THRESHOLD3, MAX_NET_THRESHOLD3, 5); 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", |