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/docs/C/index.docbook | 240 +++++++++++---------- multiload/global.h | 4 + multiload/linux-proc.c | 30 ++- multiload/load-graph.c | 88 +++++++- multiload/main.c | 33 ++- .../org.mate.panel.applet.multiload.gschema.xml.in | 20 ++ multiload/properties.c | 240 +++++++++++++++++---- 7 files changed, 477 insertions(+), 178 deletions(-) (limited to 'multiload') diff --git a/multiload/docs/C/index.docbook b/multiload/docs/C/index.docbook index e6eeecca..119d903d 100644 --- a/multiload/docs/C/index.docbook +++ b/multiload/docs/C/index.docbook @@ -1,5 +1,5 @@ - @@ -7,7 +7,7 @@ ]> - - - &applet; Manual + + &applet; Manual - &applet; displays system load information in graphical + &applet; displays system load information in graphical format in a panel. @@ -37,11 +37,11 @@ 2004 Sun Microsystems - - 2003 - 2004 - Chee Bin HOH - + + 2003 + 2004 + Chee Bin HOH + - - MATE Documentation Project - + + MATE Documentation Project + GNOME Documentation Project &legal; - - + MATE Documentation Team @@ -80,13 +80,13 @@ - - Chee Bin - HOH - + + Chee Bin + HOH + GNOME Documentation Project
cbhoh@mimos.my
-
+
@@ -100,17 +100,17 @@
- + @@ -130,40 +130,40 @@ Davyd Madeley - + - Version 2.8 - August 2004 - + Version 2.8 + August 2004 + Angela Boyle GNOME Documentation Project - - + + - - System Monitor Applet Manual V2.1 - February 2004 - + + System Monitor Applet Manual V2.1 + February 2004 + Sun GNOME Documentation Team GNOME Documentation Project - - + + - - System Monitor Applet Manual V2.0 - July 2003 - + + System Monitor Applet Manual V2.0 + July 2003 + Chee Bin HOH cbhoh@mimos.my - + GNOME Documentation Project - - + + - + This manual describes version &appletversion; of &applet;. - + Feedback To report a bug or make a suggestion regarding the &applet; applet or this @@ -173,39 +173,39 @@
- - &applet; Applet - - - &applet; + + &applet; Applet + + + &applet; - - Introduction + + Introduction -
- &applet; - - +
+ &applet; + + + format="PNG"/> - + Shows &applet;. Displays a graph for system CPU load. - - - - -
+ + +
+
+
The &applet; displays system load information in graphical format in a panel. - You can configure &applet; to display + You can configure &applet; to display the following information for your system: @@ -221,45 +221,45 @@ - Network traffic + Network traffic - Usage of swap space + Usage of swap space - Average system load + Average system load Disk load - - To Add &applet; to a Panel + + To Add &applet; to a Panel To add &applet; to a panel, right-click on the panel, then choose Add to Panel. Select &applet; in the Add to the panel dialog, then click OK. - The layout of the &applet; varies + The layout of the &applet; varies depending on the size and type of panel in which the applet resides. - +
- - - Viewing Graphs + + Viewing Graphs - - Displaying Additional Graphs + + Displaying Additional Graphs To configure the &applet; applet, right-click on the applet, then choose Preferences. Under Monitored Resources you can choose which graphics you want to display: @@ -311,26 +311,26 @@ - - To Display the Current Usage of a System Resource + + To Display the Current Usage of a System Resource - To display the current usage of a system resource, + To display the current usage of a system resource, position the mouse pointer over the corresponding graph in the applet. A tooltip displays the current usage as a percentage. - + To Display Additional System Monitor Information - To display additional system monitor information, right-click on the applet, + To display additional system monitor information, right-click on the applet, then choose Open System Monitor to start the - System Monitor application. + System Monitor application. - The System Monitor application + The System Monitor application enables you to monitor system processes and usage of system resources. - You can use the System Monitor application + You can use the System Monitor application to modify the behavior of your system. @@ -339,21 +339,21 @@ - Customizing Appearance -
- Preferences Dialog - - + Customizing Appearance +
+ Preferences Dialog + + + format="PNG"/> - + Preferences Dialog - - - - -
+ + +
+
+
To Change the Width In the right-click menu, go to Preferences. Under Options, use the System monitor width spin box to specify the width of each &applet; graph in pixels. @@ -364,7 +364,7 @@ - + Changing the Colors in a Graph To change the colors in a graph, perform the following steps: @@ -515,25 +515,30 @@ - SLIP - Serial Line Internet Protocol network connection + In + Incoming traffic + + + Out + Outgoing traffic - PLIP - Parallel Line Internet Protocol network connection + Local + Traffic over loopback - Ethernet - Ethernet network connection + Background + Graph background color - Other - Network connection other than SLIP, PLIP, or Ethernet + Gridline + Color of horizontal gridline when scaling graph - Background - No network connection + Indicator + Color of indicator showing which threshold was reached + @@ -648,5 +653,20 @@ + + + Network speed thresholds + + Thresholds together with indicator allow network graph to scale and better represent actual workload. + If combined network traffic (in + out + loopback) is below threshold1, no indicator is shown, y-axis + on network graph go from 0 to threshold1. When trafic is more than threshold1, one indicator will be + shown and y-axis now go from 0 to threshold2. When threshold2 is reached, two indicator will be shown + and y-axis go from 0 to threshold3. When threshold3 is reached, three indicators are shown and y-axis + go form 0 to whatever is current maximum in graph. + + + Gridlines are hard to explain, just observe and they are obvious. + +
diff --git a/multiload/global.h b/multiload/global.h index 2c88c579..606db7e4 100644 --- a/multiload/global.h +++ b/multiload/global.h @@ -49,6 +49,10 @@ struct _LoadGraph { double loadavg1; NetSpeed *netspeed_in; NetSpeed *netspeed_out; + 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 96754092..0e4624d6 100644 --- a/multiload/linux-proc.c +++ b/multiload/linux-proc.c @@ -373,26 +373,22 @@ GetNet (int Maximum, int data [4], LoadGraph *g) int max; int total = 0; - for (i = 0; i < COUNT_TYPES; i++) - { - /* protect against weirdness */ - if (present[i] >= past[i]) - delta[i] = (present[i] - past[i]); - else - delta[i] = 0; - total += delta[i]; - } + for (i = 0; i < COUNT_TYPES; i++) + { + /* protect against weirdness */ + if (present[i] >= past[i]) + delta[i] = (present[i] - past[i]); + else + delta[i] = 0; + 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 (Maximum * (float)delta[i] / max); - } + for (i = 0; i < COUNT_TYPES; i++) + data[i] = delta[i]; - //data[4] = Maximum - data[3] - data[2] - data[1] - data[0]; - data[COUNT_TYPES] = Maximum; - for (i = 0; i < COUNT_TYPES; i++) - data[COUNT_TYPES] -= data[i]; + } memcpy(past, present, sizeof past); } diff --git a/multiload/load-graph.c b/multiload/load-graph.c index e3d0c12c..5eb90e8f 100644 --- a/multiload/load-graph.c +++ b/multiload/load-graph.c @@ -66,8 +66,8 @@ load_graph_draw (LoadGraph *g) cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND); cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND); - /* all graphs except Load go this path */ - if (g->id != 4) + /* all graphs except Load and Net go this path */ + if (g->id != 4 && g->id != 2) { for (i = 0; i < g->draw_width; i++) g->pos [i] = g->draw_height - 1; @@ -87,7 +87,91 @@ load_graph_draw (LoadGraph *g) } cairo_stroke (cr); } + } + /* This is for network graph */ + else if (g->id == 2) + { + 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; + combined += g->data[i][0]; + combined += g->data[i][1]; + combined += g->data[i][2]; + if (combined > maxnet) + maxnet = combined; + } + //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_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++) + { + gdk_cairo_set_source_rgba (cr, &(g->colors [j])); + + for (i = 0; i < g->draw_width; i++) + { + cairo_move_to (cr, g->draw_width - i - 0.5, g->pos[i] + 0.5); + cairo_line_to (cr, g->draw_width - i - 0.5, g->pos[i] - 0.5 - ((g->data [i][j] * ratio))); + g->pos [i] -= ((g->data [i][j] * ratio)); + } + cairo_stroke (cr); + } + + for (j = g->n-1; j < g->n; j++) + { + gdk_cairo_set_source_rgba (cr, &(g->colors [j])); + for (i = 0; i < g->draw_width; i++) + { + cairo_move_to (cr, g->draw_width - i - 0.5, g->pos[i] + 0.5); + cairo_line_to (cr, g->draw_width - i - 0.5, 0.5); + } + cairo_stroke (cr); + } + /* draw grid lines if needed */ + gdk_cairo_set_source_rgba (cr, &(g->colors [4])); + double spacing = 0; + for (k = 0; k < segments -1; k++) + { + spacing = ((double) g->draw_height/segments) * (k+1); + cairo_move_to (cr, 0.5, spacing); + cairo_line_to (cr, g->draw_width-0.5, spacing); + } + cairo_stroke (cr); + /* draw indicator if needed */ + 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 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 */ diff --git a/multiload/org.mate.panel.applet.multiload.gschema.xml.in b/multiload/org.mate.panel.applet.multiload.gschema.xml.in index 206ebee3..d0d27a32 100644 --- a/multiload/org.mate.panel.applet.multiload.gschema.xml.in +++ b/multiload/org.mate.panel.applet.multiload.gschema.xml.in @@ -89,6 +89,26 @@ '#000000' Network graph background color + + '#ffffff' + Grid line color + + + '#0000ff' + Indicator color + + + 1000000 + Network threshold 1 in bytes + + + 10000000 + Network threshold 2 in bytes + + + 100000000 + Network threshold 3 in bytes + '#8b00c3' Graph color for user-related swap usage 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 ("", _("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); + 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; } -- cgit v1.2.1