File: | rc/sensors.c |
Location: | line 370, column 3 |
Description: | Value stored to 's' is never read |
1 | /* GKrellM |
2 | | Copyright (C) 1999-2010 Bill Wilson |
3 | | |
4 | | Author: Bill Wilson billw@gkrellm.net |
5 | | Latest versions might be found at: http://gkrellm.net |
6 | | |
7 | | |
8 | | GKrellM is free software: you can redistribute it and/or modify it |
9 | | under the terms of the GNU General Public License as published by |
10 | | the Free Software Foundation, either version 3 of the License, or |
11 | | (at your option) any later version. |
12 | | |
13 | | GKrellM is distributed in the hope that it will be useful, but WITHOUT |
14 | | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
15 | | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public |
16 | | License for more details. |
17 | | |
18 | | You should have received a copy of the GNU General Public License |
19 | | along with this program. If not, see http://www.gnu.org/licenses/ |
20 | | |
21 | | |
22 | | Additional permission under GNU GPL version 3 section 7 |
23 | | |
24 | | If you modify this program, or any covered work, by linking or |
25 | | combining it with the OpenSSL project's OpenSSL library (or a |
26 | | modified version of that library), containing parts covered by |
27 | | the terms of the OpenSSL or SSLeay licenses, you are granted |
28 | | additional permission to convey the resulting work. |
29 | | Corresponding Source for a non-source form of such a combination |
30 | | shall include the source code for the parts of OpenSSL used as well |
31 | | as that of the covered work. |
32 | */ |
33 | |
34 | #include "gkrellm.h" |
35 | #include "gkrellm-private.h" |
36 | #include "gkrellm-sysdeps.h" |
37 | |
38 | /* Useful info: |
39 | | http://mbm.livewiredev.com/ |
40 | | Look up boards here for sensor chip and temperature sensor type |
41 | | so sensor[1,2,3] can be set correctly in sensors.conf. |
42 | */ |
43 | |
44 | /* On Linux, the sensor id_name includes the parent chip directory, so |
45 | | "lm78/temp" will be a id_name, and not just "temp". This is to |
46 | | allow unique identification in case of multiple "temp" files. |
47 | | ie, more than 1 chip directory, each with a "temp" file. |
48 | */ |
49 | |
50 | typedef struct _sensor |
51 | { |
52 | gchar *name; /* cpuX, mb, Vx name mapped to this sensor */ |
53 | gchar *name_locale; /* gdk_draw compat */ |
54 | gchar *default_label; /* Only voltages have default labels */ |
55 | gchar *path; /* Pathname to sensor data or device file */ |
56 | gchar *id_name; /* Unique sensor identifier for config */ |
57 | gint type; |
58 | |
59 | gint id; |
60 | gint iodev; |
61 | gint inter; |
62 | |
63 | gint enabled; |
64 | gint group; |
65 | gint location; /* default, Proc panel, or cpu panel */ |
66 | gfloat factor, /* Scale sensor reading */ |
67 | offset; /* Add to sensor reading */ |
68 | gfloat default_factor, |
69 | default_offset; |
70 | gchar *vref_name; |
71 | struct _sensor |
72 | *vref; /* A neg volt may be function of a ref volt */ |
73 | |
74 | gboolean has_config; |
75 | |
76 | gfloat value, |
77 | raw_value; |
78 | gboolean value_valid; |
79 | |
80 | GkrellmAlert *alert; |
81 | void (*cb_alert)(); |
82 | gpointer cb_alert_data; |
83 | gpointer smon; |
84 | } |
85 | Sensor; |
86 | |
87 | |
88 | static GList *sensor_list = NULL((void*)0); |
89 | |
90 | static GList *temp_order_list, /* For ordering from the config. */ |
91 | *fan_order_list, |
92 | *volt_order_list; |
93 | |
94 | static gboolean using_new_config, |
95 | need_disk_temperature_update; |
96 | |
97 | static gboolean (*get_temperature)(gchar *name, gint id, |
98 | gint iodev, gint inter, gfloat *t); |
99 | static gboolean (*get_fan)(gchar *name, gint id, |
100 | gint iodev, gint inter, gfloat *f); |
101 | static gboolean (*get_voltage)(gchar *name, gint id, |
102 | gint iodev, gint inter, gfloat *v); |
103 | |
104 | static void read_sensors_config(void); |
105 | static gboolean (*config_migrate)(gchar *current_name, gchar *config_name, |
106 | gint current, gint config); |
107 | |
108 | static gint sensor_config_version; |
109 | static gint sensor_current_sysdep_private; |
110 | static gint sensor_config_sysdep_private; |
111 | |
112 | void |
113 | gkrellm_sensors_client_divert(gboolean (*get_temp_func)(), |
114 | gboolean (*get_fan_func)(), gboolean (*get_volt_func)()) |
115 | { |
116 | get_temperature = get_temp_func; |
117 | get_fan = get_fan_func; |
118 | get_voltage = get_volt_func; |
119 | } |
120 | |
121 | void |
122 | gkrellm_sensors_config_migrate_connect(gboolean (*migrate_func)(), |
123 | gint sysdep_private) |
124 | { |
125 | config_migrate = migrate_func; |
126 | sensor_current_sysdep_private = sysdep_private; |
127 | } |
128 | |
129 | static gboolean |
130 | setup_sensor_interface(void) |
131 | { |
132 | if (!get_temperature && !_GK.client_mode && gkrellm_sys_sensors_init()) |
133 | { |
134 | get_temperature = gkrellm_sys_sensors_get_temperature; |
135 | get_fan = gkrellm_sys_sensors_get_fan; |
136 | get_voltage = gkrellm_sys_sensors_get_voltage; |
137 | } |
138 | return get_temperature ? TRUE(!(0)) : FALSE(0); |
139 | } |
140 | |
141 | void |
142 | gkrellm_sensors_set_group(gpointer sr, gint group) |
143 | { |
144 | Sensor *sensor = (Sensor *) sr; |
145 | |
146 | if (sensor) |
147 | sensor->group = group; |
148 | } |
149 | |
150 | gpointer |
151 | gkrellm_sensors_add_sensor(gint type, gchar *sensor_path, gchar *id_name, |
152 | gint id, gint iodev, gint inter, |
153 | gfloat factor, gfloat offset, gchar *vref, gchar *default_label) |
154 | { |
155 | Sensor *sensor; |
156 | gchar *r; |
157 | |
158 | if (!id_name || !*id_name || type < 0 || type > 2) |
159 | return NULL((void*)0); |
160 | |
161 | sensor = g_new0(Sensor, 1)(Sensor *) (__extension__ ({ gsize __n = (gsize) (1); gsize __s = sizeof (Sensor); gpointer __p; if (__s == 1) __p = g_malloc0 (__n); else if (__builtin_constant_p (__n) && (__s == 0 || __n <= (9223372036854775807L *2UL+1UL) / __s)) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n (__n, __s); __p ; })); |
162 | sensor->id_name = g_strdup(id_name); |
163 | |
164 | if (sensor_path) |
165 | sensor->path = g_strdup(sensor_path); |
166 | else |
167 | sensor->path = g_strdup(id_name); |
168 | if (!default_label) |
169 | { |
170 | r = strrchr(id_name, '/'); |
171 | default_label = r ? r+1 : id_name; |
172 | } |
173 | gkrellm_locale_dup_string(&sensor->name, default_label, |
174 | &sensor->name_locale); |
175 | sensor->default_label = g_strdup(default_label); |
176 | |
177 | sensor->default_factor = factor; |
178 | sensor->factor |
179 | = (sensor->default_factor != 0.0 ? sensor->default_factor : 1.0); |
180 | sensor->default_offset = sensor->offset = offset; |
181 | sensor->type = type; |
182 | sensor->id = id; |
183 | sensor->iodev = iodev; |
184 | sensor->inter = inter; |
185 | if (type == SENSOR_VOLTAGE2 && vref) |
186 | sensor->vref_name = g_strdup(vref); |
187 | sensor_list = g_list_append(sensor_list, sensor); |
188 | return (gpointer) sensor; |
189 | } |
190 | |
191 | /* ======================================================================== */ |
192 | static gboolean use_threads, |
193 | thread_data_valid, |
194 | units_fahrenheit, |
195 | show_units = TRUE(!(0)); |
196 | |
197 | static gboolean thread_busy; |
198 | |
199 | static gpointer |
200 | read_sensors_thread(void *data) |
201 | { |
202 | GList *list; |
203 | Sensor *sensor; |
204 | |
205 | for (list = sensor_list; list; list = list->next) |
206 | { |
207 | sensor = (Sensor *) list->data; |
208 | if (!sensor->enabled) |
209 | continue; |
210 | if (sensor->type == SENSOR_TEMPERATURE0 && get_temperature) |
211 | (*get_temperature)(sensor->path, sensor->id, |
212 | sensor->iodev, sensor->inter, &sensor->raw_value); |
213 | if (sensor->type == SENSOR_FAN1 && get_fan) |
214 | (*get_fan)(sensor->path, sensor->id, |
215 | sensor->iodev, sensor->inter, &sensor->raw_value); |
216 | if (sensor->type == SENSOR_VOLTAGE2 && get_voltage) |
217 | (*get_voltage)(sensor->path, sensor->id, |
218 | sensor->iodev, sensor->inter, &sensor->raw_value); |
219 | } |
220 | thread_busy = FALSE(0); |
221 | return NULL((void*)0); |
222 | } |
223 | |
224 | static void |
225 | run_sensors_thread(void) |
226 | { |
227 | if (thread_busy) |
228 | return; |
229 | thread_busy = TRUE(!(0)); |
230 | g_thread_new("read_sensors", read_sensors_thread, NULL((void*)0)); |
231 | } |
232 | |
233 | /* Sort so that sensors are ordered: temp, fan, voltage. |
234 | */ |
235 | static gint |
236 | strcmp_sensor_path(Sensor *s1, Sensor *s2) |
237 | { |
238 | if (s1->type == SENSOR_TEMPERATURE0 && s2->type != SENSOR_TEMPERATURE0) |
239 | return -1; |
240 | if (s1->type != SENSOR_TEMPERATURE0 && s2->type == SENSOR_TEMPERATURE0) |
241 | return 1; |
242 | |
243 | if (s1->type == SENSOR_FAN1 && s2->type != SENSOR_FAN1) |
244 | return -1; |
245 | if (s1->type != SENSOR_FAN1 && s2->type == SENSOR_FAN1) |
246 | return 1; |
247 | |
248 | return strcmp(s1->id_name, s2->id_name)__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (s1->id_name) && __builtin_constant_p (s2->id_name ) && (__s1_len = strlen (s1->id_name), __s2_len = strlen (s2->id_name), (!((size_t)(const void *)((s1->id_name) + 1) - (size_t)(const void *)(s1->id_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((s2->id_name ) + 1) - (size_t)(const void *)(s2->id_name) == 1) || __s2_len >= 4)) ? __builtin_strcmp (s1->id_name, s2->id_name ) : (__builtin_constant_p (s1->id_name) && ((size_t )(const void *)((s1->id_name) + 1) - (size_t)(const void * )(s1->id_name) == 1) && (__s1_len = strlen (s1-> id_name), __s1_len < 4) ? (__builtin_constant_p (s2->id_name ) && ((size_t)(const void *)((s2->id_name) + 1) - ( size_t)(const void *)(s2->id_name) == 1) ? __builtin_strcmp (s1->id_name, s2->id_name) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (s2-> id_name); int __result = (((const unsigned char *) (const char *) (s1->id_name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (s1->id_name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (s1->id_name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (s1->id_name))[3] - __s2[3]); } } __result ; }))) : (__builtin_constant_p (s2->id_name) && (( size_t)(const void *)((s2->id_name) + 1) - (size_t)(const void *)(s2->id_name) == 1) && (__s2_len = strlen (s2-> id_name), __s2_len < 4) ? (__builtin_constant_p (s1->id_name ) && ((size_t)(const void *)((s1->id_name) + 1) - ( size_t)(const void *)(s1->id_name) == 1) ? __builtin_strcmp (s1->id_name, s2->id_name) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (s1->id_name); int __result = (((const unsigned char *) ( const char *) (s2->id_name))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (s2->id_name))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (s2->id_name))[2] - __s2[2]); if ( __s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (s2->id_name))[3] - __s2[ 3]); } } __result; })))) : __builtin_strcmp (s1->id_name, s2 ->id_name)))); }); |
249 | } |
250 | |
251 | static void |
252 | append_sensor_to_order_list(Sensor *sr) |
253 | { |
254 | if (sr->type == SENSOR_TEMPERATURE0) |
255 | temp_order_list = g_list_append(temp_order_list, sr); |
256 | else if (sr->type == SENSOR_FAN1) |
257 | fan_order_list = g_list_append(fan_order_list, sr); |
258 | else if (sr->type == SENSOR_VOLTAGE2) |
259 | volt_order_list = g_list_append(volt_order_list, sr); |
260 | } |
261 | |
262 | |
263 | /* This is called as sensors are read from the config and I will want to |
264 | | re-order the sensors_list to reflect the config order. Re-ordering is |
265 | | done by appending found sensors to type specific lists and later the |
266 | | sensors_list will be rebuilt from the ordered type lists. If the |
267 | | id_name is found in the sensor_list, assign the label to it. |
268 | */ |
269 | static Sensor * |
270 | map_sensor_label(gchar *label, gchar *name) |
271 | { |
272 | GList *list; |
273 | Sensor *sr; |
274 | |
275 | for (list = sensor_list; list; list = list->next) |
276 | { |
277 | sr = (Sensor *) list->data; |
278 | if ( !sr->has_config |
279 | && ( !strcmp(sr->id_name, name)__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (sr->id_name) && __builtin_constant_p (name) && (__s1_len = strlen (sr->id_name), __s2_len = strlen (name ), (!((size_t)(const void *)((sr->id_name) + 1) - (size_t) (const void *)(sr->id_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((name) + 1) - (size_t)(const void * )(name) == 1) || __s2_len >= 4)) ? __builtin_strcmp (sr-> id_name, name) : (__builtin_constant_p (sr->id_name) && ((size_t)(const void *)((sr->id_name) + 1) - (size_t)(const void *)(sr->id_name) == 1) && (__s1_len = strlen ( sr->id_name), __s1_len < 4) ? (__builtin_constant_p (name ) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) ? __builtin_strcmp (sr->id_name, name ) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (name); int __result = (((const unsigned char *) (const char *) (sr->id_name))[0] - __s2[0]); if ( __s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (sr->id_name))[1] - __s2[ 1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (sr->id_name)) [2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (sr-> id_name))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t )(const void *)(name) == 1) && (__s2_len = strlen (name ), __s2_len < 4) ? (__builtin_constant_p (sr->id_name) && ((size_t)(const void *)((sr->id_name) + 1) - (size_t)(const void *)(sr->id_name) == 1) ? __builtin_strcmp (sr->id_name , name) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (sr->id_name); int __result = (((const unsigned char *) (const char *) (name))[0] - __s2 [0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[1] - __s2 [1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[2] - __s2 [2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (name))[3] - __s2[3 ]); } } __result; })))) : __builtin_strcmp (sr->id_name, name )))); }) |
280 | || ( config_migrate |
281 | && (*config_migrate)(sr->id_name, name, |
282 | sensor_current_sysdep_private, |
283 | sensor_config_sysdep_private) |
284 | ) |
285 | ) |
286 | ) |
287 | { |
288 | gkrellm_locale_dup_string(&sr->name, label, &sr->name_locale); |
289 | append_sensor_to_order_list(sr); |
290 | sr->has_config = TRUE(!(0)); |
291 | return sr; |
292 | } |
293 | } |
294 | return NULL((void*)0); |
295 | } |
296 | |
297 | gboolean |
298 | gkrellm_sensors_available(void) |
299 | { |
300 | return (sensor_list || _GK.demo) ? TRUE(!(0)) : FALSE(0); |
301 | } |
302 | |
303 | /* The cpu and proc monitors both need a couple of sensor decals |
304 | | created on their panels. The left one will only display fan speeds |
305 | | while the right one will display both fan and temps depending on modes. |
306 | */ |
307 | void |
308 | gkrellm_sensors_create_decals(GkrellmPanel *p, gint style_id, |
309 | GkrellmDecal **dsensor, GkrellmDecal **dfan) |
310 | { |
311 | GkrellmStyle *style; |
312 | GkrellmMargin *m; |
313 | GkrellmTextstyle *ts; |
314 | GkrellmDecal *ds = NULL((void*)0), |
315 | *df = NULL((void*)0); |
316 | gint w, w_avail; |
317 | |
318 | if (sensor_list || _GK.demo) |
319 | { |
320 | style = gkrellm_panel_style(style_id); |
321 | m = gkrellm_get_style_margins(style); |
322 | ts = gkrellm_panel_alt_textstyle(style_id); |
323 | w_avail = gkrellm_chart_width() - m->left - m->right; |
324 | |
325 | df = gkrellm_create_decal_text(p, "8888", ts, style, -1, -1, 0); |
326 | |
327 | /* Sensor decal (fan and/or temp) carves out space remaining to right. |
328 | | Try to get enough for .1 deg resolution, otherwise what is left. |
329 | */ |
330 | w = gkrellm_gdk_string_width(ts->font, "188.8F") + ts->effect; |
331 | if (w > w_avail - df->w - 3) |
332 | w = gkrellm_gdk_string_width(ts->font, "88.8C") + ts->effect; |
333 | |
334 | ds = gkrellm_create_decal_text(p, "8.C", ts, style, -1, -1, w); |
335 | ds->x = w_avail + m->left - w; |
336 | df->x = m->left; |
337 | } |
338 | *dsensor = ds; |
339 | *dfan = df; |
340 | } |
341 | |
342 | void |
343 | gkrellm_sensor_draw_fan_decal(GkrellmPanel *p, GkrellmDecal *d, gfloat f) |
344 | { |
345 | gchar buf[8]; |
346 | gint w; |
347 | |
348 | if (!p || !d) |
349 | return; |
350 | snprintf(buf, sizeof(buf), "%.0f", f); |
351 | w = gkrellm_gdk_string_width(d->text_style.font, buf) |
352 | + d->text_style.effect; |
353 | d->x_off = d->w - w; |
354 | if (d->x_off < 0) |
355 | d->x_off = 0; |
356 | gkrellm_draw_decal_text(p, d, buf, 0); |
357 | } |
358 | |
359 | void |
360 | gkrellm_sensor_draw_temperature_decal(GkrellmPanel *p, GkrellmDecal *d, |
361 | gfloat t, gchar units) |
362 | { |
363 | gchar *s, buf[8]; |
364 | gint w; |
365 | |
366 | if (!p || !d) |
367 | return; |
368 | snprintf(buf, sizeof(buf), "%.1f%c", t, units); |
369 | if ((s = strchr(buf, '.')(__extension__ (__builtin_constant_p ('.') && !__builtin_constant_p (buf) && ('.') == '\0' ? (char *) __rawmemchr (buf, '.' ) : __builtin_strchr (buf, '.')))) == NULL((void*)0)) |
370 | s = strchr(buf, ',')(__extension__ (__builtin_constant_p (',') && !__builtin_constant_p (buf) && (',') == '\0' ? (char *) __rawmemchr (buf, ',' ) : __builtin_strchr (buf, ','))); /* Locale may use commas */ |
Value stored to 's' is never read | |
371 | w = gkrellm_gdk_string_width(d->text_style.font, buf) |
372 | + d->text_style.effect; |
373 | if (w > d->w + 1) |
374 | { |
375 | snprintf(buf, sizeof(buf), "%.0f%c", t, units); |
376 | w = gkrellm_gdk_string_width(d->text_style.font, buf) |
377 | + d->text_style.effect; |
378 | } |
379 | |
380 | d->x_off = d->w - w; |
381 | if (d->x_off < 0) |
382 | d->x_off = 0; |
383 | gkrellm_draw_decal_text(p, d, buf, 0 /* no longer used */); |
384 | } |
385 | |
386 | static Sensor * |
387 | lookup_sensor_from_id_name(gchar *name) |
388 | { |
389 | GList *list; |
390 | Sensor *s; |
391 | |
392 | if (!name) |
393 | return NULL((void*)0); |
394 | for (list = sensor_list; list; list = list->next) |
395 | { |
396 | s = (Sensor *) list->data; |
397 | if ( !strcmp(s->id_name, name)__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (s->id_name) && __builtin_constant_p (name) && (__s1_len = strlen (s->id_name), __s2_len = strlen (name) , (!((size_t)(const void *)((s->id_name) + 1) - (size_t)(const void *)(s->id_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((name) + 1) - (size_t)(const void * )(name) == 1) || __s2_len >= 4)) ? __builtin_strcmp (s-> id_name, name) : (__builtin_constant_p (s->id_name) && ((size_t)(const void *)((s->id_name) + 1) - (size_t)(const void *)(s->id_name) == 1) && (__s1_len = strlen ( s->id_name), __s1_len < 4) ? (__builtin_constant_p (name ) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) ? __builtin_strcmp (s->id_name, name) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (name); int __result = (((const unsigned char *) (const char *) (s->id_name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (s->id_name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (s->id_name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (s->id_name))[3] - __s2[3]); } } __result ; }))) : (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) && (__s2_len = strlen (name), __s2_len < 4) ? (__builtin_constant_p (s->id_name) && ((size_t)(const void *)((s->id_name ) + 1) - (size_t)(const void *)(s->id_name) == 1) ? __builtin_strcmp (s->id_name, name) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (s->id_name ); int __result = (((const unsigned char *) (const char *) (name ))[0] - __s2[0]); if (__s2_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (name ))[1] - __s2[1]); if (__s2_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (name ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (name)) [3] - __s2[3]); } } __result; })))) : __builtin_strcmp (s-> id_name, name)))); }) |
398 | || ( config_migrate |
399 | && (*config_migrate)(s->id_name, name, |
400 | sensor_current_sysdep_private, |
401 | sensor_config_sysdep_private) |
402 | ) |
403 | ) |
404 | return s; |
405 | } |
406 | return NULL((void*)0); |
407 | } |
408 | |
409 | /* Given a in0, in1, ... name as a reference to use for a sensor, |
410 | | find the sensor with that name for the same chip as sr. |
411 | */ |
412 | static Sensor * |
413 | lookup_vref(Sensor *sr, gchar *name) |
414 | { |
415 | GList *list; |
416 | Sensor *sv; |
417 | gchar *s, buf[128]; |
418 | |
419 | snprintf(buf, 96, "%s", sr->id_name); |
420 | s = strrchr(buf, '/'); |
421 | if (s) |
422 | ++s; |
423 | else |
424 | s = buf; |
425 | snprintf(s, 31, "%s", name); |
426 | for (list = sensor_list; list; list = list->next) |
427 | { |
428 | sv = (Sensor *) list->data; |
429 | if ( sv->type == SENSOR_VOLTAGE2 |
430 | && !strcmp(sv->id_name, buf)__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (sv->id_name) && __builtin_constant_p (buf) && (__s1_len = strlen (sv->id_name), __s2_len = strlen (buf) , (!((size_t)(const void *)((sv->id_name) + 1) - (size_t)( const void *)(sv->id_name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((buf) + 1) - (size_t)(const void * )(buf) == 1) || __s2_len >= 4)) ? __builtin_strcmp (sv-> id_name, buf) : (__builtin_constant_p (sv->id_name) && ((size_t)(const void *)((sv->id_name) + 1) - (size_t)(const void *)(sv->id_name) == 1) && (__s1_len = strlen ( sv->id_name), __s1_len < 4) ? (__builtin_constant_p (buf ) && ((size_t)(const void *)((buf) + 1) - (size_t)(const void *)(buf) == 1) ? __builtin_strcmp (sv->id_name, buf) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (buf); int __result = (((const unsigned char *) (const char *) (sv->id_name))[0] - __s2[0]); if ( __s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (sv->id_name))[1] - __s2[ 1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (sv->id_name)) [2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (sv-> id_name))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p (buf) && ((size_t)(const void *)((buf) + 1) - (size_t )(const void *)(buf) == 1) && (__s2_len = strlen (buf ), __s2_len < 4) ? (__builtin_constant_p (sv->id_name) && ((size_t)(const void *)((sv->id_name) + 1) - (size_t)(const void *)(sv->id_name) == 1) ? __builtin_strcmp (sv->id_name , buf) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (sv->id_name); int __result = (((const unsigned char *) (const char *) (buf))[0] - __s2[ 0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[1] - __s2[ 1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (buf))[2] - __s2[ 2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (buf))[3] - __s2[3] ); } } __result; })))) : __builtin_strcmp (sv->id_name, buf )))); }) |
431 | ) |
432 | return sv; |
433 | } |
434 | return NULL((void*)0); |
435 | } |
436 | |
437 | static void |
438 | cb_command_process(GkrellmAlert *alert, gchar *src, gchar *buf, gint size, |
439 | Sensor *sensor) |
440 | { |
441 | gchar c, *s, *fmt; |
442 | gint len; |
443 | |
444 | if (!buf || size < 1) |
445 | return; |
446 | --size; |
447 | *buf = '\0'; |
448 | if (!src) |
449 | return; |
450 | for (s = src; *s != '\0' && size > 0; ++s) |
451 | { |
452 | len = 1; |
453 | if (*s == '$' && *(s + 1) != '\0') |
454 | { |
455 | if ((c = *(s + 1)) == 'H') |
456 | len = snprintf(buf, size, "%s", gkrellm_sys_get_host_name()); |
457 | else if (c == 's') |
458 | { |
459 | if (sensor->type == SENSOR_FAN1) |
460 | fmt = "%.0f"; |
461 | else if (sensor->type == SENSOR_TEMPERATURE0) |
462 | fmt = "%.1f"; |
463 | else /* SENSOR_VOLTAGE */ |
464 | fmt = "%.2f"; |
465 | len = snprintf(buf, size, fmt, sensor->value); |
466 | } |
467 | else if (c == 'l' || c == 'L') |
468 | len = snprintf(buf, size, "%s", sensor->name_locale); |
469 | ++s; |
470 | } |
471 | else |
472 | *buf = *s; |
473 | size -= len; |
474 | buf += len; |
475 | } |
476 | *buf = '\0'; |
477 | } |
478 | |
479 | GkrellmAlert * |
480 | gkrellm_sensor_alert(gpointer sr) |
481 | { |
482 | if (!sr) |
483 | return NULL((void*)0); |
484 | return ((Sensor *) sr)->alert; |
485 | } |
486 | |
487 | void |
488 | gkrellm_sensor_alert_connect(gpointer sr, void (*cb_func)(), gpointer data) |
489 | { |
490 | Sensor *sensor = (Sensor *) sr; |
491 | |
492 | if (!sensor) |
493 | return; |
494 | sensor->cb_alert = cb_func; |
495 | sensor->cb_alert_data = data; |
496 | gkrellm_alert_trigger_connect(sensor->alert, cb_func, data); |
497 | gkrellm_alert_command_process_connect(sensor->alert, |
498 | cb_command_process, sensor); |
499 | gkrellm_reset_alert_soft(sensor->alert); |
500 | } |
501 | |
502 | static gboolean |
503 | sensor_read_temperature(Sensor *sensor, gfloat *temp, gchar *units) |
504 | { |
505 | gfloat t = 0; |
506 | gint found_temp = FALSE(0); |
507 | |
508 | if (sensor && get_temperature) |
509 | { |
510 | found_temp = thread_data_valid ? TRUE(!(0)) |
511 | : (*get_temperature)(sensor->path, sensor->id, |
512 | sensor->iodev, sensor->inter, &sensor->raw_value); |
513 | sensor->value = sensor->raw_value * sensor->factor + sensor->offset; |
514 | if (units_fahrenheit) |
515 | sensor->value = 1.8 * sensor->value + 32.0; |
516 | t = sensor->value; |
517 | } |
518 | if (! found_temp && _GK.demo) |
519 | { |
520 | t = 90.0 + (gfloat)(rand() & 0xf); |
521 | found_temp = TRUE(!(0)); |
522 | } |
523 | if (temp) |
524 | *temp = t; |
525 | if (units) |
526 | { |
527 | if (show_units) |
528 | *units = units_fahrenheit ? 'F':'C'; |
529 | else |
530 | *units = '\0'; |
531 | } |
532 | if (sensor) |
533 | gkrellm_debug(DEBUG_SENSORS0x80, "sensor_temp: %s %s t=%.2f\n", |
534 | sensor->name_locale, sensor->path, sensor->value); |
535 | if (found_temp && sensor) |
536 | gkrellm_check_alert(sensor->alert, sensor->value); |
537 | return found_temp; |
538 | } |
539 | |
540 | gboolean |
541 | gkrellm_sensor_read_temperature(gpointer sr, gfloat *temp, gchar *units) |
542 | { |
543 | return sensor_read_temperature((Sensor *) sr, temp, units); |
544 | } |
545 | |
546 | |
547 | static gboolean |
548 | sensor_read_fan(Sensor *sensor, gfloat *fan) |
549 | { |
550 | gfloat f = 0; |
551 | gint found_fan = FALSE(0); |
552 | |
553 | if (sensor && get_fan) |
554 | { |
555 | found_fan = thread_data_valid ? TRUE(!(0)) |
556 | : (*get_fan)(sensor->path, sensor->id, |
557 | sensor->iodev, sensor->inter, &sensor->raw_value); |
558 | sensor->value = sensor->raw_value * sensor->factor; |
559 | f = sensor->value; |
560 | } |
561 | if (! found_fan && _GK.demo) |
562 | { |
563 | f = 4980 + (gfloat)(rand() & 0x3f); |
564 | found_fan = TRUE(!(0)); |
565 | } |
566 | if (fan) |
567 | *fan = f; |
568 | if (sensor) |
569 | gkrellm_debug(DEBUG_SENSORS0x80, "sensor_fan: %s %s rpm=%.0f\n", |
570 | sensor->name_locale, sensor->path, sensor->value); |
571 | if (found_fan && sensor) |
572 | gkrellm_check_alert(sensor->alert, sensor->value); |
573 | return found_fan; |
574 | } |
575 | |
576 | gboolean |
577 | gkrellm_sensor_read_fan(gpointer sr, gfloat *fan) |
578 | { |
579 | return sensor_read_fan((Sensor *) sr, fan); |
580 | } |
581 | |
582 | |
583 | static gboolean |
584 | sensor_read_voltage(Sensor *sensor, gfloat *voltage) |
585 | { |
586 | gfloat v = 0; |
587 | gfloat offset; |
588 | gboolean found_voltage = FALSE(0); |
589 | |
590 | if (sensor && get_voltage) |
591 | { |
592 | found_voltage = thread_data_valid ? TRUE(!(0)) |
593 | : (*get_voltage)(sensor->path, sensor->id, |
594 | sensor->iodev, sensor->inter, &sensor->raw_value); |
595 | offset = sensor->offset; |
596 | if (sensor->vref) /* A negative voltage is level shifted by vref */ |
597 | offset *= sensor->vref->value; |
598 | sensor->value = sensor->raw_value * sensor->factor + offset; |
599 | v = sensor->value; |
600 | } |
601 | if (! found_voltage && _GK.demo) |
602 | { |
603 | v = 2.9 + (gfloat)(rand() & 0x7) * 0.1; |
604 | found_voltage = TRUE(!(0)); |
605 | } |
606 | if (voltage) |
607 | *voltage = v; |
608 | if (sensor) |
609 | gkrellm_debug(DEBUG_SENSORS0x80, "sensor_voltage: %s %s v=%.2f\n", |
610 | sensor->name_locale, sensor->path, sensor->value); |
611 | if (found_voltage && sensor) |
612 | gkrellm_check_alert(sensor->alert, sensor->value); |
613 | return found_voltage; |
614 | } |
615 | |
616 | gboolean |
617 | gkrellm_sensor_read_voltage(gpointer sr, gfloat *voltage) |
618 | { |
619 | return sensor_read_voltage((Sensor *) sr, voltage); |
620 | } |
621 | |
622 | /* =================================================================== */ |
623 | /* The sensors monitor */ |
624 | |
625 | static void sensor_reset_optionmenu(Sensor *sensor); |
626 | |
627 | #define SENSOR_STYLE_NAME"sensors" "sensors" |
628 | |
629 | /* Temperature and fan sensors can be located on different panels depending |
630 | | on the sensor group. |
631 | */ |
632 | #define SENSOR_PANEL_LOCATION0 0 |
633 | |
634 | #define PROC_PANEL_LOCATION1 1 /* SENSOR_GROUP_MAINBOARD */ |
635 | #define CPU_PANEL_LOCATION2 2 /* cpu0 if smp */ |
636 | |
637 | #define DISK_PANEL_LOCATION1 1 /* SENSOR_GROUP_DISK */ |
638 | |
639 | |
640 | #define DO_TEMP1 1 |
641 | #define DO_FAN1 1 |
642 | #define DO_VOLT1 1 |
643 | |
644 | typedef struct |
645 | { |
646 | GkrellmPanel **panel; |
647 | GkrellmDecal *name_decal, |
648 | *sensor_decal; |
649 | Sensor *sensor; |
650 | } |
651 | SensorMon; |
652 | |
653 | static GtkWidget |
654 | *temp_vbox, |
655 | *fan_vbox, |
656 | *volt_vbox; |
657 | |
658 | static GList *volt_list, |
659 | *temperature_list, |
660 | *fan_list, |
661 | *disk_temperature_list; |
662 | |
663 | static GkrellmPanel |
664 | *pVolt, |
665 | *pTemp, |
666 | *pFan; |
667 | |
668 | static gint style_id; |
669 | static gint volt_mon_width, |
670 | volt_mon_height, |
671 | volt_name_width, |
672 | volt_bezel_width; |
673 | |
674 | |
675 | /* Display modes */ |
676 | #define DIGITAL_WITH_LABELS0 0 |
677 | #define DIGITAL_NO_LABELS1 1 |
678 | #define N_DISPLAY_MODES2 2 |
679 | |
680 | #define MONITOR_PAD6 6 |
681 | #define NAME_PAD4 4 |
682 | |
683 | GkrellmMonitor *mon_sensors; |
684 | GkrellmMonitor *mon_config_sensors; |
685 | |
686 | static GkrellmPiximage |
687 | *bezel_piximage; |
688 | |
689 | static GkrellmStyle |
690 | *bezel_style; /* Just for the bezel image border */ |
691 | |
692 | static gint display_mode, |
693 | have_negative_volts; |
694 | |
695 | static gint minus_width; /* If will be drawing neg voltages */ |
696 | |
697 | /* If drawing '-' sign, grub a pixel or two to tighten the layout */ |
698 | static gint pixel_grub; |
699 | |
700 | |
701 | /* Avoid writing decimal values into the config to avoid possible |
702 | | locale changing decimal point breakage (decimal point can be '.' or ',') |
703 | */ |
704 | #define SENSOR_FLOAT_FACTOR10000.0 10000.0 |
705 | static gfloat sensor_float_factor = 1.0, |
706 | gkrellm_float_factor = 1.0; |
707 | |
708 | void |
709 | gkrellm_sensor_reset_location(gpointer sr) |
710 | { |
711 | GList *list; |
712 | Sensor *sensor; |
713 | |
714 | for (list = sensor_list; list; list = list->next) |
715 | { |
716 | sensor = (Sensor *) list->data; |
717 | if (sr == sensor) |
718 | { |
719 | sensor->location = SENSOR_PANEL_LOCATION0; |
720 | sensor_reset_optionmenu(sensor); |
721 | break; |
722 | } |
723 | } |
724 | } |
725 | |
726 | |
727 | static void |
728 | sensor_relocation_error(gchar *pname) |
729 | { |
730 | gchar *msg; |
731 | |
732 | msg = g_strdup_printf( |
733 | _("Can't find a %s panel to relocate sensor to.")dcgettext ("gkrellm", "Can't find a %s panel to relocate sensor to." , 5), |
734 | pname ? pname : "?"); |
735 | gkrellm_config_message_dialog(NULL((void*)0), msg); |
736 | g_free(msg); |
737 | } |
738 | |
739 | /* When moving off some other panel, reset that panel. |
740 | */ |
741 | static void |
742 | sensor_reset_location(Sensor *sr) |
743 | { |
744 | if (sr->group == SENSOR_GROUP_MAINBOARD0) |
745 | { |
746 | if (sr->location == PROC_PANEL_LOCATION1) |
747 | gkrellm_proc_set_sensor(NULL((void*)0), sr->type); |
748 | else if (sr->location >= CPU_PANEL_LOCATION2) |
749 | gkrellm_cpu_set_sensor(NULL((void*)0), sr->type, |
750 | sr->location - CPU_PANEL_LOCATION2); |
751 | } |
752 | else if (sr->group == SENSOR_GROUP_DISK1) |
753 | { |
754 | if (sr->location == DISK_PANEL_LOCATION1) |
755 | gkrellm_disk_temperature_remove(sr->id_name); |
756 | } |
757 | } |
758 | |
759 | void |
760 | gkrellm_sensors_interface_remove(gint _interface) |
761 | { |
762 | GList *list; |
763 | Sensor *sensor; |
764 | gboolean removed_one; |
765 | |
766 | do |
767 | { |
768 | removed_one = FALSE(0); |
769 | for (list = sensor_list; list; list = list->next) |
770 | { |
771 | sensor = (Sensor *) list->data; |
772 | if (sensor->inter == _interface) |
773 | { |
774 | sensor_reset_location(sensor); |
775 | g_free(sensor->id_name); |
776 | g_free(sensor->path); |
777 | g_free(sensor->name); |
778 | g_free(sensor->default_label); |
779 | g_free(sensor->vref_name); |
780 | sensor_list = g_list_remove(sensor_list, sensor); |
781 | g_free(sensor); |
782 | removed_one = TRUE(!(0)); |
783 | break; |
784 | } |
785 | } |
786 | } |
787 | while (removed_one); |
788 | } |
789 | |
790 | static void |
791 | add_sensor_monitor(Sensor *sr, GkrellmPanel **p, GList **smon_list) |
792 | { |
793 | SensorMon *smon; |
794 | gfloat t; |
795 | gchar units; |
796 | gboolean set_loc = FALSE(0); |
797 | |
798 | sr->smon = NULL((void*)0); |
799 | if (!sr->enabled) |
800 | return; |
801 | |
802 | if (sr->location != SENSOR_PANEL_LOCATION0) |
803 | { |
804 | if (sr->group == SENSOR_GROUP_MAINBOARD0) |
805 | { |
806 | if (sr->location == PROC_PANEL_LOCATION1) |
807 | set_loc = gkrellm_proc_set_sensor(sr, sr->type); |
808 | else |
809 | set_loc = gkrellm_cpu_set_sensor(sr, sr->type, |
810 | sr->location - CPU_PANEL_LOCATION2); |
811 | } |
812 | else if (sr->group == SENSOR_GROUP_DISK1) |
813 | { |
814 | if (sr->location == DISK_PANEL_LOCATION1) |
815 | { |
816 | gkrellm_freeze_alert(sr->alert); |
817 | sensor_read_temperature(sr, &t, &units); |
818 | gkrellm_thaw_alert(sr->alert); |
819 | set_loc = gkrellm_disk_temperature_display((gpointer) sr, |
820 | sr->id_name, t, units); |
821 | if (set_loc) |
822 | disk_temperature_list = |
823 | g_list_append(disk_temperature_list, sr); |
824 | } |
825 | } |
826 | if (set_loc) |
827 | return; |
828 | sr->location = SENSOR_PANEL_LOCATION0; |
829 | } |
830 | smon = g_new0(SensorMon, 1)(SensorMon *) (__extension__ ({ gsize __n = (gsize) (1); gsize __s = sizeof (SensorMon); gpointer __p; if (__s == 1) __p = g_malloc0 (__n); else if (__builtin_constant_p (__n) && (__s == 0 || __n <= (9223372036854775807L *2UL+1UL) / __s)) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n (__n, __s); __p ; })); |
831 | smon->sensor = sr; |
832 | smon->panel = p; /* Alerts need a GkrellmPanel ** */ |
833 | *smon_list = g_list_append(*smon_list, smon); |
834 | sr->smon = (gpointer) smon; |
835 | } |
836 | |
837 | static void |
838 | make_sensor_monitor_lists(gboolean do_temp, gboolean do_fan, gboolean do_volt) |
839 | { |
840 | GList *list; |
841 | Sensor *sr; |
842 | |
843 | if (do_temp) |
844 | { |
845 | gkrellm_free_glist_and_data(&temperature_list); |
846 | g_list_free(disk_temperature_list); |
847 | disk_temperature_list = NULL((void*)0); |
848 | } |
849 | if (do_fan) |
850 | gkrellm_free_glist_and_data(&fan_list); |
851 | if (do_volt) |
852 | gkrellm_free_glist_and_data(&volt_list); |
853 | |
854 | for (list = sensor_list; list; list = list->next) |
855 | { |
856 | sr = (Sensor *) list->data; |
857 | if (do_temp && sr->type == SENSOR_TEMPERATURE0) |
858 | add_sensor_monitor(sr, &pTemp, &temperature_list); |
859 | if (do_fan && sr->type == SENSOR_FAN1) |
860 | add_sensor_monitor(sr, &pFan, &fan_list); |
861 | if (do_volt && sr->type == SENSOR_VOLTAGE2) |
862 | { |
863 | if (!sr->has_config && sr->vref_name) |
864 | sr->vref = lookup_vref(sr, sr->vref_name); |
865 | add_sensor_monitor(sr, &pVolt, &volt_list); |
866 | } |
867 | } |
868 | } |
869 | |
870 | #include "pixmaps/sensors/bg_volt.xpm" |
871 | |
872 | static void |
873 | cb_alert_trigger(GkrellmAlert *alert, SensorMon *smon) |
874 | { |
875 | GkrellmAlertdecal *ad; |
876 | GkrellmDecal *d; |
877 | |
878 | ad = &alert->ad; |
879 | alert->panel = *smon->panel; |
880 | |
881 | /* Make the GkrellmAlertdecal show up under the sensor decal |
882 | */ |
883 | d = smon->sensor_decal; |
884 | if (d) |
885 | { |
886 | ad->x = d->x - 2; |
887 | ad->y = d->y - 2; |
888 | ad->w = d->w + 3; |
889 | ad->h = d->h + 4; |
890 | gkrellm_render_default_alert_decal(alert); |
891 | } |
892 | } |
893 | |
894 | |
895 | static void |
896 | draw_bezels(GkrellmPanel *p, GList *smon_list, gint w, gint h, gint x_adjust) |
897 | { |
898 | GList *list; |
899 | GkrellmBorder *b = &bezel_style->border; |
900 | SensorMon *smon; |
901 | GkrellmDecal *dv; |
902 | gint x; |
903 | |
904 | if (!bezel_piximage) |
905 | return; |
906 | for (list = smon_list; list; list = list->next) |
907 | { |
908 | smon = (SensorMon *) list->data; |
909 | dv = smon->sensor_decal; |
910 | x = dv->x + x_adjust; |
911 | if (w == 0) |
912 | w = b->left + dv->w + b->right - x_adjust; |
913 | if (h == 0) |
914 | h = b->top + b->bottom + dv->h; |
915 | gkrellm_paste_piximage(bezel_piximage, p->bg_pixmap, |
916 | x - b->left, dv->y - b->top, w, h); |
917 | gkrellm_paste_piximage(bezel_piximage, p->pixmap, |
918 | x - b->left, dv->y - b->top, w, h); |
919 | } |
920 | gdk_draw_drawable(p->bg_text_layer_pixmap, _GK.draw1_GC, p->bg_pixmap, |
921 | 0, 0, 0, 0, p->w, p->h); |
922 | } |
923 | |
924 | |
925 | static gboolean |
926 | any_negative_volts(void) |
927 | { |
928 | GList *list; |
929 | Sensor *s; |
930 | SensorMon *volt; |
931 | gfloat v; |
932 | gboolean tmp, result = FALSE(0); |
933 | |
934 | /* This routine can be called before any volt decals exist, but reading |
935 | | voltages can trigger alerts which expect to find decals. Hence freeze. |
936 | */ |
937 | tmp = thread_data_valid; |
938 | thread_data_valid = FALSE(0); /* Need results immediately */ |
939 | for (list = volt_list; list; list = list->next) |
940 | { |
941 | volt = (SensorMon *) list->data; |
942 | gkrellm_freeze_alert(volt->sensor->alert); |
943 | s = volt->sensor->vref; |
944 | if (s && s->value == 0) |
945 | sensor_read_voltage(s, &v); |
946 | sensor_read_voltage(volt->sensor, &v); |
947 | gkrellm_thaw_alert(volt->sensor->alert); |
948 | if (v < 0.0) |
949 | { |
950 | result = TRUE(!(0)); |
951 | break; |
952 | } |
953 | } |
954 | thread_data_valid = tmp; |
955 | return result; |
956 | } |
957 | |
958 | static void |
959 | make_volt_decals(GkrellmPanel *p, GkrellmStyle *style) |
960 | { |
961 | GList *list; |
962 | GkrellmBorder *b = &bezel_style->border; |
963 | Sensor *sensor; |
964 | SensorMon *volt; |
965 | GkrellmDecal *dv, *dn; |
966 | GkrellmTextstyle *ts_volt, *ts_name; |
967 | gchar *fmt; |
968 | gint w_volt; |
969 | |
970 | ts_name = gkrellm_meter_alt_textstyle(style_id); |
971 | ts_volt = gkrellm_meter_textstyle(style_id); |
972 | |
973 | volt_mon_width = 0; |
974 | volt_mon_height = 0; |
975 | volt_name_width = 0; |
976 | w_volt = 0; |
977 | |
978 | minus_width = 0; |
979 | have_negative_volts = FALSE(0); |
980 | fmt = "8.88"; |
981 | if (any_negative_volts()) |
982 | { |
983 | have_negative_volts = TRUE(!(0)); |
984 | minus_width = 1; |
985 | fmt = "-8.88"; |
986 | } |
987 | |
988 | for (list = volt_list; list; list = list->next) |
989 | { |
990 | volt = (SensorMon *) list->data; |
991 | sensor = volt->sensor; |
992 | if (display_mode == DIGITAL_WITH_LABELS0) |
993 | { |
994 | volt->name_decal = dn = gkrellm_create_decal_text(p, |
995 | volt->sensor->name_locale, ts_name, style, 0, 0, 0); |
996 | if (dn->w > volt_name_width) |
997 | volt_name_width = dn->w; |
998 | } |
999 | dv = gkrellm_create_decal_text(p, fmt, ts_volt, style, 0, 0, 0); |
1000 | volt->sensor_decal = dv; |
1001 | if (minus_width == 1) |
1002 | minus_width = gkrellm_gdk_string_width(dv->text_style.font, "-"); |
1003 | w_volt = dv->w; /* Same for all volt decals */ |
1004 | if (dv->h > volt_mon_height) |
1005 | volt_mon_height = dv->h; |
1006 | |
1007 | sensor->cb_alert = cb_alert_trigger; |
1008 | sensor->cb_alert_data = volt; |
1009 | gkrellm_alert_trigger_connect(sensor->alert, cb_alert_trigger, volt); |
1010 | gkrellm_alert_command_process_connect(sensor->alert, |
1011 | cb_command_process, sensor); |
1012 | gkrellm_reset_alert_soft(sensor->alert); |
1013 | } |
1014 | pixel_grub = minus_width ? 1 : 0; |
1015 | volt_bezel_width = b->left + w_volt + b->right - pixel_grub; |
1016 | volt_mon_height += b->top + b->bottom; |
1017 | |
1018 | /* If name decal I let bezel left border encroach into NAME_PAD space |
1019 | */ |
1020 | if (volt_name_width) |
1021 | volt_mon_width = volt_name_width + NAME_PAD4 + w_volt + b->right; |
1022 | else |
1023 | volt_mon_width = w_volt; /* borders encroach into MONITOR_PAD */ |
1024 | } |
1025 | |
1026 | static void |
1027 | layout_volt_decals(GkrellmPanel *p, GkrellmStyle *style) |
1028 | { |
1029 | GList *list; |
1030 | SensorMon *volt; |
1031 | GkrellmDecal *dv, *dn; |
1032 | GkrellmMargin *m; |
1033 | gint x, y, w, c, n, cols; |
1034 | |
1035 | m = gkrellm_get_style_margins(style); |
1036 | w = gkrellm_chart_width() - m->left - m->right; |
1037 | cols = (w + MONITOR_PAD6) / (volt_mon_width + MONITOR_PAD6); |
1038 | if (cols < 1) |
1039 | cols = 1; |
1040 | n = g_list_length(volt_list); |
1041 | if (cols > n) |
1042 | cols = n;; |
1043 | volt_mon_width = w / cols; /* spread them out */ |
1044 | x = (w - cols * volt_mon_width) / 2 + m->left; |
1045 | |
1046 | gkrellm_get_top_bottom_margins(style, &y, NULL((void*)0)); |
1047 | c = 0; |
1048 | for (list = volt_list; list; list = list->next) |
1049 | { |
1050 | volt = (SensorMon *) list->data; |
1051 | dn = volt->name_decal; |
1052 | dv = volt->sensor_decal; |
1053 | /* Right justify the volt decal in each volt_mon field |
1054 | */ |
1055 | dv->x = x + (c+1) * volt_mon_width - dv->w - bezel_style->border.right; |
1056 | if (cols > 1 && !dn) |
1057 | dv->x -= (volt_mon_width - volt_bezel_width) / 2; |
1058 | dv->y = y + bezel_style->border.top; |
1059 | if (dn) |
1060 | { |
1061 | if (cols == 1) |
1062 | dn->x = m->left; |
1063 | else |
1064 | dn->x = dv->x - volt_name_width - NAME_PAD4; |
1065 | dn->y = y + bezel_style->border.top; |
1066 | if (dn->h < dv->h) |
1067 | dn->y += (dv->h - dn->h + 1) / 2; |
1068 | } |
1069 | if (++c >= cols) |
1070 | { |
1071 | c = 0; |
1072 | y += volt_mon_height; |
1073 | } |
1074 | } |
1075 | } |
1076 | |
1077 | static void |
1078 | update_disk_temperatures(void) |
1079 | { |
1080 | GList *list; |
1081 | Sensor *sr; |
1082 | gfloat t; |
1083 | gchar units; |
1084 | gboolean display_failed = FALSE(0); |
1085 | |
1086 | for (list = disk_temperature_list; list; list = list->next) |
1087 | { |
1088 | sr = (Sensor *) list->data; |
1089 | sensor_read_temperature(sr, &t, &units); |
1090 | if (!gkrellm_disk_temperature_display((gpointer) sr, sr->id_name, |
1091 | t, units)) |
1092 | { |
1093 | /* disk panel was disabled, so put temp back on sensors panel |
1094 | */ |
1095 | display_failed = TRUE(!(0)); |
1096 | sr->location = SENSOR_PANEL_LOCATION0; |
1097 | sensor_reset_optionmenu(sr); |
1098 | } |
1099 | } |
1100 | if (display_failed) |
1101 | gkrellm_sensors_rebuild(TRUE(!(0)), FALSE(0), FALSE(0)); |
1102 | } |
1103 | |
1104 | /* Squeeze name decal text into a smaller font if it would overlap the |
1105 | | sensor decal. With smaller fonts, the y_ink value may be smaller which |
1106 | | would bump the text upward. So adjust decal offset by difference in |
1107 | | y_ink value. (GKrellM text decal heights don't include the y_ink |
1108 | | space). |
1109 | */ |
1110 | static gchar * |
1111 | name_text_fit(Sensor *s, GkrellmDecal *dn, GkrellmDecal *ds) |
1112 | { |
1113 | gchar *string; |
1114 | gint x_limit, w0, w1, y_ink0, y_ink1, h0, h1; |
1115 | |
1116 | x_limit = ds->x; |
1117 | |
1118 | /* Check for '<' in case user is doing his own markup |
1119 | */ |
1120 | if (*(s->name_locale) != '<' && dn->x + dn->w > x_limit) |
1121 | { |
1122 | gkrellm_text_markup_extents(dn->text_style.font, s->name_locale, |
1123 | strlen(s->name_locale), &w0, NULL((void*)0), NULL((void*)0), &y_ink0); |
1124 | string = g_strdup_printf("<small>%s</small>", s->name_locale); |
1125 | gkrellm_text_markup_extents(dn->text_style.font, string, |
1126 | strlen(string), &w1, &h0, NULL((void*)0), &y_ink1); |
1127 | h1 = h0; |
1128 | if (dn->x + w1 > x_limit) |
1129 | { |
1130 | g_free(string); |
1131 | string = g_strdup_printf("<small><small>%s</small></small>", |
1132 | s->name_locale); |
1133 | gkrellm_text_markup_extents(dn->text_style.font, string, |
1134 | strlen(string), &w1, &h1, NULL((void*)0), &y_ink1); |
1135 | } |
1136 | gkrellm_decal_text_set_offset(dn, 0, |
1137 | y_ink0 - y_ink1 + (h0 - h1 + 1) / 2); |
1138 | } |
1139 | else |
1140 | { |
1141 | gkrellm_decal_text_set_offset(dn, 0, 0); |
1142 | string = g_strdup(s->name_locale); |
1143 | } |
1144 | return string; |
1145 | } |
1146 | |
1147 | |
1148 | static void |
1149 | draw_temperatures(gboolean draw_name) |
1150 | { |
1151 | GList *list; |
1152 | SensorMon *smon; |
1153 | Sensor *sensor; |
1154 | gfloat t; |
1155 | gchar *name, units; |
1156 | |
1157 | if (!pTemp) |
1158 | return; |
1159 | for (list = temperature_list; list; list = list->next) |
1160 | { |
1161 | smon = (SensorMon *) list->data; |
1162 | sensor = smon->sensor; |
1163 | |
1164 | if (draw_name && smon->name_decal) |
1165 | { |
1166 | name = name_text_fit(sensor, smon->name_decal, smon->sensor_decal); |
1167 | gkrellm_draw_decal_markup(pTemp, smon->name_decal, name); |
1168 | g_free(name); |
1169 | } |
1170 | if (smon->sensor_decal) |
1171 | { |
1172 | sensor_read_temperature(sensor, &t, &units); |
1173 | gkrellm_sensor_draw_temperature_decal(pTemp, smon->sensor_decal, |
1174 | t, units); |
1175 | } |
1176 | } |
1177 | gkrellm_draw_panel_layers(pTemp); |
1178 | } |
1179 | |
1180 | static void |
1181 | draw_fans(gboolean draw_name) |
1182 | { |
1183 | GList *list; |
1184 | SensorMon *smon; |
1185 | Sensor *sensor; |
1186 | gchar *name; |
1187 | gfloat f; |
1188 | |
1189 | if (!pFan) |
1190 | return; |
1191 | for (list = fan_list; list; list = list->next) |
1192 | { |
1193 | smon = (SensorMon *) list->data; |
1194 | sensor = smon->sensor; |
1195 | |
1196 | if (draw_name && smon->name_decal) |
1197 | { |
1198 | name = name_text_fit(sensor, smon->name_decal, smon->sensor_decal); |
1199 | gkrellm_draw_decal_markup(pFan, smon->name_decal, name); |
1200 | g_free(name); |
1201 | } |
1202 | if (smon->sensor_decal) |
1203 | { |
1204 | sensor_read_fan(sensor, &f); |
1205 | gkrellm_sensor_draw_fan_decal(pFan, smon->sensor_decal, f); |
1206 | } |
1207 | } |
1208 | gkrellm_draw_panel_layers(pFan); |
1209 | } |
1210 | |
1211 | /* If s is NULL, draw 'em all |
1212 | */ |
1213 | static void |
1214 | draw_voltages(Sensor *s, gint do_names) |
1215 | { |
1216 | GList *list; |
1217 | SensorMon *volt; |
1218 | Sensor *sensor; |
1219 | GkrellmDecal *ds, *dn; |
1220 | gchar *name, *fmt, buf[32]; |
1221 | gfloat v; |
1222 | |
1223 | if (!pVolt) |
1224 | return; |
1225 | for (list = volt_list; list; list = list->next) |
1226 | { |
1227 | volt = (SensorMon *) list->data; |
1228 | sensor = volt->sensor; |
1229 | if (s && s != sensor) |
1230 | continue; |
1231 | sensor->value_valid = FALSE(0); /* In case vref monitoring stops */ |
1232 | dn = volt->name_decal; |
1233 | ds = volt->sensor_decal; |
1234 | if (do_names && dn) |
1235 | { |
1236 | name = name_text_fit(sensor, dn, ds); |
1237 | gkrellm_draw_decal_markup(pVolt, dn, name); |
1238 | g_free(name); |
1239 | } |
1240 | if (ds) |
1241 | { |
1242 | if (sensor->vref && !sensor->vref->value_valid) |
1243 | sensor_read_voltage(sensor->vref, NULL((void*)0)); |
1244 | sensor_read_voltage(sensor, &v); |
1245 | sensor->value_valid = TRUE(!(0)); |
1246 | if ((v < 10.0 && v > 0.0) || (v > -10.0 && v < 0.0)) |
1247 | fmt = "%.2f"; |
1248 | else |
1249 | fmt = "%.1f"; |
1250 | snprintf(buf, sizeof(buf), fmt, v); |
1251 | ds->x_off = (v < 0.0) ? 0 : minus_width; |
1252 | gkrellm_draw_decal_text(pVolt, ds, buf, -1); |
1253 | } |
1254 | } |
1255 | gkrellm_draw_panel_layers(pVolt); |
1256 | } |
1257 | |
1258 | static void |
1259 | update_sensors(void) |
1260 | { |
1261 | static gboolean first_time_done; |
1262 | |
1263 | if (!GK.five_second_tick && first_time_done) |
1264 | { |
1265 | if (need_disk_temperature_update) /* delayed until disks created */ |
1266 | update_disk_temperatures(); |
1267 | need_disk_temperature_update = FALSE(0); |
1268 | return; |
1269 | } |
1270 | if (use_threads) |
1271 | { |
1272 | thread_data_valid = TRUE(!(0)); |
1273 | run_sensors_thread(); |
1274 | } |
1275 | draw_temperatures(FALSE(0)); |
1276 | draw_fans(FALSE(0)); |
1277 | draw_voltages(NULL((void*)0), FALSE(0)); |
1278 | update_disk_temperatures(); |
1279 | first_time_done = TRUE(!(0)); |
1280 | } |
1281 | |
1282 | static gint |
1283 | expose_event(GtkWidget *widget, GdkEventExpose *ev, GkrellmPanel *p) |
1284 | { |
1285 | gdk_draw_drawable(widget->window, gkrellm_draw_GC(1), p->pixmap, |
1286 | ev->area.x, ev->area.y, ev->area.x, ev->area.y, |
1287 | ev->area.width, ev->area.height); |
1288 | return FALSE(0); |
1289 | } |
1290 | |
1291 | static gint |
1292 | cb_panel_press(GtkWidget *widget, GdkEventButton *ev, GkrellmPanel *p) |
1293 | { |
1294 | if (ev->button == 3) |
1295 | gkrellm_open_config_window(mon_config_sensors); |
1296 | return FALSE(0); |
1297 | } |
1298 | |
1299 | static GkrellmBorder default_bezel_border = {1,1,1,1}; |
1300 | |
1301 | static void |
1302 | assign_textstyles(GList *smon_list, GkrellmTextstyle **ts_name, GkrellmTextstyle **ts_sensor, |
1303 | gchar *format) |
1304 | { |
1305 | GList *list; |
1306 | GkrellmStyle *style; |
1307 | GkrellmMargin *margin; |
1308 | Sensor *sensor; |
1309 | SensorMon *smon; |
1310 | GkrellmTextstyle *ts, *ts_alt; |
1311 | gint w, w_name, w_sensor; |
1312 | |
1313 | style = gkrellm_meter_style(style_id); |
1314 | margin = gkrellm_get_style_margins(style); |
1315 | ts = gkrellm_copy_textstyle(gkrellm_meter_textstyle(style_id)); |
1316 | ts_alt = gkrellm_copy_textstyle(gkrellm_meter_alt_textstyle(style_id)); |
1317 | w = gkrellm_chart_width() - margin->left - margin->right; |
1318 | w_sensor = gkrellm_gdk_string_width(ts->font, format); |
1319 | w_sensor += bezel_style->border.left + bezel_style->border.right; |
1320 | for (list = smon_list; list; list = list->next) |
1321 | { |
1322 | smon = (SensorMon *)list->data; |
1323 | sensor = smon->sensor; |
1324 | w_name = gkrellm_gdk_string_width(ts_alt->font, sensor->name_locale); |
1325 | if (w_name + w_sensor > w - 2) |
1326 | { |
1327 | ts->font = ts_alt->font; /* downsize the sensor font */ |
1328 | break; |
1329 | } |
1330 | } |
1331 | *ts_name = ts_alt; /* Caller must free these */ |
1332 | *ts_sensor = ts; |
1333 | } |
1334 | |
1335 | static gint |
1336 | adjust_decal_positions(SensorMon *smon) |
1337 | { |
1338 | gint y, d, h_pad; |
1339 | |
1340 | h_pad = bezel_style->border.top + bezel_style->border.bottom; |
1341 | d = smon->sensor_decal->h - smon->name_decal->h; |
1342 | y = smon->sensor_decal->y + smon->sensor_decal->h + h_pad; |
1343 | if (d >= 0) |
1344 | smon->name_decal->y += (d + 1) / 2; |
1345 | else |
1346 | { |
1347 | if (h_pad < -d) |
1348 | y = smon->name_decal->y + smon->name_decal->h; |
1349 | smon->sensor_decal->y += -d / 2; |
1350 | } |
1351 | return y; |
1352 | } |
1353 | |
1354 | static void |
1355 | make_temperature_panel(GtkWidget *vbox, gint first_create) |
1356 | { |
1357 | Sensor *sensor; |
1358 | SensorMon *smon = NULL((void*)0); |
1359 | GkrellmStyle *style; |
1360 | GkrellmMargin *m; |
1361 | GkrellmDecal *d; |
1362 | GList *list; |
1363 | GkrellmTextstyle *ts_sensor, *ts_name; |
1364 | gchar *format; |
1365 | gint y; |
1366 | |
1367 | if (!pTemp) |
1368 | return; |
1369 | style = gkrellm_meter_style(style_id); |
1370 | m = gkrellm_get_style_margins(style); |
1371 | if (show_units) |
1372 | format = units_fahrenheit ? "188.8F" : "88.8C"; |
1373 | else |
1374 | format = units_fahrenheit ? "188.8" : "88.8"; |
1375 | assign_textstyles(temperature_list, &ts_name, &ts_sensor, format); |
1376 | gkrellm_get_top_bottom_margins(style, &y, NULL((void*)0)); |
1377 | y += bezel_style->border.top; |
1378 | for (list = temperature_list; list; list = list->next) |
1379 | { |
1380 | smon = (SensorMon *) list->data; |
1381 | sensor = smon->sensor; |
1382 | d = gkrellm_create_decal_text(pTemp, format, |
1383 | ts_sensor, style, -1, y, 0); |
1384 | d->x = gkrellm_chart_width() - d->w - m->right - 1; |
1385 | smon->sensor_decal = d; |
1386 | |
1387 | smon->name_decal = gkrellm_create_decal_text(pTemp, |
1388 | sensor->name_locale, ts_name, style, -1, y, 0); |
1389 | y = adjust_decal_positions(smon); |
1390 | sensor->cb_alert = cb_alert_trigger; |
1391 | sensor->cb_alert_data = smon; |
1392 | gkrellm_alert_trigger_connect(sensor->alert, cb_alert_trigger, smon); |
1393 | gkrellm_alert_command_process_connect(sensor->alert, |
1394 | cb_command_process, sensor); |
1395 | gkrellm_reset_alert_soft(sensor->alert); |
1396 | } |
1397 | g_free(ts_name); |
1398 | g_free(ts_sensor); |
1399 | gkrellm_panel_configure(pTemp, NULL((void*)0), style); |
1400 | if (smon && smon->sensor_decal->y + smon->sensor_decal->h > |
1401 | smon->name_decal->y + smon->name_decal->h - bezel_style->border.bottom |
1402 | ) |
1403 | gkrellm_panel_configure_add_height(pTemp, bezel_style->border.bottom); |
1404 | gkrellm_panel_create(vbox, mon_sensors, pTemp); |
1405 | draw_bezels(pTemp, temperature_list, 0, 0, 1); |
1406 | if (first_create) |
1407 | { |
1408 | g_signal_connect(G_OBJECT(pTemp->drawing_area), "expose_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((pTemp->drawing_area)), (((GType) ((20 ) << (2))))))))), ("expose_event"), (((GCallback) (expose_event ))), (pTemp), ((void*)0), (GConnectFlags) 0) |
1409 | G_CALLBACK(expose_event), pTemp)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((pTemp->drawing_area)), (((GType) ((20 ) << (2))))))))), ("expose_event"), (((GCallback) (expose_event ))), (pTemp), ((void*)0), (GConnectFlags) 0); |
1410 | g_signal_connect(G_OBJECT(pTemp->drawing_area), "button_press_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((pTemp->drawing_area)), (((GType) ((20 ) << (2))))))))), ("button_press_event"), (((GCallback) (cb_panel_press))), (pTemp), ((void*)0), (GConnectFlags) 0) |
1411 | G_CALLBACK(cb_panel_press), pTemp)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((pTemp->drawing_area)), (((GType) ((20 ) << (2))))))))), ("button_press_event"), (((GCallback) (cb_panel_press))), (pTemp), ((void*)0), (GConnectFlags) 0); |
1412 | } |
1413 | draw_temperatures(TRUE(!(0))); |
1414 | } |
1415 | |
1416 | static void |
1417 | make_fan_panel(GtkWidget *vbox, gint first_create) |
1418 | { |
1419 | Sensor *sensor; |
1420 | SensorMon *smon = NULL((void*)0); |
1421 | GkrellmStyle *style; |
1422 | GkrellmMargin *m; |
1423 | GkrellmDecal *d; |
1424 | GList *list; |
1425 | GkrellmTextstyle *ts_sensor, *ts_name; |
1426 | gchar *format; |
1427 | gint y; |
1428 | |
1429 | if (!pFan) |
1430 | return; |
1431 | style = gkrellm_meter_style(style_id); |
1432 | m = gkrellm_get_style_margins(style); |
1433 | format = "8888"; |
1434 | assign_textstyles(temperature_list, &ts_name, &ts_sensor, format); |
1435 | gkrellm_get_top_bottom_margins(style, &y, NULL((void*)0)); |
1436 | y += bezel_style->border.top; |
1437 | for (list = fan_list; list; list = list->next) |
1438 | { |
1439 | smon = (SensorMon *) list->data; |
1440 | sensor = smon->sensor; |
1441 | d = gkrellm_create_decal_text(pFan, format, |
1442 | ts_sensor, style, -1, y, 0); |
1443 | d->x = gkrellm_chart_width() - d->w - m->right - 1; |
1444 | smon->sensor_decal = d; |
1445 | |
1446 | smon->name_decal = gkrellm_create_decal_text(pFan, sensor->name_locale, |
1447 | ts_name, style, -1, y, 0); |
1448 | y = adjust_decal_positions(smon); |
1449 | sensor->cb_alert = cb_alert_trigger; |
1450 | sensor->cb_alert_data = smon; |
1451 | gkrellm_alert_trigger_connect(sensor->alert, cb_alert_trigger, smon); |
1452 | gkrellm_alert_command_process_connect(sensor->alert, |
1453 | cb_command_process, sensor); |
1454 | gkrellm_reset_alert_soft(sensor->alert); |
1455 | } |
1456 | g_free(ts_name); |
1457 | g_free(ts_sensor); |
1458 | gkrellm_panel_configure(pFan, NULL((void*)0), style); |
1459 | if (smon && smon->sensor_decal->y + smon->sensor_decal->h > |
1460 | smon->name_decal->y + smon->name_decal->h - bezel_style->border.bottom |
1461 | ) |
1462 | gkrellm_panel_configure_add_height(pFan, bezel_style->border.bottom); |
1463 | gkrellm_panel_create(vbox, mon_sensors, pFan); |
1464 | draw_bezels(pFan, fan_list, 0, 0, 0); |
1465 | if (first_create) |
1466 | { |
1467 | g_signal_connect(G_OBJECT(pFan->drawing_area), "expose_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((pFan->drawing_area)), (((GType) ((20) << (2))))))))), ("expose_event"), (((GCallback) (expose_event ))), (pFan), ((void*)0), (GConnectFlags) 0) |
1468 | G_CALLBACK(expose_event), pFan)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((pFan->drawing_area)), (((GType) ((20) << (2))))))))), ("expose_event"), (((GCallback) (expose_event ))), (pFan), ((void*)0), (GConnectFlags) 0); |
1469 | g_signal_connect(G_OBJECT(pFan->drawing_area), "button_press_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((pFan->drawing_area)), (((GType) ((20) << (2))))))))), ("button_press_event"), (((GCallback) ( cb_panel_press))), (pFan), ((void*)0), (GConnectFlags) 0) |
1470 | G_CALLBACK(cb_panel_press), pFan)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((pFan->drawing_area)), (((GType) ((20) << (2))))))))), ("button_press_event"), (((GCallback) ( cb_panel_press))), (pFan), ((void*)0), (GConnectFlags) 0); |
1471 | } |
1472 | draw_fans(TRUE(!(0))); |
1473 | } |
1474 | |
1475 | static void |
1476 | make_volt_panel(GtkWidget *vbox, gint first_create) |
1477 | { |
1478 | GkrellmStyle *style; |
1479 | |
1480 | if (!pVolt) |
1481 | return; |
1482 | style = gkrellm_meter_style(style_id); |
1483 | make_volt_decals(pVolt, style); |
1484 | layout_volt_decals(pVolt, style); |
1485 | |
1486 | gkrellm_panel_configure(pVolt, NULL((void*)0), style); |
1487 | |
1488 | /* Make the bottom margin reference against the bottom volt decals |
1489 | | bezel image. The volt decal height does not include the bezel so |
1490 | | gkrellm_panel_configure() did not account for the bezel. |
1491 | */ |
1492 | gkrellm_panel_configure_add_height(pVolt, bezel_style->border.bottom); |
1493 | gkrellm_panel_create(vbox, mon_sensors, pVolt); |
1494 | |
1495 | draw_bezels(pVolt, volt_list, |
1496 | volt_bezel_width, volt_mon_height, pixel_grub); |
1497 | |
1498 | if (first_create) |
1499 | { |
1500 | g_signal_connect(G_OBJECT(pVolt->drawing_area), "expose_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((pVolt->drawing_area)), (((GType) ((20 ) << (2))))))))), ("expose_event"), (((GCallback) (expose_event ))), (pVolt), ((void*)0), (GConnectFlags) 0) |
1501 | G_CALLBACK(expose_event), pVolt)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((pVolt->drawing_area)), (((GType) ((20 ) << (2))))))))), ("expose_event"), (((GCallback) (expose_event ))), (pVolt), ((void*)0), (GConnectFlags) 0); |
1502 | g_signal_connect(G_OBJECT(pVolt->drawing_area), "button_press_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((pVolt->drawing_area)), (((GType) ((20 ) << (2))))))))), ("button_press_event"), (((GCallback) (cb_panel_press))), (pVolt), ((void*)0), (GConnectFlags) 0) |
1503 | G_CALLBACK(cb_panel_press), pVolt)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((pVolt->drawing_area)), (((GType) ((20 ) << (2))))))))), ("button_press_event"), (((GCallback) (cb_panel_press))), (pVolt), ((void*)0), (GConnectFlags) 0); |
1504 | } |
1505 | draw_voltages(NULL((void*)0), TRUE(!(0))); |
1506 | } |
1507 | |
1508 | |
1509 | static void |
1510 | destroy_sensors_monitor(gboolean do_temp, gboolean do_fan, gboolean do_volt) |
1511 | { |
1512 | if (do_temp) |
1513 | { |
1514 | gkrellm_panel_destroy(pTemp); |
1515 | pTemp = NULL((void*)0); |
1516 | } |
1517 | if (do_fan) |
1518 | { |
1519 | gkrellm_panel_destroy(pFan); |
1520 | pFan = NULL((void*)0); |
1521 | } |
1522 | if (do_volt) |
1523 | { |
1524 | gkrellm_panel_destroy(pVolt); |
1525 | pVolt = NULL((void*)0); |
1526 | } |
1527 | } |
1528 | |
1529 | static void |
1530 | create_sensors_monitor(gboolean do_temp, gboolean do_fan, gboolean do_volt, |
1531 | gboolean first_create) |
1532 | { |
1533 | make_sensor_monitor_lists(do_temp, do_fan, do_volt); |
1534 | if (do_temp && temperature_list) |
1535 | { |
1536 | if (!pTemp) |
1537 | pTemp = gkrellm_panel_new0(); |
1538 | make_temperature_panel(temp_vbox, first_create); |
1539 | } |
1540 | if (do_fan && fan_list) |
1541 | { |
1542 | if (!pFan) |
1543 | pFan = gkrellm_panel_new0(); |
1544 | make_fan_panel(fan_vbox, first_create); |
1545 | } |
1546 | if (do_volt && volt_list) |
1547 | { |
1548 | if (!pVolt) |
1549 | pVolt = gkrellm_panel_new0(); |
1550 | make_volt_panel(volt_vbox, first_create); |
1551 | } |
1552 | if (temperature_list || fan_list || volt_list) |
1553 | gkrellm_spacers_show(mon_sensors); |
1554 | else |
1555 | gkrellm_spacers_hide(mon_sensors); |
1556 | } |
1557 | |
1558 | void |
1559 | gkrellm_sensors_rebuild(gboolean do_temp, gboolean do_fan, gboolean do_volt) |
1560 | { |
1561 | destroy_sensors_monitor(do_temp, do_fan, do_volt); |
1562 | create_sensors_monitor(do_temp, do_fan, do_volt, TRUE(!(0))); |
1563 | } |
1564 | |
1565 | static void |
1566 | create_sensors(GtkWidget *vbox, gint first_create) |
1567 | { |
1568 | gchar **xpm; |
1569 | static gboolean config_loaded; |
1570 | |
1571 | if (!config_loaded) |
1572 | read_sensors_config(); |
1573 | if (first_create) |
1574 | { |
1575 | temp_vbox = gtk_vbox_new(FALSE(0), 0); |
1576 | gtk_box_pack_start(GTK_BOX(vbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((vbox )), ((gtk_box_get_type ())))))), temp_vbox, FALSE(0), FALSE(0), 0); |
1577 | gtk_widget_show(temp_vbox); |
1578 | |
1579 | fan_vbox = gtk_vbox_new(FALSE(0), 0); |
1580 | gtk_box_pack_start(GTK_BOX(vbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((vbox )), ((gtk_box_get_type ())))))), fan_vbox, FALSE(0), FALSE(0), 0); |
1581 | gtk_widget_show(fan_vbox); |
1582 | |
1583 | volt_vbox = gtk_vbox_new(FALSE(0), 0); |
1584 | gtk_box_pack_start(GTK_BOX(vbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((vbox )), ((gtk_box_get_type ())))))), volt_vbox, FALSE(0), FALSE(0), 0); |
1585 | gtk_widget_show(volt_vbox); |
1586 | |
1587 | bezel_style = gkrellm_style_new0(); |
1588 | } |
1589 | else /* To be done after disk panels created */ |
1590 | need_disk_temperature_update = TRUE(!(0)); |
1591 | |
1592 | config_loaded = TRUE(!(0)); |
1593 | |
1594 | /* Here is where I define the volt panel theme image extensions. I ask |
1595 | | for a theme extension image: |
1596 | | THEME_DIR/sensors/bg_volt.png |
1597 | | and for a border for it from the gkrellmrc in the format: |
1598 | | set_piximage_border sensors_bg_volt l,r,t,b |
1599 | | There is no default for bg_volt image, ie it may end up being NULL. |
1600 | */ |
1601 | xpm = gkrellm_using_default_theme() ? bg_volt_xpm : NULL((void*)0); |
1602 | if (bezel_piximage) |
1603 | gkrellm_destroy_piximage(bezel_piximage); |
1604 | bezel_piximage = NULL((void*)0); |
1605 | gkrellm_load_piximage("bg_volt", xpm, &bezel_piximage, SENSOR_STYLE_NAME"sensors"); |
1606 | if (!gkrellm_set_gkrellmrc_piximage_border("sensors_bg_volt", bezel_piximage, bezel_style)) |
1607 | bezel_style->border = default_bezel_border; |
1608 | |
1609 | create_sensors_monitor(DO_TEMP1, DO_FAN1, DO_VOLT1, first_create); |
1610 | } |
1611 | |
1612 | /* FIXME: monitor_sensors and monitor_config_sensors should be combined, |
1613 | | but the issue is apply_sensors_config() must be called before the CPU |
1614 | | and Proc apply, and I want create_sensors() called after the CPU and Proc |
1615 | | create. So for now, two GkrellmMonitor structs and have two sensor |
1616 | | monitor add_builtins() in main.c. |
1617 | */ |
1618 | static GkrellmMonitor monitor_sensors = |
1619 | { |
1620 | N_("Sensors")("Sensors"), /* Voltage config handled in Sensors tab */ |
1621 | MON_VOLTAGE15, /* Id, 0 if a plugin */ |
1622 | create_sensors, /* The create function */ |
1623 | update_sensors, /* The update function */ |
1624 | NULL((void*)0), /* The config tab create function */ |
1625 | NULL((void*)0), /* Voltage apply handled in sensors apply */ |
1626 | |
1627 | NULL((void*)0), /* Voltage save config is in sensors save */ |
1628 | NULL((void*)0), /* Voltage load config is in sensors load */ |
1629 | NULL((void*)0), /* config keyword - use sensors */ |
1630 | |
1631 | NULL((void*)0), /* Undef 2 */ |
1632 | NULL((void*)0), /* Undef 1 */ |
1633 | NULL((void*)0), /* Undef 0 */ |
1634 | |
1635 | 0, /* insert_before_id - place plugin before this mon */ |
1636 | |
1637 | NULL((void*)0), /* Handle if a plugin, filled in by GKrellM */ |
1638 | NULL((void*)0) /* path if a plugin, filled in by GKrellM */ |
1639 | }; |
1640 | |
1641 | GkrellmMonitor * |
1642 | gkrellm_init_sensor_monitor(void) |
1643 | { |
1644 | if (!sensor_list) |
1645 | return NULL((void*)0); |
1646 | monitor_sensors.name = _(monitor_sensors.name)dcgettext ("gkrellm", monitor_sensors.name, 5); |
1647 | style_id = gkrellm_add_meter_style(&monitor_sensors, SENSOR_STYLE_NAME"sensors"); |
1648 | mon_sensors = &monitor_sensors; |
1649 | return &monitor_sensors; |
1650 | } |
1651 | |
1652 | /* =================================================================== */ |
1653 | /* Config for sensors monitor */ |
1654 | |
1655 | /* Don't use the user-config. Save into sensors-config and only if there |
1656 | | is a sensor_list. This preserves configs across a possible sensors |
1657 | | modules load screw up. |
1658 | | |
1659 | | 2.2.3 sets sensor_config_version to 1 to allow sensor relocation |
1660 | | to composite CPU on a SMP machine. |
1661 | | |
1662 | | 2.1.15 scales sensor factor/offset values by SENSOR_FLOAT_FACTOR to avoid |
1663 | | writting decimal points in the config. This is not backwards compatible |
1664 | | with the pre 2.1.15 sensor_config format hence the config file name |
1665 | | change to sensor-config. But sensor_config is forward compatible |
1666 | | since the float factor defaults to 1.0. |
1667 | */ |
1668 | #define SENSOR_CONFIG_VERSION1 1 |
1669 | |
1670 | #define SENSOR_CONFIG_KEYWORD"sensor" "sensor" |
1671 | #define SENSOR_CONFIG_FILE"sensor-config" "sensor-config" |
1672 | #define SENSOR_2_1_14_CONFIG_FILE"sensors_config" "sensors_config" |
1673 | |
1674 | typedef struct |
1675 | { |
1676 | gchar *config_keyword, |
1677 | *config_label; |
1678 | gboolean value; |
1679 | void (*func)(gboolean value); |
1680 | } |
1681 | SysdepOption; |
1682 | |
1683 | static void cb_alert_config(GkrellmAlert *ap, Sensor *sr); |
1684 | |
1685 | static GList *sysdep_option_list; |
1686 | |
1687 | static void |
1688 | create_sensor_alert(Sensor *s) |
1689 | { |
1690 | if (s->type == SENSOR_VOLTAGE2) |
1691 | s->alert = gkrellm_alert_create(NULL((void*)0), s->name, |
1692 | _("Sensor Volt Limits")dcgettext ("gkrellm", "Sensor Volt Limits", 5), |
1693 | TRUE(!(0)), TRUE(!(0)), TRUE(!(0)), 20, -20, 0.01, 0.5, 2); |
1694 | else if (s->type == SENSOR_TEMPERATURE0) |
1695 | s->alert = gkrellm_alert_create(NULL((void*)0), s->name, |
1696 | _("Sensor Temperature Limits (in displayed degree units)")dcgettext ("gkrellm", "Sensor Temperature Limits (in displayed degree units)" , 5), |
1697 | TRUE(!(0)), FALSE(0), TRUE(!(0)), 300, 0, 1.0, 5.0, 1); |
1698 | else if (s->type == SENSOR_FAN1) |
1699 | s->alert = gkrellm_alert_create(NULL((void*)0), s->name, |
1700 | _("Sensor Fan RPM Limits")dcgettext ("gkrellm", "Sensor Fan RPM Limits", 5), |
1701 | FALSE(0), TRUE(!(0)), TRUE(!(0)), 20000, 0, 100, 1000, 0); |
1702 | else |
1703 | return; |
1704 | gkrellm_alert_delay_config(s->alert, 5, 60, 0); |
1705 | gkrellm_alert_trigger_connect(s->alert, s->cb_alert, s->cb_alert_data); |
1706 | gkrellm_alert_command_process_connect(s->alert, cb_command_process, s); |
1707 | gkrellm_alert_config_connect(s->alert, cb_alert_config, s); |
1708 | } |
1709 | |
1710 | void |
1711 | gkrellm_sensors_sysdep_option(gchar *keyword, gchar *label, void (*func)()) |
1712 | { |
1713 | SysdepOption *so = NULL((void*)0); |
1714 | |
1715 | so = g_new0(SysdepOption, 1)(SysdepOption *) (__extension__ ({ gsize __n = (gsize) (1); gsize __s = sizeof (SysdepOption); gpointer __p; if (__s == 1) __p = g_malloc0 (__n); else if (__builtin_constant_p (__n) && (__s == 0 || __n <= (9223372036854775807L *2UL+1UL) / __s )) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n (__n, __s ); __p; })); |
1716 | sysdep_option_list = g_list_append(sysdep_option_list, so); |
1717 | so->config_keyword = g_strdup(keyword); |
1718 | so->config_label = g_strdup(label); |
1719 | so->func = func; |
1720 | } |
1721 | |
1722 | static void |
1723 | save_sensors_config(FILE *f_not_used) |
1724 | { |
1725 | FILE *f; |
1726 | GList *list; |
1727 | Sensor *s; |
1728 | SysdepOption *so; |
1729 | gchar *config, quoted_name[128], buf[128]; |
1730 | gfloat factor, offset; |
1731 | |
1732 | if (!sensor_list || _GK.no_config) |
1733 | return; |
1734 | snprintf(buf, sizeof(buf), "%s/%s", GKRELLM_DIR".gkrellm2", SENSOR_CONFIG_FILE"sensor-config"); |
1735 | config = gkrellm_make_config_file_name(gkrellm_homedir(), buf); |
1736 | f = g_fopenfopen(config, "w"); |
1737 | g_free(config); |
1738 | if (!f) |
1739 | return; |
1740 | |
1741 | fprintf(f, "%s sensor_config_version %d\n", |
1742 | SENSOR_CONFIG_KEYWORD"sensor", SENSOR_CONFIG_VERSION1); |
1743 | fprintf(f, "%s sensor_sysdep_private %d\n", |
1744 | SENSOR_CONFIG_KEYWORD"sensor", sensor_current_sysdep_private); |
1745 | fprintf(f, "%s sensor_float_factor %.0f\n", |
1746 | SENSOR_CONFIG_KEYWORD"sensor", SENSOR_FLOAT_FACTOR10000.0); |
1747 | fprintf(f, "%s gkrellm_float_factor %.0f\n", |
1748 | SENSOR_CONFIG_KEYWORD"sensor", GKRELLM_FLOAT_FACTOR1000.0); |
1749 | for (list = sysdep_option_list; list; list = list->next) |
1750 | { |
1751 | so = (SysdepOption *) list->data; |
1752 | fprintf(f, "%s sysdep_option %s %d\n", SENSOR_CONFIG_KEYWORD"sensor", |
1753 | so->config_keyword, so->value); |
1754 | } |
1755 | |
1756 | for (list = sensor_list; list; list = list->next) |
1757 | { |
1758 | s = (Sensor *) list->data; |
1759 | if (s->name && *(s->name)) |
1760 | { |
1761 | snprintf(quoted_name, sizeof(quoted_name), "\"%s\"", s->id_name); |
1762 | factor = (s->default_factor != 0.0 ? s->factor : 0.0); |
1763 | offset = (s->default_factor != 0.0 ? s->offset : 0.0); |
1764 | fprintf(f, "%s \"%s\" %s %.0f %.0f %d %d\n", |
1765 | SENSOR_CONFIG_KEYWORD"sensor", |
1766 | s->name, quoted_name, |
1767 | factor * SENSOR_FLOAT_FACTOR10000.0, |
1768 | offset * SENSOR_FLOAT_FACTOR10000.0, |
1769 | s->enabled, s->location); |
1770 | if (s->alert) |
1771 | gkrellm_save_alertconfig(f, s->alert, |
1772 | SENSOR_CONFIG_KEYWORD"sensor", quoted_name); |
1773 | } |
1774 | } |
1775 | for (list = sensor_list; list; list = list->next) |
1776 | { |
1777 | s = (Sensor *) list->data; |
1778 | if (s->vref) |
1779 | fprintf(f, "%s vref \"%s\" \"%s\"\n", SENSOR_CONFIG_KEYWORD"sensor", |
1780 | s->id_name, s->vref->id_name); |
1781 | } |
1782 | |
1783 | fprintf(f, "%s units_fahrenheit %d\n", SENSOR_CONFIG_KEYWORD"sensor", |
1784 | units_fahrenheit); |
1785 | fprintf(f, "%s show_units %d\n", SENSOR_CONFIG_KEYWORD"sensor", |
1786 | show_units); |
1787 | fprintf(f, "%s volt_display_mode %d\n", SENSOR_CONFIG_KEYWORD"sensor", |
1788 | display_mode); |
1789 | /* _GK.mbmon_port is handled in config.c so that the port can be |
1790 | | loaded early for sensor initialization. |
1791 | */ |
1792 | fclose(f); |
1793 | } |
1794 | |
1795 | static void |
1796 | load_sensors_config(gchar *arg) |
1797 | { |
1798 | Sensor *s; |
1799 | SysdepOption *so; |
1800 | GList *list; |
1801 | gchar config[32], item[CFG_BUFSIZE512], item1[CFG_BUFSIZE512]; |
1802 | gchar label[64], id_name[CFG_BUFSIZE512]; |
1803 | gint n; |
1804 | gfloat f = 1.0, |
1805 | o = 0.0; |
1806 | gint e = 0, |
1807 | location = 0; |
1808 | gfloat save_factor; |
1809 | |
1810 | n = sscanf(arg, "%31s %[^\n]", config, item); |
1811 | if (n != 2) |
1812 | return; |
1813 | gkrellm_debug(DEBUG_SENSORS0x80, "load_sensors_config: <%s> <%s>\n", config, |
1814 | item); |
1815 | if (!strcmp(config, "sensor_config_version")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (config) && __builtin_constant_p ("sensor_config_version" ) && (__s1_len = strlen (config), __s2_len = strlen ( "sensor_config_version"), (!((size_t)(const void *)((config) + 1) - (size_t)(const void *)(config) == 1) || __s1_len >= 4 ) && (!((size_t)(const void *)(("sensor_config_version" ) + 1) - (size_t)(const void *)("sensor_config_version") == 1 ) || __s2_len >= 4)) ? __builtin_strcmp (config, "sensor_config_version" ) : (__builtin_constant_p (config) && ((size_t)(const void *)((config) + 1) - (size_t)(const void *)(config) == 1) && (__s1_len = strlen (config), __s1_len < 4) ? ( __builtin_constant_p ("sensor_config_version") && ((size_t )(const void *)(("sensor_config_version") + 1) - (size_t)(const void *)("sensor_config_version") == 1) ? __builtin_strcmp (config , "sensor_config_version") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("sensor_config_version" ); int __result = (((const unsigned char *) (const char *) (config ))[0] - __s2[0]); if (__s1_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (config ))[1] - __s2[1]); if (__s1_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (config ))[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (config ))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ( "sensor_config_version") && ((size_t)(const void *)(( "sensor_config_version") + 1) - (size_t)(const void *)("sensor_config_version" ) == 1) && (__s2_len = strlen ("sensor_config_version" ), __s2_len < 4) ? (__builtin_constant_p (config) && ((size_t)(const void *)((config) + 1) - (size_t)(const void * )(config) == 1) ? __builtin_strcmp (config, "sensor_config_version" ) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (config); int __result = (((const unsigned char *) (const char *) ("sensor_config_version"))[0] - __s2[ 0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("sensor_config_version" ))[1] - __s2[1]); if (__s2_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("sensor_config_version" ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) ("sensor_config_version" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (config , "sensor_config_version")))); })) |
1816 | sscanf(item, "%d", &sensor_config_version); |
1817 | else if (!strcmp(config, "sensor_sysdep_private")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (config) && __builtin_constant_p ("sensor_sysdep_private" ) && (__s1_len = strlen (config), __s2_len = strlen ( "sensor_sysdep_private"), (!((size_t)(const void *)((config) + 1) - (size_t)(const void *)(config) == 1) || __s1_len >= 4 ) && (!((size_t)(const void *)(("sensor_sysdep_private" ) + 1) - (size_t)(const void *)("sensor_sysdep_private") == 1 ) || __s2_len >= 4)) ? __builtin_strcmp (config, "sensor_sysdep_private" ) : (__builtin_constant_p (config) && ((size_t)(const void *)((config) + 1) - (size_t)(const void *)(config) == 1) && (__s1_len = strlen (config), __s1_len < 4) ? ( __builtin_constant_p ("sensor_sysdep_private") && ((size_t )(const void *)(("sensor_sysdep_private") + 1) - (size_t)(const void *)("sensor_sysdep_private") == 1) ? __builtin_strcmp (config , "sensor_sysdep_private") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("sensor_sysdep_private" ); int __result = (((const unsigned char *) (const char *) (config ))[0] - __s2[0]); if (__s1_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (config ))[1] - __s2[1]); if (__s1_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (config ))[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (config ))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ( "sensor_sysdep_private") && ((size_t)(const void *)(( "sensor_sysdep_private") + 1) - (size_t)(const void *)("sensor_sysdep_private" ) == 1) && (__s2_len = strlen ("sensor_sysdep_private" ), __s2_len < 4) ? (__builtin_constant_p (config) && ((size_t)(const void *)((config) + 1) - (size_t)(const void * )(config) == 1) ? __builtin_strcmp (config, "sensor_sysdep_private" ) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (config); int __result = (((const unsigned char *) (const char *) ("sensor_sysdep_private"))[0] - __s2[ 0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("sensor_sysdep_private" ))[1] - __s2[1]); if (__s2_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("sensor_sysdep_private" ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) ("sensor_sysdep_private" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (config , "sensor_sysdep_private")))); })) |
1818 | sscanf(item, "%d", &sensor_config_sysdep_private); |
1819 | else if (!strcmp(config, "units_fahrenheit")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (config) && __builtin_constant_p ("units_fahrenheit" ) && (__s1_len = strlen (config), __s2_len = strlen ( "units_fahrenheit"), (!((size_t)(const void *)((config) + 1) - (size_t)(const void *)(config) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("units_fahrenheit") + 1) - (size_t )(const void *)("units_fahrenheit") == 1) || __s2_len >= 4 )) ? __builtin_strcmp (config, "units_fahrenheit") : (__builtin_constant_p (config) && ((size_t)(const void *)((config) + 1) - ( size_t)(const void *)(config) == 1) && (__s1_len = strlen (config), __s1_len < 4) ? (__builtin_constant_p ("units_fahrenheit" ) && ((size_t)(const void *)(("units_fahrenheit") + 1 ) - (size_t)(const void *)("units_fahrenheit") == 1) ? __builtin_strcmp (config, "units_fahrenheit") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("units_fahrenheit" ); int __result = (((const unsigned char *) (const char *) (config ))[0] - __s2[0]); if (__s1_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (config ))[1] - __s2[1]); if (__s1_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (config ))[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (config ))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ( "units_fahrenheit") && ((size_t)(const void *)(("units_fahrenheit" ) + 1) - (size_t)(const void *)("units_fahrenheit") == 1) && (__s2_len = strlen ("units_fahrenheit"), __s2_len < 4) ? ( __builtin_constant_p (config) && ((size_t)(const void *)((config) + 1) - (size_t)(const void *)(config) == 1) ? __builtin_strcmp (config, "units_fahrenheit") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (config) ; int __result = (((const unsigned char *) (const char *) ("units_fahrenheit" ))[0] - __s2[0]); if (__s2_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("units_fahrenheit" ))[1] - __s2[1]); if (__s2_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("units_fahrenheit" ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) ("units_fahrenheit" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (config , "units_fahrenheit")))); })) |
1820 | sscanf(item, "%d", &units_fahrenheit); |
1821 | else if (!strcmp(config, "show_units")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (config) && __builtin_constant_p ("show_units") && (__s1_len = strlen (config), __s2_len = strlen ("show_units" ), (!((size_t)(const void *)((config) + 1) - (size_t)(const void *)(config) == 1) || __s1_len >= 4) && (!((size_t) (const void *)(("show_units") + 1) - (size_t)(const void *)("show_units" ) == 1) || __s2_len >= 4)) ? __builtin_strcmp (config, "show_units" ) : (__builtin_constant_p (config) && ((size_t)(const void *)((config) + 1) - (size_t)(const void *)(config) == 1) && (__s1_len = strlen (config), __s1_len < 4) ? ( __builtin_constant_p ("show_units") && ((size_t)(const void *)(("show_units") + 1) - (size_t)(const void *)("show_units" ) == 1) ? __builtin_strcmp (config, "show_units") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("show_units"); int __result = (((const unsigned char *) (const char *) (config))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (config))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (config))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (config))[3] - __s2[3]); } } __result; })) ) : (__builtin_constant_p ("show_units") && ((size_t) (const void *)(("show_units") + 1) - (size_t)(const void *)("show_units" ) == 1) && (__s2_len = strlen ("show_units"), __s2_len < 4) ? (__builtin_constant_p (config) && ((size_t )(const void *)((config) + 1) - (size_t)(const void *)(config ) == 1) ? __builtin_strcmp (config, "show_units") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (config); int __result = (((const unsigned char *) ( const char *) ("show_units"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("show_units"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("show_units"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("show_units"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (config, "show_units")))); })) |
1822 | sscanf(item, "%d", &show_units); |
1823 | else if (!strcmp(config, "volt_display_mode")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (config) && __builtin_constant_p ("volt_display_mode" ) && (__s1_len = strlen (config), __s2_len = strlen ( "volt_display_mode"), (!((size_t)(const void *)((config) + 1) - (size_t)(const void *)(config) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("volt_display_mode") + 1) - (size_t )(const void *)("volt_display_mode") == 1) || __s2_len >= 4 )) ? __builtin_strcmp (config, "volt_display_mode") : (__builtin_constant_p (config) && ((size_t)(const void *)((config) + 1) - ( size_t)(const void *)(config) == 1) && (__s1_len = strlen (config), __s1_len < 4) ? (__builtin_constant_p ("volt_display_mode" ) && ((size_t)(const void *)(("volt_display_mode") + 1 ) - (size_t)(const void *)("volt_display_mode") == 1) ? __builtin_strcmp (config, "volt_display_mode") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("volt_display_mode" ); int __result = (((const unsigned char *) (const char *) (config ))[0] - __s2[0]); if (__s1_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (config ))[1] - __s2[1]); if (__s1_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (config ))[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (config ))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ( "volt_display_mode") && ((size_t)(const void *)(("volt_display_mode" ) + 1) - (size_t)(const void *)("volt_display_mode") == 1) && (__s2_len = strlen ("volt_display_mode"), __s2_len < 4) ? (__builtin_constant_p (config) && ((size_t)(const void *)((config) + 1) - (size_t)(const void *)(config) == 1) ? __builtin_strcmp (config, "volt_display_mode") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (config) ; int __result = (((const unsigned char *) (const char *) ("volt_display_mode" ))[0] - __s2[0]); if (__s2_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("volt_display_mode" ))[1] - __s2[1]); if (__s2_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("volt_display_mode" ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) ("volt_display_mode" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (config , "volt_display_mode")))); })) |
1824 | sscanf(item, "%d", &display_mode); |
1825 | else if (!strcmp(config, "sensor_float_factor")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (config) && __builtin_constant_p ("sensor_float_factor" ) && (__s1_len = strlen (config), __s2_len = strlen ( "sensor_float_factor"), (!((size_t)(const void *)((config) + 1 ) - (size_t)(const void *)(config) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("sensor_float_factor") + 1) - (size_t)(const void *)("sensor_float_factor") == 1) || __s2_len >= 4)) ? __builtin_strcmp (config, "sensor_float_factor" ) : (__builtin_constant_p (config) && ((size_t)(const void *)((config) + 1) - (size_t)(const void *)(config) == 1) && (__s1_len = strlen (config), __s1_len < 4) ? ( __builtin_constant_p ("sensor_float_factor") && ((size_t )(const void *)(("sensor_float_factor") + 1) - (size_t)(const void *)("sensor_float_factor") == 1) ? __builtin_strcmp (config , "sensor_float_factor") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("sensor_float_factor" ); int __result = (((const unsigned char *) (const char *) (config ))[0] - __s2[0]); if (__s1_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (config ))[1] - __s2[1]); if (__s1_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (config ))[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (config ))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ( "sensor_float_factor") && ((size_t)(const void *)(("sensor_float_factor" ) + 1) - (size_t)(const void *)("sensor_float_factor") == 1) && (__s2_len = strlen ("sensor_float_factor"), __s2_len < 4) ? (__builtin_constant_p (config) && ((size_t)(const void *)((config) + 1) - (size_t)(const void *)(config) == 1) ? __builtin_strcmp (config, "sensor_float_factor") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (config); int __result = (((const unsigned char *) (const char *) ("sensor_float_factor"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("sensor_float_factor"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("sensor_float_factor"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("sensor_float_factor" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (config , "sensor_float_factor")))); })) |
1826 | sscanf(item, "%f", &sensor_float_factor); |
1827 | else if (!strcmp(config, "gkrellm_float_factor")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (config) && __builtin_constant_p ("gkrellm_float_factor" ) && (__s1_len = strlen (config), __s2_len = strlen ( "gkrellm_float_factor"), (!((size_t)(const void *)((config) + 1) - (size_t)(const void *)(config) == 1) || __s1_len >= 4 ) && (!((size_t)(const void *)(("gkrellm_float_factor" ) + 1) - (size_t)(const void *)("gkrellm_float_factor") == 1) || __s2_len >= 4)) ? __builtin_strcmp (config, "gkrellm_float_factor" ) : (__builtin_constant_p (config) && ((size_t)(const void *)((config) + 1) - (size_t)(const void *)(config) == 1) && (__s1_len = strlen (config), __s1_len < 4) ? ( __builtin_constant_p ("gkrellm_float_factor") && ((size_t )(const void *)(("gkrellm_float_factor") + 1) - (size_t)(const void *)("gkrellm_float_factor") == 1) ? __builtin_strcmp (config , "gkrellm_float_factor") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("gkrellm_float_factor" ); int __result = (((const unsigned char *) (const char *) (config ))[0] - __s2[0]); if (__s1_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (config ))[1] - __s2[1]); if (__s1_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (config ))[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (config ))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ( "gkrellm_float_factor") && ((size_t)(const void *)(("gkrellm_float_factor" ) + 1) - (size_t)(const void *)("gkrellm_float_factor") == 1) && (__s2_len = strlen ("gkrellm_float_factor"), __s2_len < 4) ? (__builtin_constant_p (config) && ((size_t )(const void *)((config) + 1) - (size_t)(const void *)(config ) == 1) ? __builtin_strcmp (config, "gkrellm_float_factor") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (config); int __result = (((const unsigned char *) (const char *) ("gkrellm_float_factor"))[0] - __s2[0 ]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("gkrellm_float_factor" ))[1] - __s2[1]); if (__s2_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("gkrellm_float_factor" ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) ("gkrellm_float_factor" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (config , "gkrellm_float_factor")))); })) |
1828 | sscanf(item, "%f", &gkrellm_float_factor); |
1829 | else if (!strcmp(config, "vref")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (config) && __builtin_constant_p ("vref") && (__s1_len = strlen (config), __s2_len = strlen ("vref"), (!( (size_t)(const void *)((config) + 1) - (size_t)(const void *) (config) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("vref") + 1) - (size_t)(const void *)("vref") == 1) || __s2_len >= 4)) ? __builtin_strcmp (config, "vref") : ( __builtin_constant_p (config) && ((size_t)(const void *)((config) + 1) - (size_t)(const void *)(config) == 1) && (__s1_len = strlen (config), __s1_len < 4) ? (__builtin_constant_p ("vref") && ((size_t)(const void *)(("vref") + 1) - ( size_t)(const void *)("vref") == 1) ? __builtin_strcmp (config , "vref") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("vref"); int __result = ((( const unsigned char *) (const char *) (config))[0] - __s2[0]) ; if (__s1_len > 0 && __result == 0) { __result = ( ((const unsigned char *) (const char *) (config))[1] - __s2[1 ]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (config))[2] - __s2 [2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (config))[3] - __s2 [3]); } } __result; }))) : (__builtin_constant_p ("vref") && ((size_t)(const void *)(("vref") + 1) - (size_t)(const void * )("vref") == 1) && (__s2_len = strlen ("vref"), __s2_len < 4) ? (__builtin_constant_p (config) && ((size_t )(const void *)((config) + 1) - (size_t)(const void *)(config ) == 1) ? __builtin_strcmp (config, "vref") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (config); int __result = (((const unsigned char *) ( const char *) ("vref"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("vref"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("vref"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("vref"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (config, "vref")))); })) |
1830 | { |
1831 | if ( sscanf(item, "\"%63[^\"]\" \"%64[^\"]\"", id_name, item1) == 2 |
1832 | && (s = lookup_sensor_from_id_name(id_name)) != NULL((void*)0) |
1833 | ) |
1834 | s->vref = lookup_sensor_from_id_name(item1); |
1835 | } |
1836 | else if (!strcmp(config, "sysdep_option")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (config) && __builtin_constant_p ("sysdep_option") && (__s1_len = strlen (config), __s2_len = strlen ("sysdep_option" ), (!((size_t)(const void *)((config) + 1) - (size_t)(const void *)(config) == 1) || __s1_len >= 4) && (!((size_t) (const void *)(("sysdep_option") + 1) - (size_t)(const void * )("sysdep_option") == 1) || __s2_len >= 4)) ? __builtin_strcmp (config, "sysdep_option") : (__builtin_constant_p (config) && ((size_t)(const void *)((config) + 1) - (size_t)(const void * )(config) == 1) && (__s1_len = strlen (config), __s1_len < 4) ? (__builtin_constant_p ("sysdep_option") && ((size_t)(const void *)(("sysdep_option") + 1) - (size_t)(const void *)("sysdep_option") == 1) ? __builtin_strcmp (config, "sysdep_option" ) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("sysdep_option"); int __result = ((( const unsigned char *) (const char *) (config))[0] - __s2[0]) ; if (__s1_len > 0 && __result == 0) { __result = ( ((const unsigned char *) (const char *) (config))[1] - __s2[1 ]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (config))[2] - __s2 [2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (config))[3] - __s2 [3]); } } __result; }))) : (__builtin_constant_p ("sysdep_option" ) && ((size_t)(const void *)(("sysdep_option") + 1) - (size_t)(const void *)("sysdep_option") == 1) && (__s2_len = strlen ("sysdep_option"), __s2_len < 4) ? (__builtin_constant_p (config) && ((size_t)(const void *)((config) + 1) - ( size_t)(const void *)(config) == 1) ? __builtin_strcmp (config , "sysdep_option") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (config); int __result = (((const unsigned char *) (const char *) ("sysdep_option" ))[0] - __s2[0]); if (__s2_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("sysdep_option" ))[1] - __s2[1]); if (__s2_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("sysdep_option" ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) ("sysdep_option" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (config , "sysdep_option")))); })) |
1837 | { |
1838 | if (sscanf(item, "%63s %[^\n]", id_name, item1) == 2) |
1839 | { |
1840 | so = NULL((void*)0); |
1841 | for (list = sysdep_option_list; list; list = list->next) |
1842 | { |
1843 | so = (SysdepOption *) list->data; |
1844 | if (!strcmp(so->config_keyword, id_name)__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (so->config_keyword) && __builtin_constant_p (id_name ) && (__s1_len = strlen (so->config_keyword), __s2_len = strlen (id_name), (!((size_t)(const void *)((so->config_keyword ) + 1) - (size_t)(const void *)(so->config_keyword) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((id_name ) + 1) - (size_t)(const void *)(id_name) == 1) || __s2_len >= 4)) ? __builtin_strcmp (so->config_keyword, id_name) : (__builtin_constant_p (so->config_keyword) && ((size_t)(const void *)(( so->config_keyword) + 1) - (size_t)(const void *)(so->config_keyword ) == 1) && (__s1_len = strlen (so->config_keyword) , __s1_len < 4) ? (__builtin_constant_p (id_name) && ((size_t)(const void *)((id_name) + 1) - (size_t)(const void *)(id_name) == 1) ? __builtin_strcmp (so->config_keyword, id_name) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (id_name); int __result = (( (const unsigned char *) (const char *) (so->config_keyword ))[0] - __s2[0]); if (__s1_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (so-> config_keyword))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (so->config_keyword))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (so->config_keyword))[3] - __s2[3] ); } } __result; }))) : (__builtin_constant_p (id_name) && ((size_t)(const void *)((id_name) + 1) - (size_t)(const void *)(id_name) == 1) && (__s2_len = strlen (id_name), __s2_len < 4) ? (__builtin_constant_p (so->config_keyword) && ((size_t)(const void *)((so->config_keyword) + 1) - (size_t )(const void *)(so->config_keyword) == 1) ? __builtin_strcmp (so->config_keyword, id_name) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (so->config_keyword); int __result = (((const unsigned char *) (const char *) (id_name))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (id_name))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (id_name))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (id_name))[3] - __s2[3]); } } __result; }) ))) : __builtin_strcmp (so->config_keyword, id_name)))); } )) |
1845 | break; |
1846 | so = NULL((void*)0); |
1847 | } |
1848 | if (so && so->func) |
1849 | { |
1850 | so->value = atoi(item1); |
1851 | (*so->func)(so->value); |
1852 | } |
1853 | } |
1854 | } |
1855 | else if (!strcmp(config, GKRELLM_ALERTCONFIG_KEYWORD)__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (config) && __builtin_constant_p ("alert_config") && (__s1_len = strlen (config), __s2_len = strlen ("alert_config" ), (!((size_t)(const void *)((config) + 1) - (size_t)(const void *)(config) == 1) || __s1_len >= 4) && (!((size_t) (const void *)(("alert_config") + 1) - (size_t)(const void *) ("alert_config") == 1) || __s2_len >= 4)) ? __builtin_strcmp (config, "alert_config") : (__builtin_constant_p (config) && ((size_t)(const void *)((config) + 1) - (size_t)(const void * )(config) == 1) && (__s1_len = strlen (config), __s1_len < 4) ? (__builtin_constant_p ("alert_config") && ( (size_t)(const void *)(("alert_config") + 1) - (size_t)(const void *)("alert_config") == 1) ? __builtin_strcmp (config, "alert_config" ) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("alert_config"); int __result = (((const unsigned char *) (const char *) (config))[0] - __s2[0]); if ( __s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (config))[1] - __s2[1]); if ( __s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (config))[2] - __s2[2]); if ( __s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (config))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("alert_config") && ((size_t)(const void *)(("alert_config") + 1) - (size_t)(const void *)("alert_config") == 1) && (__s2_len = strlen ( "alert_config"), __s2_len < 4) ? (__builtin_constant_p (config ) && ((size_t)(const void *)((config) + 1) - (size_t) (const void *)(config) == 1) ? __builtin_strcmp (config, "alert_config" ) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (config); int __result = (((const unsigned char *) (const char *) ("alert_config"))[0] - __s2[0]); if ( __s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("alert_config"))[1] - __s2[ 1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("alert_config")) [2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("alert_config" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (config , "alert_config")))); })) |
1856 | { |
1857 | if ( sscanf(item, "\"%63[^\"]\" %[^\n]", id_name, item1) == 2 |
1858 | && (s = lookup_sensor_from_id_name(id_name)) != NULL((void*)0) |
1859 | ) |
1860 | { |
1861 | /* Since config files may be copied around, make sure to use the |
1862 | | gkrellm float factor in effect when the sensors config was |
1863 | | created. |
1864 | */ |
1865 | save_factor = _GK.float_factor; |
1866 | _GK.float_factor = gkrellm_float_factor; |
1867 | if (!s->alert) |
1868 | create_sensor_alert(s); |
1869 | gkrellm_load_alertconfig(&s->alert, item1); |
1870 | _GK.float_factor = save_factor; |
1871 | } |
1872 | } |
1873 | else if ( sscanf(arg, "\"%63[^\"]\" \"%[^\"]\" %f %f %d %d", |
1874 | label, id_name, &f, &o, &e, &location) > 1 |
1875 | && (s = map_sensor_label(label, id_name)) != NULL((void*)0) |
1876 | ) |
1877 | { |
1878 | if (f != 0.0 && s->default_factor != 0.0) |
1879 | { |
1880 | s->factor = f / sensor_float_factor; |
1881 | s->offset = o / sensor_float_factor; |
1882 | } |
1883 | s->enabled = e; |
1884 | |
1885 | if (s->type == SENSOR_VOLTAGE2) |
1886 | s->location = 0; |
1887 | else |
1888 | { |
1889 | s->location = location; |
1890 | if ( sensor_config_version == 0 && gkrellm_smp_cpus() > 0 |
1891 | && location > PROC_PANEL_LOCATION1 |
1892 | ) |
1893 | /* gkrellm < 2.2.3 did not allow relocating to composite |
1894 | | CPU if on a SMP machine. But with hyperthreading, user |
1895 | | may want to do this. |
1896 | */ |
1897 | s->location += 1; |
1898 | } |
1899 | if (!using_new_config && s->type != SENSOR_VOLTAGE2) |
1900 | s->enabled = TRUE(!(0)); /* Old config enabled with a label */ |
1901 | } |
1902 | if (display_mode < 0 || display_mode >= N_DISPLAY_MODES2) |
1903 | display_mode = N_DISPLAY_MODES2 - 1; |
1904 | } |
1905 | |
1906 | static void |
1907 | read_sensors_config(void) |
1908 | { |
1909 | FILE *f; |
1910 | Sensor *sr; |
1911 | GList *list; |
1912 | gchar *config; |
1913 | gchar buf[CFG_BUFSIZE512]; |
1914 | |
1915 | snprintf(buf, sizeof(buf), "%s/%s", GKRELLM_DIR".gkrellm2", SENSOR_CONFIG_FILE"sensor-config"); |
1916 | config = gkrellm_make_config_file_name(gkrellm_homedir(), buf); |
1917 | f = g_fopenfopen(config, "r"); |
1918 | g_free(config); |
1919 | |
1920 | if (!f) |
1921 | { |
1922 | snprintf(buf, sizeof(buf), "%s/%s", GKRELLM_DIR".gkrellm2", SENSOR_2_1_14_CONFIG_FILE"sensors_config"); |
1923 | config = gkrellm_make_config_file_name(gkrellm_homedir(), buf); |
1924 | f = g_fopenfopen(config, "r"); |
1925 | g_free(config); |
1926 | } |
1927 | if (f) |
1928 | { |
1929 | using_new_config = TRUE(!(0)); |
1930 | while (fgets(buf, sizeof(buf), f)) |
1931 | load_sensors_config(buf + strlen(SENSOR_CONFIG_KEYWORD"sensor") + 1); |
1932 | fclose(f); |
1933 | } |
1934 | |
1935 | /* In case not all sensors are in sensor_config (user edited?) |
1936 | */ |
1937 | for (list = sensor_list; list; list = list->next) |
1938 | { |
1939 | sr = (Sensor *) list->data; |
1940 | if (sr->has_config) /* Was in sensor_config and is already */ |
1941 | continue; /* appended to an order_list */ |
1942 | append_sensor_to_order_list(sr); |
1943 | } |
1944 | g_list_free(sensor_list); |
1945 | sensor_list = temp_order_list; |
1946 | sensor_list = g_list_concat(sensor_list, fan_order_list); |
1947 | sensor_list = g_list_concat(sensor_list, volt_order_list); |
1948 | } |
1949 | |
1950 | enum |
1951 | { |
1952 | NAME_COLUMN, |
1953 | ENABLE_COLUMN, |
1954 | LABEL_COLUMN, |
1955 | SENSOR_COLUMN, |
1956 | VISIBLE_COLUMN, |
1957 | IMAGE_COLUMN, |
1958 | N_COLUMNS |
1959 | }; |
1960 | |
1961 | static GtkTreeModel *sensor_model; |
1962 | static GtkTreeView *treeview; |
1963 | static GtkTreeRowReference *row_reference; |
1964 | static GtkTreeSelection *selection; |
1965 | |
1966 | |
1967 | static GtkWidget *optionmenu; |
1968 | |
1969 | static GtkWidget *display_mode_button[2]; |
1970 | static GtkWidget *factor_spin_button, |
1971 | *offset_spin_button; |
1972 | static GtkWidget *alert_button, |
1973 | *mbmon_port_entry; |
1974 | |
1975 | static Sensor *dragged_sensor; |
1976 | |
1977 | static gint sensor_last_group; |
1978 | |
1979 | static gboolean (*original_row_drop_possible)(); |
1980 | |
1981 | |
1982 | |
1983 | static void |
1984 | set_tree_store_model_data(GtkTreeStore *tree, GtkTreeIter *iter, Sensor *s) |
1985 | { |
1986 | if (!s) |
1987 | return; |
1988 | gtk_tree_store_set(tree, iter, |
1989 | NAME_COLUMN, s->id_name ? s->id_name : "??", |
1990 | ENABLE_COLUMN, s->enabled, |
1991 | LABEL_COLUMN, s->name ? s->name : "??", |
1992 | SENSOR_COLUMN, s, |
1993 | VISIBLE_COLUMN, TRUE(!(0)), |
1994 | -1); |
1995 | if (s->alert) |
1996 | gtk_tree_store_set(tree, iter, |
1997 | IMAGE_COLUMN, gkrellm_alert_pixbuf(), |
1998 | -1); |
1999 | } |
2000 | |
2001 | static void |
2002 | append_sensors_to_model(GtkTreeStore *tree, GtkTreeIter *citer, |
2003 | GtkTreeIter *iter, gint type) |
2004 | { |
2005 | GList *list; |
2006 | Sensor *s; |
2007 | |
2008 | for (list = sensor_list; list; list = list->next) |
2009 | { |
2010 | s = (Sensor *) list->data; |
2011 | if (s->type != type) |
2012 | continue; |
2013 | gtk_tree_store_append(tree, citer, iter); |
2014 | set_tree_store_model_data(tree, citer, s); |
2015 | } |
2016 | } |
2017 | |
2018 | static GtkTreeModel * |
2019 | create_model(void) |
2020 | { |
2021 | GtkTreeStore *tree; |
2022 | GtkTreeIter iter, citer; |
2023 | |
2024 | tree = gtk_tree_store_new(N_COLUMNS, |
2025 | G_TYPE_STRING((GType) ((16) << (2))), |
2026 | G_TYPE_BOOLEAN((GType) ((5) << (2))), |
2027 | G_TYPE_STRING((GType) ((16) << (2))), |
2028 | G_TYPE_POINTER((GType) ((17) << (2))), |
2029 | G_TYPE_BOOLEAN((GType) ((5) << (2))), |
2030 | GDK_TYPE_PIXBUF(gdk_pixbuf_get_type ()) |
2031 | ); |
2032 | |
2033 | gtk_tree_store_append(tree, &iter, NULL((void*)0)); |
2034 | gtk_tree_store_set(tree, &iter, |
2035 | NAME_COLUMN, _("Temperatures")dcgettext ("gkrellm", "Temperatures", 5), |
2036 | VISIBLE_COLUMN, FALSE(0), |
2037 | -1); |
2038 | append_sensors_to_model(tree, &citer, &iter, SENSOR_TEMPERATURE0); |
2039 | |
2040 | gtk_tree_store_append(tree, &iter, NULL((void*)0)); |
2041 | gtk_tree_store_set(tree, &iter, |
2042 | NAME_COLUMN, _("Fans")dcgettext ("gkrellm", "Fans", 5), |
2043 | VISIBLE_COLUMN, FALSE(0), |
2044 | -1); |
2045 | append_sensors_to_model(tree, &citer, &iter, SENSOR_FAN1); |
2046 | |
2047 | gtk_tree_store_append(tree, &iter, NULL((void*)0)); |
2048 | gtk_tree_store_set(tree, &iter, |
2049 | NAME_COLUMN, _("Voltages")dcgettext ("gkrellm", "Voltages", 5), |
2050 | VISIBLE_COLUMN, FALSE(0), |
2051 | -1); |
2052 | append_sensors_to_model(tree, &citer, &iter, SENSOR_VOLTAGE2); |
2053 | return GTK_TREE_MODEL(tree)((((GtkTreeModel*) g_type_check_instance_cast ((GTypeInstance *) ((tree)), ((gtk_tree_model_get_type ())))))); |
2054 | } |
2055 | |
2056 | void |
2057 | gkrellm_sensors_model_update(void) |
2058 | { |
2059 | GtkTreeModel *model; |
2060 | |
2061 | if (!gkrellm_config_window_shown()) |
2062 | return; |
2063 | model = sensor_model; |
2064 | sensor_model = create_model(); |
2065 | gtk_tree_view_set_model(treeview, sensor_model); |
2066 | if (model) |
2067 | g_object_unref(G_OBJECT(model)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) (( model)), (((GType) ((20) << (2))))))))); |
2068 | } |
2069 | |
2070 | static void |
2071 | change_row_reference(GtkTreeModel *model, GtkTreePath *path) |
2072 | { |
2073 | gtk_tree_row_reference_free(row_reference); |
2074 | if (model && path) |
2075 | row_reference = gtk_tree_row_reference_new(model, path); |
2076 | else |
2077 | row_reference = NULL((void*)0); |
2078 | } |
2079 | |
2080 | static Sensor * |
2081 | get_referenced_sensor(void) |
2082 | { |
2083 | GtkTreeModel *model; |
2084 | GtkTreePath *path; |
2085 | GtkTreeIter iter; |
2086 | Sensor *s; |
2087 | |
2088 | if (!row_reference) |
2089 | return NULL((void*)0); |
2090 | model = gtk_tree_view_get_model(treeview); |
2091 | path = gtk_tree_row_reference_get_path(row_reference); |
2092 | gtk_tree_model_get_iter(model, &iter, path); |
2093 | gtk_tree_model_get(model, &iter, |
2094 | SENSOR_COLUMN, &s, -1); |
2095 | return s; |
2096 | } |
2097 | |
2098 | static gboolean |
2099 | get_child_iter(GtkTreeModel *model, gchar *parent_node, GtkTreeIter *citer) |
2100 | { |
2101 | GtkTreePath *path; |
2102 | GtkTreeIter iter; |
2103 | |
2104 | path = gtk_tree_path_new_from_string(parent_node); |
2105 | gtk_tree_model_get_iter(model, &iter, path); |
2106 | gtk_tree_path_free(path); |
2107 | return gtk_tree_model_iter_children(model, citer, &iter); |
2108 | } |
2109 | |
2110 | |
2111 | /* Callback for a created or destroyed alert. Find the sensor in the model |
2112 | | and set the IMAGE_COLUMN. |
2113 | */ |
2114 | static void |
2115 | cb_alert_config(GkrellmAlert *ap, Sensor *sr) |
2116 | { |
2117 | GtkTreeModel *model; |
2118 | GtkTreeIter iter; |
2119 | Sensor *s; |
2120 | GdkPixbuf *pixbuf; |
2121 | gchar node[2]; |
2122 | gint i; |
2123 | |
2124 | if (!gkrellm_config_window_shown()) |
2125 | return; |
2126 | model = gtk_tree_view_get_model(treeview); |
2127 | pixbuf = ap->activated ? gkrellm_alert_pixbuf() : NULL((void*)0); |
2128 | for (i = 0; i < 3; ++i) |
2129 | { |
2130 | node[0] = '0' + i; /* toplevel temp, fan, or volt node */ |
2131 | node[1] = '\0'; |
2132 | if (get_child_iter(model, node, &iter)) |
2133 | do |
2134 | { |
2135 | gtk_tree_model_get(model, &iter, SENSOR_COLUMN, &s, -1); |
2136 | if (s != sr) |
2137 | continue; |
2138 | gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) g_type_check_instance_cast ((GTypeInstance *) ((model)), ((gtk_tree_store_get_type ())))))), &iter, |
2139 | IMAGE_COLUMN, pixbuf, -1); |
2140 | return; |
2141 | } |
2142 | while (gtk_tree_model_iter_next(model, &iter)); |
2143 | } |
2144 | } |
2145 | |
2146 | /* Allow destination drops only on depth 2 paths and don't allow drops from |
2147 | | source depths of 1 (top level nodes). Also disallow drags from one sensor |
2148 | | type to another. Note: from some reason if I allow drops on depth 3 nodes |
2149 | | (destination is on top of a second level node) I am not getting |
2150 | | "drag_end" callbacks. |
2151 | */ |
2152 | static gboolean |
2153 | row_drop_possible(GtkTreeDragDest *drag_dest, GtkTreePath *path, |
2154 | GtkSelectionData *selection_data) |
2155 | { |
2156 | gint *src_indices, *dst_indices; |
2157 | GtkTreePath *src_path; |
2158 | |
2159 | if (!row_reference) |
2160 | return FALSE(0); |
2161 | |
2162 | src_path = gtk_tree_row_reference_get_path(row_reference); |
2163 | src_indices = gtk_tree_path_get_indices(src_path); |
2164 | dst_indices = gtk_tree_path_get_indices(path); |
2165 | //g_debug("drop path: indices=[%d,%d]:%d, path=%s\n", |
2166 | // dst_indices[0], dst_indices[1], gtk_tree_path_get_depth(path), |
2167 | // gtk_tree_path_to_string(path)); |
2168 | |
2169 | if ( gtk_tree_path_get_depth(src_path) == 1 /* Dragging top level */ |
2170 | || gtk_tree_path_get_depth(path) != 2 |
2171 | || src_indices[0] != dst_indices[0] /* sensor types don't match */ |
2172 | ) |
2173 | return FALSE(0); |
2174 | |
2175 | return (*original_row_drop_possible)(drag_dest, path, |
2176 | selection_data); |
2177 | } |
2178 | |
2179 | /* At each drag, divert the original Gtk row_drop_possible function to my |
2180 | | custom row_drop_possible so I can control tree structure. The original |
2181 | | row_drop_possible function must be restored at "drag_end" else other |
2182 | | monitors doing drag n' drop could get screwed. |
2183 | */ |
2184 | static gboolean |
2185 | cb_drag_begin(GtkWidget *widget, GdkDragContext *context, gpointer data) |
2186 | { |
2187 | GtkTreeModel *model; |
2188 | GtkTreePath *path; |
2189 | GtkTreeIter iter; |
2190 | GtkTreeDragDestIface *dest_iface; |
2191 | |
2192 | model = gtk_tree_view_get_model(treeview); |
2193 | dest_iface = GTK_TREE_DRAG_DEST_GET_IFACE(GTK_TREE_DRAG_DEST(model))((((GtkTreeDragDestIface*) g_type_interface_peek (((GTypeInstance *) ((((((GtkTreeDragDest*) g_type_check_instance_cast ((GTypeInstance *) ((model)), ((gtk_tree_drag_dest_get_type ())))))))))->g_class , ((gtk_tree_drag_dest_get_type ())))))); |
2194 | if (!original_row_drop_possible) |
2195 | original_row_drop_possible = dest_iface->row_drop_possible; |
2196 | dest_iface->row_drop_possible = row_drop_possible; |
2197 | |
2198 | if (row_reference) |
2199 | { |
2200 | path = gtk_tree_row_reference_get_path(row_reference); |
2201 | gtk_tree_model_get_iter(model, &iter, path); |
2202 | gtk_tree_model_get(model, &iter, SENSOR_COLUMN, &dragged_sensor, -1); |
2203 | } |
2204 | else |
2205 | dragged_sensor = NULL((void*)0); |
2206 | return FALSE(0); |
2207 | } |
2208 | |
2209 | static gboolean |
2210 | cb_drag_end(GtkWidget *widget, GdkDragContext *context, gpointer data) |
2211 | { |
2212 | GtkTreeModel *model; |
2213 | GtkTreeIter iter; |
2214 | GtkTreeDragDestIface *dest_iface; |
2215 | Sensor *s; |
2216 | gchar node[2]; |
2217 | gint i, type = -1; |
2218 | |
2219 | model = gtk_tree_view_get_model(treeview); |
2220 | dest_iface = GTK_TREE_DRAG_DEST_GET_IFACE(GTK_TREE_DRAG_DEST(model))((((GtkTreeDragDestIface*) g_type_interface_peek (((GTypeInstance *) ((((((GtkTreeDragDest*) g_type_check_instance_cast ((GTypeInstance *) ((model)), ((gtk_tree_drag_dest_get_type ())))))))))->g_class , ((gtk_tree_drag_dest_get_type ())))))); |
2221 | dest_iface->row_drop_possible = original_row_drop_possible; |
2222 | |
2223 | change_row_reference(NULL((void*)0), NULL((void*)0)); |
2224 | gtk_tree_selection_unselect_all(selection); |
2225 | |
2226 | g_list_free(sensor_list); |
2227 | sensor_list = NULL((void*)0); |
2228 | |
2229 | /* Re-order the sensors list to match the model. |
2230 | */ |
2231 | model = gtk_tree_view_get_model(treeview); |
2232 | for (i = 0; i < 3; ++i) |
2233 | { |
2234 | node[0] = '0' + i; /* toplevel temp, fan, or volt node */ |
2235 | node[1] = '\0'; |
2236 | if (get_child_iter(model, node, &iter)) |
2237 | { |
2238 | do |
2239 | { |
2240 | gtk_tree_model_get(model, &iter, SENSOR_COLUMN, &s, -1); |
2241 | sensor_list = g_list_append(sensor_list, s); |
2242 | } |
2243 | while (gtk_tree_model_iter_next(model, &iter)); |
2244 | } |
2245 | } |
2246 | |
2247 | if (dragged_sensor) |
2248 | type = dragged_sensor->type; |
2249 | dragged_sensor = NULL((void*)0); |
2250 | |
2251 | if (type < 0) |
2252 | gkrellm_sensors_rebuild(DO_TEMP1, DO_FAN1, DO_VOLT1); |
2253 | else |
2254 | gkrellm_sensors_rebuild(type == SENSOR_TEMPERATURE0, |
2255 | type == SENSOR_FAN1, type == SENSOR_VOLTAGE2); |
2256 | |
2257 | return FALSE(0); |
2258 | } |
2259 | |
2260 | static void |
2261 | sensor_reset_optionmenu(Sensor *sensor) |
2262 | { |
2263 | Sensor *sr; |
2264 | |
2265 | if (!optionmenu) |
2266 | return; |
2267 | sr = get_referenced_sensor(); |
2268 | if (sr == sensor) |
2269 | gtk_combo_box_set_active(GTK_COMBO_BOX(optionmenu)((((GtkComboBox*) g_type_check_instance_cast ((GTypeInstance* ) ((optionmenu)), ((gtk_combo_box_get_type ())))))), |
2270 | SENSOR_PANEL_LOCATION0); |
2271 | } |
2272 | |
2273 | static void |
2274 | cb_location_menu(GtkComboBox *om, gpointer data) |
2275 | { |
2276 | GList *list; |
2277 | Sensor *sr, *s; |
2278 | gchar *pname = NULL((void*)0); |
2279 | gint location; |
2280 | |
2281 | location = gtk_combo_box_get_active(om); |
2282 | sr = get_referenced_sensor(); |
2283 | if (!sr || !sr->enabled || sr->location == location) |
2284 | return; |
2285 | |
2286 | /* If trying to relocate, get a dst panel name so can report failures. |
2287 | */ |
2288 | if (location != SENSOR_PANEL_LOCATION0) |
2289 | { |
2290 | if (sr->group == SENSOR_GROUP_MAINBOARD0) |
2291 | pname = (location == PROC_PANEL_LOCATION1) |
2292 | ? gkrellm_proc_get_sensor_panel_label() |
2293 | : gkrellm_cpu_get_sensor_panel_label( |
2294 | location - CPU_PANEL_LOCATION2); |
2295 | else if (sr->group == SENSOR_GROUP_DISK1) |
2296 | pname = _("Disk")dcgettext ("gkrellm", "Disk", 5); |
2297 | } |
2298 | |
2299 | /* If moving off some other panel, reset that panel. |
2300 | */ |
2301 | sensor_reset_location(sr); |
2302 | |
2303 | /* For mainboard sensor group, if relocating to a panel with some other |
2304 | | sensor of same type on it, auto restore the other sensor to the sensor |
2305 | | panel. Disk sensor group should never conflict. |
2306 | */ |
2307 | sr->location = location; |
2308 | if ( location != SENSOR_PANEL_LOCATION0 |
2309 | && sr->group == SENSOR_GROUP_MAINBOARD0 |
2310 | ) |
2311 | for (list = sensor_list; list; list = list->next) |
2312 | { |
2313 | s = (Sensor *) list->data; |
2314 | if ( s->group == SENSOR_GROUP_MAINBOARD0 |
2315 | && s != sr |
2316 | && s->type == sr->type |
2317 | && s->location == sr->location |
2318 | ) |
2319 | s->location = SENSOR_PANEL_LOCATION0; /* is being replaced */ |
2320 | } |
2321 | gkrellm_sensors_rebuild(DO_TEMP1, DO_FAN1, FALSE(0)); |
2322 | |
2323 | if (sr->location != location) /* location failed */ |
2324 | { |
2325 | gtk_combo_box_set_active(GTK_COMBO_BOX(optionmenu)((((GtkComboBox*) g_type_check_instance_cast ((GTypeInstance* ) ((optionmenu)), ((gtk_combo_box_get_type ())))))), |
2326 | SENSOR_PANEL_LOCATION0); |
2327 | sensor_relocation_error(pname); |
2328 | } |
2329 | } |
2330 | |
2331 | |
2332 | static void |
2333 | create_location_menu(gint group) |
2334 | { |
2335 | gint n, n_cpus; |
2336 | |
2337 | if (group == sensor_last_group) |
2338 | return; |
2339 | sensor_last_group = group; |
2340 | |
2341 | gtk_combo_box_append_text(GTK_COMBO_BOX(optionmenu)((((GtkComboBox*) g_type_check_instance_cast ((GTypeInstance* ) ((optionmenu)), ((gtk_combo_box_get_type ())))))), "default"); |
2342 | |
2343 | if (group == SENSOR_GROUP_MAINBOARD0) |
2344 | { |
2345 | gtk_combo_box_append_text(GTK_COMBO_BOX(optionmenu)((((GtkComboBox*) g_type_check_instance_cast ((GTypeInstance* ) ((optionmenu)), ((gtk_combo_box_get_type ())))))), |
2346 | gkrellm_proc_get_sensor_panel_label()); |
2347 | |
2348 | n_cpus = gkrellm_smp_cpus() + 1; |
2349 | for (n = 0; n < n_cpus; ++n) |
2350 | { |
2351 | gtk_combo_box_append_text(GTK_COMBO_BOX(optionmenu)((((GtkComboBox*) g_type_check_instance_cast ((GTypeInstance* ) ((optionmenu)), ((gtk_combo_box_get_type ())))))), |
2352 | gkrellm_cpu_get_sensor_panel_label(n)); |
2353 | } |
2354 | } |
2355 | else if (group == SENSOR_GROUP_DISK1) |
2356 | { |
2357 | gtk_combo_box_append_text(GTK_COMBO_BOX(optionmenu)((((GtkComboBox*) g_type_check_instance_cast ((GTypeInstance* ) ((optionmenu)), ((gtk_combo_box_get_type ())))))), _("Disk")dcgettext ("gkrellm", "Disk", 5)); |
2358 | } |
2359 | g_signal_connect(G_OBJECT(optionmenu), "changed",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((optionmenu)), (((GType) ((20) << ( 2))))))))), ("changed"), (((GCallback) (cb_location_menu))), ( ((void*)0)), ((void*)0), (GConnectFlags) 0) |
2360 | G_CALLBACK(cb_location_menu), NULL)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((optionmenu)), (((GType) ((20) << ( 2))))))))), ("changed"), (((GCallback) (cb_location_menu))), ( ((void*)0)), ((void*)0), (GConnectFlags) 0); |
2361 | } |
2362 | |
2363 | static void |
2364 | set_sensor_widget_states(Sensor *s) |
2365 | { |
2366 | gboolean f_sensitive = FALSE(0), |
2367 | o_sensitive = FALSE(0), |
2368 | p_sensitive = FALSE(0); |
2369 | gfloat factor = 1.0, |
2370 | offset = 0.0; |
2371 | gint location = SENSOR_PANEL_LOCATION0; |
2372 | |
2373 | if (s && s->enabled) |
2374 | { |
2375 | f_sensitive = TRUE(!(0)); |
2376 | if (s->type != SENSOR_FAN1) |
2377 | { |
2378 | o_sensitive = TRUE(!(0)); |
2379 | offset = s->offset; |
2380 | } |
2381 | factor = s->factor; |
2382 | if (s->type != SENSOR_VOLTAGE2) |
2383 | { |
2384 | location = s->location; |
2385 | p_sensitive = TRUE(!(0)); |
2386 | } |
2387 | } |
2388 | create_location_menu(s ? s->group : 0); |
2389 | gtk_combo_box_set_active(GTK_COMBO_BOX(optionmenu)((((GtkComboBox*) g_type_check_instance_cast ((GTypeInstance* ) ((optionmenu)), ((gtk_combo_box_get_type ())))))), location); |
2390 | gtk_spin_button_set_value(GTK_SPIN_BUTTON(factor_spin_button)((((GtkSpinButton*) g_type_check_instance_cast ((GTypeInstance *) ((factor_spin_button)), ((gtk_spin_button_get_type ()))))) ), factor); |
2391 | gtk_spin_button_set_value(GTK_SPIN_BUTTON(offset_spin_button)((((GtkSpinButton*) g_type_check_instance_cast ((GTypeInstance *) ((offset_spin_button)), ((gtk_spin_button_get_type ()))))) ), offset); |
2392 | gtk_widget_set_sensitive(optionmenu, p_sensitive); |
2393 | gtk_widget_set_sensitive(alert_button, f_sensitive); |
2394 | |
2395 | if (s && s->default_factor == 0.0) |
2396 | f_sensitive = o_sensitive = FALSE(0); |
2397 | |
2398 | gtk_widget_set_sensitive(factor_spin_button, f_sensitive); |
2399 | gtk_widget_set_sensitive(offset_spin_button, o_sensitive); |
2400 | } |
2401 | |
2402 | static void |
2403 | cb_correction_modified(void) |
2404 | { |
2405 | Sensor *s; |
2406 | |
2407 | s = get_referenced_sensor(); |
2408 | if (!s || !s->enabled) |
2409 | return; |
2410 | s->factor = gtk_spin_button_get_value(GTK_SPIN_BUTTON(factor_spin_button)((((GtkSpinButton*) g_type_check_instance_cast ((GTypeInstance *) ((factor_spin_button)), ((gtk_spin_button_get_type ()))))) )); |
2411 | s->offset = gtk_spin_button_get_value(GTK_SPIN_BUTTON(offset_spin_button)((((GtkSpinButton*) g_type_check_instance_cast ((GTypeInstance *) ((offset_spin_button)), ((gtk_spin_button_get_type ()))))) )); |
2412 | |
2413 | if (s->factor == 0) |
2414 | { |
2415 | s->factor = s->default_factor; |
2416 | s->offset = s->default_offset; |
2417 | gtk_spin_button_set_value(GTK_SPIN_BUTTON(factor_spin_button)((((GtkSpinButton*) g_type_check_instance_cast ((GTypeInstance *) ((factor_spin_button)), ((gtk_spin_button_get_type ()))))) ), |
2418 | s->factor); |
2419 | gtk_spin_button_set_value(GTK_SPIN_BUTTON(offset_spin_button)((((GtkSpinButton*) g_type_check_instance_cast ((GTypeInstance *) ((offset_spin_button)), ((gtk_spin_button_get_type ()))))) ), |
2420 | s->offset); |
2421 | } |
2422 | if (s->type == SENSOR_VOLTAGE2) |
2423 | draw_voltages(s, FALSE(0)); |
2424 | else |
2425 | { |
2426 | gkrellm_cpu_draw_sensors(s); |
2427 | gkrellm_proc_draw_sensors(s); |
2428 | draw_temperatures(FALSE(0)); |
2429 | } |
2430 | } |
2431 | |
2432 | static void |
2433 | cb_tree_selection_changed(GtkTreeSelection *selection, gpointer data) |
2434 | { |
2435 | GtkTreeIter iter; |
2436 | GtkTreeModel *model; |
2437 | GtkTreePath *path; |
2438 | Sensor *s; |
2439 | gint depth; |
2440 | |
2441 | if (!gtk_tree_selection_get_selected(selection, &model, &iter)) |
2442 | { |
2443 | change_row_reference(NULL((void*)0), NULL((void*)0)); |
2444 | set_sensor_widget_states(NULL((void*)0)); |
2445 | return; |
2446 | } |
2447 | path = gtk_tree_model_get_path(model, &iter); |
2448 | depth = gtk_tree_path_get_depth(path); |
2449 | change_row_reference(model, path); |
2450 | gtk_tree_path_free(path); |
2451 | |
2452 | if (depth == 1) |
2453 | { |
2454 | set_sensor_widget_states(NULL((void*)0)); |
2455 | return; |
2456 | } |
2457 | s = get_referenced_sensor(); |
2458 | set_sensor_widget_states(s); |
2459 | } |
2460 | |
2461 | static void |
2462 | label_edited_cb(GtkCellRendererText *cell, gchar *path_string, |
2463 | gchar *new_label, gpointer data) |
2464 | { |
2465 | GtkTreeModel *model; |
2466 | GtkTreeIter iter; |
2467 | GtkTreePath *path; |
2468 | Sensor *s; |
2469 | |
2470 | model = sensor_model; |
2471 | path = gtk_tree_path_new_from_string(path_string); |
2472 | gtk_tree_model_get_iter(model, &iter, path); |
2473 | gtk_tree_path_free(path); |
2474 | |
2475 | gtk_tree_model_get(model, &iter, |
2476 | SENSOR_COLUMN, &s, |
2477 | -1); |
2478 | if (!*new_label) |
2479 | new_label = s->default_label; |
2480 | |
2481 | gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) g_type_check_instance_cast ((GTypeInstance *) ((model)), ((gtk_tree_store_get_type ())))))), &iter, |
2482 | LABEL_COLUMN, new_label, -1); |
2483 | |
2484 | if (gkrellm_locale_dup_string(&s->name, new_label, &s->name_locale)) |
2485 | { |
2486 | gkrellm_sensors_rebuild(s->type == SENSOR_TEMPERATURE0, |
2487 | s->type == SENSOR_FAN1, s->type == SENSOR_VOLTAGE2); |
2488 | if (s->alert) |
2489 | { |
2490 | g_free(s->alert->name); |
2491 | s->alert->name = g_strdup(s->name); |
2492 | // gkrellm_reset_alert(s->alert); |
2493 | } |
2494 | } |
2495 | } |
2496 | |
2497 | static void |
2498 | enable_cb(GtkCellRendererText *cell, gchar *path_string, gpointer data) |
2499 | { |
2500 | GtkTreeModel *model; |
2501 | GtkTreeIter iter; |
2502 | GtkTreePath *path; |
2503 | Sensor *s; |
2504 | gboolean enabled; |
2505 | |
2506 | model = sensor_model; |
2507 | path = gtk_tree_path_new_from_string(path_string); |
2508 | gtk_tree_model_get_iter(model, &iter, path); |
2509 | |
2510 | gtk_tree_model_get(model, &iter, |
2511 | ENABLE_COLUMN, &enabled, |
2512 | SENSOR_COLUMN, &s, |
2513 | -1); |
2514 | s->enabled = !enabled; |
2515 | gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) g_type_check_instance_cast ((GTypeInstance *) ((model)), ((gtk_tree_store_get_type ())))))), &iter, |
2516 | ENABLE_COLUMN, s->enabled, |
2517 | -1); |
2518 | change_row_reference(model, path); |
2519 | gtk_tree_path_free(path); |
2520 | |
2521 | gkrellm_sensors_rebuild(s->type == SENSOR_TEMPERATURE0, |
2522 | s->type == SENSOR_FAN1, s->type == SENSOR_VOLTAGE2); |
2523 | |
2524 | set_sensor_widget_states(s); |
2525 | } |
2526 | |
2527 | static void |
2528 | fix_temp_alert(Sensor *s) |
2529 | { |
2530 | GkrellmAlert *a = s->alert; |
2531 | |
2532 | if (s->type != SENSOR_TEMPERATURE0 || !a) |
2533 | return; |
2534 | if (units_fahrenheit) |
2535 | { |
2536 | if (a->high.warn_limit > 0) |
2537 | a->high.warn_limit = a->high.warn_limit * 9.0 / 5.0 + 32.0; |
2538 | if (a->high.alarm_limit > 0) |
2539 | a->high.alarm_limit = a->high.alarm_limit * 9.0 / 5.0 + 32.0; |
2540 | } |
2541 | else |
2542 | { |
2543 | if (a->high.warn_limit > 0) |
2544 | a->high.warn_limit = (a->high.warn_limit - 32.0) * 5.0 / 9.0; |
2545 | if (a->high.alarm_limit > 0) |
2546 | a->high.alarm_limit = (a->high.alarm_limit - 32.0) * 5.0 / 9.0; |
2547 | } |
2548 | gkrellm_alert_window_destroy(&s->alert); |
2549 | } |
2550 | |
2551 | static void |
2552 | sysdep_option_cb(GtkWidget *button, SysdepOption *so) |
2553 | { |
2554 | if (!so) |
2555 | return; |
2556 | so->value = GTK_TOGGLE_BUTTON(button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance *) ((button)), ((gtk_toggle_button_get_type ()))))))->active; |
2557 | } |
2558 | |
2559 | static void |
2560 | cb_temperature_units(GtkWidget *button, gpointer data) |
2561 | { |
2562 | GList *list; |
2563 | gint units; |
2564 | |
2565 | units = GTK_TOGGLE_BUTTON(button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance *) ((button)), ((gtk_toggle_button_get_type ()))))))->active; |
2566 | if (units == units_fahrenheit) |
2567 | return; |
2568 | units_fahrenheit = units; |
2569 | |
2570 | for (list = sensor_list; list; list = list->next) |
2571 | fix_temp_alert((Sensor *) list->data); |
2572 | |
2573 | gkrellm_sensors_rebuild(DO_TEMP1, FALSE(0), FALSE(0)); |
2574 | gkrellm_cpu_draw_sensors(NULL((void*)0)); |
2575 | gkrellm_proc_draw_sensors(NULL((void*)0)); |
2576 | } |
2577 | |
2578 | static void |
2579 | cb_show_units(GtkWidget *button, gpointer data) |
2580 | { |
2581 | gint show; |
2582 | |
2583 | show = GTK_TOGGLE_BUTTON(button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance *) ((button)), ((gtk_toggle_button_get_type ()))))))->active; |
2584 | if (show == show_units) |
2585 | return; |
2586 | show_units = show; |
2587 | |
2588 | gkrellm_sensors_rebuild(DO_TEMP1, FALSE(0), FALSE(0)); |
2589 | gkrellm_cpu_draw_sensors(NULL((void*)0)); |
2590 | gkrellm_proc_draw_sensors(NULL((void*)0)); |
2591 | } |
2592 | |
2593 | static void |
2594 | cb_voltages_display(GtkWidget *entry, gpointer data) |
2595 | { |
2596 | gint i; |
2597 | |
2598 | for (i = 0; i < N_DISPLAY_MODES2; ++i) |
2599 | if (GTK_TOGGLE_BUTTON(display_mode_button[i])((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance *) ((display_mode_button[i])), ((gtk_toggle_button_get_type ( )))))))->active) |
2600 | display_mode = i; |
2601 | gkrellm_sensors_rebuild(FALSE(0), FALSE(0), DO_VOLT1); |
2602 | } |
2603 | |
2604 | static void |
2605 | cb_set_alert(GtkWidget *widget, gpointer data) |
2606 | { |
2607 | Sensor *s; |
2608 | |
2609 | s = get_referenced_sensor(); |
2610 | if (!s || !s->enabled) |
2611 | return; |
2612 | if (!s->alert) |
2613 | create_sensor_alert(s); |
2614 | gkrellm_alert_config_window(&s->alert); |
2615 | } |
2616 | |
2617 | |
2618 | static void |
2619 | sensors_apply(void) |
2620 | { |
2621 | gchar *str; |
2622 | gint port; |
2623 | |
2624 | if (mbmon_port_entry) |
2625 | { |
2626 | str = gkrellm_gtk_entry_get_text(&mbmon_port_entry); |
2627 | if (isdigit((unsigned char)*str)((*__ctype_b_loc ())[(int) (((unsigned char)*str))] & (unsigned short int) _ISdigit)) |
2628 | { |
2629 | port = atoi(str); |
2630 | if (_GK.mbmon_port != port) |
2631 | { |
2632 | if (!gkrellm_sys_sensors_mbmon_port_change(port) && port > 0) |
2633 | gkrellm_message_dialog(NULL((void*)0), |
2634 | _("Can't read sensor data from mbmon daemon.\n"dcgettext ("gkrellm", "Can't read sensor data from mbmon daemon.\n" "Check mbmon port number and '-r' option.\n" "Run gkrellm -d 0x80 for debug output.\n" , 5) |
2635 | "Check mbmon port number and '-r' option.\n"dcgettext ("gkrellm", "Can't read sensor data from mbmon daemon.\n" "Check mbmon port number and '-r' option.\n" "Run gkrellm -d 0x80 for debug output.\n" , 5) |
2636 | "Run gkrellm -d 0x80 for debug output.\n")dcgettext ("gkrellm", "Can't read sensor data from mbmon daemon.\n" "Check mbmon port number and '-r' option.\n" "Run gkrellm -d 0x80 for debug output.\n" , 5)); |
2637 | } |
2638 | } |
2639 | } |
2640 | } |
2641 | |
2642 | static void |
2643 | mbmon_port_entry_activate_cb(GtkWidget *widget, gpointer data) |
2644 | { |
2645 | sensors_apply(); |
2646 | } |
2647 | |
2648 | static void |
2649 | cb_config_deleted(gpointer data) |
2650 | { |
2651 | treeview = NULL((void*)0); |
2652 | } |
2653 | |
2654 | static gchar *sensor_info_text0[] = |
2655 | { |
2656 | N_("<b>No sensors detected.\n")("<b>No sensors detected.\n"), |
2657 | "\n", |
2658 | }; |
2659 | |
2660 | static gchar *sensor_info_text1[] = |
2661 | { |
2662 | N_("<h>Setup\n")("<h>Setup\n"), |
2663 | N_("Enter data scaling factors and offsets for the sensors if the default\n"("Enter data scaling factors and offsets for the sensors if the default\n" "values are not correct for your motherboard. Do a man gkrellm or\n" "see the GKrellM README for more information.\n") |
2664 | "values are not correct for your motherboard. Do a man gkrellm or\n"("Enter data scaling factors and offsets for the sensors if the default\n" "values are not correct for your motherboard. Do a man gkrellm or\n" "see the GKrellM README for more information.\n") |
2665 | "see the GKrellM README for more information.\n")("Enter data scaling factors and offsets for the sensors if the default\n" "values are not correct for your motherboard. Do a man gkrellm or\n" "see the GKrellM README for more information.\n"), |
2666 | N_("Enter a zero factor and a blank label to restore default values.\n")("Enter a zero factor and a blank label to restore default values.\n" ), |
2667 | "\n", |
2668 | N_("Drag and drop sensor rows to change the displayed order.\n")("Drag and drop sensor rows to change the displayed order.\n" ), |
2669 | "\n", |
2670 | N_("Temperature offset values must be in centigrade units.\n")("Temperature offset values must be in centigrade units.\n"), |
2671 | "\n", |
2672 | N_("Substitution variables may be used in alert commands.\n")("Substitution variables may be used in alert commands.\n"), |
2673 | N_("\t$s current sensor value.\n")("\t$s current sensor value.\n"), |
2674 | N_("\t$l sensor label.\n")("\t$l sensor label.\n"), |
2675 | }; |
2676 | |
2677 | static void |
2678 | sensors_tab_destroy(GtkWidget *w, gpointer data) |
2679 | { |
2680 | optionmenu = NULL((void*)0); |
2681 | } |
2682 | |
2683 | static void |
2684 | create_sensors_tab(GtkWidget *tab_vbox) |
2685 | { |
2686 | GtkWidget *tabs; |
2687 | GtkWidget *button; |
2688 | GtkWidget *text; |
2689 | GtkWidget *vbox, *vbox1, *hbox, *box; |
2690 | GtkWidget *scrolled; |
2691 | GtkWidget *image; |
2692 | GtkWidget *label, *entry; |
2693 | GtkTreeModel *model; |
2694 | GtkCellRenderer *renderer; |
2695 | GList *list; |
2696 | SysdepOption *so; |
2697 | gchar buf[32]; |
2698 | gint i; |
2699 | |
2700 | row_reference = NULL((void*)0); |
2701 | sensor_last_group = -1; |
2702 | |
2703 | tabs = gtk_notebook_new(); |
2704 | gtk_notebook_set_tab_pos(GTK_NOTEBOOK(tabs)((((GtkNotebook*) g_type_check_instance_cast ((GTypeInstance* ) ((tabs)), ((gtk_notebook_get_type ())))))), GTK_POS_TOP); |
2705 | gtk_box_pack_start(GTK_BOX(tab_vbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((tab_vbox )), ((gtk_box_get_type ())))))), tabs, TRUE(!(0)), TRUE(!(0)), 0); |
2706 | |
2707 | g_signal_connect(GTK_OBJECT(tabs), "destroy",g_signal_connect_data ((((((GtkObject*) g_type_check_instance_cast ((GTypeInstance*) ((tabs)), ((gtk_object_get_type ()))))))), ("destroy"), (((GCallback) (sensors_tab_destroy))), (((void* )0)), ((void*)0), (GConnectFlags) 0) |
2708 | G_CALLBACK(sensors_tab_destroy), NULL)g_signal_connect_data ((((((GtkObject*) g_type_check_instance_cast ((GTypeInstance*) ((tabs)), ((gtk_object_get_type ()))))))), ("destroy"), (((GCallback) (sensors_tab_destroy))), (((void* )0)), ((void*)0), (GConnectFlags) 0); |
2709 | |
2710 | /* --Setup tab */ |
2711 | vbox = gkrellm_gtk_framed_notebook_page(tabs, _("Setup")dcgettext ("gkrellm", "Setup", 5)); |
2712 | hbox = gtk_hbox_new(FALSE(0), 2); |
2713 | gtk_box_pack_start(GTK_BOX(vbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((vbox )), ((gtk_box_get_type ())))))), hbox, TRUE(!(0)), TRUE(!(0)), 0); |
2714 | vbox1 = gtk_vbox_new(FALSE(0), 0); |
2715 | gtk_box_pack_end(GTK_BOX(hbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((hbox )), ((gtk_box_get_type ())))))), vbox1, FALSE(0), FALSE(0), 5); |
2716 | |
2717 | scrolled = gtk_scrolled_window_new(NULL((void*)0), NULL((void*)0)); |
2718 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled)((((GtkScrolledWindow*) g_type_check_instance_cast ((GTypeInstance *) ((scrolled)), ((gtk_scrolled_window_get_type ())))))), |
2719 | GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
2720 | gtk_box_pack_start(GTK_BOX(hbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((hbox )), ((gtk_box_get_type ())))))), scrolled, TRUE(!(0)), TRUE(!(0)), 0); |
2721 | |
2722 | model = create_model(); |
2723 | sensor_model = model; |
2724 | |
2725 | treeview = GTK_TREE_VIEW(gtk_tree_view_new_with_model(model))((((GtkTreeView*) g_type_check_instance_cast ((GTypeInstance* ) ((gtk_tree_view_new_with_model(model))), ((gtk_tree_view_get_type ())))))); |
2726 | gtk_tree_view_set_rules_hint(treeview, TRUE(!(0))); |
2727 | gtk_tree_view_set_reorderable(treeview, TRUE(!(0))); |
2728 | g_signal_connect(G_OBJECT(treeview), "drag_begin",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((treeview)), (((GType) ((20) << (2) )))))))), ("drag_begin"), (((GCallback) (cb_drag_begin))), (( (void*)0)), ((void*)0), (GConnectFlags) 0) |
2729 | G_CALLBACK(cb_drag_begin), NULL)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((treeview)), (((GType) ((20) << (2) )))))))), ("drag_begin"), (((GCallback) (cb_drag_begin))), (( (void*)0)), ((void*)0), (GConnectFlags) 0); |
2730 | g_signal_connect(G_OBJECT(treeview), "drag_end",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((treeview)), (((GType) ((20) << (2) )))))))), ("drag_end"), (((GCallback) (cb_drag_end))), (((void *)0)), ((void*)0), (GConnectFlags) 0) |
2731 | G_CALLBACK(cb_drag_end), NULL)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((treeview)), (((GType) ((20) << (2) )))))))), ("drag_end"), (((GCallback) (cb_drag_end))), (((void *)0)), ((void*)0), (GConnectFlags) 0); |
2732 | g_signal_connect(G_OBJECT(treeview), "delete_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((treeview)), (((GType) ((20) << (2) )))))))), ("delete_event"), (((GCallback) (cb_config_deleted) )), (((void*)0)), ((void*)0), (GConnectFlags) 0) |
2733 | G_CALLBACK(cb_config_deleted), NULL)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((treeview)), (((GType) ((20) << (2) )))))))), ("delete_event"), (((GCallback) (cb_config_deleted) )), (((void*)0)), ((void*)0), (GConnectFlags) 0); |
2734 | |
2735 | renderer = gtk_cell_renderer_text_new(); |
2736 | gtk_tree_view_insert_column_with_attributes(treeview, -1, _("Sensor")dcgettext ("gkrellm", "Sensor", 5), |
2737 | renderer, |
2738 | "text", NAME_COLUMN, |
2739 | NULL((void*)0)); |
2740 | |
2741 | renderer = gtk_cell_renderer_toggle_new(); |
2742 | gtk_tree_view_insert_column_with_attributes(treeview, -1, _("Enable")dcgettext ("gkrellm", "Enable", 5), |
2743 | renderer, |
2744 | "active", ENABLE_COLUMN, |
2745 | "visible", VISIBLE_COLUMN, |
2746 | NULL((void*)0)); |
2747 | g_signal_connect(G_OBJECT(renderer), "toggled",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((renderer)), (((GType) ((20) << (2) )))))))), ("toggled"), (((GCallback) (enable_cb))), (((void*) 0)), ((void*)0), (GConnectFlags) 0) |
2748 | G_CALLBACK(enable_cb), NULL)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((renderer)), (((GType) ((20) << (2) )))))))), ("toggled"), (((GCallback) (enable_cb))), (((void*) 0)), ((void*)0), (GConnectFlags) 0); |
2749 | |
2750 | renderer = gtk_cell_renderer_text_new(); |
2751 | gtk_tree_view_insert_column_with_attributes(treeview, -1, _("Label")dcgettext ("gkrellm", "Label", 5), |
2752 | renderer, |
2753 | "text", LABEL_COLUMN, |
2754 | "editable", TRUE(!(0)), |
2755 | "visible", VISIBLE_COLUMN, |
2756 | NULL((void*)0)); |
2757 | g_signal_connect(G_OBJECT(renderer), "edited",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((renderer)), (((GType) ((20) << (2) )))))))), ("edited"), (((GCallback) (label_edited_cb))), (((void *)0)), ((void*)0), (GConnectFlags) 0) |
2758 | G_CALLBACK(label_edited_cb), NULL)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((renderer)), (((GType) ((20) << (2) )))))))), ("edited"), (((GCallback) (label_edited_cb))), (((void *)0)), ((void*)0), (GConnectFlags) 0); |
2759 | |
2760 | renderer = gtk_cell_renderer_pixbuf_new(); |
2761 | gtk_tree_view_insert_column_with_attributes(treeview, -1, "", |
2762 | renderer, |
2763 | "pixbuf", IMAGE_COLUMN, |
2764 | NULL((void*)0)); |
2765 | |
2766 | |
2767 | gtk_container_add(GTK_CONTAINER(scrolled)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance *) ((scrolled)), ((gtk_container_get_type ())))))), GTK_WIDGET(treeview)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) ( (treeview)), ((gtk_widget_get_type ()))))))); |
2768 | |
2769 | selection = gtk_tree_view_get_selection(treeview); |
2770 | gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE); |
2771 | g_signal_connect(G_OBJECT(selection), "changed",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((selection)), (((GType) ((20) << (2 ))))))))), ("changed"), (((GCallback) (cb_tree_selection_changed ))), (((void*)0)), ((void*)0), (GConnectFlags) 0) |
2772 | G_CALLBACK(cb_tree_selection_changed), NULL)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((selection)), (((GType) ((20) << (2 ))))))))), ("changed"), (((GCallback) (cb_tree_selection_changed ))), (((void*)0)), ((void*)0), (GConnectFlags) 0); |
2773 | |
2774 | box = gkrellm_gtk_framed_vbox(vbox1, _("Factor")dcgettext ("gkrellm", "Factor", 5), 4, FALSE(0), 0, 2); |
2775 | gkrellm_gtk_spin_button(box, &factor_spin_button, 1.0, |
2776 | -1000.0, 1000.0, 0.01, 1.0, 4, 60, |
2777 | cb_correction_modified, NULL((void*)0), FALSE(0), NULL((void*)0)); |
2778 | |
2779 | box = gkrellm_gtk_framed_vbox(vbox1, _("Offset")dcgettext ("gkrellm", "Offset", 5), 4, FALSE(0), 0, 2); |
2780 | gkrellm_gtk_spin_button(box, &offset_spin_button, 0.0, |
2781 | -10000.0, 10000.0, 1.0, 5.0, 3, 60, |
2782 | cb_correction_modified, NULL((void*)0), FALSE(0), NULL((void*)0)); |
2783 | |
2784 | box = gkrellm_gtk_framed_vbox(vbox1, _("Location")dcgettext ("gkrellm", "Location", 5), 2, FALSE(0), 0, 2); |
2785 | |
2786 | optionmenu = gtk_combo_box_new_text(); |
2787 | |
2788 | gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box )), ((gtk_box_get_type ())))))), optionmenu, FALSE(0), FALSE(0), 4); |
2789 | |
2790 | box = gtk_hbox_new(FALSE(0), 0); |
2791 | gtk_container_set_border_width(GTK_CONTAINER(box)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance *) ((box)), ((gtk_container_get_type ())))))), 2); |
2792 | image = gtk_image_new_from_pixbuf(gkrellm_alert_pixbuf()); |
2793 | label = gtk_label_new(_("Alerts")dcgettext ("gkrellm", "Alerts", 5)); |
2794 | gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box )), ((gtk_box_get_type ())))))), image, FALSE(0), FALSE(0), 3); |
2795 | gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box )), ((gtk_box_get_type ())))))), label, FALSE(0), FALSE(0), 3); |
2796 | alert_button = gtk_button_new(); |
2797 | g_signal_connect(G_OBJECT(alert_button), "clicked",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((alert_button)), (((GType) ((20) << (2))))))))), ("clicked"), (((GCallback) (cb_set_alert))), (( (void*)0)), ((void*)0), (GConnectFlags) 0) |
2798 | G_CALLBACK(cb_set_alert), NULL)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((alert_button)), (((GType) ((20) << (2))))))))), ("clicked"), (((GCallback) (cb_set_alert))), (( (void*)0)), ((void*)0), (GConnectFlags) 0); |
2799 | gtk_widget_show_all(box); |
2800 | gtk_container_add(GTK_CONTAINER(alert_button)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance *) ((alert_button)), ((gtk_container_get_type ())))))), box); |
2801 | gtk_box_pack_end(GTK_BOX(vbox1)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((vbox1 )), ((gtk_box_get_type ())))))), alert_button, FALSE(0), FALSE(0), 4); |
2802 | |
2803 | // gkrellm_gtk_button_connected(vbox1, &alert_button, FALSE, FALSE, -5, |
2804 | // cb_set_alert, NULL, "Alerts"); |
2805 | |
2806 | set_sensor_widget_states(NULL((void*)0)); |
2807 | |
2808 | /* -- Options tab */ |
2809 | vbox = gkrellm_gtk_framed_notebook_page(tabs, _("Options")dcgettext ("gkrellm", "Options", 5)); |
2810 | // box = gkrellm_gtk_framed_vbox(vbox, _("Temperatures"), 4, FALSE, 0, 2); |
2811 | box = gkrellm_gtk_category_vbox(vbox, _("Temperatures")dcgettext ("gkrellm", "Temperatures", 5), 4, 0, TRUE(!(0))); |
2812 | gkrellm_gtk_check_button_connected(box, &button, |
2813 | units_fahrenheit, FALSE(0), FALSE(0), 0, |
2814 | cb_temperature_units, NULL((void*)0), |
2815 | _("Display fahrenheit")dcgettext ("gkrellm", "Display fahrenheit", 5)); |
2816 | gkrellm_gtk_check_button_connected(box, &button, |
2817 | show_units, FALSE(0), FALSE(0), 0, |
2818 | cb_show_units, NULL((void*)0), |
2819 | _("Show units")dcgettext ("gkrellm", "Show units", 5)); |
2820 | if (!sensor_list) |
2821 | gtk_widget_set_sensitive(button, FALSE(0)); |
2822 | |
2823 | // box = gkrellm_gtk_framed_vbox(vbox, _("Voltages"), 6, FALSE, 0, 2); |
2824 | box = gkrellm_gtk_category_vbox(vbox, _("Voltages")dcgettext ("gkrellm", "Voltages", 5), 4, 0, TRUE(!(0))); |
2825 | button = gtk_radio_button_new_with_label(NULL((void*)0), |
2826 | _("Normal with labels")dcgettext ("gkrellm", "Normal with labels", 5)); |
2827 | gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box )), ((gtk_box_get_type ())))))), button, FALSE(0), TRUE(!(0)), 0); |
2828 | display_mode_button[DIGITAL_WITH_LABELS0] = button; |
2829 | g_signal_connect(G_OBJECT(button), "toggled",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((button)), (((GType) ((20) << (2))) )))))), ("toggled"), (((GCallback) (cb_voltages_display))), ( ((void*)0)), ((void*)0), (GConnectFlags) 0) |
2830 | G_CALLBACK(cb_voltages_display), NULL)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((button)), (((GType) ((20) << (2))) )))))), ("toggled"), (((GCallback) (cb_voltages_display))), ( ((void*)0)), ((void*)0), (GConnectFlags) 0); |
2831 | if (!sensor_list) |
2832 | gtk_widget_set_sensitive(button, FALSE(0)); |
2833 | |
2834 | button = gtk_radio_button_new_with_label( |
2835 | gtk_radio_button_get_group(GTK_RADIO_BUTTON (button)((((GtkRadioButton*) g_type_check_instance_cast ((GTypeInstance *) ((button)), ((gtk_radio_button_get_type ()))))))), |
2836 | _("Compact with no labels")dcgettext ("gkrellm", "Compact with no labels", 5)); |
2837 | gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box )), ((gtk_box_get_type ())))))), button, FALSE(0), TRUE(!(0)), 0); |
2838 | display_mode_button[DIGITAL_NO_LABELS1] = button; |
2839 | if (!sensor_list) |
2840 | gtk_widget_set_sensitive(button, FALSE(0)); |
2841 | |
2842 | if (sysdep_option_list) |
2843 | { |
2844 | box = gkrellm_gtk_category_vbox(vbox, _("Options")dcgettext ("gkrellm", "Options", 5), 4, 0, TRUE(!(0))); |
2845 | for (list = sysdep_option_list; list; list = list->next) |
2846 | { |
2847 | so= (SysdepOption *) list->data; |
2848 | if (so->config_label) |
2849 | gkrellm_gtk_check_button_connected(box, NULL((void*)0), |
2850 | so->value, FALSE(0), FALSE(0), 0, |
2851 | sysdep_option_cb, so, |
2852 | so->config_label); |
2853 | } |
2854 | } |
2855 | |
2856 | button = display_mode_button[display_mode]; |
2857 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance *) ((button)), ((gtk_toggle_button_get_type ())))))), TRUE(!(0))); |
2858 | |
2859 | if (gkrellm_sys_sensors_mbmon_supported()) |
2860 | { |
2861 | box = gkrellm_gtk_category_vbox(vbox, _("MBmon Daemon Port")dcgettext ("gkrellm", "MBmon Daemon Port", 5), |
2862 | 4, 0, TRUE(!(0))); |
2863 | label = gtk_label_new(""); |
2864 | gtk_label_set_use_markup(GTK_LABEL(label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) ( (label)), ((gtk_label_get_type ())))))), TRUE(!(0))); |
2865 | gtk_label_set_markup(GTK_LABEL(label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) ( (label)), ((gtk_label_get_type ())))))), |
2866 | _("<small>Daemon command must be: <b>mbmon -r -P port</b>\n"dcgettext ("gkrellm", "<small>Daemon command must be: <b>mbmon -r -P port</b>\n" "where 'port' must match the port number entered here:</small>" , 5) |
2867 | "where 'port' must match the port number entered here:</small>")dcgettext ("gkrellm", "<small>Daemon command must be: <b>mbmon -r -P port</b>\n" "where 'port' must match the port number entered here:</small>" , 5)); |
2868 | gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box )), ((gtk_box_get_type ())))))), label, FALSE(0), FALSE(0), 0); |
2869 | hbox = gtk_hbox_new(FALSE(0), 2); |
2870 | gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box )), ((gtk_box_get_type ())))))), hbox, TRUE(!(0)), TRUE(!(0)), 0); |
2871 | entry = gtk_entry_new(); |
2872 | gtk_entry_set_max_length(GTK_ENTRY(entry)((((GtkEntry*) g_type_check_instance_cast ((GTypeInstance*) ( (entry)), ((gtk_entry_get_type ())))))), 6); |
2873 | mbmon_port_entry = entry; |
2874 | if (_GK.mbmon_port > 0) |
2875 | { |
2876 | snprintf(buf, sizeof(buf), "%d", _GK.mbmon_port); |
2877 | gtk_entry_set_text(GTK_ENTRY(entry)((((GtkEntry*) g_type_check_instance_cast ((GTypeInstance*) ( (entry)), ((gtk_entry_get_type ())))))), buf); |
2878 | } |
2879 | gtk_box_pack_start(GTK_BOX(hbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((hbox )), ((gtk_box_get_type ())))))), entry, FALSE(0), FALSE(0), 4); |
2880 | label = gtk_label_new( |
2881 | _("See the README or do a \"man gkrellm\" for more information.\n")dcgettext ("gkrellm", "See the README or do a \"man gkrellm\" for more information.\n" , 5)); |
2882 | gtk_label_set_justify(GTK_LABEL(label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) ( (label)), ((gtk_label_get_type ())))))), GTK_JUSTIFY_LEFT); |
2883 | gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box )), ((gtk_box_get_type ())))))), label, FALSE(0), FALSE(0), 4); |
2884 | |
2885 | g_signal_connect(G_OBJECT(mbmon_port_entry), "activate",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((mbmon_port_entry)), (((GType) ((20) << (2))))))))), ("activate"), (((GCallback) (mbmon_port_entry_activate_cb ))), (((void*)0)), ((void*)0), (GConnectFlags) 0) |
2886 | G_CALLBACK(mbmon_port_entry_activate_cb), NULL)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((mbmon_port_entry)), (((GType) ((20) << (2))))))))), ("activate"), (((GCallback) (mbmon_port_entry_activate_cb ))), (((void*)0)), ((void*)0), (GConnectFlags) 0); |
2887 | } |
2888 | |
2889 | /* --Info tab */ |
2890 | vbox = gkrellm_gtk_framed_notebook_page(tabs, _("Info")dcgettext ("gkrellm", "Info", 5)); |
2891 | text = gkrellm_gtk_scrolled_text_view(vbox, NULL((void*)0), |
2892 | GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
2893 | |
2894 | if (!sensor_list) |
2895 | for (i = 0; i < sizeof(sensor_info_text0) / sizeof(gchar *); ++i) |
2896 | gkrellm_gtk_text_view_append(text, _(sensor_info_text0[i])dcgettext ("gkrellm", sensor_info_text0[i], 5)); |
2897 | |
2898 | for (i = 0; i < sizeof(sensor_info_text1) / sizeof(gchar *); ++i) |
2899 | gkrellm_gtk_text_view_append(text, _(sensor_info_text1[i])dcgettext ("gkrellm", sensor_info_text1[i], 5)); |
2900 | |
2901 | /* Present as instant apply, but still get our apply function called. |
2902 | */ |
2903 | gkrellm_config_instant_apply(mon_config_sensors); |
2904 | } |
2905 | |
2906 | GkrellmMonitor * |
2907 | gkrellm_get_sensors_mon(void) |
2908 | { |
2909 | return mon_config_sensors; |
2910 | } |
2911 | |
2912 | static GkrellmMonitor monitor_config_sensors = |
2913 | { |
2914 | N_("Sensors")("Sensors"), /* Name, for config tab. */ |
2915 | -1, /* Id, 0 if a plugin */ |
2916 | NULL((void*)0), /* The create function */ |
2917 | NULL((void*)0), /* The update function */ |
2918 | create_sensors_tab, /* The config tab create function */ |
2919 | sensors_apply, |
2920 | |
2921 | save_sensors_config, /* Save user conifg */ |
2922 | load_sensors_config, /* Load user config */ |
2923 | SENSOR_CONFIG_KEYWORD"sensor", /* config keyword */ |
2924 | |
2925 | NULL((void*)0), /* Undef 2 */ |
2926 | NULL((void*)0), /* Undef 1 */ |
2927 | NULL((void*)0), /* Undef 0 */ |
2928 | |
2929 | 0, /* insert_before_id - place plugin before this mon */ |
2930 | |
2931 | NULL((void*)0), /* Handle if a plugin, filled in by GKrellM */ |
2932 | NULL((void*)0) /* path if a plugin, filled in by GKrellM */ |
2933 | }; |
2934 | |
2935 | GkrellmMonitor * |
2936 | gkrellm_init_sensors_config_monitor(void) |
2937 | { |
2938 | if (!setup_sensor_interface() && !_GK.demo) |
2939 | return NULL((void*)0); |
2940 | if (!_GK.client_mode) |
2941 | use_threads = TRUE(!(0)); |
2942 | sensor_list = g_list_sort(sensor_list, (GCompareFunc) strcmp_sensor_path); |
2943 | monitor_config_sensors.name = _(monitor_config_sensors.name)dcgettext ("gkrellm", monitor_config_sensors.name, 5); |
2944 | mon_config_sensors = &monitor_config_sensors; |
2945 | return &monitor_config_sensors; |
2946 | } |
2947 |