blob: 1a519ad27870dd494bbbb172c24e021a063542fd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
#ifndef _GSM_LOAD_GRAPH_H_
#define _GSM_LOAD_GRAPH_H_
#include <glib.h>
#include <glibtop/cpu.h>
#include "legacy/gsm_color_button.h"
#include "util.h"
#include "settings-keys.h"
enum
{
LOAD_GRAPH_CPU,
LOAD_GRAPH_MEM,
LOAD_GRAPH_NET
};
enum
{
CPU_TOTAL,
CPU_USED,
N_CPU_STATES
};
struct LoadGraphLabels
{
GtkLabel *cpu[GLIBTOP_NCPU];
GtkLabel *memory;
GtkLabel *swap;
GtkLabel *net_in;
GtkLabel *net_in_total;
GtkLabel *net_out;
GtkLabel *net_out_total;
};
struct LoadGraph
: private procman::NonCopyable
{
static const unsigned GRAPH_MIN_HEIGHT = 40;
LoadGraph(guint type);
~LoadGraph();
unsigned num_bars() const;
void clear_background();
bool is_logarithmic_scale() const;
char* get_caption(guint index);
float translate_to_log_partial_if_needed(float position_partial);
double fontsize;
double rmargin;
/* left margin */
double indent;
guint n;
gint type;
guint speed;
guint num_points;
guint latest;
guint draw_width, draw_height;
guint render_counter;
guint frames_per_unit;
guint graph_dely;
guint real_draw_height;
double graph_delx;
guint graph_buffer_offset;
std::vector<GdkRGBA> colors;
std::vector<double> data_block;
std::vector<double*> data;
GtkBox *main_widget;
GtkDrawingArea *disp;
cairo_surface_t *background;
guint timer_index;
gboolean draw;
LoadGraphLabels labels;
GsmColorButton *mem_color_picker;
GsmColorButton *swap_color_picker;
Glib::RefPtr<Gio::Settings> font_settings;
/* union { */
struct CPU
{
guint now; /* 0 -> current, 1 -> last
now ^ 1 each time */
/* times[now], times[now ^ 1] is last */
guint64 times[2][GLIBTOP_NCPU][N_CPU_STATES];
} cpu;
struct NET
{
guint64 last_in, last_out;
guint64 time;
guint64 max;
std::vector<unsigned> values;
} net;
/* }; */
};
/* Force a drawing update */
void
load_graph_queue_draw (LoadGraph *g);
/* Start load graph. */
void
load_graph_start (LoadGraph *g);
/* Stop load graph. */
void
load_graph_stop (LoadGraph *g);
/* Change load graph speed and restart it if it has been previously started */
void
load_graph_change_speed (LoadGraph *g,
guint new_speed);
/* Change load graph data points and restart it if it has been previously started */
void
load_graph_change_num_points(LoadGraph *g,
guint new_num_points);
/* Clear the history data. */
void
load_graph_reset (LoadGraph *g);
LoadGraphLabels*
load_graph_get_labels (LoadGraph *g) G_GNUC_CONST;
GtkBox*
load_graph_get_widget (LoadGraph *g) G_GNUC_CONST;
GsmColorButton*
load_graph_get_mem_color_picker(LoadGraph *g) G_GNUC_CONST;
GsmColorButton*
load_graph_get_swap_color_picker(LoadGraph *g) G_GNUC_CONST;
#endif /* _GSM_LOAD_GRAPH_H_ */
|