Bug Summary

File:rc/disk.c
Location:line 1451, column 2
Description:Value stored to 'vbox1' is never read

Annotated Source Code

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
39#define DISK_ASSIGN_BY_DEVICE0 0
40#define DISK_ASSIGN_NTH1 1
41#define DISK_ASSIGN_BY_NAME2 2
42
43#define DISK_CONFIG_KEYWORD"disk" "disk"
44
45#define MIN_GRID_RES10 10
46#define MAX_GRID_RES100000000 100000000
47#define DEFAULT_GRID_RES2000 2000
48
49typedef struct
50 {
51 gchar *name,
52 *label; /* Possibly translated name */
53 GtkWidget *vbox;
54 GtkWidget *enable_button;
55 GkrellmChart *chart;
56 GkrellmChartdata *read_cd,
57 *write_cd;
58 GkrellmChartconfig *chart_config;
59 GkrellmAlert *alert;
60 GtkWidget *alert_config_read_button,
61 *alert_config_write_button;
62 gboolean alert_uses_read,
63 alert_uses_write,
64 new_text_format;
65
66 GkrellmDecal *temp_decal;
67 gint save_label_position;
68
69 gint enabled;
70 gint major,
71 minor,
72 subdisk,
73 order;
74 gint new_disk;
75 gint extra_info;
76 GkrellmLauncher launch;
77 GtkWidget *launch_entry,
78 *tooltip_entry;
79 GtkWidget *launch_table;
80
81 guint64 rb,
82 wb;
83 }
84 DiskMon;
85
86
87static void cb_alert_config(GkrellmAlert *ap, DiskMon *disk);
88static void cb_alert_config_create(GkrellmAlert *ap, GtkWidget *vbox,
89 DiskMon *disk);
90
91
92static GkrellmMonitor *mon_disk;
93
94static gint n_disks;
95static GList *disk_mon_list;
96
97
98static DiskMon *composite_disk;
99static gint ascent;
100static gint style_id;
101static gint assign_method;
102static gboolean sys_handles_composite_reset;
103static gboolean units_are_blocks;
104
105static void (*read_disk_data)();
106static gchar *(*name_from_device)();
107static gint (*order_from_name)();
108
109
110
111DiskMon *
112lookup_disk_by_device(gint major, gint minor)
113 {
114 DiskMon *disk;
115 GList *list;
116
117 for (list = disk_mon_list->next; list; list = list->next)
118 {
119 disk = (DiskMon * ) list->data;
120 if (disk->major == major && disk->minor == minor)
121 return disk;
122 }
123 return NULL((void*)0);
124 }
125
126static DiskMon *
127lookup_disk_by_name(const gchar *name)
128 {
129 DiskMon *disk;
130 GList *list;
131
132 for (list = disk_mon_list; list; list = list->next)
133 {
134 disk = (DiskMon * ) list->data;
135 if (!strcmp(name, disk->name)__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
(name) && __builtin_constant_p (disk->name) &&
(__s1_len = strlen (name), __s2_len = strlen (disk->name)
, (!((size_t)(const void *)((name) + 1) - (size_t)(const void
*)(name) == 1) || __s1_len >= 4) && (!((size_t)(const
void *)((disk->name) + 1) - (size_t)(const void *)(disk->
name) == 1) || __s2_len >= 4)) ? __builtin_strcmp (name, disk
->name) : (__builtin_constant_p (name) && ((size_t
)(const void *)((name) + 1) - (size_t)(const void *)(name) ==
1) && (__s1_len = strlen (name), __s1_len < 4) ? (
__builtin_constant_p (disk->name) && ((size_t)(const
void *)((disk->name) + 1) - (size_t)(const void *)(disk->
name) == 1) ? __builtin_strcmp (name, disk->name) : (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) (disk->name); int __result = (((const unsigned char
*) (const char *) (name))[0] - __s2[0]); if (__s1_len > 0
&& __result == 0) { __result = (((const unsigned char
*) (const char *) (name))[1] - __s2[1]); if (__s1_len > 1
&& __result == 0) { __result = (((const unsigned char
*) (const char *) (name))[2] - __s2[2]); if (__s1_len > 2
&& __result == 0) __result = (((const unsigned char *
) (const char *) (name))[3] - __s2[3]); } } __result; }))) : (
__builtin_constant_p (disk->name) && ((size_t)(const
void *)((disk->name) + 1) - (size_t)(const void *)(disk->
name) == 1) && (__s2_len = strlen (disk->name), __s2_len
< 4) ? (__builtin_constant_p (name) && ((size_t)(
const void *)((name) + 1) - (size_t)(const void *)(name) == 1
) ? __builtin_strcmp (name, disk->name) : (- (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) (name); int __result = (((const unsigned char *) (const
char *) (disk->name))[0] - __s2[0]); if (__s2_len > 0 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) (disk->name))[1] - __s2[1]); if (__s2_len > 1 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) (disk->name))[2] - __s2[2]); if (__s2_len > 2 &&
__result == 0) __result = (((const unsigned char *) (const char
*) (disk->name))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp
(name, disk->name)))); })
)
136 return disk;
137
138 /* Pre 2.1.15 config compatibility where translated "Disk" was
139 | written into the config. XXX remove this eventually.
140 */
141 if ( (disk == composite_disk || assign_method == DISK_ASSIGN_NTH1)
142 && !strcmp(name, disk->label)__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
(name) && __builtin_constant_p (disk->label) &&
(__s1_len = strlen (name), __s2_len = strlen (disk->label
), (!((size_t)(const void *)((name) + 1) - (size_t)(const void
*)(name) == 1) || __s1_len >= 4) && (!((size_t)(const
void *)((disk->label) + 1) - (size_t)(const void *)(disk->
label) == 1) || __s2_len >= 4)) ? __builtin_strcmp (name, disk
->label) : (__builtin_constant_p (name) && ((size_t
)(const void *)((name) + 1) - (size_t)(const void *)(name) ==
1) && (__s1_len = strlen (name), __s1_len < 4) ? (
__builtin_constant_p (disk->label) && ((size_t)(const
void *)((disk->label) + 1) - (size_t)(const void *)(disk->
label) == 1) ? __builtin_strcmp (name, disk->label) : (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) (disk->label); int __result = (((const unsigned char
*) (const char *) (name))[0] - __s2[0]); if (__s1_len > 0
&& __result == 0) { __result = (((const unsigned char
*) (const char *) (name))[1] - __s2[1]); if (__s1_len > 1
&& __result == 0) { __result = (((const unsigned char
*) (const char *) (name))[2] - __s2[2]); if (__s1_len > 2
&& __result == 0) __result = (((const unsigned char *
) (const char *) (name))[3] - __s2[3]); } } __result; }))) : (
__builtin_constant_p (disk->label) && ((size_t)(const
void *)((disk->label) + 1) - (size_t)(const void *)(disk->
label) == 1) && (__s2_len = strlen (disk->label), __s2_len
< 4) ? (__builtin_constant_p (name) && ((size_t)(
const void *)((name) + 1) - (size_t)(const void *)(name) == 1
) ? __builtin_strcmp (name, disk->label) : (- (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) (name); int __result = (((const unsigned char *) (const
char *) (disk->label))[0] - __s2[0]); if (__s2_len > 0
&& __result == 0) { __result = (((const unsigned char
*) (const char *) (disk->label))[1] - __s2[1]); if (__s2_len
> 1 && __result == 0) { __result = (((const unsigned
char *) (const char *) (disk->label))[2] - __s2[2]); if (
__s2_len > 2 && __result == 0) __result = (((const
unsigned char *) (const char *) (disk->label))[3] - __s2[
3]); } } __result; })))) : __builtin_strcmp (name, disk->label
)))); })
)
143 return disk;
144 }
145 return NULL((void*)0);
146 }
147
148static DiskMon *
149disk_new(const gchar *name, const gchar *label)
150 {
151 DiskMon *disk;
152
153 disk = g_new0(DiskMon, 1)(DiskMon *) (__extension__ ({ gsize __n = (gsize) (1); gsize __s
= sizeof (DiskMon); 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
; }))
;
154 disk->name = g_strdup(name);
155 disk->label = g_strdup(label);
156 disk->launch.command = g_strdup("");
157 disk->launch.tooltip_comment = g_strdup("");
158 disk->alert_uses_read = disk->alert_uses_write = TRUE(!(0));
159 disk->extra_info = TRUE(!(0));
160 return disk;
161 }
162
163static DiskMon *
164add_disk(const gchar *name, const gchar *label, gint major, gint minor, gint order)
165 {
166 DiskMon *disk;
167 GList *list;
168 gint i;
169
170 if (lookup_disk_by_name(name))
171 return NULL((void*)0);
172 disk = disk_new(name, label);
173
174 disk->major = major;
175 disk->minor = minor;
176 disk->order = order;
177 disk->subdisk = -1;
178 if (order >= 0)
179 {
180 ++disk->order; /* Skip the composite disk */
181 for (i = 1, list = disk_mon_list->next; list; list = list->next, ++i)
182 if (disk->order < ((DiskMon *) list->data)->order)
183 break;
184 disk_mon_list = g_list_insert(disk_mon_list, disk, i);
185 }
186 else
187 disk_mon_list = g_list_append(disk_mon_list, disk);
188 ++n_disks;
189 return disk;
190 }
191
192static DiskMon *
193add_subdisk(const gchar *subdisk_name, const gchar *disk_name, gint subdisk)
194 {
195 DiskMon *disk, *sdisk;
196 GList *list = NULL((void*)0);
197
198 for (list = disk_mon_list->next; list; list = list->next)
199 {
200 disk = (DiskMon * ) list->data;
201 if (!strcmp(disk_name, disk->name)__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
(disk_name) && __builtin_constant_p (disk->name) &&
(__s1_len = strlen (disk_name), __s2_len = strlen (disk->
name), (!((size_t)(const void *)((disk_name) + 1) - (size_t)(
const void *)(disk_name) == 1) || __s1_len >= 4) &&
(!((size_t)(const void *)((disk->name) + 1) - (size_t)(const
void *)(disk->name) == 1) || __s2_len >= 4)) ? __builtin_strcmp
(disk_name, disk->name) : (__builtin_constant_p (disk_name
) && ((size_t)(const void *)((disk_name) + 1) - (size_t
)(const void *)(disk_name) == 1) && (__s1_len = strlen
(disk_name), __s1_len < 4) ? (__builtin_constant_p (disk->
name) && ((size_t)(const void *)((disk->name) + 1)
- (size_t)(const void *)(disk->name) == 1) ? __builtin_strcmp
(disk_name, disk->name) : (__extension__ ({ const unsigned
char *__s2 = (const unsigned char *) (const char *) (disk->
name); int __result = (((const unsigned char *) (const char *
) (disk_name))[0] - __s2[0]); if (__s1_len > 0 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
disk_name))[1] - __s2[1]); if (__s1_len > 1 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
disk_name))[2] - __s2[2]); if (__s1_len > 2 && __result
== 0) __result = (((const unsigned char *) (const char *) (disk_name
))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p (
disk->name) && ((size_t)(const void *)((disk->name
) + 1) - (size_t)(const void *)(disk->name) == 1) &&
(__s2_len = strlen (disk->name), __s2_len < 4) ? (__builtin_constant_p
(disk_name) && ((size_t)(const void *)((disk_name) +
1) - (size_t)(const void *)(disk_name) == 1) ? __builtin_strcmp
(disk_name, disk->name) : (- (__extension__ ({ const unsigned
char *__s2 = (const unsigned char *) (const char *) (disk_name
); int __result = (((const unsigned char *) (const char *) (disk
->name))[0] - __s2[0]); if (__s2_len > 0 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
disk->name))[1] - __s2[1]); if (__s2_len > 1 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) (disk->name))[2] - __s2[2]); if (__s2_len > 2 &&
__result == 0) __result = (((const unsigned char *) (const char
*) (disk->name))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp
(disk_name, disk->name)))); })
)
202 break;
203 }
204 if (!list)
205 return NULL((void*)0);
206 sdisk = disk_new(subdisk_name, subdisk_name);
207 sdisk->order = disk->order;
208 sdisk->subdisk = subdisk;
209 for (list = list->next; list; list = list->next)
210 {
211 disk = (DiskMon * ) list->data;
212 if (disk->subdisk == -1 || disk->subdisk > subdisk)
213 break;
214 }
215 disk_mon_list = g_list_insert_before(disk_mon_list, list, sdisk);
216 ++n_disks;
217 return sdisk;
218 }
219
220static void
221disk_assign_data(DiskMon *disk, guint64 rb, guint64 wb, gboolean virtual)
222 {
223 if (!disk)
224 return;
225 disk->rb = rb;
226 disk->wb = wb;
227
228 /* Add data to composite disk if this is not a subdisk (partition) and
229 | not a virtual disk (eg /dev/mdX software RAID multi-disk).
230 */
231 if (disk->subdisk == -1 && !virtual)
232 {
233 composite_disk->rb += rb;
234 composite_disk->wb += wb;
235 }
236 }
237
238static gboolean
239setup_disk_interface(void)
240 {
241 if (!read_disk_data && !_GK.client_mode && gkrellm_sys_disk_init())
242 {
243 read_disk_data = gkrellm_sys_disk_read_data;
244 name_from_device = gkrellm_sys_disk_name_from_device;
245 order_from_name = gkrellm_sys_disk_order_from_name;
246 }
247 /* Get a read in so I'll know the assign_method before config is loaded.
248 */
249 if (read_disk_data)
250 (*read_disk_data)();
251 return read_disk_data ? TRUE(!(0)) : FALSE(0);
252 }
253
254/* ------------- Disk monitor to system dependent interface ------------- */
255void
256gkrellm_disk_client_divert(void (*read_func)(),
257 gchar *(*name_from_device_func)(), gint (*order_from_name_func)())
258 {
259 read_disk_data = read_func;
260 name_from_device = name_from_device_func;
261 order_from_name = order_from_name_func;
262 }
263
264void
265gkrellm_disk_reset_composite(void)
266 {
267 composite_disk->rb = 0;
268 composite_disk->wb = 0;
269 sys_handles_composite_reset = TRUE(!(0));
270 }
271
272void
273gkrellm_disk_units_are_blocks(void)
274 {
275 units_are_blocks = TRUE(!(0));
276 }
277
278void
279gkrellm_disk_add_by_name(const gchar *name, const gchar *label)
280 {
281 gint order = -1;
282
283 assign_method = DISK_ASSIGN_BY_NAME2;
284 if (NULL((void*)0) == name) // Cannot add disk without a name
285 return;
286 if (order_from_name) // get optional order from sysdep-code
287 order = (*order_from_name)(name);
288 if (NULL((void*)0) != label) // label is optional and might be NULL
289 add_disk(name, label, 0, 0, order);
290 else
291 add_disk(name, name, 0, 0, order);
292 }
293
294void
295gkrellm_disk_assign_data_by_device(gint device_number, gint unit_number,
296 guint64 rb, guint64 wb, gboolean virtual)
297 {
298 DiskMon *disk;
299 gchar *name;
300 gint order = -1;
301
302 assign_method = DISK_ASSIGN_BY_DEVICE0;
303 disk = lookup_disk_by_device(device_number, unit_number);
304 if (!disk && name_from_device)
305 {
306 name = (*name_from_device)(device_number, unit_number, &order);
307 if (name)
308 disk = add_disk(name, name, device_number, unit_number, order);
309 }
310 disk_assign_data(disk, rb, wb, virtual);
311 }
312
313void
314gkrellm_disk_assign_data_nth(gint n, guint64 rb, guint64 wb, gboolean virtual)
315 {
316 DiskMon *disk;
317 gchar name[32], label[32];
318
319 assign_method = DISK_ASSIGN_NTH1;
320 if (n < n_disks)
321 disk = (DiskMon *) g_list_nth_data(disk_mon_list, n + 1);
322 else
323 {
324 snprintf(name, sizeof(name), "%s%c", "Disk", 'A' + n);
325 snprintf(label, sizeof(label), "%s%c", _("Disk")dcgettext ("gkrellm", "Disk", 5), 'A' + n);
326 disk = add_disk(name, label, 0, 0, n);
327 }
328 disk_assign_data(disk, rb, wb, virtual);
329 }
330
331void
332gkrellm_disk_assign_data_by_name(gchar *name, guint64 rb, guint64 wb,
333 gboolean virtual)
334 {
335 DiskMon *disk;
336 gint order = -1;
337
338 assign_method = DISK_ASSIGN_BY_NAME2;
339 if (!name)
340 return;
341 disk = lookup_disk_by_name(name);
342 if (!disk)
343 {
344 if (order_from_name)
345 order = (*order_from_name)(name);
346 disk = add_disk(name, name, 0, 0, order);
347 }
348 disk_assign_data(disk, rb, wb, virtual);
349 }
350
351void
352gkrellm_disk_subdisk_assign_data_by_name(gchar *subdisk_name, gchar *disk_name,
353 guint64 rb, guint64 wb)
354 {
355 DiskMon *disk;
356 gchar *s, *endptr;
357 gint subdisk;
358
359 assign_method = DISK_ASSIGN_BY_NAME2;
360 if (!subdisk_name || !disk_name)
361 return;
362 disk = lookup_disk_by_name(subdisk_name);
363 if (!disk)
364 {
365 /* A subdisk name is expected to be the disk_name with a number string
366 | appended. Eg. "hda1" is a subdisk_name of disk_name "hda"
367 */
368 s = subdisk_name + strlen(disk_name);
369 subdisk = strtol(s, &endptr, 0);
370 if (!*s || *endptr)
371 return;
372 disk = add_subdisk(subdisk_name, disk_name, subdisk);
373 }
374 disk_assign_data(disk, rb, wb, FALSE(0));
375 }
376
377
378/* ----------- End of Disk monitor to system dependent interface ---------- */
379
380
381static GkrellmSizeAbbrev disk_blocks_abbrev[] =
382 {
383 { KB_SIZE(1)((1) * 1e3), 1, "%.0f" },
384 { KB_SIZE(20)((20) * 1e3), KB_SIZE(1)((1) * 1e3), "%.1fK" },
385 { MB_SIZE(1)((1) * 1e6), KB_SIZE(1)((1) * 1e3), "%.0fK" },
386 { MB_SIZE(20)((20) * 1e6), MB_SIZE(1)((1) * 1e6), "%.1fM" },
387 { MB_SIZE(50)((50) * 1e6), MB_SIZE(1)((1) * 1e6), "%.0fM" }
388 };
389
390
391static gchar *text_format,
392 *text_format_locale;
393
394static void
395format_disk_data(DiskMon *disk, gchar *src_string, gchar *buf, gint size)
396 {
397 GkrellmChart *cp;
398 gchar c, *s;
399 size_t tbl_size;
400 gint len, r_blocks, w_blocks, blocks;
401
402 if (!buf || size < 1)
403 return;
404 --size;
405 *buf = '\0';
406 if (!src_string)
407 return;
408 cp = disk->chart;
409 r_blocks = gkrellm_get_current_chartdata(disk->read_cd);
410 w_blocks = gkrellm_get_current_chartdata(disk->write_cd);
411 tbl_size = sizeof(disk_blocks_abbrev) / sizeof(GkrellmSizeAbbrev);
412 for (s = src_string; *s != '\0' && size > 0; ++s)
413 {
414 len = 1;
415 if (*s == '$' && *(s + 1) != '\0')
416 {
417 blocks = -1;
418 if ((c = *(s + 1)) == 'T')
419 blocks = r_blocks + w_blocks;
420 else if (c == 'M')
421 blocks = gkrellm_get_chart_scalemax(cp);
422 else if (c == 'r')
423 blocks = r_blocks;
424 else if (c == 'w')
425 blocks = w_blocks;
426 else if (c == 'L')
427 len = snprintf(buf, size, "%s", disk->name);
428 else if (c == 'H')
429 len = snprintf(buf, size, "%s", gkrellm_sys_get_host_name());
430 else
431 {
432 *buf = *s;
433 if (size > 1)
434 {
435 *(buf + 1) = *(s + 1);
436 ++len;
437 }
438 }
439 if (blocks >= 0)
440 len = gkrellm_format_size_abbrev(buf, size, (gfloat) blocks,
441 &disk_blocks_abbrev[0], tbl_size);
442 ++s;
443 }
444 else
445 *buf = *s;
446 size -= len;
447 buf += len;
448 }
449 *buf = '\0';
450 }
451
452static void
453draw_disk_extra(DiskMon *disk)
454 {
455 gchar buf[128];
456
457 if (!disk->chart || !disk->extra_info)
458 return;
459 format_disk_data(disk, text_format_locale, buf, sizeof(buf));
460 if (!disk->new_text_format)
461 gkrellm_chart_reuse_text_format(disk->chart);
462 disk->new_text_format = FALSE(0);
463 gkrellm_draw_chart_text(disk->chart, style_id, buf);
464 }
465
466static void
467cb_command_process(GkrellmAlert *alert, gchar *src, gchar *dst, gint len,
468 DiskMon *disk)
469 {
470 if (disk->chart)
471 format_disk_data(disk, src, dst, len);
472 }
473
474static void
475draw_disk_chart(DiskMon *disk)
476 {
477 gkrellm_draw_chartdata(disk->chart);
478 draw_disk_extra(disk);
479 gkrellm_draw_chart_to_screen(disk->chart);
480 }
481
482static void
483cb_disk_temp_alert_trigger(GkrellmAlert *alert, DiskMon *disk)
484 {
485 GkrellmAlertdecal *ad;
486 GkrellmDecal *d;
487
488 if (alert && disk && disk->chart)
489 {
490 ad = &alert->ad;
491 d = disk->temp_decal;
492 if (d)
493 {
494 ad->x = d->x - 1;
495 ad->y = d->y - 1;
496 ad->w = d->w + 2;
497 ad->h = d->h + 2;
498 gkrellm_render_default_alert_decal(alert);
499 }
500 alert->panel = disk->chart->panel;
501 }
502 }
503
504gboolean
505gkrellm_disk_temperature_display(gpointer sr, gchar *id_name, gfloat t,
506 gchar units)
507 {
508 GList *list;
509 DiskMon *disk;
510 GkrellmPanel *p;
511 GkrellmDecal *decal;
512 gchar *disk_name;
513 gint len;
514 gboolean display_done = FALSE(0), display_possible = FALSE(0);
515
516 if ((disk_name = strrchr(id_name, '/')) != NULL((void*)0))
517 ++disk_name;
518 else
519 disk_name = id_name;
520
521 len = strlen(disk_name);
522 for (list = disk_mon_list; list; list = list->next)
523 {
524 disk = (DiskMon *) list->data;
525 if ( strncmp(disk->name, disk_name, len)(__extension__ (__builtin_constant_p (len) && ((__builtin_constant_p
(disk->name) && strlen (disk->name) < ((size_t
) (len))) || (__builtin_constant_p (disk_name) && strlen
(disk_name) < ((size_t) (len)))) ? __extension__ ({ size_t
__s1_len, __s2_len; (__builtin_constant_p (disk->name) &&
__builtin_constant_p (disk_name) && (__s1_len = strlen
(disk->name), __s2_len = strlen (disk_name), (!((size_t)(
const void *)((disk->name) + 1) - (size_t)(const void *)(disk
->name) == 1) || __s1_len >= 4) && (!((size_t)(
const void *)((disk_name) + 1) - (size_t)(const void *)(disk_name
) == 1) || __s2_len >= 4)) ? __builtin_strcmp (disk->name
, disk_name) : (__builtin_constant_p (disk->name) &&
((size_t)(const void *)((disk->name) + 1) - (size_t)(const
void *)(disk->name) == 1) && (__s1_len = strlen (
disk->name), __s1_len < 4) ? (__builtin_constant_p (disk_name
) && ((size_t)(const void *)((disk_name) + 1) - (size_t
)(const void *)(disk_name) == 1) ? __builtin_strcmp (disk->
name, disk_name) : (__extension__ ({ const unsigned char *__s2
= (const unsigned char *) (const char *) (disk_name); int __result
= (((const unsigned char *) (const char *) (disk->name))[
0] - __s2[0]); if (__s1_len > 0 && __result == 0) {
__result = (((const unsigned char *) (const char *) (disk->
name))[1] - __s2[1]); if (__s1_len > 1 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
disk->name))[2] - __s2[2]); if (__s1_len > 2 &&
__result == 0) __result = (((const unsigned char *) (const char
*) (disk->name))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p
(disk_name) && ((size_t)(const void *)((disk_name) +
1) - (size_t)(const void *)(disk_name) == 1) && (__s2_len
= strlen (disk_name), __s2_len < 4) ? (__builtin_constant_p
(disk->name) && ((size_t)(const void *)((disk->
name) + 1) - (size_t)(const void *)(disk->name) == 1) ? __builtin_strcmp
(disk->name, disk_name) : (- (__extension__ ({ const unsigned
char *__s2 = (const unsigned char *) (const char *) (disk->
name); int __result = (((const unsigned char *) (const char *
) (disk_name))[0] - __s2[0]); if (__s2_len > 0 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
disk_name))[1] - __s2[1]); if (__s2_len > 1 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
disk_name))[2] - __s2[2]); if (__s2_len > 2 && __result
== 0) __result = (((const unsigned char *) (const char *) (disk_name
))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (disk
->name, disk_name)))); }) : strncmp (disk->name, disk_name
, len)))
526 || (disk->name[len] != '\0' && !isdigit((unsigned char)disk->name[len])((*__ctype_b_loc ())[(int) (((unsigned char)disk->name[len
]))] & (unsigned short int) _ISdigit)
)
527 )
528 continue;
529 if (!disk->enabled || !disk->chart || !disk->chart->panel->decal_list)
530 {
531 display_possible |= disk->enabled; /* Not created or rebuilding */
532 continue;
533 }
534 decal = disk->temp_decal;
535 p = disk->chart->panel;
536 if (display_done)
537 {
538 if (gkrellm_is_decal_visible(decal))
539 {
540 gkrellm_make_decal_invisible(p, decal);
541 p->label->position = disk->save_label_position;
542 gkrellm_draw_panel_label(p);
543 gkrellm_draw_panel_layers(p);
544 }
545 continue;
546 }
547 if (!gkrellm_is_decal_visible(decal))
548 {
549 gkrellm_make_decal_visible(p, decal);
550 disk->save_label_position = p->label->position;
551 if (p->label->position >= 0)
552 {
553 p->label->position = 0;
554 gkrellm_draw_panel_label(p);
555 }
556 gkrellm_sensor_alert_connect(sr, cb_disk_temp_alert_trigger, disk);
557 }
558 gkrellm_sensor_draw_temperature_decal(p, decal, t, units);
559 gkrellm_draw_panel_layers(p);
560 display_done = TRUE(!(0));
561 }
562 return (display_possible || display_done);
563 }
564
565void
566gkrellm_disk_temperature_remove(gchar *id_name)
567 {
568 GList *list;
569 DiskMon *disk;
570 GkrellmPanel *p;
571 GkrellmDecal *decal;
572 gchar *disk_name;
573 gint len;
574
575 if ((disk_name = strrchr(id_name, '/')) != NULL((void*)0))
576 ++disk_name;
577 else
578 disk_name = id_name;
579
580 len = strlen(disk_name);
581 for (list = disk_mon_list; list; list = list->next)
582 {
583 disk = (DiskMon *) list->data;
584 if (!disk->chart)
585 continue;
586 if ( strncmp(disk->name, disk_name, len)(__extension__ (__builtin_constant_p (len) && ((__builtin_constant_p
(disk->name) && strlen (disk->name) < ((size_t
) (len))) || (__builtin_constant_p (disk_name) && strlen
(disk_name) < ((size_t) (len)))) ? __extension__ ({ size_t
__s1_len, __s2_len; (__builtin_constant_p (disk->name) &&
__builtin_constant_p (disk_name) && (__s1_len = strlen
(disk->name), __s2_len = strlen (disk_name), (!((size_t)(
const void *)((disk->name) + 1) - (size_t)(const void *)(disk
->name) == 1) || __s1_len >= 4) && (!((size_t)(
const void *)((disk_name) + 1) - (size_t)(const void *)(disk_name
) == 1) || __s2_len >= 4)) ? __builtin_strcmp (disk->name
, disk_name) : (__builtin_constant_p (disk->name) &&
((size_t)(const void *)((disk->name) + 1) - (size_t)(const
void *)(disk->name) == 1) && (__s1_len = strlen (
disk->name), __s1_len < 4) ? (__builtin_constant_p (disk_name
) && ((size_t)(const void *)((disk_name) + 1) - (size_t
)(const void *)(disk_name) == 1) ? __builtin_strcmp (disk->
name, disk_name) : (__extension__ ({ const unsigned char *__s2
= (const unsigned char *) (const char *) (disk_name); int __result
= (((const unsigned char *) (const char *) (disk->name))[
0] - __s2[0]); if (__s1_len > 0 && __result == 0) {
__result = (((const unsigned char *) (const char *) (disk->
name))[1] - __s2[1]); if (__s1_len > 1 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
disk->name))[2] - __s2[2]); if (__s1_len > 2 &&
__result == 0) __result = (((const unsigned char *) (const char
*) (disk->name))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p
(disk_name) && ((size_t)(const void *)((disk_name) +
1) - (size_t)(const void *)(disk_name) == 1) && (__s2_len
= strlen (disk_name), __s2_len < 4) ? (__builtin_constant_p
(disk->name) && ((size_t)(const void *)((disk->
name) + 1) - (size_t)(const void *)(disk->name) == 1) ? __builtin_strcmp
(disk->name, disk_name) : (- (__extension__ ({ const unsigned
char *__s2 = (const unsigned char *) (const char *) (disk->
name); int __result = (((const unsigned char *) (const char *
) (disk_name))[0] - __s2[0]); if (__s2_len > 0 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
disk_name))[1] - __s2[1]); if (__s2_len > 1 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
disk_name))[2] - __s2[2]); if (__s2_len > 2 && __result
== 0) __result = (((const unsigned char *) (const char *) (disk_name
))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (disk
->name, disk_name)))); }) : strncmp (disk->name, disk_name
, len)))
587 || (disk->name[len] != '\0' && !isdigit((unsigned char)disk->name[len])((*__ctype_b_loc ())[(int) (((unsigned char)disk->name[len
]))] & (unsigned short int) _ISdigit)
)
588 )
589 continue;
590 p = disk->chart->panel;
591 decal = disk->temp_decal;
592 if (gkrellm_is_decal_visible(decal))
593 {
594 gkrellm_make_decal_invisible(p, decal);
595 p->label->position = disk->save_label_position;
596 gkrellm_draw_panel_label(p);
597 gkrellm_draw_panel_layers(p);
598 }
599 }
600 }
601
602
603static void
604update_disk(void)
605 {
606 GList *list;
607 DiskMon *disk;
608 GkrellmChart *cp;
609 gint bytes;
610
611 if (!sys_handles_composite_reset)
612 {
613 composite_disk->rb = 0;
614 composite_disk->wb = 0;
615 }
616 (*read_disk_data)();
617 if (n_disks == 0)
618 return;
619
620 for (list = disk_mon_list; list; list = list->next)
621 {
622 disk = (DiskMon *) list->data;
623 if ((cp = disk->chart) == NULL((void*)0)) /* or disk->enabled FALSE */
624 continue;
625 if (GK.second_tick)
626 {
627 gkrellm_store_chartdata(cp, 0,
628 (gulong) disk->wb, (gulong) disk->rb);
629 if (disk->alert)
630 {
631 bytes = 0;
632 if (disk->alert_uses_read)
633 bytes += gkrellm_get_current_chartdata(disk->read_cd);
634 if (disk->alert_uses_write)
635 bytes += gkrellm_get_current_chartdata(disk->write_cd);
636 gkrellm_check_alert(disk->alert, bytes);
637 }
638 gkrellm_panel_label_on_top_of_decals(cp->panel,
639 gkrellm_alert_decal_visible(disk->alert));
640 draw_disk_chart(disk);
641 }
642 gkrellm_update_krell(cp->panel, KRELL(cp->panel)((GkrellmKrell *)(((cp->panel)->krell_list)->data)),
643 (gulong) (disk->wb + disk->rb));
644 gkrellm_draw_panel_layers(cp->panel);
645 }
646 }
647
648
649static gint
650disk_expose_event(GtkWidget *widget, GdkEventExpose *ev)
651 {
652 GList *list;
653 GkrellmChart *cp;
654 GdkPixmap *pixmap = NULL((void*)0);
655
656 for (list = disk_mon_list; list; list = list->next)
657 {
658 if ((cp = ((DiskMon *) list->data)->chart) == NULL((void*)0))
659 continue;
660 if (widget == cp->drawing_area)
661 pixmap = cp->pixmap;
662 else if (widget == cp->panel->drawing_area)
663 pixmap = cp->panel->pixmap;
664 if (pixmap)
665 {
666 gdk_draw_drawable(widget->window, gkrellm_draw_GC(1), pixmap,
667 ev->area.x, ev->area.y, ev->area.x, ev->area.y,
668 ev->area.width, ev->area.height);
669 break;
670 }
671 }
672 return FALSE(0);
673 }
674
675static gint
676cb_disk_extra(GtkWidget *widget, GdkEventButton *ev)
677 {
678 GList *list;
679 DiskMon *disk;
680
681 for (list = disk_mon_list; list; list = list->next)
682 {
683 disk = (DiskMon *) list->data;
684 if (!disk->enabled || widget != disk->chart->drawing_area)
685 continue;
686 if (ev->button == 1 && ev->type == GDK_BUTTON_PRESS)
687 {
688 disk->extra_info = !disk->extra_info;
689 draw_disk_chart(disk);
690 gkrellm_config_modified();
691 }
692 else if ( ev->button == 3
693 || (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS)
694 )
695 gkrellm_chartconfig_window_create(disk->chart);
696 break;
697 }
698 return FALSE(0);
699 }
700
701static void
702setup_disk_scaling(GkrellmChartconfig *cf, GkrellmChart *cp)
703 {
704 gint grids, res;
705
706 grids = gkrellm_get_chartconfig_fixed_grids(cf);
707 if (!grids)
708 grids = FULL_SCALE_GRIDS5;
709 res = gkrellm_get_chartconfig_grid_resolution(cf);
710
711 KRELL(cp->panel)((GkrellmKrell *)(((cp->panel)->krell_list)->data))->full_scale = res * grids / gkrellm_update_HZ();
712 }
713
714 /* Destroy everything in a DiskMon structure except for the vbox which
715 | is preserved so disk ordering will be maintained. Compare this to
716 | destroying an InetMon where really everything is destroyed including
717 | the InetMon structure. Here the DiskMon structure is not destroyed.
718 */
719static void
720destroy_disk_monitor(DiskMon *disk)
721 {
722 if (disk->launch_table)
723 gtk_widget_destroy(disk->launch_table);
724 disk->launch_table = NULL((void*)0);
725 if (disk->launch.button)
726 gkrellm_destroy_button(disk->launch.button);
727 disk->launch.button = NULL((void*)0);
728 gkrellm_dup_string(&disk->launch.command, "");
729 gkrellm_dup_string(&disk->launch.tooltip_comment, "");
730 gkrellm_chart_destroy(disk->chart);
731 disk->chart = NULL((void*)0);
732 disk->enabled = FALSE(0);
733 }
734
735static gint
736cb_panel_press(GtkWidget *widget, GdkEventButton *ev)
737 {
738 if (ev->button == 3)
739 gkrellm_open_config_window(mon_disk);
740 return FALSE(0);
741 }
742
743static void
744create_disk_monitor(DiskMon *disk, gint first_create)
745 {
746 GkrellmChart *cp;
747 GkrellmPanel *p;
748 GkrellmDecal *d;
749 GkrellmStyle *style;
750 GkrellmTextstyle *ts;
751 GkrellmMargin *m;
752
753 if (first_create)
754 {
755 disk->chart = gkrellm_chart_new0();
756 disk->chart->panel = gkrellm_panel_new0();
757 }
758 cp = disk->chart;
759 p = cp->panel;
760
761 style = gkrellm_panel_style(style_id);
762 gkrellm_create_krell(p, gkrellm_krell_panel_piximage(style_id), style);
763
764 gkrellm_chart_create(disk->vbox, mon_disk, cp, &disk->chart_config);
765 disk->write_cd = gkrellm_add_default_chartdata(cp, _("Write bytes")dcgettext ("gkrellm", "Write bytes", 5));
766 disk->read_cd = gkrellm_add_default_chartdata(cp, _("Read bytes")dcgettext ("gkrellm", "Read bytes", 5));
767 gkrellm_set_draw_chart_function(cp, draw_disk_chart, disk);
768
769 gkrellm_chartconfig_fixed_grids_connect(cp->config,
770 setup_disk_scaling, cp);
771 gkrellm_chartconfig_grid_resolution_connect(cp->config,
772 setup_disk_scaling, cp);
773 gkrellm_chartconfig_grid_resolution_adjustment(cp->config, TRUE(!(0)),
774 0, (gfloat) MIN_GRID_RES10, (gfloat) MAX_GRID_RES100000000, 0, 0, 0, 0);
775 gkrellm_chartconfig_grid_resolution_label(cp->config,
776 units_are_blocks ?
777 _("Disk I/O blocks per sec")dcgettext ("gkrellm", "Disk I/O blocks per sec", 5) : _("Disk I/O bytes per sec")dcgettext ("gkrellm", "Disk I/O bytes per sec", 5));
778 if (gkrellm_get_chartconfig_grid_resolution(cp->config) < MIN_GRID_RES10)
779 gkrellm_set_chartconfig_grid_resolution(cp->config, DEFAULT_GRID_RES2000);
780 gkrellm_alloc_chartdata(cp);
781
782 setup_disk_scaling(cp->config, cp);
783
784 ts = gkrellm_panel_alt_textstyle(style_id);
785 disk->temp_decal = gkrellm_create_decal_text(p, "188.8F",
786 ts, style, -1, -1, 0);
787 gkrellm_make_decal_invisible(p, disk->temp_decal);
788
789 gkrellm_panel_configure(p, disk->label, style);
790 gkrellm_panel_create(disk->vbox, mon_disk, p);
791 disk->enabled = TRUE(!(0));
792 disk->new_text_format = TRUE(!(0));
793
794 /* Position the temp decal to right edge and vertically align it
795 | wrt the label.
796 */
797 d = disk->temp_decal;
798 m = gkrellm_get_style_margins(style);
799 gkrellm_move_decal(p, d,
800 gkrellm_chart_width() - m->right - d->w,
801 m->top + (p->label->height - d->h + 1) / 2);
802
803 if (first_create)
804 {
805 g_signal_connect(G_OBJECT(cp->drawing_area), "expose_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((cp->drawing_area)), (((GType) ((20) <<
(2))))))))), ("expose_event"), (((GCallback) (disk_expose_event
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
806 G_CALLBACK(disk_expose_event), NULL)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((cp->drawing_area)), (((GType) ((20) <<
(2))))))))), ("expose_event"), (((GCallback) (disk_expose_event
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
;
807 g_signal_connect(G_OBJECT (p->drawing_area), "expose_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((p->drawing_area)), (((GType) ((20) <<
(2))))))))), ("expose_event"), (((GCallback) (disk_expose_event
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
808 G_CALLBACK(disk_expose_event), NULL)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((p->drawing_area)), (((GType) ((20) <<
(2))))))))), ("expose_event"), (((GCallback) (disk_expose_event
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
;
809
810 g_signal_connect(G_OBJECT(cp->drawing_area), "button_press_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((cp->drawing_area)), (((GType) ((20) <<
(2))))))))), ("button_press_event"), (((GCallback) (cb_disk_extra
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
811 G_CALLBACK(cb_disk_extra), NULL)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((cp->drawing_area)), (((GType) ((20) <<
(2))))))))), ("button_press_event"), (((GCallback) (cb_disk_extra
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
;
812 g_signal_connect(G_OBJECT(p->drawing_area), "button_press_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((p->drawing_area)), (((GType) ((20) <<
(2))))))))), ("button_press_event"), (((GCallback) (cb_panel_press
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
813 G_CALLBACK(cb_panel_press), NULL)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((p->drawing_area)), (((GType) ((20) <<
(2))))))))), ("button_press_event"), (((GCallback) (cb_panel_press
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
;
814 }
815 else
816 draw_disk_chart(disk);
817
818 gkrellm_configure_tooltip(p, &disk->launch);
819 if (*(disk->launch.command) != '\0')
820 disk->launch.button = gkrellm_put_label_in_panel_button(p,
821 gkrellm_launch_button_cb, &disk->launch, disk->launch.pad);
822 }
823
824
825static GtkWidget *disk_vbox;
826
827static void
828create_disk(GtkWidget *vbox, gint first_create)
829 {
830 GList *list;
831 DiskMon *disk;
832 gboolean any = FALSE(0);
833
834 ascent = 0;
835 disk_vbox = vbox;
836 for (list = disk_mon_list; list; list = list->next)
837 {
838 disk = (DiskMon *) list->data;
839 if (first_create)
840 {
841 disk->vbox = gtk_vbox_new(FALSE(0), 0);
842 gtk_box_pack_start(GTK_BOX(vbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((vbox
)), ((gtk_box_get_type ()))))))
, disk->vbox, FALSE(0), FALSE(0), 0);
843 gtk_widget_show(disk->vbox);
844 }
845 gkrellm_setup_launcher(NULL((void*)0), &disk->launch, CHART_PANEL_TYPE0, 4);
846 if (disk->enabled)
847 {
848 create_disk_monitor(disk, first_create);
849 any = TRUE(!(0));
850 }
851 }
852 if (any)
853 gkrellm_spacers_show(mon_disk);
854 else
855 gkrellm_spacers_hide(mon_disk);
856 }
857
858 /* Kernel 2.4 will not show a disk until it has I/O, and some systems
859 | may dynamically add a drive.
860 */
861static void
862check_for_new_disks(void)
863 {
864 GList *list;
865 DiskMon *disk;
866
867 for (list = disk_mon_list; list; list = list->next)
868 {
869 disk = (DiskMon *) list->data;
870 if (disk->vbox == NULL((void*)0))
871 {
872 disk->vbox = gtk_vbox_new(FALSE(0), 0);
873 gtk_box_pack_start(GTK_BOX(disk_vbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((disk_vbox
)), ((gtk_box_get_type ()))))))
, disk->vbox, FALSE(0), FALSE(0),0);
874 gtk_widget_show(disk->vbox);
875 gkrellm_setup_launcher(NULL((void*)0), &disk->launch, CHART_PANEL_TYPE0, 4);
876 }
877 }
878 }
879
880static void
881cb_alert_trigger(GkrellmAlert *alert, DiskMon *disk)
882 {
883 /* Full panel alert, default decal.
884 */
885 alert->panel = disk->chart->panel;
886 }
887
888
889static void
890create_alert(DiskMon *disk)
891 {
892 disk->alert = gkrellm_alert_create(NULL((void*)0), disk->name,
893 _("Bytes per second")dcgettext ("gkrellm", "Bytes per second", 5),
894 TRUE(!(0)), FALSE(0), TRUE(!(0)),
895 1e9, 1000, 1000, 10000, 0);
896 gkrellm_alert_delay_config(disk->alert, 1, 60 * 180, 0);
897
898 gkrellm_alert_trigger_connect(disk->alert, cb_alert_trigger, disk);
899 gkrellm_alert_config_connect(disk->alert, cb_alert_config, disk);
900 gkrellm_alert_config_create_connect(disk->alert,
901 cb_alert_config_create, disk);
902 gkrellm_alert_command_process_connect(disk->alert,
903 cb_command_process, disk);
904 }
905
906static gboolean
907any_enabled_subdisks(GList *dlist)
908 {
909 GList *list;
910 DiskMon *disk;
911
912 for (list = dlist; list; list = list->next)
913 {
914 disk = (DiskMon *) list->data;
915 if (disk->subdisk == -1)
916 break;
917 if (disk->enabled)
918 return TRUE(!(0));
919 }
920 return FALSE(0);
921 }
922
923static void
924save_disk_config(FILE *f)
925 {
926 GList *list;
927 DiskMon *disk;
928 gboolean have_enabled_subdisks;
929
930 if (n_disks == 0)
931 return;
932 fprintf(f, "%s assign_method %d\n", DISK_CONFIG_KEYWORD"disk", assign_method);
933 for (list = disk_mon_list; list; list = list->next)
934 {
935 disk = (DiskMon *) list->data;
936
937 /* To deal with possible disk hardware/partition changes at next load
938 | of the config, record if any subdisks are enabled to determine if
939 | a disk saved into the config here should be artificially created
940 | should it not be present at next gkrellm startup.
941 */
942 have_enabled_subdisks = (disk->subdisk == -1) ?
943 any_enabled_subdisks(list->next) : FALSE(0);
944
945 fprintf(f, "%s device %s %d %d %d %d %d %d %d\n",
946 DISK_CONFIG_KEYWORD"disk",
947 disk->name, disk->major, disk->minor, disk->order,
948 disk->enabled, disk->extra_info, disk->subdisk,
949 have_enabled_subdisks);
950 if (*(disk->launch.command) != '\0')
951 fprintf(f, "%s launch %s %s\n", DISK_CONFIG_KEYWORD"disk",
952 disk->name, disk->launch.command);
953 if (*(disk->launch.tooltip_comment) != '\0')
954 fprintf(f, "%s tooltip_comment %s %s\n", DISK_CONFIG_KEYWORD"disk",
955 disk->name, disk->launch.tooltip_comment);
956 gkrellm_save_chartconfig(f, disk->chart_config,
957 DISK_CONFIG_KEYWORD"disk", disk->name);
958 if (disk->alert && disk->enabled)
959 {
960 gkrellm_save_alertconfig(f, disk->alert,
961 DISK_CONFIG_KEYWORD"disk", disk->name);
962 fprintf(f, "%s extra_alert_config %s %d %d\n", DISK_CONFIG_KEYWORD"disk",
963 disk->name,
964 disk->alert_uses_read, disk->alert_uses_write);
965 }
966 }
967 fprintf(f, "%s text_format %s\n", DISK_CONFIG_KEYWORD"disk", text_format);
968 }
969
970static void
971load_disk_config(gchar *arg)
972 {
973 DiskMon *disk = NULL((void*)0);
974 gchar config[32], item[CFG_BUFSIZE512],
975 name[CFG_BUFSIZE512], item1[CFG_BUFSIZE512];
976 gint major, minor, enabled, extra, order, subdisk = -1;
977 gint n;
978 gboolean enabled_subdisks = TRUE(!(0));
979 static gchar *parent;
980 static gint config_assign_method;
981
982 n = sscanf(arg, "%31s %[^\n]", config, item);
983 if (n == 2)
984 {
985 if (!strcmp(config, "text_format")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
(config) && __builtin_constant_p ("text_format") &&
(__s1_len = strlen (config), __s2_len = strlen ("text_format"
), (!((size_t)(const void *)((config) + 1) - (size_t)(const void
*)(config) == 1) || __s1_len >= 4) && (!((size_t)
(const void *)(("text_format") + 1) - (size_t)(const void *)(
"text_format") == 1) || __s2_len >= 4)) ? __builtin_strcmp
(config, "text_format") : (__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 ("text_format") && (
(size_t)(const void *)(("text_format") + 1) - (size_t)(const void
*)("text_format") == 1) ? __builtin_strcmp (config, "text_format"
) : (__extension__ ({ const unsigned char *__s2 = (const unsigned
char *) (const char *) ("text_format"); 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 ("text_format") &&
((size_t)(const void *)(("text_format") + 1) - (size_t)(const
void *)("text_format") == 1) && (__s2_len = strlen (
"text_format"), __s2_len < 4) ? (__builtin_constant_p (config
) && ((size_t)(const void *)((config) + 1) - (size_t)
(const void *)(config) == 1) ? __builtin_strcmp (config, "text_format"
) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned
char *) (const char *) (config); int __result = (((const unsigned
char *) (const char *) ("text_format"))[0] - __s2[0]); if (__s2_len
> 0 && __result == 0) { __result = (((const unsigned
char *) (const char *) ("text_format"))[1] - __s2[1]); if (__s2_len
> 1 && __result == 0) { __result = (((const unsigned
char *) (const char *) ("text_format"))[2] - __s2[2]); if (__s2_len
> 2 && __result == 0) __result = (((const unsigned
char *) (const char *) ("text_format"))[3] - __s2[3]); } } __result
; })))) : __builtin_strcmp (config, "text_format")))); })
)
986 gkrellm_locale_dup_string(&text_format, item, &text_format_locale);
987 else if (!strcmp(config, "assign_method")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
(config) && __builtin_constant_p ("assign_method") &&
(__s1_len = strlen (config), __s2_len = strlen ("assign_method"
), (!((size_t)(const void *)((config) + 1) - (size_t)(const void
*)(config) == 1) || __s1_len >= 4) && (!((size_t)
(const void *)(("assign_method") + 1) - (size_t)(const void *
)("assign_method") == 1) || __s2_len >= 4)) ? __builtin_strcmp
(config, "assign_method") : (__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 ("assign_method") &&
((size_t)(const void *)(("assign_method") + 1) - (size_t)(const
void *)("assign_method") == 1) ? __builtin_strcmp (config, "assign_method"
) : (__extension__ ({ const unsigned char *__s2 = (const unsigned
char *) (const char *) ("assign_method"); 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 ("assign_method"
) && ((size_t)(const void *)(("assign_method") + 1) -
(size_t)(const void *)("assign_method") == 1) && (__s2_len
= strlen ("assign_method"), __s2_len < 4) ? (__builtin_constant_p
(config) && ((size_t)(const void *)((config) + 1) - (
size_t)(const void *)(config) == 1) ? __builtin_strcmp (config
, "assign_method") : (- (__extension__ ({ const unsigned char
*__s2 = (const unsigned char *) (const char *) (config); int
__result = (((const unsigned char *) (const char *) ("assign_method"
))[0] - __s2[0]); if (__s2_len > 0 && __result == 0
) { __result = (((const unsigned char *) (const char *) ("assign_method"
))[1] - __s2[1]); if (__s2_len > 1 && __result == 0
) { __result = (((const unsigned char *) (const char *) ("assign_method"
))[2] - __s2[2]); if (__s2_len > 2 && __result == 0
) __result = (((const unsigned char *) (const char *) ("assign_method"
))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (config
, "assign_method")))); })
)
988 sscanf(item, "%d", &config_assign_method);
989 else if (sscanf(item, "%s %[^\n]", name, item1) == 2)
990 disk = lookup_disk_by_name(name);
991
992 if (!strcmp(config, "device")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
(config) && __builtin_constant_p ("device") &&
(__s1_len = strlen (config), __s2_len = strlen ("device"), (
!((size_t)(const void *)((config) + 1) - (size_t)(const void *
)(config) == 1) || __s1_len >= 4) && (!((size_t)(const
void *)(("device") + 1) - (size_t)(const void *)("device") ==
1) || __s2_len >= 4)) ? __builtin_strcmp (config, "device"
) : (__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 ("device") && ((size_t)(const void
*)(("device") + 1) - (size_t)(const void *)("device") == 1) ?
__builtin_strcmp (config, "device") : (__extension__ ({ const
unsigned char *__s2 = (const unsigned char *) (const char *)
("device"); 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 (
"device") && ((size_t)(const void *)(("device") + 1) -
(size_t)(const void *)("device") == 1) && (__s2_len =
strlen ("device"), __s2_len < 4) ? (__builtin_constant_p (
config) && ((size_t)(const void *)((config) + 1) - (size_t
)(const void *)(config) == 1) ? __builtin_strcmp (config, "device"
) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned
char *) (const char *) (config); int __result = (((const unsigned
char *) (const char *) ("device"))[0] - __s2[0]); if (__s2_len
> 0 && __result == 0) { __result = (((const unsigned
char *) (const char *) ("device"))[1] - __s2[1]); if (__s2_len
> 1 && __result == 0) { __result = (((const unsigned
char *) (const char *) ("device"))[2] - __s2[2]); if (__s2_len
> 2 && __result == 0) __result = (((const unsigned
char *) (const char *) ("device"))[3] - __s2[3]); } } __result
; })))) : __builtin_strcmp (config, "device")))); })
)
993 {
994 /* Disk config can be invalid (different disk naming scheme)
995 | if user changes kernel version.
996 */
997 if ( config_assign_method == assign_method
998 && sscanf(item1, "%d %d %d %d %d %d %d",
999 &major, &minor, &order,
1000 &enabled, &extra,
1001 &subdisk, &enabled_subdisks) >= 5
1002 )
1003 {
1004 /* A disk in the config may not have been found in the above
1005 | lookup because of removable drives or hardware/partition
1006 | changes since last gkrellm run.
1007 | Also Linux <= 2.4 may be getting disk stats from /proc/stat
1008 | where disks won't appear until they have I/O.
1009 | So, artificially create these not present disks if they
1010 | were previously enabled.
1011 */
1012 if (subdisk == -1)
1013 gkrellm_dup_string(&parent, name);
1014 if ( !disk && subdisk == -1
1015 && (enabled || enabled_subdisks)
1016 )
1017 disk = add_disk(name, name, major, minor, order - 1);
1018 else if (!disk && subdisk >= 0 && enabled)
1019 disk = add_subdisk(name, parent, subdisk);
1020 if (disk)
1021 {
1022 disk->enabled = enabled;
1023 disk->extra_info = extra;
1024 }
1025 }
1026 return;
1027 }
1028 if (!disk)
1029 return;
1030 if (!strcmp(config, GKRELLM_CHARTCONFIG_KEYWORD)__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
(config) && __builtin_constant_p ("chart_config") &&
(__s1_len = strlen (config), __s2_len = strlen ("chart_config"
), (!((size_t)(const void *)((config) + 1) - (size_t)(const void
*)(config) == 1) || __s1_len >= 4) && (!((size_t)
(const void *)(("chart_config") + 1) - (size_t)(const void *)
("chart_config") == 1) || __s2_len >= 4)) ? __builtin_strcmp
(config, "chart_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 ("chart_config") && (
(size_t)(const void *)(("chart_config") + 1) - (size_t)(const
void *)("chart_config") == 1) ? __builtin_strcmp (config, "chart_config"
) : (__extension__ ({ const unsigned char *__s2 = (const unsigned
char *) (const char *) ("chart_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 ("chart_config") &&
((size_t)(const void *)(("chart_config") + 1) - (size_t)(const
void *)("chart_config") == 1) && (__s2_len = strlen (
"chart_config"), __s2_len < 4) ? (__builtin_constant_p (config
) && ((size_t)(const void *)((config) + 1) - (size_t)
(const void *)(config) == 1) ? __builtin_strcmp (config, "chart_config"
) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned
char *) (const char *) (config); int __result = (((const unsigned
char *) (const char *) ("chart_config"))[0] - __s2[0]); if (
__s2_len > 0 && __result == 0) { __result = (((const
unsigned char *) (const char *) ("chart_config"))[1] - __s2[
1]); if (__s2_len > 1 && __result == 0) { __result
= (((const unsigned char *) (const char *) ("chart_config"))
[2] - __s2[2]); if (__s2_len > 2 && __result == 0)
__result = (((const unsigned char *) (const char *) ("chart_config"
))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (config
, "chart_config")))); })
)
1031 gkrellm_load_chartconfig(&disk->chart_config, item1, 2);
1032 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")))); })
)
1033 {
1034 if (!disk->alert)
1035 create_alert(disk);
1036 gkrellm_load_alertconfig(&disk->alert, item1);
1037 }
1038 else if (!strcmp(config, "extra_alert_config")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
(config) && __builtin_constant_p ("extra_alert_config"
) && (__s1_len = strlen (config), __s2_len = strlen (
"extra_alert_config"), (!((size_t)(const void *)((config) + 1
) - (size_t)(const void *)(config) == 1) || __s1_len >= 4)
&& (!((size_t)(const void *)(("extra_alert_config") +
1) - (size_t)(const void *)("extra_alert_config") == 1) || __s2_len
>= 4)) ? __builtin_strcmp (config, "extra_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
("extra_alert_config") && ((size_t)(const void *)(("extra_alert_config"
) + 1) - (size_t)(const void *)("extra_alert_config") == 1) ?
__builtin_strcmp (config, "extra_alert_config") : (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) ("extra_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 ("extra_alert_config") &&
((size_t)(const void *)(("extra_alert_config") + 1) - (size_t
)(const void *)("extra_alert_config") == 1) && (__s2_len
= strlen ("extra_alert_config"), __s2_len < 4) ? (__builtin_constant_p
(config) && ((size_t)(const void *)((config) + 1) - (
size_t)(const void *)(config) == 1) ? __builtin_strcmp (config
, "extra_alert_config") : (- (__extension__ ({ const unsigned
char *__s2 = (const unsigned char *) (const char *) (config)
; int __result = (((const unsigned char *) (const char *) ("extra_alert_config"
))[0] - __s2[0]); if (__s2_len > 0 && __result == 0
) { __result = (((const unsigned char *) (const char *) ("extra_alert_config"
))[1] - __s2[1]); if (__s2_len > 1 && __result == 0
) { __result = (((const unsigned char *) (const char *) ("extra_alert_config"
))[2] - __s2[2]); if (__s2_len > 2 && __result == 0
) __result = (((const unsigned char *) (const char *) ("extra_alert_config"
))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (config
, "extra_alert_config")))); })
)
1039 sscanf(item1, "%d %d",
1040 &disk->alert_uses_read, &disk->alert_uses_write);
1041 else if (!strcmp(config, "launch")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
(config) && __builtin_constant_p ("launch") &&
(__s1_len = strlen (config), __s2_len = strlen ("launch"), (
!((size_t)(const void *)((config) + 1) - (size_t)(const void *
)(config) == 1) || __s1_len >= 4) && (!((size_t)(const
void *)(("launch") + 1) - (size_t)(const void *)("launch") ==
1) || __s2_len >= 4)) ? __builtin_strcmp (config, "launch"
) : (__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 ("launch") && ((size_t)(const void
*)(("launch") + 1) - (size_t)(const void *)("launch") == 1) ?
__builtin_strcmp (config, "launch") : (__extension__ ({ const
unsigned char *__s2 = (const unsigned char *) (const char *)
("launch"); 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 (
"launch") && ((size_t)(const void *)(("launch") + 1) -
(size_t)(const void *)("launch") == 1) && (__s2_len =
strlen ("launch"), __s2_len < 4) ? (__builtin_constant_p (
config) && ((size_t)(const void *)((config) + 1) - (size_t
)(const void *)(config) == 1) ? __builtin_strcmp (config, "launch"
) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned
char *) (const char *) (config); int __result = (((const unsigned
char *) (const char *) ("launch"))[0] - __s2[0]); if (__s2_len
> 0 && __result == 0) { __result = (((const unsigned
char *) (const char *) ("launch"))[1] - __s2[1]); if (__s2_len
> 1 && __result == 0) { __result = (((const unsigned
char *) (const char *) ("launch"))[2] - __s2[2]); if (__s2_len
> 2 && __result == 0) __result = (((const unsigned
char *) (const char *) ("launch"))[3] - __s2[3]); } } __result
; })))) : __builtin_strcmp (config, "launch")))); })
)
1042 disk->launch.command = g_strdup(item1);
1043 else if (!strcmp(config, "tooltip_comment")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
(config) && __builtin_constant_p ("tooltip_comment")
&& (__s1_len = strlen (config), __s2_len = strlen ("tooltip_comment"
), (!((size_t)(const void *)((config) + 1) - (size_t)(const void
*)(config) == 1) || __s1_len >= 4) && (!((size_t)
(const void *)(("tooltip_comment") + 1) - (size_t)(const void
*)("tooltip_comment") == 1) || __s2_len >= 4)) ? __builtin_strcmp
(config, "tooltip_comment") : (__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 ("tooltip_comment"
) && ((size_t)(const void *)(("tooltip_comment") + 1)
- (size_t)(const void *)("tooltip_comment") == 1) ? __builtin_strcmp
(config, "tooltip_comment") : (__extension__ ({ const unsigned
char *__s2 = (const unsigned char *) (const char *) ("tooltip_comment"
); 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 (
"tooltip_comment") && ((size_t)(const void *)(("tooltip_comment"
) + 1) - (size_t)(const void *)("tooltip_comment") == 1) &&
(__s2_len = strlen ("tooltip_comment"), __s2_len < 4) ? (
__builtin_constant_p (config) && ((size_t)(const void
*)((config) + 1) - (size_t)(const void *)(config) == 1) ? __builtin_strcmp
(config, "tooltip_comment") : (- (__extension__ ({ const unsigned
char *__s2 = (const unsigned char *) (const char *) (config)
; int __result = (((const unsigned char *) (const char *) ("tooltip_comment"
))[0] - __s2[0]); if (__s2_len > 0 && __result == 0
) { __result = (((const unsigned char *) (const char *) ("tooltip_comment"
))[1] - __s2[1]); if (__s2_len > 1 && __result == 0
) { __result = (((const unsigned char *) (const char *) ("tooltip_comment"
))[2] - __s2[2]); if (__s2_len > 2 && __result == 0
) __result = (((const unsigned char *) (const char *) ("tooltip_comment"
))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (config
, "tooltip_comment")))); })
)
1044 disk->launch.tooltip_comment = g_strdup(item1);
1045 }
1046 }
1047
1048
1049/* -------------------------------------------------------------------- */
1050
1051enum
1052 {
1053 NAME_COLUMN,
1054 ENABLE_COLUMN,
1055 DISK_COLUMN,
1056 IMAGE_COLUMN,
1057 N_COLUMNS
1058 };
1059
1060static GtkTreeView *treeview;
1061
1062static GtkTreeRowReference *row_reference;
1063static GtkTreeSelection *selection;
1064
1065static GtkWidget *launch_vbox,
1066 *text_format_combo_box;
1067
1068static GtkWidget *alert_button;
1069
1070
1071
1072static GtkTreeModel *
1073create_model(void)
1074 {
1075 GtkTreeStore *tree;
1076 GtkTreeIter iter, citer;
1077 GList *list, *clist;
1078 DiskMon *disk;
1079
1080 tree = gtk_tree_store_new(N_COLUMNS,
1081 G_TYPE_STRING((GType) ((16) << (2))),
1082 G_TYPE_BOOLEAN((GType) ((5) << (2))),
1083 G_TYPE_POINTER((GType) ((17) << (2))),
1084 GDK_TYPE_PIXBUF(gdk_pixbuf_get_type ()));
1085 for (list = disk_mon_list; list; )
1086 {
1087 disk = (DiskMon *) list->data;
1088 gtk_tree_store_append(tree, &iter, NULL((void*)0));
1089 if (list == disk_mon_list)
1090 gtk_tree_store_set(tree, &iter,
1091 NAME_COLUMN, _("Composite chart combines data for all disks")dcgettext ("gkrellm", "Composite chart combines data for all disks"
, 5)
,
1092 ENABLE_COLUMN, disk->enabled,
1093 DISK_COLUMN, disk,
1094 -1);
1095 else
1096 {
1097 gtk_tree_store_set(tree, &iter,
1098 NAME_COLUMN, disk->label,
1099 ENABLE_COLUMN, disk->enabled,
1100 DISK_COLUMN, disk,
1101 -1);
1102 if (disk->alert)
1103 gtk_tree_store_set(tree, &iter,
1104 IMAGE_COLUMN, gkrellm_alert_pixbuf(), -1);
1105 }
1106 for (clist = list->next; clist; clist = clist->next)
1107 {
1108 disk = (DiskMon *) clist->data;
1109 if (disk->subdisk == -1)
1110 break;
1111 gtk_tree_store_append(tree, &citer, &iter);
1112 gtk_tree_store_set(tree, &citer,
1113 NAME_COLUMN, disk->name,
1114 ENABLE_COLUMN, disk->enabled,
1115 DISK_COLUMN, disk,
1116 -1);
1117 if (disk->alert)
1118 gtk_tree_store_set(tree, &citer,
1119 IMAGE_COLUMN, gkrellm_alert_pixbuf(), -1);
1120 }
1121 list = clist;
1122 }
1123
1124 return GTK_TREE_MODEL(tree)((((GtkTreeModel*) g_type_check_instance_cast ((GTypeInstance
*) ((tree)), ((gtk_tree_model_get_type ()))))))
;
1125 }
1126
1127static void
1128cb_launch_entry(GtkWidget *widget, DiskMon *disk)
1129 {
1130 if (disk->enabled)
1131 gkrellm_apply_launcher(&disk->launch_entry, &disk->tooltip_entry,
1132 disk->chart->panel, &disk->launch, gkrellm_launch_button_cb);
1133 }
1134
1135static void
1136add_launch_entry(GtkWidget *vbox, DiskMon *disk)
1137 {
1138 disk->launch_table = gkrellm_gtk_launcher_table_new(vbox, 1);
1139 gkrellm_gtk_config_launcher(disk->launch_table, 0, &disk->launch_entry,
1140 &disk->tooltip_entry, disk->label,
1141 &disk->launch);
1142 g_signal_connect(G_OBJECT(disk->launch_entry), "changed",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((disk->launch_entry)), (((GType) ((20)
<< (2))))))))), ("changed"), (((GCallback) (cb_launch_entry
))), (disk), ((void*)0), (GConnectFlags) 0)
1143 G_CALLBACK(cb_launch_entry), disk)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((disk->launch_entry)), (((GType) ((20)
<< (2))))))))), ("changed"), (((GCallback) (cb_launch_entry
))), (disk), ((void*)0), (GConnectFlags) 0)
;
1144 g_signal_connect(G_OBJECT(disk->tooltip_entry), "changed",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((disk->tooltip_entry)), (((GType) ((20
) << (2))))))))), ("changed"), (((GCallback) (cb_launch_entry
))), (disk), ((void*)0), (GConnectFlags) 0)
1145 G_CALLBACK(cb_launch_entry), disk)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((disk->tooltip_entry)), (((GType) ((20
) << (2))))))))), ("changed"), (((GCallback) (cb_launch_entry
))), (disk), ((void*)0), (GConnectFlags) 0)
;
1146 gtk_widget_show_all(disk->launch_table);
1147 }
1148
1149static void
1150change_row_reference(GtkTreeModel *model, GtkTreePath *path)
1151 {
1152 gtk_tree_row_reference_free(row_reference);
1153 if (model && path)
1154 row_reference = gtk_tree_row_reference_new(model, path);
1155 else
1156 row_reference = NULL((void*)0);
1157 }
1158
1159static void
1160cb_alert_config(GkrellmAlert *ap, DiskMon *disk)
1161 {
1162 GtkTreeModel *model;
1163 GtkTreeIter iter, citer;
1164 DiskMon *disk_test;
1165 GdkPixbuf *pixbuf;
1166 gboolean valid;
1167
1168 disk->alert_uses_read =
1169 GTK_TOGGLE_BUTTON(disk->alert_config_read_button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance
*) ((disk->alert_config_read_button)), ((gtk_toggle_button_get_type
()))))))
->active;
1170 disk->alert_uses_write =
1171 GTK_TOGGLE_BUTTON(disk->alert_config_write_button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance
*) ((disk->alert_config_write_button)), ((gtk_toggle_button_get_type
()))))))
->active;
1172 if (!gkrellm_config_window_shown())
1173 return;
1174 model = gtk_tree_view_get_model(treeview);
1175 pixbuf = ap->activated ? gkrellm_alert_pixbuf() : NULL((void*)0);
1176 valid = gtk_tree_model_get_iter_first(model, &iter);
1177 while (valid)
1178 {
1179 gtk_tree_model_get(model, &iter, DISK_COLUMN, &disk_test, -1);
1180 if (disk == disk_test)
1181 {
1182 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, &iter,
1183 IMAGE_COLUMN, pixbuf, -1);
1184 return;
1185 }
1186 if (gtk_tree_model_iter_children(model, &citer, &iter))
1187 do
1188 {
1189 gtk_tree_model_get(model, &citer, DISK_COLUMN, &disk_test, -1);
1190 if (disk == disk_test)
1191 {
1192 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, &citer,
1193 IMAGE_COLUMN, pixbuf, -1);
1194 return;
1195 }
1196 }
1197 while (gtk_tree_model_iter_next(model, &citer));
1198
1199 valid = gtk_tree_model_iter_next(model, &iter);
1200 }
1201 }
1202
1203static void
1204cb_alert_config_button(GtkWidget *button, DiskMon *disk)
1205 {
1206 gboolean read, write;
1207
1208 read = GTK_TOGGLE_BUTTON(disk->alert_config_read_button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance
*) ((disk->alert_config_read_button)), ((gtk_toggle_button_get_type
()))))))
->active;
1209 write = GTK_TOGGLE_BUTTON(disk->alert_config_write_button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance
*) ((disk->alert_config_write_button)), ((gtk_toggle_button_get_type
()))))))
->active;
1210 if (!read && !write)
1211 {
1212 gtk_toggle_button_set_active(
1213 GTK_TOGGLE_BUTTON(disk->alert_config_read_button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance
*) ((disk->alert_config_read_button)), ((gtk_toggle_button_get_type
()))))))
, TRUE(!(0)));
1214 gtk_toggle_button_set_active(
1215 GTK_TOGGLE_BUTTON(disk->alert_config_write_button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance
*) ((disk->alert_config_write_button)), ((gtk_toggle_button_get_type
()))))))
, TRUE(!(0)));
1216 }
1217 }
1218
1219static void
1220cb_alert_config_create(GkrellmAlert *ap, GtkWidget *vbox, DiskMon *disk)
1221 {
1222 gkrellm_gtk_check_button_connected(vbox, &disk->alert_config_read_button,
1223 disk->alert_uses_read, FALSE(0), FALSE(0), 2,
1224 cb_alert_config_button, disk, _("Read bytes")dcgettext ("gkrellm", "Read bytes", 5));
1225 gkrellm_gtk_check_button_connected(vbox, &disk->alert_config_write_button,
1226 disk->alert_uses_write, FALSE(0), FALSE(0), 2,
1227 cb_alert_config_button, disk, _("Write bytes")dcgettext ("gkrellm", "Write bytes", 5));
1228 }
1229
1230static void
1231cb_set_alert(GtkWidget *button, gpointer data)
1232 {
1233 GtkTreeModel *model;
1234 GtkTreePath *path;
1235 GtkTreeIter iter;
1236 DiskMon *disk;
1237
1238 if (!row_reference)
1239 return;
1240 model = gtk_tree_view_get_model(treeview);
1241 path = gtk_tree_row_reference_get_path(row_reference);
1242 gtk_tree_model_get_iter(model, &iter, path);
1243 gtk_tree_model_get(model, &iter, DISK_COLUMN, &disk, -1);
1244
1245 if (!disk->alert)
1246 create_alert(disk);
1247 gkrellm_alert_config_window(&disk->alert);
1248 }
1249
1250
1251static void
1252cb_tree_selection_changed(GtkTreeSelection *selection, gpointer data)
1253 {
1254 GtkTreeIter iter;
1255 GtkTreeModel *model;
1256 GtkTreePath *path;
1257 DiskMon *disk;
1258 gint *indices, depth;
1259
1260 if (!gtk_tree_selection_get_selected(selection, &model, &iter))
1261 {
1262 gtk_widget_set_sensitive(alert_button, FALSE(0));
1263 return;
1264 }
1265 path = gtk_tree_model_get_path(model, &iter);
1266 indices = gtk_tree_path_get_indices(path);
1267 depth = gtk_tree_path_get_depth(path);
1268// g_debug("selection: indices=[%d,%d]:%d, path=%s\n",
1269// indices[0], indices[1], gtk_tree_path_get_depth(path),
1270// gtk_tree_path_to_string(path));
1271 change_row_reference(model, path);
1272
1273 gtk_tree_model_get(model, &iter,
1274 DISK_COLUMN, &disk, -1);
1275
1276 if (!disk->enabled || (depth == 1 && indices[0] == 0))
1277 gtk_widget_set_sensitive(alert_button, FALSE(0));
1278 else
1279 gtk_widget_set_sensitive(alert_button, TRUE(!(0)));
1280 gtk_tree_path_free(path);
1281 }
1282
1283static void
1284cb_enable(GtkCellRendererText *cell, gchar *path_string, gpointer data)
1285 {
1286 GtkTreeModel *model;
1287 GtkTreeIter iter;
1288 GtkTreePath *path;
1289 GList *list;
1290 DiskMon *disk;
1291 gboolean enabled;
1292
1293 model = GTK_TREE_MODEL(data)((((GtkTreeModel*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_tree_model_get_type ()))))))
;
1294 path = gtk_tree_path_new_from_string(path_string);
1295 gtk_tree_model_get_iter(model, &iter, path);
1296 gtk_tree_path_free(path);
1297
1298 gtk_tree_model_get(model, &iter,
1299 ENABLE_COLUMN, &enabled,
1300 DISK_COLUMN, &disk,
1301 -1);
1302 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, &iter,
1303 ENABLE_COLUMN, !enabled,
1304 -1);
1305 if (enabled)
1306 {
1307 destroy_disk_monitor(disk);
1308 gtk_widget_set_sensitive(alert_button, FALSE(0));
1309 }
1310 else
1311 {
1312 create_disk_monitor(disk, TRUE(!(0)));
1313 add_launch_entry(launch_vbox, disk);
1314 gtk_widget_set_sensitive(alert_button, TRUE(!(0)));
1315 }
1316 disk->enabled = !enabled;
1317 enabled = FALSE(0);
1318 for (list = disk_mon_list; list; list = list->next)
1319 if (((DiskMon *) list->data)->enabled)
1320 enabled = TRUE(!(0));
1321 if (enabled)
1322 gkrellm_spacers_show(mon_disk);
1323 else
1324 gkrellm_spacers_hide(mon_disk);
1325 }
1326
1327static void
1328cb_text_format(GtkWidget *widget, gpointer data)
1329 {
1330 GList *list;
1331 DiskMon *disk;
1332 gchar *s;
1333 GtkWidget *entry;
1334
1335 entry = gtk_bin_get_child(GTK_BIN(text_format_combo_box)((((GtkBin*) g_type_check_instance_cast ((GTypeInstance*) ((text_format_combo_box
)), ((gtk_bin_get_type ()))))))
);
1336 s = gkrellm_gtk_entry_get_text(&entry);
1337 gkrellm_locale_dup_string(&text_format, s, &text_format_locale);
1338 for (list = disk_mon_list; list; list = list->next)
1339 {
1340 disk = (DiskMon *) list->data;
1341 disk->new_text_format = TRUE(!(0));
1342 draw_disk_chart(disk);
1343 }
1344 }
1345
1346
1347#define DEFAULT_TEXT_FORMAT"$T" "$T"
1348
1349static gchar *disk_info_text[] =
1350{
1351N_("<h>Chart Labels\n")("<h>Chart Labels\n"),
1352N_("Substitution variables for the format string for chart labels:\n")("Substitution variables for the format string for chart labels:\n"
)
,
1353N_("\t$L the Disk label\n")("\t$L the Disk label\n"),
1354N_("\t$M maximum chart value\n")("\t$M maximum chart value\n"),
1355N_("\t$T total read bytes + write bytes\n")("\t$T total read bytes + write bytes\n"),
1356N_("\t$r read bytes\n")("\t$r read bytes\n"),
1357N_("\t$w write bytes\n")("\t$w write bytes\n"),
1358"\n",
1359N_("Substitution variables may be used in alert commands.\n")("Substitution variables may be used in alert commands.\n")
1360};
1361
1362static void
1363create_disk_tab(GtkWidget *tab_vbox)
1364 {
1365 GtkWidget *tabs;
1366 GtkWidget *vbox, *vbox1, *hbox;
1367 GtkWidget *text;
1368 GtkWidget *scrolled;
1369 GtkTreeModel *model;
1370 GtkCellRenderer *renderer;
1371 GList *list;
1372 DiskMon *disk;
1373 gint i;
1374
1375 check_for_new_disks();
1376 if (n_disks == 0)
1377 return;
1378
1379 tabs = gtk_notebook_new();
1380 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(tabs)((((GtkNotebook*) g_type_check_instance_cast ((GTypeInstance*
) ((tabs)), ((gtk_notebook_get_type ()))))))
, GTK_POS_TOP);
1381 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);
1382
1383/* -- Options tab */
1384 vbox = gkrellm_gtk_framed_notebook_page(tabs, _("Options")dcgettext ("gkrellm", "Options", 5));
1385
1386 scrolled = gtk_scrolled_window_new(NULL((void*)0), NULL((void*)0));
1387 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled)((((GtkScrolledWindow*) g_type_check_instance_cast ((GTypeInstance
*) ((scrolled)), ((gtk_scrolled_window_get_type ()))))))
,
1388 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1389 gtk_box_pack_start(GTK_BOX(vbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((vbox
)), ((gtk_box_get_type ()))))))
, scrolled, TRUE(!(0)), TRUE(!(0)), 0);
1390
1391 model = create_model();
1392
1393 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
()))))))
;
1394 gtk_tree_view_set_rules_hint(treeview, TRUE(!(0)));
1395
1396 renderer = gtk_cell_renderer_toggle_new();
1397 gtk_tree_view_insert_column_with_attributes(treeview, -1, _("Enable")dcgettext ("gkrellm", "Enable", 5),
1398 renderer,
1399 "active", ENABLE_COLUMN,
1400 NULL((void*)0));
1401 g_signal_connect(G_OBJECT(renderer), "toggled",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((renderer)), (((GType) ((20) << (2)
)))))))), ("toggled"), (((GCallback) (cb_enable))), (model), (
(void*)0), (GConnectFlags) 0)
1402 G_CALLBACK(cb_enable), model)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((renderer)), (((GType) ((20) << (2)
)))))))), ("toggled"), (((GCallback) (cb_enable))), (model), (
(void*)0), (GConnectFlags) 0)
;
1403
1404 renderer = gtk_cell_renderer_text_new();
1405 gtk_tree_view_insert_column_with_attributes(treeview, -1, _("Disk")dcgettext ("gkrellm", "Disk", 5),
1406 renderer,
1407 "text", NAME_COLUMN,
1408 NULL((void*)0));
1409
1410 renderer = gtk_cell_renderer_pixbuf_new();
1411 gtk_tree_view_insert_column_with_attributes(treeview, -1, "",
1412 renderer,
1413 "pixbuf", IMAGE_COLUMN,
1414 NULL((void*)0));
1415
1416 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 ()))))))
);
1417 g_object_unref(G_OBJECT(model)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
model)), (((GType) ((20) << (2))))))))
);
1418 selection = gtk_tree_view_get_selection(treeview);
1419 gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
1420 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)
1421 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)
;
1422
1423 hbox = gtk_hbox_new(FALSE(0), 0);
1424 gtk_box_pack_start(GTK_BOX(vbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((vbox
)), ((gtk_box_get_type ()))))))
, hbox, FALSE(0), FALSE(0), 3);
1425 gkrellm_gtk_alert_button(hbox, &alert_button, FALSE(0), FALSE(0), 4, FALSE(0),
1426 cb_set_alert, NULL((void*)0));
1427 gtk_widget_set_sensitive(alert_button, FALSE(0));
1428
1429/* -- Setup tab */
1430 vbox = gkrellm_gtk_framed_notebook_page(tabs, _("Setup")dcgettext ("gkrellm", "Setup", 5));
1431
1432 vbox1 = gkrellm_gtk_category_vbox(vbox,
1433 _("Format String for Chart Labels")dcgettext ("gkrellm", "Format String for Chart Labels", 5),
1434 4, 0, TRUE(!(0)));
1435 text_format_combo_box = gtk_combo_box_entry_new_text();
1436 gtk_box_pack_start(GTK_BOX(vbox1)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((vbox1
)), ((gtk_box_get_type ()))))))
, text_format_combo_box, FALSE(0), FALSE(0), 0);
1437 gtk_combo_box_append_text(GTK_COMBO_BOX(text_format_combo_box)((((GtkComboBox*) g_type_check_instance_cast ((GTypeInstance*
) ((text_format_combo_box)), ((gtk_combo_box_get_type ())))))
)
,
1438 text_format);
1439 gtk_combo_box_append_text(GTK_COMBO_BOX(text_format_combo_box)((((GtkComboBox*) g_type_check_instance_cast ((GTypeInstance*
) ((text_format_combo_box)), ((gtk_combo_box_get_type ())))))
)
,
1440 DEFAULT_TEXT_FORMAT"$T");
1441 gtk_combo_box_append_text(GTK_COMBO_BOX(text_format_combo_box)((((GtkComboBox*) g_type_check_instance_cast ((GTypeInstance*
) ((text_format_combo_box)), ((gtk_combo_box_get_type ())))))
)
,
1442 "\\c\\f$M\\n$T");
1443 gtk_combo_box_append_text(GTK_COMBO_BOX(text_format_combo_box)((((GtkComboBox*) g_type_check_instance_cast ((GTypeInstance*
) ((text_format_combo_box)), ((gtk_combo_box_get_type ())))))
)
,
1444 "\\c\\f$M\\b$T");
1445 gtk_combo_box_append_text(GTK_COMBO_BOX(text_format_combo_box)((((GtkComboBox*) g_type_check_instance_cast ((GTypeInstance*
) ((text_format_combo_box)), ((gtk_combo_box_get_type ())))))
)
,
1446 _("\\f\\ww\\r\\f$M\\D2\\f\\ar\\. $r\\D1\\f\\aw\\. $w")dcgettext ("gkrellm", "\\f\\ww\\r\\f$M\\D2\\f\\ar\\. $r\\D1\\f\\aw\\. $w"
, 5)
);
1447 gtk_combo_box_set_active(GTK_COMBO_BOX(text_format_combo_box)((((GtkComboBox*) g_type_check_instance_cast ((GTypeInstance*
) ((text_format_combo_box)), ((gtk_combo_box_get_type ())))))
)
, 0);
1448 g_signal_connect(G_OBJECT(GTK_COMBO_BOX(text_format_combo_box)), "changed",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((((((GtkComboBox*) g_type_check_instance_cast
((GTypeInstance*) ((text_format_combo_box)), ((gtk_combo_box_get_type
())))))))), (((GType) ((20) << (2))))))))), ("changed"
), (((GCallback) (cb_text_format))), (((void*)0)), ((void*)0)
, (GConnectFlags) 0)
1449 G_CALLBACK(cb_text_format), NULL)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((((((GtkComboBox*) g_type_check_instance_cast
((GTypeInstance*) ((text_format_combo_box)), ((gtk_combo_box_get_type
())))))))), (((GType) ((20) << (2))))))))), ("changed"
), (((GCallback) (cb_text_format))), (((void*)0)), ((void*)0)
, (GConnectFlags) 0)
;
1450
1451 vbox1 = gkrellm_gtk_category_vbox(vbox,
Value stored to 'vbox1' is never read
1452 _("Launch Commands")dcgettext ("gkrellm", "Launch Commands", 5),
1453 4, 0, TRUE(!(0)));
1454 launch_vbox = gkrellm_gtk_scrolled_vbox(vbox, NULL((void*)0),
1455 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1456 gtk_widget_show(launch_vbox);
1457 gtk_widget_realize(launch_vbox);
1458 for (i = 0, list = disk_mon_list; list; list = list->next, ++i)
1459 {
1460 disk = (DiskMon *) list->data;
1461 if (disk->enabled)
1462 add_launch_entry(launch_vbox, disk);
1463 }
1464
1465/* --Info tab */
1466 vbox = gkrellm_gtk_framed_notebook_page(tabs, _("Info")dcgettext ("gkrellm", "Info", 5));
1467 text = gkrellm_gtk_scrolled_text_view(vbox, NULL((void*)0),
1468 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1469 for (i = 0; i < sizeof(disk_info_text)/sizeof(gchar *); ++i)
1470 gkrellm_gtk_text_view_append(text, _(disk_info_text[i])dcgettext ("gkrellm", disk_info_text[i], 5));
1471 }
1472
1473static GkrellmMonitor monitor_disk =
1474 {
1475 N_("Disk")("Disk"), /* Name, for config tab. */
1476 MON_DISK2, /* Id, 0 if a plugin */
1477 create_disk, /* The create function */
1478 update_disk, /* The update function */
1479 create_disk_tab, /* The config tab create function */
1480 NULL((void*)0), /* Instant apply */
1481
1482 save_disk_config, /* Save user conifg */
1483 load_disk_config, /* Load user config */
1484 DISK_CONFIG_KEYWORD"disk", /* config keyword */
1485
1486 NULL((void*)0), /* Undef 2 */
1487 NULL((void*)0), /* Undef 1 */
1488 NULL((void*)0), /* Undef 0 */
1489
1490 0, /* insert_before_id - place plugin before this mon */
1491
1492 NULL((void*)0), /* Handle if a plugin, filled in by GKrellM */
1493 NULL((void*)0) /* path if a plugin, filled in by GKrellM */
1494 };
1495
1496GkrellmMonitor *
1497gkrellm_init_disk_monitor(void)
1498 {
1499 DiskMon *disk;
1500
1501 monitor_disk.name = _(monitor_disk.name)dcgettext ("gkrellm", monitor_disk.name, 5);
1502
1503 disk = disk_new("Disk", _("Disk")dcgettext ("gkrellm", "Disk", 5));
1504 disk_mon_list = g_list_append(disk_mon_list, disk);
1505
1506 composite_disk = disk;
1507 gkrellm_locale_dup_string(&text_format, DEFAULT_TEXT_FORMAT"$T",
1508 &text_format_locale);
1509 mon_disk = &monitor_disk;
1510
1511 if (setup_disk_interface())
1512 {
1513 if (n_disks > 0)
1514 composite_disk->enabled = TRUE(!(0));
1515 style_id = gkrellm_add_chart_style(&monitor_disk, DISK_STYLE_NAME"disk");
1516 return &monitor_disk;
1517 }
1518 return NULL((void*)0);
1519 }