Debian Codegraph @

src/gsm-graph.h

raw symbols SCIP
1 #ifndef _GSM_GRAPH_H_
2 #define _GSM_GRAPH_H_
3 /*
4 * GNOME System Monitor graph
5 * Copyright (C) 2022 Ondřej Míchal <[email protected]z>
6 * All rights reserved.
7 *
8 * This Library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version.
12 *
13 * This software is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with the software; see the file COPYING. If not,
20 * see <http://www.gnu.org/licenses/>.
21 */
22
23 #pragma once
24
25 #include <gtk/gtk.h>
26
27 G_BEGIN_DECLS
28
29 #define GSM_TYPE_GRAPH (gsm_graph_get_type ())
30 #define GSM_GRAPH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSM_TYPE_GRAPH, GsmGraph))
31 #define GSM_IS_GRAPH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSM_TYPE_GRAPH))
32
33 typedef struct _GsmGraph GsmGraph;
34 typedef struct _GsmGraphClass GsmGraphClass;
35 typedef struct _GsmGraphPrivate GsmGraphPrivate;
36
37 struct _GsmGraph
38 {
39 GtkDrawingArea parent_instance;
40 };
41
42 struct _GsmGraphPrivate
43 {
44 gboolean draw;
45
46 // internal usage for animations
47
48 guint render_counter;
49 guint frames_per_unit;
50 guint redraw_timeout;
51
52 // used for displaying, configurable
53
54 // font size for labels
55 double fontsize;
56 // refresh timeout
57 guint speed;
58 // draw y axis with logarithmic scale instead of default linear
59 gboolean logarithmic_scale;
60 // number of chart data points
61 guint num_points;
62 // draw stacked chart
63 gboolean stacked;
64 // draw smooth chart
65 gboolean smooth;
66 // maximum value for y axis
67 guint64 max_value;
68
69 // used for displaying, internal
70
71 // right margin
72 double rmargin;
73 // cached background surface
74 cairo_surface_t *background;
75 guint indent;
76
77 // function to calculate the latest set of data to display
78 GSourceFunc data_function;
79 // the data to be passed to the data_function
80 gpointer update_data;
81 };
82
83 struct _GsmGraphClass
84 {
85 GtkDrawingAreaClass parent_class;
86
87 void (* css_changed) (GsmGraph *graph);
88 };
89
90 GType gsm_graph_get_type (void);
91 GsmGraph * gsm_graph_new (void);
92
93 void gsm_graph_dispose (GObject*);
94 void gsm_graph_finalize (GObject*);
95
96 void gsm_graph_start (GsmGraph*);
97 void gsm_graph_stop (GsmGraph*);
98 void gsm_graph_force_refresh (GsmGraph*);
99
100 // public setter methods
101 void gsm_graph_set_logarithmic_scale (GsmGraph*, gboolean);
102 void gsm_graph_set_smooth_chart (GsmGraph*, gboolean);
103 void gsm_graph_set_stacked_chart (GsmGraph*, gboolean);
104 void gsm_graph_set_speed (GsmGraph*, guint);
105 void gsm_graph_set_data_function (GsmGraph*, GSourceFunc, gpointer);
106 void gsm_graph_set_font_size (GsmGraph*, double);
107 void gsm_graph_set_num_points (GsmGraph*, guint);
108 void gsm_graph_set_max_value (GsmGraph*, guint64);
109
110 // temporary exported setter methods
111 void gsm_graph_clear_background (GsmGraph*);
112 void gsm_graph_set_background (GsmGraph*, cairo_surface_t*);
113 void gsm_graph_set_frames_per_unit (GsmGraph*, guint);
114
115 // public getter methods
116 gboolean gsm_graph_is_logarithmic_scale (GsmGraph*);
117 guint gsm_graph_get_speed (GsmGraph*);
118 double gsm_graph_get_font_size (GsmGraph*);
119 gboolean gsm_graph_is_started (GsmGraph*);
120 gboolean gsm_graph_is_smooth_chart (GsmGraph*);
121 gboolean gsm_graph_is_stacked_chart (GsmGraph*);
122 guint gsm_graph_get_num_points (GsmGraph*);
123 guint64 gsm_graph_get_max_value (GsmGraph*);
124
125 // temporary exported methods for the migration
126 gboolean gsm_graph_is_background_set (GsmGraph*);
127 cairo_surface_t * gsm_graph_get_background (GsmGraph*);
128 guint gsm_graph_get_frames_per_unit (GsmGraph*);
129 guint gsm_graph_get_render_counter (GsmGraph*);
130 guint gsm_graph_get_indent (GsmGraph*);
131 double gsm_graph_get_right_margin (GsmGraph*);
132 guint gsm_graph_get_num_bars (GsmGraph*, gint);
133
134
135 G_END_DECLS
136
137 #endif /* _GSM_GRAPH_H_ */