From e6d55cba85fc49b3dfac8150c397540bda369847 Mon Sep 17 00:00:00 2001 From: Marian Gasparovic Date: Sun, 4 Feb 2018 18:36:36 +0100 Subject: Scaling network graph using thresholds defined by user --- multiload/main.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'multiload/main.c') diff --git a/multiload/main.c b/multiload/main.c index f117e8c2..8ce5b70d 100644 --- a/multiload/main.c +++ b/multiload/main.c @@ -73,17 +73,10 @@ help_cb (GtkAction *action, GError *error = NULL; -#if GTK_CHECK_VERSION (3, 22, 0) gtk_show_uri_on_window (NULL, "help:mate-multiload", gtk_get_current_event_time (), &error); -#else - gtk_show_uri (gtk_widget_get_screen (GTK_WIDGET (ma->applet)), - "help:mate-multiload", - gtk_get_current_event_time (), - &error); -#endif if (error) { /* FIXME: the user needs to see this */ g_warning ("help error: %s\n", error->message); @@ -363,17 +356,31 @@ multiload_create_graphs(MultiloadApplet *ma) } graph_types[] = { { _("CPU Load"), "cpuload", 5, GetLoad }, { _("Memory Load"), "memload", 5, GetMemory }, - { _("Net Load"), "netload2", 4, 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_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_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 - 1; + } + if (net_threshold2 >= net_threshold3) + { + net_threshold3 = net_threshold2 + 1; + } speed = MAX (speed, 50); size = CLAMP (size, 10, 400); @@ -403,8 +410,14 @@ multiload_create_graphs(MultiloadApplet *ma) graph_types[i].name, graph_types[i].callback); } - /* 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; + /* 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_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; } /* remove the old graphs and rebuild them */ -- cgit v1.2.1