summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorinfirit <[email protected]>2014-12-18 00:34:05 +0100
committerinfirit <[email protected]>2014-12-18 00:34:05 +0100
commitc8829c37457b28b99b2be815444d5aebfe7a7ad9 (patch)
tree8d9e1ef851b7a1b709962c3c5810563f37723191 /src
parent12975909c589880030db6125ad6dcbea889edcdc (diff)
downloadmate-system-monitor-c8829c37457b28b99b2be815444d5aebfe7a7ad9.tar.bz2
mate-system-monitor-c8829c37457b28b99b2be815444d5aebfe7a7ad9.tar.xz
Give 'g' variable meaningful name, 'graph'
Taken from GSM commit: ffdc8936d6b78ddd630d9448341ef515eee8c7f7 From: Chris Kühl <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/load-graph.cpp394
1 files changed, 197 insertions, 197 deletions
diff --git a/src/load-graph.cpp b/src/load-graph.cpp
index fd4afc1..a83db22 100644
--- a/src/load-graph.cpp
+++ b/src/load-graph.cpp
@@ -70,7 +70,7 @@ unsigned LoadGraph::num_bars() const
#define FRAME_WIDTH 4
-static void draw_background(LoadGraph *g) {
+static void draw_background(LoadGraph *graph) {
GtkAllocation allocation;
double dash[2] = { 1.0, 2.0 };
cairo_t *cr;
@@ -79,19 +79,19 @@ static void draw_background(LoadGraph *g) {
char *caption;
cairo_text_extents_t extents;
- num_bars = g->num_bars();
- g->graph_dely = (g->draw_height - 15) / num_bars; /* round to int to avoid AA blur */
- g->real_draw_height = g->graph_dely * num_bars;
- g->graph_delx = (g->draw_width - 2.0 - g->rmargin - g->indent) / (LoadGraph::NUM_POINTS - 3);
- g->graph_buffer_offset = (int) (1.5 * g->graph_delx) + FRAME_WIDTH ;
+ num_bars = graph->num_bars();
+ graph->graph_dely = (graph->draw_height - 15) / num_bars; /* round to int to avoid AA blur */
+ graph->real_draw_height = graph->graph_dely * num_bars;
+ graph->graph_delx = (graph->draw_width - 2.0 - graph->rmargin - graph->indent) / (LoadGraph::NUM_POINTS - 3);
+ graph->graph_buffer_offset = (int) (1.5 * graph->graph_delx) + FRAME_WIDTH ;
- gtk_widget_get_allocation (g->disp, &allocation);
+ gtk_widget_get_allocation (graph->disp, &allocation);
#if GTK_CHECK_VERSION(3,0,0)
- g->background = gdk_window_create_similar_surface (gtk_widget_get_window (g->disp), CAIRO_CONTENT_COLOR_ALPHA, allocation.width, allocation.height);
- cr = cairo_create (g->background);
+ graph->background = gdk_window_create_similar_surface (gtk_widget_get_window (graph->disp), CAIRO_CONTENT_COLOR_ALPHA, allocation.width, allocation.height);
+ cr = cairo_create (graph->background);
#else
- g->background = gdk_pixmap_new (GDK_DRAWABLE (gtk_widget_get_window (g->disp)), allocation.width, allocation.height, -1);
- cr = gdk_cairo_create (g->background);
+ graph->background = gdk_pixmap_new (GDK_DRAWABLE (gtk_widget_get_window (graph->disp)), allocation.width, allocation.height, -1);
+ cr = gdk_cairo_create (graph->background);
#endif
// set the background colour
@@ -104,56 +104,56 @@ static void draw_background(LoadGraph *g) {
/* Draw background rectangle */
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
- cairo_rectangle (cr, g->rmargin + g->indent, 0,
- g->draw_width - g->rmargin - g->indent, g->real_draw_height);
+ cairo_rectangle (cr, graph->rmargin + graph->indent, 0,
+ graph->draw_width - graph->rmargin - graph->indent, graph->real_draw_height);
cairo_fill(cr);
cairo_set_line_width (cr, 1.0);
cairo_set_dash (cr, dash, 2, 0);
- cairo_set_font_size (cr, g->fontsize);
+ cairo_set_font_size (cr, graph->fontsize);
for (i = 0; i <= num_bars; ++i) {
double y;
if (i == 0)
- y = 0.5 + g->fontsize / 2.0;
+ y = 0.5 + graph->fontsize / 2.0;
else if (i == num_bars)
- y = i * g->graph_dely + 0.5;
+ y = i * graph->graph_dely + 0.5;
else
- y = i * g->graph_dely + g->fontsize / 2.0;
+ y = i * graph->graph_dely + graph->fontsize / 2.0;
gdk_cairo_set_source_color (cr, &style->fg[GTK_STATE_NORMAL]);
- if (g->type == LOAD_GRAPH_NET) {
+ if (graph->type == LOAD_GRAPH_NET) {
// operation orders matters so it's 0 if i == num_bars
- unsigned rate = g->net.max - (i * g->net.max / num_bars);
- const std::string caption(procman::format_network_rate(rate, g->net.max));
+ unsigned rate = graph->net.max - (i * graph->net.max / num_bars);
+ const std::string caption(procman::format_network_rate(rate, graph->net.max));
cairo_text_extents (cr, caption.c_str(), &extents);
- cairo_move_to (cr, g->indent - extents.width + 20, y);
+ cairo_move_to (cr, graph->indent - extents.width + 20, y);
cairo_show_text (cr, caption.c_str());
} else {
// operation orders matters so it's 0 if i == num_bars
caption = g_strdup_printf("%d %%", 100 - i * (100 / num_bars));
cairo_text_extents (cr, caption, &extents);
- cairo_move_to (cr, g->indent - extents.width + 20, y);
+ cairo_move_to (cr, graph->indent - extents.width + 20, y);
cairo_show_text (cr, caption);
g_free (caption);
}
cairo_set_source_rgba (cr, 0, 0, 0, 0.75);
- cairo_move_to (cr, g->rmargin + g->indent - 3, i * g->graph_dely + 0.5);
- cairo_line_to (cr, g->draw_width - 0.5, i * g->graph_dely + 0.5);
+ cairo_move_to (cr, graph->rmargin + graph->indent - 3, i * graph->graph_dely + 0.5);
+ cairo_line_to (cr, graph->draw_width - 0.5, i * graph->graph_dely + 0.5);
}
cairo_stroke (cr);
cairo_set_dash (cr, dash, 2, 1.5);
- const unsigned total_seconds = g->speed * (LoadGraph::NUM_POINTS - 2) / 1000;
+ const unsigned total_seconds = graph->speed * (LoadGraph::NUM_POINTS - 2) / 1000;
for (unsigned int i = 0; i < 7; i++) {
- double x = (i) * (g->draw_width - g->rmargin - g->indent) / 6;
+ double x = (i) * (graph->draw_width - graph->rmargin - graph->indent) / 6;
cairo_set_source_rgba (cr, 0, 0, 0, 0.75);
- cairo_move_to (cr, (ceil(x) + 0.5) + g->rmargin + g->indent, 0.5);
- cairo_line_to (cr, (ceil(x) + 0.5) + g->rmargin + g->indent, g->real_draw_height + 4.5);
+ cairo_move_to (cr, (ceil(x) + 0.5) + graph->rmargin + graph->indent, 0.5);
+ cairo_line_to (cr, (ceil(x) + 0.5) + graph->rmargin + graph->indent, graph->real_draw_height + 4.5);
cairo_stroke(cr);
unsigned seconds = total_seconds - i * total_seconds / 6;
const char* format;
@@ -163,7 +163,7 @@ static void draw_background(LoadGraph *g) {
format = "%u";
caption = g_strdup_printf(format, seconds);
cairo_text_extents (cr, caption, &extents);
- cairo_move_to (cr, ((ceil(x) + 0.5) + g->rmargin + g->indent) - (extents.width/2), g->draw_height);
+ cairo_move_to (cr, ((ceil(x) + 0.5) + graph->rmargin + graph->indent) - (extents.width/2), graph->draw_height);
gdk_cairo_set_source_color (cr, &style->fg[GTK_STATE_NORMAL]);
cairo_show_text (cr, caption);
g_free (caption);
@@ -175,10 +175,10 @@ static void draw_background(LoadGraph *g) {
/* Redraws the backing buffer for the load graph and updates the window */
void
-load_graph_queue_draw (LoadGraph *g)
+load_graph_queue_draw (LoadGraph *graph)
{
/* repaint */
- gtk_widget_queue_draw (g->disp);
+ gtk_widget_queue_draw (graph->disp);
}
static int load_graph_update (gpointer user_data); // predeclare load_graph_update so we can compile ;)
@@ -189,15 +189,15 @@ load_graph_configure (GtkWidget *widget,
gpointer data_ptr)
{
GtkAllocation allocation;
- LoadGraph * const g = static_cast<LoadGraph*>(data_ptr);
+ LoadGraph * const graph = static_cast<LoadGraph*>(data_ptr);
gtk_widget_get_allocation (widget, &allocation);
- g->draw_width = allocation.width - 2 * FRAME_WIDTH;
- g->draw_height = allocation.height - 2 * FRAME_WIDTH;
+ graph->draw_width = allocation.width - 2 * FRAME_WIDTH;
+ graph->draw_height = allocation.height - 2 * FRAME_WIDTH;
- g->clear_background();
+ graph->clear_background();
- load_graph_queue_draw (g);
+ load_graph_queue_draw (graph);
return TRUE;
}
@@ -208,34 +208,34 @@ static gboolean load_graph_draw (GtkWidget *widget, cairo_t *context, gpointer d
static gboolean load_graph_expose (GtkWidget *widget, GdkEventExpose *event, gpointer data_ptr)
#endif
{
- LoadGraph * const g = static_cast<LoadGraph*>(data_ptr);
+ LoadGraph * const graph = static_cast<LoadGraph*>(data_ptr);
GtkAllocation allocation;
GdkWindow *window;
guint i, j;
gdouble sample_width, x_offset;
- window = gtk_widget_get_window (g->disp);
- gtk_widget_get_allocation (g->disp, &allocation);
+ window = gtk_widget_get_window (graph->disp);
+ gtk_widget_get_allocation (graph->disp, &allocation);
- if (g->background == NULL) {
- draw_background(g);
+ if (graph->background == NULL) {
+ draw_background(graph);
#if GTK_CHECK_VERSION(3,0,0)
- cairo_pattern_t *pattern = cairo_pattern_create_for_surface (g->background);
+ cairo_pattern_t *pattern = cairo_pattern_create_for_surface (graph->background);
gdk_window_set_background_pattern (window, pattern);
cairo_pattern_destroy (pattern);
#else
- gdk_window_set_back_pixmap (window, g->background, FALSE);
+ gdk_window_set_back_pixmap (window, graph->background, FALSE);
#endif
}
/* Number of pixels wide for one graph point */
- sample_width = (float)(g->draw_width - g->rmargin - g->indent) / (float)LoadGraph::NUM_POINTS;
+ sample_width = (float)(graph->draw_width - graph->rmargin - graph->indent) / (float)LoadGraph::NUM_POINTS;
/* General offset */
- x_offset = g->draw_width - g->rmargin + (sample_width*2);
+ x_offset = graph->draw_width - graph->rmargin + (sample_width*2);
/* Subframe offset */
- x_offset += g->rmargin - ((sample_width / g->frames_per_unit) * g->render_counter);
+ x_offset += graph->rmargin - ((sample_width / graph->frames_per_unit) * graph->render_counter);
/* draw the graph */
cairo_t* cr;
@@ -245,24 +245,24 @@ static gboolean load_graph_expose (GtkWidget *widget, GdkEventExpose *event, gpo
cairo_set_line_width (cr, 1);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
- cairo_rectangle (cr, g->rmargin + g->indent + FRAME_WIDTH + 1, FRAME_WIDTH - 1,
- g->draw_width - g->rmargin - g->indent - 1, g->real_draw_height + FRAME_WIDTH - 1);
+ cairo_rectangle (cr, graph->rmargin + graph->indent + FRAME_WIDTH + 1, FRAME_WIDTH - 1,
+ graph->draw_width - graph->rmargin - graph->indent - 1, graph->real_draw_height + FRAME_WIDTH - 1);
cairo_clip(cr);
- for (j = 0; j < g->n; ++j) {
- cairo_move_to (cr, x_offset, (1.0f - g->data[0][j]) * g->real_draw_height);
- gdk_cairo_set_source_color (cr, &(g->colors [j]));
+ for (j = 0; j < graph->n; ++j) {
+ cairo_move_to (cr, x_offset, (1.0f - graph->data[0][j]) * graph->real_draw_height);
+ gdk_cairo_set_source_color (cr, &(graph->colors [j]));
for (i = 1; i < LoadGraph::NUM_POINTS; ++i) {
- if (g->data[i][j] == -1.0f)
+ if (graph->data[i][j] == -1.0f)
continue;
cairo_curve_to (cr,
- x_offset - ((i - 0.5f) * g->graph_delx),
- (1.0f - g->data[i-1][j]) * g->real_draw_height + 3.5f,
- x_offset - ((i - 0.5f) * g->graph_delx),
- (1.0f - g->data[i][j]) * g->real_draw_height + 3.5f,
- x_offset - (i * g->graph_delx),
- (1.0f - g->data[i][j]) * g->real_draw_height + 3.5f);
+ x_offset - ((i - 0.5f) * graph->graph_delx),
+ (1.0f - graph->data[i-1][j]) * graph->real_draw_height + 3.5f,
+ x_offset - ((i - 0.5f) * graph->graph_delx),
+ (1.0f - graph->data[i][j]) * graph->real_draw_height + 3.5f,
+ x_offset - (i * graph->graph_delx),
+ (1.0f - graph->data[i][j]) * graph->real_draw_height + 3.5f);
}
cairo_stroke (cr);
@@ -274,7 +274,7 @@ static gboolean load_graph_expose (GtkWidget *widget, GdkEventExpose *event, gpo
}
static void
-get_load (LoadGraph *g)
+get_load (LoadGraph *graph)
{
guint i;
glibtop_cpu cpu;
@@ -283,14 +283,14 @@ get_load (LoadGraph *g)
#undef NOW
#undef LAST
-#define NOW (g->cpu.times[g->cpu.now])
-#define LAST (g->cpu.times[g->cpu.now ^ 1])
+#define NOW (graph->cpu.times[graph->cpu.now])
+#define LAST (graph->cpu.times[graph->cpu.now ^ 1])
- if (g->n == 1) {
+ if (graph->n == 1) {
NOW[0][CPU_TOTAL] = cpu.total;
NOW[0][CPU_USED] = cpu.user + cpu.nice + cpu.sys;
} else {
- for (i = 0; i < g->n; i++) {
+ for (i = 0; i < graph->n; i++) {
NOW[i][CPU_TOTAL] = cpu.xcpu_total[i];
NOW[i][CPU_USED] = cpu.xcpu_user[i] + cpu.xcpu_nice[i]
+ cpu.xcpu_sys[i];
@@ -303,7 +303,7 @@ get_load (LoadGraph *g)
// graphs to be aligned, so the CPU graph needs to start
// immediately
- for (i = 0; i < g->n; i++) {
+ for (i = 0; i < graph->n; i++) {
float load;
float total, used;
gchar *text;
@@ -312,15 +312,15 @@ get_load (LoadGraph *g)
used = NOW[i][CPU_USED] - LAST[i][CPU_USED];
load = used / MAX(total, 1.0f);
- g->data[0][i] = load;
+ graph->data[0][i] = load;
/* Update label */
text = g_strdup_printf("%.1f%%", load * 100.0f);
- gtk_label_set_text(GTK_LABEL(g->labels.cpu[i]), text);
+ gtk_label_set_text(GTK_LABEL(graph->labels.cpu[i]), text);
g_free(text);
}
- g->cpu.now ^= 1;
+ graph->cpu.now ^= 1;
#undef NOW
#undef LAST
@@ -352,7 +352,7 @@ namespace
}
static void
-get_memory (LoadGraph *g)
+get_memory (LoadGraph *graph)
{
float mempercent, swappercent;
@@ -366,35 +366,35 @@ get_memory (LoadGraph *g)
swappercent = (swap.total ? (float)swap.used / (float)swap.total : 0.0f);
mempercent = (float)mem.user / (float)mem.total;
- set_memory_label_and_picker(GTK_LABEL(g->labels.memory),
- GSM_COLOR_BUTTON(g->mem_color_picker),
+ set_memory_label_and_picker(GTK_LABEL(graph->labels.memory),
+ GSM_COLOR_BUTTON(graph->mem_color_picker),
mem.user, mem.total, mempercent);
- set_memory_label_and_picker(GTK_LABEL(g->labels.swap),
- GSM_COLOR_BUTTON(g->swap_color_picker),
+ set_memory_label_and_picker(GTK_LABEL(graph->labels.swap),
+ GSM_COLOR_BUTTON(graph->swap_color_picker),
swap.used, swap.total, swappercent);
- g->data[0][0] = mempercent;
- g->data[0][1] = swappercent;
+ graph->data[0][0] = mempercent;
+ graph->data[0][1] = swappercent;
}
static void
-net_scale (LoadGraph *g, guint64 din, guint64 dout)
+net_scale (LoadGraph *graph, guint64 din, guint64 dout)
{
- g->data[0][0] = 1.0f * din / g->net.max;
- g->data[0][1] = 1.0f * dout / g->net.max;
+ graph->data[0][0] = 1.0f * din / graph->net.max;
+ graph->data[0][1] = 1.0f * dout / graph->net.max;
guint64 dmax = std::max(din, dout);
- g->net.values[g->net.cur] = dmax;
- g->net.cur = (g->net.cur + 1) % LoadGraph::NUM_POINTS;
+ graph->net.values[graph->net.cur] = dmax;
+ graph->net.cur = (graph->net.cur + 1) % LoadGraph::NUM_POINTS;
guint64 new_max;
// both way, new_max is the greatest value
- if (dmax >= g->net.max)
+ if (dmax >= graph->net.max)
new_max = dmax;
else
- new_max = *std::max_element(&g->net.values[0],
- &g->net.values[LoadGraph::NUM_POINTS]);
+ new_max = *std::max_element(&graph->net.values[0],
+ &graph->net.values[LoadGraph::NUM_POINTS]);
//
// Round network maximum
@@ -439,9 +439,9 @@ net_scale (LoadGraph *g, guint64 din, guint64 dout)
coef10 = std::ceil(coef10 / double(factor10)) * factor10;
// then make coef10 divisible by num_bars
- if (coef10 % g->num_bars() != 0)
- coef10 = coef10 + (g->num_bars() - coef10 % g->num_bars());
- g_assert(coef10 % g->num_bars() == 0);
+ if (coef10 % graph->num_bars() != 0)
+ coef10 = coef10 + (graph->num_bars() - coef10 % graph->num_bars());
+ g_assert(coef10 % graph->num_bars() == 0);
new_max = coef10 * (G_GUINT64_CONSTANT(1) << guint64(base10 * 10));
procman_debug("bak %" G_GUINT64_FORMAT " new_max %" G_GUINT64_FORMAT
"pow2 %" G_GUINT64_FORMAT " coef10 %" G_GUINT64_FORMAT,
@@ -457,31 +457,31 @@ net_scale (LoadGraph *g, guint64 din, guint64 dout)
// if max is the same or has decreased but not so much, don't
// do anything to avoid rescaling
- if ((0.8 * g->net.max) < new_max && new_max <= g->net.max)
+ if ((0.8 * graph->net.max) < new_max && new_max <= graph->net.max)
return;
- const double scale = 1.0f * g->net.max / new_max;
+ const double scale = 1.0f * graph->net.max / new_max;
for (size_t i = 0; i < LoadGraph::NUM_POINTS; i++) {
- if (g->data[i][0] >= 0.0f) {
- g->data[i][0] *= scale;
- g->data[i][1] *= scale;
+ if (graph->data[i][0] >= 0.0f) {
+ graph->data[i][0] *= scale;
+ graph->data[i][1] *= scale;
}
}
procman_debug("rescale dmax = %" G_GUINT64_FORMAT
" max = %" G_GUINT64_FORMAT
" new_max = %" G_GUINT64_FORMAT,
- dmax, g->net.max, new_max);
+ dmax, graph->net.max, new_max);
- g->net.max = new_max;
+ graph->net.max = new_max;
// force the graph background to be redrawn now that scale has changed
- g->clear_background();
+ graph->clear_background();
}
static void
-get_net (LoadGraph *g)
+get_net (LoadGraph *graph)
{
glibtop_netlist netlist;
char **ifnames;
@@ -523,13 +523,13 @@ get_net (LoadGraph *g)
g_get_current_time (&time);
- if (in >= g->net.last_in && out >= g->net.last_out &&
- g->net.time.tv_sec != 0) {
+ if (in >= graph->net.last_in && out >= graph->net.last_out &&
+ graph->net.time.tv_sec != 0) {
float dtime;
- dtime = time.tv_sec - g->net.time.tv_sec +
- (double) (time.tv_usec - g->net.time.tv_usec) / G_USEC_PER_SEC;
- din = static_cast<guint64>((in - g->net.last_in) / dtime);
- dout = static_cast<guint64>((out - g->net.last_out) / dtime);
+ dtime = time.tv_sec - graph->net.time.tv_sec +
+ (double) (time.tv_usec - graph->net.time.tv_usec) / G_USEC_PER_SEC;
+ din = static_cast<guint64>((in - graph->net.last_in) / dtime);
+ dout = static_cast<guint64>((out - graph->net.last_out) / dtime);
} else {
/* Don't calc anything if new data is less than old (interface
removed, counters reset, ...) or if it is the first time */
@@ -537,18 +537,18 @@ get_net (LoadGraph *g)
dout = 0;
}
- g->net.last_in = in;
- g->net.last_out = out;
- g->net.time = time;
+ graph->net.last_in = in;
+ graph->net.last_out = out;
+ graph->net.time = time;
- net_scale(g, din, dout);
+ net_scale(graph, din, dout);
- gtk_label_set_text (GTK_LABEL (g->labels.net_in), procman::format_network_rate(din).c_str());
- gtk_label_set_text (GTK_LABEL (g->labels.net_in_total), procman::format_network(in).c_str());
+ gtk_label_set_text (GTK_LABEL (graph->labels.net_in), procman::format_network_rate(din).c_str());
+ gtk_label_set_text (GTK_LABEL (graph->labels.net_in_total), procman::format_network(in).c_str());
- gtk_label_set_text (GTK_LABEL (g->labels.net_out), procman::format_network_rate(dout).c_str());
- gtk_label_set_text (GTK_LABEL (g->labels.net_out_total), procman::format_network(out).c_str());
+ gtk_label_set_text (GTK_LABEL (graph->labels.net_out), procman::format_network_rate(dout).c_str());
+ gtk_label_set_text (GTK_LABEL (graph->labels.net_out_total), procman::format_network(out).c_str());
}
@@ -556,33 +556,33 @@ get_net (LoadGraph *g)
static gboolean
load_graph_update (gpointer user_data)
{
- LoadGraph * const g = static_cast<LoadGraph*>(user_data);
+ LoadGraph * const graph = static_cast<LoadGraph*>(user_data);
- if (g->render_counter == g->frames_per_unit - 1) {
- std::rotate(&g->data[0], &g->data[LoadGraph::NUM_POINTS - 1], &g->data[LoadGraph::NUM_POINTS]);
+ if (graph->render_counter == graph->frames_per_unit - 1) {
+ std::rotate(&graph->data[0], &graph->data[LoadGraph::NUM_POINTS - 1], &graph->data[LoadGraph::NUM_POINTS]);
- switch (g->type) {
+ switch (graph->type) {
case LOAD_GRAPH_CPU:
- get_load(g);
+ get_load(graph);
break;
case LOAD_GRAPH_MEM:
- get_memory(g);
+ get_memory(graph);
break;
case LOAD_GRAPH_NET:
- get_net(g);
+ get_net(graph);
break;
default:
g_assert_not_reached();
}
}
- if (g->draw)
- load_graph_queue_draw (g);
+ if (graph->draw)
+ load_graph_queue_draw (graph);
- g->render_counter++;
+ graph->render_counter++;
- if (g->render_counter >= g->frames_per_unit)
- g->render_counter = 0;
+ if (graph->render_counter >= graph->frames_per_unit)
+ graph->render_counter = 0;
return TRUE;
}
@@ -604,9 +604,9 @@ LoadGraph::~LoadGraph()
static gboolean
load_graph_destroy (GtkWidget *widget, gpointer data_ptr)
{
- LoadGraph * const g = static_cast<LoadGraph*>(data_ptr);
+ LoadGraph * const graph = static_cast<LoadGraph*>(data_ptr);
- delete g;
+ delete graph;
return FALSE;
}
@@ -635,165 +635,165 @@ LoadGraph::LoadGraph(guint type)
mem_color_picker(NULL),
swap_color_picker(NULL)
{
- LoadGraph * const g = this;
+ LoadGraph * const graph = this;
// FIXME:
- // on configure, g->frames_per_unit = g->draw_width/(LoadGraph::NUM_POINTS);
+ // on configure, graph->frames_per_unit = graph->draw_width/(LoadGraph::NUM_POINTS);
// knock FRAMES down to 5 until cairo gets faster
- g->frames_per_unit = 10; // this will be changed but needs initialising
- g->fontsize = 8.0;
- g->rmargin = 3.5 * g->fontsize;
- g->indent = 24.0;
+ graph->frames_per_unit = 10; // this will be changed but needs initialising
+ graph->fontsize = 8.0;
+ graph->rmargin = 3.5 * graph->fontsize;
+ graph->indent = 24.0;
- g->type = type;
+ graph->type = type;
switch (type) {
case LOAD_GRAPH_CPU:
- memset(&this->cpu, 0, sizeof g->cpu);
- g->n = ProcData::get_instance()->config.num_cpus;
+ memset(&this->cpu, 0, sizeof graph->cpu);
+ graph->n = ProcData::get_instance()->config.num_cpus;
- for(guint i = 0; i < G_N_ELEMENTS(g->labels.cpu); ++i)
- g->labels.cpu[i] = gtk_label_new(NULL);
+ for(guint i = 0; i < G_N_ELEMENTS(graph->labels.cpu); ++i)
+ graph->labels.cpu[i] = gtk_label_new(NULL);
break;
case LOAD_GRAPH_MEM:
- g->n = 2;
- g->labels.memory = gtk_label_new(NULL);
- g->labels.swap = gtk_label_new(NULL);
+ graph->n = 2;
+ graph->labels.memory = gtk_label_new(NULL);
+ graph->labels.swap = gtk_label_new(NULL);
break;
case LOAD_GRAPH_NET:
- memset(&this->net, 0, sizeof g->net);
- g->n = 2;
- g->net.max = 1;
- g->labels.net_in = gtk_label_new(NULL);
- g->labels.net_in_total = gtk_label_new(NULL);
- g->labels.net_out = gtk_label_new(NULL);
- g->labels.net_out_total = gtk_label_new(NULL);
+ memset(&this->net, 0, sizeof graph->net);
+ graph->n = 2;
+ graph->net.max = 1;
+ graph->labels.net_in = gtk_label_new(NULL);
+ graph->labels.net_in_total = gtk_label_new(NULL);
+ graph->labels.net_out = gtk_label_new(NULL);
+ graph->labels.net_out_total = gtk_label_new(NULL);
break;
}
- g->speed = ProcData::get_instance()->config.graph_update_interval;
+ graph->speed = ProcData::get_instance()->config.graph_update_interval;
- g->colors.resize(g->n);
+ graph->colors.resize(graph->n);
switch (type) {
case LOAD_GRAPH_CPU:
- memcpy(&g->colors[0], ProcData::get_instance()->config.cpu_color,
- g->n * sizeof g->colors[0]);
+ memcpy(&graph->colors[0], ProcData::get_instance()->config.cpu_color,
+ graph->n * sizeof graph->colors[0]);
break;
case LOAD_GRAPH_MEM:
- g->colors[0] = ProcData::get_instance()->config.mem_color;
- g->colors[1] = ProcData::get_instance()->config.swap_color;
- g->mem_color_picker = gsm_color_button_new (&g->colors[0],
+ graph->colors[0] = ProcData::get_instance()->config.mem_color;
+ graph->colors[1] = ProcData::get_instance()->config.swap_color;
+ graph->mem_color_picker = gsm_color_button_new (&graph->colors[0],
GSMCP_TYPE_PIE);
- g->swap_color_picker = gsm_color_button_new (&g->colors[1],
+ graph->swap_color_picker = gsm_color_button_new (&graph->colors[1],
GSMCP_TYPE_PIE);
break;
case LOAD_GRAPH_NET:
- g->colors[0] = ProcData::get_instance()->config.net_in_color;
- g->colors[1] = ProcData::get_instance()->config.net_out_color;
+ graph->colors[0] = ProcData::get_instance()->config.net_in_color;
+ graph->colors[1] = ProcData::get_instance()->config.net_out_color;
break;
}
- g->timer_index = 0;
- g->render_counter = (g->frames_per_unit - 1);
- g->draw = FALSE;
+ graph->timer_index = 0;
+ graph->render_counter = (graph->frames_per_unit - 1);
+ graph->draw = FALSE;
- g->main_widget = gtk_vbox_new (FALSE, FALSE);
- gtk_widget_set_size_request(g->main_widget, -1, LoadGraph::GRAPH_MIN_HEIGHT);
- gtk_widget_show (g->main_widget);
+ graph->main_widget = gtk_vbox_new (FALSE, FALSE);
+ gtk_widget_set_size_request(graph->main_widget, -1, LoadGraph::GRAPH_MIN_HEIGHT);
+ gtk_widget_show (graph->main_widget);
- g->disp = gtk_drawing_area_new ();
- gtk_widget_show (g->disp);
+ graph->disp = gtk_drawing_area_new ();
+ gtk_widget_show (graph->disp);
#if GTK_CHECK_VERSION(3,0,0)
- g_signal_connect (G_OBJECT (g->disp), "draw", G_CALLBACK (load_graph_draw), g);
+ g_signal_connect (G_OBJECT (graph->disp), "draw", G_CALLBACK (load_graph_draw), graph);
#else
- g_signal_connect (G_OBJECT (g->disp), "expose_event", G_CALLBACK (load_graph_expose), g);
+ g_signal_connect (G_OBJECT (graph->disp), "expose_event", G_CALLBACK (load_graph_expose), graph);
#endif
- g_signal_connect (G_OBJECT(g->disp), "configure_event",
- G_CALLBACK (load_graph_configure), g);
- g_signal_connect (G_OBJECT(g->disp), "destroy",
- G_CALLBACK (load_graph_destroy), g);
+ g_signal_connect (G_OBJECT(graph->disp), "configure_event",
+ G_CALLBACK (load_graph_configure), graph);
+ g_signal_connect (G_OBJECT(graph->disp), "destroy",
+ G_CALLBACK (load_graph_destroy), graph);
- gtk_widget_set_events (g->disp, GDK_EXPOSURE_MASK);
+ gtk_widget_set_events (graph->disp, GDK_EXPOSURE_MASK);
- gtk_box_pack_start (GTK_BOX (g->main_widget), g->disp, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (graph->main_widget), graph->disp, TRUE, TRUE, 0);
/* Allocate data in a contiguous block */
- g->data_block = std::vector<float>(g->n * LoadGraph::NUM_POINTS, -1.0f);
+ graph->data_block = std::vector<float>(graph->n * LoadGraph::NUM_POINTS, -1.0f);
for (guint i = 0; i < LoadGraph::NUM_POINTS; ++i)
- g->data[i] = &g->data_block[0] + i * g->n;
+ graph->data[i] = &graph->data_block[0] + i * graph->n;
- gtk_widget_show_all (g->main_widget);
+ gtk_widget_show_all (graph->main_widget);
}
void
-load_graph_start (LoadGraph *g)
+load_graph_start (LoadGraph *graph)
{
- if(!g->timer_index) {
+ if(!graph->timer_index) {
- load_graph_update(g);
+ load_graph_update(graph);
- g->timer_index = g_timeout_add (g->speed / g->frames_per_unit,
+ graph->timer_index = g_timeout_add (graph->speed / graph->frames_per_unit,
load_graph_update,
- g);
+ graph);
}
- g->draw = TRUE;
+ graph->draw = TRUE;
}
void
-load_graph_stop (LoadGraph *g)
+load_graph_stop (LoadGraph *graph)
{
/* don't draw anymore, but continue to poll */
- g->draw = FALSE;
+ graph->draw = FALSE;
}
void
-load_graph_change_speed (LoadGraph *g,
+load_graph_change_speed (LoadGraph *graph,
guint new_speed)
{
- if (g->speed == new_speed)
+ if (graph->speed == new_speed)
return;
- g->speed = new_speed;
+ graph->speed = new_speed;
- g_assert(g->timer_index);
+ g_assert(graph->timer_index);
- if(g->timer_index) {
- g_source_remove (g->timer_index);
- g->timer_index = g_timeout_add (g->speed / g->frames_per_unit,
+ if(graph->timer_index) {
+ g_source_remove (graph->timer_index);
+ graph->timer_index = g_timeout_add (graph->speed / graph->frames_per_unit,
load_graph_update,
- g);
+ graph);
}
- g->clear_background();
+ graph->clear_background();
}
LoadGraphLabels*
-load_graph_get_labels (LoadGraph *g)
+load_graph_get_labels (LoadGraph *graph)
{
- return &g->labels;
+ return &graph->labels;
}
GtkWidget*
-load_graph_get_widget (LoadGraph *g)
+load_graph_get_widget (LoadGraph *graph)
{
- return g->main_widget;
+ return graph->main_widget;
}
GtkWidget*
-load_graph_get_mem_color_picker(LoadGraph *g)
+load_graph_get_mem_color_picker(LoadGraph *graph)
{
- return g->mem_color_picker;
+ return graph->mem_color_picker;
}
GtkWidget*
-load_graph_get_swap_color_picker(LoadGraph *g)
+load_graph_get_swap_color_picker(LoadGraph *graph)
{
- return g->swap_color_picker;
+ return graph->swap_color_picker;
}