summaryrefslogtreecommitdiff
path: root/multiload/src
diff options
context:
space:
mode:
Diffstat (limited to 'multiload/src')
-rw-r--r--multiload/src/autoscaler.c28
-rw-r--r--multiload/src/autoscaler.h20
-rw-r--r--multiload/src/global.h29
-rw-r--r--multiload/src/linux-proc.c59
-rw-r--r--multiload/src/linux-proc.h12
-rw-r--r--multiload/src/load-graph.c162
-rw-r--r--multiload/src/load-graph.h2
-rw-r--r--multiload/src/main.c18
-rw-r--r--multiload/src/netspeed.c44
-rw-r--r--multiload/src/properties.c89
10 files changed, 237 insertions, 226 deletions
diff --git a/multiload/src/autoscaler.c b/multiload/src/autoscaler.c
index 735b2713..fb03533f 100644
--- a/multiload/src/autoscaler.c
+++ b/multiload/src/autoscaler.c
@@ -1,42 +1,44 @@
-#include <time.h>
#include <glib.h>
#include "autoscaler.h"
/* i wish i could have used C99 initializers instead of writing this function */
-void autoscaler_init(AutoScaler *that, unsigned interval, unsigned floor)
+void
+autoscaler_init (AutoScaler *that,
+ gint64 interval,
+ guint64 floor)
{
that->update_interval = interval;
that->floor = floor;
that->max = 0;
that->count = 0;
that->last_update = 0;
- that->sum = 0.0f;
+ that->sum = 0;
that->last_average = 0.0f;
}
-
-unsigned autoscaler_get_max(AutoScaler *that, unsigned current)
+guint64
+autoscaler_get_max (AutoScaler *that,
+ guint64 current)
{
- time_t now;
+ gint64 now;
that->sum += current;
that->count++;
- time(&now);
+ now = g_get_monotonic_time ();
- if((float)difftime(now, that->last_update) > that->update_interval)
+ if ((now - that->last_update) > that->update_interval)
{
- float new_average = that->sum / that->count;
+ float new_average = (float) that->sum / (float) that->count;
float average;
- if(new_average < that->last_average)
+ if (new_average < that->last_average)
average = ((that->last_average * 0.5f) + new_average) / 1.5f;
else
average = new_average;
- that->max = average * 1.2f;
-
- that->sum = 0.0f;
+ that->max = (guint64) (average * 1.2f);
+ that->sum = 0;
that->count = 0;
that->last_update = now;
that->last_average = average;
diff --git a/multiload/src/autoscaler.h b/multiload/src/autoscaler.h
index d0ae4cd6..ef4e0946 100644
--- a/multiload/src/autoscaler.h
+++ b/multiload/src/autoscaler.h
@@ -2,25 +2,21 @@
#define MATE_APPLETS_MULTILOAD_AUTOSCALER_H
#include <glib.h>
-#include <time.h>
typedef struct _AutoScaler AutoScaler;
struct _AutoScaler
{
- /* const */ unsigned update_interval;
- /* const */ unsigned floor;
- unsigned max;
- unsigned count;
- time_t last_update;
- float sum;
+ gint64 update_interval;
+ gint64 last_update;
+ guint64 floor;
+ guint64 max;
+ guint64 count;
+ guint64 sum;
float last_average;
};
-
-G_GNUC_INTERNAL void autoscaler_init(AutoScaler *that, unsigned interval, unsigned floor);
-
-G_GNUC_INTERNAL unsigned autoscaler_get_max(AutoScaler *that, unsigned current);
-
+G_GNUC_INTERNAL void autoscaler_init (AutoScaler *that, gint64 interval, guint64 floor);
+G_GNUC_INTERNAL guint64 autoscaler_get_max (AutoScaler *that, guint64 current);
#endif /* MATE_APPLETS_MULTILOAD_AUTOSCALER_H */
diff --git a/multiload/src/global.h b/multiload/src/global.h
index 29771369..7b5db895 100644
--- a/multiload/src/global.h
+++ b/multiload/src/global.h
@@ -37,7 +37,7 @@ G_BEGIN_DECLS
typedef struct _MultiloadApplet MultiloadApplet;
typedef struct _LoadGraph LoadGraph;
-typedef void (*LoadGraphDataFunc) (int, int [], LoadGraph *);
+typedef void (*LoadGraphDataFunc) (guint64, guint64 [], LoadGraph *);
#include "netspeed.h"
@@ -85,18 +85,19 @@ typedef enum {
struct _LoadGraph {
MultiloadApplet *multiload;
- guint n, id;
+ guint n;
+ gint id;
guint speed, size;
guint orient, pixel_size;
- guint draw_width, draw_height;
+ gsize draw_width;
+ guint64 draw_height;
LoadGraphDataFunc get_data;
guint allocated;
GdkRGBA *colors;
- gint **data;
- guint data_size;
- guint *pos;
+ guint64 **data;
+ guint64 *pos;
GtkWidget *main_widget;
GtkWidget *frame, *box, *disp;
@@ -129,12 +130,12 @@ struct _MultiloadApplet
GtkWidget *check_boxes [graph_n];
GtkWidget *prop_dialog;
GtkWidget *notebook;
- int last_clicked;
+ gint last_clicked;
- float cpu_used_ratio;
- long cpu_time [cpuload_n];
- long cpu_last [cpuload_n];
- int cpu_initialized;
+ float cpu_used_ratio;
+ guint64 cpu_time [cpuload_n];
+ guint64 cpu_last [cpuload_n];
+ gboolean cpu_initialized;
double loadavg1;
@@ -149,9 +150,9 @@ struct _MultiloadApplet
NetSpeed *netspeed_in;
NetSpeed *netspeed_out;
- guint net_threshold1;
- guint net_threshold2;
- guint net_threshold3;
+ guint64 net_threshold1;
+ guint64 net_threshold2;
+ guint64 net_threshold3;
};
#include "load-graph.h"
diff --git a/multiload/src/linux-proc.c b/multiload/src/linux-proc.c
index 5381db70..10b3ddd5 100644
--- a/multiload/src/linux-proc.c
+++ b/multiload/src/linux-proc.c
@@ -2,7 +2,6 @@
#include <config.h>
#include <sys/types.h>
#include <sys/statvfs.h>
-#include <math.h>
#include <fcntl.h>
#include <unistd.h>
@@ -47,15 +46,15 @@ static const unsigned needed_netload_flags =
(1 << GLIBTOP_NETLOAD_BYTES_TOTAL);
void
-GetLoad (int Maximum,
- int data [cpuload_n],
+GetLoad (guint64 Maximum,
+ guint64 data [cpuload_n],
LoadGraph *g)
{
MultiloadApplet *multiload;
glibtop_cpu cpu;
- long cpu_aux [cpuload_n], used = 0, total = 0;
- int current_scaled, used_scaled = 0;
- int i;
+ guint64 cpu_aux [cpuload_n], used = 0, total = 0;
+ guint64 current_scaled, used_scaled = 0;
+ unsigned i;
glibtop_get_cpu (&cpu);
@@ -71,7 +70,7 @@ GetLoad (int Maximum,
if (!multiload->cpu_initialized) {
memcpy (multiload->cpu_last, multiload->cpu_time, sizeof (multiload->cpu_last));
- multiload->cpu_initialized = 1;
+ multiload->cpu_initialized = TRUE;
}
for (i = 0; i < cpuload_n; i++) {
@@ -81,7 +80,7 @@ GetLoad (int Maximum,
for (i = 0; i < cpuload_free; i++) {
used += cpu_aux [i];
- current_scaled = rint ((float)(cpu_aux [i] * Maximum) / (float)total);
+ current_scaled = (guint64) ((float)(cpu_aux [i] * Maximum) / (float)total);
used_scaled += current_scaled;
data [i] = current_scaled;
}
@@ -93,19 +92,18 @@ GetLoad (int Maximum,
}
void
-GetDiskLoad (int Maximum,
- int data [diskload_n],
+GetDiskLoad (guint64 Maximum,
+ guint64 data [diskload_n],
LoadGraph *g)
{
static gboolean first_call = TRUE;
static guint64 lastread = 0, lastwrite = 0;
static AutoScaler scaler;
- guint i;
- int max;
-
+ guint64 max;
guint64 read, write;
guint64 readdiff, writediff;
+ guint i;
MultiloadApplet *multiload;
@@ -179,7 +177,8 @@ GetDiskLoad (int Maximum,
}
glibtop_get_fsusage(&fsusage, mountentries[i].mountdir);
- read += fsusage.read; write += fsusage.write;
+ read += fsusage.read;
+ write += fsusage.write;
}
g_free(mountentries);
@@ -202,8 +201,8 @@ GetDiskLoad (int Maximum,
multiload->diskload_used_ratio = (float)(readdiff + writediff) / (float)max;
- data [diskload_read] = rint ((float)Maximum * (float)readdiff / (float)max);
- data [diskload_write] = rint ((float)Maximum * (float)writediff / (float)max);
+ data [diskload_read] = (guint64) ((float)Maximum * (float)readdiff / (float)max);
+ data [diskload_write] = (guint64) ((float)Maximum * (float)writediff / (float)max);
data [diskload_free] = Maximum - (data [0] + data[1]);
}
@@ -220,14 +219,14 @@ GetDiskLoad (int Maximum,
* aux [memload_buffer] = mem.buffer;
*/
void
-GetMemory (int Maximum,
- int data [memload_n],
+GetMemory (guint64 Maximum,
+ guint64 data [memload_n],
LoadGraph *g)
{
MultiloadApplet *multiload;
glibtop_mem mem;
guint64 aux [memload_n], cache = 0;
- int current_scaled, used_scaled = 0;
+ guint64 current_scaled, used_scaled = 0;
int i;
glibtop_get_mem (&mem);
@@ -245,7 +244,7 @@ GetMemory (int Maximum,
aux [memload_buffer] = mem.buffer;
for (i = 0; i < memload_free; i++) {
- current_scaled = rint ((float)(aux [i] * Maximum) / (float)mem.total);
+ current_scaled = (guint64) ((float)(aux [i] * Maximum) / (float)mem.total);
if (i != memload_user) {
cache += aux [i];
}
@@ -261,11 +260,11 @@ GetMemory (int Maximum,
}
void
-GetSwap (int Maximum,
- int data [swapload_n],
+GetSwap (guint64 Maximum,
+ guint64 data [swapload_n],
LoadGraph *g)
{
- int used;
+ guint64 used;
MultiloadApplet *multiload;
glibtop_swap swap;
@@ -282,7 +281,7 @@ GetSwap (int Maximum,
float ratio;
ratio = (float)swap.used / (float)swap.total;
- used = rint ((float) Maximum * ratio);
+ used = (guint64) ((float) Maximum * ratio);
multiload->swapload_used_ratio = ratio;
}
@@ -291,8 +290,8 @@ GetSwap (int Maximum,
}
void
-GetLoadAvg (int Maximum,
- int data [2],
+GetLoadAvg (guint64 Maximum,
+ guint64 data [2],
LoadGraph *g)
{
glibtop_loadavg loadavg;
@@ -305,7 +304,7 @@ GetLoadAvg (int Maximum,
multiload = g->multiload;
multiload->loadavg1 = loadavg.loadavg[0];
- data [0] = rint ((float) Maximum * loadavg.loadavg[0]);
+ data [0] = (guint64) ((float) Maximum * loadavg.loadavg[0]);
data [1] = Maximum - data[0];
}
@@ -351,8 +350,8 @@ is_net_device_virtual(char *device)
}
void
-GetNet (int Maximum,
- int data [4],
+GetNet (guint64 Maximum,
+ guint64 data [4],
LoadGraph *g)
{
enum Types {
@@ -421,7 +420,7 @@ GetNet (int Maximum,
{
/* protect against weirdness */
if (present[i] >= past[i])
- data[i] = (int) ((float) (present[i] - past[i]) / seconds);
+ data[i] = (guint) ((float) (present[i] - past[i]) / seconds);
else
data[i] = 0;
data[COUNT_TYPES] += data[i];
diff --git a/multiload/src/linux-proc.h b/multiload/src/linux-proc.h
index 0aba1a0e..fb18ef59 100644
--- a/multiload/src/linux-proc.h
+++ b/multiload/src/linux-proc.h
@@ -3,11 +3,11 @@
#include <load-graph.h>
-G_GNUC_INTERNAL void GetLoad (int Maximum, int data [cpuload_n], LoadGraph *g);
-G_GNUC_INTERNAL void GetDiskLoad (int Maximum, int data [diskload_n], LoadGraph *g);
-G_GNUC_INTERNAL void GetMemory (int Maximum, int data [memload_n], LoadGraph *g);
-G_GNUC_INTERNAL void GetSwap (int Maximum, int data [swapload_n], LoadGraph *g);
-G_GNUC_INTERNAL void GetLoadAvg (int Maximum, int data [2], LoadGraph *g);
-G_GNUC_INTERNAL void GetNet (int Maximum, int data [4], LoadGraph *g);
+G_GNUC_INTERNAL void GetLoad (guint64 Maximum, guint64 data [cpuload_n], LoadGraph *g);
+G_GNUC_INTERNAL void GetDiskLoad (guint64 Maximum, guint64 data [diskload_n], LoadGraph *g);
+G_GNUC_INTERNAL void GetMemory (guint64 Maximum, guint64 data [memload_n], LoadGraph *g);
+G_GNUC_INTERNAL void GetSwap (guint64 Maximum, guint64 data [swapload_n], LoadGraph *g);
+G_GNUC_INTERNAL void GetLoadAvg (guint64 Maximum, guint64 data [2], LoadGraph *g);
+G_GNUC_INTERNAL void GetNet (guint64 Maximum, guint64 data [4], LoadGraph *g);
#endif
diff --git a/multiload/src/load-graph.c b/multiload/src/load-graph.c
index c9ed8d03..fbff7d7d 100644
--- a/multiload/src/load-graph.c
+++ b/multiload/src/load-graph.c
@@ -30,15 +30,15 @@
static void
shift_right(LoadGraph *g)
{
- unsigned i;
- int* last_data;
+ guint64 *last_data;
+ gsize i;
/* data[g->draw_width - 1] becomes data[0] */
last_data = g->data[g->draw_width - 1];
/* data[i+1] = data[i] */
- for(i = g->draw_width - 1; i != 0; --i)
- g->data[i] = g->data[i - 1];
+ for (i = g->draw_width - 1; i != 0; --i)
+ g->data[i] = g->data[i - 1];
g->data[0] = last_data;
}
@@ -50,7 +50,6 @@ load_graph_draw (LoadGraph *g)
{
guint i, j, k;
cairo_t *cr;
- int load;
MultiloadApplet *multiload;
multiload = g->multiload;
@@ -62,7 +61,8 @@ load_graph_draw (LoadGraph *g)
if (!g->surface)
g->surface = gdk_window_create_similar_surface (gtk_widget_get_window (g->disp),
CAIRO_CONTENT_COLOR,
- g->draw_width, g->draw_height);
+ (int) g->draw_width,
+ (int) g->draw_height);
cr = cairo_create (g->surface);
cairo_set_line_width (cr, 1.0);
@@ -70,33 +70,16 @@ load_graph_draw (LoadGraph *g)
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
/* all graphs except Load and Net go this path */
- if (g->id != graph_loadavg && g->id != graph_netload2)
- {
- for (i = 0; i < g->draw_width; i++)
- g->pos [i] = g->draw_height - 1;
-
- for (j = 0; j < g->n; j++)
- {
- gdk_cairo_set_source_rgba (cr, &(g->colors [j]));
+ switch (g->id) {
- for (i = 0; i < g->draw_width; i++)
- {
- if (g->data [i][j] != 0)
- {
- 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] - (g->data [i][j] - 0.5));
- }
- g->pos [i] -= g->data [i][j];
- }
- cairo_stroke (cr);
- }
- }
/* This is for network graph */
- else if (g->id == graph_netload2)
- {
- guint maxnet = 1;
- gint segments = 1;
- guint net_threshold;
+ case graph_netload2: {
+ guint64 maxnet = 1;
+ guint64 segments = 1;
+ guint64 net_threshold;
+ guint level = 0;
+ double ratio;
+ double spacing;
for (i = 0; i < g->draw_width; i++)
{
@@ -105,7 +88,6 @@ load_graph_draw (LoadGraph *g)
maxnet = g->data[i][3];
}
//printf("max = %d ", maxnet);
- guint level = 0;
if (maxnet > multiload->net_threshold3) {
net_threshold = multiload->net_threshold3;
level = 3;
@@ -117,15 +99,14 @@ load_graph_draw (LoadGraph *g)
}
else {
net_threshold = multiload->net_threshold1;
- level = 1;
- if (maxnet < multiload->net_threshold1)
- level = 0;
+ if (maxnet >= multiload->net_threshold1)
+ level = 1;
}
//printf("level %d maxnet = %d ", level, maxnet);
maxnet = maxnet/net_threshold;
segments = MAX (maxnet+1,1);
- float ratio = (float)g->draw_height/net_threshold/segments;
+ ratio = (double) g->draw_height / (double) (net_threshold*segments);
//printf("segments %d ratio = %f t1=%ld t2=%ld t3=%ld t=%ld\n", segments, ratio, multiload->net_threshold1, multiload->net_threshold2, multiload->net_threshold3, multiload->net_threshold);
for (j = 0; j < g->n-1; j++)
@@ -134,9 +115,10 @@ load_graph_draw (LoadGraph *g)
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));
+ double x = (double) (g->draw_width - i) - 0.5;
+ cairo_move_to (cr, x, (double) g->pos[i] + 0.5);
+ cairo_line_to (cr, x, (double) g->pos[i] - 0.5 - (((double) g->data [i][j] * ratio)));
+ g->pos [i] -= (guint64) ((double) g->data [i][j] * ratio);
}
cairo_stroke (cr);
}
@@ -146,20 +128,20 @@ load_graph_draw (LoadGraph *g)
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);
+ double x = (double) (g->draw_width - i) - 0.5;
+ cairo_move_to (cr, x, (double) g->pos[i] + 0.5);
+ cairo_line_to (cr, x, 0.5);
}
cairo_stroke (cr);
}
/* draw grid lines if needed */
gdk_cairo_set_source_rgba (cr, &(g->colors [4]));
- double spacing;
for (k = 0; k < segments -1; k++)
{
- spacing = ((double) g->draw_height/segments) * (k+1);
+ spacing = ((double) g->draw_height / (double) segments) * (k+1);
cairo_move_to (cr, 0.5, spacing);
- cairo_line_to (cr, g->draw_width-0.5, spacing);
+ cairo_line_to (cr, (double) g->draw_width - 0.5, spacing);
}
cairo_stroke (cr);
/* draw indicator if needed */
@@ -167,15 +149,19 @@ load_graph_draw (LoadGraph *g)
{
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_rectangle (cr,
+ 0.5, (double) k * 2.0 * (double) g->draw_height / 5.0,
+ 5.0, (double) g->draw_height / 5.0);
cairo_fill(cr);
}
cairo_stroke (cr);
+ break;
}
+
/* this is Load graph */
- else
- {
- guint maxload = 1;
+ case graph_loadavg: {
+ double load;
+ guint64 maxload = 1;
for (i = 0; i < g->draw_width; i++)
{
g->pos [i] = g->draw_height - 1;
@@ -183,8 +169,7 @@ load_graph_draw (LoadGraph *g)
if (g->data[i][0] > maxload)
maxload = g->data[i][0];
}
- load = ceil ((double) (maxload/g->draw_height)) + 1;
- load = MAX (load,1);
+ load = ceil ((double) maxload / (double) g->draw_height) + 1.0;
for (j = 0; j < g->n; j++)
{
@@ -192,16 +177,17 @@ load_graph_draw (LoadGraph *g)
for (i = 0; i < g->draw_width; i++)
{
- cairo_move_to (cr, g->draw_width - i - 0.5, g->pos[i] + 0.5);
+ double x = (double) (g->draw_width - i) - 0.5;
+ cairo_move_to (cr, x, (double) g->pos[i] + 0.5);
if (j == 0)
{
- cairo_line_to (cr, g->draw_width - i - 0.5, g->pos[i] - ((g->data [i][j] - 0.5)/load));
+ cairo_line_to (cr, x, (double) g->pos[i] - (((double) g->data [i][j] - 0.5)/load));
}
else
{
- cairo_line_to (cr, g->draw_width - i - 0.5, 0.5);
+ cairo_line_to (cr, x, 0.5);
}
- g->pos [i] -= g->data [i][j] / load;
+ g->pos [i] -= (guint64) ((double) g->data [i][j] / load);
}
cairo_stroke (cr);
}
@@ -214,11 +200,35 @@ load_graph_draw (LoadGraph *g)
{
spacing = ((double) g->draw_height/load) * (k+1);
cairo_move_to (cr, 0.5, spacing);
- cairo_line_to (cr, g->draw_width-0.5, spacing);
- }
+ cairo_line_to (cr, (double) g->draw_width - 0.5, spacing);
+ }
cairo_stroke (cr);
+ break;
+ }
+
+ default:
+ for (i = 0; i < g->draw_width; i++)
+ g->pos [i] = g->draw_height - 1;
+
+ for (j = 0; j < g->n; j++)
+ {
+ gdk_cairo_set_source_rgba (cr, &(g->colors [j]));
+
+ for (i = 0; i < g->draw_width; i++)
+ {
+ if (g->data [i][j] != 0)
+ {
+ double x = (double) (g->draw_width - i) - 0.5;
+ cairo_move_to (cr, x, (double) g->pos[i] + 0.5);
+ cairo_line_to (cr, x, (double) g->pos[i] - (double) g->data [i][j] - 0.5);
+ }
+ g->pos [i] -= g->data [i][j];
+ }
+ cairo_stroke (cr);
+ }
}
+
gtk_widget_queue_draw (g->disp);
cairo_destroy (cr);
@@ -229,12 +239,12 @@ static gboolean
load_graph_update (LoadGraph *g)
{
if (g->data == NULL)
- return TRUE;
+ return TRUE;
shift_right(g);
if (g->tooltip_update)
- multiload_applet_tooltip_update(g);
+ multiload_applet_tooltip_update (g);
g->get_data (g->draw_height, g->data [0], g);
@@ -245,7 +255,7 @@ load_graph_update (LoadGraph *g)
void
load_graph_unalloc (LoadGraph *g)
{
- guint i;
+ gsize i;
if (!g->allocated)
return;
@@ -276,18 +286,19 @@ load_graph_unalloc (LoadGraph *g)
static void
load_graph_alloc (LoadGraph *g)
{
- guint i;
+ gsize i;
+ gsize data_size;
if (g->allocated)
return;
- g->data = g_new0 (gint *, g->draw_width);
- g->pos = g_new0 (guint, g->draw_width);
+ g->data = g_new0 (guint64 *, g->draw_width);
+ g->pos = g_new0 (guint64, g->draw_width);
- g->data_size = sizeof (guint) * g->n;
+ data_size = sizeof (guint64) * g->n;
for (i = 0; i < g->draw_width; i++) {
- g->data [i] = g_malloc0 (g->data_size);
+ g->data [i] = g_malloc0 (data_size);
}
g->allocated = TRUE;
@@ -304,8 +315,8 @@ load_graph_configure (GtkWidget *widget, GdkEventConfigure *event,
gtk_widget_get_allocation (c->disp, &allocation);
- c->draw_width = allocation.width;
- c->draw_height = allocation.height;
+ c->draw_width = (gsize) allocation.width;
+ c->draw_height = (guint64) allocation.height;
c->draw_width = MAX (c->draw_width, 1);
c->draw_height = MAX (c->draw_height, 1);
@@ -314,7 +325,8 @@ load_graph_configure (GtkWidget *widget, GdkEventConfigure *event,
if (!c->surface)
c->surface = gdk_window_create_similar_surface (gtk_widget_get_window (c->disp),
CAIRO_CONTENT_COLOR,
- c->draw_width, c->draw_height);
+ (int) c->draw_width,
+ (int) c->draw_height);
gtk_widget_queue_draw (widget);
return TRUE;
@@ -397,7 +409,7 @@ load_graph_load_config (LoadGraph *g)
LoadGraph *
load_graph_new (MultiloadApplet *ma, guint n, const gchar *label,
- guint id, guint speed, guint size, gboolean visible,
+ gint id, guint speed, guint size, gboolean visible,
const gchar *name, LoadGraphDataFunc get_data)
{
LoadGraph *g;
@@ -449,9 +461,9 @@ load_graph_new (MultiloadApplet *ma, guint n, const gchar *label,
g->timer_index = -1;
if (g->orient)
- gtk_widget_set_size_request (g->main_widget, -1, g->size);
+ gtk_widget_set_size_request (g->main_widget, -1, (gint) g->size);
else
- gtk_widget_set_size_request (g->main_widget, g->size, -1);
+ gtk_widget_set_size_request (g->main_widget, (gint) g->size, -1);
g->disp = gtk_drawing_area_new ();
gtk_widget_set_events (g->disp, GDK_EXPOSURE_MASK |
@@ -481,18 +493,22 @@ load_graph_new (MultiloadApplet *ma, guint n, const gchar *label,
void
load_graph_start (LoadGraph *g)
{
+ guint event_source_id;
+
if (g->timer_index != -1)
- g_source_remove (g->timer_index);
+ g_source_remove ((guint) g->timer_index);
- g->timer_index = g_timeout_add (g->speed,
+ event_source_id = g_timeout_add (g->speed,
(GSourceFunc) load_graph_update, g);
+
+ g->timer_index = (gint) event_source_id;
}
void
load_graph_stop (LoadGraph *g)
{
if (g->timer_index != -1)
- g_source_remove (g->timer_index);
+ g_source_remove ((guint) g->timer_index);
g->timer_index = -1;
}
diff --git a/multiload/src/load-graph.h b/multiload/src/load-graph.h
index 76effcd6..1f13a8d0 100644
--- a/multiload/src/load-graph.h
+++ b/multiload/src/load-graph.h
@@ -6,7 +6,7 @@
/* Create new load graph. */
G_GNUC_INTERNAL LoadGraph *
load_graph_new (MultiloadApplet *multiload, guint n, const gchar *label,
- guint id, guint speed, guint size, gboolean visible,
+ gint id, guint speed, guint size, gboolean visible,
const gchar *name, LoadGraphDataFunc get_data);
/* Start load graph. */
diff --git a/multiload/src/main.c b/multiload/src/main.c
index e1b0481e..d27bef7a 100644
--- a/multiload/src/main.c
+++ b/multiload/src/main.c
@@ -189,7 +189,7 @@ multiload_change_orient_cb(MatePanelApplet *applet, gint arg1, gpointer data)
static void
multiload_destroy_cb(GtkWidget *widget, gpointer data)
{
- gint i;
+ guint i;
MultiloadApplet *ma = data;
for (i = 0; i < graph_n; i++)
@@ -350,7 +350,7 @@ multiload_create_graphs(MultiloadApplet *ma)
struct { const char *label;
const char *visibility_key;
const char *name;
- int num_colours;
+ guint num_colours;
LoadGraphDataFunc callback;
} graph_types [graph_n] = {
[graph_cpuload] = { _("CPU Load"), VIEW_CPULOAD_KEY, "cpuload", cpuload_n, GetLoad },
@@ -363,16 +363,16 @@ multiload_create_graphs(MultiloadApplet *ma)
guint size;
guint speed;
- guint net_threshold1;
- guint net_threshold2;
- guint net_threshold3;
+ guint64 net_threshold1;
+ guint64 net_threshold2;
+ guint64 net_threshold3;
gint i;
speed = CLAMP (g_settings_get_uint (ma->settings, REFRESH_RATE_KEY), REFRESH_RATE_MIN, REFRESH_RATE_MAX);
size = CLAMP (g_settings_get_uint (ma->settings, GRAPH_SIZE_KEY), GRAPH_SIZE_MIN, GRAPH_SIZE_MAX);
- net_threshold1 = CLAMP (g_settings_get_uint (ma->settings, KEY_NET_THRESHOLD1), MIN_NET_THRESHOLD1, MAX_NET_THRESHOLD1);
- net_threshold2 = CLAMP (g_settings_get_uint (ma->settings, KEY_NET_THRESHOLD2), MIN_NET_THRESHOLD2, MAX_NET_THRESHOLD2);
- net_threshold3 = CLAMP (g_settings_get_uint (ma->settings, KEY_NET_THRESHOLD3), MIN_NET_THRESHOLD3, MAX_NET_THRESHOLD3);
+ net_threshold1 = CLAMP (g_settings_get_uint64 (ma->settings, KEY_NET_THRESHOLD1), MIN_NET_THRESHOLD1, MAX_NET_THRESHOLD1);
+ net_threshold2 = CLAMP (g_settings_get_uint64 (ma->settings, KEY_NET_THRESHOLD2), MIN_NET_THRESHOLD2, MAX_NET_THRESHOLD2);
+ net_threshold3 = CLAMP (g_settings_get_uint64 (ma->settings, KEY_NET_THRESHOLD3), MIN_NET_THRESHOLD3, MAX_NET_THRESHOLD3);
if (net_threshold1 >= net_threshold2)
{
net_threshold1 = net_threshold2 - 1;
@@ -411,7 +411,7 @@ multiload_create_graphs(MultiloadApplet *ma)
void
multiload_applet_refresh(MultiloadApplet *ma)
{
- gint i;
+ guint i;
MatePanelAppletOrient orientation;
/* stop and free the old graphs */
diff --git a/multiload/src/netspeed.c b/multiload/src/netspeed.c
index 3e889c8f..a61ce04b 100644
--- a/multiload/src/netspeed.c
+++ b/multiload/src/netspeed.c
@@ -1,6 +1,5 @@
#include <config.h>
#include <glib.h>
-#include <time.h>
#include "netspeed.h"
@@ -9,13 +8,14 @@ enum { N_STATES = 4 };
struct _NetSpeed
{
LoadGraph *graph;
- gulong states[N_STATES];
+ guint64 states[N_STATES];
size_t cur;
};
-NetSpeed* netspeed_new(LoadGraph *g)
+NetSpeed*
+netspeed_new (LoadGraph *g)
{
- NetSpeed *ns = g_new0(NetSpeed, 1);
+ NetSpeed *ns = g_new0 (NetSpeed, 1);
ns->graph = g;
return ns;
}
@@ -25,31 +25,22 @@ void netspeed_delete(NetSpeed *ns)
g_free(ns);
}
-void netspeed_add(NetSpeed *ns, gulong tx)
+void
+netspeed_add (NetSpeed *ns,
+ guint64 tx)
{
ns->cur = (ns->cur + 1) % N_STATES;
ns->states[ns->cur] = tx;
}
-/* Something very similar to g_format_size() but for rates.
- * This should give the same display as in g-s-m */
-static char*
-format_rate_for_display(guint rate)
+char*
+netspeed_get (NetSpeed *ns)
{
- char *bytes;
- char *text;
-
- bytes = g_format_size (rate);
- text = g_strdup_printf (_("%s/s"), bytes);
- g_free (bytes);
-
- return text;
-}
-
-char* netspeed_get(NetSpeed *ns)
-{
- gulong older, newer;
- guint rate;
+ guint64 older;
+ guint64 newer;
+ guint64 rate;
+ char *bytes;
+ char *text;
newer = ns->states[ns->cur];
older = ns->states[(ns->cur + 1) % N_STATES];
@@ -65,6 +56,9 @@ char* netspeed_get(NetSpeed *ns)
few seconds. */
rate = 0;
- return format_rate_for_display(rate);
-}
+ bytes = g_format_size (rate);
+ text = g_strdup_printf (_("%s/s"), bytes);
+ g_free (bytes);
+ return text;
+}
diff --git a/multiload/src/properties.c b/multiload/src/properties.c
index 9e1ec66c..ffe1b88c 100644
--- a/multiload/src/properties.c
+++ b/multiload/src/properties.c
@@ -54,10 +54,9 @@ soft_set_sensitive (GtkWidget *w, gboolean sensitivity)
static void
properties_set_insensitive(MultiloadApplet *ma)
{
- gint i, total_graphs, last_graph;
-
- total_graphs = 0;
- last_graph = 0;
+ guint total_graphs = 0;
+ guint last_graph = 0;
+ guint i;
for (i = 0; i < graph_n; i++)
if (ma->graphs[i]->visible)
@@ -104,9 +103,10 @@ static void
property_toggled_cb(GtkWidget *widget, gpointer name)
{
MultiloadApplet *ma;
- gint prop_type, i;
- gboolean active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
+ gint prop_type;
+ gboolean active;
+ active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget));
ma = g_object_get_data(G_OBJECT(widget), "MultiloadApplet");
prop_type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "prop_type"));
@@ -117,6 +117,8 @@ property_toggled_cb(GtkWidget *widget, gpointer name)
if (active)
{
+ guint i;
+
for (i = 0; i < graph_n; i++)
soft_set_sensitive(ma->check_boxes[i], TRUE);
gtk_widget_show_all (ma->graphs[prop_type]->main_widget);
@@ -140,7 +142,7 @@ on_speed_spin_button_value_changed (GtkSpinButton *spin_button,
{
MultiloadApplet *ma = user_data;
gint value;
- gint i;
+ guint i;
value = gtk_spin_button_get_value_as_int (spin_button);
g_settings_set_uint (ma->settings, REFRESH_RATE_KEY, (guint) value);
@@ -158,7 +160,7 @@ on_graph_size_spin_button_value_changed (GtkSpinButton *spin_button,
{
MultiloadApplet *ma = user_data;
gint value;
- gint i;
+ guint i;
value = gtk_spin_button_get_value_as_int (spin_button);
g_settings_set_uint (ma->settings, GRAPH_SIZE_KEY, (guint) value);
@@ -166,12 +168,12 @@ on_graph_size_spin_button_value_changed (GtkSpinButton *spin_button,
ma->graphs[i]->size = (guint) value;
if (ma->graphs[i]->orient) {
gtk_widget_set_size_request (ma->graphs[i]->main_widget,
- ma->graphs[i]->pixel_size,
- ma->graphs[i]->size);
+ (gint) ma->graphs[i]->pixel_size,
+ (gint) ma->graphs[i]->size);
} else {
gtk_widget_set_size_request (ma->graphs[i]->main_widget,
- ma->graphs[i]->size,
- ma->graphs[i]->pixel_size);
+ (gint) ma->graphs[i]->size,
+ (gint) ma->graphs[i]->pixel_size);
}
}
}
@@ -181,15 +183,15 @@ on_net_threshold1_spin_button_value_changed (GtkSpinButton *spin_button,
gpointer user_data)
{
MultiloadApplet *ma = user_data;
- gint value;
+ gdouble temp;
- value = gtk_spin_button_get_value_as_int (spin_button);
- if (value >= (gint) ma->net_threshold2) {
- value = (gint) ma->net_threshold2 - 1;
- gtk_spin_button_set_value (spin_button, (gdouble) value);
+ temp = gtk_spin_button_get_value (spin_button);
+ ma->net_threshold1 = (guint64) temp;
+ if (ma->net_threshold1 >= ma->net_threshold2) {
+ ma->net_threshold1 = ma->net_threshold2 - 1;
+ gtk_spin_button_set_value (spin_button, (gdouble) ma->net_threshold1);
}
- ma->net_threshold1 = (guint) value;
- g_settings_set_uint (ma->settings, KEY_NET_THRESHOLD1, ma->net_threshold1);
+ g_settings_set_uint64 (ma->settings, KEY_NET_THRESHOLD1, ma->net_threshold1);
}
@@ -198,18 +200,18 @@ on_net_threshold2_spin_button_value_changed (GtkSpinButton *spin_button,
gpointer user_data)
{
MultiloadApplet *ma = user_data;
- gint value;
-
- value = gtk_spin_button_get_value_as_int (spin_button);
- if (value >= (gint) ma->net_threshold3) {
- value = (gint) ma->net_threshold3 - 1;
- gtk_spin_button_set_value (spin_button, (gdouble) value);
- } else if (value <= (gint) ma->net_threshold1) {
- value = (gint) ma->net_threshold1 + 1;
- gtk_spin_button_set_value (spin_button, (gdouble) value);
+ gdouble temp;
+
+ temp = gtk_spin_button_get_value (spin_button);
+ ma->net_threshold2 = (guint64) temp;
+ if (ma->net_threshold2 >= ma->net_threshold3) {
+ ma->net_threshold2 = ma->net_threshold3 - 1;
+ gtk_spin_button_set_value (spin_button, (gdouble) ma->net_threshold2);
+ } else if (ma->net_threshold2 <= ma->net_threshold1) {
+ ma->net_threshold2 = ma->net_threshold1 + 1;
+ gtk_spin_button_set_value (spin_button, (gdouble) ma->net_threshold2);
}
- ma->net_threshold2 = (guint) value;
- g_settings_set_uint (ma->settings, KEY_NET_THRESHOLD2, ma->net_threshold2);
+ g_settings_set_uint64 (ma->settings, KEY_NET_THRESHOLD2, ma->net_threshold2);
}
@@ -218,15 +220,15 @@ on_net_threshold3_spin_button_value_changed (GtkSpinButton *spin_button,
gpointer user_data)
{
MultiloadApplet *ma = user_data;
- gint value;
+ gdouble temp;
- value = gtk_spin_button_get_value_as_int (spin_button);
- if (value <= (gint) ma->net_threshold2) {
- value = (gint) ma->net_threshold2 + 1;
- gtk_spin_button_set_value (spin_button, (gdouble) value);
+ temp = gtk_spin_button_get_value (spin_button);
+ ma->net_threshold3 = (guint64) temp;
+ if (ma->net_threshold3 <= ma->net_threshold2) {
+ ma->net_threshold3 = ma->net_threshold2 + 1;
+ gtk_spin_button_set_value (spin_button, (gdouble) ma->net_threshold3);
}
- ma->net_threshold3 = (guint) value;
- g_settings_set_uint (ma->settings, KEY_NET_THRESHOLD3, ma->net_threshold3);
+ g_settings_set_uint64 (ma->settings, KEY_NET_THRESHOLD3, ma->net_threshold3);
}
/* create a new page in the notebook widget, add it, and return a pointer to it */
@@ -355,6 +357,7 @@ fill_properties(GtkWidget *dialog, MultiloadApplet *ma)
gchar *label_text;
gchar *title;
guint spin_value_uint;
+ guint64 spin_value_uint64;
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
@@ -707,8 +710,8 @@ fill_properties(GtkWidget *dialog, MultiloadApplet *ma)
spin_button = gtk_spin_button_new_with_range (MIN_NET_THRESHOLD1, MAX_NET_THRESHOLD1, 5);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), spin_button);
- spin_value_uint = g_settings_get_uint (ma->settings, KEY_NET_THRESHOLD1);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin_button), (gdouble) spin_value_uint);
+ spin_value_uint64 = g_settings_get_uint64 (ma->settings, KEY_NET_THRESHOLD1);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin_button), (gdouble) spin_value_uint64);
g_signal_connect (GTK_SPIN_BUTTON (spin_button), "value-changed",
G_CALLBACK (on_net_threshold1_spin_button_value_changed), ma);
@@ -740,8 +743,8 @@ fill_properties(GtkWidget *dialog, MultiloadApplet *ma)
spin_button = gtk_spin_button_new_with_range (MIN_NET_THRESHOLD2, MAX_NET_THRESHOLD2, 5);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), spin_button);
- spin_value_uint = g_settings_get_uint (ma->settings, KEY_NET_THRESHOLD2);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin_button), (gdouble) spin_value_uint);
+ spin_value_uint64 = g_settings_get_uint64 (ma->settings, KEY_NET_THRESHOLD2);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin_button), (gdouble) spin_value_uint64);
g_signal_connect (GTK_SPIN_BUTTON (spin_button), "value-changed",
G_CALLBACK (on_net_threshold2_spin_button_value_changed), ma);
gtk_size_group_add_widget (spin_size, spin_button);
@@ -772,8 +775,8 @@ fill_properties(GtkWidget *dialog, MultiloadApplet *ma)
spin_button = gtk_spin_button_new_with_range (MIN_NET_THRESHOLD3, MAX_NET_THRESHOLD3, 5);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), spin_button);
- spin_value_uint = g_settings_get_uint (ma->settings, KEY_NET_THRESHOLD3);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin_button), (gdouble) spin_value_uint);
+ spin_value_uint64 = g_settings_get_uint64 (ma->settings, KEY_NET_THRESHOLD3);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin_button), (gdouble) spin_value_uint64);
g_signal_connect (GTK_SPIN_BUTTON (spin_button), "value-changed",
G_CALLBACK (on_net_threshold3_spin_button_value_changed), ma);
gtk_size_group_add_widget (spin_size, spin_button);