File: | rc/fs.c |
Location: | line 492, column 2 |
Description: | Undefined or garbage value returned to caller |
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 DEFAULT_DATA_FORMAT(dcgettext ("gkrellm", "$t - $f free", 5)) (_("$t - $f free")dcgettext ("gkrellm", "$t - $f free", 5)) | |||
40 | #define ALT1_DATA_FORMAT(dcgettext ("gkrellm", "$t - $u used", 5)) (_("$t - $u used")dcgettext ("gkrellm", "$t - $u used", 5)) | |||
41 | #define ALT2_DATA_FORMAT(dcgettext ("gkrellm", "$t - $U", 5)) (_("$t - $U")dcgettext ("gkrellm", "$t - $U", 5)) | |||
42 | ||||
43 | ||||
44 | /* Values for force_fs_check */ | |||
45 | #define FORCE_REDRAW1 1 | |||
46 | #define FORCE_UPDATE2 2 | |||
47 | ||||
48 | #define FS_MOUNTING_ENABLED(fs)((fs)->fstab_mounting || *((fs)->launch_umount.command) ) \ | |||
49 | ((fs)->fstab_mounting || *((fs)->launch_umount.command)) | |||
50 | ||||
51 | typedef struct | |||
52 | { | |||
53 | gchar *directory; | |||
54 | gchar *device; | |||
55 | gchar *type; | |||
56 | gchar *options; | |||
57 | } | |||
58 | Mount; | |||
59 | ||||
60 | typedef struct | |||
61 | { | |||
62 | gint idx; | |||
63 | GkrellmPanel *panel; | |||
64 | GkrellmDecalbutton *md_button, | |||
65 | *eject_button, | |||
66 | *drawer_button; | |||
67 | GkrellmDecal *mount_decal, | |||
68 | *eject_decal, | |||
69 | *label_decal, | |||
70 | *data_decal; | |||
71 | GkrellmKrell *krell; | |||
72 | gchar *label, /* Actual utf8 label */ | |||
73 | *label_shadow; /* Shadow label for gdk_draw functions */ | |||
74 | gboolean label_is_data, | |||
75 | restore_label, | |||
76 | mouse_entered; | |||
77 | ||||
78 | Mount mount; | |||
79 | gboolean fstab_mounting; | |||
80 | GkrellmLauncher launch_mount, | |||
81 | launch_umount; | |||
82 | ||||
83 | GkrellmAlert *alert; | |||
84 | ||||
85 | gboolean secondary, | |||
86 | show_if_mounted, | |||
87 | is_mounted, | |||
88 | ejectable, | |||
89 | is_nfs_fs; | |||
90 | gchar *eject_device; | |||
91 | gint eject_pending; | |||
92 | gint x_eject_button_target; | |||
93 | ||||
94 | GString *pipe_gstring; /* output of mount commands */ | |||
95 | ||||
96 | gulong krell_factor; /* avoid krell math overflow */ | |||
97 | ||||
98 | gboolean busy; | |||
99 | glong blocks, | |||
100 | bfree, | |||
101 | bavail, | |||
102 | bsize; | |||
103 | } | |||
104 | FSmon; | |||
105 | ||||
106 | static void cb_alert_config(GkrellmAlert *ap, FSmon *fs); | |||
107 | ||||
108 | static GkrellmMonitor | |||
109 | *mon_fs; | |||
110 | ||||
111 | static GList *fs_mon_list, | |||
112 | *mounts_list; | |||
113 | static GList *fstab_list; | |||
114 | ||||
115 | static gint uid; | |||
116 | ||||
117 | void (*get_mounts_list)(), | |||
118 | (*get_fsusage)(), | |||
119 | (*get_fstab_list)(); | |||
120 | gboolean (*get_fstab_modified)(); | |||
121 | ||||
122 | ||||
123 | /* If ejecting is available via an ioctl() or if there is an eject command, | |||
124 | | set these up in gkrellm_sys_fs_init() by calling gkrellm_fs_setup_eject(). | |||
125 | */ | |||
126 | void (*eject_cdrom_func)(), | |||
127 | (*close_cdrom_func)(); | |||
128 | static gchar *eject_cdrom_command, | |||
129 | *close_cdrom_command; | |||
130 | static gboolean cdrom_thread_busy; /* for the cdrom_funcs */ | |||
131 | ||||
132 | ||||
133 | static GtkWidget | |||
134 | *fs_main_vbox, | |||
135 | *fs_secondary_vbox; | |||
136 | ||||
137 | static gboolean fs_check_timeout = 2, | |||
138 | nfs_check_timeout = 16; | |||
139 | static gint check_tick; | |||
140 | ||||
141 | static gint secondary_monitors_shown; | |||
142 | ||||
143 | static gint n_fs_monitors; | |||
144 | static gint force_fs_check; | |||
145 | static FSmon *fs_in_motion; | |||
146 | static gint x_fs_motion; | |||
147 | static gint x_moved; | |||
148 | static gint x_eject_button_open, | |||
149 | x_eject_button_closed; | |||
150 | ||||
151 | static gint x_scroll; | |||
152 | static gint data_decal_width; | |||
153 | static gint cdrom_auto_eject; | |||
154 | static gint binary_units; | |||
155 | static gboolean mounting_supported = TRUE(!(0)), | |||
156 | ejecting_supported = FALSE(0); | |||
157 | static gboolean have_secondary_panels; | |||
158 | static gchar *data_format, | |||
159 | *data_format_locale; | |||
160 | ||||
161 | static gint style_id; | |||
162 | ||||
163 | static gchar *remote_fs_types[] = | |||
164 | { | |||
165 | "cifs", | |||
166 | "nfs", | |||
167 | "smbfs" | |||
168 | }; | |||
169 | ||||
170 | ||||
171 | static gboolean | |||
172 | setup_fs_interface(void) | |||
173 | { | |||
174 | #ifdef WIN32 | |||
175 | uid = 0; /* nothing comparable available on windows */ | |||
176 | #else | |||
177 | uid = getuid(); /* only real root is allowed to mount/umount always */ | |||
178 | #endif | |||
179 | if (!get_fsusage && !_GK.client_mode && gkrellm_sys_fs_init()) | |||
180 | { | |||
181 | get_fsusage = gkrellm_sys_fs_get_fsusage; | |||
182 | get_mounts_list = gkrellm_sys_fs_get_mounts_list; | |||
183 | get_fstab_list = gkrellm_sys_fs_get_fstab_list; | |||
184 | get_fstab_modified = gkrellm_sys_fs_fstab_modified; | |||
185 | } | |||
186 | return get_fsusage ? TRUE(!(0)) : FALSE(0); | |||
187 | } | |||
188 | ||||
189 | void | |||
190 | gkrellm_fs_client_divert(void (*get_fsusage_func)(), | |||
191 | void (*get_mounts_func)(), void (*get_fstab_func)(), | |||
192 | gboolean (*fstab_modified_func)()) | |||
193 | { | |||
194 | get_fsusage = get_fsusage_func; | |||
195 | get_mounts_list = get_mounts_func; | |||
196 | get_fstab_list = get_fstab_func; | |||
197 | get_fstab_modified = fstab_modified_func; | |||
198 | } | |||
199 | ||||
200 | void | |||
201 | gkrellm_fs_setup_eject(gchar *eject_tray, gchar *close_tray, | |||
202 | void (*eject_func)(), void (*close_func)()) | |||
203 | { | |||
204 | eject_cdrom_command = g_strdup(eject_tray); | |||
205 | close_cdrom_command = g_strdup(close_tray); | |||
206 | eject_cdrom_func = eject_func; | |||
207 | close_cdrom_func = close_func; | |||
208 | if (eject_cdrom_command || eject_cdrom_func) | |||
209 | ejecting_supported = TRUE(!(0)); | |||
210 | } | |||
211 | ||||
212 | void | |||
213 | gkrellm_fs_add_to_mounts_list(gchar *dir, gchar *dev, gchar *type) | |||
214 | { | |||
215 | Mount *m; | |||
216 | ||||
217 | m = g_new0(Mount, 1)(Mount *) (__extension__ ({ gsize __n = (gsize) (1); gsize __s = sizeof (Mount); 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 ; })); | |||
218 | m->directory = g_strdup(dir); | |||
219 | m->device = g_strdup(dev); | |||
220 | m->type = g_strdup(type); | |||
221 | mounts_list = g_list_append(mounts_list, m); | |||
222 | } | |||
223 | ||||
224 | void | |||
225 | gkrellm_fs_add_to_fstab_list(gchar *dir, gchar *dev, gchar *type, gchar *opt) | |||
226 | { | |||
227 | Mount *m; | |||
228 | ||||
229 | m = g_new0(Mount, 1)(Mount *) (__extension__ ({ gsize __n = (gsize) (1); gsize __s = sizeof (Mount); 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 ; })); | |||
230 | m->directory = g_strdup(dir); | |||
231 | m->device = g_strdup(dev); | |||
232 | m->type = g_strdup(type); | |||
233 | m->options = g_strdup(opt); | |||
234 | fstab_list = g_list_append(fstab_list, m); | |||
235 | } | |||
236 | ||||
237 | void | |||
238 | gkrellm_fs_assign_fsusage_data(gpointer fspointer, | |||
239 | glong blocks, glong bavail, glong bfree, glong bsize) | |||
240 | { | |||
241 | FSmon *fs = (FSmon *) fspointer; | |||
242 | ||||
243 | fs->blocks = blocks; | |||
244 | fs->bavail = bavail; | |||
245 | fs->bfree = bfree; | |||
246 | fs->bsize = bsize; | |||
247 | } | |||
248 | ||||
249 | void | |||
250 | gkrellm_fs_mounting_unsupported(void) | |||
251 | { | |||
252 | mounting_supported = FALSE(0); | |||
253 | } | |||
254 | ||||
255 | /* ======================================================================== */ | |||
256 | ||||
257 | ||||
258 | static Mount * | |||
259 | in_fstab_list(gchar *s) | |||
260 | { | |||
261 | GList *list; | |||
262 | Mount *m; | |||
263 | ||||
264 | for (list = fstab_list; list; list = list->next) | |||
265 | { | |||
266 | m = (Mount *)list->data; | |||
267 | if (strcmp(s, m->directory)__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (s) && __builtin_constant_p (m->directory) && (__s1_len = strlen (s), __s2_len = strlen (m->directory), (!((size_t)(const void *)((s) + 1) - (size_t)(const void *)( s) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((m->directory) + 1) - (size_t)(const void *)(m->directory ) == 1) || __s2_len >= 4)) ? __builtin_strcmp (s, m->directory ) : (__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 (m-> directory) && ((size_t)(const void *)((m->directory ) + 1) - (size_t)(const void *)(m->directory) == 1) ? __builtin_strcmp (s, m->directory) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (m->directory ); 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 (m->directory ) && ((size_t)(const void *)((m->directory) + 1) - (size_t)(const void *)(m->directory) == 1) && (__s2_len = strlen (m->directory), __s2_len < 4) ? (__builtin_constant_p (s) && ((size_t)(const void *)((s) + 1) - (size_t)(const void *)(s) == 1) ? __builtin_strcmp (s, m->directory) : ( - (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (s); int __result = (((const unsigned char *) (const char *) (m->directory))[0] - __s2[0]); if ( __s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (m->directory))[1] - __s2 [1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (m->directory) )[2] - __s2[2]); if (__s2_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (m-> directory))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (s, m->directory)))); }) == 0) | |||
268 | return m; | |||
269 | } | |||
270 | return NULL((void*)0); | |||
271 | } | |||
272 | ||||
273 | static void | |||
274 | refresh_mounts_list(void) | |||
275 | { | |||
276 | Mount *m; | |||
277 | ||||
278 | while (mounts_list) | |||
279 | { | |||
280 | m = (Mount *) mounts_list->data; | |||
281 | g_free(m->directory); | |||
282 | g_free(m->device); | |||
283 | g_free(m->type); | |||
284 | g_free(mounts_list->data); | |||
285 | mounts_list = g_list_remove(mounts_list, mounts_list->data); | |||
286 | } | |||
287 | (*get_mounts_list)(); | |||
288 | } | |||
289 | ||||
290 | static void | |||
291 | refresh_fstab_list(void) | |||
292 | { | |||
293 | Mount *m; | |||
294 | ||||
295 | while (fstab_list) | |||
296 | { | |||
297 | m = (Mount *) fstab_list->data; | |||
298 | g_free(m->device); | |||
299 | g_free(m->directory); | |||
300 | g_free(m->type); | |||
301 | g_free(m->options); | |||
302 | g_free(m); | |||
303 | fstab_list = g_list_remove(fstab_list, fstab_list->data); | |||
304 | } | |||
305 | (*get_fstab_list)(); | |||
306 | } | |||
307 | ||||
308 | static gint | |||
309 | fs_is_mounted(FSmon *fs) | |||
310 | { | |||
311 | Mount *m_fs, *m_mounted; | |||
312 | GList *list; | |||
313 | gint i; | |||
314 | ||||
315 | fs->is_mounted = FALSE(0); | |||
316 | m_fs = &fs->mount; | |||
317 | for (list = mounts_list; list; list = list->next) | |||
318 | { | |||
319 | m_mounted = (Mount *) list->data; | |||
320 | if (strcmp(m_fs->directory, m_mounted->directory)__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (m_fs->directory) && __builtin_constant_p (m_mounted ->directory) && (__s1_len = strlen (m_fs->directory ), __s2_len = strlen (m_mounted->directory), (!((size_t)(const void *)((m_fs->directory) + 1) - (size_t)(const void *)(m_fs ->directory) == 1) || __s1_len >= 4) && (!((size_t )(const void *)((m_mounted->directory) + 1) - (size_t)(const void *)(m_mounted->directory) == 1) || __s2_len >= 4)) ? __builtin_strcmp (m_fs->directory, m_mounted->directory ) : (__builtin_constant_p (m_fs->directory) && ((size_t )(const void *)((m_fs->directory) + 1) - (size_t)(const void *)(m_fs->directory) == 1) && (__s1_len = strlen ( m_fs->directory), __s1_len < 4) ? (__builtin_constant_p (m_mounted->directory) && ((size_t)(const void *) ((m_mounted->directory) + 1) - (size_t)(const void *)(m_mounted ->directory) == 1) ? __builtin_strcmp (m_fs->directory, m_mounted->directory) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (m_mounted-> directory); int __result = (((const unsigned char *) (const char *) (m_fs->directory))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (m_fs->directory))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (m_fs->directory))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (m_fs->directory))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p (m_mounted->directory ) && ((size_t)(const void *)((m_mounted->directory ) + 1) - (size_t)(const void *)(m_mounted->directory) == 1 ) && (__s2_len = strlen (m_mounted->directory), __s2_len < 4) ? (__builtin_constant_p (m_fs->directory) && ((size_t)(const void *)((m_fs->directory) + 1) - (size_t) (const void *)(m_fs->directory) == 1) ? __builtin_strcmp ( m_fs->directory, m_mounted->directory) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (m_fs->directory); int __result = (((const unsigned char *) (const char *) (m_mounted->directory))[0] - __s2[ 0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (m_mounted->directory ))[1] - __s2[1]); if (__s2_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (m_mounted ->directory))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (m_mounted->directory))[3] - __s2[3]); } } __result; } )))) : __builtin_strcmp (m_fs->directory, m_mounted->directory )))); })) | |||
321 | continue; | |||
322 | fs->is_mounted = TRUE(!(0)); | |||
323 | fs->is_nfs_fs = FALSE(0); | |||
324 | for (i = 0; i < (sizeof(remote_fs_types) / sizeof(gchar *)); ++i) | |||
325 | { | |||
326 | if (!strcmp(m_mounted->type, remote_fs_types[i])__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (m_mounted->type) && __builtin_constant_p (remote_fs_types [i]) && (__s1_len = strlen (m_mounted->type), __s2_len = strlen (remote_fs_types[i]), (!((size_t)(const void *)((m_mounted ->type) + 1) - (size_t)(const void *)(m_mounted->type) == 1) || __s1_len >= 4) && (!((size_t)(const void *) ((remote_fs_types[i]) + 1) - (size_t)(const void *)(remote_fs_types [i]) == 1) || __s2_len >= 4)) ? __builtin_strcmp (m_mounted ->type, remote_fs_types[i]) : (__builtin_constant_p (m_mounted ->type) && ((size_t)(const void *)((m_mounted-> type) + 1) - (size_t)(const void *)(m_mounted->type) == 1) && (__s1_len = strlen (m_mounted->type), __s1_len < 4) ? (__builtin_constant_p (remote_fs_types[i]) && ((size_t)(const void *)((remote_fs_types[i]) + 1) - (size_t) (const void *)(remote_fs_types[i]) == 1) ? __builtin_strcmp ( m_mounted->type, remote_fs_types[i]) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (remote_fs_types[i]); int __result = (((const unsigned char * ) (const char *) (m_mounted->type))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (m_mounted->type))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (m_mounted->type))[2] - __s2 [2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (m_mounted->type ))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ( remote_fs_types[i]) && ((size_t)(const void *)((remote_fs_types [i]) + 1) - (size_t)(const void *)(remote_fs_types[i]) == 1) && (__s2_len = strlen (remote_fs_types[i]), __s2_len < 4) ? ( __builtin_constant_p (m_mounted->type) && ((size_t )(const void *)((m_mounted->type) + 1) - (size_t)(const void *)(m_mounted->type) == 1) ? __builtin_strcmp (m_mounted-> type, remote_fs_types[i]) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (m_mounted ->type); int __result = (((const unsigned char *) (const char *) (remote_fs_types[i]))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (remote_fs_types[i]))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (remote_fs_types[i]))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (remote_fs_types[i]))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (m_mounted->type, remote_fs_types [i])))); })) | |||
327 | { | |||
328 | fs->is_nfs_fs = TRUE(!(0)); | |||
329 | break; | |||
330 | } | |||
331 | } | |||
332 | } | |||
333 | return fs->is_mounted; | |||
334 | } | |||
335 | ||||
336 | static GkrellmSizeAbbrev fs_decimal_abbrev[] = | |||
337 | { | |||
338 | { MB_SIZE(10)((10) * 1e6), MB_SIZE(1)((1) * 1e6), "%.2fM" }, | |||
339 | { GB_SIZE(1)((1) * 1e9), MB_SIZE(1)((1) * 1e6), "%.0fM" }, | |||
340 | { GB_SIZE(10)((10) * 1e9), GB_SIZE(1)((1) * 1e9), "%.2fG" }, | |||
341 | { GB_SIZE(100)((100) * 1e9), GB_SIZE(1)((1) * 1e9), "%.1fG" }, | |||
342 | { TB_SIZE(1)((1) * 1e12), GB_SIZE(1)((1) * 1e9), "%.0fG" }, | |||
343 | { TB_SIZE(10)((10) * 1e12), TB_SIZE(1)((1) * 1e12), "%.2fT" }, | |||
344 | { TB_SIZE(100)((100) * 1e12), TB_SIZE(1)((1) * 1e12), "%.1fT" } | |||
345 | }; | |||
346 | ||||
347 | static GkrellmSizeAbbrev fs_binary_abbrev[] = | |||
348 | { | |||
349 | { MiB_SIZE(10)((10) * 1024.0 * 1024.0), MiB_SIZE(1)((1) * 1024.0 * 1024.0), "%.2fM" }, | |||
350 | { GiB_SIZE(1)((1) * 1024.0 * 1024.0 * 1024.0), MiB_SIZE(1)((1) * 1024.0 * 1024.0), "%.0fM" }, | |||
351 | { GiB_SIZE(10)((10) * 1024.0 * 1024.0 * 1024.0), GiB_SIZE(1)((1) * 1024.0 * 1024.0 * 1024.0), "%.2fG" }, | |||
352 | { GiB_SIZE(100)((100) * 1024.0 * 1024.0 * 1024.0), GiB_SIZE(1)((1) * 1024.0 * 1024.0 * 1024.0), "%.1fG" }, | |||
353 | { TiB_SIZE(1)((1) * 1024.0 * 1024.0 * 1024.0 * 1024.0), GiB_SIZE(1)((1) * 1024.0 * 1024.0 * 1024.0), "%.0fG" }, | |||
354 | { TiB_SIZE(10)((10) * 1024.0 * 1024.0 * 1024.0 * 1024.0), TiB_SIZE(1)((1) * 1024.0 * 1024.0 * 1024.0 * 1024.0), "%.2fT" }, | |||
355 | { TiB_SIZE(100)((100) * 1024.0 * 1024.0 * 1024.0 * 1024.0), TiB_SIZE(1)((1) * 1024.0 * 1024.0 * 1024.0 * 1024.0), "%.1fT" } | |||
356 | }; | |||
357 | ||||
358 | static gint | |||
359 | format_fs_data(FSmon *fs, gchar *src_string, gchar *buf, gint size) | |||
360 | { | |||
361 | glong b, u, a; | |||
362 | gint len; | |||
363 | gchar *s; | |||
364 | gchar tbuf[32], ubuf[32], abuf[32]; | |||
365 | gfloat bsize, val; | |||
366 | GkrellmSizeAbbrev *tbl; | |||
367 | size_t tbl_size; | |||
368 | ||||
369 | if (!buf || size < 1) | |||
370 | return -1; | |||
371 | --size; | |||
372 | *buf = '\0'; | |||
373 | if (!src_string) | |||
374 | return -1; | |||
375 | ||||
376 | b = fs->blocks; | |||
377 | u = fs->blocks - fs->bfree; | |||
378 | a = fs->bavail; /* Can be negative on BSD */ | |||
379 | bsize = (gfloat) fs->bsize; | |||
380 | ||||
381 | tbl = binary_units ? &fs_binary_abbrev[0] : &fs_decimal_abbrev[0]; | |||
382 | tbl_size = binary_units | |||
383 | ? (sizeof(fs_binary_abbrev) / sizeof(GkrellmSizeAbbrev)) | |||
384 | : (sizeof(fs_decimal_abbrev) / sizeof(GkrellmSizeAbbrev)); | |||
385 | ||||
386 | gkrellm_format_size_abbrev(tbuf, sizeof(tbuf), (gfloat) b * bsize, | |||
387 | tbl, tbl_size); | |||
388 | gkrellm_format_size_abbrev(ubuf, sizeof(ubuf), (gfloat) u * bsize, | |||
389 | tbl, tbl_size); | |||
390 | gkrellm_format_size_abbrev(abuf, sizeof(abuf), (gfloat) a * bsize, | |||
391 | tbl, tbl_size); | |||
392 | ||||
393 | for (s = src_string; *s != '\0' && size > 0; ++s) | |||
394 | { | |||
395 | len = 1; | |||
396 | if (*s == '$' && *(s + 1) != '\0') | |||
397 | { | |||
398 | switch(*(s + 1)) | |||
399 | { | |||
400 | case 'D': | |||
401 | if (fs->mount.directory) | |||
402 | len = snprintf(buf, size, "%s", fs->mount.directory); | |||
403 | break; | |||
404 | case 'l': | |||
405 | case 'L': | |||
406 | len = snprintf(buf, size, "%s", fs->label_shadow); | |||
407 | break; | |||
408 | case 't': | |||
409 | len = snprintf(buf, size, "%s", tbuf); | |||
410 | break; | |||
411 | case 'u': | |||
412 | len = snprintf(buf, size, "%s", ubuf); | |||
413 | break; | |||
414 | case 'U': | |||
415 | if (u + a > 0) | |||
416 | val = 100.0 * (gfloat) u / (gfloat) (u + a); | |||
417 | else | |||
418 | val = 0; | |||
419 | len = snprintf(buf, size, "%.0f%%", val); | |||
420 | break; | |||
421 | case 'f': | |||
422 | len = snprintf(buf, size, "%s", abuf); | |||
423 | break; | |||
424 | case 'F': | |||
425 | if (u + a > 0) | |||
426 | val = 100.0 * (gfloat) a / (gfloat) (u + a); | |||
427 | else | |||
428 | val = 0; | |||
429 | len = snprintf(buf, size, "%.0f%%", val); | |||
430 | break; | |||
431 | case 'H': | |||
432 | len = snprintf(buf, size, "%s", | |||
433 | gkrellm_sys_get_host_name()); | |||
434 | break; | |||
435 | default: | |||
436 | *buf = *s; | |||
437 | if (size > 1) | |||
438 | { | |||
439 | *(buf + 1) = *(s + 1); | |||
440 | ++len; | |||
441 | } | |||
442 | break; | |||
443 | } | |||
444 | ++s; | |||
445 | } | |||
446 | else | |||
447 | *buf = *s; | |||
448 | size -= len; | |||
449 | buf += len; | |||
450 | } | |||
451 | *buf = '\0'; | |||
452 | return u + 1; | |||
453 | } | |||
454 | ||||
455 | /* Draw the fs label or toggle the fs total blocks and blocks avail. | |||
456 | */ | |||
457 | static gint | |||
458 | fs_draw_decal_text(FSmon *fs, gint value) | |||
459 | { | |||
460 | GkrellmDecal *d; | |||
461 | GkrellmTextstyle ts_save; | |||
462 | gchar buf[128]; | |||
463 | gint x_off, w; | |||
464 | ||||
465 | if (value == 0) | |||
466 | { | |||
467 | gkrellm_make_decal_invisible(fs->panel, fs->data_decal); | |||
468 | d = fs->label_decal; | |||
469 | gkrellm_make_decal_visible(fs->panel, d); | |||
470 | gkrellm_decal_text_set_offset(d, 0, 0); | |||
471 | gkrellm_draw_decal_markup(fs->panel, d, fs->label_shadow); | |||
472 | } | |||
473 | else if (!fs->busy) | |||
474 | { | |||
475 | gkrellm_make_decal_invisible(fs->panel, fs->label_decal); | |||
476 | d = fs->data_decal; | |||
477 | gkrellm_make_decal_visible(fs->panel, d); | |||
478 | ts_save = d->text_style; | |||
479 | d->text_style = *gkrellm_meter_alt_textstyle(style_id); | |||
480 | ||||
481 | format_fs_data(fs, data_format_locale, buf, sizeof(buf)); | |||
482 | gkrellm_decal_scroll_text_set_markup(fs->panel, d, buf); | |||
483 | gkrellm_decal_scroll_text_get_size(d, &w, NULL((void*)0)); | |||
484 | if (w > d->w) | |||
485 | x_off = d->w / 3 - x_scroll; | |||
486 | else | |||
487 | x_off = 0; | |||
488 | gkrellm_decal_text_set_offset(d, x_off, 0); | |||
489 | ||||
490 | d->text_style = ts_save; | |||
491 | } | |||
492 | return w; | |||
| ||||
493 | } | |||
494 | ||||
495 | static void | |||
496 | cb_command_process(GkrellmAlert *alert, gchar *src, gchar *dst, gint len, | |||
497 | FSmon *fs) | |||
498 | { | |||
499 | format_fs_data(fs, src, dst, len); | |||
500 | } | |||
501 | ||||
502 | static gpointer | |||
503 | close_cdrom_thread(void *device) | |||
504 | { | |||
505 | (*close_cdrom_func)((gchar *) device); | |||
506 | cdrom_thread_busy = FALSE(0); | |||
507 | return NULL((void*)0); | |||
508 | } | |||
509 | ||||
510 | static void | |||
511 | close_tray(FSmon *fs) | |||
512 | { | |||
513 | Mount *m; | |||
514 | static gchar *close_target; | |||
515 | gchar buf[512]; | |||
516 | ||||
517 | close_target = fs->eject_device; | |||
518 | if (close_cdrom_command) | |||
519 | { | |||
520 | snprintf(buf, sizeof(buf), close_cdrom_command, | |||
521 | *close_target ? close_target : fs->mount.directory); | |||
522 | g_spawn_command_line_async(buf, NULL((void*)0) /* GError */); | |||
523 | } | |||
524 | else if (close_cdrom_func && !cdrom_thread_busy) | |||
525 | { | |||
526 | if (!*close_target && (m = in_fstab_list(fs->mount.directory)) != NULL((void*)0)) | |||
527 | close_target = m->device; | |||
528 | if (*close_target) | |||
529 | { | |||
530 | cdrom_thread_busy = TRUE(!(0)); | |||
531 | g_thread_new("close_cdrom", close_cdrom_thread, close_target); | |||
532 | } | |||
533 | } | |||
534 | } | |||
535 | ||||
536 | static gpointer | |||
537 | eject_cdrom_thread(void *device) | |||
538 | { | |||
539 | (*eject_cdrom_func)((gchar *) device); | |||
540 | cdrom_thread_busy = FALSE(0); | |||
541 | return NULL((void*)0); | |||
542 | } | |||
543 | ||||
544 | static void | |||
545 | eject_tray(FSmon *fs) | |||
546 | { | |||
547 | Mount *m; | |||
548 | static gchar *eject_target; | |||
549 | gchar buf[512]; | |||
550 | ||||
551 | eject_target = fs->eject_device; | |||
552 | if (eject_cdrom_command) | |||
553 | { | |||
554 | snprintf(buf, sizeof(buf), eject_cdrom_command, | |||
555 | *eject_target ? eject_target : fs->mount.directory); | |||
556 | g_spawn_command_line_async(buf, NULL((void*)0) /* GError */); | |||
557 | } | |||
558 | else if (eject_cdrom_func && !cdrom_thread_busy) | |||
559 | { | |||
560 | if (!*eject_target && (m = in_fstab_list(fs->mount.directory)) != NULL((void*)0)) | |||
561 | eject_target = m->device; | |||
562 | if (*eject_target) | |||
563 | { | |||
564 | cdrom_thread_busy = TRUE(!(0)); | |||
565 | g_thread_new("eject_cdrom", eject_cdrom_thread, eject_target); | |||
566 | } | |||
567 | } | |||
568 | } | |||
569 | ||||
570 | static void | |||
571 | accumulate_pipe_gstring(FSmon *fs) | |||
572 | { | |||
573 | gchar buf[512]; | |||
574 | gint n; | |||
575 | ||||
576 | n = fread(buf, 1, sizeof(buf) - 1, fs->launch_mount.pipe); | |||
577 | buf[n] = '\0'; | |||
578 | if (n > 0) | |||
579 | { | |||
580 | if (fs->pipe_gstring) | |||
581 | g_string_append(fs->pipe_gstring, buf); | |||
582 | else | |||
583 | fs->pipe_gstring = g_string_new(buf); | |||
584 | } | |||
585 | if (feof(fs->launch_mount.pipe)) | |||
586 | { | |||
587 | pclose(fs->launch_mount.pipe); | |||
588 | fs->launch_mount.pipe = NULL((void*)0); | |||
589 | } | |||
590 | } | |||
591 | ||||
592 | static void | |||
593 | pipe_command(FSmon *fs, gchar *command) | |||
594 | { | |||
595 | gchar buf[512]; | |||
596 | ||||
597 | if (fs->launch_mount.pipe) /* Still running? */ | |||
598 | return; | |||
599 | snprintf(buf, sizeof(buf), "%s 2>&1", command); | |||
600 | if ((fs->launch_mount.pipe = popen(buf, "r")) == NULL((void*)0)) | |||
601 | return; | |||
602 | #ifndef WIN32 | |||
603 | fcntl(fileno(fs->launch_mount.pipe), F_SETFL4, O_NONBLOCK04000); | |||
604 | #endif | |||
605 | } | |||
606 | ||||
607 | static void | |||
608 | mount_command(FSmon *fs) | |||
609 | { | |||
610 | gchar cmd[CFG_BUFSIZE512]; | |||
611 | ||||
612 | if (! FS_MOUNTING_ENABLED(fs)((fs)->fstab_mounting || *((fs)->launch_umount.command) )) | |||
613 | return; | |||
614 | if (fs->is_mounted) | |||
615 | { | |||
616 | if (fs->fstab_mounting) | |||
617 | snprintf(cmd, sizeof(cmd), "umount '%s'", fs->mount.directory); | |||
618 | else | |||
619 | snprintf(cmd, sizeof(cmd), "%s", fs->launch_umount.command); | |||
620 | fs->label_is_data = FALSE(0); | |||
621 | fs_draw_decal_text(fs, 0); | |||
622 | pipe_command(fs, cmd); | |||
623 | if (cdrom_auto_eject) | |||
624 | fs->eject_pending = GK.timer_ticks + 5; /* at least 1/2 sec delay*/ | |||
625 | } | |||
626 | else | |||
627 | { | |||
628 | if (fs->ejectable) | |||
629 | close_tray(fs); | |||
630 | if (fs->fstab_mounting) | |||
631 | snprintf(cmd, sizeof(cmd), "mount '%s'", fs->mount.directory); | |||
632 | else | |||
633 | snprintf(cmd, sizeof(cmd), "%s", fs->launch_mount.command); | |||
634 | fs->blocks = fs->bfree = fs->bavail = fs->bsize = 0; | |||
635 | pipe_command(fs, cmd); | |||
636 | } | |||
637 | force_fs_check = FORCE_REDRAW1; /* An update triggers when pipe closes */ | |||
638 | } | |||
639 | ||||
640 | static void | |||
641 | hide_secondary_monitors(void) | |||
642 | { | |||
643 | FSmon *fs; | |||
644 | GList *list; | |||
645 | ||||
646 | if (!secondary_monitors_shown) | |||
647 | return; | |||
648 | secondary_monitors_shown = FALSE(0); | |||
649 | gkrellm_freeze_side_frame_packing(); | |||
650 | for (list = fs_mon_list; list; list = list->next) | |||
651 | { | |||
652 | fs = (FSmon *) list->data; | |||
653 | if (fs->secondary && (!fs_is_mounted(fs) || !fs->show_if_mounted)) | |||
654 | gkrellm_panel_hide(fs->panel); | |||
655 | } | |||
656 | gkrellm_thaw_side_frame_packing(); | |||
657 | } | |||
658 | ||||
659 | static void | |||
660 | show_secondary_monitors(void) | |||
661 | { | |||
662 | FSmon *fs; | |||
663 | GList *list; | |||
664 | ||||
665 | if (secondary_monitors_shown) | |||
666 | return; | |||
667 | secondary_monitors_shown = TRUE(!(0)); | |||
668 | gkrellm_freeze_side_frame_packing(); | |||
669 | for (list = fs_mon_list; list; list = list->next) | |||
670 | { | |||
671 | fs = (FSmon *) list->data; | |||
672 | if (fs->secondary) | |||
673 | gkrellm_panel_show(fs->panel); | |||
674 | } | |||
675 | gkrellm_thaw_side_frame_packing(); | |||
676 | } | |||
677 | ||||
678 | static gpointer | |||
679 | get_fsusage_thread(void *data) | |||
680 | { | |||
681 | FSmon *fs = (FSmon *) data; | |||
682 | ||||
683 | (*get_fsusage)(fs, fs->mount.directory); | |||
684 | fs->busy = FALSE(0); | |||
685 | return NULL((void*)0); | |||
686 | } | |||
687 | ||||
688 | static gboolean | |||
689 | animate_eject_button(FSmon *fs, gboolean force_close) | |||
690 | { | |||
691 | gint dx, target; | |||
692 | ||||
693 | if (force_close) | |||
694 | target = x_eject_button_closed; | |||
695 | else | |||
696 | target = fs->x_eject_button_target; | |||
697 | dx = target - fs->eject_decal->x; | |||
698 | if (dx > 0) | |||
699 | gkrellm_move_decal(fs->panel, fs->eject_decal, | |||
700 | fs->eject_decal->x + 1 + dx / 4, fs->eject_decal->y); | |||
701 | else if (dx < 0) | |||
702 | gkrellm_move_decal(fs->panel, fs->eject_decal, | |||
703 | fs->eject_decal->x - 1 + dx / 4, fs->eject_decal->y); | |||
704 | if (fs->eject_decal->x < x_eject_button_closed) | |||
705 | gkrellm_show_button(fs->eject_button); | |||
706 | else | |||
707 | gkrellm_hide_button(fs->eject_button); | |||
708 | if (fs->eject_decal->x != target) | |||
709 | return TRUE(!(0)); | |||
710 | return FALSE(0); | |||
711 | } | |||
712 | ||||
713 | static void | |||
714 | fs_update(void) | |||
715 | { | |||
716 | FSmon *fs; | |||
717 | GkrellmPanel *p; | |||
718 | GkrellmKrell *k; | |||
719 | GList *list; | |||
720 | glong used, avail; | |||
721 | gint full_scale, index, w_scroll, w; | |||
722 | gboolean fs_check, nfs_check, force_check, force_draw, | |||
723 | mounting_enabled; | |||
724 | ||||
725 | if (!fs_mon_list) | |||
726 | return; | |||
727 | ||||
728 | w = w_scroll = 0; | |||
729 | for (list = fs_mon_list; list; list = list->next) | |||
730 | { | |||
731 | fs = (FSmon *) list->data; | |||
732 | if (fs->label_is_data && !fs_in_motion) | |||
733 | { | |||
734 | w = fs_draw_decal_text(fs, 1); | |||
735 | if (w > w_scroll) | |||
736 | w_scroll = w; | |||
737 | gkrellm_draw_panel_layers(fs->panel); | |||
738 | } | |||
739 | } | |||
740 | if (!fs_in_motion) | |||
741 | { | |||
742 | if (w_scroll > data_decal_width) | |||
743 | x_scroll = (x_scroll + ((gkrellm_update_HZ() < 7) ? 2 : 1)) | |||
744 | % (w_scroll - data_decal_width / 3); | |||
745 | else | |||
746 | x_scroll = 0; | |||
747 | } | |||
748 | if (GK.second_tick) | |||
749 | ++check_tick; | |||
750 | fs_check = (check_tick % fs_check_timeout) ? FALSE(0) : TRUE(!(0)); | |||
751 | if (_GK.client_mode) | |||
752 | nfs_check = fs_check; | |||
753 | else | |||
754 | nfs_check = (check_tick % nfs_check_timeout) ? FALSE(0) : TRUE(!(0)); | |||
755 | ||||
756 | if (!force_fs_check && (!GK.second_tick || (!fs_check && !nfs_check))) | |||
757 | return; | |||
758 | //g_debug("fs update %d nfs %d force %d\n", fs_check, nfs_check, force_fs_check); | |||
759 | ||||
760 | refresh_mounts_list(); | |||
761 | ||||
762 | force_check = force_draw = FALSE(0); | |||
763 | ||||
764 | for (list = fs_mon_list; list; list = list->next) | |||
765 | { | |||
766 | fs = (FSmon *) list->data; | |||
767 | p = fs->panel; | |||
768 | k = fs->krell; | |||
769 | mounting_enabled = FS_MOUNTING_ENABLED(fs)((fs)->fstab_mounting || *((fs)->launch_umount.command) ); | |||
770 | if (fs_is_mounted(fs)) | |||
771 | { | |||
772 | if (mounting_enabled) | |||
773 | { /* Blink it while busy or pipe is open. */ | |||
774 | if ( (fs->launch_mount.pipe || fs->busy) | |||
775 | && fs->md_button->cur_index == D_MISC_FS_MOUNTED7 | |||
776 | ) | |||
777 | index = D_MISC_FS_UMOUNTED6; | |||
778 | else | |||
779 | index = D_MISC_FS_MOUNTED7; | |||
780 | gkrellm_set_decal_button_index(fs->md_button, index); | |||
781 | } | |||
782 | else | |||
783 | { | |||
784 | if (fs->busy && fs->md_button->cur_index == D_MISC_LED15) | |||
785 | index = D_MISC_LED04; | |||
786 | else | |||
787 | index = mounting_supported ? D_MISC_LED15 : D_MISC_BLANK0; | |||
788 | gkrellm_set_decal_button_index(fs->md_button, index); | |||
789 | } | |||
790 | if ( force_fs_check == FORCE_UPDATE2 | |||
791 | || (fs_check && !fs->is_nfs_fs) | |||
792 | || (nfs_check && fs->is_nfs_fs) | |||
793 | ) | |||
794 | { | |||
795 | if (!fs->is_nfs_fs || _GK.client_mode) | |||
796 | (*get_fsusage)(fs, fs->mount.directory); | |||
797 | else if (!fs->busy) | |||
798 | { | |||
799 | fs->busy = TRUE(!(0)); | |||
800 | g_thread_new("get_fsusage", get_fsusage_thread, fs); | |||
801 | } | |||
802 | fs->krell_factor = fs->blocks > 2097152 ? 1024 : 1; | |||
803 | } | |||
804 | ||||
805 | avail = fs->bavail >= 0 ? fs->bavail : 0; | |||
806 | used = fs->blocks - fs->bfree; | |||
807 | full_scale = (gint) (used + avail) / fs->krell_factor; | |||
808 | used /= fs->krell_factor; | |||
809 | gkrellm_set_krell_full_scale(k, full_scale, 1); | |||
810 | ||||
811 | if (!fs->busy) | |||
812 | { | |||
813 | if ( (fs_in_motion && fs->label_is_data && x_moved) | |||
814 | || fs->mouse_entered | |||
815 | ) | |||
816 | gkrellm_update_krell(p, k, 0); | |||
817 | else | |||
818 | gkrellm_update_krell(p, k, used); | |||
819 | if (full_scale > 0) | |||
820 | gkrellm_check_alert(fs->alert, | |||
821 | 100.0 * (gfloat) used / (gfloat) full_scale); | |||
822 | } | |||
823 | else | |||
824 | force_draw = TRUE(!(0)); | |||
825 | ||||
826 | if (fs->secondary && fs->show_if_mounted) | |||
827 | gkrellm_panel_show(fs->panel); | |||
828 | if (fs->eject_decal) | |||
829 | force_draw |= animate_eject_button(fs, mounting_supported); | |||
830 | } | |||
831 | else /* not mounted */ | |||
832 | { | |||
833 | gkrellm_reset_alert(fs->alert); | |||
834 | if (mounting_enabled) | |||
835 | { /* Blink it while pipe is open. */ | |||
836 | if ( fs->launch_mount.pipe | |||
837 | && fs->md_button->cur_index == D_MISC_FS_UMOUNTED6 | |||
838 | ) | |||
839 | index = D_MISC_FS_MOUNTED7; | |||
840 | else | |||
841 | index = D_MISC_FS_UMOUNTED6; | |||
842 | gkrellm_set_decal_button_index(fs->md_button, index); | |||
843 | } | |||
844 | else | |||
845 | gkrellm_set_decal_button_index(fs->md_button, D_MISC_LED04); | |||
846 | gkrellm_set_krell_full_scale(k, 100, 1); /* Arbitrary > 0 */ | |||
847 | gkrellm_update_krell(p, k, 0); | |||
848 | if (!secondary_monitors_shown && fs->secondary) | |||
849 | gkrellm_panel_hide(fs->panel); | |||
850 | if (fs->eject_decal) | |||
851 | force_draw |= animate_eject_button(fs, FALSE(0)); | |||
852 | } | |||
853 | gkrellm_set_button_sensitive(fs->md_button, mounting_enabled); | |||
854 | if (!fs->label_is_data && fs != fs_in_motion) | |||
855 | fs_draw_decal_text(fs, 0); | |||
856 | ||||
857 | if (_GK.client_mode) | |||
858 | { | |||
859 | if (fs->blocks == 0) | |||
860 | gkrellm_remove_krell(p, k); | |||
861 | else | |||
862 | gkrellm_insert_krell(p, k, FALSE(0)); | |||
863 | } | |||
864 | ||||
865 | gkrellm_draw_panel_layers(p); | |||
866 | ||||
867 | if ( fs->ejectable | |||
868 | && fs->eject_pending && fs->eject_pending < GK.timer_ticks | |||
869 | ) | |||
870 | { | |||
871 | eject_tray(fs); | |||
872 | fs->eject_pending = 0; | |||
873 | } | |||
874 | if (fs->launch_mount.pipe) | |||
875 | { | |||
876 | accumulate_pipe_gstring(fs); | |||
877 | if (fs->launch_mount.pipe == NULL((void*)0)) /* Command is done */ | |||
878 | { | |||
879 | if (fs->pipe_gstring) | |||
880 | { | |||
881 | gkrellm_message_dialog(_("GKrellM Mount Error")dcgettext ("gkrellm", "GKrellM Mount Error", 5), | |||
882 | fs->pipe_gstring->str); | |||
883 | g_string_free(fs->pipe_gstring, 1); | |||
884 | fs->pipe_gstring = NULL((void*)0); | |||
885 | } | |||
886 | force_check = TRUE(!(0)); | |||
887 | } | |||
888 | else | |||
889 | force_draw = TRUE(!(0)); /* Keep it going */ | |||
890 | } | |||
891 | } | |||
892 | force_fs_check = force_check ? FORCE_UPDATE2 : force_draw; | |||
893 | } | |||
894 | ||||
895 | static gint | |||
896 | fs_expose_event(GtkWidget *widget, GdkEventExpose *ev) | |||
897 | { | |||
898 | FSmon *fs; | |||
899 | GList *list; | |||
900 | ||||
901 | for (list = fs_mon_list; list; list = list->next) | |||
902 | { | |||
903 | fs = (FSmon *) list->data; | |||
904 | if (widget == fs->panel->drawing_area) | |||
905 | { | |||
906 | gdk_draw_drawable(widget->window, gkrellm_draw_GC(1), | |||
907 | fs->panel->pixmap, | |||
908 | ev->area.x, ev->area.y, ev->area.x, ev->area.y, | |||
909 | ev->area.width, ev->area.height); | |||
910 | break; | |||
911 | } | |||
912 | } | |||
913 | return FALSE(0); | |||
914 | } | |||
915 | ||||
916 | static gint | |||
917 | cb_panel_enter(GtkWidget *w, GdkEventButton *ev, FSmon *fs) | |||
918 | { | |||
919 | if (fs->label_is_data) | |||
920 | { | |||
921 | fs->mouse_entered = TRUE(!(0)); | |||
922 | force_fs_check = FORCE_REDRAW1; | |||
923 | } | |||
924 | if (fs->ejectable) | |||
925 | { | |||
926 | fs->x_eject_button_target = x_eject_button_open; | |||
927 | force_fs_check = FORCE_REDRAW1; | |||
928 | } | |||
929 | if (fs != fs_in_motion) | |||
930 | gkrellm_show_button(fs->drawer_button); | |||
931 | return FALSE(0); | |||
932 | } | |||
933 | ||||
934 | static gint | |||
935 | cb_panel_leave(GtkWidget *w, GdkEventButton *ev, FSmon *fs) | |||
936 | { | |||
937 | if (fs->mouse_entered) | |||
938 | force_fs_check = FORCE_REDRAW1; | |||
939 | fs->mouse_entered = FALSE(0); | |||
940 | if (fs->ejectable) | |||
941 | { | |||
942 | fs->x_eject_button_target = x_eject_button_closed; | |||
943 | force_fs_check = FORCE_REDRAW1; | |||
944 | } | |||
945 | return FALSE(0); | |||
946 | } | |||
947 | ||||
948 | ||||
949 | static void | |||
950 | cb_drawer_button(GkrellmDecalbutton *button, FSmon *fs) | |||
951 | { | |||
952 | if (secondary_monitors_shown) | |||
953 | hide_secondary_monitors(); | |||
954 | else | |||
955 | show_secondary_monitors(); | |||
956 | } | |||
957 | ||||
958 | static gint | |||
959 | cb_panel_scroll(GtkWidget *widget, GdkEventScroll *ev) | |||
960 | { | |||
961 | if (ev->direction == GDK_SCROLL_UP) | |||
962 | hide_secondary_monitors(); | |||
963 | if (ev->direction == GDK_SCROLL_DOWN) | |||
964 | show_secondary_monitors(); | |||
965 | return FALSE(0); | |||
966 | } | |||
967 | ||||
968 | static gint | |||
969 | cb_panel_release(GtkWidget *widget, GdkEventButton *ev, FSmon *fs) | |||
970 | { | |||
971 | if (ev->button == 3) | |||
972 | return TRUE(!(0)); | |||
973 | if (fs_in_motion) | |||
974 | { | |||
975 | if (fs_in_motion->restore_label) | |||
976 | { | |||
977 | if (fs_in_motion->label_is_data) | |||
978 | gkrellm_config_modified(); | |||
979 | fs_in_motion->label_is_data = FALSE(0); | |||
980 | fs_draw_decal_text(fs_in_motion, 0); | |||
981 | gkrellm_show_button(fs_in_motion->drawer_button); | |||
982 | gkrellm_draw_panel_layers(fs_in_motion->panel); | |||
983 | } | |||
984 | fs_in_motion->restore_label = TRUE(!(0)); | |||
985 | } | |||
986 | force_fs_check = FORCE_REDRAW1; /* Move krells back */ | |||
987 | fs_in_motion = NULL((void*)0); | |||
988 | x_moved = 0; | |||
989 | return FALSE(0); | |||
990 | } | |||
991 | ||||
992 | static gint | |||
993 | cb_panel_press(GtkWidget *widget, GdkEventButton *ev, FSmon *fs) | |||
994 | { | |||
995 | GkrellmDecal *d; | |||
996 | ||||
997 | d = fs->eject_decal ? fs->eject_decal : fs->mount_decal; | |||
| ||||
998 | ||||
999 | if (ev->button == 3 && ev->x < d->x) | |||
1000 | { | |||
1001 | gkrellm_open_config_window(mon_fs); | |||
1002 | return TRUE(!(0)); | |||
1003 | } | |||
1004 | #if 0 | |||
1005 | if ( ev->button == 1 | |||
1006 | && ( (fs->drawer_button | |||
1007 | && gkrellm_in_decal(fs->drawer_button->decal, ev)) | |||
1008 | || ev->x >= d->x | |||
1009 | ) | |||
1010 | ) | |||
1011 | return FALSE(0); | |||
1012 | #endif | |||
1013 | ||||
1014 | if (!fs->label_is_data) | |||
1015 | { | |||
1016 | fs->label_is_data = TRUE(!(0)); | |||
1017 | fs->restore_label = FALSE(0); | |||
1018 | fs->mouse_entered = TRUE(!(0)); | |||
1019 | gkrellm_config_modified(); | |||
1020 | } | |||
1021 | x_fs_motion = ev->x; | |||
1022 | fs_draw_decal_text(fs, 1); | |||
1023 | gkrellm_draw_panel_layers(fs->panel); | |||
1024 | fs_in_motion = fs; | |||
1025 | x_moved = 0; | |||
1026 | gkrellm_hide_button(fs->drawer_button); | |||
1027 | return TRUE(!(0)); | |||
1028 | } | |||
1029 | ||||
1030 | static gint | |||
1031 | cb_panel_motion(GtkWidget *widget, GdkEventButton *ev) | |||
1032 | { | |||
1033 | GdkModifierType state; | |||
1034 | GList *list; | |||
1035 | FSmon *fs; | |||
1036 | GkrellmDecal *d; | |||
1037 | gchar buf[128]; | |||
1038 | gint w, x_delta = 0; | |||
1039 | ||||
1040 | state = ev->state; | |||
1041 | if ( !fs_in_motion | |||
1042 | || !(state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK)) | |||
1043 | || !fs_in_motion->label_is_data | |||
1044 | ) | |||
1045 | { | |||
1046 | fs_in_motion = NULL((void*)0); | |||
1047 | return FALSE(0); | |||
1048 | } | |||
1049 | ||||
1050 | d = fs_in_motion->data_decal; | |||
1051 | format_fs_data(fs_in_motion, data_format_locale, buf, sizeof(buf)); | |||
1052 | gkrellm_decal_scroll_text_get_size(d, &w, NULL((void*)0)); | |||
1053 | if (w > d->w) | |||
1054 | { | |||
1055 | x_delta = ev->x - x_fs_motion; | |||
1056 | x_fs_motion = ev->x; | |||
1057 | d->x_off += x_delta; | |||
1058 | if (d->x_off < -w) | |||
1059 | d->x_off = -w; | |||
1060 | if (d->x_off > d->w) | |||
1061 | d->x_off = d->w; | |||
1062 | x_scroll = d->w / 3 - d->x_off; | |||
1063 | for (list = fs_mon_list; list; list = list->next) | |||
1064 | { | |||
1065 | fs = (FSmon *) list->data; | |||
1066 | if (fs->label_is_data) | |||
1067 | { | |||
1068 | fs_draw_decal_text(fs, 1); | |||
1069 | gkrellm_draw_panel_layers(fs->panel); | |||
1070 | } | |||
1071 | } | |||
1072 | if (x_moved > 0) | |||
1073 | fs_in_motion->restore_label = FALSE(0); | |||
1074 | } | |||
1075 | if (x_moved == 0) | |||
1076 | force_fs_check = FORCE_REDRAW1; /* Move krells out of the way */ | |||
1077 | x_moved += (x_delta > 0) ? x_delta : -x_delta; | |||
1078 | return FALSE(0); | |||
1079 | } | |||
1080 | ||||
1081 | static void | |||
1082 | cb_fs_mount_button(GkrellmDecalbutton *button) | |||
1083 | { | |||
1084 | if (button) | |||
1085 | mount_command((FSmon *) button->data); | |||
1086 | } | |||
1087 | ||||
1088 | static void | |||
1089 | cb_fs_eject_button(GkrellmDecalbutton *button, FSmon *fs) | |||
1090 | { | |||
1091 | if (button) | |||
1092 | eject_tray(fs); | |||
1093 | } | |||
1094 | ||||
1095 | static void | |||
1096 | cb_fs_close_tray(GkrellmDecalbutton *button, FSmon *fs) | |||
1097 | { | |||
1098 | if (button) | |||
1099 | close_tray(fs); | |||
1100 | } | |||
1101 | ||||
1102 | static void | |||
1103 | fs_monitor_create(GtkWidget *vbox, FSmon *fs, gint index, gint first_create) | |||
1104 | { | |||
1105 | GkrellmStyle *style; | |||
1106 | GkrellmTextstyle *ts; | |||
1107 | GkrellmMargin *m; | |||
1108 | GkrellmPanel *p; | |||
1109 | gchar buf[256]; | |||
1110 | gint h, label_x_position, label_y_off; | |||
1111 | gint h_data, h_label; | |||
1112 | ||||
1113 | if (first_create) | |||
1114 | fs->panel = gkrellm_panel_new0(); | |||
1115 | p = fs->panel; | |||
1116 | fs->idx = index; | |||
1117 | ++n_fs_monitors; | |||
1118 | fs->krell_factor = 1; | |||
1119 | ||||
1120 | style = gkrellm_meter_style(style_id); | |||
1121 | ts = gkrellm_meter_textstyle(style_id); | |||
1122 | m = gkrellm_get_style_margins(style); | |||
1123 | ||||
1124 | gkrellm_panel_label_get_position(style, &label_x_position, &label_y_off); | |||
1125 | ||||
1126 | format_fs_data(fs, data_format_locale, buf, sizeof(buf)); | |||
1127 | fs->data_decal = gkrellm_create_decal_text_markup(p, buf, | |||
1128 | ts, style, -1, | |||
1129 | (label_y_off > 0) ? label_y_off : -1, | |||
1130 | -1); | |||
1131 | gkrellm_decal_get_size(fs->data_decal, NULL((void*)0), &h_data); | |||
1132 | ||||
1133 | fs->label_decal = gkrellm_create_decal_text_markup(p, fs->label_shadow, | |||
1134 | ts, style, -1, | |||
1135 | (label_y_off > 0) ? label_y_off : -1, | |||
1136 | -1); | |||
1137 | gkrellm_decal_get_size(fs->label_decal, NULL((void*)0), &h_label); | |||
1138 | ||||
1139 | if (h_data > h_label) | |||
1140 | gkrellm_move_decal(p, fs->label_decal, fs->label_decal->x, | |||
1141 | fs->label_decal->y + (h_data - h_label + 1) / 2); | |||
1142 | else if (h_data < h_label) | |||
1143 | gkrellm_move_decal(p, fs->data_decal, fs->data_decal->x, | |||
1144 | fs->data_decal->y + (h_label - h_data + 1) / 2); | |||
1145 | ||||
1146 | fs->mount_decal = gkrellm_create_decal_pixmap(p, | |||
1147 | gkrellm_decal_misc_pixmap(), gkrellm_decal_misc_mask(), | |||
1148 | N_MISC_DECALS12, style, -1, -1); | |||
1149 | fs->mount_decal->x = | |||
1150 | gkrellm_chart_width() - fs->mount_decal->w - m->right; | |||
1151 | ||||
1152 | if (fs->ejectable) | |||
1153 | { | |||
1154 | fs->eject_decal = gkrellm_create_decal_pixmap(p, | |||
1155 | gkrellm_decal_misc_pixmap(), gkrellm_decal_misc_mask(), | |||
1156 | N_MISC_DECALS12, style, -1, -1); | |||
1157 | if (mounting_supported) | |||
1158 | { | |||
1159 | x_eject_button_closed = fs->mount_decal->x; | |||
1160 | x_eject_button_open = fs->mount_decal->x - fs->eject_decal->w + 1; | |||
1161 | } | |||
1162 | else | |||
1163 | { | |||
1164 | x_eject_button_closed = gkrellm_chart_width() - 2; | |||
1165 | x_eject_button_open = x_eject_button_closed - fs->eject_decal->w; | |||
1166 | } | |||
1167 | fs->x_eject_button_target = x_eject_button_closed; | |||
1168 | fs->eject_decal->x = x_eject_button_closed; | |||
1169 | } | |||
1170 | ||||
1171 | /* Usable width to determine various scrolling parameters. | |||
1172 | */ | |||
1173 | data_decal_width = fs->mount_decal->x - fs->data_decal->x; | |||
1174 | ||||
1175 | fs->krell = gkrellm_create_krell(p, | |||
1176 | gkrellm_krell_meter_piximage(style_id), style); | |||
1177 | gkrellm_monotonic_krell_values(fs->krell, FALSE(0)); | |||
1178 | ||||
1179 | gkrellm_panel_configure(p, NULL((void*)0), style); | |||
1180 | gkrellm_panel_create(vbox, mon_fs, p); | |||
1181 | ||||
1182 | fs->md_button = gkrellm_make_decal_button(p, fs->mount_decal, | |||
1183 | cb_fs_mount_button, fs, D_MISC_FS_UMOUNTED6, D_MISC_FS_PRESSED8); | |||
1184 | if (index == 0 && have_secondary_panels) | |||
1185 | { | |||
1186 | if ((h = p->h / 2) > 7) | |||
1187 | h = 7; | |||
1188 | fs->drawer_button = gkrellm_make_scaled_button(p, NULL((void*)0), | |||
1189 | cb_drawer_button, fs, TRUE(!(0)), TRUE(!(0)), | |||
1190 | 0, 0, 0, /* NULL image => builtin depth & indices */ | |||
1191 | (gkrellm_chart_width() - 20) / 2, 0, | |||
1192 | 20, h); | |||
1193 | /* Make it appear under the label decal */ | |||
1194 | gkrellm_remove_decal(p, fs->drawer_button->decal); | |||
1195 | gkrellm_insert_decal_nth(p, fs->drawer_button->decal, 0); | |||
1196 | } | |||
1197 | if (fs->eject_decal) | |||
1198 | { | |||
1199 | fs->eject_button = gkrellm_make_decal_button(p, fs->eject_decal, | |||
1200 | cb_fs_eject_button, fs, D_MISC_BUTTON_OUT9, D_MISC_BUTTON_IN11); | |||
1201 | gkrellm_hide_button(fs->eject_button); | |||
1202 | if (close_cdrom_command || close_cdrom_func) | |||
1203 | gkrellm_decal_button_right_connect(fs->eject_button, | |||
1204 | cb_fs_close_tray, fs); | |||
1205 | } | |||
1206 | if (first_create) | |||
1207 | { | |||
1208 | 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) (fs_expose_event ))), (((void*)0)), ((void*)0), (GConnectFlags) 0) | |||
1209 | G_CALLBACK(fs_expose_event), NULL)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((p->drawing_area)), (((GType) ((20) << (2))))))))), ("expose_event"), (((GCallback) (fs_expose_event ))), (((void*)0)), ((void*)0), (GConnectFlags) 0); | |||
1210 | 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 ))), (fs), ((void*)0), (GConnectFlags) 0) | |||
1211 | G_CALLBACK(cb_panel_press), fs)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((p->drawing_area)), (((GType) ((20) << (2))))))))), ("button_press_event"), (((GCallback) (cb_panel_press ))), (fs), ((void*)0), (GConnectFlags) 0); | |||
1212 | g_signal_connect(G_OBJECT(p->drawing_area),"button_release_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((p->drawing_area)), (((GType) ((20) << (2))))))))), ("button_release_event"), (((GCallback) (cb_panel_release ))), (fs), ((void*)0), (GConnectFlags) 0) | |||
1213 | G_CALLBACK(cb_panel_release), fs)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((p->drawing_area)), (((GType) ((20) << (2))))))))), ("button_release_event"), (((GCallback) (cb_panel_release ))), (fs), ((void*)0), (GConnectFlags) 0); | |||
1214 | g_signal_connect(G_OBJECT(p->drawing_area),"scroll_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((p->drawing_area)), (((GType) ((20) << (2))))))))), ("scroll_event"), (((GCallback) (cb_panel_scroll ))), (fs), ((void*)0), (GConnectFlags) 0) | |||
1215 | G_CALLBACK(cb_panel_scroll), fs)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((p->drawing_area)), (((GType) ((20) << (2))))))))), ("scroll_event"), (((GCallback) (cb_panel_scroll ))), (fs), ((void*)0), (GConnectFlags) 0); | |||
1216 | g_signal_connect(G_OBJECT(p->drawing_area),"motion_notify_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((p->drawing_area)), (((GType) ((20) << (2))))))))), ("motion_notify_event"), (((GCallback) (cb_panel_motion ))), (((void*)0)), ((void*)0), (GConnectFlags) 0) | |||
1217 | G_CALLBACK(cb_panel_motion), NULL)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((p->drawing_area)), (((GType) ((20) << (2))))))))), ("motion_notify_event"), (((GCallback) (cb_panel_motion ))), (((void*)0)), ((void*)0), (GConnectFlags) 0); | |||
1218 | g_signal_connect(G_OBJECT(p->drawing_area), "enter_notify_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((p->drawing_area)), (((GType) ((20) << (2))))))))), ("enter_notify_event"), (((GCallback) (cb_panel_enter ))), (fs), ((void*)0), (GConnectFlags) 0) | |||
1219 | G_CALLBACK(cb_panel_enter), fs)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((p->drawing_area)), (((GType) ((20) << (2))))))))), ("enter_notify_event"), (((GCallback) (cb_panel_enter ))), (fs), ((void*)0), (GConnectFlags) 0); | |||
1220 | g_signal_connect(G_OBJECT(p->drawing_area), "leave_notify_event",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((p->drawing_area)), (((GType) ((20) << (2))))))))), ("leave_notify_event"), (((GCallback) (cb_panel_leave ))), (fs), ((void*)0), (GConnectFlags) 0) | |||
1221 | G_CALLBACK(cb_panel_leave), fs)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((p->drawing_area)), (((GType) ((20) << (2))))))))), ("leave_notify_event"), (((GCallback) (cb_panel_leave ))), (fs), ((void*)0), (GConnectFlags) 0); | |||
1222 | if ( !secondary_monitors_shown && fs->secondary | |||
1223 | && (!fs_is_mounted(fs) || !fs->show_if_mounted)) | |||
1224 | gkrellm_panel_hide(fs->panel); | |||
1225 | } | |||
1226 | ||||
1227 | fs_draw_decal_text(fs, 0); | |||
1228 | force_fs_check = FORCE_UPDATE2; | |||
1229 | ||||
1230 | if (fs->launch_mount.command == NULL((void*)0)) | |||
1231 | fs->launch_mount.command = g_strdup(""); | |||
1232 | if (fs->launch_umount.command == NULL((void*)0)) | |||
1233 | fs->launch_umount.command = g_strdup(""); | |||
1234 | } | |||
1235 | ||||
1236 | static void | |||
1237 | free_fsmon_strings(FSmon *fs) | |||
1238 | { | |||
1239 | g_free(fs->label); | |||
1240 | g_free(fs->label_shadow); | |||
1241 | g_free(fs->mount.directory); | |||
1242 | g_free(fs->eject_device); | |||
1243 | g_free(fs->launch_mount.command); | |||
1244 | g_free(fs->launch_umount.command); | |||
1245 | } | |||
1246 | ||||
1247 | static void | |||
1248 | destroy_fs_monitor(FSmon *fs) | |||
1249 | { | |||
1250 | gkrellm_reset_alert(fs->alert); | |||
1251 | free_fsmon_strings(fs); | |||
1252 | gkrellm_panel_destroy(fs->panel); | |||
1253 | g_free(fs); | |||
1254 | --n_fs_monitors; | |||
1255 | } | |||
1256 | ||||
1257 | static void | |||
1258 | fs_create(GtkWidget *vbox, gint first_create) | |||
1259 | { | |||
1260 | GList *list; | |||
1261 | FSmon *fs; | |||
1262 | gint i; | |||
1263 | ||||
1264 | if (fs_main_vbox == NULL((void*)0)) | |||
1265 | { | |||
1266 | fs_main_vbox = gtk_vbox_new(FALSE(0), 0); | |||
1267 | gtk_box_pack_start(GTK_BOX(vbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((vbox )), ((gtk_box_get_type ())))))), fs_main_vbox, FALSE(0), FALSE(0), 0); | |||
1268 | gtk_widget_show(fs_main_vbox); | |||
1269 | ||||
1270 | fs_secondary_vbox = gtk_vbox_new(FALSE(0), 0); | |||
1271 | gtk_box_pack_start(GTK_BOX(vbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((vbox )), ((gtk_box_get_type ())))))), fs_secondary_vbox, FALSE(0), FALSE(0), 0); | |||
1272 | gtk_widget_show(fs_secondary_vbox); | |||
1273 | secondary_monitors_shown = FALSE(0); | |||
1274 | } | |||
1275 | n_fs_monitors = 0; | |||
1276 | for (i = 0, list = fs_mon_list; list; ++i, list = list->next) | |||
1277 | { | |||
1278 | fs = (FSmon *)list->data; | |||
1279 | fs_monitor_create(fs->secondary ? fs_secondary_vbox : fs_main_vbox,fs, | |||
1280 | i, first_create); | |||
1281 | } | |||
1282 | if (g_list_length(fs_mon_list) == 0) | |||
1283 | gkrellm_spacers_hide(mon_fs); | |||
1284 | } | |||
1285 | ||||
1286 | #define FS_CONFIG_KEYWORD"fs" "fs" | |||
1287 | ||||
1288 | static void | |||
1289 | cb_alert_trigger(GkrellmAlert *alert, FSmon *fs) | |||
1290 | { | |||
1291 | /* Full panel alert, default decal. | |||
1292 | */ | |||
1293 | alert->panel = fs->panel; | |||
1294 | } | |||
1295 | ||||
1296 | static void | |||
1297 | create_alert(FSmon *fs) | |||
1298 | { | |||
1299 | fs->alert = gkrellm_alert_create(NULL((void*)0), fs->label, | |||
1300 | _("Percent Usage")dcgettext ("gkrellm", "Percent Usage", 5), | |||
1301 | TRUE(!(0)), FALSE(0), TRUE(!(0)), | |||
1302 | 100, 10, 1, 10, 0); | |||
1303 | gkrellm_alert_trigger_connect(fs->alert, cb_alert_trigger, fs); | |||
1304 | gkrellm_alert_config_connect(fs->alert, cb_alert_config, fs); | |||
1305 | gkrellm_alert_command_process_connect(fs->alert, cb_command_process, fs); | |||
1306 | } | |||
1307 | ||||
1308 | static void | |||
1309 | fs_config_save(FILE *f) | |||
1310 | { | |||
1311 | GList *list; | |||
1312 | FSmon *fs; | |||
1313 | gchar quoted_label[64], quoted_dir[512]; | |||
1314 | ||||
1315 | for (list = fs_mon_list; list; list = list->next) | |||
1316 | { | |||
1317 | fs = (FSmon *) list->data; | |||
1318 | snprintf(quoted_label, sizeof(quoted_label), "\"%s\"", fs->label); | |||
1319 | snprintf(quoted_dir, sizeof(quoted_dir), "\"%s\"",fs->mount.directory); | |||
1320 | fprintf(f, "%s %s %s %d %d %d %d %d\n", FS_CONFIG_KEYWORD"fs", | |||
1321 | quoted_label, quoted_dir, | |||
1322 | fs->fstab_mounting, fs->secondary, | |||
1323 | fs->show_if_mounted, fs->label_is_data, fs->ejectable); | |||
1324 | if (*(fs->launch_mount.command)) | |||
1325 | fprintf(f, "%s mount_command %s\n", FS_CONFIG_KEYWORD"fs", | |||
1326 | fs->launch_mount.command); | |||
1327 | if (*(fs->launch_umount.command)) | |||
1328 | fprintf(f, "%s umount_command %s\n", FS_CONFIG_KEYWORD"fs", | |||
1329 | fs->launch_umount.command); | |||
1330 | if (*(fs->eject_device)) | |||
1331 | fprintf(f, "%s eject_device %s\n", FS_CONFIG_KEYWORD"fs", | |||
1332 | fs->eject_device); | |||
1333 | if (fs->alert) | |||
1334 | gkrellm_save_alertconfig(f, fs->alert, | |||
1335 | FS_CONFIG_KEYWORD"fs", quoted_label); | |||
1336 | } | |||
1337 | if (!_GK.client_mode) | |||
1338 | { | |||
1339 | fprintf(f, "%s fs_check_timeout %d\n", FS_CONFIG_KEYWORD"fs", | |||
1340 | fs_check_timeout); | |||
1341 | fprintf(f, "%s nfs_check_timeout %d\n", FS_CONFIG_KEYWORD"fs", | |||
1342 | nfs_check_timeout); | |||
1343 | fprintf(f, "%s auto_eject %d\n", FS_CONFIG_KEYWORD"fs", cdrom_auto_eject); | |||
1344 | } | |||
1345 | fprintf(f, "%s binary_units %d\n", FS_CONFIG_KEYWORD"fs", binary_units); | |||
1346 | fprintf(f, "%s data_format %s\n", FS_CONFIG_KEYWORD"fs", data_format); | |||
1347 | } | |||
1348 | ||||
1349 | static gboolean | |||
1350 | fstab_user_permission(Mount *m) | |||
1351 | { | |||
1352 | struct stat my_stat; | |||
1353 | ||||
1354 | stat(m->device, &my_stat); | |||
1355 | if ( strstr(m->options, "user") | |||
1356 | || (strstr(m->options, "owner") && my_stat.st_uid == uid) | |||
1357 | ) | |||
1358 | return TRUE(!(0)); | |||
1359 | return FALSE(0); | |||
1360 | } | |||
1361 | ||||
1362 | static gint | |||
1363 | fix_fstab_mountable_changed(FSmon *fs) | |||
1364 | { | |||
1365 | Mount *m; | |||
1366 | ||||
1367 | if (!mounting_supported) | |||
1368 | return FALSE(0); | |||
1369 | m = in_fstab_list(fs->mount.directory); | |||
1370 | if ( (!m || (!fstab_user_permission(m) && uid != 0)) | |||
1371 | && fs->fstab_mounting | |||
1372 | ) | |||
1373 | { | |||
1374 | fs->fstab_mounting = FALSE(0); | |||
1375 | return TRUE(!(0)); | |||
1376 | } | |||
1377 | return FALSE(0); | |||
1378 | } | |||
1379 | ||||
1380 | static FSmon * | |||
1381 | lookup_fs(gchar *name) | |||
1382 | { | |||
1383 | GList *list; | |||
1384 | FSmon *fs; | |||
1385 | ||||
1386 | if (!name) | |||
1387 | return NULL((void*)0); | |||
1388 | for (list = fs_mon_list; list; list = list->next) | |||
1389 | { | |||
1390 | fs = (FSmon *) list->data; | |||
1391 | if (!strcmp(fs->label, name)__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (fs->label) && __builtin_constant_p (name) && (__s1_len = strlen (fs->label), __s2_len = strlen (name), (!((size_t)(const void *)((fs->label) + 1) - (size_t)(const void *)(fs->label) == 1) || __s1_len >= 4) && ( !((size_t)(const void *)((name) + 1) - (size_t)(const void *) (name) == 1) || __s2_len >= 4)) ? __builtin_strcmp (fs-> label, name) : (__builtin_constant_p (fs->label) && ((size_t)(const void *)((fs->label) + 1) - (size_t)(const void *)(fs->label) == 1) && (__s1_len = strlen (fs ->label), __s1_len < 4) ? (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *) (name) == 1) ? __builtin_strcmp (fs->label, name) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (name); int __result = (((const unsigned char *) (const char *) (fs->label))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (fs->label))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (fs->label))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (fs->label))[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 (fs->label) && ((size_t)(const void *)((fs->label) + 1) - (size_t)(const void *)(fs->label) == 1) ? __builtin_strcmp (fs->label , name) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (fs->label); 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 (fs->label, name )))); })) | |||
1392 | return fs; | |||
1393 | } | |||
1394 | return NULL((void*)0); | |||
1395 | } | |||
1396 | ||||
1397 | static void | |||
1398 | fs_config_load(gchar *arg) | |||
1399 | { | |||
1400 | static FSmon *fs_prev; | |||
1401 | FSmon *fs; | |||
1402 | gchar *cut_label, *cut_dir; | |||
1403 | gchar config[32], item[CFG_BUFSIZE512]; | |||
1404 | gchar name[64], item1[CFG_BUFSIZE512]; | |||
1405 | gint n; | |||
1406 | ||||
1407 | if ((n = sscanf(arg, "%31s %[^\n]", config, item)) != 2) | |||
1408 | return; | |||
1409 | ||||
1410 | if (!strcmp(config, "fs_check_timeout")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (config) && __builtin_constant_p ("fs_check_timeout" ) && (__s1_len = strlen (config), __s2_len = strlen ( "fs_check_timeout"), (!((size_t)(const void *)((config) + 1) - (size_t)(const void *)(config) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("fs_check_timeout") + 1) - (size_t )(const void *)("fs_check_timeout") == 1) || __s2_len >= 4 )) ? __builtin_strcmp (config, "fs_check_timeout") : (__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 ("fs_check_timeout" ) && ((size_t)(const void *)(("fs_check_timeout") + 1 ) - (size_t)(const void *)("fs_check_timeout") == 1) ? __builtin_strcmp (config, "fs_check_timeout") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("fs_check_timeout" ); 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 ( "fs_check_timeout") && ((size_t)(const void *)(("fs_check_timeout" ) + 1) - (size_t)(const void *)("fs_check_timeout") == 1) && (__s2_len = strlen ("fs_check_timeout"), __s2_len < 4) ? ( __builtin_constant_p (config) && ((size_t)(const void *)((config) + 1) - (size_t)(const void *)(config) == 1) ? __builtin_strcmp (config, "fs_check_timeout") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (config) ; int __result = (((const unsigned char *) (const char *) ("fs_check_timeout" ))[0] - __s2[0]); if (__s2_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("fs_check_timeout" ))[1] - __s2[1]); if (__s2_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("fs_check_timeout" ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) ("fs_check_timeout" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (config , "fs_check_timeout")))); })) | |||
1411 | { | |||
1412 | sscanf(item, "%d", &fs_check_timeout); | |||
1413 | if (fs_check_timeout < 2) | |||
1414 | fs_check_timeout = 2; | |||
1415 | } | |||
1416 | else if (!strcmp(config, "nfs_check_timeout")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (config) && __builtin_constant_p ("nfs_check_timeout" ) && (__s1_len = strlen (config), __s2_len = strlen ( "nfs_check_timeout"), (!((size_t)(const void *)((config) + 1) - (size_t)(const void *)(config) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("nfs_check_timeout") + 1) - (size_t )(const void *)("nfs_check_timeout") == 1) || __s2_len >= 4 )) ? __builtin_strcmp (config, "nfs_check_timeout") : (__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 ("nfs_check_timeout" ) && ((size_t)(const void *)(("nfs_check_timeout") + 1 ) - (size_t)(const void *)("nfs_check_timeout") == 1) ? __builtin_strcmp (config, "nfs_check_timeout") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("nfs_check_timeout" ); 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 ( "nfs_check_timeout") && ((size_t)(const void *)(("nfs_check_timeout" ) + 1) - (size_t)(const void *)("nfs_check_timeout") == 1) && (__s2_len = strlen ("nfs_check_timeout"), __s2_len < 4) ? (__builtin_constant_p (config) && ((size_t)(const void *)((config) + 1) - (size_t)(const void *)(config) == 1) ? __builtin_strcmp (config, "nfs_check_timeout") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (config) ; int __result = (((const unsigned char *) (const char *) ("nfs_check_timeout" ))[0] - __s2[0]); if (__s2_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("nfs_check_timeout" ))[1] - __s2[1]); if (__s2_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("nfs_check_timeout" ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) ("nfs_check_timeout" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (config , "nfs_check_timeout")))); })) | |||
1417 | { | |||
1418 | sscanf(item, "%d", &nfs_check_timeout); | |||
1419 | if (nfs_check_timeout < 5) | |||
1420 | nfs_check_timeout = 5; | |||
1421 | } | |||
1422 | else if (!strcmp(config, "auto_eject")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (config) && __builtin_constant_p ("auto_eject") && (__s1_len = strlen (config), __s2_len = strlen ("auto_eject" ), (!((size_t)(const void *)((config) + 1) - (size_t)(const void *)(config) == 1) || __s1_len >= 4) && (!((size_t) (const void *)(("auto_eject") + 1) - (size_t)(const void *)("auto_eject" ) == 1) || __s2_len >= 4)) ? __builtin_strcmp (config, "auto_eject" ) : (__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 ("auto_eject") && ((size_t)(const void *)(("auto_eject") + 1) - (size_t)(const void *)("auto_eject" ) == 1) ? __builtin_strcmp (config, "auto_eject") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("auto_eject"); 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 ("auto_eject") && ((size_t) (const void *)(("auto_eject") + 1) - (size_t)(const void *)("auto_eject" ) == 1) && (__s2_len = strlen ("auto_eject"), __s2_len < 4) ? (__builtin_constant_p (config) && ((size_t )(const void *)((config) + 1) - (size_t)(const void *)(config ) == 1) ? __builtin_strcmp (config, "auto_eject") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (config); int __result = (((const unsigned char *) ( const char *) ("auto_eject"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("auto_eject"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("auto_eject"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("auto_eject"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (config, "auto_eject")))); })) | |||
1423 | sscanf(item, "%d", &cdrom_auto_eject); | |||
1424 | else if (!strcmp(config, "binary_units")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (config) && __builtin_constant_p ("binary_units") && (__s1_len = strlen (config), __s2_len = strlen ("binary_units" ), (!((size_t)(const void *)((config) + 1) - (size_t)(const void *)(config) == 1) || __s1_len >= 4) && (!((size_t) (const void *)(("binary_units") + 1) - (size_t)(const void *) ("binary_units") == 1) || __s2_len >= 4)) ? __builtin_strcmp (config, "binary_units") : (__builtin_constant_p (config) && ((size_t)(const void *)((config) + 1) - (size_t)(const void * )(config) == 1) && (__s1_len = strlen (config), __s1_len < 4) ? (__builtin_constant_p ("binary_units") && ( (size_t)(const void *)(("binary_units") + 1) - (size_t)(const void *)("binary_units") == 1) ? __builtin_strcmp (config, "binary_units" ) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("binary_units"); int __result = (((const unsigned char *) (const char *) (config))[0] - __s2[0]); if ( __s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (config))[1] - __s2[1]); if ( __s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (config))[2] - __s2[2]); if ( __s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (config))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("binary_units") && ((size_t)(const void *)(("binary_units") + 1) - (size_t)(const void *)("binary_units") == 1) && (__s2_len = strlen ( "binary_units"), __s2_len < 4) ? (__builtin_constant_p (config ) && ((size_t)(const void *)((config) + 1) - (size_t) (const void *)(config) == 1) ? __builtin_strcmp (config, "binary_units" ) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (config); int __result = (((const unsigned char *) (const char *) ("binary_units"))[0] - __s2[0]); if ( __s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("binary_units"))[1] - __s2[ 1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("binary_units")) [2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("binary_units" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (config , "binary_units")))); })) | |||
1425 | sscanf(item, "%d", &binary_units); | |||
1426 | else if (!strcmp(config, "data_format")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (config) && __builtin_constant_p ("data_format") && (__s1_len = strlen (config), __s2_len = strlen ("data_format" ), (!((size_t)(const void *)((config) + 1) - (size_t)(const void *)(config) == 1) || __s1_len >= 4) && (!((size_t) (const void *)(("data_format") + 1) - (size_t)(const void *)( "data_format") == 1) || __s2_len >= 4)) ? __builtin_strcmp (config, "data_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 ("data_format") && ( (size_t)(const void *)(("data_format") + 1) - (size_t)(const void *)("data_format") == 1) ? __builtin_strcmp (config, "data_format" ) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("data_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 ("data_format") && ((size_t)(const void *)(("data_format") + 1) - (size_t)(const void *)("data_format") == 1) && (__s2_len = strlen ( "data_format"), __s2_len < 4) ? (__builtin_constant_p (config ) && ((size_t)(const void *)((config) + 1) - (size_t) (const void *)(config) == 1) ? __builtin_strcmp (config, "data_format" ) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (config); int __result = (((const unsigned char *) (const char *) ("data_format"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("data_format"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("data_format"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("data_format"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (config, "data_format")))); })) | |||
1427 | gkrellm_locale_dup_string(&data_format, item, &data_format_locale); | |||
1428 | else if (fs_prev && !strcmp(config, "mount_command")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (config) && __builtin_constant_p ("mount_command") && (__s1_len = strlen (config), __s2_len = strlen ("mount_command" ), (!((size_t)(const void *)((config) + 1) - (size_t)(const void *)(config) == 1) || __s1_len >= 4) && (!((size_t) (const void *)(("mount_command") + 1) - (size_t)(const void * )("mount_command") == 1) || __s2_len >= 4)) ? __builtin_strcmp (config, "mount_command") : (__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 ("mount_command") && ((size_t)(const void *)(("mount_command") + 1) - (size_t)(const void *)("mount_command") == 1) ? __builtin_strcmp (config, "mount_command" ) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("mount_command"); 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 ("mount_command" ) && ((size_t)(const void *)(("mount_command") + 1) - (size_t)(const void *)("mount_command") == 1) && (__s2_len = strlen ("mount_command"), __s2_len < 4) ? (__builtin_constant_p (config) && ((size_t)(const void *)((config) + 1) - ( size_t)(const void *)(config) == 1) ? __builtin_strcmp (config , "mount_command") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (config); int __result = (((const unsigned char *) (const char *) ("mount_command" ))[0] - __s2[0]); if (__s2_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("mount_command" ))[1] - __s2[1]); if (__s2_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("mount_command" ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) ("mount_command" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (config , "mount_command")))); })) | |||
1429 | gkrellm_dup_string(&fs_prev->launch_mount.command, item); | |||
1430 | else if (fs_prev && !strcmp(config, "umount_command")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (config) && __builtin_constant_p ("umount_command") && (__s1_len = strlen (config), __s2_len = strlen ("umount_command" ), (!((size_t)(const void *)((config) + 1) - (size_t)(const void *)(config) == 1) || __s1_len >= 4) && (!((size_t) (const void *)(("umount_command") + 1) - (size_t)(const void * )("umount_command") == 1) || __s2_len >= 4)) ? __builtin_strcmp (config, "umount_command") : (__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 ("umount_command") && ((size_t)(const void *)(("umount_command") + 1) - (size_t)(const void *)("umount_command") == 1) ? __builtin_strcmp (config, "umount_command" ) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("umount_command"); 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 ("umount_command" ) && ((size_t)(const void *)(("umount_command") + 1) - (size_t)(const void *)("umount_command") == 1) && (__s2_len = strlen ("umount_command"), __s2_len < 4) ? (__builtin_constant_p (config) && ((size_t)(const void *)((config) + 1) - ( size_t)(const void *)(config) == 1) ? __builtin_strcmp (config , "umount_command") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (config); int __result = (((const unsigned char *) (const char *) ("umount_command" ))[0] - __s2[0]); if (__s2_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("umount_command" ))[1] - __s2[1]); if (__s2_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("umount_command" ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) ("umount_command" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (config , "umount_command")))); })) | |||
1431 | gkrellm_dup_string(&fs_prev->launch_umount.command, item); | |||
1432 | else if (fs_prev && !strcmp(config, "eject_device")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (config) && __builtin_constant_p ("eject_device") && (__s1_len = strlen (config), __s2_len = strlen ("eject_device" ), (!((size_t)(const void *)((config) + 1) - (size_t)(const void *)(config) == 1) || __s1_len >= 4) && (!((size_t) (const void *)(("eject_device") + 1) - (size_t)(const void *) ("eject_device") == 1) || __s2_len >= 4)) ? __builtin_strcmp (config, "eject_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 ("eject_device") && ( (size_t)(const void *)(("eject_device") + 1) - (size_t)(const void *)("eject_device") == 1) ? __builtin_strcmp (config, "eject_device" ) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("eject_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 ("eject_device") && ((size_t)(const void *)(("eject_device") + 1) - (size_t)(const void *)("eject_device") == 1) && (__s2_len = strlen ( "eject_device"), __s2_len < 4) ? (__builtin_constant_p (config ) && ((size_t)(const void *)((config) + 1) - (size_t) (const void *)(config) == 1) ? __builtin_strcmp (config, "eject_device" ) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (config); int __result = (((const unsigned char *) (const char *) ("eject_device"))[0] - __s2[0]); if ( __s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("eject_device"))[1] - __s2[ 1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("eject_device")) [2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("eject_device" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (config , "eject_device")))); })) | |||
1433 | { | |||
1434 | if (fs_prev->ejectable) | |||
1435 | gkrellm_dup_string(&fs_prev->eject_device, item); | |||
1436 | } | |||
1437 | 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")))); })) | |||
1438 | { | |||
1439 | if ( sscanf(item, "\"%63[^\"]\" %[^\n]", name, item1) == 2 | |||
1440 | && (fs = lookup_fs(name)) != NULL((void*)0) | |||
1441 | ) | |||
1442 | { | |||
1443 | if (!fs->alert) | |||
1444 | create_alert(fs); | |||
1445 | gkrellm_load_alertconfig(&fs->alert, item1); | |||
1446 | } | |||
1447 | } | |||
1448 | else | |||
1449 | { | |||
1450 | if ( (cut_label = gkrellm_cut_quoted_string(arg, &arg)) != NULL((void*)0) | |||
1451 | && (cut_dir = gkrellm_cut_quoted_string(arg, &arg)) != NULL((void*)0) | |||
1452 | ) | |||
1453 | { | |||
1454 | fs = g_new0(FSmon, 1)(FSmon *) (__extension__ ({ gsize __n = (gsize) (1); gsize __s = sizeof (FSmon); 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 ; })); | |||
1455 | gkrellm_locale_dup_string(&fs->label, cut_label,&fs->label_shadow); | |||
1456 | ||||
1457 | sscanf(arg, "%d %d %d %d %d", &fs->fstab_mounting, | |||
1458 | &fs->secondary, &fs->show_if_mounted, | |||
1459 | &fs->label_is_data, &fs->ejectable); | |||
1460 | if (fs->fstab_mounting > 1) /* pre 2.0.0 config fix */ | |||
1461 | fs->fstab_mounting = FALSE(0); | |||
1462 | if (!ejecting_supported) | |||
1463 | fs->ejectable = FALSE(0); | |||
1464 | if (!mounting_supported) | |||
1465 | fs->fstab_mounting = fs->show_if_mounted = FALSE(0); | |||
1466 | if (fs->secondary) | |||
1467 | have_secondary_panels = TRUE(!(0)); | |||
1468 | fs->mount.directory = g_strdup(cut_dir); | |||
1469 | fs->restore_label = fs->label_is_data; | |||
1470 | ||||
1471 | fix_fstab_mountable_changed(fs); | |||
1472 | fs->krell_factor = 1; | |||
1473 | fs->launch_mount.command = g_strdup(""); | |||
1474 | fs->launch_umount.command = g_strdup(""); | |||
1475 | fs->eject_device = g_strdup(""); | |||
1476 | fs_mon_list = g_list_append(fs_mon_list, fs); | |||
1477 | fs_prev = fs; /* XXX */ | |||
1478 | } | |||
1479 | } | |||
1480 | } | |||
1481 | ||||
1482 | ||||
1483 | /* --------------------------------------------------------------------- */ | |||
1484 | ||||
1485 | enum | |||
1486 | { | |||
1487 | NAME_COLUMN, | |||
1488 | MOUNT_POINT_COLUMN, | |||
1489 | SHOW_COLUMN, | |||
1490 | FSTAB_COLUMN, | |||
1491 | MOUNT_COMMAND_COLUMN, | |||
1492 | UMOUNT_COMMAND_COLUMN, | |||
1493 | EJECTABLE_COLUMN, | |||
1494 | DEVICE_COLUMN, | |||
1495 | FSMON_COLUMN, | |||
1496 | ALERT_COLUMN, | |||
1497 | SHOW_DATA_COLUMN, | |||
1498 | VISIBLE_COLUMN, | |||
1499 | IMAGE_COLUMN, | |||
1500 | N_COLUMNS | |||
1501 | }; | |||
1502 | ||||
1503 | static GtkTreeView *treeview; | |||
1504 | static GtkTreeRowReference *row_reference; | |||
1505 | static GtkTreeSelection *selection; | |||
1506 | ||||
1507 | static GtkWidget | |||
1508 | *label_entry, | |||
1509 | *dir_combo_box, | |||
1510 | *mount_entry, | |||
1511 | *umount_entry, | |||
1512 | *mounting_button, | |||
1513 | *ejectable_button, | |||
1514 | *device_entry, | |||
1515 | *secondary_button, | |||
1516 | *show_button, | |||
1517 | *delete_button, | |||
1518 | *new_apply_button; | |||
1519 | ||||
1520 | static GtkWidget *alert_button; | |||
1521 | ||||
1522 | static GtkWidget *data_format_combo_box; | |||
1523 | ||||
1524 | static gboolean (*original_row_drop_possible)(); | |||
1525 | ||||
1526 | ||||
1527 | static void | |||
1528 | set_tree_store_model_data(GtkTreeStore *tree, GtkTreeIter *iter, FSmon *fs) | |||
1529 | { | |||
1530 | gtk_tree_store_set(tree, iter, | |||
1531 | NAME_COLUMN, fs->label, | |||
1532 | MOUNT_POINT_COLUMN, fs->mount.directory, | |||
1533 | SHOW_COLUMN, fs->show_if_mounted, | |||
1534 | FSTAB_COLUMN, fs->fstab_mounting, | |||
1535 | MOUNT_COMMAND_COLUMN, fs->launch_mount.command, | |||
1536 | UMOUNT_COMMAND_COLUMN, fs->launch_umount.command, | |||
1537 | EJECTABLE_COLUMN, fs->ejectable, | |||
1538 | DEVICE_COLUMN, fs->eject_device, | |||
1539 | FSMON_COLUMN, fs, | |||
1540 | ALERT_COLUMN, fs->alert, | |||
1541 | SHOW_DATA_COLUMN, fs->label_is_data, | |||
1542 | VISIBLE_COLUMN, TRUE(!(0)), | |||
1543 | -1); | |||
1544 | if (fs->alert) | |||
1545 | gtk_tree_store_set(tree, iter, | |||
1546 | IMAGE_COLUMN, gkrellm_alert_pixbuf(), | |||
1547 | -1); | |||
1548 | } | |||
1549 | ||||
1550 | static GtkTreeModel * | |||
1551 | create_model(void) | |||
1552 | { | |||
1553 | GtkTreeStore *tree; | |||
1554 | GtkTreeIter iter, citer; | |||
1555 | GList *list; | |||
1556 | FSmon *fs; | |||
1557 | ||||
1558 | tree = gtk_tree_store_new(N_COLUMNS, | |||
1559 | G_TYPE_STRING((GType) ((16) << (2))), G_TYPE_STRING((GType) ((16) << (2))), | |||
1560 | G_TYPE_BOOLEAN((GType) ((5) << (2))), G_TYPE_BOOLEAN((GType) ((5) << (2))), | |||
1561 | G_TYPE_STRING((GType) ((16) << (2))), G_TYPE_STRING((GType) ((16) << (2))), | |||
1562 | G_TYPE_BOOLEAN((GType) ((5) << (2))), G_TYPE_STRING((GType) ((16) << (2))), | |||
1563 | G_TYPE_POINTER((GType) ((17) << (2))), G_TYPE_POINTER((GType) ((17) << (2))), | |||
1564 | G_TYPE_BOOLEAN((GType) ((5) << (2))), | |||
1565 | G_TYPE_BOOLEAN((GType) ((5) << (2))), GDK_TYPE_PIXBUF(gdk_pixbuf_get_type ())); | |||
1566 | ||||
1567 | gtk_tree_store_append(tree, &iter, NULL((void*)0)); | |||
1568 | gtk_tree_store_set(tree, &iter, | |||
1569 | NAME_COLUMN, _("Primary")dcgettext ("gkrellm", "Primary", 5), | |||
1570 | VISIBLE_COLUMN, FALSE(0), | |||
1571 | -1); | |||
1572 | for (list = fs_mon_list; list; list = list->next) | |||
1573 | { | |||
1574 | fs = (FSmon *) list->data; | |||
1575 | if (fs->secondary) | |||
1576 | continue; | |||
1577 | gtk_tree_store_append(tree, &citer, &iter); | |||
1578 | set_tree_store_model_data(tree, &citer, fs); | |||
1579 | } | |||
1580 | ||||
1581 | gtk_tree_store_append(tree, &iter, NULL((void*)0)); | |||
1582 | gtk_tree_store_set(tree, &iter, | |||
1583 | NAME_COLUMN, _("Secondary")dcgettext ("gkrellm", "Secondary", 5), | |||
1584 | VISIBLE_COLUMN, FALSE(0), | |||
1585 | -1); | |||
1586 | for (list = fs_mon_list; list; list = list->next) | |||
1587 | { | |||
1588 | fs = (FSmon *) list->data; | |||
1589 | if (!fs->secondary) | |||
1590 | continue; | |||
1591 | gtk_tree_store_append(tree, &citer, &iter); | |||
1592 | set_tree_store_model_data(tree, &citer, fs); | |||
1593 | } | |||
1594 | return GTK_TREE_MODEL(tree)((((GtkTreeModel*) g_type_check_instance_cast ((GTypeInstance *) ((tree)), ((gtk_tree_model_get_type ())))))); | |||
1595 | } | |||
1596 | ||||
1597 | static void | |||
1598 | change_row_reference(GtkTreeModel *model, GtkTreePath *path) | |||
1599 | { | |||
1600 | gtk_tree_row_reference_free(row_reference); | |||
1601 | if (model && path) | |||
1602 | row_reference = gtk_tree_row_reference_new(model, path); | |||
1603 | else | |||
1604 | row_reference = NULL((void*)0); | |||
1605 | } | |||
1606 | ||||
1607 | static void | |||
1608 | cb_set_alert(GtkWidget *button, gpointer data) | |||
1609 | { | |||
1610 | GtkTreeModel *model; | |||
1611 | GtkTreePath *path; | |||
1612 | GtkTreeIter iter; | |||
1613 | FSmon *fs; | |||
1614 | ||||
1615 | if (!row_reference) | |||
1616 | return; | |||
1617 | model = gtk_tree_view_get_model(treeview); | |||
1618 | path = gtk_tree_row_reference_get_path(row_reference); | |||
1619 | gtk_tree_model_get_iter(model, &iter, path); | |||
1620 | gtk_tree_model_get(model, &iter, FSMON_COLUMN, &fs, -1); | |||
1621 | ||||
1622 | if (!fs->alert) | |||
1623 | create_alert(fs); | |||
1624 | gkrellm_alert_config_window(&fs->alert); | |||
1625 | gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) g_type_check_instance_cast ((GTypeInstance *) ((model)), ((gtk_tree_store_get_type ())))))), &iter, | |||
1626 | ALERT_COLUMN, fs->alert, -1); | |||
1627 | } | |||
1628 | ||||
1629 | static gboolean | |||
1630 | get_child_iter(GtkTreeModel *model, gchar *parent_node, GtkTreeIter *citer) | |||
1631 | { | |||
1632 | GtkTreePath *path; | |||
1633 | GtkTreeIter iter; | |||
1634 | ||||
1635 | path = gtk_tree_path_new_from_string(parent_node); | |||
1636 | gtk_tree_model_get_iter(model, &iter, path); | |||
1637 | gtk_tree_path_free(path); | |||
1638 | return gtk_tree_model_iter_children(model, citer, &iter); | |||
1639 | } | |||
1640 | ||||
1641 | /* Callback for a created or destroyed alert. Find the sensor in the model | |||
1642 | | and set the IMAGE_COLUMN. | |||
1643 | */ | |||
1644 | static void | |||
1645 | cb_alert_config(GkrellmAlert *ap, FSmon *fs) | |||
1646 | { | |||
1647 | GtkTreeModel *model; | |||
1648 | GtkTreeIter iter; | |||
1649 | FSmon *fs_test; | |||
1650 | GdkPixbuf *pixbuf; | |||
1651 | gchar node[2]; | |||
1652 | gint i; | |||
1653 | ||||
1654 | if (!gkrellm_config_window_shown()) | |||
1655 | return; | |||
1656 | model = gtk_tree_view_get_model(treeview); | |||
1657 | pixbuf = ap->activated ? gkrellm_alert_pixbuf() : NULL((void*)0); | |||
1658 | for (i = 0; i < 2; ++i) | |||
1659 | { | |||
1660 | node[0] = '0' + i; /* toplevel Primary or Secondary node */ | |||
1661 | node[1] = '\0'; | |||
1662 | if (get_child_iter(model, node, &iter)) | |||
1663 | do | |||
1664 | { | |||
1665 | gtk_tree_model_get(model, &iter, FSMON_COLUMN, &fs_test, -1); | |||
1666 | if (fs != fs_test) | |||
1667 | continue; | |||
1668 | gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) g_type_check_instance_cast ((GTypeInstance *) ((model)), ((gtk_tree_store_get_type ())))))), &iter, | |||
1669 | IMAGE_COLUMN, pixbuf, -1); | |||
1670 | return; | |||
1671 | } | |||
1672 | while (gtk_tree_model_iter_next(model, &iter)); | |||
1673 | } | |||
1674 | } | |||
1675 | ||||
1676 | /* Watch what is going into the directory combo entry, compare it to | |||
1677 | | fstab entries and accordingly set sensitivity of the mounting_button. | |||
1678 | */ | |||
1679 | static void | |||
1680 | cb_combo_changed(GtkComboBox *widget, gpointer user_data) | |||
1681 | { | |||
1682 | Mount *m; | |||
1683 | gchar *s; | |||
1684 | GtkWidget *entry; | |||
1685 | ||||
1686 | if (!mounting_supported || _GK.client_mode) | |||
1687 | return; | |||
1688 | ||||
1689 | entry = gtk_bin_get_child(GTK_BIN(dir_combo_box)((((GtkBin*) g_type_check_instance_cast ((GTypeInstance*) ((dir_combo_box )), ((gtk_bin_get_type ()))))))); | |||
1690 | s = gkrellm_gtk_entry_get_text(&entry); | |||
1691 | m = in_fstab_list(s); | |||
1692 | if (m && (fstab_user_permission(m) || uid == 0)) | |||
1693 | { | |||
1694 | gtk_widget_set_sensitive(mounting_button, TRUE(!(0))); | |||
1695 | if (GTK_TOGGLE_BUTTON(mounting_button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance *) ((mounting_button)), ((gtk_toggle_button_get_type ()))))))->active) | |||
1696 | { | |||
1697 | gtk_entry_set_text(GTK_ENTRY(mount_entry)((((GtkEntry*) g_type_check_instance_cast ((GTypeInstance*) ( (mount_entry)), ((gtk_entry_get_type ())))))), ""); | |||
1698 | gtk_entry_set_text(GTK_ENTRY(umount_entry)((((GtkEntry*) g_type_check_instance_cast ((GTypeInstance*) ( (umount_entry)), ((gtk_entry_get_type ())))))), ""); | |||
1699 | gtk_widget_set_sensitive(mount_entry, FALSE(0)); | |||
1700 | gtk_widget_set_sensitive(umount_entry, FALSE(0)); | |||
1701 | } | |||
1702 | } | |||
1703 | else | |||
1704 | { | |||
1705 | if (GTK_TOGGLE_BUTTON(mounting_button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance *) ((mounting_button)), ((gtk_toggle_button_get_type ()))))))->active) | |||
1706 | gtk_toggle_button_set_active( | |||
1707 | GTK_TOGGLE_BUTTON(mounting_button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance *) ((mounting_button)), ((gtk_toggle_button_get_type ())))))), FALSE(0)); | |||
1708 | else | |||
1709 | { | |||
1710 | gtk_widget_set_sensitive(mount_entry, TRUE(!(0))); | |||
1711 | gtk_widget_set_sensitive(umount_entry, TRUE(!(0))); | |||
1712 | } | |||
1713 | gtk_widget_set_sensitive(mounting_button, FALSE(0)); | |||
1714 | } | |||
1715 | } | |||
1716 | ||||
1717 | static void | |||
1718 | cb_mount_button_clicked(GtkWidget *widget) | |||
1719 | { | |||
1720 | if (!mounting_supported || _GK.client_mode) | |||
1721 | return; | |||
1722 | if (GTK_TOGGLE_BUTTON(mounting_button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance *) ((mounting_button)), ((gtk_toggle_button_get_type ()))))))->active) | |||
1723 | { | |||
1724 | gtk_entry_set_text(GTK_ENTRY(mount_entry)((((GtkEntry*) g_type_check_instance_cast ((GTypeInstance*) ( (mount_entry)), ((gtk_entry_get_type ())))))), ""); | |||
1725 | gtk_entry_set_text(GTK_ENTRY(umount_entry)((((GtkEntry*) g_type_check_instance_cast ((GTypeInstance*) ( (umount_entry)), ((gtk_entry_get_type ())))))), ""); | |||
1726 | gtk_widget_set_sensitive(mount_entry, FALSE(0)); | |||
1727 | gtk_widget_set_sensitive(umount_entry, FALSE(0)); | |||
1728 | if (device_entry) | |||
1729 | { | |||
1730 | gtk_entry_set_text(GTK_ENTRY(device_entry)((((GtkEntry*) g_type_check_instance_cast ((GTypeInstance*) ( (device_entry)), ((gtk_entry_get_type ())))))), ""); | |||
1731 | gtk_widget_set_sensitive(device_entry, FALSE(0)); | |||
1732 | } | |||
1733 | } | |||
1734 | else | |||
1735 | { | |||
1736 | gtk_widget_set_sensitive(mount_entry, TRUE(!(0))); | |||
1737 | gtk_widget_set_sensitive(umount_entry, TRUE(!(0))); | |||
1738 | if ( ejectable_button | |||
1739 | && GTK_TOGGLE_BUTTON(ejectable_button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance *) ((ejectable_button)), ((gtk_toggle_button_get_type ()))))) )->active | |||
1740 | ) | |||
1741 | gtk_widget_set_sensitive(device_entry, TRUE(!(0))); | |||
1742 | } | |||
1743 | } | |||
1744 | ||||
1745 | static void | |||
1746 | cb_ejectable_button_clicked(GtkWidget *widget) | |||
1747 | { | |||
1748 | gboolean fstab_mounting; | |||
1749 | ||||
1750 | if (!mounting_supported || _GK.client_mode) | |||
1751 | return; | |||
1752 | fstab_mounting = GTK_TOGGLE_BUTTON(mounting_button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance *) ((mounting_button)), ((gtk_toggle_button_get_type ()))))))->active; | |||
1753 | if (GTK_TOGGLE_BUTTON(ejectable_button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance *) ((ejectable_button)), ((gtk_toggle_button_get_type ()))))) )->active) | |||
1754 | { | |||
1755 | gtk_widget_set_sensitive(device_entry, !fstab_mounting); | |||
1756 | } | |||
1757 | else | |||
1758 | { | |||
1759 | gtk_entry_set_text(GTK_ENTRY(device_entry)((((GtkEntry*) g_type_check_instance_cast ((GTypeInstance*) ( (device_entry)), ((gtk_entry_get_type ())))))), ""); | |||
1760 | gtk_widget_set_sensitive(device_entry, FALSE(0)); | |||
1761 | } | |||
1762 | } | |||
1763 | ||||
1764 | static void | |||
1765 | cb_secondary_button_clicked(GtkWidget *widget) | |||
1766 | { | |||
1767 | if (!mounting_supported) /* Show button is in client mode */ | |||
1768 | return; | |||
1769 | if (GTK_TOGGLE_BUTTON(secondary_button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance *) ((secondary_button)), ((gtk_toggle_button_get_type ()))))) )->active) | |||
1770 | gtk_widget_set_sensitive(show_button, TRUE(!(0))); | |||
1771 | else | |||
1772 | { | |||
1773 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(show_button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance *) ((show_button)), ((gtk_toggle_button_get_type ())))))), FALSE(0)); | |||
1774 | gtk_widget_set_sensitive(show_button, FALSE(0)); | |||
1775 | } | |||
1776 | } | |||
1777 | ||||
1778 | static void | |||
1779 | reset_entries(gboolean level0) | |||
1780 | { | |||
1781 | gtk_entry_set_text(GTK_ENTRY(label_entry)((((GtkEntry*) g_type_check_instance_cast ((GTypeInstance*) ( (label_entry)), ((gtk_entry_get_type ())))))), ""); | |||
1782 | gtk_combo_box_set_active(GTK_COMBO_BOX(dir_combo_box)((((GtkComboBox*) g_type_check_instance_cast ((GTypeInstance* ) ((dir_combo_box)), ((gtk_combo_box_get_type ())))))), -1); | |||
1783 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(secondary_button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance *) ((secondary_button)), ((gtk_toggle_button_get_type ()))))) ), level0); | |||
1784 | if (mounting_button) | |||
1785 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mounting_button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance *) ((mounting_button)), ((gtk_toggle_button_get_type ())))))),FALSE(0)); | |||
1786 | if (show_button) | |||
1787 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(show_button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance *) ((show_button)), ((gtk_toggle_button_get_type ())))))), FALSE(0)); | |||
1788 | if (ejectable_button) | |||
1789 | { | |||
1790 | gtk_toggle_button_set_active( | |||
1791 | GTK_TOGGLE_BUTTON(ejectable_button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance *) ((ejectable_button)), ((gtk_toggle_button_get_type ()))))) ), FALSE(0)); | |||
1792 | if (device_entry) | |||
1793 | gtk_entry_set_text(GTK_ENTRY(device_entry)((((GtkEntry*) g_type_check_instance_cast ((GTypeInstance*) ( (device_entry)), ((gtk_entry_get_type ())))))), ""); | |||
1794 | } | |||
1795 | if (mount_entry) | |||
1796 | { | |||
1797 | gtk_entry_set_text(GTK_ENTRY(mount_entry)((((GtkEntry*) g_type_check_instance_cast ((GTypeInstance*) ( (mount_entry)), ((gtk_entry_get_type ())))))), ""); | |||
1798 | gtk_entry_set_text(GTK_ENTRY(umount_entry)((((GtkEntry*) g_type_check_instance_cast ((GTypeInstance*) ( (umount_entry)), ((gtk_entry_get_type ())))))), ""); | |||
1799 | } | |||
1800 | change_row_reference(NULL((void*)0), NULL((void*)0)); | |||
1801 | gtk_tree_selection_unselect_all(selection); | |||
1802 | } | |||
1803 | ||||
1804 | static FSmon * | |||
1805 | fs_new_from_model(GtkTreeModel *model, GtkTreeIter *iter) | |||
1806 | { | |||
1807 | FSmon *fs; | |||
1808 | gchar *label; | |||
1809 | ||||
1810 | fs = g_new0(FSmon, 1)(FSmon *) (__extension__ ({ gsize __n = (gsize) (1); gsize __s = sizeof (FSmon); 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 ; })); | |||
1811 | gtk_tree_model_get(model, iter, | |||
1812 | NAME_COLUMN, &label, | |||
1813 | MOUNT_POINT_COLUMN, &fs->mount.directory, | |||
1814 | SHOW_COLUMN, &fs->show_if_mounted, | |||
1815 | FSTAB_COLUMN, &fs->fstab_mounting, | |||
1816 | MOUNT_COMMAND_COLUMN, &fs->launch_mount.command, | |||
1817 | UMOUNT_COMMAND_COLUMN, &fs->launch_umount.command, | |||
1818 | EJECTABLE_COLUMN, &fs->ejectable, | |||
1819 | DEVICE_COLUMN, &fs->eject_device, | |||
1820 | ALERT_COLUMN, &fs->alert, | |||
1821 | SHOW_DATA_COLUMN, &fs->label_is_data, | |||
1822 | -1); | |||
1823 | gkrellm_locale_dup_string(&fs->label, label, &fs->label_shadow); | |||
1824 | g_free(label); | |||
1825 | return fs; | |||
1826 | } | |||
1827 | ||||
1828 | static void | |||
1829 | cb_tree_selection_changed(GtkTreeSelection *selection, gpointer data) | |||
1830 | { | |||
1831 | GtkTreeIter iter; | |||
1832 | GtkTreeModel *model; | |||
1833 | GtkTreePath *path; | |||
1834 | FSmon *fs; | |||
1835 | gint *indices, depth, secondary; | |||
1836 | ||||
1837 | if (!gtk_tree_selection_get_selected(selection, &model, &iter)) | |||
1838 | { | |||
1839 | reset_entries(FALSE(0)); | |||
1840 | gtk_button_set_label(GTK_BUTTON(new_apply_button)((((GtkButton*) g_type_check_instance_cast ((GTypeInstance*) ( (new_apply_button)), ((gtk_button_get_type ())))))), GTK_STOCK_NEW"gtk-new"); | |||
1841 | gtk_widget_set_sensitive(delete_button, FALSE(0)); | |||
1842 | gtk_widget_set_sensitive(alert_button, FALSE(0)); | |||
1843 | return; | |||
1844 | } | |||
1845 | path = gtk_tree_model_get_path(model, &iter); | |||
1846 | indices = gtk_tree_path_get_indices(path); | |||
1847 | secondary = indices[0]; | |||
1848 | depth = gtk_tree_path_get_depth(path); | |||
1849 | // g_debug("selection: indices=[%d,%d]:%d, path=%s\n", | |||
1850 | // indices[0], indices[1], gtk_tree_path_get_depth(path), | |||
1851 | // gtk_tree_path_to_string(path)); | |||
1852 | change_row_reference(model, path); | |||
1853 | gtk_tree_path_free(path); | |||
1854 | ||||
1855 | if (depth == 1) | |||
1856 | { | |||
1857 | reset_entries(secondary); | |||
1858 | gtk_button_set_label(GTK_BUTTON(new_apply_button)((((GtkButton*) g_type_check_instance_cast ((GTypeInstance*) ( (new_apply_button)), ((gtk_button_get_type ())))))), GTK_STOCK_NEW"gtk-new"); | |||
1859 | gtk_widget_set_sensitive(delete_button, FALSE(0)); | |||
1860 | gtk_widget_set_sensitive(alert_button, FALSE(0)); | |||
1861 | return; | |||
1862 | } | |||
1863 | gtk_button_set_label(GTK_BUTTON(new_apply_button)((((GtkButton*) g_type_check_instance_cast ((GTypeInstance*) ( (new_apply_button)), ((gtk_button_get_type ())))))), GTK_STOCK_APPLY"gtk-apply"); | |||
1864 | gtk_widget_set_sensitive(delete_button, TRUE(!(0))); | |||
1865 | gtk_widget_set_sensitive(alert_button, TRUE(!(0))); | |||
1866 | ||||
1867 | fs = fs_new_from_model(model, &iter); | |||
1868 | if (!secondary) | |||
1869 | fs->show_if_mounted = FALSE(0); /* in case dragged secondary->primary*/ | |||
1870 | ||||
1871 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(secondary_button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance *) ((secondary_button)), ((gtk_toggle_button_get_type ()))))) ), | |||
1872 | secondary); | |||
1873 | gtk_entry_set_text(GTK_ENTRY(label_entry)((((GtkEntry*) g_type_check_instance_cast ((GTypeInstance*) ( (label_entry)), ((gtk_entry_get_type ())))))), fs->label); | |||
1874 | gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(dir_combo_box)))((((GtkEntry*) g_type_check_instance_cast ((GTypeInstance*) ( (gtk_bin_get_child(((((GtkBin*) g_type_check_instance_cast (( GTypeInstance*) ((dir_combo_box)), ((gtk_bin_get_type ()))))) )))), ((gtk_entry_get_type ())))))), | |||
1875 | fs->mount.directory); | |||
1876 | if (show_button) | |||
1877 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(show_button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance *) ((show_button)), ((gtk_toggle_button_get_type ())))))), | |||
1878 | fs->show_if_mounted); | |||
1879 | if (mounting_button) | |||
1880 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mounting_button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance *) ((mounting_button)), ((gtk_toggle_button_get_type ())))))), | |||
1881 | fs->fstab_mounting); | |||
1882 | if (ejectable_button) | |||
1883 | { | |||
1884 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ejectable_button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance *) ((ejectable_button)), ((gtk_toggle_button_get_type ()))))) ), | |||
1885 | fs->ejectable); | |||
1886 | if (device_entry) | |||
1887 | { | |||
1888 | gtk_entry_set_text(GTK_ENTRY(device_entry)((((GtkEntry*) g_type_check_instance_cast ((GTypeInstance*) ( (device_entry)), ((gtk_entry_get_type ())))))), fs->eject_device); | |||
1889 | if (!fs->ejectable) | |||
1890 | gtk_widget_set_sensitive(device_entry, FALSE(0)); | |||
1891 | } | |||
1892 | } | |||
1893 | if (mount_entry) | |||
1894 | { | |||
1895 | gtk_entry_set_text(GTK_ENTRY(mount_entry)((((GtkEntry*) g_type_check_instance_cast ((GTypeInstance*) ( (mount_entry)), ((gtk_entry_get_type ())))))), fs->launch_mount.command); | |||
1896 | gtk_entry_set_text(GTK_ENTRY(umount_entry)((((GtkEntry*) g_type_check_instance_cast ((GTypeInstance*) ( (umount_entry)), ((gtk_entry_get_type ())))))), fs->launch_umount.command); | |||
1897 | } | |||
1898 | free_fsmon_strings(fs); | |||
1899 | g_free(fs); | |||
1900 | } | |||
1901 | ||||
1902 | static void | |||
1903 | sync_fs_panels(void) | |||
1904 | { | |||
1905 | GtkTreeModel *model; | |||
1906 | GtkTreePath *path; | |||
1907 | GtkTreeIter iter0, iter1, iter; | |||
1908 | GList *list; | |||
1909 | FSmon *fs; | |||
1910 | ||||
1911 | model = gtk_tree_view_get_model(treeview); | |||
1912 | ||||
1913 | path = gtk_tree_path_new_from_string("0"); | |||
1914 | gtk_tree_model_get_iter(model, &iter0, path); | |||
1915 | gtk_tree_path_free(path); | |||
1916 | ||||
1917 | path = gtk_tree_path_new_from_string("1"); | |||
1918 | gtk_tree_model_get_iter(model, &iter1, path); | |||
1919 | gtk_tree_path_free(path); | |||
1920 | ||||
1921 | if ( gtk_tree_model_iter_has_child(model, &iter1) | |||
1922 | && !gtk_tree_model_iter_has_child(model, &iter0) | |||
1923 | ) | |||
1924 | { | |||
1925 | gkrellm_config_message_dialog(_("Entry Error")dcgettext ("gkrellm", "Entry Error", 5), | |||
1926 | N_("At least one primary fs monitor must exist to click on in order to show\n"("At least one primary fs monitor must exist to click on in order to show\n" "secondary ones.\n") | |||
1927 | "secondary ones.\n")("At least one primary fs monitor must exist to click on in order to show\n" "secondary ones.\n")); | |||
1928 | } | |||
1929 | ||||
1930 | for (list = fs_mon_list; list; list = list->next) | |||
1931 | destroy_fs_monitor((FSmon *) list->data); | |||
1932 | g_list_free(fs_mon_list); | |||
1933 | fs_mon_list = NULL((void*)0); | |||
1934 | n_fs_monitors = 0; | |||
1935 | have_secondary_panels = gtk_tree_model_iter_has_child(model, &iter1); | |||
1936 | ||||
1937 | if (gtk_tree_model_iter_children(model, &iter, &iter0)) | |||
1938 | { | |||
1939 | do | |||
1940 | { | |||
1941 | fs = fs_new_from_model(model, &iter); | |||
1942 | fs->secondary = FALSE(0); | |||
1943 | fs->show_if_mounted = FALSE(0); | |||
1944 | fs_mon_list = g_list_append(fs_mon_list, fs); | |||
1945 | fs_monitor_create(fs_main_vbox, fs, n_fs_monitors, TRUE(!(0))); | |||
1946 | gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) g_type_check_instance_cast ((GTypeInstance *) ((model)), ((gtk_tree_store_get_type ())))))), &iter, | |||
1947 | FSMON_COLUMN, fs, -1); | |||
1948 | gkrellm_alert_trigger_connect(fs->alert, cb_alert_trigger, fs); | |||
1949 | gkrellm_alert_config_connect(fs->alert, cb_alert_config, fs); | |||
1950 | } | |||
1951 | while (gtk_tree_model_iter_next(model, &iter)); | |||
1952 | } | |||
1953 | ||||
1954 | if (gtk_tree_model_iter_children(model, &iter, &iter1)) | |||
1955 | { | |||
1956 | do | |||
1957 | { | |||
1958 | fs = fs_new_from_model(model, &iter); | |||
1959 | fs->secondary = TRUE(!(0)); | |||
1960 | fs_mon_list = g_list_append(fs_mon_list, fs); | |||
1961 | fs_monitor_create(fs_secondary_vbox, fs, n_fs_monitors, TRUE(!(0))); | |||
1962 | gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) g_type_check_instance_cast ((GTypeInstance *) ((model)), ((gtk_tree_store_get_type ())))))), &iter, | |||
1963 | FSMON_COLUMN, fs, -1); | |||
1964 | gkrellm_alert_trigger_connect(fs->alert, cb_alert_trigger, fs); | |||
1965 | gkrellm_alert_config_connect(fs->alert, cb_alert_config, fs); | |||
1966 | } | |||
1967 | while (gtk_tree_model_iter_next(model, &iter)); | |||
1968 | } | |||
1969 | else | |||
1970 | secondary_monitors_shown = FALSE(0); | |||
1971 | ||||
1972 | force_fs_check = FORCE_UPDATE2; | |||
1973 | if (g_list_length(fs_mon_list) > 0) | |||
1974 | gkrellm_spacers_show(mon_fs); | |||
1975 | else | |||
1976 | gkrellm_spacers_hide(mon_fs); | |||
1977 | } | |||
1978 | ||||
1979 | static void | |||
1980 | add_cb(GtkWidget *widget) | |||
1981 | { | |||
1982 | GtkTreeModel *model; | |||
1983 | GtkTreePath *path = NULL((void*)0); | |||
1984 | GtkTreeIter iter, parent_iter; | |||
1985 | FSmon *fs; | |||
1986 | gchar *label; | |||
1987 | gint secondary, *indices; | |||
1988 | gboolean a, b, err = FALSE(0); | |||
1989 | GtkWidget *entry; | |||
1990 | ||||
1991 | fs = g_new0(FSmon, 1)(FSmon *) (__extension__ ({ gsize __n = (gsize) (1); gsize __s = sizeof (FSmon); 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 ; })); | |||
1992 | fs->launch_mount.command = g_strdup(""); | |||
1993 | fs->launch_umount.command = g_strdup(""); | |||
1994 | fs->eject_device = g_strdup(""); | |||
1995 | ||||
1996 | label = gkrellm_gtk_entry_get_text(&label_entry); | |||
1997 | gkrellm_locale_dup_string(&fs->label, label, &fs->label_shadow); | |||
1998 | ||||
1999 | entry = gtk_bin_get_child(GTK_BIN(dir_combo_box)((((GtkBin*) g_type_check_instance_cast ((GTypeInstance*) ((dir_combo_box )), ((gtk_bin_get_type ()))))))); | |||
2000 | fs->mount.directory = g_strdup(gkrellm_gtk_entry_get_text(&entry)); | |||
2001 | ||||
2002 | if (show_button) | |||
2003 | fs->show_if_mounted = GTK_TOGGLE_BUTTON(show_button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance *) ((show_button)), ((gtk_toggle_button_get_type ()))))))->active; | |||
2004 | if (mounting_button) | |||
2005 | fs->fstab_mounting = GTK_TOGGLE_BUTTON(mounting_button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance *) ((mounting_button)), ((gtk_toggle_button_get_type ()))))))->active; | |||
2006 | if (mount_entry) | |||
2007 | { | |||
2008 | gkrellm_dup_string(&(fs->launch_mount.command), | |||
2009 | gkrellm_gtk_entry_get_text(&mount_entry)); | |||
2010 | gkrellm_dup_string(&(fs->launch_umount.command), | |||
2011 | gkrellm_gtk_entry_get_text(&umount_entry)); | |||
2012 | } | |||
2013 | if (ejectable_button) | |||
2014 | { | |||
2015 | fs->ejectable = GTK_TOGGLE_BUTTON(ejectable_button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance *) ((ejectable_button)), ((gtk_toggle_button_get_type ()))))) )->active; | |||
2016 | if (fs->ejectable && !fs->fstab_mounting && device_entry) | |||
2017 | gkrellm_dup_string(&(fs->eject_device), | |||
2018 | gkrellm_gtk_entry_get_text(&device_entry)); | |||
2019 | } | |||
2020 | if (!*(fs->label) || !*(fs->mount.directory)) | |||
2021 | { | |||
2022 | gkrellm_config_message_dialog(_("Entry Error")dcgettext ("gkrellm", "Entry Error", 5), | |||
2023 | #if !defined(WIN32) | |||
2024 | _("Both a label and a mount point must be entered.")dcgettext ("gkrellm", "Both a label and a mount point must be entered." , 5)); | |||
2025 | #else | |||
2026 | "Both a label and a disk must be entered."); | |||
2027 | #endif | |||
2028 | err = TRUE(!(0)); | |||
2029 | } | |||
2030 | a = (*(fs->launch_mount.command) != '\0'); | |||
2031 | b = (*(fs->launch_umount.command) != '\0'); | |||
2032 | if (mounting_supported && !_GK.client_mode && ((a && !b) || (!a && b))) | |||
2033 | { | |||
2034 | gkrellm_config_message_dialog(_("Entry Error")dcgettext ("gkrellm", "Entry Error", 5), | |||
2035 | _("Both mount and umount commands must be entered.")dcgettext ("gkrellm", "Both mount and umount commands must be entered." , 5)); | |||
2036 | err = TRUE(!(0)); | |||
2037 | } | |||
2038 | if ( mounting_supported && !_GK.client_mode | |||
2039 | && fs->ejectable && !fs->fstab_mounting && !*fs->eject_device | |||
2040 | ) | |||
2041 | { | |||
2042 | gkrellm_config_message_dialog(_("Entry Error")dcgettext ("gkrellm", "Entry Error", 5), | |||
2043 | _("Missing ejectable device entry.")dcgettext ("gkrellm", "Missing ejectable device entry.", 5)); | |||
2044 | err = TRUE(!(0)); | |||
2045 | } | |||
2046 | if (err) | |||
2047 | { | |||
2048 | free_fsmon_strings(fs); | |||
2049 | g_free(fs); | |||
2050 | return; | |||
2051 | } | |||
2052 | ||||
2053 | model = gtk_tree_view_get_model(treeview); | |||
2054 | secondary = GTK_TOGGLE_BUTTON(secondary_button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance *) ((secondary_button)), ((gtk_toggle_button_get_type ()))))) )->active; | |||
2055 | if (row_reference) | |||
2056 | { | |||
2057 | path = gtk_tree_row_reference_get_path(row_reference); | |||
2058 | gtk_tree_model_get_iter(model, &iter, path); | |||
2059 | indices = gtk_tree_path_get_indices(path); | |||
2060 | ||||
2061 | /* Have a row ref, but if user changed secondary button, remove the | |||
2062 | | row ref node and set path NULL so iter will be set as function of | |||
2063 | | secondary. row_ref will be invalidated below. | |||
2064 | */ | |||
2065 | if (indices[0] != secondary) | |||
2066 | { | |||
2067 | gtk_tree_store_remove(GTK_TREE_STORE(model)((((GtkTreeStore*) g_type_check_instance_cast ((GTypeInstance *) ((model)), ((gtk_tree_store_get_type ())))))), &iter); | |||
2068 | path = NULL((void*)0); | |||
2069 | } | |||
2070 | } | |||
2071 | if (!path) | |||
2072 | { | |||
2073 | gtk_tree_model_iter_nth_child(model, &parent_iter, NULL((void*)0), secondary); | |||
2074 | gtk_tree_store_append(GTK_TREE_STORE(model)((((GtkTreeStore*) g_type_check_instance_cast ((GTypeInstance *) ((model)), ((gtk_tree_store_get_type ())))))), &iter, &parent_iter); | |||
2075 | } | |||
2076 | set_tree_store_model_data(GTK_TREE_STORE(model)((((GtkTreeStore*) g_type_check_instance_cast ((GTypeInstance *) ((model)), ((gtk_tree_store_get_type ())))))), &iter, fs); | |||
2077 | if (!path) | |||
2078 | { | |||
2079 | /* If appending (not editing existing node) leave cursor at root level | |||
2080 | | and clear the entries anticipating another new entry. | |||
2081 | */ | |||
2082 | path = gtk_tree_path_new_from_string(secondary ? "1" : "0"); | |||
2083 | gtk_tree_view_set_cursor(treeview, path, NULL((void*)0), FALSE(0)); | |||
2084 | gtk_tree_path_free(path); | |||
2085 | reset_entries(secondary); | |||
2086 | } | |||
2087 | free_fsmon_strings(fs); | |||
2088 | g_free(fs); | |||
2089 | sync_fs_panels(); | |||
2090 | } | |||
2091 | ||||
2092 | static void | |||
2093 | cb_delete(GtkWidget *widget) | |||
2094 | { | |||
2095 | GtkTreeModel *model; | |||
2096 | GtkTreePath *path; | |||
2097 | GtkTreeIter iter; | |||
2098 | FSmon *fs; | |||
2099 | ||||
2100 | if (!row_reference) | |||
2101 | return; | |||
2102 | model = gtk_tree_view_get_model(treeview); | |||
2103 | path = gtk_tree_row_reference_get_path(row_reference); | |||
2104 | gtk_tree_model_get_iter(model, &iter, path); | |||
2105 | ||||
2106 | gtk_tree_model_get(model, &iter, FSMON_COLUMN, &fs, -1); | |||
2107 | gkrellm_alert_destroy(&fs->alert); | |||
2108 | ||||
2109 | gtk_tree_store_remove(GTK_TREE_STORE(model)((((GtkTreeStore*) g_type_check_instance_cast ((GTypeInstance *) ((model)), ((gtk_tree_store_get_type ())))))), &iter); | |||
2110 | reset_entries(FALSE(0)); | |||
2111 | sync_fs_panels(); | |||
2112 | } | |||
2113 | ||||
2114 | static void | |||
2115 | cb_data_format(GtkWidget *widget, gpointer data) | |||
2116 | { | |||
2117 | GList *list; | |||
2118 | FSmon *fs; | |||
2119 | GkrellmDecal *d; | |||
2120 | gchar *s, buf[256]; | |||
2121 | gint h_data, h_label; | |||
2122 | GtkWidget *entry; | |||
2123 | ||||
2124 | entry = gtk_bin_get_child(GTK_BIN(data_format_combo_box)((((GtkBin*) g_type_check_instance_cast ((GTypeInstance*) ((data_format_combo_box )), ((gtk_bin_get_type ()))))))); | |||
2125 | s = gkrellm_gtk_entry_get_text(&entry); | |||
2126 | ||||
2127 | /* In case Pango markup tags, don't accept line unless valid markup. | |||
2128 | | Ie, markup like <span ...> xxx </span> or <b> xxx </b> | |||
2129 | */ | |||
2130 | ||||
2131 | if ( strchr(s, '<')(__extension__ (__builtin_constant_p ('<') && !__builtin_constant_p (s) && ('<') == '\0' ? (char *) __rawmemchr (s, '<' ) : __builtin_strchr (s, '<'))) != NULL((void*)0) | |||
2132 | && !pango_parse_markup(s, -1, 0, NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0)) | |||
2133 | ) | |||
2134 | return; | |||
2135 | ||||
2136 | if (gkrellm_locale_dup_string(&data_format, s, &data_format_locale)) | |||
2137 | { | |||
2138 | for (list = fs_mon_list; list; list = list->next) | |||
2139 | { | |||
2140 | fs = (FSmon *) list->data; | |||
2141 | fs->label_decal->value = -1; /* Force redraw */ | |||
2142 | ||||
2143 | d = fs->data_decal; | |||
2144 | ||||
2145 | format_fs_data(fs, data_format_locale, buf, sizeof(buf)); | |||
2146 | gkrellm_text_markup_extents(d->text_style.font, buf, strlen(buf), | |||
2147 | NULL((void*)0), &h_data, NULL((void*)0), NULL((void*)0)); | |||
2148 | h_data += d->text_style.effect; | |||
2149 | h_label = fs->label_decal->h; | |||
2150 | ||||
2151 | /* Rebuild fs mon panels if new format string height extents | |||
2152 | | are wrong for current label/data decals. | |||
2153 | */ | |||
2154 | if ( (d->h >= h_label && h_data != d->h) | |||
2155 | || (d->h < h_label && h_data >= h_label) | |||
2156 | ) | |||
2157 | { | |||
2158 | sync_fs_panels(); | |||
2159 | break; | |||
2160 | } | |||
2161 | if (d->h < h_label && h_data < h_label && d->h != h_data) | |||
2162 | gkrellm_move_decal(fs->panel, d, d->x, | |||
2163 | d->y + (d->h - h_data) / 2); | |||
2164 | } | |||
2165 | } | |||
2166 | } | |||
2167 | ||||
2168 | static void | |||
2169 | cb_auto_eject(GtkWidget *button, gpointer data) | |||
2170 | { | |||
2171 | cdrom_auto_eject = GTK_TOGGLE_BUTTON(button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance *) ((button)), ((gtk_toggle_button_get_type ()))))))->active; | |||
2172 | } | |||
2173 | ||||
2174 | static void | |||
2175 | cb_binary_units(GtkWidget *button, gpointer data) | |||
2176 | { | |||
2177 | binary_units = GTK_TOGGLE_BUTTON(button)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance *) ((button)), ((gtk_toggle_button_get_type ()))))))->active; | |||
2178 | } | |||
2179 | ||||
2180 | static void | |||
2181 | cb_check_interval(GtkWidget *widget, GtkSpinButton *spin) | |||
2182 | { | |||
2183 | fs_check_timeout = gtk_spin_button_get_value_as_int(spin); | |||
2184 | } | |||
2185 | ||||
2186 | static void | |||
2187 | cb_nfs_check_interval(GtkWidget *widget, GtkSpinButton *spin) | |||
2188 | { | |||
2189 | nfs_check_timeout = gtk_spin_button_get_value_as_int(spin); | |||
2190 | } | |||
2191 | ||||
2192 | /* Allow destination drops only on depth 2 paths and don't allow drops from | |||
2193 | | source depths of 1 (top level nodes). Note: for some reason if I allow | |||
2194 | | drops on depth 3 nodes (destination is on top of a second level node) I | |||
2195 | | am not getting "drag_end" callbacks. | |||
2196 | */ | |||
2197 | static gboolean | |||
2198 | row_drop_possible(GtkTreeDragDest *drag_dest, GtkTreePath *path, | |||
2199 | GtkSelectionData *selection_data) | |||
2200 | { | |||
2201 | GtkTreePath *src_path; | |||
2202 | ||||
2203 | if (!row_reference) | |||
2204 | return FALSE(0); | |||
2205 | src_path = gtk_tree_row_reference_get_path(row_reference); | |||
2206 | ||||
2207 | if ( gtk_tree_path_get_depth(src_path) == 1 | |||
2208 | || gtk_tree_path_get_depth(path) != 2 | |||
2209 | ) | |||
2210 | return FALSE(0); | |||
2211 | ||||
2212 | return (*original_row_drop_possible)(drag_dest, path, | |||
2213 | selection_data); | |||
2214 | } | |||
2215 | ||||
2216 | /* At each drag, divert the original Gtk row_drop_possible function to my | |||
2217 | | custom row_drop_possible so I can control tree structure. The original | |||
2218 | | row_drop_possible function must be restored at "drag_end" else other | |||
2219 | | monitors doing drag n' drop could get screwed. | |||
2220 | */ | |||
2221 | static gboolean | |||
2222 | cb_drag_begin(GtkWidget *widget, GdkDragContext *context, gpointer data) | |||
2223 | { | |||
2224 | GtkTreeModel *model; | |||
2225 | GtkTreeDragDestIface *dest_iface; | |||
2226 | ||||
2227 | model = gtk_tree_view_get_model(treeview); | |||
2228 | dest_iface = GTK_TREE_DRAG_DEST_GET_IFACE(GTK_TREE_DRAG_DEST(model))((((GtkTreeDragDestIface*) g_type_interface_peek (((GTypeInstance *) ((((((GtkTreeDragDest*) g_type_check_instance_cast ((GTypeInstance *) ((model)), ((gtk_tree_drag_dest_get_type ())))))))))->g_class , ((gtk_tree_drag_dest_get_type ())))))); | |||
2229 | if (!original_row_drop_possible) | |||
2230 | original_row_drop_possible = dest_iface->row_drop_possible; | |||
2231 | dest_iface->row_drop_possible = row_drop_possible; | |||
2232 | return FALSE(0); | |||
2233 | } | |||
2234 | ||||
2235 | static gboolean | |||
2236 | cb_drag_end(GtkWidget *widget, GdkDragContext *context, gpointer data) | |||
2237 | { | |||
2238 | GtkTreeModel *model; | |||
2239 | GtkTreeDragDestIface *dest_iface; | |||
2240 | ||||
2241 | model = gtk_tree_view_get_model(treeview); | |||
2242 | dest_iface = GTK_TREE_DRAG_DEST_GET_IFACE(GTK_TREE_DRAG_DEST(model))((((GtkTreeDragDestIface*) g_type_interface_peek (((GTypeInstance *) ((((((GtkTreeDragDest*) g_type_check_instance_cast ((GTypeInstance *) ((model)), ((gtk_tree_drag_dest_get_type ())))))))))->g_class , ((gtk_tree_drag_dest_get_type ())))))); | |||
2243 | dest_iface->row_drop_possible = original_row_drop_possible; | |||
2244 | ||||
2245 | reset_entries(FALSE(0)); | |||
2246 | sync_fs_panels(); | |||
2247 | return FALSE(0); | |||
2248 | } | |||
2249 | ||||
2250 | ||||
2251 | static void | |||
2252 | create_fs_panels_page(GtkWidget *vbox) | |||
2253 | { | |||
2254 | GtkWidget *table; | |||
2255 | GtkWidget *hbox, *hbox1, *vbox1; | |||
2256 | GtkWidget *label; | |||
2257 | GtkWidget *scrolled; | |||
2258 | GtkTreeModel *model; | |||
2259 | GtkCellRenderer *renderer; | |||
2260 | GList *list; | |||
2261 | ||||
2262 | ||||
2263 | hbox = gtk_hbox_new(FALSE(0), 0); | |||
2264 | 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); | |||
2265 | vbox1 = gkrellm_gtk_framed_vbox(hbox, NULL((void*)0), 1, TRUE(!(0)), 0, 2); | |||
2266 | ||||
2267 | table = gtk_table_new(2, 2, FALSE(0)); | |||
2268 | gtk_box_pack_start(GTK_BOX(vbox1)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((vbox1 )), ((gtk_box_get_type ())))))), table, FALSE(0), FALSE(0), 0); | |||
2269 | ||||
2270 | label = gtk_label_new(_("Label")dcgettext ("gkrellm", "Label", 5)); | |||
2271 | gtk_table_attach(GTK_TABLE(table)((((GtkTable*) g_type_check_instance_cast ((GTypeInstance*) ( (table)), ((gtk_table_get_type ())))))), label, 0, 1, 0, 1, | |||
2272 | GTK_SHRINK, GTK_SHRINK, 2, 1); | |||
2273 | label_entry = gtk_entry_new(); | |||
2274 | // gtk_entry_set_max_length(GTK_ENTRY(label_entry), 16); | |||
2275 | gtk_widget_set_size_request(label_entry, 100, -1); | |||
2276 | gtk_table_attach_defaults(GTK_TABLE(table)((((GtkTable*) g_type_check_instance_cast ((GTypeInstance*) ( (table)), ((gtk_table_get_type ())))))), label_entry, 1, 2, 0, 1); | |||
2277 | ||||
2278 | #if !defined(WIN32) | |||
2279 | label = gtk_label_new(_("Mount Point")dcgettext ("gkrellm", "Mount Point", 5)); | |||
2280 | #else | |||
2281 | label = gtk_label_new("Disk"); | |||
2282 | #endif | |||
2283 | gtk_table_attach(GTK_TABLE(table)((((GtkTable*) g_type_check_instance_cast ((GTypeInstance*) ( (table)), ((gtk_table_get_type ())))))), label, 0, 1, 1, 2, | |||
2284 | GTK_SHRINK, GTK_SHRINK, 2, 1); | |||
2285 | dir_combo_box = gtk_combo_box_entry_new_text(); | |||
2286 | gtk_table_attach_defaults(GTK_TABLE(table)((((GtkTable*) g_type_check_instance_cast ((GTypeInstance*) ( (table)), ((gtk_table_get_type ())))))), dir_combo_box, 1, 2, 1, 2); | |||
2287 | for (list = fstab_list; list; list = list->next) | |||
2288 | { | |||
2289 | gtk_combo_box_append_text(GTK_COMBO_BOX(dir_combo_box)((((GtkComboBox*) g_type_check_instance_cast ((GTypeInstance* ) ((dir_combo_box)), ((gtk_combo_box_get_type ())))))), | |||
2290 | ((Mount *)list->data)->directory); | |||
2291 | } | |||
2292 | gtk_combo_box_set_active(GTK_COMBO_BOX(dir_combo_box)((((GtkComboBox*) g_type_check_instance_cast ((GTypeInstance* ) ((dir_combo_box)), ((gtk_combo_box_get_type ())))))), -1); | |||
2293 | g_signal_connect(G_OBJECT(GTK_COMBO_BOX(dir_combo_box)),g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((((((GtkComboBox*) g_type_check_instance_cast ((GTypeInstance*) ((dir_combo_box)), ((gtk_combo_box_get_type ())))))))), (((GType) ((20) << (2))))))))), ("changed" ), (((GCallback) (cb_combo_changed))), (((void*)0)), ((void*) 0), (GConnectFlags) 0) | |||
2294 | "changed", G_CALLBACK(cb_combo_changed), NULL)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((((((GtkComboBox*) g_type_check_instance_cast ((GTypeInstance*) ((dir_combo_box)), ((gtk_combo_box_get_type ())))))))), (((GType) ((20) << (2))))))))), ("changed" ), (((GCallback) (cb_combo_changed))), (((void*)0)), ((void*) 0), (GConnectFlags) 0); | |||
2295 | ||||
2296 | vbox1 = gtk_vbox_new(FALSE(0), 0); | |||
2297 | 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); | |||
2298 | hbox = gtk_hbox_new(FALSE(0), 0); | |||
2299 | 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); | |||
2300 | ||||
2301 | gkrellm_gtk_check_button_connected(hbox, &secondary_button, 0, | |||
2302 | TRUE(!(0)), TRUE(!(0)), 2, cb_secondary_button_clicked, NULL((void*)0), | |||
2303 | _("Secondary")dcgettext ("gkrellm", "Secondary", 5)); | |||
2304 | ||||
2305 | ||||
2306 | if (mounting_supported) | |||
2307 | { | |||
2308 | gkrellm_gtk_check_button_connected(hbox, &show_button, 0, | |||
2309 | TRUE(!(0)), TRUE(!(0)), 2, NULL((void*)0), NULL((void*)0), | |||
2310 | _("Show if mounted")dcgettext ("gkrellm", "Show if mounted", 5)); | |||
2311 | gtk_widget_set_sensitive(show_button, FALSE(0)); | |||
2312 | if (!_GK.client_mode) | |||
2313 | { | |||
2314 | gkrellm_gtk_check_button_connected(vbox1, &mounting_button, 0, | |||
2315 | FALSE(0), FALSE(0), 2, cb_mount_button_clicked, NULL((void*)0), | |||
2316 | _("Enable /etc/fstab mounting")dcgettext ("gkrellm", "Enable /etc/fstab mounting", 5)); | |||
2317 | gtk_widget_set_sensitive(mounting_button, FALSE(0)); | |||
2318 | } | |||
2319 | } | |||
2320 | ||||
2321 | hbox = gtk_hbox_new(FALSE(0), 0); | |||
2322 | 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); | |||
2323 | ||||
2324 | if (ejecting_supported && !_GK.client_mode) | |||
2325 | { | |||
2326 | vbox1 = gkrellm_gtk_framed_vbox(hbox, NULL((void*)0), 1, FALSE(0), 0, 2); | |||
2327 | ||||
2328 | gkrellm_gtk_check_button_connected(vbox1, &ejectable_button, 0, | |||
2329 | FALSE(0), FALSE(0), 0, cb_ejectable_button_clicked, NULL((void*)0), | |||
2330 | _("Ejectable")dcgettext ("gkrellm", "Ejectable", 5)); | |||
2331 | ||||
2332 | if (mounting_supported) | |||
2333 | { | |||
2334 | hbox1 = gtk_hbox_new(FALSE(0), 0); | |||
2335 | gtk_box_pack_start(GTK_BOX(vbox1)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((vbox1 )), ((gtk_box_get_type ())))))), hbox1, FALSE(0), FALSE(0), 0); | |||
2336 | label = gtk_label_new(_("Device")dcgettext ("gkrellm", "Device", 5)); | |||
2337 | gtk_box_pack_start(GTK_BOX(hbox1)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((hbox1 )), ((gtk_box_get_type ())))))), label, FALSE(0), FALSE(0), 2); | |||
2338 | device_entry = gtk_entry_new(); | |||
2339 | gtk_entry_set_max_length(GTK_ENTRY(device_entry)((((GtkEntry*) g_type_check_instance_cast ((GTypeInstance*) ( (device_entry)), ((gtk_entry_get_type ())))))), 64); | |||
2340 | gtk_widget_set_size_request(device_entry, 100, -1); | |||
2341 | gtk_box_pack_start(GTK_BOX(hbox1)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((hbox1 )), ((gtk_box_get_type ())))))), device_entry, | |||
2342 | FALSE(0), FALSE(0), 2); | |||
2343 | } | |||
2344 | } | |||
2345 | ||||
2346 | if (mounting_supported && !_GK.client_mode) | |||
2347 | { | |||
2348 | vbox1 = gkrellm_gtk_framed_vbox(hbox, NULL((void*)0), 1, TRUE(!(0)), 0, 2); | |||
2349 | table = gkrellm_gtk_launcher_table_new(vbox1, 1); /* Won't have tooltip */ | |||
2350 | gkrellm_gtk_config_launcher(table, 0, &mount_entry, | |||
2351 | NULL((void*)0), _("mount")dcgettext ("gkrellm", "mount", 5), NULL((void*)0)); | |||
2352 | gkrellm_gtk_config_launcher(table, 1, &umount_entry, | |||
2353 | NULL((void*)0), _("umount")dcgettext ("gkrellm", "umount", 5), NULL((void*)0)); | |||
2354 | } | |||
2355 | hbox = gtk_hbox_new(FALSE(0), 2); | |||
2356 | gtk_box_pack_start(GTK_BOX(vbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((vbox )), ((gtk_box_get_type ())))))), hbox, TRUE(!(0)), TRUE(!(0)), 0); | |||
2357 | ||||
2358 | vbox1 = gtk_vbox_new(FALSE(0), 0); | |||
2359 | gtk_box_pack_end(GTK_BOX(hbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((hbox )), ((gtk_box_get_type ())))))), vbox1, FALSE(0), FALSE(0), 5); | |||
2360 | ||||
2361 | gkrellm_gtk_button_connected(vbox1, &new_apply_button, FALSE(0), FALSE(0), 4, | |||
2362 | add_cb, NULL((void*)0), GTK_STOCK_NEW"gtk-new"); | |||
2363 | GTK_WIDGET_SET_FLAGS(new_apply_button, GTK_CAN_DEFAULT)do{ (((((((GtkObject*) g_type_check_instance_cast ((GTypeInstance *) ((new_apply_button)), ((gtk_object_get_type ()))))))->flags )) |= (GTK_CAN_DEFAULT)); }while (0); | |||
2364 | gtk_widget_grab_default(new_apply_button); | |||
2365 | ||||
2366 | gkrellm_gtk_button_connected(vbox1, &delete_button, FALSE(0), FALSE(0), 4, | |||
2367 | cb_delete, NULL((void*)0), GTK_STOCK_DELETE"gtk-delete"); | |||
2368 | gtk_widget_set_sensitive(delete_button, FALSE(0)); | |||
2369 | ||||
2370 | gkrellm_gtk_alert_button(vbox1, &alert_button, FALSE(0), FALSE(0), 4, FALSE(0), | |||
2371 | cb_set_alert, NULL((void*)0)); | |||
2372 | gtk_widget_set_sensitive(alert_button, FALSE(0)); | |||
2373 | ||||
2374 | scrolled = gtk_scrolled_window_new(NULL((void*)0), NULL((void*)0)); | |||
2375 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled)((((GtkScrolledWindow*) g_type_check_instance_cast ((GTypeInstance *) ((scrolled)), ((gtk_scrolled_window_get_type ())))))), | |||
2376 | GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | |||
2377 | gtk_box_pack_end(GTK_BOX(hbox)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((hbox )), ((gtk_box_get_type ())))))), scrolled, TRUE(!(0)), TRUE(!(0)), 0); | |||
2378 | ||||
2379 | model = create_model(); | |||
2380 | ||||
2381 | 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 ())))))); | |||
2382 | g_object_unref(G_OBJECT(model)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) (( model)), (((GType) ((20) << (2))))))))); | |||
2383 | gtk_tree_view_set_rules_hint(treeview, TRUE(!(0))); | |||
2384 | gtk_tree_view_set_reorderable(treeview, TRUE(!(0))); | |||
2385 | g_signal_connect(G_OBJECT(treeview), "drag_begin",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((treeview)), (((GType) ((20) << (2) )))))))), ("drag_begin"), (((GCallback) (cb_drag_begin))), (( (void*)0)), ((void*)0), (GConnectFlags) 0) | |||
2386 | G_CALLBACK(cb_drag_begin), NULL)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((treeview)), (((GType) ((20) << (2) )))))))), ("drag_begin"), (((GCallback) (cb_drag_begin))), (( (void*)0)), ((void*)0), (GConnectFlags) 0); | |||
2387 | g_signal_connect(G_OBJECT(treeview), "drag_end",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((treeview)), (((GType) ((20) << (2) )))))))), ("drag_end"), (((GCallback) (cb_drag_end))), (((void *)0)), ((void*)0), (GConnectFlags) 0) | |||
2388 | G_CALLBACK(cb_drag_end), NULL)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((treeview)), (((GType) ((20) << (2) )))))))), ("drag_end"), (((GCallback) (cb_drag_end))), (((void *)0)), ((void*)0), (GConnectFlags) 0); | |||
2389 | ||||
2390 | renderer = gtk_cell_renderer_text_new(); | |||
2391 | // g_object_set(G_OBJECT(renderer), "xalign", 0.0, NULL); | |||
2392 | gtk_tree_view_insert_column_with_attributes(treeview, -1, _("Label")dcgettext ("gkrellm", "Label", 5), | |||
2393 | renderer, | |||
2394 | "text", NAME_COLUMN, NULL((void*)0)); | |||
2395 | renderer = gtk_cell_renderer_text_new(); | |||
2396 | gtk_tree_view_insert_column_with_attributes(treeview, -1, _("Mount Point")dcgettext ("gkrellm", "Mount Point", 5), | |||
2397 | renderer, | |||
2398 | "text", MOUNT_POINT_COLUMN, | |||
2399 | // "visible", VISIBLE_COLUMN, | |||
2400 | NULL((void*)0)); | |||
2401 | ||||
2402 | renderer = gtk_cell_renderer_pixbuf_new(); | |||
2403 | gtk_tree_view_insert_column_with_attributes(treeview, -1, "", | |||
2404 | renderer, | |||
2405 | "pixbuf", IMAGE_COLUMN, | |||
2406 | NULL((void*)0)); | |||
2407 | ||||
2408 | 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 ()))))))); | |||
2409 | ||||
2410 | selection = gtk_tree_view_get_selection(treeview); | |||
2411 | gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE); | |||
2412 | 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) | |||
2413 | 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); | |||
2414 | } | |||
2415 | ||||
2416 | ||||
2417 | static gchar *fs_info_text0[] = | |||
2418 | { | |||
2419 | N_("<h>Mounting\n")("<h>Mounting\n"), | |||
2420 | N_("Enter file system mount points to monitor and enter a label to describe\n"("Enter file system mount points to monitor and enter a label to describe\n" "the mount point. The krell shows the ratio of blocks used to total blocks\n" "available. Mounting commands can be enabled for mount points in one\n" "of two ways:\n\n") | |||
2421 | "the mount point. The krell shows the ratio of blocks used to total blocks\n"("Enter file system mount points to monitor and enter a label to describe\n" "the mount point. The krell shows the ratio of blocks used to total blocks\n" "available. Mounting commands can be enabled for mount points in one\n" "of two ways:\n\n") | |||
2422 | "available. Mounting commands can be enabled for mount points in one\n"("Enter file system mount points to monitor and enter a label to describe\n" "the mount point. The krell shows the ratio of blocks used to total blocks\n" "available. Mounting commands can be enabled for mount points in one\n" "of two ways:\n\n") | |||
2423 | "of two ways:\n\n")("Enter file system mount points to monitor and enter a label to describe\n" "the mount point. The krell shows the ratio of blocks used to total blocks\n" "available. Mounting commands can be enabled for mount points in one\n" "of two ways:\n\n"), | |||
2424 | ||||
2425 | N_("<b>\t1) Mounting using /etc/fstab: ")("<b>\t1) Mounting using /etc/fstab: "), | |||
2426 | ||||
2427 | N_("If a mount point is in your\n"("If a mount point is in your\n""\t/etc/fstab and you have mount permission then mount and umount\n" "\tcommands can be enabled and executed for that mount point simply\n" "\tby checking the \"Enable /etc/fstab mounting\" option.\n""\tMount table entries in /etc/fstab need the \"user\" or \"owner\" option\n" "\tset to grant this permission unless GKrellM is run as root.\n" "\tFor example, if you run GKrellM as a normal user and you want\n" "\tto be able to mount your floppy, your /etc/fstab could have\n" "\teither of:\n") | |||
2428 | "\t/etc/fstab and you have mount permission then mount and umount\n"("If a mount point is in your\n""\t/etc/fstab and you have mount permission then mount and umount\n" "\tcommands can be enabled and executed for that mount point simply\n" "\tby checking the \"Enable /etc/fstab mounting\" option.\n""\tMount table entries in /etc/fstab need the \"user\" or \"owner\" option\n" "\tset to grant this permission unless GKrellM is run as root.\n" "\tFor example, if you run GKrellM as a normal user and you want\n" "\tto be able to mount your floppy, your /etc/fstab could have\n" "\teither of:\n") | |||
2429 | "\tcommands can be enabled and executed for that mount point simply\n"("If a mount point is in your\n""\t/etc/fstab and you have mount permission then mount and umount\n" "\tcommands can be enabled and executed for that mount point simply\n" "\tby checking the \"Enable /etc/fstab mounting\" option.\n""\tMount table entries in /etc/fstab need the \"user\" or \"owner\" option\n" "\tset to grant this permission unless GKrellM is run as root.\n" "\tFor example, if you run GKrellM as a normal user and you want\n" "\tto be able to mount your floppy, your /etc/fstab could have\n" "\teither of:\n") | |||
2430 | "\tby checking the \"Enable /etc/fstab mounting\" option.\n"("If a mount point is in your\n""\t/etc/fstab and you have mount permission then mount and umount\n" "\tcommands can be enabled and executed for that mount point simply\n" "\tby checking the \"Enable /etc/fstab mounting\" option.\n""\tMount table entries in /etc/fstab need the \"user\" or \"owner\" option\n" "\tset to grant this permission unless GKrellM is run as root.\n" "\tFor example, if you run GKrellM as a normal user and you want\n" "\tto be able to mount your floppy, your /etc/fstab could have\n" "\teither of:\n") | |||
2431 | "\tMount table entries in /etc/fstab need the \"user\" or \"owner\" option\n"("If a mount point is in your\n""\t/etc/fstab and you have mount permission then mount and umount\n" "\tcommands can be enabled and executed for that mount point simply\n" "\tby checking the \"Enable /etc/fstab mounting\" option.\n""\tMount table entries in /etc/fstab need the \"user\" or \"owner\" option\n" "\tset to grant this permission unless GKrellM is run as root.\n" "\tFor example, if you run GKrellM as a normal user and you want\n" "\tto be able to mount your floppy, your /etc/fstab could have\n" "\teither of:\n") | |||
2432 | "\tset to grant this permission unless GKrellM is run as root.\n"("If a mount point is in your\n""\t/etc/fstab and you have mount permission then mount and umount\n" "\tcommands can be enabled and executed for that mount point simply\n" "\tby checking the \"Enable /etc/fstab mounting\" option.\n""\tMount table entries in /etc/fstab need the \"user\" or \"owner\" option\n" "\tset to grant this permission unless GKrellM is run as root.\n" "\tFor example, if you run GKrellM as a normal user and you want\n" "\tto be able to mount your floppy, your /etc/fstab could have\n" "\teither of:\n") | |||
2433 | "\tFor example, if you run GKrellM as a normal user and you want\n"("If a mount point is in your\n""\t/etc/fstab and you have mount permission then mount and umount\n" "\tcommands can be enabled and executed for that mount point simply\n" "\tby checking the \"Enable /etc/fstab mounting\" option.\n""\tMount table entries in /etc/fstab need the \"user\" or \"owner\" option\n" "\tset to grant this permission unless GKrellM is run as root.\n" "\tFor example, if you run GKrellM as a normal user and you want\n" "\tto be able to mount your floppy, your /etc/fstab could have\n" "\teither of:\n") | |||
2434 | "\tto be able to mount your floppy, your /etc/fstab could have\n"("If a mount point is in your\n""\t/etc/fstab and you have mount permission then mount and umount\n" "\tcommands can be enabled and executed for that mount point simply\n" "\tby checking the \"Enable /etc/fstab mounting\" option.\n""\tMount table entries in /etc/fstab need the \"user\" or \"owner\" option\n" "\tset to grant this permission unless GKrellM is run as root.\n" "\tFor example, if you run GKrellM as a normal user and you want\n" "\tto be able to mount your floppy, your /etc/fstab could have\n" "\teither of:\n") | |||
2435 | "\teither of:\n")("If a mount point is in your\n""\t/etc/fstab and you have mount permission then mount and umount\n" "\tcommands can be enabled and executed for that mount point simply\n" "\tby checking the \"Enable /etc/fstab mounting\" option.\n""\tMount table entries in /etc/fstab need the \"user\" or \"owner\" option\n" "\tset to grant this permission unless GKrellM is run as root.\n" "\tFor example, if you run GKrellM as a normal user and you want\n" "\tto be able to mount your floppy, your /etc/fstab could have\n" "\teither of:\n"), | |||
2436 | ||||
2437 | N_("<i>\t\t/dev/fd0 /mnt/floppy ext2 user,noauto,rw,exec 0 0\n")("<i>\t\t/dev/fd0 /mnt/floppy ext2 user,noauto,rw,exec 0 0\n" ), | |||
2438 | N_("\tor\n")("\tor\n"), | |||
2439 | N_("<i>\t\t/dev/fd0 /mnt/floppy ext2 user,defaults 0 0\n\n")("<i>\t\t/dev/fd0 /mnt/floppy ext2 user,defaults 0 0\n\n" ), | |||
2440 | ||||
2441 | N_("<b>\t2) Mounting using custom commands: ")("<b>\t2) Mounting using custom commands: "), | |||
2442 | N_("If GKrellM is run as root or if\n"("If GKrellM is run as root or if\n""\tyou have sudo permission to run the mount commands, then a custom\n" "\tmount command can be entered into the \"mount command\" entry\n" "\tbox. A umount command must also be entered if you choose this\n" "\tmethod. Example mount and umount entries using sudo:\n") | |||
2443 | "\tyou have sudo permission to run the mount commands, then a custom\n"("If GKrellM is run as root or if\n""\tyou have sudo permission to run the mount commands, then a custom\n" "\tmount command can be entered into the \"mount command\" entry\n" "\tbox. A umount command must also be entered if you choose this\n" "\tmethod. Example mount and umount entries using sudo:\n") | |||
2444 | "\tmount command can be entered into the \"mount command\" entry\n"("If GKrellM is run as root or if\n""\tyou have sudo permission to run the mount commands, then a custom\n" "\tmount command can be entered into the \"mount command\" entry\n" "\tbox. A umount command must also be entered if you choose this\n" "\tmethod. Example mount and umount entries using sudo:\n") | |||
2445 | "\tbox. A umount command must also be entered if you choose this\n"("If GKrellM is run as root or if\n""\tyou have sudo permission to run the mount commands, then a custom\n" "\tmount command can be entered into the \"mount command\" entry\n" "\tbox. A umount command must also be entered if you choose this\n" "\tmethod. Example mount and umount entries using sudo:\n") | |||
2446 | "\tmethod. Example mount and umount entries using sudo:\n")("If GKrellM is run as root or if\n""\tyou have sudo permission to run the mount commands, then a custom\n" "\tmount command can be entered into the \"mount command\" entry\n" "\tbox. A umount command must also be entered if you choose this\n" "\tmethod. Example mount and umount entries using sudo:\n"), | |||
2447 | ||||
2448 | N_("<i>\t\tsudo /bin/mount -t msdos /dev/fd0 /mnt/A\n")("<i>\t\tsudo /bin/mount -t msdos /dev/fd0 /mnt/A\n"), | |||
2449 | N_("<i>\t\tsudo /bin/umount /mnt/A\n")("<i>\t\tsudo /bin/umount /mnt/A\n"), | |||
2450 | ||||
2451 | N_("\tNotes: the mount point specified in a custom mount command\n"("\tNotes: the mount point specified in a custom mount command\n" "\t(/mnt/A in this example) must be the same as entered in the\n" "\t\"Mount Point\" entry. You should have the NOPASSWD option set\n" "\tin /etc/sudoers if using sudo.\n\n") | |||
2452 | "\t(/mnt/A in this example) must be the same as entered in the\n"("\tNotes: the mount point specified in a custom mount command\n" "\t(/mnt/A in this example) must be the same as entered in the\n" "\t\"Mount Point\" entry. You should have the NOPASSWD option set\n" "\tin /etc/sudoers if using sudo.\n\n") | |||
2453 | "\t\"Mount Point\" entry. You should have the NOPASSWD option set\n"("\tNotes: the mount point specified in a custom mount command\n" "\t(/mnt/A in this example) must be the same as entered in the\n" "\t\"Mount Point\" entry. You should have the NOPASSWD option set\n" "\tin /etc/sudoers if using sudo.\n\n") | |||
2454 | "\tin /etc/sudoers if using sudo.\n\n")("\tNotes: the mount point specified in a custom mount command\n" "\t(/mnt/A in this example) must be the same as entered in the\n" "\t\"Mount Point\" entry. You should have the NOPASSWD option set\n" "\tin /etc/sudoers if using sudo.\n\n"), | |||
2455 | ||||
2456 | N_("<h>Primary and Secondary Monitors\n")("<h>Primary and Secondary Monitors\n"), /* xgettext:no-c-format */ | |||
2457 | N_("File system monitors can be created as primary (always visible)\n"("File system monitors can be created as primary (always visible)\n" "or secondary which can be hidden and then shown when they are of\n" "interest. For example, you might make primary file system monitors\n" "for root, home, or user so they will be always visible, but make\n" "secondary monitors for less frequently used mount points such as\n" "floppy, zip, backup partitions, foreign file system types, etc.\n" "Secondary FS monitors can also be configured to always be visible if they\n" "are mounted by checking the \"Show if mounted\" option. Using this\n" "feature you can show the secondary group, mount a file system, and have\n" "that FS monitor remain visible even when the secondary group is hidden.\n" "A standard cdrom mount will show as 100% full but a monitor for it\n" "could be created with mounting enabled just to have the\n" "mount/umount convenience.\n\n" ) | |||
2458 | "or secondary which can be hidden and then shown when they are of\n"("File system monitors can be created as primary (always visible)\n" "or secondary which can be hidden and then shown when they are of\n" "interest. For example, you might make primary file system monitors\n" "for root, home, or user so they will be always visible, but make\n" "secondary monitors for less frequently used mount points such as\n" "floppy, zip, backup partitions, foreign file system types, etc.\n" "Secondary FS monitors can also be configured to always be visible if they\n" "are mounted by checking the \"Show if mounted\" option. Using this\n" "feature you can show the secondary group, mount a file system, and have\n" "that FS monitor remain visible even when the secondary group is hidden.\n" "A standard cdrom mount will show as 100% full but a monitor for it\n" "could be created with mounting enabled just to have the\n" "mount/umount convenience.\n\n" ) | |||
2459 | "interest. For example, you might make primary file system monitors\n"("File system monitors can be created as primary (always visible)\n" "or secondary which can be hidden and then shown when they are of\n" "interest. For example, you might make primary file system monitors\n" "for root, home, or user so they will be always visible, but make\n" "secondary monitors for less frequently used mount points such as\n" "floppy, zip, backup partitions, foreign file system types, etc.\n" "Secondary FS monitors can also be configured to always be visible if they\n" "are mounted by checking the \"Show if mounted\" option. Using this\n" "feature you can show the secondary group, mount a file system, and have\n" "that FS monitor remain visible even when the secondary group is hidden.\n" "A standard cdrom mount will show as 100% full but a monitor for it\n" "could be created with mounting enabled just to have the\n" "mount/umount convenience.\n\n" ) | |||
2460 | "for root, home, or user so they will be always visible, but make\n"("File system monitors can be created as primary (always visible)\n" "or secondary which can be hidden and then shown when they are of\n" "interest. For example, you might make primary file system monitors\n" "for root, home, or user so they will be always visible, but make\n" "secondary monitors for less frequently used mount points such as\n" "floppy, zip, backup partitions, foreign file system types, etc.\n" "Secondary FS monitors can also be configured to always be visible if they\n" "are mounted by checking the \"Show if mounted\" option. Using this\n" "feature you can show the secondary group, mount a file system, and have\n" "that FS monitor remain visible even when the secondary group is hidden.\n" "A standard cdrom mount will show as 100% full but a monitor for it\n" "could be created with mounting enabled just to have the\n" "mount/umount convenience.\n\n" ) | |||
2461 | "secondary monitors for less frequently used mount points such as\n"("File system monitors can be created as primary (always visible)\n" "or secondary which can be hidden and then shown when they are of\n" "interest. For example, you might make primary file system monitors\n" "for root, home, or user so they will be always visible, but make\n" "secondary monitors for less frequently used mount points such as\n" "floppy, zip, backup partitions, foreign file system types, etc.\n" "Secondary FS monitors can also be configured to always be visible if they\n" "are mounted by checking the \"Show if mounted\" option. Using this\n" "feature you can show the secondary group, mount a file system, and have\n" "that FS monitor remain visible even when the secondary group is hidden.\n" "A standard cdrom mount will show as 100% full but a monitor for it\n" "could be created with mounting enabled just to have the\n" "mount/umount convenience.\n\n" ) | |||
2462 | "floppy, zip, backup partitions, foreign file system types, etc.\n"("File system monitors can be created as primary (always visible)\n" "or secondary which can be hidden and then shown when they are of\n" "interest. For example, you might make primary file system monitors\n" "for root, home, or user so they will be always visible, but make\n" "secondary monitors for less frequently used mount points such as\n" "floppy, zip, backup partitions, foreign file system types, etc.\n" "Secondary FS monitors can also be configured to always be visible if they\n" "are mounted by checking the \"Show if mounted\" option. Using this\n" "feature you can show the secondary group, mount a file system, and have\n" "that FS monitor remain visible even when the secondary group is hidden.\n" "A standard cdrom mount will show as 100% full but a monitor for it\n" "could be created with mounting enabled just to have the\n" "mount/umount convenience.\n\n" ) | |||
2463 | "Secondary FS monitors can also be configured to always be visible if they\n"("File system monitors can be created as primary (always visible)\n" "or secondary which can be hidden and then shown when they are of\n" "interest. For example, you might make primary file system monitors\n" "for root, home, or user so they will be always visible, but make\n" "secondary monitors for less frequently used mount points such as\n" "floppy, zip, backup partitions, foreign file system types, etc.\n" "Secondary FS monitors can also be configured to always be visible if they\n" "are mounted by checking the \"Show if mounted\" option. Using this\n" "feature you can show the secondary group, mount a file system, and have\n" "that FS monitor remain visible even when the secondary group is hidden.\n" "A standard cdrom mount will show as 100% full but a monitor for it\n" "could be created with mounting enabled just to have the\n" "mount/umount convenience.\n\n" ) | |||
2464 | "are mounted by checking the \"Show if mounted\" option. Using this\n"("File system monitors can be created as primary (always visible)\n" "or secondary which can be hidden and then shown when they are of\n" "interest. For example, you might make primary file system monitors\n" "for root, home, or user so they will be always visible, but make\n" "secondary monitors for less frequently used mount points such as\n" "floppy, zip, backup partitions, foreign file system types, etc.\n" "Secondary FS monitors can also be configured to always be visible if they\n" "are mounted by checking the \"Show if mounted\" option. Using this\n" "feature you can show the secondary group, mount a file system, and have\n" "that FS monitor remain visible even when the secondary group is hidden.\n" "A standard cdrom mount will show as 100% full but a monitor for it\n" "could be created with mounting enabled just to have the\n" "mount/umount convenience.\n\n" ) | |||
2465 | "feature you can show the secondary group, mount a file system, and have\n"("File system monitors can be created as primary (always visible)\n" "or secondary which can be hidden and then shown when they are of\n" "interest. For example, you might make primary file system monitors\n" "for root, home, or user so they will be always visible, but make\n" "secondary monitors for less frequently used mount points such as\n" "floppy, zip, backup partitions, foreign file system types, etc.\n" "Secondary FS monitors can also be configured to always be visible if they\n" "are mounted by checking the \"Show if mounted\" option. Using this\n" "feature you can show the secondary group, mount a file system, and have\n" "that FS monitor remain visible even when the secondary group is hidden.\n" "A standard cdrom mount will show as 100% full but a monitor for it\n" "could be created with mounting enabled just to have the\n" "mount/umount convenience.\n\n" ) | |||
2466 | "that FS monitor remain visible even when the secondary group is hidden.\n"("File system monitors can be created as primary (always visible)\n" "or secondary which can be hidden and then shown when they are of\n" "interest. For example, you might make primary file system monitors\n" "for root, home, or user so they will be always visible, but make\n" "secondary monitors for less frequently used mount points such as\n" "floppy, zip, backup partitions, foreign file system types, etc.\n" "Secondary FS monitors can also be configured to always be visible if they\n" "are mounted by checking the \"Show if mounted\" option. Using this\n" "feature you can show the secondary group, mount a file system, and have\n" "that FS monitor remain visible even when the secondary group is hidden.\n" "A standard cdrom mount will show as 100% full but a monitor for it\n" "could be created with mounting enabled just to have the\n" "mount/umount convenience.\n\n" ) | |||
2467 | "A standard cdrom mount will show as 100% full but a monitor for it\n"("File system monitors can be created as primary (always visible)\n" "or secondary which can be hidden and then shown when they are of\n" "interest. For example, you might make primary file system monitors\n" "for root, home, or user so they will be always visible, but make\n" "secondary monitors for less frequently used mount points such as\n" "floppy, zip, backup partitions, foreign file system types, etc.\n" "Secondary FS monitors can also be configured to always be visible if they\n" "are mounted by checking the \"Show if mounted\" option. Using this\n" "feature you can show the secondary group, mount a file system, and have\n" "that FS monitor remain visible even when the secondary group is hidden.\n" "A standard cdrom mount will show as 100% full but a monitor for it\n" "could be created with mounting enabled just to have the\n" "mount/umount convenience.\n\n" ) | |||
2468 | "could be created with mounting enabled just to have the\n"("File system monitors can be created as primary (always visible)\n" "or secondary which can be hidden and then shown when they are of\n" "interest. For example, you might make primary file system monitors\n" "for root, home, or user so they will be always visible, but make\n" "secondary monitors for less frequently used mount points such as\n" "floppy, zip, backup partitions, foreign file system types, etc.\n" "Secondary FS monitors can also be configured to always be visible if they\n" "are mounted by checking the \"Show if mounted\" option. Using this\n" "feature you can show the secondary group, mount a file system, and have\n" "that FS monitor remain visible even when the secondary group is hidden.\n" "A standard cdrom mount will show as 100% full but a monitor for it\n" "could be created with mounting enabled just to have the\n" "mount/umount convenience.\n\n" ) | |||
2469 | "mount/umount convenience.\n\n")("File system monitors can be created as primary (always visible)\n" "or secondary which can be hidden and then shown when they are of\n" "interest. For example, you might make primary file system monitors\n" "for root, home, or user so they will be always visible, but make\n" "secondary monitors for less frequently used mount points such as\n" "floppy, zip, backup partitions, foreign file system types, etc.\n" "Secondary FS monitors can also be configured to always be visible if they\n" "are mounted by checking the \"Show if mounted\" option. Using this\n" "feature you can show the secondary group, mount a file system, and have\n" "that FS monitor remain visible even when the secondary group is hidden.\n" "A standard cdrom mount will show as 100% full but a monitor for it\n" "could be created with mounting enabled just to have the\n" "mount/umount convenience.\n\n" ) | |||
2470 | }; | |||
2471 | ||||
2472 | static gchar *fs_info_text1[] = | |||
2473 | { | |||
2474 | N_("<h>Panel Labels\n")("<h>Panel Labels\n"), | |||
2475 | N_("Substitution variables for the format string for file system panels:\n")("Substitution variables for the format string for file system panels:\n" ), | |||
2476 | N_("\t$t total capacity\n")("\t$t total capacity\n"), | |||
2477 | N_("\t$u used space\n")("\t$u used space\n"), | |||
2478 | N_("\t$f free space\n")("\t$f free space\n"), | |||
2479 | N_("\t$U used %,\n")("\t$U used %,\n"), | |||
2480 | N_("\t$F free %\n")("\t$F free %\n"), | |||
2481 | N_("\t$l the panel label\n")("\t$l the panel label\n"), | |||
2482 | #if !defined(WIN32) | |||
2483 | N_("\t$D the mount point\n")("\t$D the mount point\n"), | |||
2484 | #else | |||
2485 | N_("\t$D the disk\n")("\t$D the disk\n"), | |||
2486 | #endif | |||
2487 | "\n", | |||
2488 | N_("Substitution variables may be used in alert commands.\n")("Substitution variables may be used in alert commands.\n"), | |||
2489 | "\n", | |||
2490 | N_("<h>Mouse Button Actions:\n")("<h>Mouse Button Actions:\n"), | |||
2491 | N_("<b>\tLeft ")("<b>\tLeft "), | |||
2492 | N_("click on a panel to scroll a programmable display\n")("click on a panel to scroll a programmable display\n"), | |||
2493 | N_("\t\tof file system capacities (default is total and free space).\n")("\t\tof file system capacities (default is total and free space).\n" ), | |||
2494 | N_("<b>\tWheel ")("<b>\tWheel "), | |||
2495 | N_("Shows and hides the secondary file system monitors.\n")("Shows and hides the secondary file system monitors.\n") | |||
2496 | }; | |||
2497 | ||||
2498 | static void | |||
2499 | fs_tab_create(GtkWidget *tab_vbox) | |||
2500 | { | |||
2501 | GtkWidget *tabs; | |||
2502 | GtkWidget *vbox, *vbox1; | |||
2503 | GtkWidget *text; | |||
2504 | gint i; | |||
2505 | ||||
2506 | row_reference = NULL((void*)0); | |||
2507 | refresh_fstab_list(); | |||
2508 | ||||
2509 | tabs = gtk_notebook_new(); | |||
2510 | gtk_notebook_set_tab_pos(GTK_NOTEBOOK(tabs)((((GtkNotebook*) g_type_check_instance_cast ((GTypeInstance* ) ((tabs)), ((gtk_notebook_get_type ())))))), GTK_POS_TOP); | |||
2511 | 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); | |||
2512 | ||||
2513 | vbox = gkrellm_gtk_framed_notebook_page(tabs, _("Panels")dcgettext ("gkrellm", "Panels", 5)); | |||
2514 | create_fs_panels_page(vbox); | |||
2515 | ||||
2516 | // vbox = gkrellm_gtk_framed_notebook_page(tabs, _("Primary")); | |||
2517 | // fill_fs_tab(vbox, &primary_widgets); | |||
2518 | ||||
2519 | // vbox = gkrellm_gtk_framed_notebook_page(tabs, _("Secondary")); | |||
2520 | // fill_fs_tab(vbox, &secondary_widgets); | |||
2521 | ||||
2522 | /* --Setup tab */ | |||
2523 | vbox = gkrellm_gtk_framed_notebook_page(tabs, _("Setup")dcgettext ("gkrellm", "Setup", 5)); | |||
2524 | ||||
2525 | vbox1 = gkrellm_gtk_category_vbox(vbox, | |||
2526 | _("Options")dcgettext ("gkrellm", "Options", 5), | |||
2527 | 4, 0, TRUE(!(0))); | |||
2528 | gkrellm_gtk_check_button_connected(vbox1, NULL((void*)0), | |||
2529 | binary_units, FALSE(0), FALSE(0), 0, | |||
2530 | cb_binary_units, NULL((void*)0), | |||
2531 | _("Use binary units (MiB, GiG) for reporting disk capacities.")dcgettext ("gkrellm", "Use binary units (MiB, GiG) for reporting disk capacities." , 5)); | |||
2532 | ||||
2533 | if (mounting_supported && ejecting_supported && !_GK.client_mode) | |||
2534 | gkrellm_gtk_check_button_connected(vbox1, NULL((void*)0), | |||
2535 | cdrom_auto_eject, FALSE(0), FALSE(0), 0, | |||
2536 | cb_auto_eject, NULL((void*)0), | |||
2537 | _("Auto eject when ejectable devices are unmounted")dcgettext ("gkrellm", "Auto eject when ejectable devices are unmounted" , 5)); | |||
2538 | ||||
2539 | if (!_GK.client_mode) | |||
2540 | { | |||
2541 | vbox1 = gkrellm_gtk_framed_vbox_end(vbox, NULL((void*)0), 4, FALSE(0), 0, 2); | |||
2542 | gkrellm_gtk_spin_button(vbox1, NULL((void*)0), | |||
2543 | (gfloat) fs_check_timeout, | |||
2544 | 2.0, 15.0, 1.0, 5.0, 0 /*digits*/, 0 /*width*/, | |||
2545 | cb_check_interval, NULL((void*)0), FALSE(0), | |||
2546 | _("Seconds between data updates for local mounted file systems")dcgettext ("gkrellm", "Seconds between data updates for local mounted file systems" , 5)); | |||
2547 | gkrellm_gtk_spin_button(vbox1, NULL((void*)0), | |||
2548 | (gfloat) nfs_check_timeout, | |||
2549 | 5.0, 60.0, 1.0, 5.0, 0, 0, | |||
2550 | cb_nfs_check_interval, NULL((void*)0), FALSE(0), | |||
2551 | _("Seconds between data updates for remote mounted file systems")dcgettext ("gkrellm", "Seconds between data updates for remote mounted file systems" , 5)); | |||
2552 | } | |||
2553 | ||||
2554 | vbox1 = gkrellm_gtk_category_vbox(vbox, | |||
2555 | _("Format String for Panel Labels")dcgettext ("gkrellm", "Format String for Panel Labels", 5), | |||
2556 | 4, 0, TRUE(!(0))); | |||
2557 | data_format_combo_box = gtk_combo_box_entry_new_text(); | |||
2558 | gtk_box_pack_start(GTK_BOX(vbox1)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((vbox1 )), ((gtk_box_get_type ())))))), data_format_combo_box, FALSE(0), FALSE(0), 2); | |||
2559 | gtk_combo_box_append_text(GTK_COMBO_BOX(data_format_combo_box)((((GtkComboBox*) g_type_check_instance_cast ((GTypeInstance* ) ((data_format_combo_box)), ((gtk_combo_box_get_type ()))))) ), data_format); | |||
2560 | gtk_combo_box_append_text(GTK_COMBO_BOX(data_format_combo_box)((((GtkComboBox*) g_type_check_instance_cast ((GTypeInstance* ) ((data_format_combo_box)), ((gtk_combo_box_get_type ()))))) ), DEFAULT_DATA_FORMAT(dcgettext ("gkrellm", "$t - $f free", 5))); | |||
2561 | gtk_combo_box_append_text(GTK_COMBO_BOX(data_format_combo_box)((((GtkComboBox*) g_type_check_instance_cast ((GTypeInstance* ) ((data_format_combo_box)), ((gtk_combo_box_get_type ()))))) ), ALT1_DATA_FORMAT(dcgettext ("gkrellm", "$t - $u used", 5))); | |||
2562 | gtk_combo_box_append_text(GTK_COMBO_BOX(data_format_combo_box)((((GtkComboBox*) g_type_check_instance_cast ((GTypeInstance* ) ((data_format_combo_box)), ((gtk_combo_box_get_type ()))))) ), ALT2_DATA_FORMAT(dcgettext ("gkrellm", "$t - $U", 5))); | |||
2563 | gtk_combo_box_set_active(GTK_COMBO_BOX(data_format_combo_box)((((GtkComboBox*) g_type_check_instance_cast ((GTypeInstance* ) ((data_format_combo_box)), ((gtk_combo_box_get_type ()))))) ), 0); | |||
2564 | g_signal_connect(G_OBJECT(GTK_COMBO_BOX(data_format_combo_box)), "changed",g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((((((GtkComboBox*) g_type_check_instance_cast ((GTypeInstance*) ((data_format_combo_box)), ((gtk_combo_box_get_type ())))))))), (((GType) ((20) << (2))))))))), ("changed" ), (((GCallback) (cb_data_format))), (((void*)0)), ((void*)0) , (GConnectFlags) 0) | |||
2565 | G_CALLBACK(cb_data_format), NULL)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((((((GtkComboBox*) g_type_check_instance_cast ((GTypeInstance*) ((data_format_combo_box)), ((gtk_combo_box_get_type ())))))))), (((GType) ((20) << (2))))))))), ("changed" ), (((GCallback) (cb_data_format))), (((void*)0)), ((void*)0) , (GConnectFlags) 0); | |||
2566 | ||||
2567 | /* --Info tab */ | |||
2568 | vbox = gkrellm_gtk_framed_notebook_page(tabs, _("Info")dcgettext ("gkrellm", "Info", 5)); | |||
2569 | text = gkrellm_gtk_scrolled_text_view(vbox, NULL((void*)0), | |||
2570 | GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | |||
2571 | if (mounting_supported && !_GK.client_mode) | |||
2572 | for (i = 0; i < sizeof(fs_info_text0)/sizeof(gchar *); ++i) | |||
2573 | gkrellm_gtk_text_view_append(text, _(fs_info_text0[i])dcgettext ("gkrellm", fs_info_text0[i], 5)); | |||
2574 | for (i = 0; i < sizeof(fs_info_text1)/sizeof(gchar *); ++i) | |||
2575 | gkrellm_gtk_text_view_append(text, _(fs_info_text1[i])dcgettext ("gkrellm", fs_info_text1[i], 5)); | |||
2576 | } | |||
2577 | ||||
2578 | ||||
2579 | ||||
2580 | static GkrellmMonitor monitor_fs = | |||
2581 | { | |||
2582 | N_("File System")("File System"), /* Name, for config tab. */ | |||
2583 | MON_FS6, /* Id, 0 if a plugin */ | |||
2584 | fs_create, /* The create function */ | |||
2585 | fs_update, /* The update function */ | |||
2586 | fs_tab_create, /* The config tab create function */ | |||
2587 | NULL((void*)0), /* Instant config */ | |||
2588 | ||||
2589 | fs_config_save, /* Save user conifg */ | |||
2590 | fs_config_load, /* Load user config */ | |||
2591 | FS_CONFIG_KEYWORD"fs", /* config keyword */ | |||
2592 | ||||
2593 | NULL((void*)0), /* Undef 2 */ | |||
2594 | NULL((void*)0), /* Undef 1 */ | |||
2595 | NULL((void*)0), /* Undef 0 */ | |||
2596 | ||||
2597 | 0, /* insert_before_id - place plugin before this mon */ | |||
2598 | ||||
2599 | NULL((void*)0), /* Handle if a plugin, filled in by GKrellM */ | |||
2600 | NULL((void*)0) /* path if a plugin, filled in by GKrellM */ | |||
2601 | }; | |||
2602 | ||||
2603 | GkrellmMonitor * | |||
2604 | gkrellm_init_fs_monitor(void) | |||
2605 | { | |||
2606 | monitor_fs.name = _(monitor_fs.name)dcgettext ("gkrellm", monitor_fs.name, 5); | |||
2607 | style_id = gkrellm_add_meter_style(&monitor_fs, FS_STYLE_NAME"fs"); | |||
2608 | gkrellm_locale_dup_string(&data_format, DEFAULT_DATA_FORMAT(dcgettext ("gkrellm", "$t - $f free", 5)), | |||
2609 | &data_format_locale); | |||
2610 | ||||
2611 | mon_fs = &monitor_fs; | |||
2612 | if (setup_fs_interface()) | |||
2613 | { | |||
2614 | refresh_fstab_list(); | |||
2615 | refresh_mounts_list(); | |||
2616 | return &monitor_fs; | |||
2617 | } | |||
2618 | return NULL((void*)0); | |||
2619 | } |