summaryrefslogtreecommitdiff
path: root/multiload
diff options
context:
space:
mode:
authorMarian Gasparovic <[email protected]>2018-02-04 18:36:36 +0100
committerraveit65 <[email protected]>2018-02-04 19:15:28 +0100
commite6d55cba85fc49b3dfac8150c397540bda369847 (patch)
treede6d8272b079641679b718258d4be7d9adc1594d /multiload
parent560c27fb0638d41fe39ad0e0719dd6153b17eea0 (diff)
downloadmate-applets-e6d55cba85fc49b3dfac8150c397540bda369847.tar.bz2
mate-applets-e6d55cba85fc49b3dfac8150c397540bda369847.tar.xz
Scaling network graph using thresholds defined by user
Diffstat (limited to 'multiload')
-rw-r--r--multiload/docs/C/index.docbook240
-rw-r--r--multiload/global.h4
-rw-r--r--multiload/linux-proc.c30
-rw-r--r--multiload/load-graph.c88
-rw-r--r--multiload/main.c33
-rw-r--r--multiload/org.mate.panel.applet.multiload.gschema.xml.in20
-rw-r--r--multiload/properties.c240
7 files changed, 477 insertions, 178 deletions
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 @@
<?xml version="1.0"?>
-<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
<!ENTITY legal SYSTEM "legal.xml">
<!ENTITY appletversion "1.10.2">
@@ -7,7 +7,7 @@
<!ENTITY date "July 2015">
<!ENTITY applet "System Monitor">
]>
-<!--
+<!--
(Do not remove this comment block.)
Maintained by the MATE Documentation Project
http://wiki.mate-desktop.org/dev-doc:doc-team-guide
@@ -19,10 +19,10 @@
<article id="index" lang="en">
<!-- please do not change the id; for translations, change lang to -->
<!-- appropriate code -->
- <articleinfo>
- <title>&applet; Manual</title>
+ <articleinfo>
+ <title>&applet; Manual</title>
<abstract role="description">
- <para>&applet; displays system load information in graphical
+ <para>&applet; displays system load information in graphical
format in a panel.</para>
</abstract>
<copyright>
@@ -37,11 +37,11 @@
<year>2004</year>
<holder>Sun Microsystems</holder>
</copyright>
- <copyright>
- <year>2003</year>
- <year>2004</year>
- <holder>Chee Bin HOH</holder>
- </copyright>
+ <copyright>
+ <year>2003</year>
+ <year>2004</year>
+ <holder>Chee Bin HOH</holder>
+ </copyright>
<!-- translators: uncomment this:
<copyright>
@@ -50,19 +50,19 @@
</copyright>
-->
- <publisher role="maintainer">
- <publishername> MATE Documentation Project </publishername>
- </publisher>
+ <publisher role="maintainer">
+ <publishername> MATE Documentation Project </publishername>
+ </publisher>
<publisher>
<publishername> GNOME Documentation Project </publishername>
</publisher>
&legal;
-<!-- This file contains link to license for the documentation (GNU FDL), and
- other legal stuff such as "NO WARRANTY" statement. Please do not change
+<!-- This file contains link to license for the documentation (GNU FDL), and
+ other legal stuff such as "NO WARRANTY" statement. Please do not change
any of this. -->
- <authorgroup>
+ <authorgroup>
<author>
<firstname>MATE Documentation Team</firstname>
@@ -80,13 +80,13 @@
</address></affiliation>
</author>
- <author>
- <firstname>Chee Bin</firstname>
- <surname>HOH</surname>
- <affiliation>
+ <author>
+ <firstname>Chee Bin</firstname>
+ <surname>HOH</surname>
+ <affiliation>
<orgname>GNOME Documentation Project</orgname>
<address><email>[email protected]</email></address>
- </affiliation>
+ </affiliation>
</author>
<author>
@@ -100,17 +100,17 @@
<!-- This is appropriate place for other contributors: translators,
maintainers, etc. Commented out by default.
<othercredit role="translator">
- <firstname>Latin</firstname>
- <surname>Translator 1</surname>
- <affiliation>
- <orgname>Latin Translation Team</orgname>
- <address> <email>[email protected]</email> </address>
+ <firstname>Latin</firstname>
+ <surname>Translator 1</surname>
+ <affiliation>
+ <orgname>Latin Translation Team</orgname>
+ <address> <email>[email protected]</email> </address>
</affiliation>
<contrib>Latin translation</contrib>
</othercredit>
-->
</authorgroup>
-
+
<releaseinfo revision="1.10.2" role="review"/>
<revhistory>
@@ -130,40 +130,40 @@
<para role="author">Davyd Madeley</para>
</revdescription>
</revision>
-
+
<revision>
- <revnumber>Version 2.8</revnumber>
- <date>August 2004</date>
- <revdescription>
+ <revnumber>Version 2.8</revnumber>
+ <date>August 2004</date>
+ <revdescription>
<para role="author">Angela Boyle</para>
<para role="publisher">GNOME Documentation Project</para>
- </revdescription>
- </revision>
+ </revdescription>
+ </revision>
- <revision>
- <revnumber>System Monitor Applet Manual V2.1</revnumber>
- <date>February 2004</date>
- <revdescription>
+ <revision>
+ <revnumber>System Monitor Applet Manual V2.1</revnumber>
+ <date>February 2004</date>
+ <revdescription>
<para role="author">Sun GNOME Documentation Team</para>
<para role="publisher">GNOME Documentation Project</para>
- </revdescription>
- </revision>
+ </revdescription>
+ </revision>
- <revision>
- <revnumber>System Monitor Applet Manual V2.0</revnumber>
- <date>July 2003</date>
- <revdescription>
+ <revision>
+ <revnumber>System Monitor Applet Manual V2.0</revnumber>
+ <date>July 2003</date>
+ <revdescription>
<para role="author">Chee Bin HOH
<email>[email protected]</email>
- </para>
+ </para>
<para role="publisher">GNOME Documentation Project</para>
- </revdescription>
- </revision>
+ </revdescription>
+ </revision>
- </revhistory>
+ </revhistory>
<releaseinfo> This manual describes version &appletversion; of &applet;.
- </releaseinfo>
+ </releaseinfo>
<legalnotice>
<title>Feedback</title>
<para> To report a bug or make a suggestion regarding the &applet; applet or this
@@ -173,39 +173,39 @@
</legalnotice>
</articleinfo>
- <indexterm zone="index">
- <primary>&applet; Applet</primary>
- </indexterm>
- <indexterm zone="index">
- <primary>&applet;</primary>
+ <indexterm zone="index">
+ <primary>&applet; Applet</primary>
+ </indexterm>
+ <indexterm zone="index">
+ <primary>&applet;</primary>
</indexterm>
<!-- ============= Document Body ============================= -->
<!-- ============= Introduction ============================== -->
- <sect1 id="multiload-introduction">
- <title>Introduction</title>
+ <sect1 id="multiload-introduction">
+ <title>Introduction</title>
<!-- ==== Figure ============================================= -->
- <figure id="system-monitor-applet-fig">
- <title>&applet;</title>
- <screenshot>
- <mediaobject>
+ <figure id="system-monitor-applet-fig">
+ <title>&applet;</title>
+ <screenshot>
+ <mediaobject>
<imageobject><imagedata fileref="figures/system-monitor-applet_window.png"
- format="PNG"/>
+ format="PNG"/>
</imageobject>
- <textobject>
+ <textobject>
<phrase>Shows &applet;. Displays a graph for system CPU load.
- </phrase>
- </textobject>
- </mediaobject>
- </screenshot>
- </figure>
+ </phrase>
+ </textobject>
+ </mediaobject>
+ </screenshot>
+ </figure>
<!-- ==== End of Figure ======================================= -->
<para>
The <application>&applet;</application> displays
system load information in graphical format in a panel.
- You can configure <application>&applet;</application> to display
+ You can configure <application>&applet;</application> to display
the following information for your system:
</para>
<itemizedlist>
@@ -221,45 +221,45 @@
</listitem>
<listitem>
<para>
- Network traffic
+ Network traffic
</para>
</listitem>
<listitem>
<para>
- Usage of swap space
+ Usage of swap space
</para>
</listitem>
<listitem>
<para>
- Average system load
+ Average system load
</para>
</listitem>
<listitem><para>Disk load</para></listitem>
</itemizedlist>
- <sect2 id="multiload-introduction-add">
- <title>To Add &applet; to a Panel</title>
+ <sect2 id="multiload-introduction-add">
+ <title>To Add &applet; to a Panel</title>
<para>To add <application>&applet;</application> to a panel,
right-click on the panel, then choose <guimenuitem>Add to
Panel</guimenuitem>. Select <application>&applet;</application>
in the <application>Add to the panel</application> dialog, then
click <guibutton>OK</guibutton>.</para>
<para>
- The layout of the <application>&applet;</application> varies
+ The layout of the <application>&applet;</application> varies
depending on the size and type of panel in which the applet resides.
- </para>
+ </para>
</sect2>
</sect1>
<!-- ================ Usage ================================ -->
-<!-- Use this section to describe how to use the applet to perform the tasks for
+<!-- Use this section to describe how to use the applet to perform the tasks for
which the applet is designed. -->
- <sect1 id="multiload-usage">
- <title>Viewing Graphs</title>
+ <sect1 id="multiload-usage">
+ <title>Viewing Graphs</title>
<!-- ================ displaying addistional graphics======================== -->
- <sect2 id="multiload-usage-graphs">
- <title>Displaying Additional Graphs</title>
+ <sect2 id="multiload-usage-graphs">
+ <title>Displaying Additional Graphs</title>
<para>To configure the <application>&applet;</application> applet, right-click on the applet, then choose <guimenuitem>Preferences</guimenuitem>. Under <guilabel>Monitored Resources</guilabel> you can choose which graphics you want to display:</para>
<itemizedlist>
<listitem>
@@ -311,26 +311,26 @@
</itemizedlist>
</sect2>
<!-- ================ displaying current usage of system resources================== -->
- <sect2 id="multiload-usage-current">
- <title>To Display the Current Usage of a System Resource</title>
+ <sect2 id="multiload-usage-current">
+ <title>To Display the Current Usage of a System Resource</title>
<para>
- 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.
</para>
</sect2>
<!-- ================ displaying additional info================== -->
- <sect2 id="multiload-usage-extra">
+ <sect2 id="multiload-usage-extra">
<title>To Display Additional System Monitor Information</title>
<para>
- To display additional system monitor information, right-click on the applet,
+ To display additional system monitor information, right-click on the applet,
then choose <guimenuitem>Open System Monitor</guimenuitem> to start the
- <application>System Monitor</application> application.
+ <application>System Monitor</application> application.
</para>
<para>
- The <application>System Monitor</application> application
+ The <application>System Monitor</application> application
enables you to monitor system processes and usage of system resources.
- You can use the <application>System Monitor</application> application
+ You can use the <application>System Monitor</application> application
to modify the behavior of your system.
</para>
</sect2>
@@ -339,21 +339,21 @@
<!-- ============= Preferences =========================== -->
<sect1 id="multiload-prefs">
- <title>Customizing Appearance</title>
- <figure id="system-monitor-prefs-fig">
- <title>Preferences Dialog</title>
- <screenshot>
- <mediaobject>
+ <title>Customizing Appearance</title>
+ <figure id="system-monitor-prefs-fig">
+ <title>Preferences Dialog</title>
+ <screenshot>
+ <mediaobject>
<imageobject><imagedata fileref="figures/multiload-preferences.png"
- format="PNG"/>
+ format="PNG"/>
</imageobject>
- <textobject>
+ <textobject>
<phrase>Preferences Dialog
- </phrase>
- </textobject>
- </mediaobject>
- </screenshot>
- </figure>
+ </phrase>
+ </textobject>
+ </mediaobject>
+ </screenshot>
+ </figure>
<sect2 id="multiload-size">
<title>To Change the Width</title>
<para>In the right-click menu, go to <guimenuitem>Preferences</guimenuitem>. Under <guilabel>Options</guilabel>, use the <guilabel>System monitor width</guilabel> spin box to specify the width of each <application>&applet;</application> graph in pixels.</para>
@@ -364,7 +364,7 @@
</para>
</sect2>
<!-- ================ changing graph colors======================== -->
- <sect2 id="multiload-usage-colors">
+ <sect2 id="multiload-usage-colors">
<title>Changing the Colors in a Graph</title>
<para>
To change the colors in a graph, perform the following steps:
@@ -515,25 +515,30 @@
</thead>
<tbody>
<row valign="top">
- <entry><para><guilabel>SLIP</guilabel></para></entry>
- <entry><para>Serial Line Internet Protocol network connection</para></entry>
+ <entry><para><guilabel>In</guilabel></para></entry>
+ <entry><para>Incoming traffic</para></entry>
+ </row>
+ <row valign="top">
+ <entry><para><guilabel>Out</guilabel></para></entry>
+ <entry><para>Outgoing traffic</para></entry>
</row>
<row valign="top">
- <entry><para><guilabel>PLIP</guilabel></para></entry>
- <entry><para>Parallel Line Internet Protocol network connection</para></entry>
+ <entry><para><guilabel>Local</guilabel></para></entry>
+ <entry><para>Traffic over loopback</para></entry>
</row>
<row valign="top">
- <entry><para><guilabel>Ethernet</guilabel></para></entry>
- <entry><para>Ethernet network connection</para></entry>
+ <entry><para><guilabel>Background</guilabel></para></entry>
+ <entry><para>Graph background color</para></entry>
</row>
<row valign="top">
- <entry><para><guilabel>Other</guilabel></para></entry>
- <entry><para>Network connection other than SLIP, PLIP, or Ethernet</para></entry>
+ <entry><para><guilabel>Gridline</guilabel></para></entry>
+ <entry><para>Color of horizontal gridline when scaling graph</para></entry>
</row>
<row valign="top">
- <entry><para><guilabel>Background</guilabel></para></entry>
- <entry><para>No network connection</para></entry>
+ <entry><para><guilabel>Indicator</guilabel></para></entry>
+ <entry><para>Color of indicator showing which threshold was reached</para></entry>
</row>
+
</tbody>
</tgroup>
</informaltable>
@@ -648,5 +653,20 @@
</listitem>
</itemizedlist>
</sect2>
+ <!-- ================ Explaining thresholds======================== -->
+ <sect2 id="network thresholds">
+ <title>Network speed thresholds</title>
+ <para>
+ 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.
+ </para>
+ <para>
+ Gridlines are hard to explain, just observe and they are obvious.
+ </para>
+ </sect2>
</sect1>
</article>
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 @@
<default>'#000000'</default>
<summary>Network graph background color</summary>
</key>
+ <key name="netload2-color4" type="s">
+ <default>'#ffffff'</default>
+ <summary>Grid line color</summary>
+ </key>
+ <key name="netload2-color5" type="s">
+ <default>'#0000ff'</default>
+ <summary>Indicator color</summary>
+ </key>
+ <key name="netthreshold1" type="u">
+ <default>1000000</default>
+ <summary>Network threshold 1 in bytes</summary>
+ </key>
+ <key name="netthreshold2" type="u">
+ <default>10000000</default>
+ <summary>Network threshold 2 in bytes</summary>
+ </key>
+ <key name="netthreshold3" type="u">
+ <default>100000000</default>
+ <summary>Network threshold 3 in bytes</summary>
+ </key>
<key name="swapload-color0" type="s">
<default>'#8b00c3'</default>
<summary>Graph color for user-related swap usage</summary>
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;
}