Bug Summary

File:rc/plugins.c
Location:line 863, column 6
Description:Value stored to 'waste' 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#include <gmodule.h>
39
40#if defined(WIN32)
41 #include "win32-plugin.h"
42#endif
43
44/* ======================================================================= */
45/* Plugin interface to GKrellM.
46*/
47
48gchar *
49gkrellm_get_hostname(void)
50 {
51 gchar *hostname;
52
53 if (_GK.client_mode)
54 hostname = _GK.server_hostname;
55 else
56 hostname = gkrellm_sys_get_host_name();
57 return hostname;
58 }
59
60gchar *
61gkrellm_get_theme_path(void)
62 {
63 return _GK.theme_path;
64 }
65
66GkrellmKrell *
67gkrellm_krell_new0(void)
68 {
69 GkrellmKrell *k;
70
71 k = g_new0(GkrellmKrell, 1)(GkrellmKrell *) (__extension__ ({ gsize __n = (gsize) (1); gsize
__s = sizeof (GkrellmKrell); 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; }))
;
72 return k;
73 }
74
75GkrellmDecal *
76gkrellm_decal_new0(void)
77 {
78 GkrellmDecal *d;
79
80 d = g_new0(GkrellmDecal, 1)(GkrellmDecal *) (__extension__ ({ gsize __n = (gsize) (1); gsize
__s = sizeof (GkrellmDecal); 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; }))
;
81 return d;
82 }
83
84
85GkrellmLabel *
86gkrellm_label_new0(void)
87 {
88 GkrellmLabel *l;
89
90 l = g_new0(GkrellmLabel, 1)(GkrellmLabel *) (__extension__ ({ gsize __n = (gsize) (1); gsize
__s = sizeof (GkrellmLabel); 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; }))
;
91 return l;
92 }
93
94
95GkrellmStyle *
96gkrellm_style_new0(void)
97 {
98 GkrellmStyle *s;
99
100 s = g_new0(GkrellmStyle, 1)(GkrellmStyle *) (__extension__ ({ gsize __n = (gsize) (1); gsize
__s = sizeof (GkrellmStyle); 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; }))
;
101 return s;
102 }
103
104GkrellmStyle *
105gkrellm_copy_style(GkrellmStyle *style)
106 {
107 GkrellmStyle *s = NULL((void*)0);
108
109 if (style)
110 {
111 s = gkrellm_style_new0();
112 *s = *style;
113 }
114 return s;
115 }
116
117void
118gkrellm_copy_style_values(GkrellmStyle *dst, GkrellmStyle *src)
119 {
120 if (src && dst)
121 *dst = *src;
122 }
123
124GkrellmTextstyle *
125gkrellm_textstyle_new0(void)
126 {
127 GkrellmTextstyle *t;
128
129 t = g_new0(GkrellmTextstyle, 1)(GkrellmTextstyle *) (__extension__ ({ gsize __n = (gsize) (1
); gsize __s = sizeof (GkrellmTextstyle); 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; }))
;
130 return t;
131 }
132
133GkrellmTextstyle *
134gkrellm_copy_textstyle(GkrellmTextstyle *ts)
135 {
136 GkrellmTextstyle *t = gkrellm_textstyle_new0();
137
138 *t = *ts;
139 return t;
140 }
141
142GkrellmChart *
143gkrellm_chart_new0(void)
144 {
145 GkrellmChart *c;
146
147 c = g_new0(GkrellmChart, 1)(GkrellmChart *) (__extension__ ({ gsize __n = (gsize) (1); gsize
__s = sizeof (GkrellmChart); 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; }))
;
148 return c;
149 }
150
151GkrellmChartconfig *
152gkrellm_chartconfig_new0(void)
153 {
154 GkrellmChartconfig *config;
155
156 config = g_new0(GkrellmChartconfig, 1)(GkrellmChartconfig *) (__extension__ ({ gsize __n = (gsize) (
1); gsize __s = sizeof (GkrellmChartconfig); 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; }))
;
157 return config;
158 }
159
160GkrellmPanel *
161gkrellm_panel_new0(void)
162 {
163 GkrellmPanel *p;
164
165 p = g_new0(GkrellmPanel, 1)(GkrellmPanel *) (__extension__ ({ gsize __n = (gsize) (1); gsize
__s = sizeof (GkrellmPanel); 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; }))
;
166 p->label = gkrellm_label_new0();
167 return p;
168 }
169
170
171static GkrellmStyle *
172get_style_from_list(GList *list, gint n)
173 {
174 GList *l;
175 GkrellmStyle *style;
176
177 l = g_list_nth(list, n);
178 if (l == NULL((void*)0) || l->data == NULL((void*)0))
179 l = list;
180 if (l->data == NULL((void*)0))
181 {
182 g_warning("Warning: NULL style returned %d\n", n);
183 abort();
184 }
185 style = (GkrellmStyle *) l->data;
186 return style;
187 }
188
189GkrellmStyle *
190gkrellm_meter_style(gint n)
191 {
192 return get_style_from_list(_GK.meter_style_list, n);
193 }
194
195GkrellmStyle *
196gkrellm_panel_style(gint n)
197 {
198 return get_style_from_list(_GK.panel_style_list, n);
199 }
200
201GkrellmStyle *
202gkrellm_chart_style(gint n)
203 {
204 return get_style_from_list(_GK.chart_style_list, n);
205 }
206
207static GkrellmStyle *
208get_style_from_list_by_name(GList *name_list, GList *style_list, gchar *name)
209 {
210 GList *list;
211 gchar *p, buf[128];
212 gint n;
213
214 strncpy(buf, name, sizeof(buf))__builtin_strncpy (buf, name, sizeof(buf));
215 buf[sizeof(buf) - 1] = '\0';
216 if ( (p = strchr(buf, '.')(__extension__ (__builtin_constant_p ('.') && !__builtin_constant_p
(buf) && ('.') == '\0' ? (char *) __rawmemchr (buf, '.'
) : __builtin_strchr (buf, '.')))
) != NULL((void*)0)
217 && (n = gkrellm_string_position_in_list(_GK.custom_name_list, name)) >= 0
218 )
219 list = _GK.custom_style_list;
220 else
221 {
222 if (p)
223 *p = '\0';
224 if ((n = gkrellm_string_position_in_list(name_list, buf)) < 0)
225 n = 0;
226 list = style_list;
227 }
228 return get_style_from_list(list, n);
229 }
230
231GkrellmStyle *
232gkrellm_meter_style_by_name(gchar *name)
233 {
234 return get_style_from_list_by_name(_GK.meter_name_list,
235 _GK.meter_style_list, name);
236 }
237
238GkrellmStyle *
239gkrellm_panel_style_by_name(gchar *name)
240 {
241 return get_style_from_list_by_name(_GK.chart_name_list,
242 _GK.panel_style_list, name);
243 }
244
245GkrellmStyle *
246gkrellm_chart_style_by_name(gchar *name)
247 {
248 return get_style_from_list_by_name(_GK.chart_name_list,
249 _GK.chart_style_list, name);
250 }
251
252gint
253gkrellm_lookup_chart_style_id(gchar *name)
254 {
255 GList *list;
256 gint i;
257
258 for (list = _GK.chart_name_list, i = 0; list; list = list->next, ++i)
259 if (name && !strcmp(name, (gchar *)list->data)__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
(name) && __builtin_constant_p ((gchar *)list->data
) && (__s1_len = strlen (name), __s2_len = strlen ((gchar
*)list->data), (!((size_t)(const void *)((name) + 1) - (size_t
)(const void *)(name) == 1) || __s1_len >= 4) && (
!((size_t)(const void *)(((gchar *)list->data) + 1) - (size_t
)(const void *)((gchar *)list->data) == 1) || __s2_len >=
4)) ? __builtin_strcmp (name, (gchar *)list->data) : (__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 ((gchar *)list->
data) && ((size_t)(const void *)(((gchar *)list->data
) + 1) - (size_t)(const void *)((gchar *)list->data) == 1)
? __builtin_strcmp (name, (gchar *)list->data) : (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) ((gchar *)list->data); 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 ((gchar *)list->data) && ((size_t
)(const void *)(((gchar *)list->data) + 1) - (size_t)(const
void *)((gchar *)list->data) == 1) && (__s2_len =
strlen ((gchar *)list->data), __s2_len < 4) ? (__builtin_constant_p
(name) && ((size_t)(const void *)((name) + 1) - (size_t
)(const void *)(name) == 1) ? __builtin_strcmp (name, (gchar *
)list->data) : (- (__extension__ ({ const unsigned char *__s2
= (const unsigned char *) (const char *) (name); int __result
= (((const unsigned char *) (const char *) ((gchar *)list->
data))[0] - __s2[0]); if (__s2_len > 0 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
(gchar *)list->data))[1] - __s2[1]); if (__s2_len > 1 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) ((gchar *)list->data))[2] - __s2[2]); if (__s2_len
> 2 && __result == 0) __result = (((const unsigned
char *) (const char *) ((gchar *)list->data))[3] - __s2[3
]); } } __result; })))) : __builtin_strcmp (name, (gchar *)list
->data)))); })
)
260 return i;
261 return 0;
262 }
263
264gint
265gkrellm_lookup_meter_style_id(gchar *name)
266 {
267 GList *list;
268 gint i;
269
270 for (list = _GK.meter_name_list, i = 0; list; list = list->next, ++i)
271 if (name && !strcmp(name, (gchar *)list->data)__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
(name) && __builtin_constant_p ((gchar *)list->data
) && (__s1_len = strlen (name), __s2_len = strlen ((gchar
*)list->data), (!((size_t)(const void *)((name) + 1) - (size_t
)(const void *)(name) == 1) || __s1_len >= 4) && (
!((size_t)(const void *)(((gchar *)list->data) + 1) - (size_t
)(const void *)((gchar *)list->data) == 1) || __s2_len >=
4)) ? __builtin_strcmp (name, (gchar *)list->data) : (__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 ((gchar *)list->
data) && ((size_t)(const void *)(((gchar *)list->data
) + 1) - (size_t)(const void *)((gchar *)list->data) == 1)
? __builtin_strcmp (name, (gchar *)list->data) : (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) ((gchar *)list->data); 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 ((gchar *)list->data) && ((size_t
)(const void *)(((gchar *)list->data) + 1) - (size_t)(const
void *)((gchar *)list->data) == 1) && (__s2_len =
strlen ((gchar *)list->data), __s2_len < 4) ? (__builtin_constant_p
(name) && ((size_t)(const void *)((name) + 1) - (size_t
)(const void *)(name) == 1) ? __builtin_strcmp (name, (gchar *
)list->data) : (- (__extension__ ({ const unsigned char *__s2
= (const unsigned char *) (const char *) (name); int __result
= (((const unsigned char *) (const char *) ((gchar *)list->
data))[0] - __s2[0]); if (__s2_len > 0 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
(gchar *)list->data))[1] - __s2[1]); if (__s2_len > 1 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) ((gchar *)list->data))[2] - __s2[2]); if (__s2_len
> 2 && __result == 0) __result = (((const unsigned
char *) (const char *) ((gchar *)list->data))[3] - __s2[3
]); } } __result; })))) : __builtin_strcmp (name, (gchar *)list
->data)))); })
)
272 return i;
273 return 0;
274 }
275
276static GkrellmPiximage *
277get_piximage_from_list(GList *list, gint n)
278 {
279 GList *l;
280
281 l = g_list_nth(list, n);
282 if (l == NULL((void*)0) || l->data == NULL((void*)0))
283 l = list;
284 if (l->data == NULL((void*)0))
285 {
286 g_warning("Warning: NULL image returned %d\n", n);
287 abort();
288 }
289 return (GkrellmPiximage *) l->data;
290 }
291
292GkrellmPiximage *
293gkrellm_bg_chart_piximage(gint n)
294 {
295 return get_piximage_from_list(_GK.bg_chart_piximage_list, n);
296 }
297
298GkrellmPiximage *
299gkrellm_bg_grid_piximage(gint n)
300 {
301 return get_piximage_from_list(_GK.bg_grid_piximage_list, n);
302 }
303
304GkrellmPiximage *
305gkrellm_bg_panel_piximage(gint n)
306 {
307 return get_piximage_from_list(_GK.bg_panel_piximage_list, n);
308 }
309
310GkrellmPiximage *
311gkrellm_bg_meter_piximage(gint n)
312 {
313 return get_piximage_from_list(_GK.bg_meter_piximage_list, n);
314 }
315
316GkrellmPiximage *
317gkrellm_krell_panel_piximage(gint n)
318 {
319 return get_piximage_from_list(_GK.krell_panel_piximage_list, n);
320 }
321
322GkrellmPiximage *
323gkrellm_krell_meter_piximage(gint n)
324 {
325 return get_piximage_from_list(_GK.krell_meter_piximage_list, n);
326 }
327
328void
329gkrellm_get_decal_alarm_piximage(GkrellmPiximage **im, gint *frames)
330 {
331 if (im)
332 *im = _GK.decal_alarm_piximage;
333 if (frames)
334 *frames = _GK.decal_alarm_frames;
335 }
336
337void
338gkrellm_get_decal_warn_piximage(GkrellmPiximage **im, gint *frames)
339 {
340 if (im)
341 *im = _GK.decal_warn_piximage;
342 if (frames)
343 *frames = _GK.decal_warn_frames;
344 }
345
346
347void
348gkrellm_monitor_height_adjust(gint h)
349 {
350 _GK.monitor_height += h;
351 }
352
353GdkPixmap *
354gkrellm_decal_misc_pixmap(void)
355 {
356 return _GK.decal_misc_pixmap;
357 }
358
359GdkBitmap *
360gkrellm_decal_misc_mask(void)
361 {
362 return _GK.decal_misc_mask;
363 }
364
365GdkPixmap **
366gkrellm_data_in_pixmap(void)
367 {
368 return &_GK.data_in_pixmap;
369 }
370
371GdkPixmap *
372gkrellm_data_in_grid_pixmap(void)
373 {
374 return _GK.data_in_grid_pixmap;
375 }
376
377GdkPixmap **
378gkrellm_data_out_pixmap(void)
379 {
380 return &_GK.data_out_pixmap;
381 }
382
383GdkPixmap *
384gkrellm_data_out_grid_pixmap(void)
385 {
386 return _GK.data_out_grid_pixmap;
387 }
388
389GkrellmPiximage *
390gkrellm_krell_slider_piximage(void)
391 {
392 return _GK.krell_slider_piximage;
393 }
394
395GkrellmStyle *
396gkrellm_krell_slider_style(void)
397 {
398 return _GK.krell_slider_style;
399 }
400
401GkrellmPiximage *
402gkrellm_krell_mini_piximage(void)
403 {
404 return _GK.krell_mini_piximage;
405 }
406
407GkrellmStyle *
408gkrellm_krell_mini_style(void)
409 {
410 return _GK.krell_mini_style;
411 }
412
413GdkGC *
414gkrellm_draw_GC(gint n)
415 {
416 GdkGC *gc;
417
418 if (n == 0)
419 return _GK.draw_stencil_GC;
420 else if (n == 1)
421 gc = _GK.draw1_GC;
422 else if (n == 2)
423 gc = _GK.draw2_GC;
424 else
425 gc = _GK.draw3_GC;
426 return gc;
427 }
428
429GdkGC *
430gkrellm_bit_GC(gint n)
431 {
432 if (n == 0)
433 return _GK.bit0_GC;
434 else
435 return _GK.bit1_GC;
436 }
437
438GkrellmTextstyle *
439gkrellm_chart_textstyle(gint n)
440 {
441 GkrellmStyle *style;
442 GkrellmTextstyle *ts;
443
444 style = get_style_from_list(_GK.chart_style_list, n);
445 ts = &style->label_tsA;
446 ts->font = *(ts->font_seed);
447 return ts;
448 }
449
450GkrellmTextstyle *
451gkrellm_panel_textstyle(gint n)
452 {
453 GkrellmStyle *style;
454 GkrellmTextstyle *ts;
455
456 style = get_style_from_list(_GK.panel_style_list, n);
457 ts = &style->label_tsA;
458 ts->font = *(ts->font_seed);
459 return ts;
460 }
461
462GkrellmTextstyle *
463gkrellm_meter_textstyle(gint n)
464 {
465 GkrellmStyle *style;
466 GkrellmTextstyle *ts;
467
468 style = get_style_from_list(_GK.meter_style_list, n);
469 ts = &style->label_tsA;
470 ts->font = *(ts->font_seed);
471 return ts;
472 }
473
474
475GkrellmTextstyle *
476gkrellm_chart_alt_textstyle(gint n)
477 {
478 GkrellmStyle *style;
479 GkrellmTextstyle *ts;
480
481 style = get_style_from_list(_GK.chart_style_list, n);
482 ts = &style->label_tsB;
483 ts->font = *(ts->font_seed);
484 return ts;
485 }
486
487GkrellmTextstyle *
488gkrellm_panel_alt_textstyle(gint n)
489 {
490 GkrellmStyle *style;
491 GkrellmTextstyle *ts;
492
493 style = get_style_from_list(_GK.panel_style_list, n);
494 ts = &style->label_tsB;
495 ts->font = *(ts->font_seed);
496 return ts;
497 }
498
499GkrellmTextstyle *
500gkrellm_meter_alt_textstyle(gint n)
501 {
502 GkrellmStyle *style;
503 GkrellmTextstyle *ts;
504
505 style = get_style_from_list(_GK.meter_style_list, n);
506 ts = &style->label_tsB;
507 ts->font = *(ts->font_seed);
508 return ts;
509 }
510
511PangoFontDescription *
512gkrellm_default_font(gint n)
513 {
514 if (n == 0)
515 return _GK.small_font;
516 else if (n == 1)
517 return _GK.normal_font;
518 else
519 return _GK.large_font;
520 }
521
522GdkColor *
523gkrellm_white_color(void)
524 {
525 return &_GK.white_color;
526 }
527
528GdkColor *
529gkrellm_black_color(void)
530 {
531 return &_GK.background_color;
532 }
533
534GdkColor *
535gkrellm_in_color(void)
536 {
537 return &_GK.in_color;
538 }
539
540GdkColor *
541gkrellm_out_color(void)
542 {
543 return &_GK.out_color;
544 }
545
546gboolean
547gkrellm_demo_mode(void)
548 {
549 return _GK.demo;
550 }
551
552gint
553gkrellm_update_HZ(void)
554 {
555 return _GK.update_HZ;
556 }
557
558gint
559gkrellm_chart_width(void)
560 {
561 return _GK.chart_width;
562 }
563
564void
565gkrellm_allow_scaling(gboolean *allow, gint *width_ref)
566 {
567 if (allow)
568 *allow = _GK.allow_scaling;
569 if (width_ref)
570 *width_ref = _GK.chart_width_ref;
571 }
572
573gint
574gkrellm_plugin_debug(void)
575 {
576 return _GK.debug;
577 }
578
579/* ======================================================================= */
580typedef struct
581 {
582 GkrellmMonitor *mon_plugin,
583 *mon_target;
584 gchar key;
585 gchar *(*func)(gchar key, gchar *which);
586 gint id;
587 }
588 ExportLabel;
589
590static GList *export_label_list;
591
592gint
593gkrellm_plugin_export_label(GkrellmMonitor *mon_plugin, gchar *mon_name,
594 gchar key, gchar *(*func)(gchar key, gchar *which))
595 {
596 GkrellmMonitor *mon;
597 ExportLabel *el;
598 GList *list;
599 static gint id;
600
601 if (!mon_name || !mon_plugin || !func || !key)
602 return -1;
603 for (list = gkrellm_monitor_list; list; list = list->next)
604 {
605 mon = (GkrellmMonitor *) list->data;
606 if (mon->name && (_GK.debug_level & DEBUG_PLUGIN0x20000))
607 g_print(" %s %s\n", mon->name, mon_name);
608 if (mon->name && !strcmp(mon->name, mon_name)__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
(mon->name) && __builtin_constant_p (mon_name) &&
(__s1_len = strlen (mon->name), __s2_len = strlen (mon_name
), (!((size_t)(const void *)((mon->name) + 1) - (size_t)(const
void *)(mon->name) == 1) || __s1_len >= 4) && (
!((size_t)(const void *)((mon_name) + 1) - (size_t)(const void
*)(mon_name) == 1) || __s2_len >= 4)) ? __builtin_strcmp (
mon->name, mon_name) : (__builtin_constant_p (mon->name
) && ((size_t)(const void *)((mon->name) + 1) - (size_t
)(const void *)(mon->name) == 1) && (__s1_len = strlen
(mon->name), __s1_len < 4) ? (__builtin_constant_p (mon_name
) && ((size_t)(const void *)((mon_name) + 1) - (size_t
)(const void *)(mon_name) == 1) ? __builtin_strcmp (mon->name
, mon_name) : (__extension__ ({ const unsigned char *__s2 = (
const unsigned char *) (const char *) (mon_name); int __result
= (((const unsigned char *) (const char *) (mon->name))[0
] - __s2[0]); if (__s1_len > 0 && __result == 0) {
__result = (((const unsigned char *) (const char *) (mon->
name))[1] - __s2[1]); if (__s1_len > 1 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
mon->name))[2] - __s2[2]); if (__s1_len > 2 && __result
== 0) __result = (((const unsigned char *) (const char *) (mon
->name))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p
(mon_name) && ((size_t)(const void *)((mon_name) + 1
) - (size_t)(const void *)(mon_name) == 1) && (__s2_len
= strlen (mon_name), __s2_len < 4) ? (__builtin_constant_p
(mon->name) && ((size_t)(const void *)((mon->name
) + 1) - (size_t)(const void *)(mon->name) == 1) ? __builtin_strcmp
(mon->name, mon_name) : (- (__extension__ ({ const unsigned
char *__s2 = (const unsigned char *) (const char *) (mon->
name); int __result = (((const unsigned char *) (const char *
) (mon_name))[0] - __s2[0]); if (__s2_len > 0 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
mon_name))[1] - __s2[1]); if (__s2_len > 1 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
mon_name))[2] - __s2[2]); if (__s2_len > 2 && __result
== 0) __result = (((const unsigned char *) (const char *) (mon_name
))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (mon
->name, mon_name)))); })
)
609 break;
610 }
611 if (!list)
612 return -1;
613
614 el = g_new0(ExportLabel, 1)(ExportLabel *) (__extension__ ({ gsize __n = (gsize) (1); gsize
__s = sizeof (ExportLabel); 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; }))
;
615 export_label_list = g_list_append(export_label_list, el);
616 el->mon_target = mon;
617 el->mon_plugin = mon_plugin;
618 el->key = key;
619 el->func = func;
620 el->id = ++id;
621
622 return id;
623 }
624
625void
626gkrellm_plugin_cancel_label(GkrellmMonitor *mon_plugin, gint id)
627 {
628 GList *list;
629 ExportLabel *el;
630
631 if (!mon_plugin || id < 1)
632 return;
633 for (list = export_label_list; list; list = list->next)
634 {
635 el = (ExportLabel *) list->data;
636 if (el->id == id)
637 {
638 export_label_list = g_list_remove(export_label_list, el);
639 g_free(el);
640 break;
641 }
642 }
643 }
644
645gchar *
646gkrellm_plugin_get_exported_label(GkrellmMonitor *mon, gchar key, gchar *which)
647 {
648 GList *list;
649 ExportLabel *el;
650 gchar *result = NULL((void*)0);
651
652 for (list = export_label_list; list; list = list->next)
653 {
654 el = (ExportLabel *) list->data;
655 if ( el->mon_target == mon && el->key == key
656 && el->mon_plugin->privat->enabled && el->func
657 )
658 {
659 result = (*el->func)(key, which);
660 break;
661 }
662 }
663 return result;
664 }
665
666/* ======================================================================= */
667
668static GkrellmMonitor *place_plugin;
669
670enum
671 {
672 NAME_COLUMN,
673 ENABLE_COLUMN,
674 MON_COLUMN,
675 N_COLUMNS
676 };
677
678static GtkTreeView *treeview;
679static GtkTreeRowReference *row_reference;
680
681static GtkWidget *place_label,
682 *place_button,
683 *after_button,
684 *before_button,
685 *gravity_spin_button,
686 *builtin_button[N_BUILTIN_MONITORS16];
687
688static GList *plugins_list,
689 *plugins_enable_list,
690 *plugins_place_list;
691
692static gboolean plugin_enable_list_modified,
693 plugin_placement_modified;
694
695gchar *plugin_install_log;
696
697
698GkrellmMonitor *
699gkrellm_monitor_from_id(gint id)
700 {
701 GList *list;
702 GkrellmMonitor *mon;
703
704 for (list = gkrellm_monitor_list; list; list = list->next)
705 {
706 mon = (GkrellmMonitor *) list->data;
707 if (mon->id == id)
708 return mon;
709 }
710 return NULL((void*)0);
711 }
712
713GkrellmMonitor *
714lookup_monitor_from_name(gchar *name)
715 {
716 GkrellmMonitor *mon;
717 GList *list;
718
719 for (list = gkrellm_monitor_list; list; list = list->next)
720 {
721 mon = (GkrellmMonitor *) list->data;
722 if (!mon->name || mon->id < 0)
723 continue;
724 if (!strcmp(name, mon->name)__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
(name) && __builtin_constant_p (mon->name) &&
(__s1_len = strlen (name), __s2_len = strlen (mon->name),
(!((size_t)(const void *)((name) + 1) - (size_t)(const void *
)(name) == 1) || __s1_len >= 4) && (!((size_t)(const
void *)((mon->name) + 1) - (size_t)(const void *)(mon->
name) == 1) || __s2_len >= 4)) ? __builtin_strcmp (name, mon
->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 (mon->name) && ((size_t)(const
void *)((mon->name) + 1) - (size_t)(const void *)(mon->
name) == 1) ? __builtin_strcmp (name, mon->name) : (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) (mon->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 (mon->name) && ((size_t)(const
void *)((mon->name) + 1) - (size_t)(const void *)(mon->
name) == 1) && (__s2_len = strlen (mon->name), __s2_len
< 4) ? (__builtin_constant_p (name) && ((size_t)(
const void *)((name) + 1) - (size_t)(const void *)(name) == 1
) ? __builtin_strcmp (name, mon->name) : (- (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) (name); int __result = (((const unsigned char *) (const
char *) (mon->name))[0] - __s2[0]); if (__s2_len > 0 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) (mon->name))[1] - __s2[1]); if (__s2_len > 1 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) (mon->name))[2] - __s2[2]); if (__s2_len > 2 &&
__result == 0) __result = (((const unsigned char *) (const char
*) (mon->name))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp
(name, mon->name)))); })
)
725 return mon;
726 }
727 return NULL((void*)0);
728 }
729
730GkrellmMonitor *
731gkrellm_monitor_from_style_name(gchar *style_name)
732 {
733 GkrellmMonitor *mon;
734 GList *list;
735
736 for (list = gkrellm_monitor_list; list; list = list->next)
737 {
738 mon = (GkrellmMonitor *) list->data;
739 if (!mon->privat || !mon->privat->style_name)
740 continue;
741 if (!strcmp(style_name, mon->privat->style_name)__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
(style_name) && __builtin_constant_p (mon->privat
->style_name) && (__s1_len = strlen (style_name), __s2_len
= strlen (mon->privat->style_name), (!((size_t)(const void
*)((style_name) + 1) - (size_t)(const void *)(style_name) ==
1) || __s1_len >= 4) && (!((size_t)(const void *)
((mon->privat->style_name) + 1) - (size_t)(const void *
)(mon->privat->style_name) == 1) || __s2_len >= 4)) ?
__builtin_strcmp (style_name, mon->privat->style_name)
: (__builtin_constant_p (style_name) && ((size_t)(const
void *)((style_name) + 1) - (size_t)(const void *)(style_name
) == 1) && (__s1_len = strlen (style_name), __s1_len <
4) ? (__builtin_constant_p (mon->privat->style_name) &&
((size_t)(const void *)((mon->privat->style_name) + 1)
- (size_t)(const void *)(mon->privat->style_name) == 1
) ? __builtin_strcmp (style_name, mon->privat->style_name
) : (__extension__ ({ const unsigned char *__s2 = (const unsigned
char *) (const char *) (mon->privat->style_name); int __result
= (((const unsigned char *) (const char *) (style_name))[0] -
__s2[0]); if (__s1_len > 0 && __result == 0) { __result
= (((const unsigned char *) (const char *) (style_name))[1] -
__s2[1]); if (__s1_len > 1 && __result == 0) { __result
= (((const unsigned char *) (const char *) (style_name))[2] -
__s2[2]); if (__s1_len > 2 && __result == 0) __result
= (((const unsigned char *) (const char *) (style_name))[3] -
__s2[3]); } } __result; }))) : (__builtin_constant_p (mon->
privat->style_name) && ((size_t)(const void *)((mon
->privat->style_name) + 1) - (size_t)(const void *)(mon
->privat->style_name) == 1) && (__s2_len = strlen
(mon->privat->style_name), __s2_len < 4) ? (__builtin_constant_p
(style_name) && ((size_t)(const void *)((style_name)
+ 1) - (size_t)(const void *)(style_name) == 1) ? __builtin_strcmp
(style_name, mon->privat->style_name) : (- (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) (style_name); int __result = (((const unsigned char *
) (const char *) (mon->privat->style_name))[0] - __s2[0
]); if (__s2_len > 0 && __result == 0) { __result =
(((const unsigned char *) (const char *) (mon->privat->
style_name))[1] - __s2[1]); if (__s2_len > 1 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
mon->privat->style_name))[2] - __s2[2]); if (__s2_len >
2 && __result == 0) __result = (((const unsigned char
*) (const char *) (mon->privat->style_name))[3] - __s2
[3]); } } __result; })))) : __builtin_strcmp (style_name, mon
->privat->style_name)))); })
)
742 return mon;
743 }
744 return NULL((void*)0);
745 }
746
747static void
748plugin_log(gchar *string1, ...)
749 {
750 va_list args;
751 gchar *s, *old_log;
752
753 if (!string1)
754 return;
755 va_start(args, string1)__builtin_va_start(args, string1);
756 s = string1;
757 while (s)
758 {
759 old_log = plugin_install_log;
760 if (plugin_install_log)
761 plugin_install_log = g_strconcat(plugin_install_log, s, NULL((void*)0));
762 else
763 plugin_install_log = g_strconcat(s, NULL((void*)0));
764 g_free(old_log);
765 s = va_arg(args, gchar *)__builtin_va_arg(args, gchar *);
766 }
767 va_end(args)__builtin_va_end(args);
768 }
769
770static gboolean
771user_placement(GkrellmMonitor *plugin)
772 {
773 GList *list;
774 GkrellmMonitor *mon;
775 gchar *line, *s, *plugin_name, *mon_name;
776 gint n, after, gravity;
777
778 if (!plugin->name)
779 return FALSE(0);
780 for (list = plugins_place_list; list; list = list->next)
781 {
782 line = g_strconcat((gchar *) list->data, NULL((void*)0));
783 plugin_name = gkrellm_cut_quoted_string(line, &s);
784 mon_name = gkrellm_cut_quoted_string(s, &s);
785 n = sscanf(s, "%d %d", &after, &gravity);
786 if (n == 2)
787 {
788 if (after)
789 gravity = 0;
790 if ( !strcmp(plugin_name, plugin->name)__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
(plugin_name) && __builtin_constant_p (plugin->name
) && (__s1_len = strlen (plugin_name), __s2_len = strlen
(plugin->name), (!((size_t)(const void *)((plugin_name) +
1) - (size_t)(const void *)(plugin_name) == 1) || __s1_len >=
4) && (!((size_t)(const void *)((plugin->name) + 1
) - (size_t)(const void *)(plugin->name) == 1) || __s2_len
>= 4)) ? __builtin_strcmp (plugin_name, plugin->name) :
(__builtin_constant_p (plugin_name) && ((size_t)(const
void *)((plugin_name) + 1) - (size_t)(const void *)(plugin_name
) == 1) && (__s1_len = strlen (plugin_name), __s1_len
< 4) ? (__builtin_constant_p (plugin->name) &&
((size_t)(const void *)((plugin->name) + 1) - (size_t)(const
void *)(plugin->name) == 1) ? __builtin_strcmp (plugin_name
, plugin->name) : (__extension__ ({ const unsigned char *__s2
= (const unsigned char *) (const char *) (plugin->name); int
__result = (((const unsigned char *) (const char *) (plugin_name
))[0] - __s2[0]); if (__s1_len > 0 && __result == 0
) { __result = (((const unsigned char *) (const char *) (plugin_name
))[1] - __s2[1]); if (__s1_len > 1 && __result == 0
) { __result = (((const unsigned char *) (const char *) (plugin_name
))[2] - __s2[2]); if (__s1_len > 2 && __result == 0
) __result = (((const unsigned char *) (const char *) (plugin_name
))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p (
plugin->name) && ((size_t)(const void *)((plugin->
name) + 1) - (size_t)(const void *)(plugin->name) == 1) &&
(__s2_len = strlen (plugin->name), __s2_len < 4) ? (__builtin_constant_p
(plugin_name) && ((size_t)(const void *)((plugin_name
) + 1) - (size_t)(const void *)(plugin_name) == 1) ? __builtin_strcmp
(plugin_name, plugin->name) : (- (__extension__ ({ const unsigned
char *__s2 = (const unsigned char *) (const char *) (plugin_name
); int __result = (((const unsigned char *) (const char *) (plugin
->name))[0] - __s2[0]); if (__s2_len > 0 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
plugin->name))[1] - __s2[1]); if (__s2_len > 1 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) (plugin->name))[2] - __s2[2]); if (__s2_len > 2
&& __result == 0) __result = (((const unsigned char *
) (const char *) (plugin->name))[3] - __s2[3]); } } __result
; })))) : __builtin_strcmp (plugin_name, plugin->name))));
})
791 && (mon = lookup_monitor_from_name(mon_name)) != NULL((void*)0)
792 )
793 {
794 plugin->privat->insert_before_id = mon->id;
795 plugin->privat->gravity = gravity;
796 plugin->privat->insert_after = after;
797 g_free(line);
798 return TRUE(!(0));
799 }
800 }
801 g_free(line);
802 }
803 return FALSE(0);
804 }
805
806void
807gkrellm_place_plugin(GList **monitor_list, GkrellmMonitor *plugin)
808 {
809 GkrellmMonitor *mon;
810 GList *list, *plist, *waste;
811 gint n, gravity, after_flag;
812 gchar buf[120];
813
814 if (plugin->create_monitor && !plugin->privat->main_vbox)
815 {
816 plugin->privat->main_vbox = gtk_vbox_new(FALSE(0), 0);
817 plugin->privat->top_spacer.vbox = gtk_vbox_new(FALSE(0), 0);
818 plugin->privat->vbox = gtk_vbox_new(FALSE(0), 0);
819 plugin->privat->bottom_spacer.vbox = gtk_vbox_new(FALSE(0), 0);
820 }
821 for (plist = NULL((void*)0), list = *monitor_list; list; list = list->next)
822 {
823 mon = (GkrellmMonitor *) list->data;
824
825 /* Save list position as plugins are encountered so we can later
826 | walk through them looking at gravity.
827 */
828 if (MONITOR_ID(mon)((mon)->id & 0x1f) == MON_PLUGIN16 && plist == NULL((void*)0))
829 plist = list;
830 if (MONITOR_ID(mon)((mon)->id & 0x1f) == plugin->privat->insert_before_id)
831 {
832 after_flag = plugin->privat->insert_after;
833 gravity = plugin->privat->gravity;
834 snprintf(buf, sizeof(buf), _("\t%s: placement is %s %s G:%d\n")dcgettext ("gkrellm", "\t%s: placement is %s %s G:%d\n", 5),
835 plugin->name,
836 after_flag ? _("after")dcgettext ("gkrellm", "after", 5) : _("before")dcgettext ("gkrellm", "before", 5), mon->name, gravity);
837 plugin_log(buf, NULL((void*)0));
838 if (after_flag)
839 {
840 if ((n = g_list_position(*monitor_list, list)) < 0)
841 n = 0;
842 *monitor_list = g_list_insert(*monitor_list, plugin, n + 1);
843 }
844 else
845 {
846 /* If there are plugins already above this builtin, then place
847 | based on gravity. Insert above the first plugin found that
848 | has greater gravity than the current placing plugin.
849 */
850 if (plist)
851 {
852 for ( ; plist != list; plist = plist->next)
853 {
854 mon = (GkrellmMonitor *) plist->data;
855 if (mon->privat->gravity > gravity)
856 break;
857 }
858 list = plist;
859 }
860 if (list == *monitor_list)
861 *monitor_list = g_list_prepend(list, plugin);
862 else
863 waste = g_list_prepend(list, plugin);
Value stored to 'waste' is never read
864 }
865 return;
866 }
867 else if (MONITOR_ID(mon)((mon)->id & 0x1f) != MON_PLUGIN16)
868 plist = NULL((void*)0);
869 }
870 if (plugin->privat->insert_before_id != MON_UPTIME9)
871 {
872 plugin->privat->insert_before_id = MON_UPTIME9;
873 gkrellm_place_plugin(monitor_list, plugin);
874 return;
875 }
876 *monitor_list = g_list_append(*monitor_list, plugin);
877 }
878
879GkrellmMonitor *
880install_plugin(gchar *plugin_name)
881 {
882 GList *list;
883 GModule *module;
884 GkrellmMonitor *m, *mm;
885 GkrellmMonitor *(*init_plugin)();
886 gchar buf[256];
887 static GkrellmMonitor mon_tmp;
888
889 if (!g_module_supported())
890 return NULL((void*)0);
891 module = g_module_open(plugin_name, 0);
892 plugin_log(plugin_name, "\n", NULL((void*)0));
893
894 if (! module)
895 {
896 snprintf(buf, sizeof(buf), _("\tError: %s\n")dcgettext ("gkrellm", "\tError: %s\n", 5), g_module_error());
897 plugin_log(buf, NULL((void*)0));
898 return NULL((void*)0);
899 }
900 if (!g_module_symbol(module, "gkrellm_init_plugin",
901 (gpointer) &init_plugin))
902 {
903 snprintf(buf, sizeof(buf), _("\tError: %s\n")dcgettext ("gkrellm", "\tError: %s\n", 5), g_module_error());
904 plugin_log(buf, NULL((void*)0));
905 g_module_close(module);
906 return NULL((void*)0);
907 }
908 _GK.no_messages = TRUE(!(0)); /* Enforce policy */
909
910 mon_tmp.name = g_strdup(plugin_name);
911 gkrellm_record_state(INIT_MONITOR, &mon_tmp);
912
913#if defined(WIN32)
914 {
915 win32_plugin_callbacks ** plugin_cb = NULL((void*)0);
916
917 if (!g_module_symbol(module, "callbacks", (gpointer) &plugin_cb))
918 {
919 snprintf(buf, sizeof(buf), _("\tError: %s\n")dcgettext ("gkrellm", "\tError: %s\n", 5), g_module_error());
920 plugin_log(buf, NULL((void*)0));
921 g_module_close(module);
922 return NULL((void*)0);
923 }
924 *plugin_cb = &gkrellm_callbacks;
925 }
926#endif
927
928 m = (*init_plugin)();
929
930 _GK.no_messages = FALSE(0);
931
932 g_free(mon_tmp.name);
933 mon_tmp.name = NULL((void*)0);
934 gkrellm_record_state(INTERNAL, NULL((void*)0));
935
936 if (m == NULL((void*)0))
937 {
938 plugin_log(_("\tOoops! plugin returned NULL, aborting\n")dcgettext ("gkrellm", "\tOoops! plugin returned NULL, aborting\n"
, 5)
, NULL((void*)0));
939 g_module_close(module);
940 return NULL((void*)0);
941 }
942 for (list = gkrellm_monitor_list; list; list = list->next)
943 {
944 mm = (GkrellmMonitor *) list->data;
945 if ( !mm->privat || !mm->privat->style_name
946 || !m->privat || !m->privat->style_name
947 || strcmp(mm->privat->style_name, m->privat->style_name)__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
(mm->privat->style_name) && __builtin_constant_p
(m->privat->style_name) && (__s1_len = strlen (
mm->privat->style_name), __s2_len = strlen (m->privat
->style_name), (!((size_t)(const void *)((mm->privat->
style_name) + 1) - (size_t)(const void *)(mm->privat->style_name
) == 1) || __s1_len >= 4) && (!((size_t)(const void
*)((m->privat->style_name) + 1) - (size_t)(const void *
)(m->privat->style_name) == 1) || __s2_len >= 4)) ? __builtin_strcmp
(mm->privat->style_name, m->privat->style_name) :
(__builtin_constant_p (mm->privat->style_name) &&
((size_t)(const void *)((mm->privat->style_name) + 1) -
(size_t)(const void *)(mm->privat->style_name) == 1) &&
(__s1_len = strlen (mm->privat->style_name), __s1_len <
4) ? (__builtin_constant_p (m->privat->style_name) &&
((size_t)(const void *)((m->privat->style_name) + 1) -
(size_t)(const void *)(m->privat->style_name) == 1) ? __builtin_strcmp
(mm->privat->style_name, m->privat->style_name) :
(__extension__ ({ const unsigned char *__s2 = (const unsigned
char *) (const char *) (m->privat->style_name); int __result
= (((const unsigned char *) (const char *) (mm->privat->
style_name))[0] - __s2[0]); if (__s1_len > 0 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
mm->privat->style_name))[1] - __s2[1]); if (__s1_len >
1 && __result == 0) { __result = (((const unsigned char
*) (const char *) (mm->privat->style_name))[2] - __s2[
2]); if (__s1_len > 2 && __result == 0) __result =
(((const unsigned char *) (const char *) (mm->privat->
style_name))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p
(m->privat->style_name) && ((size_t)(const void
*)((m->privat->style_name) + 1) - (size_t)(const void *
)(m->privat->style_name) == 1) && (__s2_len = strlen
(m->privat->style_name), __s2_len < 4) ? (__builtin_constant_p
(mm->privat->style_name) && ((size_t)(const void
*)((mm->privat->style_name) + 1) - (size_t)(const void
*)(mm->privat->style_name) == 1) ? __builtin_strcmp (mm
->privat->style_name, m->privat->style_name) : (-
(__extension__ ({ const unsigned char *__s2 = (const unsigned
char *) (const char *) (mm->privat->style_name); int __result
= (((const unsigned char *) (const char *) (m->privat->
style_name))[0] - __s2[0]); if (__s2_len > 0 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
m->privat->style_name))[1] - __s2[1]); if (__s2_len >
1 && __result == 0) { __result = (((const unsigned char
*) (const char *) (m->privat->style_name))[2] - __s2[2
]); if (__s2_len > 2 && __result == 0) __result = (
((const unsigned char *) (const char *) (m->privat->style_name
))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (mm->
privat->style_name, m->privat->style_name)))); })
948 )
949 continue;
950 plugin_log(_("\tWarning: style name \"")dcgettext ("gkrellm", "\tWarning: style name \"", 5), m->privat->style_name,
951 _("\" already used by:\n\t\t")dcgettext ("gkrellm", "\" already used by:\n\t\t", 5), mm->path, "\n", NULL((void*)0));
952 }
953 for (list = gkrellm_monitor_list; list; list = list->next)
954 {
955 mm = (GkrellmMonitor *) list->data;
956 if ( !mm->config_keyword || !m->config_keyword
957 || strcmp(mm->config_keyword, m->config_keyword)__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
(mm->config_keyword) && __builtin_constant_p (m->
config_keyword) && (__s1_len = strlen (mm->config_keyword
), __s2_len = strlen (m->config_keyword), (!((size_t)(const
void *)((mm->config_keyword) + 1) - (size_t)(const void *
)(mm->config_keyword) == 1) || __s1_len >= 4) &&
(!((size_t)(const void *)((m->config_keyword) + 1) - (size_t
)(const void *)(m->config_keyword) == 1) || __s2_len >=
4)) ? __builtin_strcmp (mm->config_keyword, m->config_keyword
) : (__builtin_constant_p (mm->config_keyword) && (
(size_t)(const void *)((mm->config_keyword) + 1) - (size_t
)(const void *)(mm->config_keyword) == 1) && (__s1_len
= strlen (mm->config_keyword), __s1_len < 4) ? (__builtin_constant_p
(m->config_keyword) && ((size_t)(const void *)((m
->config_keyword) + 1) - (size_t)(const void *)(m->config_keyword
) == 1) ? __builtin_strcmp (mm->config_keyword, m->config_keyword
) : (__extension__ ({ const unsigned char *__s2 = (const unsigned
char *) (const char *) (m->config_keyword); int __result =
(((const unsigned char *) (const char *) (mm->config_keyword
))[0] - __s2[0]); if (__s1_len > 0 && __result == 0
) { __result = (((const unsigned char *) (const char *) (mm->
config_keyword))[1] - __s2[1]); if (__s1_len > 1 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) (mm->config_keyword))[2] - __s2[2]); if (__s1_len
> 2 && __result == 0) __result = (((const unsigned
char *) (const char *) (mm->config_keyword))[3] - __s2[3]
); } } __result; }))) : (__builtin_constant_p (m->config_keyword
) && ((size_t)(const void *)((m->config_keyword) +
1) - (size_t)(const void *)(m->config_keyword) == 1) &&
(__s2_len = strlen (m->config_keyword), __s2_len < 4) ?
(__builtin_constant_p (mm->config_keyword) && ((size_t
)(const void *)((mm->config_keyword) + 1) - (size_t)(const
void *)(mm->config_keyword) == 1) ? __builtin_strcmp (mm->
config_keyword, m->config_keyword) : (- (__extension__ ({ const
unsigned char *__s2 = (const unsigned char *) (const char *)
(mm->config_keyword); int __result = (((const unsigned char
*) (const char *) (m->config_keyword))[0] - __s2[0]); if (
__s2_len > 0 && __result == 0) { __result = (((const
unsigned char *) (const char *) (m->config_keyword))[1] -
__s2[1]); if (__s2_len > 1 && __result == 0) { __result
= (((const unsigned char *) (const char *) (m->config_keyword
))[2] - __s2[2]); if (__s2_len > 2 && __result == 0
) __result = (((const unsigned char *) (const char *) (m->
config_keyword))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp
(mm->config_keyword, m->config_keyword)))); })
958 )
959 continue;
960 plugin_log(_("\tWarning: config keyword \"")dcgettext ("gkrellm", "\tWarning: config keyword \"", 5), m->config_keyword,
961 _("\" already used by:\n\t\t")dcgettext ("gkrellm", "\" already used by:\n\t\t", 5), mm->path, "\n", NULL((void*)0));
962 }
963 m->handle = module;
964 m->path = plugin_name;
965 if (!m->name)
966 m->name = g_path_get_basename(m->path);
967 if (m->privat == NULL((void*)0)) /* Won't be null if style was added */
968 m->privat = g_new0(GkrellmMonprivate, 1)(GkrellmMonprivate *) (__extension__ ({ gsize __n = (gsize) (
1); gsize __s = sizeof (GkrellmMonprivate); 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; }))
;
969 m->privat->enabled = TRUE(!(0));
970
971 /* Enforce some id fields.
972 */
973 m->id &= ~(MON_ID_MASK0x1f | MON_CONFIG_MASK0xf00);
974 m->id |= MON_PLUGIN16;
975 if (PLUGIN_INSERT_BEFORE_ID(m)((m)->insert_before_id & 0x1f) >= N_BUILTIN_MONITORS16)
976 m->insert_before_id = MON_UPTIME9;
977 if (!user_placement(m))
978 {
979 m->privat->insert_before_id = PLUGIN_INSERT_BEFORE_ID(m)((m)->insert_before_id & 0x1f);
980 m->privat->gravity = PLUGIN_GRAVITY(m)(((m)->insert_before_id & 0xf000) >> 12);
981 m->privat->insert_after = PLUGIN_INSERT_AFTER(m)(((m)->insert_before_id & 0x200) >> 9);
982 }
983 gkrellm_place_plugin(&gkrellm_monitor_list, m);
984 return m;
985 }
986
987pid_t
988gkrellm_get_pid(void)
989 {
990 return getpid();
991 }
992
993void
994gkrellm_disable_plugin_connect(GkrellmMonitor *mon, void (*cb_func)())
995 {
996 if (!mon || !mon->privat || !cb_func)
997 return;
998 mon->privat->cb_disable_plugin = cb_func;
999 }
1000
1001static void
1002disable_plugin(GkrellmMonitor *plugin)
1003 {
1004 GkrellmMonprivate *mp = plugin->privat;
1005
1006 if (!mp->enabled)
1007 return;
1008 if (mp->top_spacer.image)
1009 gtk_widget_destroy(mp->top_spacer.image);
1010 mp->top_spacer.image = NULL((void*)0);
1011 if (mp->bottom_spacer.image)
1012 gtk_widget_destroy(mp->bottom_spacer.image);
1013 mp->bottom_spacer.image = NULL((void*)0);
1014
1015 /* It is not safe to destroy a plugin widget tree.
1016 | They have already done one time first_create stuff.
1017 */
1018 gtk_widget_hide(mp->vbox);
1019 gtk_widget_hide(mp->main_vbox);
1020 mp->enabled = FALSE(0);
1021 if (mp->cb_disable_plugin)
1022 (*mp->cb_disable_plugin)();
1023 gkrellm_build();
1024 gkrellm_remove_plugin_config_page(plugin);
1025 plugin_enable_list_modified = TRUE(!(0));
1026 }
1027
1028static void
1029enable_plugin(GkrellmMonitor *plugin)
1030 {
1031 GkrellmMonprivate *mp = plugin->privat;
1032
1033 if (mp->enabled)
1034 return;
1035 gtk_widget_show(mp->vbox);
1036 gtk_widget_show(mp->main_vbox);
1037 mp->enabled = TRUE(!(0));
1038 gkrellm_load_user_config(plugin, TRUE(!(0)));
1039 gkrellm_build();
1040 gkrellm_add_plugin_config_page(plugin);
1041 plugin_enable_list_modified = TRUE(!(0));
1042 }
1043
1044static void
1045load_plugins_placement_file(void)
1046 {
1047 FILE *f;
1048 gchar *path, *s, buf[256];
1049
1050 gkrellm_free_glist_and_data(&plugins_place_list);
1051 path = gkrellm_make_config_file_name(gkrellm_homedir(),
1052 PLUGIN_PLACEMENT_FILE".gkrellm2/plugin_placement");
1053 if ((f = g_fopenfopen(path, "r")) != NULL((void*)0))
1054 {
1055 while ((fgets(buf, sizeof(buf), f)) != NULL((void*)0))
1056 {
1057 if ((s = strchr(buf, '\n')(__extension__ (__builtin_constant_p ('\n') && !__builtin_constant_p
(buf) && ('\n') == '\0' ? (char *) __rawmemchr (buf,
'\n') : __builtin_strchr (buf, '\n')))
) != NULL((void*)0))
1058 *s = '\0';
1059 s = g_strdup(buf);
1060 plugins_place_list = g_list_append(plugins_place_list, s);
1061 }
1062 fclose(f);
1063 }
1064 g_free(path);
1065 }
1066
1067static void
1068save_plugins_placement_file(void)
1069 {
1070 FILE *f;
1071 GList *list;
1072 GkrellmMonitor *builtin, *plugin;
1073 GkrellmMonprivate *mp;
1074 gchar *path;
1075
1076 if (!plugin_placement_modified || _GK.demo || _GK.no_config)
1077 return;
1078 path = gkrellm_make_config_file_name(gkrellm_homedir(),
1079 PLUGIN_PLACEMENT_FILE".gkrellm2/plugin_placement");
1080 if ((f = g_fopenfopen(path, "w")) != NULL((void*)0))
1081 {
1082 for (list = plugins_list; list; list = list->next)
1083 {
1084 plugin = (GkrellmMonitor *) list->data;
1085 mp = plugin->privat;
1086 if ( mp->enabled && !mp->from_command_line
1087 && ( mp->insert_before_id != PLUGIN_INSERT_BEFORE_ID(plugin)((plugin)->insert_before_id & 0x1f)
1088 || mp->insert_after != PLUGIN_INSERT_AFTER(plugin)(((plugin)->insert_before_id & 0x200) >> 9)
1089 || mp->gravity != PLUGIN_GRAVITY(plugin)(((plugin)->insert_before_id & 0xf000) >> 12)
1090 )
1091 )
1092 {
1093 builtin = gkrellm_monitor_from_id(mp->insert_before_id);
1094 if (!builtin)
1095 continue;
1096 fprintf(f, "\"%s\" \"%s\" %d %d\n", plugin->name,
1097 builtin->name, mp->insert_after, mp->gravity);
1098 }
1099 }
1100 fclose(f);
1101 }
1102 plugin_placement_modified = FALSE(0);
1103 g_free(path);
1104 }
1105
1106static void
1107load_plugins_enable_file(void)
1108 {
1109 FILE *f;
1110 gchar *path, *s, buf[256];
1111
1112 gkrellm_free_glist_and_data(&plugins_enable_list);
1113 path = gkrellm_make_config_file_name(gkrellm_homedir(),PLUGIN_ENABLE_FILE".gkrellm2/plugin_enable");
1114 if ((f = g_fopenfopen(path, "r")) != NULL((void*)0))
1115 {
1116 while ((fgets(buf, sizeof(buf), f)) != NULL((void*)0))
1117 {
1118 if ((s = strchr(buf, '\n')(__extension__ (__builtin_constant_p ('\n') && !__builtin_constant_p
(buf) && ('\n') == '\0' ? (char *) __rawmemchr (buf,
'\n') : __builtin_strchr (buf, '\n')))
) != NULL((void*)0))
1119 *s = '\0';
1120 if (!buf[0])
1121 continue;
1122 s = g_path_get_basename(buf);
1123 plugins_enable_list = g_list_append(plugins_enable_list, s);
1124 }
1125 fclose(f);
1126 }
1127 g_free(path);
1128 }
1129
1130static void
1131save_plugins_enable_file(void)
1132 {
1133 FILE *f;
1134 GList *list;
1135 GkrellmMonitor *m;
1136 gchar *path, *s;
1137
1138 if (!plugin_enable_list_modified || _GK.demo)
1139 return;
1140 path = gkrellm_make_config_file_name(gkrellm_homedir(),
1141 PLUGIN_ENABLE_FILE".gkrellm2/plugin_enable");
1142 if ((f = g_fopenfopen(path, "w")) != NULL((void*)0))
1143 {
1144 for (list = plugins_list; list; list = list->next)
1145 {
1146 m = (GkrellmMonitor *) list->data;
1147 if (m->privat->enabled && !m->privat->from_command_line)
1148 {
1149 s = g_path_get_basename(m->path);
1150 fprintf(f, "%s\n", s);
1151 g_free(s);
1152 }
1153 }
1154 fclose(f);
1155 }
1156 plugin_enable_list_modified = FALSE(0);
1157 g_free(path);
1158 }
1159
1160static gchar *
1161string_suffix(gchar *string, gchar *suffix)
1162 {
1163 gchar *dot;
1164
1165 dot = strrchr(string, '.');
1166 if (dot && !strcmp(dot + 1, suffix)__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
(dot + 1) && __builtin_constant_p (suffix) &&
(__s1_len = strlen (dot + 1), __s2_len = strlen (suffix), (!
((size_t)(const void *)((dot + 1) + 1) - (size_t)(const void *
)(dot + 1) == 1) || __s1_len >= 4) && (!((size_t)(
const void *)((suffix) + 1) - (size_t)(const void *)(suffix) ==
1) || __s2_len >= 4)) ? __builtin_strcmp (dot + 1, suffix
) : (__builtin_constant_p (dot + 1) && ((size_t)(const
void *)((dot + 1) + 1) - (size_t)(const void *)(dot + 1) == 1
) && (__s1_len = strlen (dot + 1), __s1_len < 4) ?
(__builtin_constant_p (suffix) && ((size_t)(const void
*)((suffix) + 1) - (size_t)(const void *)(suffix) == 1) ? __builtin_strcmp
(dot + 1, suffix) : (__extension__ ({ const unsigned char *__s2
= (const unsigned char *) (const char *) (suffix); int __result
= (((const unsigned char *) (const char *) (dot + 1))[0] - __s2
[0]); if (__s1_len > 0 && __result == 0) { __result
= (((const unsigned char *) (const char *) (dot + 1))[1] - __s2
[1]); if (__s1_len > 1 && __result == 0) { __result
= (((const unsigned char *) (const char *) (dot + 1))[2] - __s2
[2]); if (__s1_len > 2 && __result == 0) __result =
(((const unsigned char *) (const char *) (dot + 1))[3] - __s2
[3]); } } __result; }))) : (__builtin_constant_p (suffix) &&
((size_t)(const void *)((suffix) + 1) - (size_t)(const void *
)(suffix) == 1) && (__s2_len = strlen (suffix), __s2_len
< 4) ? (__builtin_constant_p (dot + 1) && ((size_t
)(const void *)((dot + 1) + 1) - (size_t)(const void *)(dot +
1) == 1) ? __builtin_strcmp (dot + 1, suffix) : (- (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) (dot + 1); int __result = (((const unsigned char *) (
const char *) (suffix))[0] - __s2[0]); if (__s2_len > 0 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) (suffix))[1] - __s2[1]); if (__s2_len > 1 &&
__result == 0) { __result = (((const unsigned char *) (const
char *) (suffix))[2] - __s2[2]); if (__s2_len > 2 &&
__result == 0) __result = (((const unsigned char *) (const char
*) (suffix))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp
(dot + 1, suffix)))); })
)
1167 return dot + 1;
1168 return NULL((void*)0);
1169 }
1170
1171static void
1172scan_for_plugins(gchar *path)
1173 {
1174 GDir *dir;
1175 gchar *name, *filename;
1176 GList *list;
1177 GkrellmMonitor *m = NULL((void*)0);
1178 gchar *s;
1179 gboolean exists;
1180
1181 if (!path || !*path || (dir = g_dir_open(path, 0, NULL((void*)0))) == NULL((void*)0))
1182 return;
1183 while ((name = (gchar *) g_dir_read_name(dir)) != NULL((void*)0))
1184 {
1185 if ( !string_suffix(name, "so")
1186 && !string_suffix(name, "la")
1187 && !string_suffix(name, "dll")
1188 )
1189 continue;
1190
1191 /* If there's a libtool .la archive, won't want to load this .so
1192 */
1193 if ( !string_suffix(name, "la")
1194 && (s = strrchr(name, '.')) != NULL((void*)0)
1195 )
1196 {
1197 s = g_strndup(name, s - name);
1198 filename = g_strconcat(path, G_DIR_SEPARATOR_S"/", s, ".la", NULL((void*)0));
1199 exists = g_file_test(filename, G_FILE_TEST_EXISTS);
1200 g_free(s);
1201 g_free(filename);
1202 if (exists)
1203 continue;
1204 }
1205 for (list = plugins_list; list; list = list->next)
1206 {
1207 m = (GkrellmMonitor *) list->data;
1208 s = g_path_get_basename(m->path);
1209 exists = !strcmp(s, name)__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
(s) && __builtin_constant_p (name) && (__s1_len
= strlen (s), __s2_len = strlen (name), (!((size_t)(const void
*)((s) + 1) - (size_t)(const void *)(s) == 1) || __s1_len >=
4) && (!((size_t)(const void *)((name) + 1) - (size_t
)(const void *)(name) == 1) || __s2_len >= 4)) ? __builtin_strcmp
(s, name) : (__builtin_constant_p (s) && ((size_t)(const
void *)((s) + 1) - (size_t)(const void *)(s) == 1) &&
(__s1_len = strlen (s), __s1_len < 4) ? (__builtin_constant_p
(name) && ((size_t)(const void *)((name) + 1) - (size_t
)(const void *)(name) == 1) ? __builtin_strcmp (s, name) : (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) (name); int __result = (((const unsigned char *) (const
char *) (s))[0] - __s2[0]); if (__s1_len > 0 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
s))[1] - __s2[1]); if (__s1_len > 1 && __result ==
0) { __result = (((const unsigned char *) (const char *) (s)
)[2] - __s2[2]); if (__s1_len > 2 && __result == 0
) __result = (((const unsigned char *) (const char *) (s))[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) && ((size_t)(const
void *)((s) + 1) - (size_t)(const void *)(s) == 1) ? __builtin_strcmp
(s, name) : (- (__extension__ ({ const unsigned char *__s2 =
(const unsigned char *) (const char *) (s); 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, name)))); })
;
1210 g_free(s);
1211 if (exists)
1212 break;
1213 m = NULL((void*)0);
1214 }
1215 s = g_strconcat(path, G_DIR_SEPARATOR_S"/", name, NULL((void*)0));
1216 if (m)
1217 {
1218 plugin_log(_("Ignoring duplicate plugin ")dcgettext ("gkrellm", "Ignoring duplicate plugin ", 5), s, "\n", NULL((void*)0));
1219 g_free(s);
1220 continue;
1221 }
1222 m = install_plugin(s);
1223 if (m) /* s is saved for use */
1224 {
1225 plugins_list = g_list_append(plugins_list, m);
1226 s = g_path_get_basename(m->path);
1227 if (! gkrellm_string_in_list(plugins_enable_list, s))
1228 m->privat->enabled = FALSE(0);
1229 }
1230 g_free(s);
1231 }
1232 g_dir_close(dir);
1233 }
1234
1235void
1236gkrellm_plugins_load(void)
1237 {
1238 GkrellmMonitor *m;
1239 gchar *path;
1240
1241 if (_GK.command_line_plugin)
1242 {
1243 if ( *_GK.command_line_plugin != '.'
1244 && !strchr(_GK.command_line_plugin, G_DIR_SEPARATOR)(__extension__ (__builtin_constant_p ('/') && !__builtin_constant_p
(_GK.command_line_plugin) && ('/') == '\0' ? (char *
) __rawmemchr (_GK.command_line_plugin, '/') : __builtin_strchr
(_GK.command_line_plugin, '/')))
1245 )
1246 path = g_strconcat(".", G_DIR_SEPARATOR_S"/",
1247 _GK.command_line_plugin, NULL((void*)0));
1248 else
1249 path = g_strdup(_GK.command_line_plugin);
1250 plugin_log(_("*** Command line plugin:\n")dcgettext ("gkrellm", "*** Command line plugin:\n", 5), NULL((void*)0));
1251 if ((m = install_plugin(path)) == NULL((void*)0))
1252 g_free(path);
1253 else
1254 {
1255 m->privat->from_command_line = TRUE(!(0));
1256 plugins_list = g_list_append(plugins_list, m);
1257 }
1258 plugin_log("\n", NULL((void*)0));
1259 }
1260 load_plugins_enable_file();
1261 load_plugins_placement_file();
1262 path = g_strconcat(gkrellm_homedir(), G_DIR_SEPARATOR_S"/",
1263 GKRELLM_PLUGINS_DIR".gkrellm2/plugins", NULL((void*)0));
1264 scan_for_plugins(path);
1265 g_free(path);
1266
1267#if defined(WIN32)
1268 gchar *install_path;
1269 install_path = g_win32_get_package_installation_directory_of_module(NULL((void*)0));
1270 if (install_path != NULL((void*)0))
1271 {
1272 path = g_build_filename(install_path, "lib", "gkrellm2", "plugins", NULL((void*)0));
1273 scan_for_plugins(path);
1274 g_free(path);
1275 g_free(install_path);
1276 }
1277#endif
1278
1279
1280#if defined(LOCAL_PLUGINS_DIR"/usr/local/lib64/gkrellm2/plugins")
1281 scan_for_plugins(LOCAL_PLUGINS_DIR"/usr/local/lib64/gkrellm2/plugins");
1282#endif
1283
1284#if defined(SYSTEM_PLUGINS_DIR"/usr/lib64/gkrellm2/plugins")
1285 scan_for_plugins(SYSTEM_PLUGINS_DIR"/usr/lib64/gkrellm2/plugins");
1286#endif
1287 }
1288
1289#if 0
1290void
1291shuffle_test(void)
1292 {
1293 GList *list;
1294 GkrellmMonitor *mon;
1295 gint i;
1296 static gboolean srand_done;
1297 extern GtkWidget *gkrellm_monitor_vbox();
1298
1299 if (!srand_done)
1300 {
1301 srandom((unsigned int) time(0));
1302 srand_done = TRUE(!(0));
1303 }
1304 for (list = gkrellm_monitor_list; list; list = list->next)
1305 {
1306 i = (gint) random();
1307 i = (i % (g_list_length(gkrellm_monitor_list) - 2)) + 1;
1308 mon = (GkrellmMonitor *) list->data;
1309 if (mon->privat->main_vbox && mon != gkrellm_mon_host())
1310 {
1311 gtk_box_reorder_child(GTK_BOX(gkrellm_monitor_vbox())((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((gkrellm_monitor_vbox
())), ((gtk_box_get_type ()))))))
,
1312 mon->privat->main_vbox, i);
1313 }
1314 }
1315 }
1316#endif
1317
1318static void
1319replace_plugins()
1320 {
1321 GList *new_monitor_list, *list;
1322 GkrellmMonitor *mon;
1323 extern GtkWidget *gkrellm_monitor_vbox();
1324
1325 new_monitor_list = NULL((void*)0);
1326 for (list = gkrellm_monitor_list; list; list = list->next)
1327 {
1328 mon = (GkrellmMonitor *) list->data;
1329 if (mon->privat->main_vbox && mon != gkrellm_mon_host())
1330 {
1331 g_object_ref(G_OBJECT(mon->privat->main_vbox)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mon->privat->main_vbox)), (((GType) ((20) << (2))
))))))
);
1332 gtk_container_remove(GTK_CONTAINER(gkrellm_monitor_vbox())((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((gkrellm_monitor_vbox())), ((gtk_container_get_type ())))
)))
,
1333 mon->privat->main_vbox);
1334 }
1335 if (MONITOR_ID(mon)((mon)->id & 0x1f) != MON_PLUGIN16)
1336 new_monitor_list = g_list_append(new_monitor_list, mon);
1337 }
1338 for (list = gkrellm_monitor_list; list; list = list->next)
1339 {
1340 mon = (GkrellmMonitor *) list->data;
1341 if (MONITOR_ID(mon)((mon)->id & 0x1f) == MON_PLUGIN16)
1342 gkrellm_place_plugin(&new_monitor_list, mon);
1343 }
1344 g_list_free(gkrellm_monitor_list);
1345 gkrellm_monitor_list = new_monitor_list;
1346 for (list = gkrellm_monitor_list; list; list = list->next)
1347 {
1348 mon = (GkrellmMonitor *) list->data;
1349 if (mon->privat->main_vbox && mon != gkrellm_mon_host())
1350 {
1351 gtk_box_pack_start(GTK_BOX(gkrellm_monitor_vbox())((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((gkrellm_monitor_vbox
())), ((gtk_box_get_type ()))))))
,
1352 mon->privat->main_vbox, FALSE(0), FALSE(0), 0);
1353 g_object_ref(G_OBJECT(mon->privat->main_vbox)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mon->privat->main_vbox)), (((GType) ((20) << (2))
))))))
);
1354 }
1355 }
1356 }
1357
1358
1359static GtkWidget *place_plugin_window;
1360static GtkWidget *place_plugin_vbox;
1361static gboolean setting_place_buttons;
1362
1363static void
1364apply_place(void)
1365 {
1366 GList *list;
1367 GkrellmMonitor *mon;
1368 gint i;
1369
1370 if (!place_plugin || setting_place_buttons)
1371 return;
1372 for (i = 0; i < N_BUILTIN_MONITORS16; ++i)
1373 if (GTK_TOGGLE_BUTTON(builtin_button[i])((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance
*) ((builtin_button[i])), ((gtk_toggle_button_get_type ()))))
))
->active)
1374 break;
1375 for (list = gkrellm_monitor_list; list; list = list->next)
1376 {
1377 mon = (GkrellmMonitor *) list->data;
1378 if (MONITOR_ID(mon)((mon)->id & 0x1f) == MON_PLUGIN16 || i != mon->privat->button_id)
1379 continue;
1380 place_plugin->privat->insert_before_id = mon->id;
1381 place_plugin->privat->insert_after =
1382 GTK_TOGGLE_BUTTON(after_button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance
*) ((after_button)), ((gtk_toggle_button_get_type ()))))))
->active;
1383 if (place_plugin->privat->insert_after)
1384 place_plugin->privat->gravity = 0;
1385 else
1386 place_plugin->privat->gravity = gtk_spin_button_get_value_as_int(
1387 GTK_SPIN_BUTTON(gravity_spin_button)((((GtkSpinButton*) g_type_check_instance_cast ((GTypeInstance
*) ((gravity_spin_button)), ((gtk_spin_button_get_type ()))))
))
);
1388
1389 replace_plugins();
1390 plugin_placement_modified = TRUE(!(0));
1391 break;
1392 }
1393 }
1394
1395static void
1396cb_close_place(void)
1397 {
1398 if (place_plugin_window)
1399 gtk_widget_destroy(place_plugin_window);
1400 place_plugin_window = NULL((void*)0);
1401 place_plugin_vbox = NULL((void*)0);
1402 }
1403
1404static gint
1405place_plugin_window_delete_event(GtkWidget *widget, GdkEvent *ev,gpointer data)
1406 {
1407 cb_close_place();
1408 return FALSE(0);
1409 }
1410
1411static void
1412cb_place_default(GtkWidget *widget, gpointer data)
1413 {
1414 GkrellmMonitor *mon;
1415
1416 if (!place_plugin)
1417 return;
1418 if (PLUGIN_INSERT_AFTER(place_plugin)(((place_plugin)->insert_before_id & 0x200) >> 9
)
)
1419 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(after_button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance
*) ((after_button)), ((gtk_toggle_button_get_type ()))))))
,
1420 TRUE(!(0)));
1421 else
1422 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(before_button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance
*) ((before_button)), ((gtk_toggle_button_get_type ()))))))
,
1423 TRUE(!(0)));
1424 gtk_spin_button_set_value(GTK_SPIN_BUTTON(gravity_spin_button)((((GtkSpinButton*) g_type_check_instance_cast ((GTypeInstance
*) ((gravity_spin_button)), ((gtk_spin_button_get_type ()))))
))
,
1425 (gfloat) PLUGIN_GRAVITY(place_plugin)(((place_plugin)->insert_before_id & 0xf000) >> 12
)
);
1426 mon = gkrellm_monitor_from_id(PLUGIN_INSERT_BEFORE_ID(place_plugin)((place_plugin)->insert_before_id & 0x1f));
1427 if (mon && mon->privat->button_id >= 0)
1428 gtk_toggle_button_set_active(
1429 GTK_TOGGLE_BUTTON(builtin_button[mon->privat->button_id])((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance
*) ((builtin_button[mon->privat->button_id])), ((gtk_toggle_button_get_type
()))))))
, TRUE(!(0)));
1430 }
1431
1432static void
1433place_button_sensitivity(GkrellmMonitor *plugin, gboolean state)
1434 {
1435 GkrellmMonitor *mon = NULL((void*)0);
1436
1437 if (gkrellm_demo_mode())
1438 {
1439 gtk_widget_set_sensitive(place_button, FALSE(0));
1440 return;
1441 }
1442 place_plugin = plugin;
1443 if (state && plugin && plugin->create_monitor)
1444 {
1445 gtk_widget_set_sensitive(place_button, TRUE(!(0)));
1446 if (place_plugin_vbox)
1447 gtk_widget_set_sensitive(place_plugin_vbox, TRUE(!(0)));
1448 }
1449 else
1450 {
1451 gtk_widget_set_sensitive(place_button, FALSE(0));
1452 if (place_plugin_vbox)
1453 gtk_widget_set_sensitive(place_plugin_vbox, FALSE(0));
1454 return;
1455 }
1456 if (!place_plugin_window)
1457 return;
1458
1459 setting_place_buttons = TRUE(!(0));
1460 gtk_label_set_text(GTK_LABEL(place_label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(place_label)), ((gtk_label_get_type ()))))))
, plugin->name);
1461 if (plugin->privat->insert_after)
1462 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(after_button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance
*) ((after_button)), ((gtk_toggle_button_get_type ()))))))
, TRUE(!(0)));
1463 else
1464 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(before_button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance
*) ((before_button)), ((gtk_toggle_button_get_type ()))))))
, TRUE(!(0)));
1465 gtk_spin_button_set_value(GTK_SPIN_BUTTON(gravity_spin_button)((((GtkSpinButton*) g_type_check_instance_cast ((GTypeInstance
*) ((gravity_spin_button)), ((gtk_spin_button_get_type ()))))
))
,
1466 (gfloat) plugin->privat->gravity);
1467 mon = gkrellm_monitor_from_id(plugin->privat->insert_before_id);
1468 if (mon && mon->privat->button_id >= 0)
1469 gtk_toggle_button_set_active(
1470 GTK_TOGGLE_BUTTON(builtin_button[mon->privat->button_id])((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance
*) ((builtin_button[mon->privat->button_id])), ((gtk_toggle_button_get_type
()))))))
, TRUE(!(0)));
1471 setting_place_buttons = FALSE(0);
1472 }
1473
1474static gboolean
1475cb_place(GtkToggleButton *button, gpointer data)
1476 {
1477 if (!button->active)
1478 return FALSE(0);
1479 apply_place();
1480 return TRUE(!(0));
1481 }
1482
1483static void
1484cb_place_spin(GtkWidget *widget, GtkSpinButton *spin)
1485 {
1486 if (!place_plugin)
1487 return;
1488 if (place_plugin->privat->insert_after)
1489 gtk_spin_button_set_value(GTK_SPIN_BUTTON(gravity_spin_button)((((GtkSpinButton*) g_type_check_instance_cast ((GTypeInstance
*) ((gravity_spin_button)), ((gtk_spin_button_get_type ()))))
))
, 0.0);
1490 else
1491 apply_place();
1492 return;
1493 }
1494
1495static void
1496cb_place_button(GtkWidget *widget, gpointer data)
1497 {
1498 GtkWidget *main_vbox, *vbox, *vbox1, *vbox2, *vbox3, *hbox;
1499 GtkWidget *button;
1500 GtkTreeModel *model;
1501 GtkTreePath *path;
1502 GtkTreeIter iter;
1503 GSList *group;
1504 GList *list;
1505 GkrellmMonitor *mon;
1506 gint i;
1507
1508 if (gkrellm_demo_mode())
1509 return;
1510 if (!place_plugin_window)
1511 {
1512 place_plugin_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1513 g_signal_connect(G_OBJECT(place_plugin_window), "delete_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((place_plugin_window)), (((GType) ((20) <<
(2))))))))), ("delete_event"), (((GCallback) (place_plugin_window_delete_event
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
1514 G_CALLBACK(place_plugin_window_delete_event), NULL)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((place_plugin_window)), (((GType) ((20) <<
(2))))))))), ("delete_event"), (((GCallback) (place_plugin_window_delete_event
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
;
1515 gtk_window_set_title(GTK_WINDOW(place_plugin_window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(place_plugin_window)), ((gtk_window_get_type ()))))))
,
1516 _("GKrellM Place Plugin")dcgettext ("gkrellm", "GKrellM Place Plugin", 5));
1517 gtk_window_set_wmclass(GTK_WINDOW(place_plugin_window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(place_plugin_window)), ((gtk_window_get_type ()))))))
,
1518 "Gkrellm_conf", "Gkrellm");
1519
1520 main_vbox = gtk_vbox_new(FALSE(0), 0);
1521 gtk_container_add(GTK_CONTAINER(place_plugin_window)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((place_plugin_window)), ((gtk_container_get_type ()))))))
, main_vbox);
1522 place_plugin_vbox = main_vbox;
1523 vbox = gkrellm_gtk_framed_vbox(main_vbox, NULL((void*)0), 3, FALSE(0), 4, 3);
1524 hbox = gtk_hbox_new(FALSE(0), 0);
1525 gtk_box_pack_start(GTK_BOX(vbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((vbox
)), ((gtk_box_get_type ()))))))
, hbox, FALSE(0), FALSE(0), 0);
1526
1527 vbox1 = gkrellm_gtk_framed_vbox(hbox, _("Builtin Monitors")dcgettext ("gkrellm", "Builtin Monitors", 5),
1528 3, FALSE(0), 4, 3);
1529 group = NULL((void*)0);
1530 for (i = 0, list = gkrellm_monitor_list; list; list = list->next)
1531 {
1532 mon = (GkrellmMonitor *) list->data;
1533 mon->privat->button_id = -1;
1534 if (MONITOR_ID(mon)((mon)->id & 0x1f) != MON_PLUGIN16)
1535 {
1536 if ( !mon->name || !mon->create_monitor
1537 || mon == gkrellm_mon_host()
1538 )
1539 continue;
1540 button = gtk_radio_button_new_with_label(group, mon->name);
1541 g_signal_connect(G_OBJECT(button), "clicked",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((button)), (((GType) ((20) << (2)))
)))))), ("clicked"), (((GCallback) (cb_place))), (((void*)0))
, ((void*)0), (GConnectFlags) 0)
1542 G_CALLBACK(cb_place), NULL)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((button)), (((GType) ((20) << (2)))
)))))), ("clicked"), (((GCallback) (cb_place))), (((void*)0))
, ((void*)0), (GConnectFlags) 0)
;
1543 gtk_box_pack_start(GTK_BOX(vbox1)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((vbox1
)), ((gtk_box_get_type ()))))))
, button, FALSE(0), FALSE(0), 0);
1544 if (i < N_BUILTIN_MONITORS16)
1545 {
1546 builtin_button[i] = button;
1547 mon->privat->button_id = i++;
1548 }
1549 group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button)((((GtkRadioButton*) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_radio_button_get_type ()))))))
);
1550 }
1551 }
1552 vbox1 = gtk_vbox_new(FALSE(0), 0);
1553 gtk_box_pack_start(GTK_BOX(hbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((hbox
)), ((gtk_box_get_type ()))))))
, vbox1, FALSE(0), FALSE(0), 0);
1554 place_label = gtk_label_new("");
1555 gtk_box_pack_start(GTK_BOX(vbox1)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((vbox1
)), ((gtk_box_get_type ()))))))
, place_label, FALSE(0), FALSE(0), 10);
1556 vbox2 = gkrellm_gtk_framed_vbox(vbox1, _("Place Plugin")dcgettext ("gkrellm", "Place Plugin", 5),
1557 3, FALSE(0), 4, 3);
1558
1559 group = NULL((void*)0);
1560 vbox3 = gkrellm_gtk_framed_vbox(vbox2, NULL((void*)0), 3, FALSE(0), 4, 3);
1561 before_button = gtk_radio_button_new_with_label(group,
1562 _("Before selected builtin monitor")dcgettext ("gkrellm", "Before selected builtin monitor", 5));
1563 g_signal_connect(G_OBJECT(before_button), "clicked",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((before_button)), (((GType) ((20) <<
(2))))))))), ("clicked"), (((GCallback) (cb_place))), (((void
*)0)), ((void*)0), (GConnectFlags) 0)
1564 G_CALLBACK(cb_place), NULL)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((before_button)), (((GType) ((20) <<
(2))))))))), ("clicked"), (((GCallback) (cb_place))), (((void
*)0)), ((void*)0), (GConnectFlags) 0)
;
1565 gtk_box_pack_start(GTK_BOX(vbox3)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((vbox3
)), ((gtk_box_get_type ()))))))
, before_button, FALSE(0), FALSE(0), 0);
1566 gkrellm_gtk_spin_button(vbox3, &gravity_spin_button, 8,
1567 0.0, 15.0, 1, 1, 0, 50,
1568 cb_place_spin, NULL((void*)0), FALSE(0),
1569 _("With gravity")dcgettext ("gkrellm", "With gravity", 5));
1570
1571 vbox3 = gkrellm_gtk_framed_vbox(vbox2, NULL((void*)0), 3, FALSE(0), 4, 3);
1572 group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(before_button)((((GtkRadioButton*) g_type_check_instance_cast ((GTypeInstance
*) ((before_button)), ((gtk_radio_button_get_type ()))))))
);
1573 after_button = gtk_radio_button_new_with_label(group,
1574 _("After selected builtin monitor")dcgettext ("gkrellm", "After selected builtin monitor", 5));
1575 g_signal_connect(G_OBJECT(after_button), "clicked",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((after_button)), (((GType) ((20) <<
(2))))))))), ("clicked"), (((GCallback) (cb_place))), (((void
*)0)), ((void*)0), (GConnectFlags) 0)
1576 G_CALLBACK(cb_place), NULL)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((after_button)), (((GType) ((20) <<
(2))))))))), ("clicked"), (((GCallback) (cb_place))), (((void
*)0)), ((void*)0), (GConnectFlags) 0)
;
1577 gtk_box_pack_start(GTK_BOX(vbox3)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((vbox3
)), ((gtk_box_get_type ()))))))
, after_button, FALSE(0), FALSE(0), 0);
1578
1579 hbox = gtk_hbox_new(FALSE(0), 0);
1580 gtk_box_pack_start(GTK_BOX(vbox1)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((vbox1
)), ((gtk_box_get_type ()))))))
, hbox, FALSE(0), FALSE(0), 0);
1581 gkrellm_gtk_button_connected(hbox, NULL((void*)0), TRUE(!(0)), FALSE(0), 0,
1582 cb_place_default, NULL((void*)0), _("Plugin Defaults")dcgettext ("gkrellm", "Plugin Defaults", 5));
1583
1584 hbox = gtk_hbutton_box_new();
1585 gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox)((((GtkButtonBox*) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((gtk_button_box_get_type ()))))))
, GTK_BUTTONBOX_END);
1586 gtk_box_set_spacing(GTK_BOX(hbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((hbox
)), ((gtk_box_get_type ()))))))
, 5);
1587 gtk_box_pack_end(GTK_BOX(vbox1)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((vbox1
)), ((gtk_box_get_type ()))))))
, hbox, FALSE(0), FALSE(0), 0);
1588
1589 button = gtk_button_new_from_stock(GTK_STOCK_OK"gtk-ok");
1590 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT)do{ (((((((GtkObject*) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_object_get_type ()))))))->flags)) |= (
GTK_CAN_DEFAULT)); }while (0)
;
1591 g_signal_connect(G_OBJECT(button), "clicked",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((button)), (((GType) ((20) << (2)))
)))))), ("clicked"), (((GCallback) (cb_close_place))), (((void
*)0)), ((void*)0), (GConnectFlags) 0)
1592 G_CALLBACK(cb_close_place), NULL)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((button)), (((GType) ((20) << (2)))
)))))), ("clicked"), (((GCallback) (cb_close_place))), (((void
*)0)), ((void*)0), (GConnectFlags) 0)
;
1593 gtk_box_pack_start(GTK_BOX(hbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((hbox
)), ((gtk_box_get_type ()))))))
, button, TRUE(!(0)), TRUE(!(0)), 0);
1594
1595 gtk_widget_show_all(place_plugin_window);
1596 }
1597 else
1598 gtk_window_present(GTK_WINDOW(place_plugin_window)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(place_plugin_window)), ((gtk_window_get_type ()))))))
);
1599// gdk_window_raise(place_plugin_window->window);
1600
1601 if (row_reference)
1602 {
1603 model = gtk_tree_view_get_model(treeview);
1604 path = gtk_tree_row_reference_get_path(row_reference);
1605 gtk_tree_model_get_iter(model, &iter, path);
1606 gtk_tree_model_get(model, &iter, MON_COLUMN, &mon, -1);
1607 place_button_sensitivity(mon, mon->privat->enabled);
1608 }
1609 }
1610
1611static void
1612cb_enable_plugin(GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
1613 {
1614 GtkTreeModel *model = (GtkTreeModel *)data;
1615 GtkTreeIter iter;
1616 GtkTreePath *path;
1617 GkrellmMonitor *mon;
1618 gboolean enable;
1619
1620 path = gtk_tree_path_new_from_string(path_str);
1621 gtk_tree_model_get_iter(model, &iter, path);
1622 gtk_tree_path_free(path);
1623 gtk_tree_model_get(model, &iter,
1624 ENABLE_COLUMN, &enable,
1625 MON_COLUMN, &mon,
1626 -1);
1627 if (mon->privat->from_command_line)
1628 enable = TRUE(!(0));
1629 else
1630 enable = !enable;
1631 gtk_list_store_set(GTK_LIST_STORE(model)((((GtkListStore*) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_list_store_get_type ()))))))
, &iter,
1632 ENABLE_COLUMN, enable, -1);
1633 if (enable)
1634 enable_plugin(mon);
1635 else
1636 disable_plugin(mon);
1637 place_button_sensitivity(mon, enable);
1638 }
1639
1640static void
1641cb_tree_selection_changed(GtkTreeSelection *selection, gpointer data)
1642 {
1643 GtkTreeIter iter;
1644 GtkTreeModel *model;
1645 GtkTreePath *path;
1646 GkrellmMonitor *mon;
1647
1648 gtk_tree_row_reference_free(row_reference);
1649 if (!gtk_tree_selection_get_selected(selection, &model, &iter))
1650 {
1651 row_reference = NULL((void*)0);
1652 place_button_sensitivity(NULL((void*)0), FALSE(0));
1653 return;
1654 }
1655 path = gtk_tree_model_get_path(model, &iter);
1656 row_reference = gtk_tree_row_reference_new(model, path);
1657 gtk_tree_model_get(model, &iter, MON_COLUMN, &mon, -1);
1658 place_button_sensitivity(mon, mon->privat->enabled);
1659 }
1660
1661void
1662gkrellm_plugins_config_close(void)
1663 {
1664 save_plugins_enable_file();
1665 save_plugins_placement_file();
1666 cb_close_place();
1667 }
1668
1669static GtkTreeModel *
1670create_model(void)
1671 {
1672 GtkListStore *store;
1673 GtkTreeIter iter;
1674 GkrellmMonitor *mon;
1675 GList *list;
1676 gchar *buf;
1677
1678 store = gtk_list_store_new(N_COLUMNS,
1679 G_TYPE_STRING((GType) ((16) << (2))), G_TYPE_BOOLEAN((GType) ((5) << (2))), G_TYPE_POINTER((GType) ((17) << (2))));
1680 for (list = plugins_list; list; list = list->next)
1681 {
1682 mon = (GkrellmMonitor *) list->data;
1683 if (mon->privat->from_command_line)
1684 buf = g_strdup_printf("%s (%s)", mon->name,
1685 _("from command line")dcgettext ("gkrellm", "from command line", 5));
1686 else
1687 buf = NULL((void*)0);
1688
1689 gtk_list_store_append(store, &iter);
1690 gtk_list_store_set(store, &iter,
1691 NAME_COLUMN, buf ? buf : mon->name,
1692 ENABLE_COLUMN, mon->privat->enabled,
1693 MON_COLUMN, mon,
1694 -1);
1695 g_free(buf);
1696 }
1697 return GTK_TREE_MODEL(store)((((GtkTreeModel*) g_type_check_instance_cast ((GTypeInstance
*) ((store)), ((gtk_tree_model_get_type ()))))))
;
1698 }
1699
1700void
1701gkrellm_plugins_config_create(GtkWidget *tab_vbox)
1702 {
1703 GtkWidget *tabs;
1704 GtkWidget *vbox;
1705 GtkWidget *hbox;
1706 GtkWidget *scrolled;
1707 GtkWidget *view;
1708 GtkTreeModel *model;
1709 GtkCellRenderer *renderer;
1710 GtkTreeSelection *selection;
1711 GtkTreeViewColumn *column;
1712 GtkTextIter iter;
1713 GtkTextBuffer *buffer;
1714
1715 row_reference = NULL((void*)0);
1716 tabs = gtk_notebook_new();
1717 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(tabs)((((GtkNotebook*) g_type_check_instance_cast ((GTypeInstance*
) ((tabs)), ((gtk_notebook_get_type ()))))))
, GTK_POS_TOP);
1718 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);
1719
1720
1721/* -- Plugins tab */
1722 vbox = gkrellm_gtk_framed_notebook_page(tabs, _("Plugins")dcgettext ("gkrellm", "Plugins", 5));
1723
1724 scrolled = gtk_scrolled_window_new(NULL((void*)0), NULL((void*)0));
1725 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled)((((GtkScrolledWindow*) g_type_check_instance_cast ((GTypeInstance
*) ((scrolled)), ((gtk_scrolled_window_get_type ()))))))
,
1726 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1727 gtk_box_pack_start(GTK_BOX(vbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((vbox
)), ((gtk_box_get_type ()))))))
, scrolled, TRUE(!(0)), TRUE(!(0)), 2);
1728
1729 model = create_model();
1730 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
()))))))
;
1731 g_object_unref(G_OBJECT(model)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
model)), (((GType) ((20) << (2))))))))
);
1732 gtk_tree_view_set_rules_hint(treeview, TRUE(!(0)));
1733
1734 renderer = gtk_cell_renderer_toggle_new();
1735 gtk_tree_view_insert_column_with_attributes(treeview, -1, _("Enable")dcgettext ("gkrellm", "Enable", 5),
1736 renderer,
1737 "active", ENABLE_COLUMN, NULL((void*)0));
1738 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_plugin))), (model
), ((void*)0), (GConnectFlags) 0)
1739 G_CALLBACK(cb_enable_plugin), model)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((renderer)), (((GType) ((20) << (2)
)))))))), ("toggled"), (((GCallback) (cb_enable_plugin))), (model
), ((void*)0), (GConnectFlags) 0)
;
1740
1741 renderer = gtk_cell_renderer_text_new();
1742 column = gtk_tree_view_column_new_with_attributes (_("Plugin")dcgettext ("gkrellm", "Plugin", 5),
1743 renderer,
1744 "text", NAME_COLUMN, NULL((void*)0));
1745 gtk_tree_view_append_column(treeview, column);
1746 gtk_tree_view_column_set_sort_column_id(column, NAME_COLUMN);
1747 gtk_tree_view_column_clicked(column); /* Sort it */
1748/* gtk_tree_sortable_set_sort_column_id(model,
1749 NAME_COLUMN, GTK_ORDER_ASCENDING);
1750*/
1751
1752 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 ()))))))
);
1753 selection = gtk_tree_view_get_selection(treeview);
1754 gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
1755 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)
1756 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)
;
1757
1758 hbox = gtk_hbutton_box_new();
1759 gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox)((((GtkButtonBox*) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((gtk_button_box_get_type ()))))))
, GTK_BUTTONBOX_START);
1760 gtk_box_set_spacing(GTK_BOX(hbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((hbox
)), ((gtk_box_get_type ()))))))
, 5);
1761 gtk_box_pack_start(GTK_BOX(vbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((vbox
)), ((gtk_box_get_type ()))))))
, hbox, FALSE(0), FALSE(0), 2);
1762
1763 place_button = gtk_button_new_with_label(_("Place")dcgettext ("gkrellm", "Place", 5));
1764 gtk_box_pack_start(GTK_BOX(hbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((hbox
)), ((gtk_box_get_type ()))))))
, place_button, TRUE(!(0)), TRUE(!(0)), 0);
1765 g_signal_connect(G_OBJECT(GTK_BUTTON(place_button)), "clicked",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((((((GtkButton*) g_type_check_instance_cast
((GTypeInstance*) ((place_button)), ((gtk_button_get_type ()
)))))))), (((GType) ((20) << (2))))))))), ("clicked"), (
((GCallback) (cb_place_button))), (((void*)0)), ((void*)0), (
GConnectFlags) 0)
1766 G_CALLBACK(cb_place_button), NULL)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((((((GtkButton*) g_type_check_instance_cast
((GTypeInstance*) ((place_button)), ((gtk_button_get_type ()
)))))))), (((GType) ((20) << (2))))))))), ("clicked"), (
((GCallback) (cb_place_button))), (((void*)0)), ((void*)0), (
GConnectFlags) 0)
;
1767 gtk_widget_set_sensitive(place_button, FALSE(0));
1768
1769/* --Plugins detect log tab */
1770 vbox = gkrellm_gtk_framed_notebook_page(tabs, _("Install Log")dcgettext ("gkrellm", "Install Log", 5));
1771 view = gkrellm_gtk_scrolled_text_view(vbox, NULL((void*)0),
1772 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1773 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(view)((((GtkTextView*) g_type_check_instance_cast ((GTypeInstance*
) ((view)), ((gtk_text_view_get_type ()))))))
);
1774 gtk_text_buffer_get_end_iter(buffer, &iter);
1775 if (plugin_install_log)
1776 gtk_text_buffer_insert(buffer, &iter, plugin_install_log, -1);
1777 else
1778 gtk_text_buffer_insert(buffer, &iter, _("No plugins found.")dcgettext ("gkrellm", "No plugins found.", 5), -1);
1779 }