diff --git a/multiload/global.h b/multiload/global.h
index e0a55b78f..606db7e49 100644
--- a/multiload/global.h
+++ b/multiload/global.h
@@ -49,7 +49,10 @@ struct _LoadGraph {
double loadavg1;
NetSpeed *netspeed_in;
NetSpeed *netspeed_out;
- guint net_granularity;
+ guint net_threshold;
+ guint net_threshold1;
+ guint net_threshold2;
+ guint net_threshold3;
gboolean visible;
gboolean tooltip_update;
diff --git a/multiload/linux-proc.c b/multiload/linux-proc.c
index 97b5db567..4bff3baf0 100644
--- a/multiload/linux-proc.c
+++ b/multiload/linux-proc.c
@@ -362,7 +362,6 @@ GetNet (int Maximum, int data [4], LoadGraph *g)
g_strfreev(devices);
netspeed_add(g->netspeed_in, present[IN_COUNT]);
netspeed_add(g->netspeed_out, present[OUT_COUNT]);
-
if(ticks < 2) /* avoid initial spike */
{
ticks++;
@@ -384,10 +383,11 @@ GetNet (int Maximum, int data [4], LoadGraph *g)
total += delta[i];
}
- max = autoscaler_get_max(&scaler, total);
+ //max = autoscaler_get_max(&scaler, total);
for (i = 0; i < COUNT_TYPES; i++) {
- data[i] = rint (delta[i]);
+ //data[i] = rint (delta[i]);
+ data[i] = delta[i];
}
}
diff --git a/multiload/load-graph.c b/multiload/load-graph.c
index bd02b5026..02afcd0a4 100644
--- a/multiload/load-graph.c
+++ b/multiload/load-graph.c
@@ -91,21 +91,44 @@ load_graph_draw (LoadGraph *g)
/* This is for network graph */
else if (g->id == 2)
{
- guint maxnet = 1;
+ guint maxnet = 1;
gint segments = 1;
gint combined = 0;
for (i = 0; i < g->draw_width; i++)
{
g->pos [i] = g->draw_height - 1;
combined = 0;
- for (j = 0; j < g->n; j++)
- combined += g->data[i][j];
+ //for (j = 0; j < g->n; j++)
+ combined += g->data[i][0];
+ combined += g->data[i][1];
+ combined += g->data[i][2];
if (combined > maxnet)
maxnet = combined;
}
- maxnet = maxnet/g->net_granularity;
+ //printf("max = %d ", maxnet);
+ guint level = 0;
+ GdkRGBA grid_color;
+ if (maxnet > g->net_threshold3) {
+ g->net_threshold = g->net_threshold3;
+ level = 3;
+ }
+ else
+ if (maxnet > g->net_threshold2) {
+ g->net_threshold = g->net_threshold2;
+ level = 2;
+ }
+ else {
+ g->net_threshold = g->net_threshold1;
+ level = 1;
+ if (maxnet < g->net_threshold1)
+ level = 0;
+ }
+
+ //printf("level %d maxnet = %d ", level, maxnet);
+ maxnet = maxnet/g->net_threshold;
segments = MAX (maxnet+1,1);
- float ratio = (float)g->draw_height/g->net_granularity/segments;
+ float ratio = (float)g->draw_height/g->net_threshold/segments;
+ //printf("segments %d ratio = %f t1=%ld t2=%ld t3=%ld t=%ld\n", segments, ratio, g->net_threshold1, g->net_threshold2, g->net_threshold3, g->net_threshold);
for (j = 0; j < g->n-1; j++)
{
@@ -133,7 +156,6 @@ load_graph_draw (LoadGraph *g)
/* draw grid lines if needed */
gdk_cairo_set_source_rgba (cr, &(g->colors [4]));
-
double spacing = 0;
for (k = 0; k < segments -1; k++)
{
@@ -142,6 +164,14 @@ load_graph_draw (LoadGraph *g)
cairo_line_to (cr, g->draw_width-0.5, spacing);
}
cairo_stroke (cr);
+ if (level > 0)
+ {
+ gdk_cairo_set_source_rgba (cr, &(g->colors [5]));
+ for (k = 0; k< level; k++ )
+ cairo_rectangle(cr, 0.5, (k*2) * g->draw_height/5, 5, g->draw_height/5);
+ cairo_fill(cr);
+ }
+ cairo_stroke (cr);
}
/* this is Load graph */
else
diff --git a/multiload/main.c b/multiload/main.c
index 217957497..94c8dc723 100644
--- a/multiload/main.c
+++ b/multiload/main.c
@@ -363,21 +363,31 @@ multiload_create_graphs(MultiloadApplet *ma)
} graph_types[] = {
{ _("CPU Load"), "cpuload", 5, GetLoad },
{ _("Memory Load"), "memload", 5, GetMemory },
- { _("Net Load"), "netload2", 5, GetNet },
+ { _("Net Load"), "netload2", 6, GetNet },
{ _("Swap Load"), "swapload", 2, GetSwap },
{ _("Load Average"), "loadavg", 3, GetLoadAvg },
{ _("Disk Load"), "diskload", 3, GetDiskLoad }
};
gint speed, size;
- guint net_granularity;
+ 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");
- net_granularity = g_settings_get_uint (ma->settings, "netgranularity");
- if (net_granularity == 0)
- net_granularity = 100000;
+ 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");
+ if (net_threshold1 >= net_threshold2)
+ {
+ net_threshold1 = net_threshold2 / 2;
+ }
+ if (net_threshold2 >= net_threshold3)
+ {
+ net_threshold3 = net_threshold2 * 2;
+ }
speed = MAX (speed, 50);
size = CLAMP (size, 10, 400);
@@ -408,8 +418,11 @@ multiload_create_graphs(MultiloadApplet *ma)
graph_types[i].callback);
}
/* for Network graph, colors[4] is grid line color, it should not be used in loop in load-graph.c */
+ /* for Network graph, colors[5] is indicator color, it should not be used in loop in load-graph.c */
ma->graphs[2]->n = 4;
- ma->graphs[2]->net_granularity = net_granularity;
+ ma->graphs[2]->net_threshold1 = net_threshold1;
+ ma->graphs[2]->net_threshold2 = net_threshold2;
+ ma->graphs[2]->net_threshold3 = net_threshold3;
/* for Load graph, colors[2] is grid line color, it should not be used in loop in load-graph.c */
ma->graphs[4]->n = 2;
}
diff --git a/multiload/org.mate.panel.applet.multiload.gschema.xml.in b/multiload/org.mate.panel.applet.multiload.gschema.xml.in
index e6530fcbd..6e0d77ed3 100644
--- a/multiload/org.mate.panel.applet.multiload.gschema.xml.in
+++ b/multiload/org.mate.panel.applet.multiload.gschema.xml.in
@@ -93,10 +93,26 @@
'#ffffff'
Grid line color
+
+ '#0000ff'
+ Indicator color
+
100000
Network graph granularity in bytes
+
+ 500000
+ Network threshold 1 in bytes
+
+
+ 1500000
+ Network threshold 2 in bytes
+
+
+ 15000000
+ Network threshold 3 in bytes
+
'#8b00c3'
Graph color for user-related swap usage
diff --git a/multiload/properties.c b/multiload/properties.c
index 2cee3ce5e..6fcb7a66f 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"
@@ -147,15 +150,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 +194,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();
@@ -614,6 +663,7 @@ fill_properties(GtkWidget *dialog, MultiloadApplet *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);
@@ -624,7 +674,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);
@@ -632,6 +682,180 @@ 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 ("", _("Network speed thresholds"), "", 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);
+#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);
+
+ 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);
+#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);
+
+ 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"));
+#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);
+ 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: "));
+#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);
+
+ 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"));
+#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);
+ 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: "));
+#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);
+
+ 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"));
+#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);
+
+ 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;
}