File: | baobab/src/baobab.c |
Warning: | line 1219, column 9 This statement is never executed |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* |
2 | * baobab.c |
3 | * This file is part of baobab |
4 | * |
5 | * Copyright (C) 2005-2006 Fabio Marzocca <thesaltydog@gmail.com> |
6 | * |
7 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published by |
9 | * the Free Software Foundation; either version 2 of the License, or |
10 | * (at your option) any later version. |
11 | * |
12 | * This program is distributed in the hope that it will be useful, |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * GNU General Public License for more details. |
16 | * |
17 | * You should have received a copy of the GNU General Public License |
18 | * along with this program; if not, write to the Free Software |
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, |
20 | * Boston, MA 02110-1301 USA |
21 | */ |
22 | |
23 | #include <config.h> |
24 | |
25 | #include <ctk/ctk.h> |
26 | #include <glib/gi18n.h> |
27 | #include <gio/gio.h> |
28 | #include <glibtop.h> |
29 | |
30 | #include "baobab.h" |
31 | #include "baobab-scan.h" |
32 | #include "baobab-treeview.h" |
33 | #include "baobab-utils.h" |
34 | #include "callbacks.h" |
35 | #include "baobab-prefs.h" |
36 | |
37 | #include "baobab-treemap.h" |
38 | #include "baobab-ringschart.h" |
39 | |
40 | #define BAOBAB_UI_RESOURCE"/org/cafe/disk-usage-analyzer/baobab-main-window.ui" "/org/cafe/disk-usage-analyzer/baobab-main-window.ui" |
41 | |
42 | static void push_iter_in_stack (CtkTreeIter *); |
43 | static CtkTreeIter pop_iter_from_stack (void); |
44 | |
45 | BaobabApplication baobab; |
46 | |
47 | static gint currentdepth = 0; |
48 | static CtkTreeIter currentiter; |
49 | static CtkTreeIter firstiter; |
50 | static GQueue *iterstack = NULL((void*)0); |
51 | |
52 | enum { |
53 | DND_TARGET_URI_LIST |
54 | }; |
55 | |
56 | static CtkTargetEntry dnd_target_list[] = { |
57 | { "text/uri-list", 0, DND_TARGET_URI_LIST }, |
58 | }; |
59 | |
60 | static gboolean |
61 | scan_is_local (GFile *file) |
62 | { |
63 | gchar *uri_scheme; |
64 | gboolean ret = FALSE(0); |
65 | |
66 | uri_scheme = g_file_get_uri_scheme (file); |
67 | if (g_ascii_strcasecmp(uri_scheme,"file") == 0) |
68 | ret = TRUE(!(0)); |
69 | |
70 | g_free (uri_scheme); |
71 | |
72 | return ret; |
73 | } |
74 | |
75 | void |
76 | baobab_set_busy (gboolean busy) |
77 | { |
78 | static CdkCursor *busy_cursor = NULL((void*)0); |
79 | CdkCursor *cursor = NULL((void*)0); |
80 | CdkWindow *window; |
81 | CdkDisplay *display; |
82 | |
83 | window = ctk_widget_get_window (baobab.window); |
84 | |
85 | if (busy == TRUE(!(0))) { |
86 | if (!busy_cursor && window) { |
87 | display = ctk_widget_get_display (baobab.window); |
88 | busy_cursor = cdk_cursor_new_for_display (display, CDK_WATCH); |
89 | } |
90 | cursor = busy_cursor; |
91 | |
92 | ctk_widget_show (baobab.spinner); |
93 | ctk_spinner_start (CTK_SPINNER (baobab.spinner)((((CtkSpinner*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((baobab.spinner)), ((ctk_spinner_get_type ()))))))); |
94 | |
95 | baobab_chart_freeze_updates (baobab.rings_chart); |
96 | baobab_chart_freeze_updates (baobab.treemap_chart); |
97 | |
98 | ctk_widget_set_sensitive (baobab.chart_type_combo, FALSE(0)); |
99 | } |
100 | else { |
101 | ctk_widget_hide (baobab.spinner); |
102 | ctk_spinner_stop (CTK_SPINNER (baobab.spinner)((((CtkSpinner*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((baobab.spinner)), ((ctk_spinner_get_type ()))))))); |
103 | |
104 | baobab_chart_thaw_updates (baobab.rings_chart); |
105 | baobab_chart_thaw_updates (baobab.treemap_chart); |
106 | |
107 | ctk_widget_set_sensitive (baobab.chart_type_combo, TRUE(!(0))); |
108 | } |
109 | |
110 | /* change the cursor */ |
111 | if (window) { |
112 | cdk_window_set_cursor (window, cursor); |
113 | } |
114 | } |
115 | |
116 | static void |
117 | set_drop_target (CtkWidget *target, gboolean active) { |
118 | if (active) { |
119 | ctk_drag_dest_set (CTK_WIDGET (target)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((target)), ((ctk_widget_get_type ())))))), |
120 | CTK_DEST_DEFAULT_DROP | CTK_DEST_DEFAULT_MOTION | CTK_DEST_DEFAULT_HIGHLIGHT, |
121 | dnd_target_list, |
122 | G_N_ELEMENTS (dnd_target_list)(sizeof (dnd_target_list) / sizeof ((dnd_target_list)[0])), |
123 | CDK_ACTION_COPY); |
124 | } else { |
125 | ctk_drag_dest_unset (target); |
126 | } |
127 | } |
128 | |
129 | /* menu & toolbar sensitivity */ |
130 | static void |
131 | check_menu_sens (gboolean scanning) |
132 | { |
133 | gboolean has_current_location; |
134 | |
135 | if (scanning) { |
136 | while (ctk_events_pending ()) |
137 | ctk_main_iteration (); |
138 | |
139 | baobab_set_statusbar (_("Scanning...")gettext ("Scanning...")); |
140 | set_ui_action_sens ("expand_all", TRUE(!(0))); |
141 | set_ui_action_sens ("collapse_all", TRUE(!(0))); |
142 | } |
143 | |
144 | has_current_location = baobab.current_location != NULL((void*)0); |
145 | |
146 | set_ui_action_sens ("menuscanhome", !scanning); |
147 | set_ui_action_sens ("menuallfs", !scanning); |
148 | set_ui_action_sens ("menuscandir", !scanning); |
149 | set_ui_action_sens ("menustop", scanning); |
150 | set_ui_action_sens ("menurescan", !scanning && has_current_location); |
151 | set_ui_action_sens ("preferenze1", !scanning); |
152 | set_ui_action_sens ("menu_scan_rem", !scanning); |
153 | set_ui_action_sens ("ck_allocated", !scanning && baobab.is_local); |
154 | |
155 | set_ui_widget_sens ("tbscanhome", !scanning); |
156 | set_ui_widget_sens ("tbscanall", !scanning); |
157 | set_ui_widget_sens ("tbscandir", !scanning); |
158 | set_ui_widget_sens ("tbstop", scanning); |
159 | set_ui_widget_sens ("tbrescan", !scanning && has_current_location); |
160 | set_ui_widget_sens ("tb_scan_remote", !scanning); |
161 | } |
162 | |
163 | static void |
164 | check_drop_targets (gboolean scanning) |
165 | { |
166 | set_drop_target (baobab.rings_chart, !scanning); |
167 | set_drop_target (baobab.treemap_chart, !scanning); |
168 | } |
169 | |
170 | static void |
171 | update_scan_label (void) |
172 | { |
173 | gchar *markup; |
174 | gchar *total; |
175 | gchar *used; |
176 | gchar *available; |
177 | CtkWidget *label; |
178 | |
179 | total = g_format_size (baobab.fs.total); |
180 | used = g_format_size (baobab.fs.used); |
181 | available = g_format_size (baobab.fs.avail); |
182 | |
183 | /* Translators: these are labels for disk space */ |
184 | markup = g_markup_printf_escaped ("<small>%s <b>%s</b> (%s %s %s %s)</small>", |
185 | _("Total filesystem capacity:")gettext ("Total filesystem capacity:"), total, |
186 | _("used:")gettext ("used:"), used, |
187 | _("available:")gettext ("available:"), available); |
188 | |
189 | g_free (total); |
190 | g_free (used); |
191 | g_free (available); |
192 | |
193 | label = CTK_WIDGET (ctk_builder_get_object (baobab.main_ui, "label1"))((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_builder_get_object (baobab.main_ui, "label1"))), ((ctk_widget_get_type ())))))); |
194 | |
195 | ctk_label_set_markup (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), ((ctk_label_get_type ())))))), markup); |
196 | g_free (markup); |
197 | } |
198 | |
199 | void |
200 | baobab_update_filesystem (void) |
201 | { |
202 | baobab_get_filesystem (&baobab.fs); |
203 | update_scan_label (); |
204 | } |
205 | |
206 | void |
207 | baobab_scan_location (GFile *file) |
208 | { |
209 | CtkToggleAction *ck_allocated; |
210 | |
211 | if (!baobab_check_dir (file)) |
212 | return; |
213 | |
214 | if (iterstack !=NULL((void*)0)) |
215 | return; |
216 | |
217 | if (baobab.current_location) |
218 | g_object_unref (baobab.current_location); |
219 | baobab.current_location = g_object_ref (file)((__typeof__ (file)) (g_object_ref) (file)); |
220 | |
221 | baobab.STOP_SCANNING = FALSE(0); |
222 | baobab_set_busy (TRUE(!(0))); |
223 | check_menu_sens (TRUE(!(0))); |
224 | check_drop_targets (TRUE(!(0))); |
225 | ctk_tree_store_clear (baobab.model); |
226 | currentdepth = -1; /* flag */ |
227 | iterstack = g_queue_new (); |
228 | |
229 | /* check if the file system is local or remote */ |
230 | baobab.is_local = scan_is_local (file); |
231 | ck_allocated = CTK_TOGGLE_ACTION (ctk_builder_get_object (baobab.main_ui, "ck_allocated"))((((CtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_builder_get_object (baobab.main_ui, "ck_allocated")) ), ((ctk_toggle_action_get_type ())))))); |
232 | if (!baobab.is_local) { |
233 | ctk_toggle_action_set_active (ck_allocated, FALSE(0)); |
234 | ctk_action_set_sensitive (CTK_ACTION (ck_allocated)((((CtkAction*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ck_allocated)), ((ctk_action_get_type ())))))), FALSE(0)); |
235 | baobab.show_allocated = FALSE(0); |
236 | } |
237 | else { |
238 | ctk_action_set_sensitive (CTK_ACTION (ck_allocated)((((CtkAction*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ck_allocated)), ((ctk_action_get_type ())))))), TRUE(!(0))); |
239 | } |
240 | |
241 | baobab_scan_execute (file); |
242 | |
243 | /* set statusbar, percentage and allocated/normal size */ |
244 | baobab_set_statusbar (_("Calculating percentage bars...")gettext ("Calculating percentage bars...")); |
245 | ctk_tree_model_foreach (CTK_TREE_MODEL (baobab.model)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((baobab.model)), ((ctk_tree_model_get_type ())))))), |
246 | show_bars, |
247 | NULL((void*)0)); |
248 | |
249 | baobab_chart_set_max_depth (baobab.rings_chart, baobab.model_max_depth); |
250 | baobab_chart_set_max_depth (baobab.treemap_chart, baobab.model_max_depth); |
251 | |
252 | baobab_set_busy (FALSE(0)); |
253 | check_menu_sens (FALSE(0)); |
254 | check_drop_targets (FALSE(0)); |
255 | baobab_set_statusbar (_("Ready")gettext ("Ready")); |
256 | |
257 | ctk_tree_view_columns_autosize (CTK_TREE_VIEW (baobab.tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((baobab.tree_view)), ((ctk_tree_view_get_type ()))))))); |
258 | baobab.STOP_SCANNING = TRUE(!(0)); |
259 | g_queue_free (iterstack); |
260 | iterstack = NULL((void*)0); |
261 | baobab.CONTENTS_CHANGED_DELAYED = FALSE(0); |
262 | } |
263 | |
264 | void |
265 | baobab_scan_home (void) |
266 | { |
267 | GFile *file; |
268 | |
269 | file = g_file_new_for_path (g_get_home_dir ()); |
270 | baobab_scan_location (file); |
271 | g_object_unref (file); |
272 | } |
273 | |
274 | void |
275 | baobab_scan_root (void) |
276 | { |
277 | GFile *file; |
278 | |
279 | file = g_file_new_for_uri ("file:///"); |
280 | baobab_scan_location (file); |
281 | g_object_unref (file); |
282 | } |
283 | |
284 | void |
285 | baobab_rescan_current_dir (void) |
286 | { |
287 | g_return_if_fail (baobab.current_location != NULL)do { if ((baobab.current_location != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "baobab.current_location != NULL" ); return; } } while (0); |
288 | |
289 | baobab_update_filesystem (); |
290 | |
291 | g_object_ref (baobab.current_location)((__typeof__ (baobab.current_location)) (g_object_ref) (baobab .current_location)); |
292 | baobab_scan_location (baobab.current_location); |
293 | g_object_unref (baobab.current_location); |
294 | } |
295 | |
296 | void |
297 | baobab_stop_scan (void) |
298 | { |
299 | baobab.STOP_SCANNING = TRUE(!(0)); |
300 | |
301 | baobab_set_statusbar (_("Calculating percentage bars...")gettext ("Calculating percentage bars...")); |
302 | ctk_tree_model_foreach (CTK_TREE_MODEL (baobab.model)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((baobab.model)), ((ctk_tree_model_get_type ())))))), |
303 | show_bars, NULL((void*)0)); |
304 | ctk_tree_view_columns_autosize (CTK_TREE_VIEW (baobab.tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((baobab.tree_view)), ((ctk_tree_view_get_type ()))))))); |
305 | } |
306 | |
307 | /* |
308 | * pre-fills model during scanning |
309 | */ |
310 | static void |
311 | prefill_model (struct chan_data *data) |
312 | { |
313 | CtkTreeIter iter, iterparent; |
314 | char *name; |
315 | char *str; |
316 | |
317 | if (currentdepth == -1) { |
318 | ctk_tree_store_append (baobab.model, &iter, NULL((void*)0)); |
319 | firstiter = iter; |
320 | } |
321 | else if (data->depth == 1) { |
322 | CtkTreePath *path; |
323 | |
324 | ctk_tree_store_append (baobab.model, &iter, &firstiter); |
325 | path = ctk_tree_model_get_path (CTK_TREE_MODEL (baobab.model)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((baobab.model)), ((ctk_tree_model_get_type ())))))), |
326 | &firstiter); |
327 | ctk_tree_view_expand_row (CTK_TREE_VIEW (baobab.tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((baobab.tree_view)), ((ctk_tree_view_get_type ())))))), |
328 | path, FALSE(0)); |
329 | ctk_tree_path_free (path); |
330 | } |
331 | else if (data->depth > currentdepth) { |
332 | ctk_tree_store_append (baobab.model, &iter, ¤titer); |
333 | } |
334 | else if (data->depth == currentdepth) { |
335 | ctk_tree_model_iter_parent ((CtkTreeModel *) baobab.model, |
336 | &iterparent, ¤titer); |
337 | ctk_tree_store_append (baobab.model, &iter, &iterparent); |
338 | } |
339 | else if (data->depth < currentdepth) { |
340 | CtkTreeIter tempiter; |
341 | gint i; |
342 | iter = currentiter; |
343 | for (i = 0; i <= (currentdepth - data->depth); i++) { |
344 | ctk_tree_model_iter_parent ((CtkTreeModel *) |
345 | baobab.model, |
346 | &tempiter, &iter); |
347 | iter = tempiter; |
348 | } |
349 | ctk_tree_store_append (baobab.model, &iter, &tempiter); |
350 | } |
351 | |
352 | currentdepth = data->depth; |
353 | push_iter_in_stack (&iter); |
354 | currentiter = iter; |
355 | |
356 | /* in case filenames contains gmarkup */ |
357 | name = g_markup_escape_text (data->display_name, -1); |
358 | |
359 | str = g_strdup_printf ("<small><i>%s</i></small>", _("Scanning...")gettext ("Scanning...")); |
360 | |
361 | ctk_tree_view_set_headers_visible (CTK_TREE_VIEW (baobab.tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((baobab.tree_view)), ((ctk_tree_view_get_type ())))))), TRUE(!(0))); |
362 | ctk_tree_store_set (baobab.model, &iter, |
363 | COL_DIR_NAME, name, |
364 | COL_H_PARSENAME, "", |
365 | COL_H_ELEMENTS, -1, |
366 | COL_H_PERC, -1.0, |
367 | COL_DIR_SIZE, str, |
368 | COL_ELEMENTS, str, -1); |
369 | |
370 | g_free (name); |
371 | g_free (str); |
372 | |
373 | while (ctk_events_pending ()) { |
374 | ctk_main_iteration (); |
375 | } |
376 | } |
377 | |
378 | static void |
379 | first_row (void) |
380 | { |
381 | char *size; |
382 | gdouble perc; |
383 | char *label; |
384 | |
385 | CtkTreeIter root_iter; |
386 | |
387 | gchar *capacity_label, *capacity_size; |
388 | |
389 | ctk_tree_store_append (baobab.model, &root_iter, NULL((void*)0)); |
390 | |
391 | capacity_size = g_format_size (baobab.fs.total); |
392 | |
393 | capacity_label = g_strdup (_("Total filesystem capacity"))g_strdup_inline (gettext ("Total filesystem capacity")); |
394 | ctk_tree_store_set (baobab.model, &root_iter, |
395 | COL_DIR_NAME, capacity_label, |
396 | COL_H_PARSENAME, "", |
397 | COL_H_PERC, 100.0, |
398 | COL_DIR_SIZE, capacity_size, |
399 | COL_H_SIZE, baobab.fs.total, |
400 | COL_H_ALLOCSIZE, baobab.fs.total, |
401 | COL_H_ELEMENTS, -1, -1); |
402 | g_free (capacity_label); |
403 | g_free (capacity_size); |
404 | |
405 | ctk_tree_view_set_headers_visible (CTK_TREE_VIEW (baobab.tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((baobab.tree_view)), ((ctk_tree_view_get_type ())))))), FALSE(0)); |
406 | ctk_tree_store_append (baobab.model, &firstiter, &root_iter); |
407 | |
408 | size = g_format_size (baobab.fs.used); |
409 | |
410 | if (baobab.fs.total == 0 && baobab.fs.used == 0) { |
411 | perc = 100.0; |
412 | } else { |
413 | g_assert (baobab.fs.total != 0)do { if (baobab.fs.total != 0) ; else g_assertion_message_expr (((gchar*) 0), "baobab.c", 413, ((const char*) (__func__)), "baobab.fs.total != 0" ); } while (0); |
414 | perc = ((gdouble) baobab.fs.used * 100) / (gdouble) baobab.fs.total; |
415 | } |
416 | |
417 | label = g_strdup (_("Total filesystem usage"))g_strdup_inline (gettext ("Total filesystem usage")); |
418 | ctk_tree_store_set (baobab.model, &firstiter, |
419 | COL_DIR_NAME, label, |
420 | COL_H_PARSENAME, "", |
421 | COL_H_PERC, perc, |
422 | COL_DIR_SIZE, size, |
423 | COL_H_SIZE, baobab.fs.used, |
424 | COL_H_ALLOCSIZE, baobab.fs.used, |
425 | COL_H_ELEMENTS, -1, -1); |
426 | |
427 | g_free (size); |
428 | g_free (label); |
429 | |
430 | ctk_tree_view_expand_all (CTK_TREE_VIEW (baobab.tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((baobab.tree_view)), ((ctk_tree_view_get_type ()))))))); |
431 | } |
432 | |
433 | /* fills model during scanning */ |
434 | void |
435 | baobab_fill_model (struct chan_data *data) |
436 | { |
437 | CtkTreeIter iter; |
438 | GString *hardlinks; |
439 | GString *elements; |
440 | char *name; |
441 | char *size; |
442 | char *alloc_size; |
443 | |
444 | if (data->elements == -1) { |
445 | prefill_model (data); |
446 | return; |
447 | } |
448 | |
449 | iter = pop_iter_from_stack (); |
450 | |
451 | /* in case filenames contains gmarkup */ |
452 | name = g_markup_escape_text (data->display_name, -1); |
453 | |
454 | hardlinks = g_string_new (""); |
455 | if (data->tempHLsize > 0) { |
456 | size = g_format_size (data->tempHLsize); |
457 | |
458 | g_string_assign (hardlinks, "<i>("); |
459 | g_string_append (hardlinks, _("contains hardlinks for:"))(__builtin_constant_p (gettext ("contains hardlinks for:")) ? __extension__ ({ const char * const __val = (gettext ("contains hardlinks for:" )); g_string_append_len_inline (hardlinks, __val, (__val != ( (void*)0)) ? (gssize) strlen (((__val) + !(__val))) : (gssize ) -1); }) : g_string_append_len_inline (hardlinks, gettext ("contains hardlinks for:" ), (gssize) -1)); |
460 | g_string_append (hardlinks, " ")(__builtin_constant_p (" ") ? __extension__ ({ const char * const __val = (" "); g_string_append_len_inline (hardlinks, __val, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val) )) : (gssize) -1); }) : g_string_append_len_inline (hardlinks , " ", (gssize) -1)); |
461 | g_string_append (hardlinks, size)(__builtin_constant_p (size) ? __extension__ ({ const char * const __val = (size); g_string_append_len_inline (hardlinks, __val , (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val ))) : (gssize) -1); }) : g_string_append_len_inline (hardlinks , size, (gssize) -1)); |
462 | g_string_append (hardlinks, ")</i>")(__builtin_constant_p (")</i>") ? __extension__ ({ const char * const __val = (")</i>"); g_string_append_len_inline (hardlinks, __val, (__val != ((void*)0)) ? (gssize) strlen ( ((__val) + !(__val))) : (gssize) -1); }) : g_string_append_len_inline (hardlinks, ")</i>", (gssize) -1)); |
463 | g_free (size); |
464 | } |
465 | |
466 | elements = g_string_new (""); |
467 | g_string_printf (elements, |
468 | ngettext ("%5d item", "%5d items", |
469 | data->elements), data->elements); |
470 | |
471 | size = g_format_size (data->size); |
472 | alloc_size = g_format_size (data->alloc_size); |
473 | |
474 | ctk_tree_store_set (baobab.model, &iter, |
475 | COL_DIR_NAME, name, |
476 | COL_H_PARSENAME, data->parse_name, |
477 | COL_H_PERC, -1.0, |
478 | COL_DIR_SIZE, |
479 | baobab.show_allocated ? alloc_size : size, |
480 | COL_H_SIZE, data->size, |
481 | COL_ELEMENTS, elements->str, |
482 | COL_H_ELEMENTS, data->elements, |
483 | COL_HARDLINK, hardlinks->str, |
484 | COL_H_HARDLINK, data->tempHLsize, |
485 | COL_H_ALLOCSIZE, data->alloc_size, -1); |
486 | |
487 | while (ctk_events_pending ()) { |
488 | ctk_main_iteration (); |
489 | } |
490 | |
491 | g_string_free (hardlinks, TRUE)(__builtin_constant_p ((!(0))) ? (((!(0))) ? (g_string_free) ( (hardlinks), ((!(0)))) : g_string_free_and_steal (hardlinks)) : (g_string_free) ((hardlinks), ((!(0))))); |
492 | g_string_free (elements, TRUE)(__builtin_constant_p ((!(0))) ? (((!(0))) ? (g_string_free) ( (elements), ((!(0)))) : g_string_free_and_steal (elements)) : (g_string_free) ((elements), ((!(0))))); |
493 | g_free (name); |
494 | g_free (size); |
495 | g_free (alloc_size); |
496 | } |
497 | |
498 | void |
499 | push_iter_in_stack (CtkTreeIter *iter) |
500 | { |
501 | g_queue_push_head (iterstack, iter->user_data3); |
502 | g_queue_push_head (iterstack, iter->user_data2); |
503 | g_queue_push_head (iterstack, iter->user_data); |
504 | g_queue_push_head (iterstack, GINT_TO_POINTER (iter->stamp)((gpointer) (glong) (iter->stamp))); |
505 | } |
506 | |
507 | CtkTreeIter |
508 | pop_iter_from_stack (void) |
509 | { |
510 | CtkTreeIter iter; |
511 | |
512 | iter.stamp = GPOINTER_TO_INT (g_queue_pop_head (iterstack))((gint) (glong) (g_queue_pop_head (iterstack))); |
513 | iter.user_data = g_queue_pop_head (iterstack); |
514 | iter.user_data2 = g_queue_pop_head (iterstack); |
515 | iter.user_data3 = g_queue_pop_head (iterstack); |
516 | |
517 | return iter; |
518 | } |
519 | |
520 | gboolean |
521 | baobab_is_excluded_location (GFile *file) |
522 | { |
523 | gboolean ret = FALSE(0); |
524 | GSList *l; |
525 | |
526 | g_return_val_if_fail (file != NULL, FALSE)do { if ((file != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "file != NULL"); return ((0)); } } while (0); |
527 | |
528 | for (l = baobab.excluded_locations; l != NULL((void*)0); l = l->next) { |
529 | if (g_file_equal (l->data, file)) { |
530 | ret = TRUE(!(0)); |
531 | break; |
532 | } |
533 | } |
534 | |
535 | return ret; |
536 | } |
537 | |
538 | static void |
539 | volume_changed (GVolumeMonitor *volume_monitor, |
540 | GVolume *volume, |
541 | gpointer user_data) |
542 | { |
543 | /* filesystem has changed (mounted or unmounted device) */ |
544 | baobab_update_filesystem (); |
545 | } |
546 | |
547 | static void |
548 | home_contents_changed (GFileMonitor *file_monitor, |
549 | GFile *child, |
550 | GFile *other_file, |
551 | GFileMonitorEvent event_type, |
552 | gpointer user_data) |
553 | |
554 | { |
555 | gchar *excluding; |
556 | |
557 | if (baobab.CONTENTS_CHANGED_DELAYED) |
558 | return; |
559 | |
560 | excluding = g_file_get_basename (child); |
561 | if (strcmp (excluding, ".recently-used") == 0 || |
562 | strcmp (excluding, ".cafe2_private") == 0 || |
563 | strcmp (excluding, ".xsession-errors") == 0 || |
564 | strcmp (excluding, ".bash_history") == 0) { |
565 | g_free (excluding); |
566 | return; |
567 | } |
568 | g_free (excluding); |
569 | |
570 | baobab.CONTENTS_CHANGED_DELAYED = TRUE(!(0)); |
571 | } |
572 | |
573 | static void |
574 | monitor_volume (void) |
575 | { |
576 | baobab.monitor_vol = g_volume_monitor_get (); |
577 | |
578 | g_signal_connect (baobab.monitor_vol, "volume_changed",g_signal_connect_data ((baobab.monitor_vol), ("volume_changed" ), (((GCallback) (volume_changed))), (((void*)0)), ((void*)0) , (GConnectFlags) 0) |
579 | G_CALLBACK (volume_changed), NULL)g_signal_connect_data ((baobab.monitor_vol), ("volume_changed" ), (((GCallback) (volume_changed))), (((void*)0)), ((void*)0) , (GConnectFlags) 0); |
580 | } |
581 | |
582 | static void |
583 | monitor_home (gboolean enable) |
584 | { |
585 | if (enable && baobab.monitor_home == NULL((void*)0)) { |
586 | GFile *file; |
587 | GError *error = NULL((void*)0); |
588 | |
589 | file = g_file_new_for_path (g_get_home_dir ()); |
590 | baobab.monitor_home = g_file_monitor_directory (file, 0, NULL((void*)0), &error); |
591 | g_object_unref (file); |
592 | |
593 | if (!baobab.monitor_home) { |
594 | message (_("Could not initialize monitoring")gettext ("Could not initialize monitoring"), |
595 | _("Changes to your home folder will not be monitored.")gettext ("Changes to your home folder will not be monitored." ), |
596 | CTK_MESSAGE_WARNING, NULL((void*)0)); |
597 | g_print ("homedir:%s\n", error->message); |
598 | g_error_free (error); |
599 | } |
600 | else { |
601 | g_signal_connect (baobab.monitor_home,g_signal_connect_data ((baobab.monitor_home), ("changed"), (( (GCallback) (home_contents_changed))), (((void*)0)), ((void*) 0), (GConnectFlags) 0) |
602 | "changed",g_signal_connect_data ((baobab.monitor_home), ("changed"), (( (GCallback) (home_contents_changed))), (((void*)0)), ((void*) 0), (GConnectFlags) 0) |
603 | G_CALLBACK (home_contents_changed),g_signal_connect_data ((baobab.monitor_home), ("changed"), (( (GCallback) (home_contents_changed))), (((void*)0)), ((void*) 0), (GConnectFlags) 0) |
604 | NULL)g_signal_connect_data ((baobab.monitor_home), ("changed"), (( (GCallback) (home_contents_changed))), (((void*)0)), ((void*) 0), (GConnectFlags) 0); |
605 | } |
606 | } |
607 | else if (!enable && baobab.monitor_home != NULL((void*)0)) { |
608 | g_file_monitor_cancel (baobab.monitor_home); |
609 | g_object_unref (baobab.monitor_home); |
610 | baobab.monitor_home = NULL((void*)0); |
611 | } |
612 | } |
613 | |
614 | void |
615 | baobab_set_statusbar (const gchar *text) |
616 | { |
617 | ctk_statusbar_pop (CTK_STATUSBAR (baobab.statusbar)((((CtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((baobab.statusbar)), ((ctk_statusbar_get_type ())))))), 1); |
618 | ctk_statusbar_push (CTK_STATUSBAR (baobab.statusbar)((((CtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((baobab.statusbar)), ((ctk_statusbar_get_type ())))))), 1, text); |
619 | |
620 | while (ctk_events_pending ()) |
621 | ctk_main_iteration (); |
622 | } |
623 | |
624 | static void |
625 | toolbar_reconfigured_cb (CtkToolItem *item, |
626 | CtkWidget *spinner) |
627 | { |
628 | CtkToolbarStyle style; |
629 | CtkIconSize size; |
630 | |
631 | style = ctk_tool_item_get_toolbar_style (item); |
632 | |
633 | if (style == CTK_TOOLBAR_BOTH) |
634 | { |
635 | size = CTK_ICON_SIZE_DIALOG; |
636 | } |
637 | else |
638 | { |
639 | size = CTK_ICON_SIZE_LARGE_TOOLBAR; |
640 | } |
641 | |
642 | ctk_widget_set_size_request (spinner, size, size); |
643 | } |
644 | |
645 | static void |
646 | baobab_create_toolbar (void) |
647 | { |
648 | CtkWidget *toolbar; |
649 | CtkToolItem *item; |
650 | CtkToolItem *separator; |
651 | |
652 | toolbar = CTK_WIDGET (ctk_builder_get_object (baobab.main_ui, "toolbar1"))((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_builder_get_object (baobab.main_ui, "toolbar1"))), ( (ctk_widget_get_type ())))))); |
653 | if (toolbar == NULL((void*)0)) { |
654 | g_printerr ("Could not build toolbar\n"); |
655 | return; |
656 | } |
657 | |
658 | baobab.toolbar = toolbar; |
659 | |
660 | separator = ctk_separator_tool_item_new (); |
661 | ctk_separator_tool_item_set_draw (CTK_SEPARATOR_TOOL_ITEM (separator)((((CtkSeparatorToolItem*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((separator)), ((ctk_separator_tool_item_get_type ())))))), FALSE(0)); |
662 | ctk_tool_item_set_expand (CTK_TOOL_ITEM (separator)((((CtkToolItem*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((separator)), ((ctk_tool_item_get_type ())))))), TRUE(!(0))); |
663 | ctk_container_add (CTK_CONTAINER (toolbar)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((toolbar)), ((ctk_container_get_type ())))))), CTK_WIDGET (separator)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((separator)), ((ctk_widget_get_type ()))))))); |
664 | ctk_widget_show (CTK_WIDGET (separator)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((separator)), ((ctk_widget_get_type ()))))))); |
665 | |
666 | baobab.spinner = ctk_spinner_new (); |
667 | item = ctk_tool_item_new (); |
668 | ctk_container_add (CTK_CONTAINER (item)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), ((ctk_container_get_type ())))))), baobab.spinner); |
669 | ctk_container_add (CTK_CONTAINER (toolbar)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((toolbar)), ((ctk_container_get_type ())))))), CTK_WIDGET (item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), ((ctk_widget_get_type ()))))))); |
670 | ctk_widget_show (CTK_WIDGET (item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), ((ctk_widget_get_type ()))))))); |
671 | |
672 | g_signal_connect (item, "toolbar-reconfigured",g_signal_connect_data ((item), ("toolbar-reconfigured"), (((GCallback ) (toolbar_reconfigured_cb))), (baobab.spinner), ((void*)0), ( GConnectFlags) 0) |
673 | G_CALLBACK (toolbar_reconfigured_cb), baobab.spinner)g_signal_connect_data ((item), ("toolbar-reconfigured"), (((GCallback ) (toolbar_reconfigured_cb))), (baobab.spinner), ((void*)0), ( GConnectFlags) 0); |
674 | toolbar_reconfigured_cb (item, baobab.spinner); |
675 | |
676 | g_settings_bind (baobab.ui_settings, |
677 | BAOBAB_SETTINGS_TOOLBAR_VISIBLE"toolbar-visible", |
678 | baobab.toolbar, "visible", |
679 | G_SETTINGS_BIND_DEFAULT); |
680 | g_settings_bind (baobab.ui_settings, |
681 | BAOBAB_SETTINGS_TOOLBAR_VISIBLE"toolbar-visible", |
682 | CTK_TOGGLE_ACTION (ctk_builder_get_object (baobab.main_ui, "view_tb"))((((CtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_builder_get_object (baobab.main_ui, "view_tb"))), (( ctk_toggle_action_get_type ())))))), "active", |
683 | G_SETTINGS_BIND_DEFAULT); |
684 | |
685 | } |
686 | |
687 | static void |
688 | baobab_create_statusbar (void) |
689 | { |
690 | baobab.statusbar = CTK_WIDGET (ctk_builder_get_object (baobab.main_ui,((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_builder_get_object (baobab.main_ui, "statusbar1"))), ((ctk_widget_get_type ())))))) |
691 | "statusbar1"))((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_builder_get_object (baobab.main_ui, "statusbar1"))), ((ctk_widget_get_type ())))))); |
692 | if (baobab.statusbar == NULL((void*)0)) { |
693 | g_printerr ("Could not build statusbar\n"); |
694 | return; |
695 | } |
696 | |
697 | g_settings_bind (baobab.ui_settings, |
698 | BAOBAB_SETTINGS_STATUSBAR_VISIBLE"statusbar-visible", |
699 | baobab.statusbar, "visible", |
700 | G_SETTINGS_BIND_DEFAULT); |
701 | g_settings_bind (baobab.ui_settings, |
702 | BAOBAB_SETTINGS_STATUSBAR_VISIBLE"statusbar-visible", |
703 | CTK_TOGGLE_ACTION (ctk_builder_get_object (baobab.main_ui, "view_sb"))((((CtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_builder_get_object (baobab.main_ui, "view_sb"))), (( ctk_toggle_action_get_type ())))))), "active", |
704 | G_SETTINGS_BIND_DEFAULT); |
705 | } |
706 | |
707 | static void |
708 | baobab_settings_subfoldertips_changed (GSettings *settings, |
709 | const gchar *key, |
710 | gpointer user_data) |
711 | { |
712 | gboolean visible; |
713 | |
714 | visible = g_settings_get_boolean (settings, key); |
715 | baobab_ringschart_set_subfoldertips_enabled (baobab.rings_chart, visible); |
716 | } |
717 | |
718 | static void |
719 | baobab_set_excluded_locations (gchar **uris) |
720 | { |
721 | gint i; |
722 | |
723 | g_slist_free_full (baobab.excluded_locations, g_object_unref); |
724 | baobab.excluded_locations = NULL((void*)0); |
725 | for (i = 0; uris[i] != NULL((void*)0); ++i) { |
726 | baobab.excluded_locations = g_slist_prepend (baobab.excluded_locations, |
727 | g_file_new_for_uri (uris[i])); |
728 | } |
729 | } |
730 | |
731 | static void |
732 | store_excluded_locations (void) |
733 | { |
734 | GSList *l; |
735 | GPtrArray *uris; |
736 | GSList *uri_list = NULL((void*)0); |
737 | |
738 | uris = g_ptr_array_new (); |
739 | |
740 | for (l = baobab.excluded_locations; l != NULL((void*)0); l = l->next) { |
741 | g_ptr_array_add (uris, g_file_get_uri (l->data)); |
742 | } |
743 | |
744 | g_ptr_array_add (uris, NULL((void*)0)); |
745 | |
746 | g_settings_set_strv (baobab.prefs_settings, |
747 | BAOBAB_SETTINGS_EXCLUDED_URIS"excluded-uris", |
748 | (const gchar *const *) uris->pdata); |
749 | |
750 | g_ptr_array_free (uris, TRUE(!(0))); |
751 | } |
752 | |
753 | static void |
754 | sanity_check_excluded_locations (void) |
755 | { |
756 | GFile *root; |
757 | GSList *l; |
758 | |
759 | /* Make sure the root dir is not excluded */ |
760 | root = g_file_new_for_uri ("file:///"); |
761 | |
762 | for (l = baobab.excluded_locations; l != NULL((void*)0); l = l->next) { |
763 | if (g_file_equal (l->data, root)) { |
764 | baobab.excluded_locations = g_slist_delete_link (baobab.excluded_locations, l); |
765 | store_excluded_locations (); |
766 | break; |
767 | } |
768 | } |
769 | |
770 | g_object_unref (root); |
771 | } |
772 | |
773 | static void |
774 | excluded_uris_changed (GSettings *settings, |
775 | const gchar *key, |
776 | gpointer user_data) |
777 | { |
778 | gchar **uris; |
779 | |
780 | uris = g_settings_get_strv (settings, key); |
781 | baobab_set_excluded_locations (uris); |
782 | g_strfreev (uris); |
783 | |
784 | baobab_update_filesystem (); |
785 | |
786 | ctk_tree_store_clear (baobab.model); |
787 | first_row (); |
788 | } |
789 | |
790 | static void |
791 | baobab_setup_excluded_locations (void) |
792 | { |
793 | gchar **uris; |
794 | |
795 | g_signal_connect (baobab.prefs_settings,g_signal_connect_data ((baobab.prefs_settings), ("changed::" "excluded-uris" ), (((GCallback) (excluded_uris_changed))), (((void*)0)), ((void *)0), (GConnectFlags) 0) |
796 | "changed::" BAOBAB_SETTINGS_EXCLUDED_URIS,g_signal_connect_data ((baobab.prefs_settings), ("changed::" "excluded-uris" ), (((GCallback) (excluded_uris_changed))), (((void*)0)), ((void *)0), (GConnectFlags) 0) |
797 | G_CALLBACK (excluded_uris_changed),g_signal_connect_data ((baobab.prefs_settings), ("changed::" "excluded-uris" ), (((GCallback) (excluded_uris_changed))), (((void*)0)), ((void *)0), (GConnectFlags) 0) |
798 | NULL)g_signal_connect_data ((baobab.prefs_settings), ("changed::" "excluded-uris" ), (((GCallback) (excluded_uris_changed))), (((void*)0)), ((void *)0), (GConnectFlags) 0); |
799 | |
800 | uris = g_settings_get_strv (baobab.prefs_settings, |
801 | BAOBAB_SETTINGS_EXCLUDED_URIS"excluded-uris"); |
802 | baobab_set_excluded_locations (uris); |
803 | g_strfreev (uris); |
804 | |
805 | sanity_check_excluded_locations (); |
806 | } |
807 | |
808 | static void |
809 | baobab_settings_monitor_home_changed (GSettings *settings, |
810 | const gchar *key, |
811 | gpointer user_data) |
812 | { |
813 | gboolean enable; |
814 | |
815 | enable = g_settings_get_boolean (settings, key); |
816 | |
817 | monitor_home (enable); |
818 | } |
819 | |
820 | static void |
821 | baobab_setup_monitors (void) |
822 | { |
823 | gboolean enable; |
824 | |
825 | monitor_volume (); |
826 | |
827 | g_signal_connect (baobab.prefs_settings,g_signal_connect_data ((baobab.prefs_settings), ("changed::" "monitor-home" ), (((GCallback) (baobab_settings_monitor_home_changed))), (( (void*)0)), ((void*)0), (GConnectFlags) 0) |
828 | "changed::" BAOBAB_SETTINGS_MONITOR_HOME,g_signal_connect_data ((baobab.prefs_settings), ("changed::" "monitor-home" ), (((GCallback) (baobab_settings_monitor_home_changed))), (( (void*)0)), ((void*)0), (GConnectFlags) 0) |
829 | G_CALLBACK (baobab_settings_monitor_home_changed),g_signal_connect_data ((baobab.prefs_settings), ("changed::" "monitor-home" ), (((GCallback) (baobab_settings_monitor_home_changed))), (( (void*)0)), ((void*)0), (GConnectFlags) 0) |
830 | NULL)g_signal_connect_data ((baobab.prefs_settings), ("changed::" "monitor-home" ), (((GCallback) (baobab_settings_monitor_home_changed))), (( (void*)0)), ((void*)0), (GConnectFlags) 0); |
831 | |
832 | enable = g_settings_get_boolean (baobab.prefs_settings, |
833 | BAOBAB_SETTINGS_MONITOR_HOME"monitor-home"); |
834 | |
835 | monitor_home (enable); |
836 | } |
837 | |
838 | static void |
839 | baobab_init (void) |
840 | { |
841 | GError *error = NULL((void*)0); |
842 | |
843 | /* FileSystem usage */ |
844 | baobab_get_filesystem (&baobab.fs); |
845 | |
846 | /* Load the UI */ |
847 | baobab.main_ui = ctk_builder_new (); |
848 | if (ctk_builder_add_from_resource (baobab.main_ui, BAOBAB_UI_RESOURCE"/org/cafe/disk-usage-analyzer/baobab-main-window.ui", &error) == 0) { |
849 | g_object_unref (baobab.main_ui); |
850 | g_critical ("Unable to load the user interface file: %s", error->message); |
851 | g_error_free (error); |
852 | exit (1); |
853 | } |
854 | |
855 | ctk_builder_connect_signals (baobab.main_ui, NULL((void*)0)); |
856 | |
857 | /* Settings */ |
858 | baobab.ui_settings = g_settings_new (BAOBAB_UI_SETTINGS_SCHEMA"org.cafe.disk-usage-analyzer.ui"); |
859 | baobab.prefs_settings = g_settings_new (BAOBAB_PREFS_SETTINGS_SCHEMA"org.cafe.disk-usage-analyzer.preferences"); |
860 | |
861 | /* Misc */ |
862 | baobab.CONTENTS_CHANGED_DELAYED = FALSE(0); |
863 | baobab.STOP_SCANNING = TRUE(!(0)); |
864 | baobab.show_allocated = TRUE(!(0)); |
865 | baobab.is_local = TRUE(!(0)); |
866 | |
867 | baobab_setup_excluded_locations (); |
868 | |
869 | baobab_create_toolbar (); |
870 | baobab_create_statusbar (); |
871 | baobab_setup_monitors (); |
872 | |
873 | g_signal_connect (baobab.ui_settings, "changed::" BAOBAB_SETTINGS_SUBFLSTIPS_VISIBLE,g_signal_connect_data ((baobab.ui_settings), ("changed::" "subfoldertips-visible" ), ((GCallback) baobab_settings_subfoldertips_changed), (((void *)0)), ((void*)0), (GConnectFlags) 0) |
874 | (GCallback) baobab_settings_subfoldertips_changed, NULL)g_signal_connect_data ((baobab.ui_settings), ("changed::" "subfoldertips-visible" ), ((GCallback) baobab_settings_subfoldertips_changed), (((void *)0)), ((void*)0), (GConnectFlags) 0); |
875 | } |
876 | |
877 | static void |
878 | baobab_shutdown (void) |
879 | { |
880 | if (baobab.current_location) { |
881 | g_object_unref (baobab.current_location); |
882 | } |
883 | |
884 | if (baobab.monitor_vol) { |
885 | g_object_unref (baobab.monitor_vol); |
886 | } |
887 | |
888 | if (baobab.monitor_home) { |
889 | g_file_monitor_cancel (baobab.monitor_home); |
890 | g_object_unref (baobab.monitor_home); |
891 | } |
892 | |
893 | g_free (baobab.selected_path); |
894 | |
895 | g_slist_free_full (baobab.excluded_locations, g_object_unref); |
896 | |
897 | if (baobab.ui_settings) { |
898 | g_object_unref (baobab.ui_settings); |
899 | } |
900 | |
901 | if (baobab.prefs_settings) { |
902 | g_object_unref (baobab.prefs_settings); |
903 | } |
904 | } |
905 | |
906 | static BaobabChartMenu * |
907 | create_context_menu (void) |
908 | { |
909 | BaobabChartMenu *menu = NULL((void*)0); |
910 | |
911 | baobab.chart_menu = g_new0 (BaobabChartMenu, 1)((BaobabChartMenu *) g_malloc0_n ((1), sizeof (BaobabChartMenu ))); |
912 | menu = baobab.chart_menu; |
913 | |
914 | menu->widget = ctk_menu_new (); |
915 | |
916 | menu->up_item = ctk_image_menu_item_new_with_label (_("Move to parent folder")gettext ("Move to parent folder")); |
917 | ctk_image_menu_item_set_image (CTK_IMAGE_MENU_ITEM (menu->up_item)((((CtkImageMenuItem*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((menu->up_item)), ((ctk_image_menu_item_get_type ())))))), |
918 | ctk_image_new_from_icon_name("go-up", CTK_ICON_SIZE_MENU)); |
919 | |
920 | menu->zoom_in_item = ctk_image_menu_item_new_with_label (_("Zoom in")gettext ("Zoom in")) ; |
921 | ctk_image_menu_item_set_image (CTK_IMAGE_MENU_ITEM (menu->zoom_in_item)((((CtkImageMenuItem*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((menu->zoom_in_item)), ((ctk_image_menu_item_get_type ())))))), |
922 | ctk_image_new_from_icon_name("list-add", CTK_ICON_SIZE_MENU)); |
923 | |
924 | menu->zoom_out_item = ctk_image_menu_item_new_with_label (_("Zoom out")gettext ("Zoom out")); |
925 | ctk_image_menu_item_set_image (CTK_IMAGE_MENU_ITEM (menu->zoom_out_item)((((CtkImageMenuItem*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((menu->zoom_out_item)), ((ctk_image_menu_item_get_type ())))))), |
926 | ctk_image_new_from_icon_name("list-remove", CTK_ICON_SIZE_MENU)); |
927 | |
928 | menu->snapshot_item = ctk_image_menu_item_new_with_label (_("Save screenshot")gettext ("Save screenshot")); |
929 | ctk_image_menu_item_set_image (CTK_IMAGE_MENU_ITEM (menu->snapshot_item)((((CtkImageMenuItem*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((menu->snapshot_item)), ((ctk_image_menu_item_get_type ())))))), |
930 | ctk_image_new_from_icon_name ("applets-screenshooter", CTK_ICON_SIZE_MENU)); |
931 | |
932 | ctk_menu_shell_append (CTK_MENU_SHELL (menu->widget)((((CtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((menu->widget)), ((ctk_menu_shell_get_type ())))))), |
933 | menu->up_item); |
934 | ctk_menu_shell_append (CTK_MENU_SHELL (menu->widget)((((CtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((menu->widget)), ((ctk_menu_shell_get_type ())))))), |
935 | ctk_separator_menu_item_new ()); |
936 | ctk_menu_shell_append (CTK_MENU_SHELL (menu->widget)((((CtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((menu->widget)), ((ctk_menu_shell_get_type ())))))), |
937 | menu->zoom_in_item); |
938 | ctk_menu_shell_append (CTK_MENU_SHELL (menu->widget)((((CtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((menu->widget)), ((ctk_menu_shell_get_type ())))))), |
939 | menu->zoom_out_item); |
940 | ctk_menu_shell_append (CTK_MENU_SHELL (menu->widget)((((CtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((menu->widget)), ((ctk_menu_shell_get_type ())))))), |
941 | ctk_separator_menu_item_new ()); |
942 | ctk_menu_shell_append (CTK_MENU_SHELL (menu->widget)((((CtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((menu->widget)), ((ctk_menu_shell_get_type ())))))), |
943 | menu->snapshot_item); |
944 | |
945 | /* connect signals */ |
946 | g_signal_connect (menu->up_item, "activate",g_signal_connect_data ((menu->up_item), ("activate"), (((GCallback ) (on_move_upwards_cb))), (((void*)0)), ((void*)0), (GConnectFlags ) 0) |
947 | G_CALLBACK (on_move_upwards_cb), NULL)g_signal_connect_data ((menu->up_item), ("activate"), (((GCallback ) (on_move_upwards_cb))), (((void*)0)), ((void*)0), (GConnectFlags ) 0); |
948 | g_signal_connect (menu->zoom_in_item, "activate",g_signal_connect_data ((menu->zoom_in_item), ("activate"), (((GCallback) (on_zoom_in_cb))), (((void*)0)), ((void*)0), ( GConnectFlags) 0) |
949 | G_CALLBACK (on_zoom_in_cb), NULL)g_signal_connect_data ((menu->zoom_in_item), ("activate"), (((GCallback) (on_zoom_in_cb))), (((void*)0)), ((void*)0), ( GConnectFlags) 0); |
950 | g_signal_connect (menu->zoom_out_item, "activate",g_signal_connect_data ((menu->zoom_out_item), ("activate") , (((GCallback) (on_zoom_out_cb))), (((void*)0)), ((void*)0), (GConnectFlags) 0) |
951 | G_CALLBACK (on_zoom_out_cb), NULL)g_signal_connect_data ((menu->zoom_out_item), ("activate") , (((GCallback) (on_zoom_out_cb))), (((void*)0)), ((void*)0), (GConnectFlags) 0); |
952 | g_signal_connect (menu->snapshot_item, "activate",g_signal_connect_data ((menu->snapshot_item), ("activate") , (((GCallback) (on_chart_snapshot_cb))), (((void*)0)), ((void *)0), (GConnectFlags) 0) |
953 | G_CALLBACK (on_chart_snapshot_cb), NULL)g_signal_connect_data ((menu->snapshot_item), ("activate") , (((GCallback) (on_chart_snapshot_cb))), (((void*)0)), ((void *)0), (GConnectFlags) 0); |
954 | |
955 | ctk_widget_show_all (menu->widget); |
956 | |
957 | return menu; |
958 | } |
959 | |
960 | static void |
961 | on_chart_item_activated (BaobabChart *chart, CtkTreeIter *iter) |
962 | { |
963 | CtkTreePath *path; |
964 | |
965 | path = ctk_tree_model_get_path (CTK_TREE_MODEL (baobab.model)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((baobab.model)), ((ctk_tree_model_get_type ())))))), iter); |
966 | |
967 | if (!ctk_tree_view_row_expanded (CTK_TREE_VIEW (baobab.tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((baobab.tree_view)), ((ctk_tree_view_get_type ())))))), path)) |
968 | ctk_tree_view_expand_to_path (CTK_TREE_VIEW (baobab.tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((baobab.tree_view)), ((ctk_tree_view_get_type ())))))), path); |
969 | |
970 | ctk_tree_view_set_cursor (CTK_TREE_VIEW (baobab.tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((baobab.tree_view)), ((ctk_tree_view_get_type ())))))), |
971 | path, NULL((void*)0), FALSE(0)); |
972 | ctk_tree_path_free (path); |
973 | } |
974 | |
975 | static gboolean |
976 | on_chart_button_release (BaobabChart *chart, |
977 | CdkEventButton *event, |
978 | gpointer data) |
979 | { |
980 | if (baobab_chart_is_frozen (baobab.current_chart)) |
981 | return FALSE(0); |
982 | |
983 | if (event->button== 3) /* right button */ |
984 | { |
985 | CtkTreePath *root_path; |
986 | BaobabChartMenu *menu; |
987 | |
988 | root_path = baobab_chart_get_root (baobab.current_chart); |
989 | |
990 | menu = baobab.chart_menu; |
991 | ctk_widget_set_sensitive (menu->up_item, |
992 | ((root_path != NULL((void*)0)) && |
993 | (ctk_tree_path_get_depth (root_path) > 1))); |
994 | ctk_widget_set_sensitive (menu->zoom_in_item, |
995 | baobab_chart_can_zoom_in (baobab.current_chart)); |
996 | ctk_widget_set_sensitive (menu->zoom_out_item, |
997 | baobab_chart_can_zoom_out (baobab.current_chart)); |
998 | |
999 | /* show the menu */ |
1000 | ctk_menu_popup_at_pointer (CTK_MENU (menu->widget)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((menu->widget)), ((ctk_menu_get_type ())))))), |
1001 | (const CdkEvent*) event); |
1002 | |
1003 | ctk_tree_path_free (root_path); |
1004 | } |
1005 | |
1006 | return FALSE(0); |
1007 | } |
1008 | |
1009 | static void |
1010 | drag_data_received_handl (CtkWidget *widget, |
1011 | CdkDragContext *context, |
1012 | gint x, |
1013 | gint y, |
1014 | CtkSelectionData *selection_data, |
1015 | guint target_type, |
1016 | guint time, |
1017 | gpointer data) |
1018 | { |
1019 | GFile *gf = NULL((void*)0); |
1020 | |
1021 | /* set "gf" if we got some valid data */ |
1022 | if ((selection_data != NULL((void*)0)) && |
1023 | (ctk_selection_data_get_length (selection_data) >= 0) && |
1024 | (target_type == DND_TARGET_URI_LIST)) { |
1025 | gchar **uri_list; |
1026 | uri_list = g_uri_list_extract_uris ((const gchar *) ctk_selection_data_get_data (selection_data)); |
1027 | /* check list is 1 item long */ |
1028 | if (uri_list != NULL((void*)0) && uri_list[0] != NULL((void*)0) && uri_list[1] == NULL((void*)0)) { |
1029 | gf = g_file_new_for_uri (uri_list[0]); |
1030 | } |
1031 | g_strfreev (uri_list); |
1032 | } |
1033 | |
1034 | /* success if "gf" has been set */ |
1035 | if (gf != NULL((void*)0)) { |
1036 | /* finish drop before beginning scan, as the drag-drop can |
1037 | probably time out */ |
1038 | ctk_drag_finish (context, TRUE(!(0)), FALSE(0), time); |
1039 | baobab_scan_location (gf); |
1040 | g_object_unref (gf); |
1041 | } else { |
1042 | ctk_drag_finish (context, FALSE(0), FALSE(0), time); |
1043 | } |
1044 | } |
1045 | |
1046 | static void |
1047 | set_active_chart (CtkWidget *chart) |
1048 | { |
1049 | if (baobab.current_chart != chart) { |
1050 | if (baobab.current_chart) { |
1051 | baobab_chart_freeze_updates (baobab.current_chart); |
1052 | |
1053 | g_object_ref (baobab.current_chart)((__typeof__ (baobab.current_chart)) (g_object_ref) (baobab.current_chart )); |
1054 | ctk_container_remove (CTK_CONTAINER (baobab.chart_frame)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((baobab.chart_frame)), ((ctk_container_get_type ())))))), |
1055 | baobab.current_chart); |
1056 | } |
1057 | |
1058 | ctk_container_add (CTK_CONTAINER (baobab.chart_frame)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((baobab.chart_frame)), ((ctk_container_get_type ())))))), chart); |
1059 | g_object_unref (chart); |
1060 | |
1061 | baobab_chart_thaw_updates (chart); |
1062 | |
1063 | baobab.current_chart = chart; |
1064 | |
1065 | ctk_widget_show_all (baobab.chart_frame); |
1066 | |
1067 | g_settings_set_string (baobab.ui_settings, |
1068 | BAOBAB_SETTINGS_ACTIVE_CHART"active-chart", |
1069 | baobab.current_chart == baobab.rings_chart ? "rings" : "treemap"); |
1070 | } |
1071 | } |
1072 | |
1073 | static void |
1074 | on_chart_type_change (CtkWidget *combo, gpointer user_data) |
1075 | { |
1076 | CtkWidget *chart; |
1077 | guint active; |
1078 | |
1079 | active = ctk_combo_box_get_active (CTK_COMBO_BOX (combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((combo)), ((ctk_combo_box_get_type ()))))))); |
1080 | |
1081 | switch (active) { |
1082 | case 0: |
1083 | chart = baobab.rings_chart; |
1084 | break; |
1085 | case 1: |
1086 | chart = baobab.treemap_chart; |
1087 | break; |
1088 | default: |
1089 | g_return_if_reached ()do { g_log (((gchar*) 0), G_LOG_LEVEL_CRITICAL, "file %s: line %d (%s): should not be reached" , "baobab.c", 1089, ((const char*) (__func__))); return; } while (0); |
1090 | } |
1091 | |
1092 | set_active_chart (chart); |
1093 | } |
1094 | |
1095 | static void |
1096 | initialize_charts (void) |
1097 | { |
1098 | CtkWidget *hpaned_main; |
1099 | CtkWidget *hbox1; |
1100 | char *saved_chart; |
1101 | gboolean visible; |
1102 | |
1103 | baobab.chart_frame = ctk_frame_new (NULL((void*)0)); |
1104 | ctk_frame_set_label_align (CTK_FRAME (baobab.chart_frame)((((CtkFrame*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((baobab.chart_frame)), ((ctk_frame_get_type ())))))), 0.0, 0.0); |
1105 | ctk_frame_set_shadow_type (CTK_FRAME (baobab.chart_frame)((((CtkFrame*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((baobab.chart_frame)), ((ctk_frame_get_type ())))))), CTK_SHADOW_IN); |
1106 | |
1107 | hpaned_main = CTK_WIDGET (ctk_builder_get_object (baobab.main_ui, "hpaned_main"))((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_builder_get_object (baobab.main_ui, "hpaned_main"))) , ((ctk_widget_get_type ())))))); |
1108 | ctk_paned_pack2 (CTK_PANED (hpaned_main)((((CtkPaned*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hpaned_main)), ((ctk_paned_get_type ())))))), |
1109 | baobab.chart_frame, TRUE(!(0)), TRUE(!(0))); |
1110 | ctk_paned_set_position (CTK_PANED (hpaned_main)((((CtkPaned*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hpaned_main)), ((ctk_paned_get_type ())))))), 480); |
1111 | |
1112 | baobab.chart_type_combo = ctk_combo_box_text_new (); |
1113 | ctk_combo_box_text_append_text (CTK_COMBO_BOX_TEXT (baobab.chart_type_combo)((((CtkComboBoxText*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((baobab.chart_type_combo)), ((ctk_combo_box_text_get_type ())))))), |
1114 | _("View as Rings Chart")gettext ("View as Rings Chart")); |
1115 | ctk_combo_box_text_append_text (CTK_COMBO_BOX_TEXT (baobab.chart_type_combo)((((CtkComboBoxText*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((baobab.chart_type_combo)), ((ctk_combo_box_text_get_type ())))))), |
1116 | _("View as Treemap Chart")gettext ("View as Treemap Chart")); |
1117 | ctk_widget_show (baobab.chart_type_combo); |
1118 | g_signal_connect (baobab.chart_type_combo,g_signal_connect_data ((baobab.chart_type_combo), ("changed") , (((GCallback) (on_chart_type_change))), (((void*)0)), ((void *)0), (GConnectFlags) 0) |
1119 | "changed",g_signal_connect_data ((baobab.chart_type_combo), ("changed") , (((GCallback) (on_chart_type_change))), (((void*)0)), ((void *)0), (GConnectFlags) 0) |
1120 | G_CALLBACK (on_chart_type_change), NULL)g_signal_connect_data ((baobab.chart_type_combo), ("changed") , (((GCallback) (on_chart_type_change))), (((void*)0)), ((void *)0), (GConnectFlags) 0); |
1121 | |
1122 | hbox1 = CTK_WIDGET (ctk_builder_get_object (baobab.main_ui, "hbox1"))((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_builder_get_object (baobab.main_ui, "hbox1"))), ((ctk_widget_get_type ())))))); |
1123 | ctk_container_add (CTK_CONTAINER (hbox1)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox1)), ((ctk_container_get_type ())))))), baobab.chart_type_combo); |
1124 | ctk_box_set_spacing (CTK_BOX (hbox1)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox1)), ((ctk_box_get_type ())))))), 50); |
1125 | ctk_box_set_child_packing (CTK_BOX (hbox1)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox1)), ((ctk_box_get_type ())))))), |
1126 | baobab.chart_type_combo, |
1127 | FALSE(0), |
1128 | TRUE(!(0)), |
1129 | 0, CTK_PACK_END); |
1130 | |
1131 | baobab.chart_menu = create_context_menu (); |
1132 | |
1133 | /* Baobab's Treemap Chart */ |
1134 | baobab.treemap_chart = baobab_treemap_new (); |
1135 | baobab_chart_set_model_with_columns (baobab.treemap_chart, |
1136 | CTK_TREE_MODEL (baobab.model)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((baobab.model)), ((ctk_tree_model_get_type ())))))), |
1137 | COL_DIR_NAME, |
1138 | COL_DIR_SIZE, |
1139 | COL_H_PARSENAME, |
1140 | COL_H_PERC, |
1141 | COL_H_ELEMENTS, |
1142 | NULL((void*)0)); |
1143 | baobab_chart_set_max_depth (baobab.treemap_chart, 1); |
1144 | g_signal_connect (baobab.treemap_chart, "item_activated",g_signal_connect_data ((baobab.treemap_chart), ("item_activated" ), (((GCallback) (on_chart_item_activated))), (((void*)0)), ( (void*)0), (GConnectFlags) 0) |
1145 | G_CALLBACK (on_chart_item_activated), NULL)g_signal_connect_data ((baobab.treemap_chart), ("item_activated" ), (((GCallback) (on_chart_item_activated))), (((void*)0)), ( (void*)0), (GConnectFlags) 0); |
1146 | g_signal_connect (baobab.treemap_chart, "button-release-event",g_signal_connect_data ((baobab.treemap_chart), ("button-release-event" ), (((GCallback) (on_chart_button_release))), (((void*)0)), ( (void*)0), (GConnectFlags) 0) |
1147 | G_CALLBACK (on_chart_button_release), NULL)g_signal_connect_data ((baobab.treemap_chart), ("button-release-event" ), (((GCallback) (on_chart_button_release))), (((void*)0)), ( (void*)0), (GConnectFlags) 0); |
1148 | g_signal_connect (baobab.treemap_chart, "drag-data-received",g_signal_connect_data ((baobab.treemap_chart), ("drag-data-received" ), (((GCallback) (drag_data_received_handl))), (((void*)0)), ( (void*)0), (GConnectFlags) 0) |
1149 | G_CALLBACK (drag_data_received_handl), NULL)g_signal_connect_data ((baobab.treemap_chart), ("drag-data-received" ), (((GCallback) (drag_data_received_handl))), (((void*)0)), ( (void*)0), (GConnectFlags) 0); |
1150 | ctk_widget_show (baobab.treemap_chart); |
1151 | g_object_ref_sink (baobab.treemap_chart)((__typeof__ (baobab.treemap_chart)) (g_object_ref_sink) (baobab .treemap_chart)); |
1152 | baobab_chart_freeze_updates (baobab.treemap_chart); |
1153 | |
1154 | /* Baobab's Rings Chart */ |
1155 | baobab.rings_chart = (CtkWidget *) baobab_ringschart_new (); |
1156 | baobab_chart_set_model_with_columns (baobab.rings_chart, |
1157 | CTK_TREE_MODEL (baobab.model)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((baobab.model)), ((ctk_tree_model_get_type ())))))), |
1158 | COL_DIR_NAME, |
1159 | COL_DIR_SIZE, |
1160 | COL_H_PARSENAME, |
1161 | COL_H_PERC, |
1162 | COL_H_ELEMENTS, |
1163 | NULL((void*)0)); |
1164 | |
1165 | visible = g_settings_get_boolean (baobab.ui_settings, |
1166 | BAOBAB_SETTINGS_SUBFLSTIPS_VISIBLE"subfoldertips-visible"); |
1167 | baobab_ringschart_set_subfoldertips_enabled (baobab.rings_chart, visible); |
1168 | |
1169 | baobab_chart_set_max_depth (baobab.rings_chart, 1); |
1170 | g_signal_connect (baobab.rings_chart, "item_activated",g_signal_connect_data ((baobab.rings_chart), ("item_activated" ), (((GCallback) (on_chart_item_activated))), (((void*)0)), ( (void*)0), (GConnectFlags) 0) |
1171 | G_CALLBACK (on_chart_item_activated), NULL)g_signal_connect_data ((baobab.rings_chart), ("item_activated" ), (((GCallback) (on_chart_item_activated))), (((void*)0)), ( (void*)0), (GConnectFlags) 0); |
1172 | g_signal_connect (baobab.rings_chart, "button-release-event",g_signal_connect_data ((baobab.rings_chart), ("button-release-event" ), (((GCallback) (on_chart_button_release))), (((void*)0)), ( (void*)0), (GConnectFlags) 0) |
1173 | G_CALLBACK (on_chart_button_release), NULL)g_signal_connect_data ((baobab.rings_chart), ("button-release-event" ), (((GCallback) (on_chart_button_release))), (((void*)0)), ( (void*)0), (GConnectFlags) 0); |
1174 | g_signal_connect (baobab.rings_chart, "drag-data-received",g_signal_connect_data ((baobab.rings_chart), ("drag-data-received" ), (((GCallback) (drag_data_received_handl))), (((void*)0)), ( (void*)0), (GConnectFlags) 0) |
1175 | G_CALLBACK (drag_data_received_handl), NULL)g_signal_connect_data ((baobab.rings_chart), ("drag-data-received" ), (((GCallback) (drag_data_received_handl))), (((void*)0)), ( (void*)0), (GConnectFlags) 0); |
1176 | ctk_widget_show (baobab.rings_chart); |
1177 | g_object_ref_sink (baobab.rings_chart)((__typeof__ (baobab.rings_chart)) (g_object_ref_sink) (baobab .rings_chart)); |
1178 | baobab_chart_freeze_updates (baobab.rings_chart); |
1179 | |
1180 | saved_chart = g_settings_get_string (baobab.ui_settings, |
1181 | BAOBAB_SETTINGS_ACTIVE_CHART"active-chart"); |
1182 | |
1183 | if (0 == g_ascii_strcasecmp (saved_chart, "treemap")) { |
1184 | set_active_chart (baobab.treemap_chart); |
1185 | ctk_combo_box_set_active (CTK_COMBO_BOX (baobab.chart_type_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((baobab.chart_type_combo)), ((ctk_combo_box_get_type ())) )))), 1); |
1186 | } else { |
1187 | set_active_chart (baobab.rings_chart); |
1188 | ctk_combo_box_set_active (CTK_COMBO_BOX (baobab.chart_type_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((baobab.chart_type_combo)), ((ctk_combo_box_get_type ())) )))), 0); |
1189 | } |
1190 | |
1191 | g_free (saved_chart); |
1192 | |
1193 | check_drop_targets (FALSE(0)); |
1194 | } |
1195 | |
1196 | void |
1197 | baobab_quit () |
1198 | { |
1199 | baobab_stop_scan (); |
1200 | ctk_main_quit (); |
1201 | } |
1202 | |
1203 | static gboolean |
1204 | start_proc_on_command_line (GFile *file) |
1205 | { |
1206 | baobab_scan_location (file); |
1207 | |
1208 | return FALSE(0); |
1209 | } |
1210 | |
1211 | static gboolean |
1212 | show_version (const gchar *option_name, |
1213 | const gchar *value, |
1214 | gpointer data, |
1215 | GError **error) |
1216 | { |
1217 | g_print("%s %s\n", g_get_application_name (), VERSION"1.25.0"); |
1218 | exit (0); |
1219 | return TRUE(!(0)); /* It's just good form */ |
This statement is never executed | |
1220 | } |
1221 | |
1222 | int |
1223 | main (int argc, char *argv[]) |
1224 | { |
1225 | gchar **directories = NULL((void*)0); |
1226 | const GOptionEntry options[] = { |
1227 | {"version", 'V', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, show_version, N_("Show version")("Show version"), NULL((void*)0)}, |
1228 | {G_OPTION_REMAINING"", 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &directories, NULL((void*)0), N_("[DIRECTORY]")("[DIRECTORY]")}, |
1229 | {NULL((void*)0)} |
1230 | }; |
1231 | GOptionContext *context; |
1232 | GError *error = NULL((void*)0); |
1233 | |
1234 | bindtextdomain (GETTEXT_PACKAGE"cafe-utils", CAFELOCALEDIR"/usr/share/locale"); |
1235 | bind_textdomain_codeset (GETTEXT_PACKAGE"cafe-utils", "UTF-8"); |
1236 | textdomain (GETTEXT_PACKAGE"cafe-utils"); |
1237 | |
1238 | g_set_application_name (_("Disk Usage Analyzer")gettext ("Disk Usage Analyzer")); |
1239 | |
1240 | context = g_option_context_new (NULL((void*)0)); |
1241 | g_option_context_set_ignore_unknown_options (context, FALSE(0)); |
1242 | g_option_context_set_help_enabled (context, TRUE(!(0))); |
1243 | g_option_context_add_main_entries(context, options, GETTEXT_PACKAGE"cafe-utils"); |
1244 | g_option_context_add_group (context, ctk_get_option_group (TRUE(!(0)))); |
1245 | |
1246 | g_option_context_parse (context, &argc, &argv, &error); |
1247 | |
1248 | if (error) { |
1249 | g_critical ("Unable to parse option: %s", error->message); |
1250 | g_error_free (error); |
1251 | g_option_context_free (context); |
1252 | |
1253 | exit (1); |
1254 | } |
1255 | g_option_context_free (context); |
1256 | |
1257 | if (directories && directories[0] && directories[1]) { |
1258 | g_critical (_("Too many arguments. Only one directory can be specified.")gettext ("Too many arguments. Only one directory can be specified." )); |
1259 | exit (1); |
1260 | } |
1261 | |
1262 | glibtop_init (); |
1263 | |
1264 | ctk_window_set_default_icon_name ("cafe-disk-usage-analyzer"); |
1265 | |
1266 | g_object_set (ctk_settings_get_default (), "ctk-menu-images", TRUE(!(0)), NULL((void*)0)); |
1267 | g_object_set (ctk_settings_get_default (), "ctk-button-images", TRUE(!(0)), NULL((void*)0)); |
1268 | |
1269 | baobab_init (); |
1270 | |
1271 | if (baobab.fs.total == 0) { |
1272 | CtkWidget *dialog; |
1273 | |
1274 | dialog = ctk_message_dialog_new (NULL((void*)0), |
1275 | CTK_DIALOG_DESTROY_WITH_PARENT, |
1276 | CTK_MESSAGE_ERROR, |
1277 | CTK_BUTTONS_CLOSE, |
1278 | _("Could not detect any mount point.")gettext ("Could not detect any mount point.")); |
1279 | ctk_message_dialog_format_secondary_text (CTK_MESSAGE_DIALOG(dialog)((((CtkMessageDialog*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((dialog)), ((ctk_message_dialog_get_type ()) ))))), |
1280 | _("Without mount points disk usage cannot be analyzed.")gettext ("Without mount points disk usage cannot be analyzed." )); |
1281 | ctk_dialog_run (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ()))))))); |
1282 | ctk_widget_destroy (dialog); |
1283 | goto closing; |
1284 | } |
1285 | |
1286 | check_menu_sens (FALSE(0)); |
1287 | update_scan_label (); |
1288 | |
1289 | baobab.window = CTK_WIDGET (ctk_builder_get_object (baobab.main_ui, "baobab_window"))((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_builder_get_object (baobab.main_ui, "baobab_window") )), ((ctk_widget_get_type ())))))); |
1290 | ctk_window_set_position (CTK_WINDOW (baobab.window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((baobab.window)), ((ctk_window_get_type ())))))), |
1291 | CTK_WIN_POS_CENTER); |
1292 | |
1293 | baobab.tree_view = create_directory_treeview (); |
1294 | |
1295 | set_ui_action_sens ("menurescan", FALSE(0)); |
1296 | |
1297 | /* set allocated space checkbox */ |
1298 | ctk_toggle_action_set_active (CTK_TOGGLE_ACTION (ctk_builder_get_object (baobab.main_ui,((((CtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_builder_get_object (baobab.main_ui, "ck_allocated")) ), ((ctk_toggle_action_get_type ())))))) |
1299 | "ck_allocated"))((((CtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_builder_get_object (baobab.main_ui, "ck_allocated")) ), ((ctk_toggle_action_get_type ())))))), |
1300 | baobab.show_allocated); |
1301 | |
1302 | ctk_widget_show (baobab.window); |
1303 | |
1304 | first_row (); |
1305 | baobab_set_statusbar (_("Ready")gettext ("Ready")); |
1306 | |
1307 | initialize_charts (); |
1308 | |
1309 | /* commandline */ |
1310 | if (directories && directories[0]) { |
1311 | GFile *file; |
1312 | |
1313 | file = g_file_new_for_commandline_arg (directories[0]); |
1314 | |
1315 | /* start processing the dir specified on the |
1316 | * command line as soon as we enter the main loop */ |
1317 | g_idle_add_full (G_PRIORITY_DEFAULT_IDLE200, |
1318 | (GSourceFunc) start_proc_on_command_line, |
1319 | file, |
1320 | g_object_unref); |
1321 | } |
1322 | g_strfreev (directories); |
1323 | |
1324 | ctk_main (); |
1325 | |
1326 | closing: |
1327 | baobab_shutdown (); |
1328 | |
1329 | glibtop_close (); |
1330 | |
1331 | return 0; |
1332 | } |