summaryrefslogtreecommitdiff
path: root/multiload/properties.c
diff options
context:
space:
mode:
Diffstat (limited to 'multiload/properties.c')
-rw-r--r--multiload/properties.c240
1 files changed, 201 insertions, 39 deletions
diff --git a/multiload/properties.c b/multiload/properties.c
index 017f88da..9eb8683c 100644
--- a/multiload/properties.c
+++ b/multiload/properties.c
@@ -30,6 +30,9 @@
#define PROP_SPEED 6
#define PROP_SIZE 7
+#define PROP_NET_THRESHOLD1 8
+#define PROP_NET_THRESHOLD2 9
+#define PROP_NET_THRESHOLD3 10
#define HIG_IDENTATION " "
#define NEVER_SENSITIVE "never_sensitive"
@@ -83,17 +86,10 @@ properties_close_cb (GtkWidget *widget, gint arg, MultiloadApplet *ma)
{
case GTK_RESPONSE_HELP:
-#if GTK_CHECK_VERSION (3, 22, 0)
gtk_show_uri_on_window (NULL,
"help:mate-multiload/multiload-prefs",
gtk_get_current_event_time (),
&error);
-#else
- gtk_show_uri (gtk_widget_get_screen (GTK_WIDGET (ma->applet)),
- "help:mate-multiload/multiload-prefs",
- gtk_get_current_event_time (),
- &error);
-#endif
if (error) { /* FIXME: the user needs to see this */
g_warning ("help error: %s\n", error->message);
@@ -147,15 +143,16 @@ static void
spin_button_changed_cb(GtkWidget *widget, gpointer name)
{
MultiloadApplet *ma;
- gint value, prop_type, i;
+ 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));
/* FIXME: the first toggle button to be checked/dechecked does not work, but after that everything is cool. what gives? */
- g_settings_set_int (ma->settings, (gchar *)name, value);
- g_settings_set_int (ma->settings, (gchar *)name, value);
+ g_settings_set_uint (ma->settings, (gchar *)name, value);
+ g_settings_set_uint (ma->settings, (gchar *)name, value);
switch(prop_type)
{
@@ -190,6 +187,51 @@ spin_button_changed_cb(GtkWidget *widget, gpointer name)
}
break;
+ case PROP_NET_THRESHOLD1:
+ {
+ if (value >= ma->graphs[2]->net_threshold2)
+ {
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget),
+ (gdouble)g_settings_get_uint (ma->settings, "netthreshold2") - 1);
+ ma->graphs[2]->net_threshold1 = g_settings_get_uint (ma->settings, "netthreshold2") - 1;
+ }
+ else
+ ma->graphs[2]->net_threshold1 = value;
+
+ break;
+ }
+ case PROP_NET_THRESHOLD2:
+ {
+ if (value >= ma->graphs[2]->net_threshold3)
+ {
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget),
+ (gdouble)g_settings_get_uint (ma->settings, "netthreshold3") - 1);
+ ma->graphs[2]->net_threshold2 = g_settings_get_uint (ma->settings, "netthreshold3") - 1;
+ }
+ else if (value <= ma->graphs[2]->net_threshold1)
+ {
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget),
+ (gdouble)g_settings_get_uint (ma->settings, "netthreshold1") + 1);
+ ma->graphs[2]->net_threshold2 = g_settings_get_uint (ma->settings, "netthreshold1") + 1;
+ }
+ else
+ ma->graphs[2]->net_threshold2 = value;
+
+ break;
+ }
+ case PROP_NET_THRESHOLD3:
+ {
+ if (value <= ma->graphs[2]->net_threshold2)
+ {
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget),
+ (gdouble)g_settings_get_uint (ma->settings, "netthreshold2") + 1);
+ ma->graphs[2]->net_threshold3 = g_settings_get_uint (ma->settings, "netthreshold2") + 1;
+ }
+ else
+ ma->graphs[2]->net_threshold3 = value;
+ break;
+ }
+
}
default:
g_assert_not_reached();
@@ -329,11 +371,7 @@ fill_properties(GtkWidget *dialog, MultiloadApplet *ma)
label = gtk_label_new_with_mnemonic (_(title));
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
-#if GTK_CHECK_VERSION (3, 16, 0)
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
-#else
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
-#endif
gtk_box_pack_start (GTK_BOX (category_vbox), label, FALSE, FALSE, 0);
g_free (title);
@@ -438,11 +476,7 @@ fill_properties(GtkWidget *dialog, MultiloadApplet *ma)
label = gtk_label_new (title);
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
-#if GTK_CHECK_VERSION (3, 16, 0)
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
-#else
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
-#endif
gtk_box_pack_start (GTK_BOX (category_vbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
g_free (title);
@@ -473,11 +507,7 @@ fill_properties(GtkWidget *dialog, MultiloadApplet *ma)
label_text = g_strdup(_("System m_onitor height: "));
label = gtk_label_new_with_mnemonic(label_text);
-#if GTK_CHECK_VERSION (3, 16, 0)
gtk_label_set_xalign (GTK_LABEL (label), 0.0f);
-#else
- gtk_misc_set_alignment (GTK_MISC (label), 0.0f, 0.5f);
-#endif
gtk_size_group_add_widget (label_size, label);
gtk_box_pack_start (GTK_BOX (control_hbox), label, FALSE, FALSE, 0);
@@ -506,11 +536,7 @@ fill_properties(GtkWidget *dialog, MultiloadApplet *ma)
gtk_box_pack_start (GTK_BOX (hbox), spin_button, FALSE, FALSE, 0);
label = gtk_label_new (_("pixels"));
-#if GTK_CHECK_VERSION (3, 16, 0)
gtk_label_set_xalign (GTK_LABEL (label), 0.0f);
-#else
- gtk_misc_set_alignment (GTK_MISC (label), 0.0f, 0.5f);
-#endif
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
control_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
@@ -518,11 +544,7 @@ fill_properties(GtkWidget *dialog, MultiloadApplet *ma)
gtk_widget_show (control_hbox);
label = gtk_label_new_with_mnemonic(_("Sys_tem monitor update interval: "));
-#if GTK_CHECK_VERSION (3, 16, 0)
gtk_label_set_xalign (GTK_LABEL (label), 0.0f);
-#else
- gtk_misc_set_alignment (GTK_MISC (label), 0.0f, 0.5f);
-#endif
gtk_size_group_add_widget (label_size, label);
gtk_box_pack_start (GTK_BOX (control_hbox), label, FALSE, FALSE, 0);
@@ -548,11 +570,7 @@ fill_properties(GtkWidget *dialog, MultiloadApplet *ma)
}
label = gtk_label_new(_("milliseconds"));
-#if GTK_CHECK_VERSION (3, 16, 0)
gtk_label_set_xalign (GTK_LABEL (label), 0.0f);
-#else
- gtk_misc_set_alignment (GTK_MISC (label), 0.0f, 0.5f);
-#endif
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
g_free(label_text);
@@ -566,11 +584,7 @@ fill_properties(GtkWidget *dialog, MultiloadApplet *ma)
label = gtk_label_new (title);
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
-#if GTK_CHECK_VERSION (3, 16, 0)
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
-#else
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
-#endif
gtk_box_pack_start (GTK_BOX (category_vbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
g_free (title);
@@ -613,6 +627,8 @@ fill_properties(GtkWidget *dialog, MultiloadApplet *ma)
add_color_selector(page, _("_Out"), "netload2-color1", ma);
add_color_selector (page, _("_Local"), "netload2-color2", ma);
add_color_selector(page, _("_Background"), "netload2-color3", ma);
+ add_color_selector(page, _("_Gridline"), "netload2-color4", ma);
+ add_color_selector(page, _("_Indicator"), "netload2-color5", ma);
page = add_page(ma->notebook, _("Swap Space"));
gtk_container_set_border_width (GTK_CONTAINER (page), 12);
@@ -623,7 +639,7 @@ fill_properties(GtkWidget *dialog, MultiloadApplet *ma)
gtk_container_set_border_width (GTK_CONTAINER (page), 12);
add_color_selector(page, _("_Average"), "loadavg-color0", ma);
add_color_selector(page, _("_Background"), "loadavg-color1", ma);
- add_color_selector(page, _("_Gridline"), "loadavg-color2", ma);
+ add_color_selector(page, _("_Gridline"), "loadavg-color2", ma);
page = add_page (ma->notebook, _("Harddisk"));
gtk_container_set_border_width (GTK_CONTAINER (page), 12);
@@ -631,6 +647,152 @@ fill_properties(GtkWidget *dialog, MultiloadApplet *ma)
add_color_selector (page, _("_Write"), "diskload-color1", ma);
add_color_selector (page, _("_Background"), "diskload-color2", ma);
+ title = g_strconcat ("<span weight=\"bold\">", _("Network speed thresholds"), "</span>", NULL);
+ label = gtk_label_new (title);
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+ gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
+ gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+ gtk_box_pack_start (GTK_BOX (category_vbox), label, FALSE, FALSE, 0);
+ gtk_widget_show (label);
+ g_free (title);
+
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_box_pack_start (GTK_BOX (category_vbox), hbox, TRUE, TRUE, 0);
+ gtk_widget_show (hbox);
+
+ indent = gtk_label_new (HIG_IDENTATION);
+ gtk_label_set_justify (GTK_LABEL (indent), GTK_JUSTIFY_LEFT);
+ gtk_box_pack_start (GTK_BOX (hbox), indent, FALSE, FALSE, 0);
+ gtk_widget_show (indent);
+
+ control_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+ gtk_box_pack_start (GTK_BOX (hbox), control_vbox, TRUE, TRUE, 0);
+ gtk_widget_show (control_vbox);
+
+ control_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+ gtk_box_pack_start (GTK_BOX (control_vbox), control_hbox, TRUE, TRUE, 0);
+ gtk_widget_show (control_hbox);
+
+ label_size = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+
+ orient = mate_panel_applet_get_orient(ma->applet);
+ label_text = g_strdup(_("Threshold 1: "));
+ label = gtk_label_new_with_mnemonic(label_text);
+ gtk_label_set_xalign (GTK_LABEL (label), 0.0f);
+ gtk_size_group_add_widget (label_size, label);
+ gtk_box_pack_start (GTK_BOX (control_hbox), label, FALSE, FALSE, 0);
+
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+ gtk_box_pack_start (GTK_BOX (control_hbox), hbox, TRUE, TRUE, 0);
+ gtk_widget_show (hbox);
+
+ spin_size = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+
+ spin_button = gtk_spin_button_new_with_range(10, 1000000000, 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",
+ GUINT_TO_POINTER(PROP_NET_THRESHOLD1));
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin_button),
+ (gdouble)g_settings_get_uint(ma->settings, "netthreshold1"));
+ g_signal_connect(G_OBJECT(spin_button), "value_changed",
+ G_CALLBACK(spin_button_changed_cb), "netthreshold1");
+
+ if ( ! g_settings_is_writable (ma->settings, "netthreshold1"))
+ {
+ hard_set_sensitive (label, FALSE);
+ hard_set_sensitive (hbox, FALSE);
+ }
+
+ gtk_size_group_add_widget (spin_size, spin_button);
+ gtk_box_pack_start (GTK_BOX (hbox), spin_button, FALSE, FALSE, 0);
+
+ label = gtk_label_new (_("bytes"));
+ gtk_label_set_xalign (GTK_LABEL (label), 0.0f);
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
+ control_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+ gtk_box_pack_start (GTK_BOX (control_vbox), control_hbox, TRUE, TRUE, 0);
+ gtk_widget_show (control_hbox);
+
+ label = gtk_label_new_with_mnemonic(_("Threshold 2: "));
+ gtk_label_set_xalign (GTK_LABEL (label), 0.0f);
+ gtk_size_group_add_widget (label_size, label);
+ gtk_box_pack_start (GTK_BOX (control_hbox), label, FALSE, FALSE, 0);
+
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+ 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);
+ 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_NET_THRESHOLD2));
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin_button),
+ (gdouble)g_settings_get_uint (ma->settings, "netthreshold2"));
+ g_signal_connect(G_OBJECT(spin_button), "value_changed",
+ G_CALLBACK(spin_button_changed_cb), "netthreshold2");
+ 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, "netthreshold2"))
+ {
+ hard_set_sensitive (label, FALSE);
+ hard_set_sensitive (hbox, FALSE);
+ }
+
+ label = gtk_label_new(_("bytes"));
+ gtk_label_set_xalign (GTK_LABEL (label), 0.0f);
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
+ control_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+ gtk_box_pack_start (GTK_BOX (control_vbox), control_hbox, TRUE, TRUE, 0);
+ gtk_widget_show (control_hbox);
+
+ label = gtk_label_new_with_mnemonic(_("Threshold 3: "));
+ gtk_label_set_xalign (GTK_LABEL (label), 0.0f);
+ gtk_size_group_add_widget (label_size, label);
+ gtk_box_pack_start (GTK_BOX (control_hbox), label, FALSE, FALSE, 0);
+
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+ 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);
+ 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_NET_THRESHOLD3));
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin_button),
+ (gdouble)g_settings_get_uint (ma->settings, "netthreshold3"));
+ g_signal_connect(G_OBJECT(spin_button), "value_changed",
+ G_CALLBACK(spin_button_changed_cb), "netthreshold3");
+ 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, "netthreshold3"))
+ {
+ hard_set_sensitive (label, FALSE);
+ hard_set_sensitive (hbox, FALSE);
+ }
+
+ label = gtk_label_new(_("bytes"));
+ gtk_label_set_xalign (GTK_LABEL (label), 0.0f);
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
+ 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);
+
+ control_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+ gtk_box_pack_start (GTK_BOX (control_vbox), control_hbox, TRUE, TRUE, 0);
+ gtk_widget_show (control_hbox);
+
+ gtk_widget_show (category_vbox);
+
+
return;
}