1 /*
2 * version 0.000000000001
3 *
4 * i might update the program when the guy who wrote x86info shows me the code
5 * required in fetching the cpu speed only (cus i think it's a little to hard
6 * on your system every x86info -mhz call).
7 *
8 */
9
10 #include <gkrellm2/gkrellm.h>
11 #include "gkx86info.h"
12
13 #define CONFIG_NAME "gkx86info"
14 #define STYLE_NAME "gkx86info"
15
16 static GkrellmMonitor *monitor;
17 static GkrellmPanel *panel;
18 static GkrellmDecal *decal_text1;
19 static gchar *info;
20 static gint style_id;
21 //static FILE *x86info_pipe = 0;
22
23
24 static gint
panel_expose_event(GtkWidget * widget,GdkEventExpose * ev)25 panel_expose_event(GtkWidget *widget, GdkEventExpose *ev) {
26
27 gdk_draw_pixmap(widget->window,
28 widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
29 panel->pixmap, ev->area.x, ev->area.y, ev->area.x, ev->area.y,
30 ev->area.width, ev->area.height);
31 return FALSE;
32 }
33
34
35 static void
update_plugin()36 update_plugin() {
37
38 static gint x_scroll, w;
39
40 if (w == 0)
41 w = gkrellm_chart_width();
42 x_scroll = (x_scroll + 1) % (2 * w);
43
44 // dont do it too much...
45 if ((GK.timer_ticks % 10) != 0) return;
46
47 info = estimate_MHz(1);
48
49 decal_text1->x_off =
50 (w - gdk_string_width(decal_text1->text_style.font, info)) / 2;
51 if (decal_text1->x_off < 0)
52 decal_text1->x_off = 0;
53
54 gkrellm_draw_decal_text(panel, decal_text1, info, w - x_scroll);
55 gkrellm_draw_panel_layers(panel);
56
57 // malloc'd it from estimate_MHz();
58 free(info);
59 }
60
61
62 static void
create_plugin(GtkWidget * vbox,gint first_create)63 create_plugin(GtkWidget *vbox, gint first_create) {
64
65 GkrellmStyle *style;
66 GkrellmTextstyle *ts, *ts_alt;
67
68 if (first_create)
69 panel = gkrellm_panel_new0();
70
71 style = gkrellm_meter_style(style_id);
72
73 ts = gkrellm_meter_textstyle(style_id);
74 ts_alt = gkrellm_meter_alt_textstyle(style_id);
75
76 decal_text1 = gkrellm_create_decal_text(panel, "8MHz", ts, style,
77 -1, -1, -1);
78
79 gkrellm_panel_configure(panel, NULL, style);
80 gkrellm_panel_create(vbox, monitor, panel);
81
82 if (first_create)
83 g_signal_connect(G_OBJECT (panel->drawing_area), "expose_event",
84 G_CALLBACK (panel_expose_event), NULL);
85 }
86
87
88 static GkrellmMonitor plugin_mon = {
89
90 CONFIG_NAME, /* Name, for config tab. */
91 0, /* Id, 0 if a plugin */
92 create_plugin, /* The create function */
93 update_plugin, /* The update function */
94 NULL, /* The config tab create function */
95 NULL, /* Apply the config function */
96
97 NULL, /* Save user config */
98 NULL, /* Load user config */
99 NULL, /* config keyword */
100
101 NULL, /* Undefined 2 */
102 NULL, /* Undefined 1 */
103 NULL, /* private */
104
105 MON_INSERT_AFTER|MON_CPU, /* Insert plugin before this monitor */
106
107 NULL, /* Handle if a plugin, filled in by GKrellM */
108 NULL /* path if a plugin, filled in by GKrellM */
109 };
110
111
112 GkrellmMonitor *
gkrellm_init_plugin()113 gkrellm_init_plugin() {
114
115 style_id = gkrellm_add_meter_style(&plugin_mon, STYLE_NAME);
116 monitor = &plugin_mon;
117 return &plugin_mon;
118 }
119