summaryrefslogtreecommitdiff
path: root/netspeed/src/netspeed.c
diff options
context:
space:
mode:
authorrbuj <[email protected]>2020-07-06 15:20:54 +0200
committerraveit65 <[email protected]>2020-07-19 17:03:08 +0200
commit425fd302e154cb737075befe6c5b314696fa0490 (patch)
tree8456d8a91279ddb74d2882928b1aa14f9016c743 /netspeed/src/netspeed.c
parent338fe2580cce6fed8a79324310bc7b0e625661a6 (diff)
downloadmate-applets-425fd302e154cb737075befe6c5b314696fa0490.tar.bz2
mate-applets-425fd302e154cb737075befe6c5b314696fa0490.tar.xz
netspeed: Use a macro for setting refresh time value
Diffstat (limited to 'netspeed/src/netspeed.c')
-rw-r--r--netspeed/src/netspeed.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/netspeed/src/netspeed.c b/netspeed/src/netspeed.c
index c5182efc..ef11e37e 100644
--- a/netspeed/src/netspeed.c
+++ b/netspeed/src/netspeed.c
@@ -65,9 +65,11 @@ static const char LOGO_ICON[] = "mate-netspeed-applet";
* of these values -> prevents the value from
* "jumping around like crazy"
*/
-#define OLD_VALUES 5
-#define GRAPH_VALUES 180
-#define GRAPH_LINES 4
+#define OLD_VALUES 5
+#define OLD_VALUES_DBL 5.0
+#define GRAPH_VALUES 180
+#define GRAPH_LINES 4
+#define REFRESH_TIME 1000
/* A struct containing all the "global" data of the
* applet
@@ -89,7 +91,6 @@ typedef struct
gboolean device_has_changed;
guint timeout_id;
- int refresh_time;
char *up_cmd, *down_cmd;
gboolean show_sum, show_bits;
gboolean change_icon, auto_change_device;
@@ -656,10 +657,8 @@ update_applet(MateNetspeedApplet *applet)
if (applet->devinfo.tx < applet->out_old[applet->index_old]) outdiff = 0;
else outdiff = applet->devinfo.tx - applet->out_old[applet->index_old];
- inrate = indiff * 1000.0;
- inrate /= (double)(applet->refresh_time * OLD_VALUES);
- outrate = outdiff * 1000.0;
- outrate /= (double)(applet->refresh_time * OLD_VALUES);
+ inrate = (double)indiff / OLD_VALUES_DBL;
+ outrate = (double)outdiff / OLD_VALUES_DBL;
applet->in_graph[applet->index_graph] = inrate;
applet->out_graph[applet->index_graph] = outrate;
@@ -1587,7 +1586,6 @@ mate_netspeed_applet_factory(MatePanelApplet *applet_widget, const gchar *iid, g
applet = g_malloc0(sizeof(MateNetspeedApplet));
applet->applet = applet_widget;
memset(&applet->devinfo, 0, sizeof(DevInfo));
- applet->refresh_time = 1000.0;
/* Set the default colors of the graph
*/
@@ -1695,7 +1693,7 @@ mate_netspeed_applet_factory(MatePanelApplet *applet_widget, const gchar *iid, g
mate_panel_applet_set_flags(applet_widget, MATE_PANEL_APPLET_EXPAND_MINOR);
- applet->timeout_id = g_timeout_add(applet->refresh_time,
+ applet->timeout_id = g_timeout_add (REFRESH_TIME,
(GSourceFunc)timeout_function,
(gpointer)applet);