File: | fr-window.c |
Warning: | line 7686, column 28 Null pointer passed to 1st parameter expecting 'nonnull' |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ | |||
2 | ||||
3 | /* | |||
4 | * Grapa | |||
5 | * | |||
6 | * Copyright (C) 2007 Free Software Foundation, Inc. | |||
7 | * | |||
8 | * This program is free software; you can redistribute it and/or modify | |||
9 | * it under the terms of the GNU General Public License as published by | |||
10 | * the Free Software Foundation; either version 2 of the License, or | |||
11 | * (at your option) any later version. | |||
12 | * | |||
13 | * This program is distributed in the hope that it will be useful, | |||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
16 | * GNU General Public License for more details. | |||
17 | * | |||
18 | * along with this program; if not, write to the Free Software | |||
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |||
20 | */ | |||
21 | ||||
22 | #include <config.h> | |||
23 | #include <math.h> | |||
24 | #include <string.h> | |||
25 | ||||
26 | #include <glib.h> | |||
27 | #include <glib/gi18n.h> | |||
28 | #include <gio/gio.h> | |||
29 | #include <cdk/cdk.h> | |||
30 | #include <cdk/cdkkeysyms.h> | |||
31 | #include <gdk-pixbuf/gdk-pixbuf.h> | |||
32 | ||||
33 | #include <libnotify/notify.h> | |||
34 | ||||
35 | #include "actions.h" | |||
36 | #include "dlg-batch-add.h" | |||
37 | #include "dlg-delete.h" | |||
38 | #include "dlg-extract.h" | |||
39 | #include "dlg-open-with.h" | |||
40 | #include "dlg-ask-password.h" | |||
41 | #include "dlg-package-installer.h" | |||
42 | #include "dlg-update.h" | |||
43 | #include "eggtreemultidnd.h" | |||
44 | #include "fr-marshal.h" | |||
45 | #include "fr-list-model.h" | |||
46 | #include "fr-archive.h" | |||
47 | #include "fr-error.h" | |||
48 | #include "fr-window.h" | |||
49 | #include "file-data.h" | |||
50 | #include "file-utils.h" | |||
51 | #include "glib-utils.h" | |||
52 | #include "fr-init.h" | |||
53 | #include "ctk-utils.h" | |||
54 | #include "open-file.h" | |||
55 | #include "typedefs.h" | |||
56 | #include "ui.h" | |||
57 | ||||
58 | #ifdef __GNUC__4 | |||
59 | #define UNUSED_VARIABLE__attribute__ ((unused)) __attribute__ ((unused)) | |||
60 | #else | |||
61 | #define UNUSED_VARIABLE__attribute__ ((unused)) | |||
62 | #endif | |||
63 | ||||
64 | #define LAST_OUTPUT_DIALOG_NAME"last-output" "last-output" | |||
65 | #define ACTIVITY_DELAY100 100 | |||
66 | #define ACTIVITY_PULSE_STEP(0.033) (0.033) | |||
67 | ||||
68 | #define PROGRESS_TIMEOUT_MSECS5000 5000 | |||
69 | #define PROGRESS_DIALOG_DEFAULT_WIDTH500 500 | |||
70 | #define PROGRESS_BAR_HEIGHT10 10 | |||
71 | #undef LOG_PROGRESS | |||
72 | ||||
73 | #define HIDE_PROGRESS_TIMEOUT_MSECS500 500 | |||
74 | #define DEFAULT_NAME_COLUMN_WIDTH250 250 | |||
75 | #define OTHER_COLUMNS_WIDTH100 100 | |||
76 | ||||
77 | #define FILE_LIST_ICON_SIZECTK_ICON_SIZE_LARGE_TOOLBAR CTK_ICON_SIZE_LARGE_TOOLBAR | |||
78 | #define DIR_TREE_ICON_SIZECTK_ICON_SIZE_MENU CTK_ICON_SIZE_MENU | |||
79 | ||||
80 | #define BAD_CHARS"/\\*" "/\\*" | |||
81 | ||||
82 | static GHashTable *pixbuf_hash = NULL((void*)0); | |||
83 | static GHashTable *tree_pixbuf_hash = NULL((void*)0); | |||
84 | static CtkIconTheme *icon_theme = NULL((void*)0); | |||
85 | static int file_list_icon_size = 0; | |||
86 | static int dir_tree_icon_size = 0; | |||
87 | static gboolean enable_notifications = TRUE(!(0)); | |||
88 | ||||
89 | #define XDS_FILENAME"xds.txt" "xds.txt" | |||
90 | #define MAX_XDS_ATOM_VAL_LEN4096 4096 | |||
91 | #define XDS_ATOMcdk_atom_intern ("XdndDirectSave0", (0)) cdk_atom_intern ("XdndDirectSave0", FALSE(0)) | |||
92 | #define TEXT_ATOMcdk_atom_intern ("text/plain", (0)) cdk_atom_intern ("text/plain", FALSE(0)) | |||
93 | #define XFR_ATOMcdk_atom_intern ("XdndGrapa0", (0)) cdk_atom_intern ("XdndGrapa0", FALSE(0)) | |||
94 | ||||
95 | #define FR_CLIPBOARD(cdk_atom_intern_static_string ("_RNGRAMPA_SPECIAL_CLIPBOARD" )) (cdk_atom_intern_static_string ("_RNGRAMPA_SPECIAL_CLIPBOARD")) | |||
96 | #define FR_SPECIAL_URI_LIST(cdk_atom_intern_static_string ("application/grapa-uri-list") ) (cdk_atom_intern_static_string ("application/grapa-uri-list")) | |||
97 | ||||
98 | static CtkTargetEntry clipboard_targets[] = { | |||
99 | { "application/grapa-uri-list", 0, 1 } | |||
100 | }; | |||
101 | ||||
102 | static CtkTargetEntry target_table[] = { | |||
103 | { "XdndGrapa0", 0, 0 }, | |||
104 | { "text/uri-list", 0, 1 }, | |||
105 | }; | |||
106 | ||||
107 | static CtkTargetEntry folder_tree_targets[] = { | |||
108 | { "XdndGrapa0", 0, 0 }, | |||
109 | { "XdndDirectSave0", 0, 2 } | |||
110 | }; | |||
111 | ||||
112 | ||||
113 | typedef struct { | |||
114 | FrBatchActionType type; | |||
115 | void * data; | |||
116 | GFreeFunc free_func; | |||
117 | } FRBatchAction; | |||
118 | ||||
119 | ||||
120 | typedef struct { | |||
121 | guint converting : 1; | |||
122 | char *temp_dir; | |||
123 | FrArchive *new_archive; | |||
124 | char *password; | |||
125 | gboolean encrypt_header; | |||
126 | guint volume_size; | |||
127 | char *new_file; | |||
128 | } FRConvertData; | |||
129 | ||||
130 | ||||
131 | typedef enum { | |||
132 | FR_CLIPBOARD_OP_CUT, | |||
133 | FR_CLIPBOARD_OP_COPY | |||
134 | } FRClipboardOp; | |||
135 | ||||
136 | ||||
137 | typedef struct { | |||
138 | GList *file_list; | |||
139 | char *extract_to_dir; | |||
140 | char *base_dir; | |||
141 | gboolean skip_older; | |||
142 | FrOverwrite overwrite; | |||
143 | gboolean junk_paths; | |||
144 | char *password; | |||
145 | gboolean extract_here; | |||
146 | gboolean ask_to_open_destination; | |||
147 | } ExtractData; | |||
148 | ||||
149 | ||||
150 | typedef enum { | |||
151 | FR_WINDOW_AREA_MENUBAR, | |||
152 | FR_WINDOW_AREA_TOOLBAR, | |||
153 | FR_WINDOW_AREA_LOCATIONBAR, | |||
154 | FR_WINDOW_AREA_CONTENTS, | |||
155 | FR_WINDOW_AREA_FILTERBAR, | |||
156 | FR_WINDOW_AREA_STATUSBAR, | |||
157 | } FrWindowArea; | |||
158 | ||||
159 | ||||
160 | typedef enum { | |||
161 | DIALOG_RESPONSE_NONE = 1, | |||
162 | DIALOG_RESPONSE_OPEN_ARCHIVE, | |||
163 | DIALOG_RESPONSE_OPEN_DESTINATION_FOLDER, | |||
164 | DIALOG_RESPONSE_OPEN_DESTINATION_FOLDER_AND_QUIT, | |||
165 | DIALOG_RESPONSE_QUIT | |||
166 | } DialogResponse; | |||
167 | ||||
168 | ||||
169 | /* -- FrClipboardData -- */ | |||
170 | ||||
171 | ||||
172 | typedef struct { | |||
173 | int refs; | |||
174 | char *archive_filename; | |||
175 | char *archive_password; | |||
176 | FRClipboardOp op; | |||
177 | char *base_dir; | |||
178 | GList *files; | |||
179 | char *tmp_dir; | |||
180 | char *current_dir; | |||
181 | } FrClipboardData; | |||
182 | ||||
183 | ||||
184 | static FrClipboardData* | |||
185 | fr_clipboard_data_new (void) | |||
186 | { | |||
187 | FrClipboardData *data; | |||
188 | ||||
189 | data = g_new0 (FrClipboardData, 1)((FrClipboardData *) g_malloc0_n ((1), sizeof (FrClipboardData ))); | |||
190 | data->refs = 1; | |||
191 | ||||
192 | return data; | |||
193 | } | |||
194 | ||||
195 | ||||
196 | static FrClipboardData * | |||
197 | fr_clipboard_data_ref (FrClipboardData *clipboard_data) | |||
198 | { | |||
199 | clipboard_data->refs++; | |||
200 | return clipboard_data; | |||
201 | } | |||
202 | ||||
203 | ||||
204 | static void | |||
205 | fr_clipboard_data_unref (FrClipboardData *clipboard_data) | |||
206 | { | |||
207 | if (clipboard_data == NULL((void*)0)) | |||
208 | return; | |||
209 | if (--clipboard_data->refs > 0) | |||
210 | return; | |||
211 | ||||
212 | g_free (clipboard_data->archive_filename); | |||
213 | g_free (clipboard_data->archive_password); | |||
214 | g_free (clipboard_data->base_dir); | |||
215 | g_free (clipboard_data->tmp_dir); | |||
216 | g_free (clipboard_data->current_dir); | |||
217 | g_list_free_full (clipboard_data->files, g_free); | |||
218 | g_free (clipboard_data); | |||
219 | } | |||
220 | ||||
221 | ||||
222 | static void | |||
223 | fr_clipboard_data_set_password (FrClipboardData *clipboard_data, | |||
224 | const char *password) | |||
225 | { | |||
226 | if (clipboard_data->archive_password != password) | |||
227 | g_free (clipboard_data->archive_password); | |||
228 | if (password != NULL((void*)0)) | |||
229 | clipboard_data->archive_password = g_strdup (password)g_strdup_inline (password); | |||
230 | } | |||
231 | ||||
232 | ||||
233 | /**/ | |||
234 | ||||
235 | enum { | |||
236 | ARCHIVE_LOADED, | |||
237 | PROGRESS, | |||
238 | READY, | |||
239 | LAST_SIGNAL | |||
240 | }; | |||
241 | ||||
242 | static CtkApplicationWindowClass *parent_class = NULL((void*)0); | |||
243 | static guint fr_window_signals[LAST_SIGNAL] = { 0 }; | |||
244 | ||||
245 | struct _FrWindowPrivateData { | |||
246 | CtkWidget *layout; | |||
247 | CtkWidget *contents; | |||
248 | CtkWidget *list_view; | |||
249 | CtkListStore *list_store; | |||
250 | CtkWidget *tree_view; | |||
251 | CtkTreeStore *tree_store; | |||
252 | CtkWidget *toolbar; | |||
253 | CtkWidget *statusbar; | |||
254 | CtkWidget *progress_bar; | |||
255 | CtkWidget *location_bar; | |||
256 | CtkWidget *location_entry; | |||
257 | CtkWidget *location_label; | |||
258 | CtkWidget *filter_bar; | |||
259 | CtkWidget *filter_entry; | |||
260 | CtkWidget *paned; | |||
261 | CtkWidget *sidepane; | |||
262 | CtkTreePath *list_hover_path; | |||
263 | CtkTreeViewColumn *filename_column; | |||
264 | ||||
265 | gboolean filter_mode; | |||
266 | gint current_view_length; | |||
267 | ||||
268 | guint help_message_cid; | |||
269 | guint list_info_cid; | |||
270 | guint progress_cid; | |||
271 | ||||
272 | CtkWidget * up_arrows[5]; | |||
273 | CtkWidget * down_arrows[5]; | |||
274 | ||||
275 | FrAction action; | |||
276 | gboolean archive_present; | |||
277 | gboolean archive_new; /* A new archive has been created | |||
278 | * but it doesn't contain any | |||
279 | * file yet. The real file will | |||
280 | * be created only when the user | |||
281 | * adds some file to the | |||
282 | * archive.*/ | |||
283 | ||||
284 | char * archive_uri; | |||
285 | char * open_default_dir; /* default directory to be used | |||
286 | * in the Open dialog. */ | |||
287 | char * add_default_dir; /* default directory to be used | |||
288 | * in the Add dialog. */ | |||
289 | char * extract_default_dir; /* default directory to be used | |||
290 | * in the Extract dialog. */ | |||
291 | gboolean freeze_default_dir; | |||
292 | gboolean asked_for_password; | |||
293 | gboolean ask_to_open_destination_after_extraction; | |||
294 | gboolean destroy_with_error_dialog; | |||
295 | ||||
296 | FRBatchAction current_batch_action; | |||
297 | ||||
298 | gboolean give_focus_to_the_list; | |||
299 | gboolean single_click; | |||
300 | CtkTreePath *path_clicked; | |||
301 | ||||
302 | FrWindowSortMethod sort_method; | |||
303 | CtkSortType sort_type; | |||
304 | ||||
305 | char * last_location; | |||
306 | ||||
307 | gboolean view_folders; | |||
308 | FrWindowListMode list_mode; | |||
309 | FrWindowListMode last_list_mode; | |||
310 | GList * history; | |||
311 | GList * history_current; | |||
312 | char * password; | |||
313 | char * password_for_paste; | |||
314 | gboolean encrypt_header; | |||
315 | FrCompression compression; | |||
316 | guint volume_size; | |||
317 | ||||
318 | guint activity_timeout_handle; /* activity timeout | |||
319 | * handle. */ | |||
320 | gint activity_ref; /* when > 0 some activity | |||
321 | * is present. */ | |||
322 | ||||
323 | guint update_timeout_handle; /* update file list | |||
324 | * timeout handle. */ | |||
325 | ||||
326 | FRConvertData convert_data; | |||
327 | ||||
328 | gboolean stoppable; | |||
329 | gboolean closing; | |||
330 | ||||
331 | FrClipboardData *clipboard_data; | |||
332 | FrClipboardData *copy_data; | |||
333 | ||||
334 | FrArchive *copy_from_archive; | |||
335 | ||||
336 | CtkActionGroup *actions; | |||
337 | ||||
338 | CtkWidget *file_popup_menu; | |||
339 | CtkWidget *folder_popup_menu; | |||
340 | CtkWidget *sidebar_folder_popup_menu; | |||
341 | ||||
342 | /* dragged files data */ | |||
343 | ||||
344 | char *drag_destination_folder; | |||
345 | char *drag_base_dir; | |||
346 | GError *drag_error; | |||
347 | GList *drag_file_list; /* the list of files we are | |||
348 | * dragging*/ | |||
349 | ||||
350 | /* progress dialog data */ | |||
351 | ||||
352 | CtkWidget *progress_dialog; | |||
353 | CtkWidget *pd_action; | |||
354 | CtkWidget *pd_message; | |||
355 | CtkWidget *pd_progress_bar; | |||
356 | CtkWidget *pd_cancel_button; | |||
357 | CtkWidget *pd_close_button; | |||
358 | CtkWidget *pd_open_archive_button; | |||
359 | CtkWidget *pd_open_destination_button; | |||
360 | CtkWidget *pd_open_destination_and_quit_button; | |||
361 | CtkWidget *pd_quit_button; | |||
362 | CtkWidget *pd_state_button; //Switch state, pause state or start state | |||
363 | CtkWidget *pd_icon; | |||
364 | gboolean progress_pulse; | |||
365 | guint progress_timeout; /* Timeout to display the progress dialog. */ | |||
366 | guint hide_progress_timeout; /* Timeout to hide the progress dialog. */ | |||
367 | char *pd_last_archive; | |||
368 | char *working_archive; | |||
369 | double pd_last_fraction; | |||
370 | char *pd_last_message; | |||
371 | gboolean use_progress_dialog; | |||
372 | ||||
373 | /* update dialog data */ | |||
374 | ||||
375 | gpointer update_dialog; | |||
376 | GList *open_files; | |||
377 | ||||
378 | /* batch mode data */ | |||
379 | ||||
380 | gboolean batch_mode; /* whether we are in a non interactive | |||
381 | * mode. */ | |||
382 | GList *batch_action_list; /* FRBatchAction * elements */ | |||
383 | GList *batch_action; /* current action. */ | |||
384 | char *batch_title; | |||
385 | ||||
386 | /* misc */ | |||
387 | ||||
388 | GSettings *settings_listing; | |||
389 | GSettings *settings_ui; | |||
390 | GSettings *settings_general; | |||
391 | GSettings *settings_dialogs; | |||
392 | GSettings *settings_baul; | |||
393 | ||||
394 | gulong theme_changed_handler_id; | |||
395 | gboolean non_interactive; | |||
396 | char *extract_here_dir; | |||
397 | gboolean extract_interact_use_default_dir; | |||
398 | gboolean update_dropped_files; | |||
399 | gboolean batch_adding_one_file; | |||
400 | ||||
401 | CtkWindow *load_error_parent_window; | |||
402 | gboolean showing_error_dialog; | |||
403 | CtkWindow *error_dialog_parent; | |||
404 | }; | |||
405 | ||||
406 | ||||
407 | /* -- fr_window_free_private_data -- */ | |||
408 | ||||
409 | ||||
410 | static void | |||
411 | fr_window_free_batch_data (FrWindow *window) | |||
412 | { | |||
413 | GList *scan; | |||
414 | ||||
415 | for (scan = window->priv->batch_action_list; scan; scan = scan->next) { | |||
416 | FRBatchAction *adata = scan->data; | |||
417 | ||||
418 | if ((adata->data != NULL((void*)0)) && (adata->free_func != NULL((void*)0))) | |||
419 | (*adata->free_func) (adata->data); | |||
420 | g_free (adata); | |||
421 | } | |||
422 | ||||
423 | g_list_free (window->priv->batch_action_list); | |||
424 | window->priv->batch_action_list = NULL((void*)0); | |||
425 | window->priv->batch_action = NULL((void*)0); | |||
426 | ||||
427 | g_free (window->priv->batch_title); | |||
428 | window->priv->batch_title = NULL((void*)0); | |||
429 | } | |||
430 | ||||
431 | ||||
432 | static void | |||
433 | gh_unref_pixbuf (gpointer key G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
434 | gpointer value, | |||
435 | gpointer user_data G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
436 | { | |||
437 | g_object_unref (value); | |||
438 | } | |||
439 | ||||
440 | ||||
441 | static void | |||
442 | fr_window_clipboard_remove_file_list (FrWindow *window, | |||
443 | GList *file_list) | |||
444 | { | |||
445 | GList *scan1; | |||
446 | ||||
447 | if (window->priv->copy_data == NULL((void*)0)) | |||
448 | return; | |||
449 | ||||
450 | if (file_list == NULL((void*)0)) { | |||
451 | fr_clipboard_data_unref (window->priv->copy_data); | |||
452 | window->priv->copy_data = NULL((void*)0); | |||
453 | return; | |||
454 | } | |||
455 | ||||
456 | for (scan1 = file_list; scan1; scan1 = scan1->next) { | |||
457 | const char *name1 = scan1->data; | |||
458 | GList *scan2; | |||
459 | ||||
460 | for (scan2 = window->priv->copy_data->files; scan2;) { | |||
461 | const char *name2 = scan2->data; | |||
462 | ||||
463 | if (strcmp (name1, name2) == 0) { | |||
464 | GList *tmp = scan2->next; | |||
465 | window->priv->copy_data->files = g_list_remove_link (window->priv->copy_data->files, scan2); | |||
466 | g_free (scan2->data); | |||
467 | g_list_free (scan2); | |||
468 | scan2 = tmp; | |||
469 | } | |||
470 | else | |||
471 | scan2 = scan2->next; | |||
472 | } | |||
473 | } | |||
474 | ||||
475 | if (window->priv->copy_data->files == NULL((void*)0)) { | |||
476 | fr_clipboard_data_unref (window->priv->copy_data); | |||
477 | window->priv->copy_data = NULL((void*)0); | |||
478 | } | |||
479 | } | |||
480 | ||||
481 | ||||
482 | static void | |||
483 | fr_window_history_clear (FrWindow *window) | |||
484 | { | |||
485 | if (window->priv->history != NULL((void*)0)) | |||
486 | path_list_free (window->priv->history); | |||
487 | window->priv->history = NULL((void*)0); | |||
488 | window->priv->history_current = NULL((void*)0); | |||
489 | g_free (window->priv->last_location); | |||
490 | window->priv->last_location = NULL((void*)0); | |||
491 | } | |||
492 | ||||
493 | ||||
494 | static void | |||
495 | fr_window_free_open_files (FrWindow *window) | |||
496 | { | |||
497 | GList *scan; | |||
498 | ||||
499 | for (scan = window->priv->open_files; scan; scan = scan->next) { | |||
500 | OpenFile *file = scan->data; | |||
501 | ||||
502 | if (file->monitor != NULL((void*)0)) | |||
503 | g_file_monitor_cancel (file->monitor); | |||
504 | open_file_free (file); | |||
505 | } | |||
506 | g_list_free (window->priv->open_files); | |||
507 | window->priv->open_files = NULL((void*)0); | |||
508 | } | |||
509 | ||||
510 | ||||
511 | static void | |||
512 | fr_window_convert_data_free (FrWindow *window, | |||
513 | gboolean all) | |||
514 | { | |||
515 | if (all) { | |||
516 | g_free (window->priv->convert_data.new_file); | |||
517 | window->priv->convert_data.new_file = NULL((void*)0); | |||
518 | } | |||
519 | ||||
520 | window->priv->convert_data.converting = FALSE(0); | |||
521 | ||||
522 | if (window->priv->convert_data.temp_dir != NULL((void*)0)) { | |||
523 | g_free (window->priv->convert_data.temp_dir); | |||
524 | window->priv->convert_data.temp_dir = NULL((void*)0); | |||
525 | } | |||
526 | ||||
527 | if (window->priv->convert_data.new_archive != NULL((void*)0)) { | |||
528 | g_object_unref (window->priv->convert_data.new_archive); | |||
529 | window->priv->convert_data.new_archive = NULL((void*)0); | |||
530 | } | |||
531 | ||||
532 | if (window->priv->convert_data.password != NULL((void*)0)) { | |||
533 | g_free (window->priv->convert_data.password); | |||
534 | window->priv->convert_data.password = NULL((void*)0); | |||
535 | } | |||
536 | } | |||
537 | ||||
538 | ||||
539 | static void | |||
540 | fr_window_free_private_data (FrWindow *window) | |||
541 | { | |||
542 | if (window->priv->update_timeout_handle != 0) { | |||
543 | g_source_remove (window->priv->update_timeout_handle); | |||
544 | window->priv->update_timeout_handle = 0; | |||
545 | } | |||
546 | ||||
547 | while (window->priv->activity_ref > 0) | |||
548 | fr_window_stop_activity_mode (window); | |||
549 | ||||
550 | if (window->priv->progress_timeout != 0) { | |||
551 | g_source_remove (window->priv->progress_timeout); | |||
552 | window->priv->progress_timeout = 0; | |||
553 | } | |||
554 | ||||
555 | if (window->priv->hide_progress_timeout != 0) { | |||
556 | g_source_remove (window->priv->hide_progress_timeout); | |||
557 | window->priv->hide_progress_timeout = 0; | |||
558 | } | |||
559 | ||||
560 | if (window->priv->theme_changed_handler_id != 0) | |||
561 | g_signal_handler_disconnect (icon_theme, window->priv->theme_changed_handler_id); | |||
562 | ||||
563 | fr_window_history_clear (window); | |||
564 | ||||
565 | g_free (window->priv->open_default_dir); | |||
566 | g_free (window->priv->add_default_dir); | |||
567 | g_free (window->priv->extract_default_dir); | |||
568 | g_free (window->priv->archive_uri); | |||
569 | ||||
570 | g_free (window->priv->password); | |||
571 | g_free (window->priv->password_for_paste); | |||
572 | ||||
573 | g_object_unref (window->priv->list_store); | |||
574 | ||||
575 | if (window->priv->clipboard_data != NULL((void*)0)) { | |||
576 | fr_clipboard_data_unref (window->priv->clipboard_data); | |||
577 | window->priv->clipboard_data = NULL((void*)0); | |||
578 | } | |||
579 | if (window->priv->copy_data != NULL((void*)0)) { | |||
580 | fr_clipboard_data_unref (window->priv->copy_data); | |||
581 | window->priv->copy_data = NULL((void*)0); | |||
582 | } | |||
583 | if (window->priv->copy_from_archive != NULL((void*)0)) { | |||
584 | g_object_unref (window->priv->copy_from_archive); | |||
585 | window->priv->copy_from_archive = NULL((void*)0); | |||
586 | } | |||
587 | ||||
588 | fr_window_free_open_files (window); | |||
589 | ||||
590 | fr_window_convert_data_free (window, TRUE(!(0))); | |||
591 | ||||
592 | g_clear_error (&window->priv->drag_error); | |||
593 | path_list_free (window->priv->drag_file_list); | |||
594 | window->priv->drag_file_list = NULL((void*)0); | |||
595 | ||||
596 | if (window->priv->file_popup_menu != NULL((void*)0)) { | |||
597 | ctk_widget_destroy (window->priv->file_popup_menu); | |||
598 | window->priv->file_popup_menu = NULL((void*)0); | |||
599 | } | |||
600 | ||||
601 | if (window->priv->folder_popup_menu != NULL((void*)0)) { | |||
602 | ctk_widget_destroy (window->priv->folder_popup_menu); | |||
603 | window->priv->folder_popup_menu = NULL((void*)0); | |||
604 | } | |||
605 | ||||
606 | if (window->priv->sidebar_folder_popup_menu != NULL((void*)0)) { | |||
607 | ctk_widget_destroy (window->priv->sidebar_folder_popup_menu); | |||
608 | window->priv->sidebar_folder_popup_menu = NULL((void*)0); | |||
609 | } | |||
610 | ||||
611 | g_free (window->priv->last_location); | |||
612 | ||||
613 | fr_window_free_batch_data (window); | |||
614 | fr_window_reset_current_batch_action (window); | |||
615 | ||||
616 | g_free (window->priv->pd_last_archive); | |||
617 | g_free (window->priv->pd_last_message); | |||
618 | g_free (window->priv->extract_here_dir); | |||
619 | ||||
620 | g_settings_set_enum (window->priv->settings_listing, PREF_LISTING_SORT_METHOD"sort-method", window->priv->sort_method); | |||
621 | g_settings_set_enum (window->priv->settings_listing, PREF_LISTING_SORT_TYPE"sort-type", window->priv->sort_type); | |||
622 | g_settings_set_enum (window->priv->settings_listing, PREF_LISTING_LIST_MODE"list-mode", window->priv->last_list_mode); | |||
623 | ||||
624 | _g_object_unref (window->priv->settings_listing); | |||
625 | _g_object_unref (window->priv->settings_ui); | |||
626 | _g_object_unref (window->priv->settings_general); | |||
627 | _g_object_unref (window->priv->settings_dialogs); | |||
628 | ||||
629 | if (window->priv->settings_baul) | |||
630 | _g_object_unref (window->priv->settings_baul); | |||
631 | } | |||
632 | ||||
633 | ||||
634 | static void | |||
635 | fr_window_finalize (GObject *object) | |||
636 | { | |||
637 | FrWindow *window = FR_WINDOW (object)((((FrWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((fr_window_get_type ())))))); | |||
638 | ||||
639 | fr_window_free_open_files (window); | |||
640 | ||||
641 | if (window->archive != NULL((void*)0)) { | |||
642 | g_object_unref (window->archive); | |||
643 | window->archive = NULL((void*)0); | |||
644 | } | |||
645 | ||||
646 | if (window->priv != NULL((void*)0)) { | |||
647 | fr_window_free_private_data (window); | |||
648 | g_free (window->priv); | |||
649 | window->priv = NULL((void*)0); | |||
650 | } | |||
651 | ||||
652 | if (ctk_application_get_windows (CTK_APPLICATION (g_application_get_default ())((((CtkApplication*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((g_application_get_default ())), ((ctk_application_get_type ()))))))) == NULL((void*)0)) { | |||
653 | if (pixbuf_hash != NULL((void*)0)) { | |||
654 | g_hash_table_foreach (pixbuf_hash, | |||
655 | gh_unref_pixbuf, | |||
656 | NULL((void*)0)); | |||
657 | g_hash_table_destroy (pixbuf_hash); | |||
658 | pixbuf_hash = NULL((void*)0); | |||
659 | } | |||
660 | if (tree_pixbuf_hash != NULL((void*)0)) { | |||
661 | g_hash_table_foreach (tree_pixbuf_hash, | |||
662 | gh_unref_pixbuf, | |||
663 | NULL((void*)0)); | |||
664 | g_hash_table_destroy (tree_pixbuf_hash); | |||
665 | tree_pixbuf_hash = NULL((void*)0); | |||
666 | } | |||
667 | } | |||
668 | ||||
669 | G_OBJECT_CLASS (parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((parent_class)), (((GType) ((20) << (2))))))))->finalize (object); | |||
670 | } | |||
671 | ||||
672 | ||||
673 | static gboolean | |||
674 | close__step2 (gpointer data) | |||
675 | { | |||
676 | ctk_widget_destroy (CTK_WIDGET (data)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), ((ctk_widget_get_type ()))))))); | |||
677 | return FALSE(0); | |||
678 | } | |||
679 | ||||
680 | ||||
681 | void | |||
682 | fr_window_close (FrWindow *window) | |||
683 | { | |||
684 | if (window->priv->activity_ref > 0) | |||
685 | return; | |||
686 | ||||
687 | window->priv->closing = TRUE(!(0)); | |||
688 | ||||
689 | if (ctk_widget_get_realized (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))) { | |||
690 | int width, height; | |||
691 | ||||
692 | width = ctk_widget_get_allocated_width (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
693 | height = ctk_widget_get_allocated_height (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
694 | g_settings_set_int (window->priv->settings_ui, PREF_UI_WINDOW_WIDTH"window-width", width); | |||
695 | g_settings_set_int (window->priv->settings_ui, PREF_UI_WINDOW_HEIGHT"window-height", height); | |||
696 | ||||
697 | width = ctk_paned_get_position (CTK_PANED (window->priv->paned)((((CtkPaned*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->paned)), ((ctk_paned_get_type ())))) ))); | |||
698 | if (width > 0) | |||
699 | g_settings_set_int (window->priv->settings_ui, PREF_UI_SIDEBAR_WIDTH"sidebar-width", width); | |||
700 | ||||
701 | width = ctk_tree_view_column_get_width (window->priv->filename_column); | |||
702 | if (width > 0) | |||
703 | g_settings_set_int (window->priv->settings_listing, PREF_LISTING_NAME_COLUMN_WIDTH"name-column-width", width); | |||
704 | } | |||
705 | ||||
706 | g_idle_add (close__step2, window); | |||
707 | } | |||
708 | ||||
709 | ||||
710 | static void | |||
711 | fr_window_class_init (FrWindowClass *class) | |||
712 | { | |||
713 | GObjectClass *gobject_class; | |||
714 | ||||
715 | parent_class = g_type_class_peek_parent (class); | |||
716 | ||||
717 | fr_window_signals[ARCHIVE_LOADED] = | |||
718 | g_signal_new ("archive-loaded", | |||
719 | G_TYPE_FROM_CLASS (class)(((GTypeClass*) (class))->g_type), | |||
720 | G_SIGNAL_RUN_LAST, | |||
721 | G_STRUCT_OFFSET (FrWindowClass, archive_loaded)((glong) __builtin_offsetof(FrWindowClass, archive_loaded)), | |||
722 | NULL((void*)0), NULL((void*)0), | |||
723 | fr_marshal_VOID__BOOLEANg_cclosure_marshal_VOID__BOOLEAN, | |||
724 | G_TYPE_NONE((GType) ((1) << (2))), 1, | |||
725 | G_TYPE_BOOLEAN((GType) ((5) << (2)))); | |||
726 | fr_window_signals[PROGRESS] = | |||
727 | g_signal_new ("progress", | |||
728 | G_TYPE_FROM_CLASS (class)(((GTypeClass*) (class))->g_type), | |||
729 | G_SIGNAL_RUN_LAST, | |||
730 | G_STRUCT_OFFSET (FrWindowClass, progress)((glong) __builtin_offsetof(FrWindowClass, progress)), | |||
731 | NULL((void*)0), NULL((void*)0), | |||
732 | fr_marshal_VOID__DOUBLE_STRING, | |||
733 | G_TYPE_NONE((GType) ((1) << (2))), 2, | |||
734 | G_TYPE_DOUBLE((GType) ((15) << (2))), | |||
735 | G_TYPE_STRING((GType) ((16) << (2)))); | |||
736 | fr_window_signals[READY] = | |||
737 | g_signal_new ("ready", | |||
738 | G_TYPE_FROM_CLASS (class)(((GTypeClass*) (class))->g_type), | |||
739 | G_SIGNAL_RUN_LAST, | |||
740 | G_STRUCT_OFFSET (FrWindowClass, ready)((glong) __builtin_offsetof(FrWindowClass, ready)), | |||
741 | NULL((void*)0), NULL((void*)0), | |||
742 | fr_marshal_VOID__POINTERg_cclosure_marshal_VOID__POINTER, | |||
743 | G_TYPE_NONE((GType) ((1) << (2))), 1, | |||
744 | G_TYPE_POINTER((GType) ((17) << (2)))); | |||
745 | ||||
746 | gobject_class = (GObjectClass*) class; | |||
747 | gobject_class->finalize = fr_window_finalize; | |||
748 | } | |||
749 | ||||
750 | ||||
751 | static void fr_window_update_paste_command_sensitivity (FrWindow *, CtkClipboard *); | |||
752 | ||||
753 | ||||
754 | static void | |||
755 | clipboard_owner_change_cb (CtkClipboard *clipboard, | |||
756 | CdkEvent *event G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
757 | gpointer user_data) | |||
758 | { | |||
759 | fr_window_update_paste_command_sensitivity ((FrWindow *) user_data, clipboard); | |||
760 | } | |||
761 | ||||
762 | ||||
763 | static void | |||
764 | fr_window_realized (CtkWidget *window, | |||
765 | gpointer *data G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
766 | { | |||
767 | CtkClipboard *clipboard; | |||
768 | ||||
769 | clipboard = ctk_widget_get_clipboard (window, FR_CLIPBOARD(cdk_atom_intern_static_string ("_RNGRAMPA_SPECIAL_CLIPBOARD" ))); | |||
770 | g_signal_connect (clipboard,g_signal_connect_data ((clipboard), ("owner_change"), (((GCallback ) (clipboard_owner_change_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
771 | "owner_change",g_signal_connect_data ((clipboard), ("owner_change"), (((GCallback ) (clipboard_owner_change_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
772 | G_CALLBACK (clipboard_owner_change_cb),g_signal_connect_data ((clipboard), ("owner_change"), (((GCallback ) (clipboard_owner_change_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
773 | window)g_signal_connect_data ((clipboard), ("owner_change"), (((GCallback ) (clipboard_owner_change_cb))), (window), ((void*)0), (GConnectFlags ) 0); | |||
774 | } | |||
775 | ||||
776 | ||||
777 | static void | |||
778 | fr_window_unrealized (CtkWidget *window, | |||
779 | gpointer *data G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
780 | { | |||
781 | CtkClipboard *clipboard; | |||
782 | ||||
783 | clipboard = ctk_widget_get_clipboard (window, FR_CLIPBOARD(cdk_atom_intern_static_string ("_RNGRAMPA_SPECIAL_CLIPBOARD" ))); | |||
784 | g_signal_handlers_disconnect_by_func (clipboard,g_signal_handlers_disconnect_matched ((clipboard), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (clipboard_owner_change_cb))), (window)) | |||
785 | G_CALLBACK (clipboard_owner_change_cb),g_signal_handlers_disconnect_matched ((clipboard), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (clipboard_owner_change_cb))), (window)) | |||
786 | window)g_signal_handlers_disconnect_matched ((clipboard), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (clipboard_owner_change_cb))), (window)); | |||
787 | } | |||
788 | ||||
789 | ||||
790 | static void | |||
791 | fr_window_init (FrWindow *window) | |||
792 | { | |||
793 | CtkStyleContext *context; | |||
794 | ||||
795 | window->priv = g_new0 (FrWindowPrivateData, 1)((FrWindowPrivateData *) g_malloc0_n ((1), sizeof (FrWindowPrivateData ))); | |||
796 | window->priv->update_dropped_files = FALSE(0); | |||
797 | window->priv->filter_mode = FALSE(0); | |||
798 | window->priv->batch_title = NULL((void*)0); | |||
799 | window->priv->use_progress_dialog = TRUE(!(0)); | |||
800 | window->priv->batch_title = NULL((void*)0); | |||
801 | ||||
802 | context = ctk_widget_get_style_context (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
803 | ctk_style_context_add_class (context, "grapa-window"); | |||
804 | ||||
805 | g_signal_connect (window,g_signal_connect_data ((window), ("realize"), (((GCallback) ( fr_window_realized))), (((void*)0)), ((void*)0), (GConnectFlags ) 0) | |||
806 | "realize",g_signal_connect_data ((window), ("realize"), (((GCallback) ( fr_window_realized))), (((void*)0)), ((void*)0), (GConnectFlags ) 0) | |||
807 | G_CALLBACK (fr_window_realized),g_signal_connect_data ((window), ("realize"), (((GCallback) ( fr_window_realized))), (((void*)0)), ((void*)0), (GConnectFlags ) 0) | |||
808 | NULL)g_signal_connect_data ((window), ("realize"), (((GCallback) ( fr_window_realized))), (((void*)0)), ((void*)0), (GConnectFlags ) 0); | |||
809 | g_signal_connect (window,g_signal_connect_data ((window), ("unrealize"), (((GCallback) (fr_window_unrealized))), (((void*)0)), ((void*)0), (GConnectFlags ) 0) | |||
810 | "unrealize",g_signal_connect_data ((window), ("unrealize"), (((GCallback) (fr_window_unrealized))), (((void*)0)), ((void*)0), (GConnectFlags ) 0) | |||
811 | G_CALLBACK (fr_window_unrealized),g_signal_connect_data ((window), ("unrealize"), (((GCallback) (fr_window_unrealized))), (((void*)0)), ((void*)0), (GConnectFlags ) 0) | |||
812 | NULL)g_signal_connect_data ((window), ("unrealize"), (((GCallback) (fr_window_unrealized))), (((void*)0)), ((void*)0), (GConnectFlags ) 0); | |||
813 | } | |||
814 | ||||
815 | ||||
816 | GType | |||
817 | fr_window_get_type (void) | |||
818 | { | |||
819 | static GType type = 0; | |||
820 | ||||
821 | if (! type) { | |||
822 | GTypeInfo type_info = { | |||
823 | sizeof (FrWindowClass), | |||
824 | NULL((void*)0), | |||
825 | NULL((void*)0), | |||
826 | (GClassInitFunc) fr_window_class_init, | |||
827 | NULL((void*)0), | |||
828 | NULL((void*)0), | |||
829 | sizeof (FrWindow), | |||
830 | 0, | |||
831 | (GInstanceInitFunc) fr_window_init, | |||
832 | NULL((void*)0) | |||
833 | }; | |||
834 | ||||
835 | type = g_type_register_static (CTK_TYPE_APPLICATION_WINDOW(ctk_application_window_get_type ()), | |||
836 | "FrWindow", | |||
837 | &type_info, | |||
838 | 0); | |||
839 | } | |||
840 | ||||
841 | return type; | |||
842 | } | |||
843 | ||||
844 | ||||
845 | /* -- window history -- */ | |||
846 | ||||
847 | ||||
848 | #if 0 | |||
849 | static void | |||
850 | fr_window_history_print (FrWindow *window) | |||
851 | { | |||
852 | GList *list; | |||
853 | ||||
854 | debug (DEBUG_INFO"fr-window.c", 854, __FUNCTION__, "history:\n"); | |||
855 | for (list = window->priv->history; list; list = list->next) | |||
856 | g_print ("\t%s %s\n", | |||
857 | (char*) list->data, | |||
858 | (list == window->priv->history_current)? "<-": ""); | |||
859 | g_print ("\n"); | |||
860 | } | |||
861 | #endif | |||
862 | ||||
863 | ||||
864 | static void | |||
865 | fr_window_history_add (FrWindow *window, | |||
866 | const char *path) | |||
867 | { | |||
868 | if ((window->priv->history_current == NULL((void*)0)) || (g_strcmp0 (path, window->priv->history_current->data) != 0)) { | |||
869 | GList *scan; | |||
870 | GList *new_current = NULL((void*)0); | |||
871 | ||||
872 | /* search the path in the history */ | |||
873 | for (scan = window->priv->history_current; scan; scan = scan->next) { | |||
874 | char *path_in_history = scan->data; | |||
875 | ||||
876 | if (g_strcmp0 (path, path_in_history) == 0) { | |||
877 | new_current = scan; | |||
878 | break; | |||
879 | } | |||
880 | } | |||
881 | ||||
882 | if (new_current != NULL((void*)0)) { | |||
883 | window->priv->history_current = new_current; | |||
884 | } | |||
885 | else { | |||
886 | /* remove all the paths after the current position */ | |||
887 | for (scan = window->priv->history; scan && (scan != window->priv->history_current); /* void */) { | |||
888 | GList *next = scan->next; | |||
889 | ||||
890 | window->priv->history = g_list_remove_link (window->priv->history, scan); | |||
891 | path_list_free (scan); | |||
892 | ||||
893 | scan = next; | |||
894 | } | |||
895 | ||||
896 | window->priv->history = g_list_prepend (window->priv->history, g_strdup (path)g_strdup_inline (path)); | |||
897 | window->priv->history_current = window->priv->history; | |||
898 | } | |||
899 | } | |||
900 | } | |||
901 | ||||
902 | ||||
903 | static void | |||
904 | fr_window_history_pop (FrWindow *window) | |||
905 | { | |||
906 | GList *first; | |||
907 | ||||
908 | if (window->priv->history == NULL((void*)0)) | |||
909 | return; | |||
910 | ||||
911 | first = window->priv->history; | |||
912 | window->priv->history = g_list_remove_link (window->priv->history, first); | |||
913 | if (window->priv->history_current == first) | |||
914 | window->priv->history_current = window->priv->history; | |||
915 | g_free (first->data); | |||
916 | g_list_free (first); | |||
917 | } | |||
918 | ||||
919 | ||||
920 | /* -- window_update_file_list -- */ | |||
921 | ||||
922 | ||||
923 | static GPtrArray * | |||
924 | fr_window_get_current_dir_list (FrWindow *window) | |||
925 | { | |||
926 | GPtrArray *files; | |||
927 | guint i; | |||
928 | ||||
929 | files = g_ptr_array_sized_new (128); | |||
930 | ||||
931 | for (i = 0; i < window->archive->command->files->len; i++) { | |||
932 | FileData *fdata = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i]; | |||
933 | ||||
934 | if (fdata->list_name == NULL((void*)0)) | |||
935 | continue; | |||
936 | g_ptr_array_add (files, fdata); | |||
937 | } | |||
938 | ||||
939 | return files; | |||
940 | } | |||
941 | ||||
942 | ||||
943 | static gint | |||
944 | sort_by_name (gconstpointer ptr1, | |||
945 | gconstpointer ptr2) | |||
946 | { | |||
947 | FileData *fdata1 = *((FileData **) ptr1); | |||
948 | FileData *fdata2 = *((FileData **) ptr2); | |||
949 | ||||
950 | if (file_data_is_dir (fdata1) != file_data_is_dir (fdata2)) { | |||
951 | if (file_data_is_dir (fdata1)) | |||
952 | return -1; | |||
953 | else | |||
954 | return 1; | |||
955 | } | |||
956 | ||||
957 | return strcmp (fdata1->sort_key, fdata2->sort_key); | |||
958 | } | |||
959 | ||||
960 | ||||
961 | static gint | |||
962 | sort_by_size (gconstpointer ptr1, | |||
963 | gconstpointer ptr2) | |||
964 | { | |||
965 | FileData *fdata1 = *((FileData **) ptr1); | |||
966 | FileData *fdata2 = *((FileData **) ptr2); | |||
967 | ||||
968 | if (file_data_is_dir (fdata1) != file_data_is_dir (fdata2)) { | |||
969 | if (file_data_is_dir (fdata1)) | |||
970 | return -1; | |||
971 | else | |||
972 | return 1; | |||
973 | } | |||
974 | else if (file_data_is_dir (fdata1) && file_data_is_dir (fdata2)) { | |||
975 | if (fdata1->dir_size > fdata2->dir_size) | |||
976 | return 1; | |||
977 | else | |||
978 | return -1; | |||
979 | } | |||
980 | ||||
981 | if (fdata1->size == fdata2->size) | |||
982 | return sort_by_name (ptr1, ptr2); | |||
983 | else if (fdata1->size > fdata2->size) | |||
984 | return 1; | |||
985 | else | |||
986 | return -1; | |||
987 | } | |||
988 | ||||
989 | ||||
990 | static gint | |||
991 | sort_by_type (gconstpointer ptr1, | |||
992 | gconstpointer ptr2) | |||
993 | { | |||
994 | FileData *fdata1 = *((FileData **) ptr1); | |||
995 | FileData *fdata2 = *((FileData **) ptr2); | |||
996 | int result; | |||
997 | const char *desc1, *desc2; | |||
998 | ||||
999 | if (file_data_is_dir (fdata1) != file_data_is_dir (fdata2)) { | |||
1000 | if (file_data_is_dir (fdata1)) | |||
1001 | return -1; | |||
1002 | else | |||
1003 | return 1; | |||
1004 | } | |||
1005 | else if (file_data_is_dir (fdata1) && file_data_is_dir (fdata2)) | |||
1006 | return sort_by_name (ptr1, ptr2); | |||
1007 | ||||
1008 | desc1 = g_content_type_get_description (fdata1->content_type); | |||
1009 | desc2 = g_content_type_get_description (fdata2->content_type); | |||
1010 | ||||
1011 | result = strcasecmp (desc1, desc2); | |||
1012 | if (result == 0) | |||
1013 | return sort_by_name (ptr1, ptr2); | |||
1014 | else | |||
1015 | return result; | |||
1016 | } | |||
1017 | ||||
1018 | ||||
1019 | static gint | |||
1020 | sort_by_time (gconstpointer ptr1, | |||
1021 | gconstpointer ptr2) | |||
1022 | { | |||
1023 | FileData *fdata1 = *((FileData **) ptr1); | |||
1024 | FileData *fdata2 = *((FileData **) ptr2); | |||
1025 | ||||
1026 | if (file_data_is_dir (fdata1) != file_data_is_dir (fdata2)) { | |||
1027 | if (file_data_is_dir (fdata1)) | |||
1028 | return -1; | |||
1029 | else | |||
1030 | return 1; | |||
1031 | } | |||
1032 | else if (file_data_is_dir (fdata1) && file_data_is_dir (fdata2)) | |||
1033 | return sort_by_name (ptr1, ptr2); | |||
1034 | ||||
1035 | if (fdata1->modified == fdata2->modified) | |||
1036 | return sort_by_name (ptr1, ptr2); | |||
1037 | else if (fdata1->modified > fdata2->modified) | |||
1038 | return 1; | |||
1039 | else | |||
1040 | return -1; | |||
1041 | } | |||
1042 | ||||
1043 | ||||
1044 | static gint | |||
1045 | sort_by_path (gconstpointer ptr1, | |||
1046 | gconstpointer ptr2) | |||
1047 | { | |||
1048 | FileData *fdata1 = *((FileData **) ptr1); | |||
1049 | FileData *fdata2 = *((FileData **) ptr2); | |||
1050 | int result; | |||
1051 | ||||
1052 | if (file_data_is_dir (fdata1) != file_data_is_dir (fdata2)) { | |||
1053 | if (file_data_is_dir (fdata1)) | |||
1054 | return -1; | |||
1055 | else | |||
1056 | return 1; | |||
1057 | } | |||
1058 | else if (file_data_is_dir (fdata1) && file_data_is_dir (fdata2)) | |||
1059 | return sort_by_name (ptr1, ptr2); | |||
1060 | ||||
1061 | /* 2 files */ | |||
1062 | ||||
1063 | result = strcasecmp (fdata1->path, fdata2->path); | |||
1064 | if (result == 0) | |||
1065 | return sort_by_name (ptr1, ptr2); | |||
1066 | else | |||
1067 | return result; | |||
1068 | } | |||
1069 | ||||
1070 | ||||
1071 | static guint64 | |||
1072 | get_dir_size (FrWindow *window, | |||
1073 | const char *current_dir, | |||
1074 | const char *name) | |||
1075 | { | |||
1076 | guint64 size; | |||
1077 | char *dirname; | |||
1078 | int dirname_l; | |||
1079 | guint i; | |||
1080 | ||||
1081 | dirname = g_strconcat (current_dir, name, "/", NULL((void*)0)); | |||
1082 | dirname_l = strlen (dirname); | |||
1083 | ||||
1084 | size = 0; | |||
1085 | for (i = 0; i < window->archive->command->files->len; i++) { | |||
1086 | FileData *fd = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i]; | |||
1087 | ||||
1088 | if (strncmp (dirname, fd->full_path, dirname_l) == 0) | |||
1089 | size += fd->size; | |||
1090 | } | |||
1091 | ||||
1092 | g_free (dirname); | |||
1093 | ||||
1094 | return size; | |||
1095 | } | |||
1096 | ||||
1097 | ||||
1098 | static gboolean | |||
1099 | file_data_respects_filter (FrWindow *window, | |||
1100 | FileData *fdata) | |||
1101 | { | |||
1102 | const char *filter; | |||
1103 | ||||
1104 | filter = ctk_entry_get_text (CTK_ENTRY (window->priv->filter_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->filter_entry)), ((ctk_entry_get_type ()))))))); | |||
1105 | if ((fdata == NULL((void*)0)) || (filter == NULL((void*)0)) || (*filter == '\0')) | |||
1106 | return TRUE(!(0)); | |||
1107 | ||||
1108 | if (fdata->dir || (fdata->name == NULL((void*)0))) | |||
1109 | return FALSE(0); | |||
1110 | ||||
1111 | return strncasecmp (fdata->name, filter, strlen (filter)) == 0; | |||
1112 | } | |||
1113 | ||||
1114 | ||||
1115 | static gboolean | |||
1116 | compute_file_list_name (FrWindow *window, | |||
1117 | FileData *fdata, | |||
1118 | const char *current_dir, | |||
1119 | size_t current_dir_len, | |||
1120 | GHashTable *names_hash, | |||
1121 | gboolean *different_name) | |||
1122 | { | |||
1123 | register char *scan, *end; | |||
1124 | ||||
1125 | *different_name = FALSE(0); | |||
1126 | ||||
1127 | if (! file_data_respects_filter (window, fdata)) | |||
1128 | return FALSE(0); | |||
1129 | ||||
1130 | if (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT) { | |||
1131 | if (!(fdata->dir)) | |||
1132 | file_data_set_list_name (fdata, fdata->name); | |||
1133 | return FALSE(0); | |||
1134 | } | |||
1135 | ||||
1136 | if (strncmp (fdata->full_path, current_dir, current_dir_len) != 0) { | |||
1137 | *different_name = TRUE(!(0)); | |||
1138 | return FALSE(0); | |||
1139 | } | |||
1140 | ||||
1141 | if (strlen (fdata->full_path) == current_dir_len) | |||
1142 | return FALSE(0); | |||
1143 | ||||
1144 | scan = fdata->full_path + current_dir_len; | |||
1145 | end = strchr (scan, '/'); | |||
1146 | if ((end == NULL((void*)0)) && ! fdata->dir) { /* file */ | |||
1147 | file_data_set_list_name (fdata, scan); | |||
1148 | } | |||
1149 | else { /* folder */ | |||
1150 | char *dir_name; | |||
1151 | ||||
1152 | if (end != NULL((void*)0)) | |||
1153 | dir_name = g_strndup (scan, end - scan); | |||
1154 | else | |||
1155 | dir_name = g_strdup (scan)g_strdup_inline (scan); | |||
1156 | ||||
1157 | /* avoid to insert duplicated folders */ | |||
1158 | if (g_hash_table_lookup (names_hash, dir_name) != NULL((void*)0)) { | |||
1159 | g_free (dir_name); | |||
1160 | return FALSE(0); | |||
1161 | } | |||
1162 | g_hash_table_insert (names_hash, dir_name, GINT_TO_POINTER (1)((gpointer) (glong) (1))); | |||
1163 | ||||
1164 | if ((end != NULL((void*)0)) && (*(end + 1) != '\0')) | |||
1165 | fdata->list_dir = TRUE(!(0)); | |||
1166 | file_data_set_list_name (fdata, dir_name); | |||
1167 | fdata->dir_size = get_dir_size (window, current_dir, dir_name); | |||
1168 | } | |||
1169 | ||||
1170 | return TRUE(!(0)); | |||
1171 | } | |||
1172 | ||||
1173 | ||||
1174 | static void | |||
1175 | fr_window_compute_list_names (FrWindow *window, | |||
1176 | GPtrArray *files) | |||
1177 | { | |||
1178 | const char *current_dir; | |||
1179 | size_t current_dir_len; | |||
1180 | GHashTable *names_hash; | |||
1181 | guint i; | |||
1182 | gboolean visible_list_started = FALSE(0); | |||
1183 | gboolean visible_list_completed = FALSE(0); | |||
1184 | gboolean different_name; | |||
1185 | ||||
1186 | current_dir = fr_window_get_current_location (window); | |||
1187 | current_dir_len = strlen (current_dir); | |||
1188 | names_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL((void*)0)); | |||
1189 | ||||
1190 | for (i = 0; i < files->len; i++) { | |||
1191 | FileData *fdata = g_ptr_array_index (files, i)((files)->pdata)[i]; | |||
1192 | ||||
1193 | file_data_set_list_name (fdata, NULL((void*)0)); | |||
1194 | fdata->list_dir = FALSE(0); | |||
1195 | ||||
1196 | /* the files array is sorted by path, when the visible list | |||
1197 | * is started and we find a path that doesn't match the | |||
1198 | * current_dir path, the following files can't match | |||
1199 | * the current_dir path. */ | |||
1200 | ||||
1201 | if (visible_list_completed) | |||
1202 | continue; | |||
1203 | ||||
1204 | if (compute_file_list_name (window, fdata, current_dir, current_dir_len, names_hash, &different_name)) { | |||
1205 | visible_list_started = TRUE(!(0)); | |||
1206 | } | |||
1207 | else if (visible_list_started && different_name) | |||
1208 | visible_list_completed = TRUE(!(0)); | |||
1209 | } | |||
1210 | ||||
1211 | g_hash_table_destroy (names_hash); | |||
1212 | } | |||
1213 | ||||
1214 | ||||
1215 | static gboolean | |||
1216 | fr_window_dir_exists_in_archive (FrWindow *window, | |||
1217 | const char *dir_name) | |||
1218 | { | |||
1219 | int dir_name_len; | |||
1220 | guint i; | |||
1221 | ||||
1222 | if (dir_name == NULL((void*)0)) | |||
1223 | return FALSE(0); | |||
1224 | ||||
1225 | dir_name_len = strlen (dir_name); | |||
1226 | if (dir_name_len == 0) | |||
1227 | return TRUE(!(0)); | |||
1228 | ||||
1229 | if (strcmp (dir_name, "/") == 0) | |||
1230 | return TRUE(!(0)); | |||
1231 | ||||
1232 | for (i = 0; i < window->archive->command->files->len; i++) { | |||
1233 | FileData *fdata = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i]; | |||
1234 | ||||
1235 | if (strncmp (dir_name, fdata->full_path, dir_name_len) == 0) { | |||
1236 | return TRUE(!(0)); | |||
1237 | } | |||
1238 | else if (fdata->dir | |||
1239 | && (fdata->full_path[strlen (fdata->full_path) -1] != '/') | |||
1240 | && (strncmp (dir_name, fdata->full_path, dir_name_len - 1) == 0)) | |||
1241 | { | |||
1242 | return TRUE(!(0)); | |||
1243 | } | |||
1244 | } | |||
1245 | ||||
1246 | return FALSE(0); | |||
1247 | } | |||
1248 | ||||
1249 | ||||
1250 | static char * | |||
1251 | get_parent_dir (const char *current_dir) | |||
1252 | { | |||
1253 | char *dir; | |||
1254 | char *new_dir; | |||
1255 | char *retval; | |||
1256 | ||||
1257 | if (current_dir == NULL((void*)0)) | |||
1258 | return NULL((void*)0); | |||
1259 | if (strcmp (current_dir, "/") == 0) | |||
1260 | return g_strdup ("/")g_strdup_inline ("/"); | |||
1261 | ||||
1262 | dir = g_strdup (current_dir)g_strdup_inline (current_dir); | |||
1263 | dir[strlen (dir) - 1] = 0; | |||
1264 | new_dir = remove_level_from_path (dir); | |||
1265 | g_free (dir); | |||
1266 | ||||
1267 | if (new_dir[strlen (new_dir) - 1] == '/') | |||
1268 | retval = new_dir; | |||
1269 | else { | |||
1270 | retval = g_strconcat (new_dir, "/", NULL((void*)0)); | |||
1271 | g_free (new_dir); | |||
1272 | } | |||
1273 | ||||
1274 | return retval; | |||
1275 | } | |||
1276 | ||||
1277 | ||||
1278 | static void fr_window_update_statusbar_list_info (FrWindow *window); | |||
1279 | ||||
1280 | ||||
1281 | static GdkPixbuf * | |||
1282 | get_mime_type_icon (const char *mime_type) | |||
1283 | { | |||
1284 | GdkPixbuf *pixbuf = NULL((void*)0); | |||
1285 | ||||
1286 | pixbuf = g_hash_table_lookup (tree_pixbuf_hash, mime_type); | |||
1287 | if (pixbuf != NULL((void*)0)) { | |||
1288 | g_object_ref (G_OBJECT (pixbuf))((__typeof__ (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((pixbuf)), (((GType) ((20) << (2))) ))))))) (g_object_ref) (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((pixbuf)), (((GType) ((20) << (2))) ))))))); | |||
1289 | return pixbuf; | |||
1290 | } | |||
1291 | ||||
1292 | pixbuf = get_mime_type_pixbuf (mime_type, file_list_icon_size, icon_theme); | |||
1293 | if (pixbuf == NULL((void*)0)) | |||
1294 | return NULL((void*)0); | |||
1295 | ||||
1296 | pixbuf = gdk_pixbuf_copy (pixbuf); | |||
1297 | g_hash_table_insert (tree_pixbuf_hash, (gpointer) mime_type, pixbuf); | |||
1298 | g_object_ref (G_OBJECT (pixbuf))((__typeof__ (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((pixbuf)), (((GType) ((20) << (2))) ))))))) (g_object_ref) (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((pixbuf)), (((GType) ((20) << (2))) ))))))); | |||
1299 | ||||
1300 | return pixbuf; | |||
1301 | } | |||
1302 | ||||
1303 | ||||
1304 | static GdkPixbuf * | |||
1305 | get_icon (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
1306 | FileData *fdata) | |||
1307 | { | |||
1308 | GdkPixbuf *pixbuf = NULL((void*)0); | |||
1309 | const char *content_type; | |||
1310 | GIcon *icon; | |||
1311 | ||||
1312 | if (file_data_is_dir (fdata)) | |||
1313 | content_type = MIME_TYPE_DIRECTORY"folder"; | |||
1314 | else | |||
1315 | content_type = fdata->content_type; | |||
1316 | ||||
1317 | /* look in the hash table. */ | |||
1318 | ||||
1319 | pixbuf = g_hash_table_lookup (pixbuf_hash, content_type); | |||
1320 | if (pixbuf != NULL((void*)0)) { | |||
1321 | g_object_ref (G_OBJECT (pixbuf))((__typeof__ (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((pixbuf)), (((GType) ((20) << (2))) ))))))) (g_object_ref) (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((pixbuf)), (((GType) ((20) << (2))) ))))))); | |||
1322 | return pixbuf; | |||
1323 | } | |||
1324 | ||||
1325 | icon = g_content_type_get_icon (content_type); | |||
1326 | pixbuf = get_icon_pixbuf (icon, file_list_icon_size, icon_theme); | |||
1327 | g_object_unref (icon); | |||
1328 | ||||
1329 | if (pixbuf == NULL((void*)0)) | |||
1330 | return NULL((void*)0); | |||
1331 | ||||
1332 | pixbuf = gdk_pixbuf_copy (pixbuf); | |||
1333 | g_hash_table_insert (pixbuf_hash, (gpointer) content_type, pixbuf); | |||
1334 | g_object_ref (G_OBJECT (pixbuf))((__typeof__ (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((pixbuf)), (((GType) ((20) << (2))) ))))))) (g_object_ref) (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((pixbuf)), (((GType) ((20) << (2))) ))))))); | |||
1335 | ||||
1336 | return pixbuf; | |||
1337 | } | |||
1338 | ||||
1339 | ||||
1340 | static GdkPixbuf * | |||
1341 | get_emblem (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
1342 | FileData *fdata) | |||
1343 | { | |||
1344 | GdkPixbuf *pixbuf = NULL((void*)0); | |||
1345 | ||||
1346 | if (! fdata->encrypted) | |||
1347 | return NULL((void*)0); | |||
1348 | ||||
1349 | /* encrypted */ | |||
1350 | ||||
1351 | pixbuf = g_hash_table_lookup (pixbuf_hash, "emblem-nowrite"); | |||
1352 | if (pixbuf != NULL((void*)0)) { | |||
1353 | g_object_ref (G_OBJECT (pixbuf))((__typeof__ (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((pixbuf)), (((GType) ((20) << (2))) ))))))) (g_object_ref) (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((pixbuf)), (((GType) ((20) << (2))) ))))))); | |||
1354 | return pixbuf; | |||
1355 | } | |||
1356 | ||||
1357 | pixbuf = ctk_icon_theme_load_icon (icon_theme, | |||
1358 | "emblem-nowrite", | |||
1359 | file_list_icon_size, | |||
1360 | 0, | |||
1361 | NULL((void*)0)); | |||
1362 | if (pixbuf == NULL((void*)0)) | |||
1363 | return NULL((void*)0); | |||
1364 | ||||
1365 | pixbuf = gdk_pixbuf_copy (pixbuf); | |||
1366 | g_hash_table_insert (pixbuf_hash, (gpointer) "emblem-nowrite", pixbuf); | |||
1367 | g_object_ref (G_OBJECT (pixbuf))((__typeof__ (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((pixbuf)), (((GType) ((20) << (2))) ))))))) (g_object_ref) (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((pixbuf)), (((GType) ((20) << (2))) ))))))); | |||
1368 | ||||
1369 | return pixbuf; | |||
1370 | } | |||
1371 | ||||
1372 | ||||
1373 | static int | |||
1374 | get_column_from_sort_method (FrWindowSortMethod sort_method) | |||
1375 | { | |||
1376 | switch (sort_method) { | |||
1377 | case FR_WINDOW_SORT_BY_NAME: return COLUMN_NAME; | |||
1378 | case FR_WINDOW_SORT_BY_SIZE: return COLUMN_SIZE; | |||
1379 | case FR_WINDOW_SORT_BY_TYPE: return COLUMN_TYPE; | |||
1380 | case FR_WINDOW_SORT_BY_TIME: return COLUMN_TIME; | |||
1381 | case FR_WINDOW_SORT_BY_PATH: return COLUMN_PATH; | |||
1382 | default: | |||
1383 | break; | |||
1384 | } | |||
1385 | ||||
1386 | return COLUMN_NAME; | |||
1387 | } | |||
1388 | ||||
1389 | ||||
1390 | static int | |||
1391 | get_sort_method_from_column (int column_id) | |||
1392 | { | |||
1393 | switch (column_id) { | |||
1394 | case COLUMN_NAME: return FR_WINDOW_SORT_BY_NAME; | |||
1395 | case COLUMN_SIZE: return FR_WINDOW_SORT_BY_SIZE; | |||
1396 | case COLUMN_TYPE: return FR_WINDOW_SORT_BY_TYPE; | |||
1397 | case COLUMN_TIME: return FR_WINDOW_SORT_BY_TIME; | |||
1398 | case COLUMN_PATH: return FR_WINDOW_SORT_BY_PATH; | |||
1399 | default: | |||
1400 | break; | |||
1401 | } | |||
1402 | ||||
1403 | return FR_WINDOW_SORT_BY_NAME; | |||
1404 | } | |||
1405 | ||||
1406 | ||||
1407 | static void | |||
1408 | add_selected_from_list_view (CtkTreeModel *model, | |||
1409 | CtkTreePath *path G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
1410 | CtkTreeIter *iter, | |||
1411 | gpointer data) | |||
1412 | { | |||
1413 | GList **list = data; | |||
1414 | FileData *fdata; | |||
1415 | ||||
1416 | ctk_tree_model_get (model, iter, | |||
1417 | COLUMN_FILE_DATA, &fdata, | |||
1418 | -1); | |||
1419 | *list = g_list_prepend (*list, fdata); | |||
1420 | } | |||
1421 | ||||
1422 | ||||
1423 | static void | |||
1424 | add_selected_from_tree_view (CtkTreeModel *model, | |||
1425 | CtkTreePath *path G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
1426 | CtkTreeIter *iter, | |||
1427 | gpointer data) | |||
1428 | { | |||
1429 | GList **list = data; | |||
1430 | char *dir_path; | |||
1431 | ||||
1432 | ctk_tree_model_get (model, iter, | |||
1433 | TREE_COLUMN_PATH, &dir_path, | |||
1434 | -1); | |||
1435 | *list = g_list_prepend (*list, dir_path); | |||
1436 | } | |||
1437 | ||||
1438 | ||||
1439 | static void | |||
1440 | add_selected_fd (CtkTreeModel *model, | |||
1441 | CtkTreePath *path G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
1442 | CtkTreeIter *iter, | |||
1443 | gpointer data) | |||
1444 | { | |||
1445 | GList **list = data; | |||
1446 | FileData *fdata; | |||
1447 | ||||
1448 | ctk_tree_model_get (model, iter, | |||
1449 | COLUMN_FILE_DATA, &fdata, | |||
1450 | -1); | |||
1451 | if (! fdata->list_dir) | |||
1452 | *list = g_list_prepend (*list, fdata); | |||
1453 | } | |||
1454 | ||||
1455 | ||||
1456 | static GList * | |||
1457 | get_selection_as_fd (FrWindow *window) | |||
1458 | { | |||
1459 | CtkTreeSelection *selection; | |||
1460 | GList *list = NULL((void*)0); | |||
1461 | ||||
1462 | if (! ctk_widget_get_realized (window->priv->list_view)) | |||
1463 | return NULL((void*)0); | |||
1464 | ||||
1465 | selection = ctk_tree_view_get_selection (CTK_TREE_VIEW (window->priv->list_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_view)), ((ctk_tree_view_get_type ()))))))); | |||
1466 | if (selection == NULL((void*)0)) | |||
1467 | return NULL((void*)0); | |||
1468 | ctk_tree_selection_selected_foreach (selection, add_selected_fd, &list); | |||
1469 | ||||
1470 | return list; | |||
1471 | } | |||
1472 | ||||
1473 | ||||
1474 | static void | |||
1475 | fr_window_update_statusbar_list_info (FrWindow *window) | |||
1476 | { | |||
1477 | char *info, *archive_info, *selected_info; | |||
1478 | char *size_txt, *sel_size_txt; | |||
1479 | int tot_n, sel_n; | |||
1480 | goffset tot_size, sel_size; | |||
1481 | GList *scan; | |||
1482 | ||||
1483 | if (window == NULL((void*)0)) | |||
1484 | return; | |||
1485 | ||||
1486 | if ((window->archive == NULL((void*)0)) || (window->archive->command == NULL((void*)0))) { | |||
1487 | ctk_statusbar_pop (CTK_STATUSBAR (window->priv->statusbar)((((CtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->statusbar)), ((ctk_statusbar_get_type ())))))), window->priv->list_info_cid); | |||
1488 | return; | |||
1489 | } | |||
1490 | ||||
1491 | tot_n = 0; | |||
1492 | tot_size = 0; | |||
1493 | ||||
1494 | if (window->priv->archive_present) { | |||
1495 | GPtrArray *files = fr_window_get_current_dir_list (window); | |||
1496 | guint i; | |||
1497 | ||||
1498 | for (i = 0; i < files->len; i++) { | |||
1499 | FileData *fd = g_ptr_array_index (files, i)((files)->pdata)[i]; | |||
1500 | ||||
1501 | tot_n++; | |||
1502 | if (! file_data_is_dir (fd)) | |||
1503 | tot_size += fd->size; | |||
1504 | else | |||
1505 | tot_size += fd->dir_size; | |||
1506 | } | |||
1507 | g_ptr_array_free (files, TRUE(!(0))); | |||
1508 | } | |||
1509 | ||||
1510 | sel_n = 0; | |||
1511 | sel_size = 0; | |||
1512 | ||||
1513 | if (window->priv->archive_present) { | |||
1514 | GList *selection = get_selection_as_fd (window); | |||
1515 | ||||
1516 | for (scan = selection; scan; scan = scan->next) { | |||
1517 | FileData *fd = scan->data; | |||
1518 | ||||
1519 | sel_n++; | |||
1520 | if (! file_data_is_dir (fd)) | |||
1521 | sel_size += fd->size; | |||
1522 | } | |||
1523 | g_list_free (selection); | |||
1524 | } | |||
1525 | ||||
1526 | size_txt = g_format_size (tot_size); | |||
1527 | sel_size_txt = g_format_size (sel_size); | |||
1528 | ||||
1529 | if (tot_n == 0) | |||
1530 | archive_info = g_strdup ("")g_strdup_inline (""); | |||
1531 | else | |||
1532 | archive_info = g_strdup_printf (ngettext ("%d object (%s)", "%d objects (%s)", tot_n), tot_n, size_txt); | |||
1533 | ||||
1534 | if (sel_n == 0) | |||
1535 | selected_info = g_strdup ("")g_strdup_inline (""); | |||
1536 | else | |||
1537 | selected_info = g_strdup_printf (ngettext ("%d object selected (%s)", "%d objects selected (%s)", sel_n), sel_n, sel_size_txt); | |||
1538 | ||||
1539 | info = g_strconcat (archive_info, | |||
1540 | ((sel_n == 0) ? NULL((void*)0) : ", "), | |||
1541 | selected_info, | |||
1542 | NULL((void*)0)); | |||
1543 | ||||
1544 | ctk_statusbar_push (CTK_STATUSBAR (window->priv->statusbar)((((CtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->statusbar)), ((ctk_statusbar_get_type ())))))), window->priv->list_info_cid, info); | |||
1545 | ||||
1546 | g_free (size_txt); | |||
1547 | g_free (sel_size_txt); | |||
1548 | g_free (archive_info); | |||
1549 | g_free (selected_info); | |||
1550 | g_free (info); | |||
1551 | } | |||
1552 | ||||
1553 | ||||
1554 | static void | |||
1555 | fr_window_populate_file_list (FrWindow *window, | |||
1556 | GPtrArray *files) | |||
1557 | { | |||
1558 | guint i; | |||
1559 | ||||
1560 | ctk_list_store_clear (window->priv->list_store); | |||
1561 | ||||
1562 | ctk_tree_sortable_set_sort_column_id (CTK_TREE_SORTABLE (window->priv->list_store)((((CtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_store)), ((ctk_tree_sortable_get_type ())))))), | |||
1563 | CTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID(-1), | |||
1564 | CTK_SORT_ASCENDING); | |||
1565 | ||||
1566 | for (i = 0; i < files->len; i++) { | |||
1567 | FileData *fdata = g_ptr_array_index (files, i)((files)->pdata)[i]; | |||
1568 | CtkTreeIter iter; | |||
1569 | GdkPixbuf *icon, *emblem; | |||
1570 | char *utf8_name; | |||
1571 | ||||
1572 | if (fdata->list_name == NULL((void*)0)) | |||
1573 | continue; | |||
1574 | ||||
1575 | ctk_list_store_append (window->priv->list_store, &iter); | |||
1576 | ||||
1577 | icon = get_icon (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))), fdata); | |||
1578 | utf8_name = g_filename_display_name (fdata->list_name); | |||
1579 | emblem = get_emblem (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))), fdata); | |||
1580 | ||||
1581 | if (file_data_is_dir (fdata)) { | |||
1582 | char *utf8_path; | |||
1583 | char *tmp; | |||
1584 | char *s_size; | |||
1585 | char *s_time; | |||
1586 | ||||
1587 | if (fdata->list_dir) | |||
1588 | tmp = remove_ending_separator (fr_window_get_current_location (window)); | |||
1589 | ||||
1590 | else | |||
1591 | tmp = remove_level_from_path (fdata->path); | |||
1592 | utf8_path = g_filename_display_name (tmp); | |||
1593 | g_free (tmp); | |||
1594 | ||||
1595 | s_size = g_format_size (fdata->dir_size); | |||
1596 | ||||
1597 | if (fdata->list_dir) { | |||
1598 | s_time = g_strdup ("")g_strdup_inline (""); | |||
1599 | } else { | |||
1600 | GDateTime *date_time; | |||
1601 | date_time = g_date_time_new_from_unix_local (fdata->modified); | |||
1602 | s_time = g_date_time_format (date_time, _("%d %B %Y, %H:%M")gettext ("%d %B %Y, %H:%M")); | |||
1603 | g_date_time_unref (date_time); | |||
1604 | } | |||
1605 | ||||
1606 | ctk_list_store_set (window->priv->list_store, &iter, | |||
1607 | COLUMN_FILE_DATA, fdata, | |||
1608 | COLUMN_ICON, icon, | |||
1609 | COLUMN_NAME, utf8_name, | |||
1610 | COLUMN_EMBLEM, emblem, | |||
1611 | COLUMN_TYPE, _("Folder")gettext ("Folder"), | |||
1612 | COLUMN_SIZE, s_size, | |||
1613 | COLUMN_TIME, s_time, | |||
1614 | COLUMN_PATH, utf8_path, | |||
1615 | -1); | |||
1616 | g_free (utf8_path); | |||
1617 | g_free (s_size); | |||
1618 | g_free (s_time); | |||
1619 | } | |||
1620 | else { | |||
1621 | GDateTime *date_time; | |||
1622 | char *utf8_path; | |||
1623 | char *s_size; | |||
1624 | char *s_time; | |||
1625 | const char *desc; | |||
1626 | ||||
1627 | utf8_path = g_filename_display_name (fdata->path); | |||
1628 | ||||
1629 | s_size = g_format_size (fdata->size); | |||
1630 | date_time = g_date_time_new_from_unix_local (fdata->modified); | |||
1631 | s_time = g_date_time_format (date_time, _("%d %B %Y, %H:%M")gettext ("%d %B %Y, %H:%M")); | |||
1632 | g_date_time_unref (date_time); | |||
1633 | desc = g_content_type_get_description (fdata->content_type); | |||
1634 | ||||
1635 | ctk_list_store_set (window->priv->list_store, &iter, | |||
1636 | COLUMN_FILE_DATA, fdata, | |||
1637 | COLUMN_ICON, icon, | |||
1638 | COLUMN_NAME, utf8_name, | |||
1639 | COLUMN_EMBLEM, emblem, | |||
1640 | COLUMN_TYPE, desc, | |||
1641 | COLUMN_SIZE, s_size, | |||
1642 | COLUMN_TIME, s_time, | |||
1643 | COLUMN_PATH, utf8_path, | |||
1644 | -1); | |||
1645 | g_free (utf8_path); | |||
1646 | g_free (s_size); | |||
1647 | g_free (s_time); | |||
1648 | } | |||
1649 | g_free (utf8_name); | |||
1650 | if (icon != NULL((void*)0)) | |||
1651 | g_object_unref (icon); | |||
1652 | if (emblem != NULL((void*)0)) | |||
1653 | g_object_unref (emblem); | |||
1654 | } | |||
1655 | ||||
1656 | ctk_tree_sortable_set_sort_column_id (CTK_TREE_SORTABLE (window->priv->list_store)((((CtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_store)), ((ctk_tree_sortable_get_type ())))))), | |||
1657 | get_column_from_sort_method (window->priv->sort_method), | |||
1658 | window->priv->sort_type); | |||
1659 | ||||
1660 | fr_window_update_statusbar_list_info (window); | |||
1661 | fr_window_stop_activity_mode (window); | |||
1662 | } | |||
1663 | ||||
1664 | ||||
1665 | static int | |||
1666 | path_compare (gconstpointer a, | |||
1667 | gconstpointer b) | |||
1668 | { | |||
1669 | char *path_a = *((char**) a); | |||
1670 | char *path_b = *((char**) b); | |||
1671 | ||||
1672 | return strcmp (path_a, path_b); | |||
1673 | } | |||
1674 | ||||
1675 | ||||
1676 | static gboolean | |||
1677 | get_tree_iter_from_path (FrWindow *window, | |||
1678 | const char *path, | |||
1679 | CtkTreeIter *parent, | |||
1680 | CtkTreeIter *iter) | |||
1681 | { | |||
1682 | gboolean result = FALSE(0); | |||
1683 | ||||
1684 | if (! ctk_tree_model_iter_children (CTK_TREE_MODEL (window->priv->tree_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->tree_store)), ((ctk_tree_model_get_type ())))))), iter, parent)) | |||
1685 | return FALSE(0); | |||
1686 | ||||
1687 | do { | |||
1688 | CtkTreeIter tmp; | |||
1689 | char *iter_path; | |||
1690 | ||||
1691 | if (get_tree_iter_from_path (window, path, iter, &tmp)) { | |||
1692 | *iter = tmp; | |||
1693 | return TRUE(!(0)); | |||
1694 | } | |||
1695 | ||||
1696 | ctk_tree_model_get (CTK_TREE_MODEL (window->priv->tree_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->tree_store)), ((ctk_tree_model_get_type ())))))), | |||
1697 | iter, | |||
1698 | TREE_COLUMN_PATH, &iter_path, | |||
1699 | -1); | |||
1700 | ||||
1701 | if ((iter_path != NULL((void*)0)) && (strcmp (path, iter_path) == 0)) { | |||
1702 | result = TRUE(!(0)); | |||
1703 | g_free (iter_path); | |||
1704 | break; | |||
1705 | } | |||
1706 | g_free (iter_path); | |||
1707 | } while (ctk_tree_model_iter_next (CTK_TREE_MODEL (window->priv->tree_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->tree_store)), ((ctk_tree_model_get_type ())))))), iter)); | |||
1708 | ||||
1709 | return result; | |||
1710 | } | |||
1711 | ||||
1712 | ||||
1713 | static void | |||
1714 | set_sensitive (FrWindow *window, | |||
1715 | const char *action_name, | |||
1716 | gboolean sensitive) | |||
1717 | { | |||
1718 | CtkAction *action; | |||
1719 | ||||
1720 | action = ctk_action_group_get_action (window->priv->actions, action_name); | |||
1721 | g_object_set (action, "sensitive", sensitive, NULL((void*)0)); | |||
1722 | } | |||
1723 | ||||
1724 | ||||
1725 | static void | |||
1726 | fr_window_update_current_location (FrWindow *window) | |||
1727 | { | |||
1728 | const char *current_dir = fr_window_get_current_location (window); | |||
1729 | char *path; | |||
1730 | CtkTreeIter iter; | |||
1731 | ||||
1732 | if (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT) { | |||
1733 | ctk_widget_hide (window->priv->location_bar); | |||
1734 | return; | |||
1735 | } | |||
1736 | ||||
1737 | ctk_widget_show (window->priv->location_bar); | |||
1738 | ||||
1739 | ctk_entry_set_text (CTK_ENTRY (window->priv->location_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->location_entry)), ((ctk_entry_get_type ())))))), window->priv->archive_present? current_dir: ""); | |||
1740 | ||||
1741 | set_sensitive (window, "GoBack", window->priv->archive_present && (current_dir != NULL((void*)0)) && (window->priv->history_current != NULL((void*)0)) && (window->priv->history_current->next != NULL((void*)0))); | |||
1742 | set_sensitive (window, "GoForward", window->priv->archive_present && (current_dir != NULL((void*)0)) && (window->priv->history_current != NULL((void*)0)) && (window->priv->history_current->prev != NULL((void*)0))); | |||
1743 | set_sensitive (window, "GoUp", window->priv->archive_present && (current_dir != NULL((void*)0)) && (strcmp (current_dir, "/") != 0)); | |||
1744 | set_sensitive (window, "GoHome", window->priv->archive_present); | |||
1745 | ctk_widget_set_sensitive (window->priv->location_entry, window->priv->archive_present); | |||
1746 | ctk_widget_set_sensitive (window->priv->location_label, window->priv->archive_present); | |||
1747 | ctk_widget_set_sensitive (window->priv->filter_entry, window->priv->archive_present); | |||
1748 | ||||
1749 | #if 0 | |||
1750 | fr_window_history_print (window); | |||
1751 | #endif | |||
1752 | ||||
1753 | path = remove_ending_separator (current_dir); | |||
1754 | if (get_tree_iter_from_path (window, path, NULL((void*)0), &iter)) { | |||
1755 | CtkTreeSelection *selection; | |||
1756 | CtkTreePath *t_path; | |||
1757 | ||||
1758 | t_path = ctk_tree_model_get_path (CTK_TREE_MODEL (window->priv->tree_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->tree_store)), ((ctk_tree_model_get_type ())))))), &iter); | |||
1759 | ctk_tree_view_expand_to_path (CTK_TREE_VIEW (window->priv->tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->tree_view)), ((ctk_tree_view_get_type ())))))), t_path); | |||
1760 | ctk_tree_path_free (t_path); | |||
1761 | ||||
1762 | selection = ctk_tree_view_get_selection (CTK_TREE_VIEW (window->priv->tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->tree_view)), ((ctk_tree_view_get_type ()))))))); | |||
1763 | ctk_tree_selection_select_iter (selection, &iter); | |||
1764 | } | |||
1765 | g_free (path); | |||
1766 | } | |||
1767 | ||||
1768 | ||||
1769 | static void | |||
1770 | fr_window_update_dir_tree (FrWindow *window) | |||
1771 | { | |||
1772 | GPtrArray *dirs; | |||
1773 | GHashTable *dir_cache; | |||
1774 | guint i; | |||
1775 | GdkPixbuf *icon; | |||
1776 | ||||
1777 | ctk_tree_store_clear (window->priv->tree_store); | |||
1778 | ||||
1779 | if (! window->priv->view_folders | |||
1780 | || ! window->priv->archive_present | |||
1781 | || (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT)) | |||
1782 | { | |||
1783 | ctk_widget_set_sensitive (window->priv->tree_view, FALSE(0)); | |||
1784 | ctk_widget_hide (window->priv->sidepane); | |||
1785 | return; | |||
1786 | } | |||
1787 | else { | |||
1788 | ctk_widget_set_sensitive (window->priv->tree_view, TRUE(!(0))); | |||
1789 | if (! ctk_widget_get_visible (window->priv->sidepane)) | |||
1790 | ctk_widget_show_all (window->priv->sidepane); | |||
1791 | } | |||
1792 | ||||
1793 | if (ctk_widget_get_realized (window->priv->tree_view)) | |||
1794 | ctk_tree_view_scroll_to_point (CTK_TREE_VIEW (window->priv->tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->tree_view)), ((ctk_tree_view_get_type ())))))), 0, 0); | |||
1795 | ||||
1796 | /**/ | |||
1797 | ||||
1798 | dirs = g_ptr_array_sized_new (128); | |||
1799 | ||||
1800 | dir_cache = g_hash_table_new_full (g_str_hash, g_str_equal, NULL((void*)0), NULL((void*)0)); | |||
1801 | for (i = 0; i < window->archive->command->files->len; i++) { | |||
1802 | FileData *fdata = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i]; | |||
1803 | char *dir; | |||
1804 | ||||
1805 | if (ctk_entry_get_text (CTK_ENTRY (window->priv->filter_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->filter_entry)), ((ctk_entry_get_type ()))))))) != NULL((void*)0)) { | |||
1806 | if (! file_data_respects_filter (window, fdata)) | |||
1807 | continue; | |||
1808 | } | |||
1809 | ||||
1810 | if (fdata->dir) | |||
1811 | dir = remove_ending_separator (fdata->full_path); | |||
1812 | else | |||
1813 | dir = remove_level_from_path (fdata->full_path); | |||
1814 | ||||
1815 | while ((dir != NULL((void*)0)) && (strcmp (dir, "/") != 0)) { | |||
1816 | char *new_dir; | |||
1817 | ||||
1818 | if (g_hash_table_lookup (dir_cache, dir) != NULL((void*)0)) | |||
1819 | break; | |||
1820 | ||||
1821 | new_dir = dir; | |||
1822 | g_ptr_array_add (dirs, new_dir); | |||
1823 | g_hash_table_replace (dir_cache, new_dir, "1"); | |||
1824 | ||||
1825 | dir = remove_level_from_path (new_dir); | |||
1826 | } | |||
1827 | ||||
1828 | g_free (dir); | |||
1829 | } | |||
1830 | g_hash_table_destroy (dir_cache); | |||
1831 | ||||
1832 | g_ptr_array_sort (dirs, path_compare); | |||
1833 | dir_cache = g_hash_table_new_full (g_str_hash, g_str_equal, NULL((void*)0), (GDestroyNotify) ctk_tree_path_free); | |||
1834 | ||||
1835 | /**/ | |||
1836 | ||||
1837 | icon = get_mime_type_icon (MIME_TYPE_ARCHIVE"application/x-archive"); | |||
1838 | { | |||
1839 | CtkTreeIter node; | |||
1840 | char *uri; | |||
1841 | char *name; | |||
1842 | ||||
1843 | uri = g_file_get_uri (window->archive->file); | |||
1844 | name = g_uri_display_basename (uri); | |||
1845 | ||||
1846 | ctk_tree_store_append (window->priv->tree_store, &node, NULL((void*)0)); | |||
1847 | ctk_tree_store_set (window->priv->tree_store, &node, | |||
1848 | TREE_COLUMN_ICON, icon, | |||
1849 | TREE_COLUMN_NAME, name, | |||
1850 | TREE_COLUMN_PATH, "/", | |||
1851 | TREE_COLUMN_WEIGHT, PANGO_WEIGHT_BOLD, | |||
1852 | -1); | |||
1853 | g_hash_table_replace (dir_cache, "/", ctk_tree_model_get_path (CTK_TREE_MODEL (window->priv->tree_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->tree_store)), ((ctk_tree_model_get_type ())))))), &node)); | |||
1854 | ||||
1855 | g_free (name); | |||
1856 | g_free (uri); | |||
1857 | } | |||
1858 | g_object_unref (icon); | |||
1859 | ||||
1860 | /**/ | |||
1861 | ||||
1862 | icon = get_mime_type_icon (MIME_TYPE_DIRECTORY"folder"); | |||
1863 | for (i = 0; i < dirs->len; i++) { | |||
1864 | char *dir = g_ptr_array_index (dirs, i)((dirs)->pdata)[i]; | |||
1865 | char *parent_dir; | |||
1866 | CtkTreePath *parent_path; | |||
1867 | CtkTreeIter parent; | |||
1868 | CtkTreeIter node; | |||
1869 | ||||
1870 | parent_dir = remove_level_from_path (dir); | |||
1871 | if (parent_dir == NULL((void*)0)) | |||
1872 | continue; | |||
1873 | ||||
1874 | parent_path = g_hash_table_lookup (dir_cache, parent_dir); | |||
1875 | ctk_tree_model_get_iter (CTK_TREE_MODEL (window->priv->tree_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->tree_store)), ((ctk_tree_model_get_type ())))))), | |||
1876 | &parent, | |||
1877 | parent_path); | |||
1878 | ctk_tree_store_append (window->priv->tree_store, &node, &parent); | |||
1879 | ctk_tree_store_set (window->priv->tree_store, &node, | |||
1880 | TREE_COLUMN_ICON, icon, | |||
1881 | TREE_COLUMN_NAME, file_name_from_path (dir), | |||
1882 | TREE_COLUMN_PATH, dir, | |||
1883 | TREE_COLUMN_WEIGHT, PANGO_WEIGHT_NORMAL, | |||
1884 | -1); | |||
1885 | g_hash_table_replace (dir_cache, dir, ctk_tree_model_get_path (CTK_TREE_MODEL (window->priv->tree_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->tree_store)), ((ctk_tree_model_get_type ())))))), &node)); | |||
1886 | ||||
1887 | g_free (parent_dir); | |||
1888 | } | |||
1889 | g_hash_table_destroy (dir_cache); | |||
1890 | if (icon != NULL((void*)0)) | |||
1891 | g_object_unref (icon); | |||
1892 | ||||
1893 | g_ptr_array_free (dirs, TRUE(!(0))); | |||
1894 | ||||
1895 | fr_window_update_current_location (window); | |||
1896 | } | |||
1897 | ||||
1898 | ||||
1899 | static void | |||
1900 | fr_window_update_filter_bar_visibility (FrWindow *window) | |||
1901 | { | |||
1902 | const char *filter; | |||
1903 | ||||
1904 | filter = ctk_entry_get_text (CTK_ENTRY (window->priv->filter_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->filter_entry)), ((ctk_entry_get_type ()))))))); | |||
1905 | if ((filter == NULL((void*)0)) || (*filter == '\0')) | |||
1906 | ctk_widget_hide (window->priv->filter_bar); | |||
1907 | else | |||
1908 | ctk_widget_show (window->priv->filter_bar); | |||
1909 | } | |||
1910 | ||||
1911 | ||||
1912 | static void | |||
1913 | fr_window_update_file_list (FrWindow *window, | |||
1914 | gboolean update_view) | |||
1915 | { | |||
1916 | GPtrArray *files; | |||
1917 | gboolean free_files = FALSE(0); | |||
1918 | ||||
1919 | if (ctk_widget_get_realized (window->priv->list_view)) | |||
1920 | ctk_tree_view_scroll_to_point (CTK_TREE_VIEW (window->priv->list_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_view)), ((ctk_tree_view_get_type ())))))), 0, 0); | |||
1921 | ||||
1922 | if (! window->priv->archive_present || window->priv->archive_new) { | |||
1923 | if (update_view) | |||
1924 | ctk_list_store_clear (window->priv->list_store); | |||
1925 | ||||
1926 | window->priv->current_view_length = 0; | |||
1927 | ||||
1928 | if (window->priv->archive_new) { | |||
1929 | ctk_widget_set_sensitive (window->priv->list_view, TRUE(!(0))); | |||
1930 | ctk_widget_show_all (ctk_widget_get_parent (window->priv->list_view)); | |||
1931 | } | |||
1932 | else { | |||
1933 | ctk_widget_set_sensitive (window->priv->list_view, FALSE(0)); | |||
1934 | ctk_widget_hide (ctk_widget_get_parent (window->priv->list_view)); | |||
1935 | } | |||
1936 | ||||
1937 | return; | |||
1938 | } | |||
1939 | else { | |||
1940 | ctk_widget_set_sensitive (window->priv->list_view, TRUE(!(0))); | |||
1941 | ctk_widget_show_all (ctk_widget_get_parent (window->priv->list_view)); | |||
1942 | } | |||
1943 | ||||
1944 | if (window->priv->give_focus_to_the_list) { | |||
1945 | ctk_widget_grab_focus (window->priv->list_view); | |||
1946 | window->priv->give_focus_to_the_list = FALSE(0); | |||
1947 | } | |||
1948 | ||||
1949 | /**/ | |||
1950 | ||||
1951 | fr_window_start_activity_mode (window); | |||
1952 | ||||
1953 | if (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT) { | |||
1954 | fr_window_compute_list_names (window, window->archive->command->files); | |||
1955 | files = window->archive->command->files; | |||
1956 | free_files = FALSE(0); | |||
1957 | } | |||
1958 | else { | |||
1959 | char *current_dir = g_strdup (fr_window_get_current_location (window))g_strdup_inline (fr_window_get_current_location (window)); | |||
1960 | ||||
1961 | while (! fr_window_dir_exists_in_archive (window, current_dir)) { | |||
1962 | char *tmp; | |||
1963 | ||||
1964 | fr_window_history_pop (window); | |||
1965 | ||||
1966 | tmp = get_parent_dir (current_dir); | |||
1967 | g_free (current_dir); | |||
1968 | current_dir = tmp; | |||
1969 | ||||
1970 | fr_window_history_add (window, current_dir); | |||
1971 | } | |||
1972 | g_free (current_dir); | |||
1973 | ||||
1974 | fr_window_compute_list_names (window, window->archive->command->files); | |||
1975 | files = fr_window_get_current_dir_list (window); | |||
1976 | free_files = TRUE(!(0)); | |||
1977 | } | |||
1978 | ||||
1979 | if (files != NULL((void*)0)) | |||
1980 | window->priv->current_view_length = files->len; | |||
1981 | else | |||
1982 | window->priv->current_view_length = 0; | |||
1983 | ||||
1984 | if (update_view) | |||
1985 | fr_window_populate_file_list (window, files); | |||
1986 | ||||
1987 | if (free_files) | |||
1988 | g_ptr_array_free (files, TRUE(!(0))); | |||
1989 | } | |||
1990 | ||||
1991 | ||||
1992 | void | |||
1993 | fr_window_update_list_order (FrWindow *window) | |||
1994 | { | |||
1995 | ctk_tree_sortable_set_sort_column_id (CTK_TREE_SORTABLE (window->priv->list_store)((((CtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_store)), ((ctk_tree_sortable_get_type ())))))), get_column_from_sort_method (window->priv->sort_method), window->priv->sort_type); | |||
1996 | } | |||
1997 | ||||
1998 | ||||
1999 | static void | |||
2000 | fr_window_update_title (FrWindow *window) | |||
2001 | { | |||
2002 | if (! window->priv->archive_present) | |||
2003 | ctk_window_set_title (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), _("Archive Manager")gettext ("Archive Manager")); | |||
2004 | else { | |||
2005 | char *title; | |||
2006 | char *name; | |||
2007 | ||||
2008 | name = g_uri_display_basename (fr_window_get_archive_uri (window)); | |||
2009 | title = g_strdup_printf ("%s %s", | |||
2010 | name, | |||
2011 | window->archive->read_only ? _("[read only]")gettext ("[read only]") : ""); | |||
2012 | ||||
2013 | ctk_window_set_title (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), title); | |||
2014 | g_free (title); | |||
2015 | g_free (name); | |||
2016 | } | |||
2017 | } | |||
2018 | ||||
2019 | ||||
2020 | static void | |||
2021 | check_whether_has_a_dir (CtkTreeModel *model, | |||
2022 | CtkTreePath *path G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
2023 | CtkTreeIter *iter, | |||
2024 | gpointer data) | |||
2025 | { | |||
2026 | gboolean *has_a_dir = data; | |||
2027 | FileData *fdata; | |||
2028 | ||||
2029 | ctk_tree_model_get (model, iter, | |||
2030 | COLUMN_FILE_DATA, &fdata, | |||
2031 | -1); | |||
2032 | if (file_data_is_dir (fdata)) | |||
2033 | *has_a_dir = TRUE(!(0)); | |||
2034 | } | |||
2035 | ||||
2036 | ||||
2037 | static gboolean | |||
2038 | selection_has_a_dir (FrWindow *window) | |||
2039 | { | |||
2040 | CtkTreeSelection *selection; | |||
2041 | gboolean has_a_dir = FALSE(0); | |||
2042 | ||||
2043 | if (! ctk_widget_get_realized (window->priv->list_view)) | |||
2044 | return FALSE(0); | |||
2045 | ||||
2046 | selection = ctk_tree_view_get_selection (CTK_TREE_VIEW (window->priv->list_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_view)), ((ctk_tree_view_get_type ()))))))); | |||
2047 | if (selection == NULL((void*)0)) | |||
2048 | return FALSE(0); | |||
2049 | ||||
2050 | ctk_tree_selection_selected_foreach (selection, | |||
2051 | check_whether_has_a_dir, | |||
2052 | &has_a_dir); | |||
2053 | ||||
2054 | return has_a_dir; | |||
2055 | } | |||
2056 | ||||
2057 | ||||
2058 | static void | |||
2059 | set_active (FrWindow *window, | |||
2060 | const char *action_name, | |||
2061 | gboolean is_active) | |||
2062 | { | |||
2063 | CtkAction *action; | |||
2064 | ||||
2065 | action = ctk_action_group_get_action (window->priv->actions, action_name); | |||
2066 | ctk_toggle_action_set_active (CTK_TOGGLE_ACTION (action)((((CtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), ((ctk_toggle_action_get_type ())))))), is_active); | |||
2067 | } | |||
2068 | ||||
2069 | ||||
2070 | static void | |||
2071 | fr_window_update_paste_command_sensitivity (FrWindow *window, | |||
2072 | CtkClipboard *clipboard) | |||
2073 | { | |||
2074 | gboolean running; | |||
2075 | gboolean no_archive; | |||
2076 | gboolean ro; | |||
2077 | gboolean compr_file; | |||
2078 | ||||
2079 | if (window->priv->closing) | |||
2080 | return; | |||
2081 | ||||
2082 | if (clipboard == NULL((void*)0)) | |||
2083 | clipboard = ctk_widget_get_clipboard (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))), FR_CLIPBOARD(cdk_atom_intern_static_string ("_RNGRAMPA_SPECIAL_CLIPBOARD" ))); | |||
2084 | running = window->priv->activity_ref > 0; | |||
2085 | no_archive = (window->archive == NULL((void*)0)) || ! window->priv->archive_present; | |||
2086 | ro = ! no_archive && window->archive->read_only; | |||
2087 | compr_file = ! no_archive && window->archive->is_compressed_file; | |||
2088 | ||||
2089 | set_sensitive (window, "Paste", ! no_archive && ! ro && ! running && ! compr_file && (window->priv->list_mode != FR_WINDOW_LIST_MODE_FLAT) && ctk_clipboard_wait_is_target_available (clipboard, FR_SPECIAL_URI_LIST(cdk_atom_intern_static_string ("application/grapa-uri-list") ))); | |||
2090 | } | |||
2091 | ||||
2092 | ||||
2093 | static void | |||
2094 | fr_window_update_sensitivity (FrWindow *window) | |||
2095 | { | |||
2096 | gboolean no_archive; | |||
2097 | gboolean ro; | |||
2098 | gboolean file_op; | |||
2099 | gboolean running; | |||
2100 | gboolean compr_file; | |||
2101 | gboolean sel_not_null; | |||
2102 | gboolean one_file_selected; | |||
2103 | gboolean dir_selected; | |||
2104 | int n_selected; | |||
2105 | ||||
2106 | if (window->priv->batch_mode) | |||
2107 | return; | |||
2108 | ||||
2109 | running = window->priv->activity_ref > 0; | |||
2110 | no_archive = (window->archive == NULL((void*)0)) || ! window->priv->archive_present; | |||
2111 | ro = ! no_archive && window->archive->read_only; | |||
2112 | file_op = ! no_archive && ! window->priv->archive_new && ! running; | |||
2113 | compr_file = ! no_archive && window->archive->is_compressed_file; | |||
2114 | n_selected = fr_window_get_n_selected_files (window); | |||
2115 | sel_not_null = n_selected > 0; | |||
2116 | one_file_selected = n_selected == 1; | |||
2117 | dir_selected = selection_has_a_dir (window); | |||
2118 | ||||
2119 | set_sensitive (window, "AddFiles", ! no_archive && ! ro && ! running && ! compr_file); | |||
2120 | set_sensitive (window, "AddFiles_Toolbar", ! no_archive && ! ro && ! running && ! compr_file); | |||
2121 | set_sensitive (window, "AddFolder", ! no_archive && ! ro && ! running && ! compr_file); | |||
2122 | set_sensitive (window, "AddFolder_Toolbar", ! no_archive && ! ro && ! running && ! compr_file); | |||
2123 | set_sensitive (window, "Copy", ! no_archive && ! ro && ! running && ! compr_file && sel_not_null && (window->priv->list_mode != FR_WINDOW_LIST_MODE_FLAT)); | |||
2124 | set_sensitive (window, "Cut", ! no_archive && ! ro && ! running && ! compr_file && sel_not_null && (window->priv->list_mode != FR_WINDOW_LIST_MODE_FLAT)); | |||
2125 | set_sensitive (window, "Delete", ! no_archive && ! ro && ! window->priv->archive_new && ! running && ! compr_file); | |||
2126 | set_sensitive (window, "DeselectAll", ! no_archive && sel_not_null); | |||
2127 | set_sensitive (window, "Extract", file_op); | |||
2128 | set_sensitive (window, "Extract_Toolbar", file_op); | |||
2129 | set_sensitive (window, "Find", ! no_archive); | |||
2130 | set_sensitive (window, "LastOutput", ((window->archive != NULL((void*)0)) | |||
2131 | && (window->archive->process != NULL((void*)0)) | |||
2132 | && (window->archive->process->out.raw != NULL((void*)0)))); | |||
2133 | set_sensitive (window, "New", ! running); | |||
2134 | set_sensitive (window, "Open", ! running); | |||
2135 | set_sensitive (window, "Open_Toolbar", ! running); | |||
2136 | set_sensitive (window, "OpenSelection", file_op && sel_not_null && ! dir_selected); | |||
2137 | set_sensitive (window, "OpenFolder", file_op && one_file_selected && dir_selected); | |||
2138 | set_sensitive (window, "Password", ! running && (window->priv->asked_for_password || (! no_archive && window->archive->command->propPassword))); | |||
2139 | set_sensitive (window, "Properties", file_op); | |||
2140 | set_sensitive (window, "Close", !running || window->priv->stoppable); | |||
2141 | set_sensitive (window, "Reload", ! (no_archive || running)); | |||
2142 | set_sensitive (window, "Rename", ! no_archive && ! ro && ! running && ! compr_file && one_file_selected); | |||
2143 | set_sensitive (window, "SaveAs", ! no_archive && ! compr_file && ! running); | |||
2144 | set_sensitive (window, "SelectAll", ! no_archive); | |||
2145 | set_sensitive (window, "Stop", running && window->priv->stoppable); | |||
2146 | set_sensitive (window, "TestArchive", ! no_archive && ! running && window->archive->command->propTest); | |||
2147 | set_sensitive (window, "ViewSelection", file_op && one_file_selected && ! dir_selected); | |||
2148 | set_sensitive (window, "ViewSelection_Toolbar", file_op && one_file_selected && ! dir_selected); | |||
2149 | ||||
2150 | if (window->priv->progress_dialog != NULL((void*)0)) | |||
2151 | ctk_dialog_set_response_sensitive (CTK_DIALOG (window->priv->progress_dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->progress_dialog)), ((ctk_dialog_get_type ())))))), | |||
2152 | CTK_RESPONSE_OK, | |||
2153 | running && window->priv->stoppable); | |||
2154 | ||||
2155 | fr_window_update_paste_command_sensitivity (window, NULL((void*)0)); | |||
2156 | ||||
2157 | set_sensitive (window, "SelectAll", (window->priv->current_view_length > 0) && (window->priv->current_view_length != n_selected)); | |||
2158 | set_sensitive (window, "DeselectAll", n_selected > 0); | |||
2159 | set_sensitive (window, "OpenRecent", ! running); | |||
2160 | set_sensitive (window, "OpenRecent_Toolbar", ! running); | |||
2161 | ||||
2162 | set_sensitive (window, "ViewFolders", (window->priv->list_mode == FR_WINDOW_LIST_MODE_AS_DIR)); | |||
2163 | ||||
2164 | set_sensitive (window, "ViewAllFiles", ! window->priv->filter_mode); | |||
2165 | set_sensitive (window, "ViewAsFolder", ! window->priv->filter_mode); | |||
2166 | } | |||
2167 | ||||
2168 | ||||
2169 | static gboolean | |||
2170 | location_entry_key_press_event_cb (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
2171 | CdkEventKey *event, | |||
2172 | FrWindow *window) | |||
2173 | { | |||
2174 | if ((event->keyval == CDK_KEY_Return0xff0d) | |||
2175 | || (event->keyval == CDK_KEY_KP_Enter0xff8d) | |||
2176 | || (event->keyval == CDK_KEY_ISO_Enter0xfe34)) | |||
2177 | { | |||
2178 | fr_window_go_to_location (window, ctk_entry_get_text (CTK_ENTRY (window->priv->location_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->location_entry)), ((ctk_entry_get_type ()))))))), FALSE(0)); | |||
2179 | } | |||
2180 | ||||
2181 | return FALSE(0); | |||
2182 | } | |||
2183 | ||||
2184 | ||||
2185 | static void | |||
2186 | show_notification (FrWindow *window) | |||
2187 | { | |||
2188 | GSettings *settings; | |||
2189 | settings = g_settings_new ("org.cafe.grapa.general"); | |||
2190 | ||||
2191 | if ((g_settings_get_boolean (settings, "notifications")) && | |||
2192 | (window->priv->use_progress_dialog) && | |||
2193 | (window->priv->progress_dialog != NULL((void*)0)) && | |||
2194 | (ctk_widget_get_visible (window->priv->progress_dialog)) && | |||
2195 | (ctk_window_is_active (CTK_WINDOW (ctk_widget_get_toplevel (window->priv->progress_dialog))((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_widget_get_toplevel (window->priv->progress_dialog ))), ((ctk_window_get_type ()))))))) == FALSE(0)) && | |||
2196 | (ctk_window_is_active (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ()))))))) == FALSE(0)) && | |||
2197 | enable_notifications) { | |||
2198 | notify_init ("grapa"); | |||
2199 | NotifyNotification *notification; | |||
2200 | ||||
2201 | notification = notify_notification_new ("grapa", | |||
2202 | _("Process completed")gettext ("Process completed"), | |||
2203 | "grapa"); | |||
2204 | ||||
2205 | notify_notification_show (notification, NULL((void*)0)); | |||
2206 | g_object_unref (G_OBJECT (notification)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notification)), (((GType) ((20) << (2))))))))); | |||
2207 | notify_uninit (); | |||
2208 | } | |||
2209 | ||||
2210 | enable_notifications = TRUE(!(0)); | |||
2211 | g_object_unref (settings); | |||
2212 | } | |||
2213 | ||||
2214 | ||||
2215 | static gboolean | |||
2216 | real_close_progress_dialog (gpointer data) | |||
2217 | { | |||
2218 | FrWindow *window = data; | |||
2219 | ||||
2220 | show_notification (window); | |||
2221 | ||||
2222 | if (window->priv->hide_progress_timeout != 0) { | |||
2223 | g_source_remove (window->priv->hide_progress_timeout); | |||
2224 | window->priv->hide_progress_timeout = 0; | |||
2225 | } | |||
2226 | ||||
2227 | if (window->priv->progress_dialog != NULL((void*)0)) | |||
2228 | ctk_widget_hide (window->priv->progress_dialog); | |||
2229 | ||||
2230 | return FALSE(0); | |||
2231 | } | |||
2232 | ||||
2233 | ||||
2234 | static void close_suspend_process(FrWindow *window) | |||
2235 | { | |||
2236 | if (window->archive->process != NULL((void*)0)) | |||
2237 | { | |||
2238 | start_close_suspend_process(window->archive->process); | |||
2239 | } | |||
2240 | } | |||
2241 | static void | |||
2242 | close_progress_dialog (FrWindow *window, | |||
2243 | gboolean close_now) | |||
2244 | { | |||
2245 | if (window->priv->progress_timeout != 0) { | |||
2246 | g_source_remove (window->priv->progress_timeout); | |||
2247 | window->priv->progress_timeout = 0; | |||
2248 | } | |||
2249 | ||||
2250 | if (! window->priv->batch_mode && ctk_widget_get_mapped (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))) | |||
2251 | ctk_widget_hide (window->priv->progress_bar); | |||
2252 | ||||
2253 | if (window->priv->progress_dialog == NULL((void*)0)) | |||
2254 | return; | |||
2255 | ||||
2256 | if (close_now) { | |||
2257 | if (window->priv->hide_progress_timeout != 0) { | |||
2258 | g_source_remove (window->priv->hide_progress_timeout); | |||
2259 | window->priv->hide_progress_timeout = 0; | |||
2260 | } | |||
2261 | real_close_progress_dialog (window); | |||
2262 | } | |||
2263 | else { | |||
2264 | if (window->priv->hide_progress_timeout != 0) | |||
2265 | return; | |||
2266 | window->priv->hide_progress_timeout = g_timeout_add (HIDE_PROGRESS_TIMEOUT_MSECS500, | |||
2267 | real_close_progress_dialog, | |||
2268 | window); | |||
2269 | } | |||
2270 | close_suspend_process(window); | |||
2271 | } | |||
2272 | ||||
2273 | ||||
2274 | static gboolean | |||
2275 | progress_dialog_delete_event (CtkWidget *caller G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
2276 | CdkEvent *event G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
2277 | FrWindow *window) | |||
2278 | { | |||
2279 | if (window->priv->stoppable) { | |||
2280 | activate_action_stop (NULL((void*)0), window); | |||
2281 | close_progress_dialog (window, TRUE(!(0))); | |||
2282 | } | |||
2283 | ||||
2284 | return TRUE(!(0)); | |||
2285 | } | |||
2286 | ||||
2287 | ||||
2288 | static void | |||
2289 | open_folder (CtkWindow *parent, | |||
2290 | const char *folder) | |||
2291 | { | |||
2292 | GError *error = NULL((void*)0); | |||
2293 | ||||
2294 | if (folder == NULL((void*)0)) | |||
2295 | return; | |||
2296 | ||||
2297 | if (! ctk_show_uri_on_window (parent, folder, CDK_CURRENT_TIME0L, &error)) { | |||
2298 | CtkWidget *d; | |||
2299 | char *utf8_name; | |||
2300 | char *message; | |||
2301 | ||||
2302 | utf8_name = g_filename_display_name (folder); | |||
2303 | message = g_strdup_printf (_("Could not display the folder \"%s\"")gettext ("Could not display the folder \"%s\""), utf8_name); | |||
2304 | g_free (utf8_name); | |||
2305 | ||||
2306 | d = _ctk_error_dialog_new (parent, | |||
2307 | CTK_DIALOG_MODAL, | |||
2308 | NULL((void*)0), | |||
2309 | message, | |||
2310 | "%s", | |||
2311 | error->message); | |||
2312 | ctk_dialog_run (CTK_DIALOG (d)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((d)), ((ctk_dialog_get_type ()))))))); | |||
2313 | ctk_widget_destroy (d); | |||
2314 | ||||
2315 | g_free (message); | |||
2316 | g_clear_error (&error); | |||
2317 | } | |||
2318 | } | |||
2319 | ||||
2320 | ||||
2321 | static void | |||
2322 | fr_window_view_extraction_destination_folder (FrWindow *window) | |||
2323 | { | |||
2324 | open_folder (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), fr_archive_get_last_extraction_destination (window->archive)); | |||
2325 | } | |||
2326 | ||||
2327 | static void change_button_label (FrWindow *window, | |||
2328 | CtkWidget *button) | |||
2329 | { | |||
2330 | const gchar *state; | |||
2331 | state = ctk_button_get_label (CTK_BUTTON (button)((((CtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((button)), ((ctk_button_get_type ()))))))); | |||
2332 | ||||
2333 | if (g_strrstr (_("_Pause")gettext ("_Pause"), state) != NULL((void*)0)) | |||
2334 | { | |||
2335 | ctk_widget_set_visible (window->priv->pd_progress_bar, FALSE(0)); | |||
2336 | fr_command_message (window->archive->command, _("Process paused")gettext ("Process paused")); | |||
2337 | ||||
2338 | ctk_button_set_label (CTK_BUTTON (button)((((CtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((button)), ((ctk_button_get_type ())))))), _("_Resume")gettext ("_Resume")); | |||
2339 | ctk_button_set_image (CTK_BUTTON (button)((((CtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((button)), ((ctk_button_get_type ())))))), | |||
2340 | ctk_image_new_from_icon_name ("media-playback-start", | |||
2341 | CTK_ICON_SIZE_BUTTON)); | |||
2342 | } | |||
2343 | else | |||
2344 | { | |||
2345 | ctk_widget_set_visible (window->priv->pd_progress_bar, TRUE(!(0))); | |||
2346 | fr_command_message (window->archive->command, _("Please wait…")gettext ("Please wait…")); | |||
2347 | ||||
2348 | ctk_button_set_label (CTK_BUTTON(button)((((CtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((button)), ((ctk_button_get_type ())))))), _("_Pause")gettext ("_Pause")); | |||
2349 | ctk_button_set_image (CTK_BUTTON (button)((((CtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((button)), ((ctk_button_get_type ())))))), | |||
2350 | ctk_image_new_from_icon_name ("media-playback-pause", | |||
2351 | CTK_ICON_SIZE_BUTTON)); | |||
2352 | } | |||
2353 | } | |||
2354 | static void fr_state_switch (FrWindow *window) | |||
2355 | { | |||
2356 | int ret; | |||
2357 | if (window->archive->process != NULL((void*)0)) | |||
2358 | { | |||
2359 | ret = start_switch_state (window->archive->process); | |||
2360 | if (ret == 0) | |||
2361 | { | |||
2362 | change_button_label (window, window->priv->pd_state_button); | |||
2363 | } | |||
2364 | } | |||
2365 | } | |||
2366 | ||||
2367 | static void | |||
2368 | progress_dialog_response (CtkDialog *dialog G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
2369 | int response_id, | |||
2370 | FrWindow *window) | |||
2371 | { | |||
2372 | CtkWidget *new_window; | |||
2373 | ||||
2374 | switch (response_id) { | |||
2375 | case CTK_RESPONSE_CANCEL: | |||
2376 | if (window->priv->stoppable) { | |||
2377 | activate_action_stop (NULL((void*)0), window); | |||
2378 | close_progress_dialog (window, TRUE(!(0))); | |||
2379 | } | |||
2380 | break; | |||
2381 | case CTK_RESPONSE_CLOSE: | |||
2382 | close_progress_dialog (window, TRUE(!(0))); | |||
2383 | break; | |||
2384 | case DIALOG_RESPONSE_OPEN_ARCHIVE: | |||
2385 | new_window = fr_window_new (); | |||
2386 | ctk_widget_show (new_window); | |||
2387 | fr_window_archive_open (FR_WINDOW (new_window)((((FrWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((new_window)), ((fr_window_get_type ())))))), window->priv->convert_data.new_file, CTK_WINDOW (new_window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((new_window)), ((ctk_window_get_type ()))))))); | |||
2388 | close_progress_dialog (window, TRUE(!(0))); | |||
2389 | break; | |||
2390 | case DIALOG_RESPONSE_OPEN_DESTINATION_FOLDER: | |||
2391 | fr_window_view_extraction_destination_folder (window); | |||
2392 | close_progress_dialog (window, TRUE(!(0))); | |||
2393 | break; | |||
2394 | case DIALOG_RESPONSE_OPEN_DESTINATION_FOLDER_AND_QUIT: | |||
2395 | fr_window_view_extraction_destination_folder (window); | |||
2396 | close_progress_dialog (window, TRUE(!(0))); | |||
2397 | fr_window_close (window); | |||
2398 | break; | |||
2399 | case DIALOG_RESPONSE_QUIT: | |||
2400 | fr_window_close (window); | |||
2401 | break; | |||
2402 | case CTK_RESPONSE_ACCEPT: | |||
2403 | fr_state_switch (window); | |||
2404 | break; | |||
2405 | default: | |||
2406 | break; | |||
2407 | } | |||
2408 | } | |||
2409 | ||||
2410 | ||||
2411 | static char* | |||
2412 | get_action_description (FrAction action, | |||
2413 | const char *uri) | |||
2414 | { | |||
2415 | char *basename; | |||
2416 | char *message; | |||
2417 | ||||
2418 | basename = (uri != NULL((void*)0)) ? g_uri_display_basename (uri) : NULL((void*)0); | |||
2419 | ||||
2420 | message = NULL((void*)0); | |||
2421 | switch (action) { | |||
2422 | case FR_ACTION_CREATING_NEW_ARCHIVE: | |||
2423 | /* Translators: %s is a filename */ | |||
2424 | message = g_strdup_printf (_("Creating \"%s\"")gettext ("Creating \"%s\""), basename); | |||
2425 | break; | |||
2426 | case FR_ACTION_LOADING_ARCHIVE: | |||
2427 | /* Translators: %s is a filename */ | |||
2428 | message = g_strdup_printf (_("Loading \"%s\"")gettext ("Loading \"%s\""), basename); | |||
2429 | break; | |||
2430 | case FR_ACTION_LISTING_CONTENT: | |||
2431 | /* Translators: %s is a filename */ | |||
2432 | message = g_strdup_printf (_("Reading \"%s\"")gettext ("Reading \"%s\""), basename); | |||
2433 | break; | |||
2434 | case FR_ACTION_DELETING_FILES: | |||
2435 | /* Translators: %s is a filename */ | |||
2436 | message = g_strdup_printf (_("Deleting files from \"%s\"")gettext ("Deleting files from \"%s\""), basename); | |||
2437 | break; | |||
2438 | case FR_ACTION_TESTING_ARCHIVE: | |||
2439 | /* Translators: %s is a filename */ | |||
2440 | message = g_strdup_printf (_("Testing \"%s\"")gettext ("Testing \"%s\""), basename); | |||
2441 | break; | |||
2442 | case FR_ACTION_GETTING_FILE_LIST: | |||
2443 | message = g_strdup (_("Getting the file list"))g_strdup_inline (gettext ("Getting the file list")); | |||
2444 | break; | |||
2445 | case FR_ACTION_COPYING_FILES_FROM_REMOTE: | |||
2446 | /* Translators: %s is a filename */ | |||
2447 | message = g_strdup_printf (_("Copying the files to add to \"%s\"")gettext ("Copying the files to add to \"%s\""), basename); | |||
2448 | break; | |||
2449 | case FR_ACTION_ADDING_FILES: | |||
2450 | /* Translators: %s is a filename */ | |||
2451 | message = g_strdup_printf (_("Adding files to \"%s\"")gettext ("Adding files to \"%s\""), basename); | |||
2452 | break; | |||
2453 | case FR_ACTION_EXTRACTING_FILES: | |||
2454 | /* Translators: %s is a filename */ | |||
2455 | message = g_strdup_printf (_("Extracting files from \"%s\"")gettext ("Extracting files from \"%s\""), basename); | |||
2456 | break; | |||
2457 | case FR_ACTION_COPYING_FILES_TO_REMOTE: | |||
2458 | message = g_strdup (_("Copying the extracted files to the destination"))g_strdup_inline (gettext ("Copying the extracted files to the destination" )); | |||
2459 | break; | |||
2460 | case FR_ACTION_CREATING_ARCHIVE: | |||
2461 | /* Translators: %s is a filename */ | |||
2462 | message = g_strdup_printf (_("Creating \"%s\"")gettext ("Creating \"%s\""), basename); | |||
2463 | break; | |||
2464 | case FR_ACTION_SAVING_REMOTE_ARCHIVE: | |||
2465 | /* Translators: %s is a filename */ | |||
2466 | message = g_strdup_printf (_("Saving \"%s\"")gettext ("Saving \"%s\""), basename); | |||
2467 | break; | |||
2468 | case FR_ACTION_NONE: | |||
2469 | break; | |||
2470 | } | |||
2471 | g_free (basename); | |||
2472 | ||||
2473 | return message; | |||
2474 | } | |||
2475 | ||||
2476 | ||||
2477 | static void | |||
2478 | progress_dialog_update_action_description (FrWindow *window) | |||
2479 | { | |||
2480 | const char *current_archive; | |||
2481 | char *description; | |||
2482 | char *description_markup; | |||
2483 | ||||
2484 | if (window->priv->progress_dialog == NULL((void*)0)) | |||
2485 | return; | |||
2486 | ||||
2487 | if (window->priv->convert_data.converting) | |||
2488 | current_archive = window->priv->convert_data.new_file; | |||
2489 | else if (window->priv->working_archive != NULL((void*)0)) | |||
2490 | current_archive = window->priv->working_archive; | |||
2491 | else | |||
2492 | current_archive = window->priv->archive_uri; | |||
2493 | ||||
2494 | g_free (window->priv->pd_last_archive); | |||
2495 | window->priv->pd_last_archive = NULL((void*)0); | |||
2496 | if (current_archive != NULL((void*)0)) | |||
2497 | window->priv->pd_last_archive = g_strdup (current_archive)g_strdup_inline (current_archive); | |||
2498 | ||||
2499 | description = get_action_description (window->priv->action, window->priv->pd_last_archive); | |||
2500 | description_markup = g_markup_printf_escaped ("<span weight=\"bold\" size=\"larger\">%s</span>", description); | |||
2501 | ctk_label_set_markup (CTK_LABEL (window->priv->pd_action)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->pd_action)), ((ctk_label_get_type () )))))), description_markup); | |||
2502 | ||||
2503 | g_free (description_markup); | |||
2504 | g_free (description); | |||
2505 | } | |||
2506 | ||||
2507 | ||||
2508 | static gboolean | |||
2509 | fr_window_working_archive_cb (FrCommand *command G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
2510 | const char *archive_filename, | |||
2511 | FrWindow *window) | |||
2512 | { | |||
2513 | g_free (window->priv->working_archive); | |||
2514 | window->priv->working_archive = NULL((void*)0); | |||
2515 | if (archive_filename != NULL((void*)0)) | |||
2516 | window->priv->working_archive = g_strdup (archive_filename)g_strdup_inline (archive_filename); | |||
2517 | progress_dialog_update_action_description (window); | |||
2518 | ||||
2519 | return TRUE(!(0)); | |||
2520 | } | |||
2521 | ||||
2522 | ||||
2523 | static gboolean | |||
2524 | fr_window_message_cb (FrCommand *command G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
2525 | const char *msg, | |||
2526 | FrWindow *window) | |||
2527 | { | |||
2528 | if (window->priv->pd_last_message != msg) { | |||
2529 | g_free (window->priv->pd_last_message); | |||
2530 | window->priv->pd_last_message = g_strdup (msg)g_strdup_inline (msg); | |||
2531 | } | |||
2532 | ||||
2533 | if (window->priv->progress_dialog == NULL((void*)0)) | |||
2534 | return TRUE(!(0)); | |||
2535 | ||||
2536 | if (msg != NULL((void*)0)) { | |||
2537 | while (*msg == ' ') | |||
2538 | msg++; | |||
2539 | if (*msg == 0) | |||
2540 | msg = NULL((void*)0); | |||
2541 | } | |||
2542 | ||||
2543 | if (msg != NULL((void*)0)) { | |||
2544 | char *utf8_msg; | |||
2545 | ||||
2546 | if (! g_utf8_validate (msg, -1, NULL((void*)0))) | |||
2547 | utf8_msg = g_locale_to_utf8 (msg, -1 , 0, 0, 0); | |||
2548 | else | |||
2549 | utf8_msg = g_strdup (msg)g_strdup_inline (msg); | |||
2550 | if (utf8_msg == NULL((void*)0)) | |||
2551 | return TRUE(!(0)); | |||
2552 | ||||
2553 | if (g_utf8_validate (utf8_msg, -1, NULL((void*)0))) | |||
2554 | ctk_label_set_text (CTK_LABEL (window->priv->pd_message)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->pd_message)), ((ctk_label_get_type ( ))))))), utf8_msg); | |||
2555 | ||||
2556 | g_free (window->priv->pd_last_message); | |||
2557 | window->priv->pd_last_message = g_strdup (utf8_msg)g_strdup_inline (utf8_msg); | |||
2558 | ||||
2559 | g_signal_emit (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), | |||
2560 | fr_window_signals[PROGRESS], | |||
2561 | 0, | |||
2562 | window->priv->pd_last_fraction, | |||
2563 | window->priv->pd_last_message); | |||
2564 | ||||
2565 | #ifdef LOG_PROGRESS | |||
2566 | g_print ("message > %s\n", utf8_msg); | |||
2567 | #endif | |||
2568 | ||||
2569 | g_free (utf8_msg); | |||
2570 | } | |||
2571 | else | |||
2572 | ctk_label_set_text (CTK_LABEL (window->priv->pd_message)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->pd_message)), ((ctk_label_get_type ( ))))))), ""); | |||
2573 | ||||
2574 | progress_dialog_update_action_description (window); | |||
2575 | ||||
2576 | return TRUE(!(0)); | |||
2577 | } | |||
2578 | ||||
2579 | ||||
2580 | static void | |||
2581 | create_the_progress_dialog (FrWindow *window) | |||
2582 | { | |||
2583 | CtkWindow *parent; | |||
2584 | CtkDialogFlags flags; | |||
2585 | CtkDialog *d; | |||
2586 | CtkWidget *hbox; | |||
2587 | CtkWidget *vbox; | |||
2588 | CtkWidget *progress_vbox; | |||
2589 | CtkWidget *lbl; | |||
2590 | PangoAttrList *attr_list; | |||
2591 | GdkPixbuf *icon; | |||
2592 | ||||
2593 | if (window->priv->progress_dialog != NULL((void*)0)) | |||
2594 | return; | |||
2595 | ||||
2596 | flags = CTK_DIALOG_DESTROY_WITH_PARENT; | |||
2597 | if (window->priv->batch_mode) { | |||
2598 | parent = NULL((void*)0); | |||
2599 | } | |||
2600 | else { | |||
2601 | parent = CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))); | |||
2602 | flags |= CTK_DIALOG_MODAL; | |||
2603 | } | |||
2604 | ||||
2605 | window->priv->progress_dialog = ctk_dialog_new_with_buttons ((window->priv->batch_mode ? window->priv->batch_title : NULL((void*)0)), | |||
2606 | parent, | |||
2607 | flags, | |||
2608 | NULL((void*)0), | |||
2609 | NULL((void*)0)); | |||
2610 | ||||
2611 | window->priv->pd_quit_button = ctk_dialog_add_button (CTK_DIALOG (window->priv->progress_dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->progress_dialog)), ((ctk_dialog_get_type ())))))), CTK_STOCK_QUIT((CtkStock)"ctk-quit"), DIALOG_RESPONSE_QUIT); | |||
2612 | window->priv->pd_open_archive_button = ctk_dialog_add_button (CTK_DIALOG (window->priv->progress_dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->progress_dialog)), ((ctk_dialog_get_type ())))))), _("_Open the Archive")gettext ("_Open the Archive"), DIALOG_RESPONSE_OPEN_ARCHIVE); | |||
2613 | window->priv->pd_open_destination_button = ctk_dialog_add_button (CTK_DIALOG (window->priv->progress_dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->progress_dialog)), ((ctk_dialog_get_type ())))))), _("_Show the Files")gettext ("_Show the Files"), DIALOG_RESPONSE_OPEN_DESTINATION_FOLDER); | |||
2614 | window->priv->pd_open_destination_and_quit_button = ctk_dialog_add_button (CTK_DIALOG (window->priv->progress_dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->progress_dialog)), ((ctk_dialog_get_type ())))))), _("Show the _Files and Quit")gettext ("Show the _Files and Quit"), DIALOG_RESPONSE_OPEN_DESTINATION_FOLDER_AND_QUIT); | |||
2615 | window->priv->pd_close_button = ctk_dialog_add_button (CTK_DIALOG (window->priv->progress_dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->progress_dialog)), ((ctk_dialog_get_type ())))))), CTK_STOCK_CLOSE((CtkStock)"ctk-close"), CTK_RESPONSE_CLOSE); | |||
2616 | window->priv->pd_cancel_button = ctk_dialog_add_button (CTK_DIALOG (window->priv->progress_dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->progress_dialog)), ((ctk_dialog_get_type ())))))), CTK_STOCK_CANCEL((CtkStock)"ctk-cancel"), CTK_RESPONSE_CANCEL); | |||
2617 | /*add start button default suspend*/ | |||
2618 | window->priv->pd_state_button = ctk_dialog_add_button (CTK_DIALOG (window->priv->progress_dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->progress_dialog)), ((ctk_dialog_get_type ())))))), CTK_STOCK_MEDIA_PAUSE((CtkStock)"ctk-media-pause"), CTK_RESPONSE_ACCEPT); | |||
2619 | d = CTK_DIALOG (window->priv->progress_dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->progress_dialog)), ((ctk_dialog_get_type ())))))); | |||
2620 | ctk_window_set_resizable (CTK_WINDOW (d)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((d)), ((ctk_window_get_type ())))))), TRUE(!(0))); | |||
2621 | ctk_dialog_set_default_response (CTK_DIALOG (d)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((d)), ((ctk_dialog_get_type ())))))), CTK_RESPONSE_OK); | |||
2622 | ctk_window_set_default_size (CTK_WINDOW (d)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((d)), ((ctk_window_get_type ())))))), PROGRESS_DIALOG_DEFAULT_WIDTH500, -1); | |||
2623 | ||||
2624 | /* Main */ | |||
2625 | ||||
2626 | hbox = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 24); | |||
2627 | ctk_container_set_border_width (CTK_CONTAINER (hbox)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), ((ctk_container_get_type ())))))), 6); | |||
2628 | ctk_box_pack_start (CTK_BOX (ctk_dialog_get_content_area (d))((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_dialog_get_content_area (d))), ((ctk_box_get_type () )))))), hbox, FALSE(0), FALSE(0), 10); | |||
2629 | ||||
2630 | icon = get_mime_type_pixbuf ("package-x-generic", _ctk_widget_lookup_for_size (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))), CTK_ICON_SIZE_DIALOG), NULL((void*)0)); | |||
2631 | window->priv->pd_icon = ctk_image_new_from_pixbuf (icon); | |||
2632 | g_object_unref (icon); | |||
2633 | ||||
2634 | ctk_widget_set_valign (window->priv->pd_icon, CTK_ALIGN_START); | |||
2635 | ctk_box_pack_start (CTK_BOX (hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), ((ctk_box_get_type ())))))), window->priv->pd_icon, FALSE(0), FALSE(0), 0); | |||
2636 | ||||
2637 | vbox = ctk_box_new (CTK_ORIENTATION_VERTICAL, 5); | |||
2638 | ctk_box_pack_start (CTK_BOX (hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), ((ctk_box_get_type ())))))), vbox, TRUE(!(0)), TRUE(!(0)), 0); | |||
2639 | ||||
2640 | /* action description */ | |||
2641 | ||||
2642 | lbl = window->priv->pd_action = ctk_label_new (""); | |||
2643 | ctk_widget_set_halign (lbl, CTK_ALIGN_START); | |||
2644 | ctk_widget_set_valign (lbl, CTK_ALIGN_START); | |||
2645 | ctk_widget_set_hexpand (lbl, TRUE(!(0))); | |||
2646 | ctk_widget_set_vexpand (lbl, TRUE(!(0))); | |||
2647 | ctk_widget_set_margin_bottom (lbl, 12); | |||
2648 | ||||
2649 | ctk_label_set_xalign (CTK_LABEL (lbl)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((lbl)), ((ctk_label_get_type ())))))), 0.0); | |||
2650 | ctk_label_set_ellipsize (CTK_LABEL (lbl)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((lbl)), ((ctk_label_get_type ())))))), PANGO_ELLIPSIZE_END); | |||
2651 | ctk_box_pack_start (CTK_BOX (vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((vbox)), ((ctk_box_get_type ())))))), lbl, TRUE(!(0)), TRUE(!(0)), 0); | |||
2652 | ||||
2653 | /* archive name */ | |||
2654 | ||||
2655 | g_free (window->priv->pd_last_archive); | |||
2656 | window->priv->pd_last_archive = NULL((void*)0); | |||
2657 | ||||
2658 | if (window->priv->archive_uri != NULL((void*)0)) | |||
2659 | window->priv->pd_last_archive = g_strdup (window->priv->archive_uri)g_strdup_inline (window->priv->archive_uri); | |||
2660 | ||||
2661 | /* progress and details */ | |||
2662 | ||||
2663 | progress_vbox = ctk_box_new (CTK_ORIENTATION_VERTICAL, 6); | |||
2664 | ctk_widget_set_valign (progress_vbox, CTK_ALIGN_START); | |||
2665 | ctk_widget_set_hexpand (progress_vbox, TRUE(!(0))); | |||
2666 | ctk_widget_set_vexpand (progress_vbox, TRUE(!(0))); | |||
2667 | ctk_widget_set_margin_bottom (progress_vbox, 6); | |||
2668 | ctk_box_pack_start (CTK_BOX (vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((vbox)), ((ctk_box_get_type ())))))), progress_vbox, TRUE(!(0)), TRUE(!(0)), 0); | |||
2669 | ||||
2670 | /* progress bar */ | |||
2671 | ||||
2672 | window->priv->pd_progress_bar = ctk_progress_bar_new (); | |||
2673 | ctk_progress_bar_set_pulse_step (CTK_PROGRESS_BAR (window->priv->pd_progress_bar)((((CtkProgressBar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->pd_progress_bar)), ((ctk_progress_bar_get_type ())))))), ACTIVITY_PULSE_STEP(0.033)); | |||
2674 | ctk_box_pack_start (CTK_BOX (progress_vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((progress_vbox)), ((ctk_box_get_type ())))))), window->priv->pd_progress_bar, TRUE(!(0)), TRUE(!(0)), 0); | |||
2675 | ||||
2676 | /* details label */ | |||
2677 | ||||
2678 | lbl = window->priv->pd_message = ctk_label_new (""); | |||
2679 | ||||
2680 | attr_list = pango_attr_list_new (); | |||
2681 | pango_attr_list_insert (attr_list, pango_attr_size_new (9000)); | |||
2682 | ctk_label_set_attributes (CTK_LABEL (lbl)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((lbl)), ((ctk_label_get_type ())))))), attr_list); | |||
2683 | pango_attr_list_unref (attr_list); | |||
2684 | ||||
2685 | ctk_label_set_xalign (CTK_LABEL (lbl)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((lbl)), ((ctk_label_get_type ())))))), 0.0); | |||
2686 | ctk_label_set_ellipsize (CTK_LABEL (lbl)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((lbl)), ((ctk_label_get_type ())))))), PANGO_ELLIPSIZE_END); | |||
2687 | ctk_box_pack_start (CTK_BOX (progress_vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((progress_vbox)), ((ctk_box_get_type ())))))), lbl, TRUE(!(0)), TRUE(!(0)), 0); | |||
2688 | ||||
2689 | ctk_widget_show_all (hbox); | |||
2690 | ||||
2691 | progress_dialog_update_action_description (window); | |||
2692 | ||||
2693 | /* signals */ | |||
2694 | ||||
2695 | g_signal_connect (G_OBJECT (window->priv->progress_dialog),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->progress_dialog)), ( ((GType) ((20) << (2))))))))), ("response"), (((GCallback ) (progress_dialog_response))), (window), ((void*)0), (GConnectFlags ) 0) | |||
2696 | "response",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->progress_dialog)), ( ((GType) ((20) << (2))))))))), ("response"), (((GCallback ) (progress_dialog_response))), (window), ((void*)0), (GConnectFlags ) 0) | |||
2697 | G_CALLBACK (progress_dialog_response),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->progress_dialog)), ( ((GType) ((20) << (2))))))))), ("response"), (((GCallback ) (progress_dialog_response))), (window), ((void*)0), (GConnectFlags ) 0) | |||
2698 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->progress_dialog)), ( ((GType) ((20) << (2))))))))), ("response"), (((GCallback ) (progress_dialog_response))), (window), ((void*)0), (GConnectFlags ) 0); | |||
2699 | g_signal_connect (G_OBJECT (window->priv->progress_dialog),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->progress_dialog)), ( ((GType) ((20) << (2))))))))), ("delete_event"), (((GCallback ) (progress_dialog_delete_event))), (window), ((void*)0), (GConnectFlags ) 0) | |||
2700 | "delete_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->progress_dialog)), ( ((GType) ((20) << (2))))))))), ("delete_event"), (((GCallback ) (progress_dialog_delete_event))), (window), ((void*)0), (GConnectFlags ) 0) | |||
2701 | G_CALLBACK (progress_dialog_delete_event),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->progress_dialog)), ( ((GType) ((20) << (2))))))))), ("delete_event"), (((GCallback ) (progress_dialog_delete_event))), (window), ((void*)0), (GConnectFlags ) 0) | |||
2702 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->progress_dialog)), ( ((GType) ((20) << (2))))))))), ("delete_event"), (((GCallback ) (progress_dialog_delete_event))), (window), ((void*)0), (GConnectFlags ) 0); | |||
2703 | } | |||
2704 | ||||
2705 | ||||
2706 | static gboolean | |||
2707 | display_progress_dialog (gpointer data) | |||
2708 | { | |||
2709 | FrWindow *window = data; | |||
2710 | ||||
2711 | if (window->priv->progress_timeout != 0) | |||
2712 | g_source_remove (window->priv->progress_timeout); | |||
2713 | ||||
2714 | if (window->priv->use_progress_dialog && (window->priv->progress_dialog != NULL((void*)0))) { | |||
2715 | ctk_dialog_set_response_sensitive (CTK_DIALOG (window->priv->progress_dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->progress_dialog)), ((ctk_dialog_get_type ())))))), | |||
2716 | CTK_RESPONSE_OK, | |||
2717 | window->priv->stoppable); | |||
2718 | if (! window->priv->non_interactive) | |||
2719 | ctk_widget_show (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
2720 | ctk_widget_hide (window->priv->progress_bar); | |||
2721 | ctk_widget_show (window->priv->progress_dialog); | |||
2722 | fr_window_message_cb (NULL((void*)0), window->priv->pd_last_message, window); | |||
2723 | } | |||
2724 | ||||
2725 | window->priv->progress_timeout = 0; | |||
2726 | ||||
2727 | return FALSE(0); | |||
2728 | } | |||
2729 | ||||
2730 | ||||
2731 | static void | |||
2732 | open_progress_dialog (FrWindow *window, | |||
2733 | gboolean open_now) | |||
2734 | { | |||
2735 | if (window->priv->hide_progress_timeout != 0) { | |||
2736 | g_source_remove (window->priv->hide_progress_timeout); | |||
2737 | window->priv->hide_progress_timeout = 0; | |||
2738 | } | |||
2739 | ||||
2740 | if (open_now) { | |||
2741 | if (window->priv->progress_timeout != 0) | |||
2742 | g_source_remove (window->priv->progress_timeout); | |||
2743 | window->priv->progress_timeout = 0; | |||
2744 | } | |||
2745 | ||||
2746 | if ((window->priv->progress_timeout != 0) | |||
2747 | || ((window->priv->progress_dialog != NULL((void*)0)) && ctk_widget_get_visible (window->priv->progress_dialog))) | |||
2748 | return; | |||
2749 | ||||
2750 | if (! window->priv->batch_mode && ! open_now) | |||
2751 | ctk_widget_show (window->priv->progress_bar); | |||
2752 | ||||
2753 | create_the_progress_dialog (window); | |||
2754 | ctk_widget_show (window->priv->pd_cancel_button); | |||
2755 | ctk_widget_show (window->priv->pd_state_button); | |||
2756 | ctk_widget_hide (window->priv->pd_open_archive_button); | |||
2757 | ctk_widget_hide (window->priv->pd_open_destination_button); | |||
2758 | ctk_widget_hide (window->priv->pd_open_destination_and_quit_button); | |||
2759 | ctk_widget_hide (window->priv->pd_quit_button); | |||
2760 | ctk_widget_hide (window->priv->pd_close_button); | |||
2761 | ||||
2762 | if (open_now) | |||
2763 | display_progress_dialog (window); | |||
2764 | else | |||
2765 | window->priv->progress_timeout = g_timeout_add (PROGRESS_TIMEOUT_MSECS5000, | |||
2766 | display_progress_dialog, | |||
2767 | window); | |||
2768 | } | |||
2769 | ||||
2770 | ||||
2771 | static gboolean | |||
2772 | fr_window_progress_cb (FrArchive *archive, | |||
2773 | double fraction, | |||
2774 | FrWindow *window) | |||
2775 | { | |||
2776 | window->priv->progress_pulse = (fraction < 0.0); | |||
2777 | if (! window->priv->progress_pulse) { | |||
2778 | fraction = CLAMP (fraction, 0.0, 1.0)(((fraction) > (1.0)) ? (1.0) : (((fraction) < (0.0)) ? (0.0) : (fraction))); | |||
2779 | if (window->priv->progress_dialog != NULL((void*)0)) | |||
2780 | ctk_progress_bar_set_fraction (CTK_PROGRESS_BAR (window->priv->pd_progress_bar)((((CtkProgressBar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->pd_progress_bar)), ((ctk_progress_bar_get_type ())))))), fraction); | |||
2781 | ctk_progress_bar_set_fraction (CTK_PROGRESS_BAR (window->priv->progress_bar)((((CtkProgressBar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->progress_bar)), ((ctk_progress_bar_get_type ())))))), fraction); | |||
2782 | ||||
2783 | if ((archive != NULL((void*)0)) && (archive->command != NULL((void*)0)) && (archive->command->n_files > 0)) { | |||
2784 | char *message = NULL((void*)0); | |||
2785 | int remaining_files; | |||
2786 | ||||
2787 | remaining_files = archive->command->n_files - archive->command->n_file + 1; | |||
2788 | ||||
2789 | switch (window->priv->action) { | |||
2790 | case FR_ACTION_ADDING_FILES: | |||
2791 | case FR_ACTION_EXTRACTING_FILES: | |||
2792 | case FR_ACTION_DELETING_FILES: | |||
2793 | message = g_strdup_printf (ngettext ("%d file remaining", | |||
2794 | "%d files remaining", | |||
2795 | remaining_files), remaining_files); | |||
2796 | break; | |||
2797 | default: | |||
2798 | break; | |||
2799 | } | |||
2800 | ||||
2801 | if (message != NULL((void*)0)) | |||
2802 | fr_command_message (archive->command, message); | |||
2803 | } | |||
2804 | ||||
2805 | window->priv->pd_last_fraction = fraction; | |||
2806 | ||||
2807 | g_signal_emit (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), | |||
2808 | fr_window_signals[PROGRESS], | |||
2809 | 0, | |||
2810 | window->priv->pd_last_fraction, | |||
2811 | window->priv->pd_last_message); | |||
2812 | ||||
2813 | #ifdef LOG_PROGRESS | |||
2814 | g_print ("progress > %2.2f\n", fraction); | |||
2815 | #endif | |||
2816 | } | |||
2817 | return TRUE(!(0)); | |||
2818 | } | |||
2819 | ||||
2820 | ||||
2821 | static void | |||
2822 | open_progress_dialog_with_open_destination (FrWindow *window) | |||
2823 | { | |||
2824 | window->priv->ask_to_open_destination_after_extraction = FALSE(0); | |||
2825 | ||||
2826 | if (window->priv->hide_progress_timeout != 0) { | |||
2827 | g_source_remove (window->priv->hide_progress_timeout); | |||
2828 | window->priv->hide_progress_timeout = 0; | |||
2829 | } | |||
2830 | if (window->priv->progress_timeout != 0) { | |||
2831 | g_source_remove (window->priv->progress_timeout); | |||
2832 | window->priv->progress_timeout = 0; | |||
2833 | } | |||
2834 | ||||
2835 | create_the_progress_dialog (window); | |||
2836 | ctk_widget_hide (window->priv->pd_cancel_button); | |||
2837 | ctk_widget_hide (window->priv->pd_state_button); | |||
2838 | ctk_widget_hide (window->priv->pd_open_archive_button); | |||
2839 | ctk_widget_show (window->priv->pd_open_destination_button); | |||
2840 | ctk_widget_show (window->priv->pd_open_destination_and_quit_button); | |||
2841 | ctk_widget_show (window->priv->pd_quit_button); | |||
2842 | ctk_widget_show (window->priv->pd_close_button); | |||
2843 | display_progress_dialog (window); | |||
2844 | fr_window_progress_cb (NULL((void*)0), 1.0, window); | |||
2845 | fr_window_message_cb (NULL((void*)0), _("Extraction completed successfully")gettext ("Extraction completed successfully"), window); | |||
2846 | } | |||
2847 | ||||
2848 | ||||
2849 | static void | |||
2850 | open_progress_dialog_with_open_archive (FrWindow *window) | |||
2851 | { | |||
2852 | if (window->priv->hide_progress_timeout != 0) { | |||
2853 | g_source_remove (window->priv->hide_progress_timeout); | |||
2854 | window->priv->hide_progress_timeout = 0; | |||
2855 | } | |||
2856 | if (window->priv->progress_timeout != 0) { | |||
2857 | g_source_remove (window->priv->progress_timeout); | |||
2858 | window->priv->progress_timeout = 0; | |||
2859 | } | |||
2860 | ||||
2861 | create_the_progress_dialog (window); | |||
2862 | ctk_widget_hide (window->priv->pd_cancel_button); | |||
2863 | ctk_widget_hide (window->priv->pd_state_button); | |||
2864 | ctk_widget_hide (window->priv->pd_open_destination_button); | |||
2865 | ctk_widget_hide (window->priv->pd_open_destination_and_quit_button); | |||
2866 | ctk_widget_show (window->priv->pd_open_archive_button); | |||
2867 | ctk_widget_show (window->priv->pd_close_button); | |||
2868 | display_progress_dialog (window); | |||
2869 | fr_window_progress_cb (NULL((void*)0), 1.0, window); | |||
2870 | fr_window_message_cb (NULL((void*)0), _("Archive created successfully")gettext ("Archive created successfully"), window); | |||
2871 | } | |||
2872 | ||||
2873 | ||||
2874 | void | |||
2875 | fr_window_push_message (FrWindow *window, | |||
2876 | const char *msg) | |||
2877 | { | |||
2878 | if (! ctk_widget_get_mapped (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))) | |||
2879 | return; | |||
2880 | ||||
2881 | ctk_statusbar_push (CTK_STATUSBAR (window->priv->statusbar)((((CtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->statusbar)), ((ctk_statusbar_get_type ())))))), | |||
2882 | window->priv->progress_cid, | |||
2883 | msg); | |||
2884 | } | |||
2885 | ||||
2886 | ||||
2887 | void | |||
2888 | fr_window_pop_message (FrWindow *window) | |||
2889 | { | |||
2890 | if (! ctk_widget_get_mapped (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))) | |||
2891 | return; | |||
2892 | ctk_statusbar_pop (CTK_STATUSBAR (window->priv->statusbar)((((CtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->statusbar)), ((ctk_statusbar_get_type ())))))), window->priv->progress_cid); | |||
2893 | if (window->priv->progress_dialog != NULL((void*)0)) | |||
2894 | ctk_label_set_text (CTK_LABEL (window->priv->pd_message)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->pd_message)), ((ctk_label_get_type ( ))))))), ""); | |||
2895 | } | |||
2896 | ||||
2897 | ||||
2898 | static void | |||
2899 | action_started (FrArchive *archive, | |||
2900 | FrAction action, | |||
2901 | gpointer data) | |||
2902 | { | |||
2903 | FrWindow *window = data; | |||
2904 | char *message; | |||
2905 | ||||
2906 | window->priv->action = action; | |||
2907 | fr_window_start_activity_mode (window); | |||
2908 | ||||
2909 | #ifdef CAFE_ENABLE_DEBUG | |||
2910 | debug (DEBUG_INFO"fr-window.c", 2910, __FUNCTION__, "%s [START] (FR::Window)\n", get_action_name (action)); | |||
2911 | #endif | |||
2912 | ||||
2913 | message = get_action_description (action, window->priv->pd_last_archive); | |||
2914 | fr_window_push_message (window, message); | |||
2915 | g_free (message); | |||
2916 | ||||
2917 | switch (action) { | |||
2918 | case FR_ACTION_EXTRACTING_FILES: | |||
2919 | open_progress_dialog (window, window->priv->ask_to_open_destination_after_extraction || window->priv->convert_data.converting || window->priv->batch_mode); | |||
2920 | break; | |||
2921 | default: | |||
2922 | open_progress_dialog (window, window->priv->batch_mode); | |||
2923 | break; | |||
2924 | } | |||
2925 | ||||
2926 | if (archive->command != NULL((void*)0)) { | |||
2927 | fr_command_progress (archive->command, -1.0); | |||
2928 | fr_command_message (archive->command, _("Please wait…")gettext ("Please wait…")); | |||
2929 | } | |||
2930 | } | |||
2931 | ||||
2932 | ||||
2933 | static void | |||
2934 | fr_window_add_to_recent_list (FrWindow *window, | |||
2935 | char *uri) | |||
2936 | { | |||
2937 | if (window->priv->batch_mode) | |||
2938 | return; | |||
2939 | ||||
2940 | if (is_temp_dir (uri)) | |||
2941 | return; | |||
2942 | ||||
2943 | if (window->archive->content_type != NULL((void*)0)) { | |||
2944 | CtkRecentData *recent_data; | |||
2945 | ||||
2946 | recent_data = g_new0 (CtkRecentData, 1)((CtkRecentData *) g_malloc0_n ((1), sizeof (CtkRecentData))); | |||
2947 | recent_data->mime_type = g_content_type_get_mime_type (window->archive->content_type); | |||
2948 | recent_data->app_name = "Grapa"; | |||
2949 | recent_data->app_exec = "grapa"; | |||
2950 | ctk_recent_manager_add_full (ctk_recent_manager_get_default (), uri, recent_data); | |||
2951 | ||||
2952 | g_free (recent_data); | |||
2953 | } | |||
2954 | else | |||
2955 | ctk_recent_manager_add_item (ctk_recent_manager_get_default (), uri); | |||
2956 | } | |||
2957 | ||||
2958 | ||||
2959 | static void | |||
2960 | fr_window_remove_from_recent_list (FrWindow *window G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
2961 | char *filename) | |||
2962 | { | |||
2963 | if (filename != NULL((void*)0)) | |||
2964 | ctk_recent_manager_remove_item (ctk_recent_manager_get_default (), filename, NULL((void*)0)); | |||
2965 | } | |||
2966 | ||||
2967 | ||||
2968 | static void | |||
2969 | error_dialog_response_cb (CtkDialog *dialog, | |||
2970 | gint arg1 G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
2971 | gpointer user_data) | |||
2972 | { | |||
2973 | FrWindow *window = user_data; | |||
2974 | CtkWindow *dialog_parent = window->priv->error_dialog_parent; | |||
2975 | ||||
2976 | window->priv->showing_error_dialog = FALSE(0); | |||
2977 | window->priv->error_dialog_parent = NULL((void*)0); | |||
2978 | ||||
2979 | if ((dialog_parent != NULL((void*)0)) && (ctk_widget_get_toplevel (CTK_WIDGET (dialog_parent)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog_parent)), ((ctk_widget_get_type ()))))))) != (CtkWidget*) dialog_parent)) | |||
2980 | ctk_window_set_modal (dialog_parent, TRUE(!(0))); | |||
2981 | ctk_widget_destroy (CTK_WIDGET (dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_widget_get_type ()))))))); | |||
2982 | ||||
2983 | if (window->priv->destroy_with_error_dialog) | |||
2984 | ctk_widget_destroy (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
2985 | } | |||
2986 | ||||
2987 | ||||
2988 | static void | |||
2989 | fr_window_show_error_dialog (FrWindow *window, | |||
2990 | CtkWidget *dialog, | |||
2991 | CtkWindow *dialog_parent, | |||
2992 | const char *details) | |||
2993 | { | |||
2994 | if (window->priv->batch_mode && ! window->priv->use_progress_dialog) { | |||
2995 | GError *error; | |||
2996 | ||||
2997 | error = g_error_new_literal (FR_ERRORfr_error_quark (), FR_PROC_ERROR_GENERIC, details ? details : _("Command exited abnormally.")gettext ("Command exited abnormally.")); | |||
2998 | g_signal_emit (window, | |||
2999 | fr_window_signals[READY], | |||
3000 | 0, | |||
3001 | error); | |||
3002 | ||||
3003 | ctk_widget_destroy (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
3004 | ||||
3005 | return; | |||
3006 | } | |||
3007 | ||||
3008 | close_progress_dialog (window, TRUE(!(0))); | |||
3009 | ||||
3010 | if (window->priv->batch_mode) | |||
3011 | fr_window_destroy_with_error_dialog (window); | |||
3012 | ||||
3013 | if (dialog_parent != NULL((void*)0)) | |||
3014 | ctk_window_set_modal (dialog_parent, FALSE(0)); | |||
3015 | g_signal_connect (dialog,g_signal_connect_data ((dialog), ("response"), (((GCallback) ( error_dialog_response_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3016 | "response",g_signal_connect_data ((dialog), ("response"), (((GCallback) ( error_dialog_response_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3017 | G_CALLBACK (error_dialog_response_cb),g_signal_connect_data ((dialog), ("response"), (((GCallback) ( error_dialog_response_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
3018 | window)g_signal_connect_data ((dialog), ("response"), (((GCallback) ( error_dialog_response_cb))), (window), ((void*)0), (GConnectFlags ) 0); | |||
3019 | ctk_window_set_modal (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), TRUE(!(0))); | |||
3020 | ctk_widget_show (dialog); | |||
3021 | ||||
3022 | window->priv->showing_error_dialog = TRUE(!(0)); | |||
3023 | window->priv->error_dialog_parent = dialog_parent; | |||
3024 | } | |||
3025 | ||||
3026 | ||||
3027 | void | |||
3028 | fr_window_destroy_with_error_dialog (FrWindow *window) | |||
3029 | { | |||
3030 | window->priv->destroy_with_error_dialog = TRUE(!(0)); | |||
3031 | } | |||
3032 | ||||
3033 | ||||
3034 | static gboolean | |||
3035 | handle_errors (FrWindow *window, | |||
3036 | FrArchive *archive, | |||
3037 | FrAction action, | |||
3038 | FrProcError *error) | |||
3039 | { | |||
3040 | if (error->type == FR_PROC_ERROR_ASK_PASSWORD) { | |||
3041 | close_progress_dialog (window, TRUE(!(0))); | |||
3042 | dlg_ask_password (window); | |||
3043 | return FALSE(0); | |||
3044 | } | |||
3045 | else if (error->type == FR_PROC_ERROR_UNSUPPORTED_FORMAT) { | |||
3046 | close_progress_dialog (window, TRUE(!(0))); | |||
3047 | dlg_package_installer (window, archive, action); | |||
3048 | return FALSE(0); | |||
3049 | } | |||
3050 | #if 0 | |||
3051 | else if (error->type == FR_PROC_ERROR_BAD_CHARSET) { | |||
3052 | close_progress_dialog (window, TRUE(!(0))); | |||
3053 | /* dlg_ask_archive_charset (window); FIXME: implement after feature freeze */ | |||
3054 | return FALSE(0); | |||
3055 | } | |||
3056 | #endif | |||
3057 | else if (error->type == FR_PROC_ERROR_STOPPED) { | |||
3058 | /* nothing */ | |||
3059 | } | |||
3060 | else if (error->type != FR_PROC_ERROR_NONE) { | |||
3061 | char *msg = NULL((void*)0); | |||
3062 | char *utf8_name; | |||
3063 | char *details = NULL((void*)0); | |||
3064 | CtkWindow *dialog_parent; | |||
3065 | CtkWidget *dialog; | |||
3066 | FrProcess *process = archive->process; | |||
3067 | GList *output = NULL((void*)0); | |||
3068 | ||||
3069 | if (window->priv->batch_mode) { | |||
3070 | dialog_parent = NULL((void*)0); | |||
3071 | window->priv->load_error_parent_window = NULL((void*)0); | |||
3072 | } | |||
3073 | else { | |||
3074 | dialog_parent = (CtkWindow *) window; | |||
3075 | if (window->priv->load_error_parent_window == NULL((void*)0)) | |||
3076 | window->priv->load_error_parent_window = (CtkWindow *) window; | |||
3077 | } | |||
3078 | ||||
3079 | if ((action == FR_ACTION_LISTING_CONTENT) || (action == FR_ACTION_LOADING_ARCHIVE)) | |||
3080 | fr_window_archive_close (window); | |||
3081 | ||||
3082 | switch (action) { | |||
3083 | case FR_ACTION_CREATING_NEW_ARCHIVE: | |||
3084 | dialog_parent = window->priv->load_error_parent_window; | |||
3085 | msg = _("Could not create the archive")gettext ("Could not create the archive"); | |||
3086 | break; | |||
3087 | ||||
3088 | case FR_ACTION_EXTRACTING_FILES: | |||
3089 | case FR_ACTION_COPYING_FILES_TO_REMOTE: | |||
3090 | msg = _("An error occurred while extracting files.")gettext ("An error occurred while extracting files."); | |||
3091 | break; | |||
3092 | ||||
3093 | case FR_ACTION_LOADING_ARCHIVE: | |||
3094 | dialog_parent = window->priv->load_error_parent_window; | |||
3095 | utf8_name = g_uri_display_basename (window->priv->archive_uri); | |||
3096 | msg = g_strdup_printf (_("Could not open \"%s\"")gettext ("Could not open \"%s\""), utf8_name); | |||
3097 | g_free (utf8_name); | |||
3098 | break; | |||
3099 | ||||
3100 | case FR_ACTION_LISTING_CONTENT: | |||
3101 | msg = _("An error occurred while loading the archive.")gettext ("An error occurred while loading the archive."); | |||
3102 | break; | |||
3103 | ||||
3104 | case FR_ACTION_DELETING_FILES: | |||
3105 | msg = _("An error occurred while deleting files from the archive.")gettext ("An error occurred while deleting files from the archive." ); | |||
3106 | break; | |||
3107 | ||||
3108 | case FR_ACTION_ADDING_FILES: | |||
3109 | case FR_ACTION_GETTING_FILE_LIST: | |||
3110 | case FR_ACTION_COPYING_FILES_FROM_REMOTE: | |||
3111 | msg = _("An error occurred while adding files to the archive.")gettext ("An error occurred while adding files to the archive." ); | |||
3112 | break; | |||
3113 | ||||
3114 | case FR_ACTION_TESTING_ARCHIVE: | |||
3115 | msg = _("An error occurred while testing archive.")gettext ("An error occurred while testing archive."); | |||
3116 | break; | |||
3117 | ||||
3118 | case FR_ACTION_SAVING_REMOTE_ARCHIVE: | |||
3119 | msg = _("An error occurred while saving the archive.")gettext ("An error occurred while saving the archive."); | |||
3120 | break; | |||
3121 | ||||
3122 | default: | |||
3123 | msg = _("An error occurred.")gettext ("An error occurred."); | |||
3124 | break; | |||
3125 | } | |||
3126 | ||||
3127 | switch (error->type) { | |||
3128 | case FR_PROC_ERROR_COMMAND_NOT_FOUND: | |||
3129 | details = _("Command not found.")gettext ("Command not found."); | |||
3130 | break; | |||
3131 | case FR_PROC_ERROR_EXITED_ABNORMALLY: | |||
3132 | details = _("Command exited abnormally.")gettext ("Command exited abnormally."); | |||
3133 | break; | |||
3134 | case FR_PROC_ERROR_SPAWN: | |||
3135 | details = error->gerror->message; | |||
3136 | break; | |||
3137 | default: | |||
3138 | if (error->gerror != NULL((void*)0)) | |||
3139 | details = error->gerror->message; | |||
3140 | else | |||
3141 | details = NULL((void*)0); | |||
3142 | break; | |||
3143 | } | |||
3144 | ||||
3145 | if (error->type != FR_PROC_ERROR_GENERIC) | |||
3146 | output = (process->err.raw != NULL((void*)0)) ? process->err.raw : process->out.raw; | |||
3147 | ||||
3148 | dialog = _ctk_error_dialog_new (dialog_parent, | |||
3149 | 0, | |||
3150 | output, | |||
3151 | msg, | |||
3152 | ((details != NULL((void*)0)) ? "%s" : NULL((void*)0)), | |||
3153 | details); | |||
3154 | fr_window_show_error_dialog (window, dialog, dialog_parent, details); | |||
3155 | ||||
3156 | return FALSE(0); | |||
3157 | } | |||
3158 | ||||
3159 | return TRUE(!(0)); | |||
3160 | } | |||
3161 | ||||
3162 | ||||
3163 | static void | |||
3164 | convert__action_performed (FrArchive *archive, | |||
3165 | FrAction action, | |||
3166 | FrProcError *error, | |||
3167 | gpointer data) | |||
3168 | { | |||
3169 | FrWindow *window = data; | |||
3170 | ||||
3171 | #ifdef CAFE_ENABLE_DEBUG | |||
3172 | debug (DEBUG_INFO"fr-window.c", 3172, __FUNCTION__, "%s [CONVERT::DONE] (FR::Window)\n", get_action_name (action)); | |||
3173 | #endif | |||
3174 | ||||
3175 | if ((action == FR_ACTION_GETTING_FILE_LIST) || (action == FR_ACTION_ADDING_FILES)) { | |||
3176 | fr_window_stop_activity_mode (window); | |||
3177 | fr_window_pop_message (window); | |||
3178 | close_progress_dialog (window, FALSE(0)); | |||
3179 | } | |||
3180 | ||||
3181 | if (action != FR_ACTION_ADDING_FILES) | |||
3182 | return; | |||
3183 | ||||
3184 | handle_errors (window, archive, action, error); | |||
3185 | ||||
3186 | if (error->type == FR_PROC_ERROR_NONE) | |||
3187 | open_progress_dialog_with_open_archive (window); | |||
3188 | ||||
3189 | remove_local_directory (window->priv->convert_data.temp_dir); | |||
3190 | fr_window_convert_data_free (window, FALSE(0)); | |||
3191 | ||||
3192 | fr_window_update_sensitivity (window); | |||
3193 | fr_window_update_statusbar_list_info (window); | |||
3194 | } | |||
3195 | ||||
3196 | ||||
3197 | static void fr_window_exec_next_batch_action (FrWindow *window); | |||
3198 | ||||
3199 | ||||
3200 | static void | |||
3201 | action_performed (FrArchive *archive, | |||
3202 | FrAction action, | |||
3203 | FrProcError *error, | |||
3204 | gpointer data) | |||
3205 | { | |||
3206 | FrWindow *window = data; | |||
3207 | gboolean continue_batch = FALSE(0); | |||
3208 | char *archive_dir; | |||
3209 | gboolean temp_dir; | |||
3210 | ||||
3211 | #ifdef CAFE_ENABLE_DEBUG | |||
3212 | debug (DEBUG_INFO"fr-window.c", 3212, __FUNCTION__, "%s [DONE] (FR::Window)\n", get_action_name (action)); | |||
3213 | #endif | |||
3214 | ||||
3215 | fr_window_stop_activity_mode (window); | |||
3216 | fr_window_pop_message (window); | |||
3217 | ||||
3218 | continue_batch = handle_errors (window, archive, action, error); | |||
3219 | ||||
3220 | if ((error->type == FR_PROC_ERROR_ASK_PASSWORD) | |||
3221 | || (error->type == FR_PROC_ERROR_UNSUPPORTED_FORMAT) | |||
3222 | /*|| (error->type == FR_PROC_ERROR_BAD_CHARSET)*/) | |||
3223 | { | |||
3224 | return; | |||
3225 | } | |||
3226 | ||||
3227 | switch (action) { | |||
3228 | case FR_ACTION_CREATING_NEW_ARCHIVE: | |||
3229 | case FR_ACTION_CREATING_ARCHIVE: | |||
3230 | close_progress_dialog (window, FALSE(0)); | |||
3231 | if (error->type != FR_PROC_ERROR_STOPPED) { | |||
3232 | fr_window_history_clear (window); | |||
3233 | fr_window_go_to_location (window, "/", TRUE(!(0))); | |||
3234 | fr_window_update_dir_tree (window); | |||
3235 | fr_window_update_title (window); | |||
3236 | fr_window_update_sensitivity (window); | |||
3237 | } | |||
3238 | break; | |||
3239 | ||||
3240 | case FR_ACTION_LOADING_ARCHIVE: | |||
3241 | close_progress_dialog (window, FALSE(0)); | |||
3242 | if (error->type != FR_PROC_ERROR_NONE) { | |||
3243 | fr_window_remove_from_recent_list (window, window->priv->archive_uri); | |||
3244 | if (window->priv->non_interactive) { | |||
3245 | fr_window_archive_close (window); | |||
3246 | fr_window_stop_batch (window); | |||
3247 | } | |||
3248 | } | |||
3249 | else { | |||
3250 | fr_window_add_to_recent_list (window, window->priv->archive_uri); | |||
3251 | if (! window->priv->non_interactive) | |||
3252 | ctk_window_present (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ()))))))); | |||
3253 | } | |||
3254 | continue_batch = FALSE(0); | |||
3255 | g_signal_emit (window, | |||
3256 | fr_window_signals[ARCHIVE_LOADED], | |||
3257 | 0, | |||
3258 | error->type == FR_PROC_ERROR_NONE); | |||
3259 | break; | |||
3260 | ||||
3261 | case FR_ACTION_LISTING_CONTENT: | |||
3262 | /* update the uri because multi-volume archives can have | |||
3263 | * a different name after loading. */ | |||
3264 | g_free (window->priv->archive_uri); | |||
3265 | window->priv->archive_uri = g_file_get_uri (window->archive->file); | |||
3266 | ||||
3267 | close_progress_dialog (window, FALSE(0)); | |||
3268 | if (error->type != FR_PROC_ERROR_NONE) { | |||
3269 | fr_window_remove_from_recent_list (window, window->priv->archive_uri); | |||
3270 | fr_window_archive_close (window); | |||
3271 | fr_window_set_password (window, NULL((void*)0)); | |||
3272 | break; | |||
3273 | } | |||
3274 | ||||
3275 | archive_dir = remove_level_from_path (window->priv->archive_uri); | |||
3276 | temp_dir = is_temp_dir (archive_dir); | |||
3277 | if (! window->priv->archive_present) { | |||
3278 | window->priv->archive_present = TRUE(!(0)); | |||
3279 | ||||
3280 | fr_window_history_clear (window); | |||
3281 | fr_window_history_add (window, "/"); | |||
3282 | ||||
3283 | if (! temp_dir) { | |||
3284 | fr_window_set_open_default_dir (window, archive_dir); | |||
3285 | fr_window_set_add_default_dir (window, archive_dir); | |||
3286 | if (! window->priv->freeze_default_dir) | |||
3287 | fr_window_set_extract_default_dir (window, archive_dir, FALSE(0)); | |||
3288 | } | |||
3289 | ||||
3290 | window->priv->archive_new = FALSE(0); | |||
3291 | } | |||
3292 | g_free (archive_dir); | |||
3293 | ||||
3294 | if (! temp_dir) | |||
3295 | fr_window_add_to_recent_list (window, window->priv->archive_uri); | |||
3296 | ||||
3297 | fr_window_update_title (window); | |||
3298 | fr_window_go_to_location (window, fr_window_get_current_location (window), TRUE(!(0))); | |||
3299 | fr_window_update_dir_tree (window); | |||
3300 | if (! window->priv->batch_mode && window->priv->non_interactive) | |||
3301 | ctk_window_present (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ()))))))); | |||
3302 | break; | |||
3303 | ||||
3304 | case FR_ACTION_DELETING_FILES: | |||
3305 | close_progress_dialog (window, FALSE(0)); | |||
3306 | if (error->type != FR_PROC_ERROR_STOPPED) | |||
3307 | fr_window_archive_reload (window); | |||
3308 | return; | |||
3309 | ||||
3310 | case FR_ACTION_ADDING_FILES: | |||
3311 | if (ctk_widget_get_visible (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))) == FALSE(0)) | |||
3312 | show_notification (window); | |||
3313 | ||||
3314 | close_progress_dialog (window, FALSE(0)); | |||
3315 | ||||
3316 | /* update the uri because multi-volume archives can have | |||
3317 | * a different name after creation. */ | |||
3318 | g_free (window->priv->archive_uri); | |||
3319 | window->priv->archive_uri = g_file_get_uri (window->archive->file); | |||
3320 | ||||
3321 | if (error->type == FR_PROC_ERROR_NONE) { | |||
3322 | if (window->priv->archive_new) | |||
3323 | window->priv->archive_new = FALSE(0); | |||
3324 | fr_window_add_to_recent_list (window, window->priv->archive_uri); | |||
3325 | } | |||
3326 | if (! window->priv->batch_mode && (error->type != FR_PROC_ERROR_STOPPED)) { | |||
3327 | fr_window_archive_reload (window); | |||
3328 | return; | |||
3329 | } | |||
3330 | break; | |||
3331 | ||||
3332 | case FR_ACTION_TESTING_ARCHIVE: | |||
3333 | close_progress_dialog (window, FALSE(0)); | |||
3334 | if (error->type == FR_PROC_ERROR_NONE) | |||
3335 | fr_window_view_last_output (window, _("Test Result")gettext ("Test Result")); | |||
3336 | return; | |||
3337 | ||||
3338 | case FR_ACTION_EXTRACTING_FILES: | |||
3339 | if (error->type != FR_PROC_ERROR_NONE) { | |||
3340 | if (window->priv->convert_data.converting) { | |||
3341 | remove_local_directory (window->priv->convert_data.temp_dir); | |||
3342 | fr_window_convert_data_free (window, TRUE(!(0))); | |||
3343 | } | |||
3344 | break; | |||
3345 | } | |||
3346 | if (window->priv->convert_data.converting) { | |||
3347 | char *source_dir; | |||
3348 | ||||
3349 | source_dir = g_filename_to_uri (window->priv->convert_data.temp_dir, NULL((void*)0), NULL((void*)0)); | |||
3350 | fr_archive_add_with_wildcard ( | |||
3351 | window->priv->convert_data.new_archive, | |||
3352 | "*", | |||
3353 | NULL((void*)0), | |||
3354 | NULL((void*)0), | |||
3355 | source_dir, | |||
3356 | NULL((void*)0), | |||
3357 | FALSE(0), | |||
3358 | TRUE(!(0)), | |||
3359 | window->priv->convert_data.password, | |||
3360 | window->priv->convert_data.encrypt_header, | |||
3361 | window->priv->compression, | |||
3362 | window->priv->convert_data.volume_size); | |||
3363 | g_free (source_dir); | |||
3364 | } | |||
3365 | else { | |||
3366 | if ((window->priv->ask_to_open_destination_after_extraction) && (window->priv->drag_destination_folder == NULL((void*)0))) { | |||
3367 | open_progress_dialog_with_open_destination (window); | |||
3368 | show_notification (window); | |||
3369 | } | |||
3370 | else { | |||
3371 | if (ctk_widget_get_visible (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))) == FALSE(0)) | |||
3372 | show_notification (window); | |||
3373 | ||||
3374 | close_progress_dialog (window, FALSE(0)); | |||
3375 | ||||
3376 | if (window->priv->drag_destination_folder) { | |||
3377 | g_free (window->priv->drag_destination_folder); | |||
3378 | window->priv->drag_destination_folder = NULL((void*)0); | |||
3379 | } | |||
3380 | } | |||
3381 | } | |||
3382 | break; | |||
3383 | ||||
3384 | default: | |||
3385 | close_progress_dialog (window, FALSE(0)); | |||
3386 | continue_batch = FALSE(0); | |||
3387 | break; | |||
3388 | } | |||
3389 | ||||
3390 | if (window->priv->batch_action == NULL((void*)0)) { | |||
3391 | fr_window_update_sensitivity (window); | |||
3392 | fr_window_update_statusbar_list_info (window); | |||
3393 | } | |||
3394 | ||||
3395 | if (continue_batch) { | |||
3396 | if (error->type != FR_PROC_ERROR_NONE) | |||
3397 | fr_window_stop_batch (window); | |||
3398 | else | |||
3399 | fr_window_exec_next_batch_action (window); | |||
3400 | } | |||
3401 | } | |||
3402 | ||||
3403 | ||||
3404 | /* -- selections -- */ | |||
3405 | ||||
3406 | ||||
3407 | #undef DEBUG_GET_DIR_LIST_FROM_PATH | |||
3408 | ||||
3409 | ||||
3410 | static GList * | |||
3411 | get_dir_list_from_path (FrWindow *window, | |||
3412 | char *path) | |||
3413 | { | |||
3414 | char *dirname; | |||
3415 | int dirname_l; | |||
3416 | GList *list = NULL((void*)0); | |||
3417 | guint i; | |||
3418 | ||||
3419 | if (path[strlen (path) - 1] != '/') | |||
3420 | dirname = g_strconcat (path, "/", NULL((void*)0)); | |||
3421 | else | |||
3422 | dirname = g_strdup (path)g_strdup_inline (path); | |||
3423 | dirname_l = strlen (dirname); | |||
3424 | for (i = 0; i < window->archive->command->files->len; i++) { | |||
3425 | FileData *fd = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i]; | |||
3426 | gboolean matches = FALSE(0); | |||
3427 | ||||
3428 | #ifdef DEBUG_GET_DIR_LIST_FROM_PATH | |||
3429 | g_print ("%s <=> %s (%d)\n", dirname, fd->full_path, dirname_l); | |||
3430 | #endif | |||
3431 | ||||
3432 | if (fd->dir) { | |||
3433 | int full_path_l = strlen (fd->full_path); | |||
3434 | if ((full_path_l == dirname_l - 1) && (strncmp (dirname, fd->full_path, full_path_l) == 0)) | |||
3435 | /* example: dirname is '/path/to/dir/' and fd->full_path is '/path/to/dir' */ | |||
3436 | matches = TRUE(!(0)); | |||
3437 | else if (strcmp (dirname, fd->full_path) == 0) | |||
3438 | matches = TRUE(!(0)); | |||
3439 | } | |||
3440 | ||||
3441 | if (! matches && strncmp (dirname, fd->full_path, dirname_l) == 0) { | |||
3442 | matches = TRUE(!(0)); | |||
3443 | } | |||
3444 | ||||
3445 | if (matches) { | |||
3446 | #ifdef DEBUG_GET_DIR_LIST_FROM_PATH | |||
3447 | g_print ("`-> OK\n"); | |||
3448 | #endif | |||
3449 | list = g_list_prepend (list, g_strdup (fd->original_path)g_strdup_inline (fd->original_path)); | |||
3450 | } | |||
3451 | } | |||
3452 | g_free (dirname); | |||
3453 | ||||
3454 | return g_list_reverse (list); | |||
3455 | } | |||
3456 | ||||
3457 | ||||
3458 | static GList * | |||
3459 | get_dir_list_from_file_data (FrWindow *window, | |||
3460 | FileData *fdata) | |||
3461 | { | |||
3462 | char *dirname; | |||
3463 | GList *list; | |||
3464 | ||||
3465 | dirname = g_strconcat (fr_window_get_current_location (window), | |||
3466 | fdata->list_name, | |||
3467 | NULL((void*)0)); | |||
3468 | list = get_dir_list_from_path (window, dirname); | |||
3469 | g_free (dirname); | |||
3470 | ||||
3471 | return list; | |||
3472 | } | |||
3473 | ||||
3474 | ||||
3475 | GList * | |||
3476 | fr_window_get_file_list_selection (FrWindow *window, | |||
3477 | gboolean recursive, | |||
3478 | gboolean *has_dirs) | |||
3479 | { | |||
3480 | CtkTreeSelection *selection; | |||
3481 | GList *selections = NULL((void*)0), *list, *scan; | |||
3482 | ||||
3483 | g_return_val_if_fail (window != NULL, NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return (((void*)0)); } } while (0); | |||
3484 | ||||
3485 | if (has_dirs != NULL((void*)0)) | |||
3486 | *has_dirs = FALSE(0); | |||
3487 | ||||
3488 | selection = ctk_tree_view_get_selection (CTK_TREE_VIEW (window->priv->list_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_view)), ((ctk_tree_view_get_type ()))))))); | |||
3489 | if (selection == NULL((void*)0)) | |||
3490 | return NULL((void*)0); | |||
3491 | ctk_tree_selection_selected_foreach (selection, add_selected_from_list_view, &selections); | |||
3492 | ||||
3493 | list = NULL((void*)0); | |||
3494 | for (scan = selections; scan; scan = scan->next) { | |||
3495 | FileData *fd = scan->data; | |||
3496 | ||||
3497 | if (!fd) | |||
3498 | continue; | |||
3499 | ||||
3500 | if (file_data_is_dir (fd)) { | |||
3501 | if (has_dirs != NULL((void*)0)) | |||
3502 | *has_dirs = TRUE(!(0)); | |||
3503 | ||||
3504 | if (recursive) | |||
3505 | list = g_list_concat (list, get_dir_list_from_file_data (window, fd)); | |||
3506 | } | |||
3507 | else | |||
3508 | list = g_list_prepend (list, g_strdup (fd->original_path)g_strdup_inline (fd->original_path)); | |||
3509 | } | |||
3510 | if (selections) | |||
3511 | g_list_free (selections); | |||
3512 | ||||
3513 | return g_list_reverse (list); | |||
3514 | } | |||
3515 | ||||
3516 | ||||
3517 | GList * | |||
3518 | fr_window_get_folder_tree_selection (FrWindow *window, | |||
3519 | gboolean recursive, | |||
3520 | gboolean *has_dirs) | |||
3521 | { | |||
3522 | CtkTreeSelection *tree_selection; | |||
3523 | GList *selections, *list, *scan; | |||
3524 | ||||
3525 | g_return_val_if_fail (window != NULL, NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return (((void*)0)); } } while (0); | |||
3526 | ||||
3527 | if (has_dirs != NULL((void*)0)) | |||
3528 | *has_dirs = FALSE(0); | |||
3529 | ||||
3530 | tree_selection = ctk_tree_view_get_selection (CTK_TREE_VIEW (window->priv->tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->tree_view)), ((ctk_tree_view_get_type ()))))))); | |||
3531 | if (tree_selection == NULL((void*)0)) | |||
3532 | return NULL((void*)0); | |||
3533 | ||||
3534 | selections = NULL((void*)0); | |||
3535 | ctk_tree_selection_selected_foreach (tree_selection, add_selected_from_tree_view, &selections); | |||
3536 | if (selections == NULL((void*)0)) | |||
3537 | return NULL((void*)0); | |||
3538 | ||||
3539 | if (has_dirs != NULL((void*)0)) | |||
3540 | *has_dirs = TRUE(!(0)); | |||
3541 | ||||
3542 | list = NULL((void*)0); | |||
3543 | for (scan = selections; scan; scan = scan->next) { | |||
3544 | char *path = scan->data; | |||
3545 | ||||
3546 | if (recursive) | |||
3547 | list = g_list_concat (list, get_dir_list_from_path (window, path)); | |||
3548 | } | |||
3549 | path_list_free (selections); | |||
3550 | ||||
3551 | return g_list_reverse (list); | |||
3552 | } | |||
3553 | ||||
3554 | ||||
3555 | GList * | |||
3556 | fr_window_get_file_list_from_path_list (FrWindow *window, | |||
3557 | GList *path_list, | |||
3558 | gboolean *has_dirs) | |||
3559 | { | |||
3560 | CtkTreeModel *model; | |||
3561 | GList *selections, *list, *scan; | |||
3562 | ||||
3563 | g_return_val_if_fail (window != NULL, NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return (((void*)0)); } } while (0); | |||
3564 | ||||
3565 | model = CTK_TREE_MODEL (window->priv->list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_store)), ((ctk_tree_model_get_type ())))))); | |||
3566 | selections = NULL((void*)0); | |||
3567 | ||||
3568 | if (has_dirs != NULL((void*)0)) | |||
3569 | *has_dirs = FALSE(0); | |||
3570 | ||||
3571 | for (scan = path_list; scan; scan = scan->next) { | |||
3572 | CtkTreeRowReference *reference = scan->data; | |||
3573 | CtkTreePath *path; | |||
3574 | CtkTreeIter iter; | |||
3575 | FileData *fdata; | |||
3576 | ||||
3577 | path = ctk_tree_row_reference_get_path (reference); | |||
3578 | if (path == NULL((void*)0)) | |||
3579 | continue; | |||
3580 | ||||
3581 | if (! ctk_tree_model_get_iter (model, &iter, path)) | |||
3582 | continue; | |||
3583 | ||||
3584 | ctk_tree_model_get (model, &iter, | |||
3585 | COLUMN_FILE_DATA, &fdata, | |||
3586 | -1); | |||
3587 | ||||
3588 | selections = g_list_prepend (selections, fdata); | |||
3589 | } | |||
3590 | ||||
3591 | list = NULL((void*)0); | |||
3592 | for (scan = selections; scan; scan = scan->next) { | |||
3593 | FileData *fd = scan->data; | |||
3594 | ||||
3595 | if (!fd) | |||
3596 | continue; | |||
3597 | ||||
3598 | if (file_data_is_dir (fd)) { | |||
3599 | if (has_dirs != NULL((void*)0)) | |||
3600 | *has_dirs = TRUE(!(0)); | |||
3601 | list = g_list_concat (list, get_dir_list_from_file_data (window, fd)); | |||
3602 | } | |||
3603 | else | |||
3604 | list = g_list_prepend (list, g_strdup (fd->original_path)g_strdup_inline (fd->original_path)); | |||
3605 | } | |||
3606 | ||||
3607 | if (selections != NULL((void*)0)) | |||
3608 | g_list_free (selections); | |||
3609 | ||||
3610 | return g_list_reverse (list); | |||
3611 | } | |||
3612 | ||||
3613 | ||||
3614 | GList * | |||
3615 | fr_window_get_file_list_pattern (FrWindow *window, | |||
3616 | const char *pattern) | |||
3617 | { | |||
3618 | GRegex **regexps; | |||
3619 | GList *list; | |||
3620 | guint i; | |||
3621 | ||||
3622 | g_return_val_if_fail (window != NULL, NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return (((void*)0)); } } while (0); | |||
3623 | ||||
3624 | regexps = search_util_get_regexps (pattern, G_REGEX_CASELESS); | |||
3625 | list = NULL((void*)0); | |||
3626 | for (i = 0; i < window->archive->command->files->len; i++) { | |||
3627 | FileData *fd = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i]; | |||
3628 | char *utf8_name; | |||
3629 | ||||
3630 | /* FIXME: only files in the current location ? */ | |||
3631 | ||||
3632 | if (fd == NULL((void*)0)) | |||
3633 | continue; | |||
3634 | ||||
3635 | utf8_name = g_filename_to_utf8 (fd->name, -1, NULL((void*)0), NULL((void*)0), NULL((void*)0)); | |||
3636 | if (match_regexps (regexps, utf8_name, 0)) | |||
3637 | list = g_list_prepend (list, g_strdup (fd->original_path)g_strdup_inline (fd->original_path)); | |||
3638 | g_free (utf8_name); | |||
3639 | } | |||
3640 | free_regexps (regexps); | |||
3641 | ||||
3642 | return g_list_reverse (list); | |||
3643 | } | |||
3644 | ||||
3645 | ||||
3646 | static GList * | |||
3647 | fr_window_get_file_list (FrWindow *window) | |||
3648 | { | |||
3649 | GList *list; | |||
3650 | guint i; | |||
3651 | ||||
3652 | g_return_val_if_fail (window != NULL, NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return (((void*)0)); } } while (0); | |||
3653 | ||||
3654 | list = NULL((void*)0); | |||
3655 | for (i = 0; i < window->archive->command->files->len; i++) { | |||
3656 | FileData *fd = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i]; | |||
3657 | list = g_list_prepend (list, g_strdup (fd->original_path)g_strdup_inline (fd->original_path)); | |||
3658 | } | |||
3659 | ||||
3660 | return g_list_reverse (list); | |||
3661 | } | |||
3662 | ||||
3663 | ||||
3664 | int | |||
3665 | fr_window_get_n_selected_files (FrWindow *window) | |||
3666 | { | |||
3667 | return _ctk_count_selected (ctk_tree_view_get_selection (CTK_TREE_VIEW (window->priv->list_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_view)), ((ctk_tree_view_get_type ())))))))); | |||
3668 | } | |||
3669 | ||||
3670 | ||||
3671 | /**/ | |||
3672 | ||||
3673 | ||||
3674 | static int | |||
3675 | dir_tree_button_press_cb (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
3676 | CdkEventButton *event, | |||
3677 | gpointer data) | |||
3678 | { | |||
3679 | FrWindow *window = data; | |||
3680 | CtkTreeSelection *selection; | |||
3681 | ||||
3682 | if (event->window != ctk_tree_view_get_bin_window (CTK_TREE_VIEW (window->priv->tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->tree_view)), ((ctk_tree_view_get_type ())))))))) | |||
3683 | return FALSE(0); | |||
3684 | ||||
3685 | selection = ctk_tree_view_get_selection (CTK_TREE_VIEW (window->priv->tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->tree_view)), ((ctk_tree_view_get_type ()))))))); | |||
3686 | if (selection == NULL((void*)0)) | |||
3687 | return FALSE(0); | |||
3688 | ||||
3689 | if ((event->type == CDK_BUTTON_PRESS) && (event->button == 3)) { | |||
3690 | CtkTreePath *path; | |||
3691 | CtkTreeIter iter; | |||
3692 | ||||
3693 | if (ctk_tree_view_get_path_at_pos (CTK_TREE_VIEW (window->priv->tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->tree_view)), ((ctk_tree_view_get_type ())))))), | |||
3694 | event->x, event->y, | |||
3695 | &path, NULL((void*)0), NULL((void*)0), NULL((void*)0))) { | |||
3696 | ||||
3697 | if (! ctk_tree_model_get_iter (CTK_TREE_MODEL (window->priv->tree_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->tree_store)), ((ctk_tree_model_get_type ())))))), &iter, path)) { | |||
3698 | ctk_tree_path_free (path); | |||
3699 | return FALSE(0); | |||
3700 | } | |||
3701 | ctk_tree_path_free (path); | |||
3702 | ||||
3703 | if (! ctk_tree_selection_iter_is_selected (selection, &iter)) { | |||
3704 | ctk_tree_selection_unselect_all (selection); | |||
3705 | ctk_tree_selection_select_iter (selection, &iter); | |||
3706 | } | |||
3707 | ||||
3708 | ctk_menu_popup_at_pointer (CTK_MENU (window->priv->sidebar_folder_popup_menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->sidebar_folder_popup_menu)), ((ctk_menu_get_type ())))))), | |||
3709 | (const CdkEvent*) event); | |||
3710 | } | |||
3711 | else | |||
3712 | ctk_tree_selection_unselect_all (selection); | |||
3713 | ||||
3714 | return TRUE(!(0)); | |||
3715 | } | |||
3716 | else if ((event->type == CDK_BUTTON_PRESS) && (event->button == 8)) { | |||
3717 | fr_window_go_back (window); | |||
3718 | return TRUE(!(0)); | |||
3719 | } | |||
3720 | else if ((event->type == CDK_BUTTON_PRESS) && (event->button == 9)) { | |||
3721 | fr_window_go_forward (window); | |||
3722 | return TRUE(!(0)); | |||
3723 | } | |||
3724 | ||||
3725 | return FALSE(0); | |||
3726 | } | |||
3727 | ||||
3728 | ||||
3729 | static FileData * | |||
3730 | fr_window_get_selected_item_from_file_list (FrWindow *window) | |||
3731 | { | |||
3732 | CtkTreeSelection *tree_selection; | |||
3733 | GList *selection; | |||
3734 | FileData *fdata = NULL((void*)0); | |||
3735 | ||||
3736 | g_return_val_if_fail (window != NULL, NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return (((void*)0)); } } while (0); | |||
3737 | ||||
3738 | tree_selection = ctk_tree_view_get_selection (CTK_TREE_VIEW (window->priv->list_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_view)), ((ctk_tree_view_get_type ()))))))); | |||
3739 | if (tree_selection == NULL((void*)0)) | |||
3740 | return NULL((void*)0); | |||
3741 | ||||
3742 | selection = NULL((void*)0); | |||
3743 | ctk_tree_selection_selected_foreach (tree_selection, add_selected_from_list_view, &selection); | |||
3744 | if ((selection == NULL((void*)0)) || (selection->next != NULL((void*)0))) { | |||
3745 | /* return NULL if the selection contains more than one entry. */ | |||
3746 | g_list_free (selection); | |||
3747 | return NULL((void*)0); | |||
3748 | } | |||
3749 | ||||
3750 | fdata = file_data_copy (selection->data); | |||
3751 | g_list_free (selection); | |||
3752 | ||||
3753 | return fdata; | |||
3754 | } | |||
3755 | ||||
3756 | ||||
3757 | static char * | |||
3758 | fr_window_get_selected_folder_in_tree_view (FrWindow *window) | |||
3759 | { | |||
3760 | CtkTreeSelection *tree_selection; | |||
3761 | GList *selections; | |||
3762 | char *path = NULL((void*)0); | |||
3763 | ||||
3764 | g_return_val_if_fail (window != NULL, NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return (((void*)0)); } } while (0); | |||
3765 | ||||
3766 | tree_selection = ctk_tree_view_get_selection (CTK_TREE_VIEW (window->priv->tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->tree_view)), ((ctk_tree_view_get_type ()))))))); | |||
3767 | if (tree_selection == NULL((void*)0)) | |||
3768 | return NULL((void*)0); | |||
3769 | ||||
3770 | selections = NULL((void*)0); | |||
3771 | ctk_tree_selection_selected_foreach (tree_selection, add_selected_from_tree_view, &selections); | |||
3772 | ||||
3773 | if (selections != NULL((void*)0)) { | |||
3774 | path = selections->data; | |||
3775 | g_list_free (selections); | |||
3776 | } | |||
3777 | ||||
3778 | return path; | |||
3779 | } | |||
3780 | ||||
3781 | ||||
3782 | void | |||
3783 | fr_window_current_folder_activated (FrWindow *window, | |||
3784 | gboolean from_sidebar) | |||
3785 | { | |||
3786 | char *dir_path; | |||
3787 | ||||
3788 | if (! from_sidebar) { | |||
3789 | FileData *fdata; | |||
3790 | char *dir_name; | |||
3791 | ||||
3792 | fdata = fr_window_get_selected_item_from_file_list (window); | |||
3793 | if ((fdata == NULL((void*)0)) || ! file_data_is_dir (fdata)) { | |||
3794 | file_data_free (fdata); | |||
3795 | return; | |||
3796 | } | |||
3797 | dir_name = g_strdup (fdata->list_name)g_strdup_inline (fdata->list_name); | |||
3798 | dir_path = g_strconcat (fr_window_get_current_location (window), | |||
3799 | dir_name, | |||
3800 | "/", | |||
3801 | NULL((void*)0)); | |||
3802 | g_free (dir_name); | |||
3803 | file_data_free (fdata); | |||
3804 | } | |||
3805 | else | |||
3806 | dir_path = fr_window_get_selected_folder_in_tree_view (window); | |||
3807 | ||||
3808 | fr_window_go_to_location (window, dir_path, FALSE(0)); | |||
3809 | ||||
3810 | g_free (dir_path); | |||
3811 | } | |||
3812 | ||||
3813 | ||||
3814 | static gboolean | |||
3815 | row_activated_cb (CtkTreeView *tree_view G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
3816 | CtkTreePath *path, | |||
3817 | CtkTreeViewColumn *column G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
3818 | gpointer data) | |||
3819 | { | |||
3820 | FrWindow *window = data; | |||
3821 | FileData *fdata; | |||
3822 | CtkTreeIter iter; | |||
3823 | ||||
3824 | if (! ctk_tree_model_get_iter (CTK_TREE_MODEL (window->priv->list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_store)), ((ctk_tree_model_get_type ())))))), | |||
3825 | &iter, | |||
3826 | path)) | |||
3827 | return FALSE(0); | |||
3828 | ||||
3829 | ctk_tree_model_get (CTK_TREE_MODEL (window->priv->list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_store)), ((ctk_tree_model_get_type ())))))), &iter, | |||
3830 | COLUMN_FILE_DATA, &fdata, | |||
3831 | -1); | |||
3832 | ||||
3833 | if (! file_data_is_dir (fdata)) { | |||
3834 | GList *list = g_list_prepend (NULL((void*)0), fdata->original_path); | |||
3835 | fr_window_open_files (window, list, FALSE(0)); | |||
3836 | g_list_free (list); | |||
3837 | } | |||
3838 | else if (window->priv->list_mode == FR_WINDOW_LIST_MODE_AS_DIR) { | |||
3839 | char *new_dir; | |||
3840 | new_dir = g_strconcat (fr_window_get_current_location (window), | |||
3841 | fdata->list_name, | |||
3842 | "/", | |||
3843 | NULL((void*)0)); | |||
3844 | fr_window_go_to_location (window, new_dir, FALSE(0)); | |||
3845 | g_free (new_dir); | |||
3846 | } | |||
3847 | ||||
3848 | return FALSE(0); | |||
3849 | } | |||
3850 | ||||
3851 | ||||
3852 | static int | |||
3853 | file_button_press_cb (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
3854 | CdkEventButton *event, | |||
3855 | gpointer data) | |||
3856 | { | |||
3857 | FrWindow *window = data; | |||
3858 | CtkTreeSelection *selection; | |||
3859 | ||||
3860 | if (event->window != ctk_tree_view_get_bin_window (CTK_TREE_VIEW (window->priv->list_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_view)), ((ctk_tree_view_get_type ())))))))) | |||
3861 | return FALSE(0); | |||
3862 | ||||
3863 | selection = ctk_tree_view_get_selection (CTK_TREE_VIEW (window->priv->list_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_view)), ((ctk_tree_view_get_type ()))))))); | |||
3864 | if (selection == NULL((void*)0)) | |||
3865 | return FALSE(0); | |||
3866 | ||||
3867 | if (window->priv->path_clicked != NULL((void*)0)) { | |||
3868 | ctk_tree_path_free (window->priv->path_clicked); | |||
3869 | window->priv->path_clicked = NULL((void*)0); | |||
3870 | } | |||
3871 | ||||
3872 | if ((event->type == CDK_BUTTON_PRESS) && (event->button == 3)) { | |||
3873 | CtkTreePath *path; | |||
3874 | CtkTreeIter iter; | |||
3875 | int n_selected; | |||
3876 | ||||
3877 | if (ctk_tree_view_get_path_at_pos (CTK_TREE_VIEW (window->priv->list_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_view)), ((ctk_tree_view_get_type ())))))), | |||
3878 | event->x, event->y, | |||
3879 | &path, NULL((void*)0), NULL((void*)0), NULL((void*)0))) { | |||
3880 | ||||
3881 | if (! ctk_tree_model_get_iter (CTK_TREE_MODEL (window->priv->list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_store)), ((ctk_tree_model_get_type ())))))), &iter, path)) { | |||
3882 | ctk_tree_path_free (path); | |||
3883 | return FALSE(0); | |||
3884 | } | |||
3885 | ctk_tree_path_free (path); | |||
3886 | ||||
3887 | if (! ctk_tree_selection_iter_is_selected (selection, &iter)) { | |||
3888 | ctk_tree_selection_unselect_all (selection); | |||
3889 | ctk_tree_selection_select_iter (selection, &iter); | |||
3890 | } | |||
3891 | } | |||
3892 | else | |||
3893 | ctk_tree_selection_unselect_all (selection); | |||
3894 | ||||
3895 | n_selected = fr_window_get_n_selected_files (window); | |||
3896 | if ((n_selected == 1) && selection_has_a_dir (window)) | |||
3897 | ctk_menu_popup_at_pointer (CTK_MENU (window->priv->folder_popup_menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->folder_popup_menu)), ((ctk_menu_get_type ())))))), | |||
3898 | (const CdkEvent*) event); | |||
3899 | else | |||
3900 | ctk_menu_popup_at_pointer (CTK_MENU (window->priv->file_popup_menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->file_popup_menu)), ((ctk_menu_get_type ())))))), | |||
3901 | (const CdkEvent*) event); | |||
3902 | return TRUE(!(0)); | |||
3903 | } | |||
3904 | else if ((event->type == CDK_BUTTON_PRESS) && (event->button == 1)) { | |||
3905 | CtkTreePath *path = NULL((void*)0); | |||
3906 | ||||
3907 | if (! ctk_tree_view_get_path_at_pos (CTK_TREE_VIEW (window->priv->list_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_view)), ((ctk_tree_view_get_type ())))))), | |||
3908 | event->x, event->y, | |||
3909 | &path, NULL((void*)0), NULL((void*)0), NULL((void*)0))) { | |||
3910 | ctk_tree_selection_unselect_all (selection); | |||
3911 | } | |||
3912 | ||||
3913 | if (window->priv->path_clicked != NULL((void*)0)) { | |||
3914 | ctk_tree_path_free (window->priv->path_clicked); | |||
3915 | window->priv->path_clicked = NULL((void*)0); | |||
3916 | } | |||
3917 | ||||
3918 | if (path != NULL((void*)0)) { | |||
3919 | window->priv->path_clicked = ctk_tree_path_copy (path); | |||
3920 | ctk_tree_path_free (path); | |||
3921 | } | |||
3922 | ||||
3923 | return FALSE(0); | |||
3924 | } | |||
3925 | else if ((event->type == CDK_BUTTON_PRESS) && (event->button == 8)) { | |||
3926 | // go back | |||
3927 | fr_window_go_back (window); | |||
3928 | return TRUE(!(0)); | |||
3929 | } | |||
3930 | else if ((event->type == CDK_BUTTON_PRESS) && (event->button == 9)) { | |||
3931 | // go forward | |||
3932 | fr_window_go_forward (window); | |||
3933 | return TRUE(!(0)); | |||
3934 | } | |||
3935 | ||||
3936 | return FALSE(0); | |||
3937 | } | |||
3938 | ||||
3939 | ||||
3940 | static int | |||
3941 | file_button_release_cb (CtkWidget *widget, | |||
3942 | CdkEventButton *event, | |||
3943 | gpointer data) | |||
3944 | { | |||
3945 | FrWindow *window = data; | |||
3946 | CtkTreeSelection *selection; | |||
3947 | ||||
3948 | if (event->window != ctk_tree_view_get_bin_window (CTK_TREE_VIEW (window->priv->list_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_view)), ((ctk_tree_view_get_type ())))))))) | |||
3949 | return FALSE(0); | |||
3950 | ||||
3951 | selection = ctk_tree_view_get_selection (CTK_TREE_VIEW (window->priv->list_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_view)), ((ctk_tree_view_get_type ()))))))); | |||
3952 | if (selection == NULL((void*)0)) | |||
3953 | return FALSE(0); | |||
3954 | ||||
3955 | if (window->priv->path_clicked == NULL((void*)0)) | |||
3956 | return FALSE(0); | |||
3957 | ||||
3958 | if ((event->type == CDK_BUTTON_RELEASE) | |||
3959 | && (event->button == 1) | |||
3960 | && (window->priv->path_clicked != NULL((void*)0))) { | |||
3961 | CtkTreePath *path = NULL((void*)0); | |||
3962 | ||||
3963 | if (ctk_tree_view_get_path_at_pos (CTK_TREE_VIEW (window->priv->list_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_view)), ((ctk_tree_view_get_type ())))))), | |||
3964 | event->x, event->y, | |||
3965 | &path, NULL((void*)0), NULL((void*)0), NULL((void*)0))) { | |||
3966 | ||||
3967 | if ((ctk_tree_path_compare (window->priv->path_clicked, path) == 0) | |||
3968 | && window->priv->single_click | |||
3969 | && ! ((event->state & CDK_CONTROL_MASK) || (event->state & CDK_SHIFT_MASK))) { | |||
3970 | ctk_tree_view_set_cursor (CTK_TREE_VIEW (widget)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_tree_view_get_type ())))))), | |||
3971 | path, | |||
3972 | NULL((void*)0), | |||
3973 | FALSE(0)); | |||
3974 | ctk_tree_view_row_activated (CTK_TREE_VIEW (widget)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_tree_view_get_type ())))))), | |||
3975 | path, | |||
3976 | NULL((void*)0)); | |||
3977 | } | |||
3978 | } | |||
3979 | ||||
3980 | if (path != NULL((void*)0)) | |||
3981 | ctk_tree_path_free (path); | |||
3982 | } | |||
3983 | ||||
3984 | if (window->priv->path_clicked != NULL((void*)0)) { | |||
3985 | ctk_tree_path_free (window->priv->path_clicked); | |||
3986 | window->priv->path_clicked = NULL((void*)0); | |||
3987 | } | |||
3988 | ||||
3989 | return FALSE(0); | |||
3990 | } | |||
3991 | ||||
3992 | ||||
3993 | static gboolean | |||
3994 | file_motion_notify_callback (CtkWidget *widget, | |||
3995 | CdkEventMotion *event, | |||
3996 | gpointer user_data) | |||
3997 | { | |||
3998 | FrWindow *window = user_data; | |||
3999 | CdkCursor *cursor; | |||
4000 | CtkTreePath *last_hover_path; | |||
4001 | CdkDisplay *display; | |||
4002 | CtkTreeIter iter; | |||
4003 | ||||
4004 | if (! window->priv->single_click) | |||
4005 | return FALSE(0); | |||
4006 | ||||
4007 | if (event->window != ctk_tree_view_get_bin_window (CTK_TREE_VIEW (window->priv->list_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_view)), ((ctk_tree_view_get_type ())))))))) | |||
4008 | return FALSE(0); | |||
4009 | ||||
4010 | last_hover_path = window->priv->list_hover_path; | |||
4011 | ||||
4012 | ctk_tree_view_get_path_at_pos (CTK_TREE_VIEW (widget)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_tree_view_get_type ())))))), | |||
4013 | event->x, event->y, | |||
4014 | &window->priv->list_hover_path, | |||
4015 | NULL((void*)0), NULL((void*)0), NULL((void*)0)); | |||
4016 | ||||
4017 | display = ctk_widget_get_display (CTK_WIDGET (widget)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_widget_get_type ()))))))); | |||
4018 | ||||
4019 | if (window->priv->list_hover_path != NULL((void*)0)) | |||
4020 | cursor = cdk_cursor_new_for_display (display, CDK_HAND2); | |||
4021 | else | |||
4022 | cursor = NULL((void*)0); | |||
4023 | ||||
4024 | cdk_window_set_cursor (event->window, cursor); | |||
4025 | ||||
4026 | /* only redraw if the hover row has changed */ | |||
4027 | if (!(last_hover_path == NULL((void*)0) && window->priv->list_hover_path == NULL((void*)0)) && | |||
4028 | (!(last_hover_path != NULL((void*)0) && window->priv->list_hover_path != NULL((void*)0)) || | |||
4029 | ctk_tree_path_compare (last_hover_path, window->priv->list_hover_path))) | |||
4030 | { | |||
4031 | if (last_hover_path) { | |||
4032 | ctk_tree_model_get_iter (CTK_TREE_MODEL (window->priv->list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_store)), ((ctk_tree_model_get_type ())))))), | |||
4033 | &iter, last_hover_path); | |||
4034 | ctk_tree_model_row_changed (CTK_TREE_MODEL (window->priv->list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_store)), ((ctk_tree_model_get_type ())))))), | |||
4035 | last_hover_path, &iter); | |||
4036 | } | |||
4037 | ||||
4038 | if (window->priv->list_hover_path) { | |||
4039 | ctk_tree_model_get_iter (CTK_TREE_MODEL (window->priv->list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_store)), ((ctk_tree_model_get_type ())))))), | |||
4040 | &iter, window->priv->list_hover_path); | |||
4041 | ctk_tree_model_row_changed (CTK_TREE_MODEL (window->priv->list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_store)), ((ctk_tree_model_get_type ())))))), | |||
4042 | window->priv->list_hover_path, &iter); | |||
4043 | } | |||
4044 | } | |||
4045 | ||||
4046 | ctk_tree_path_free (last_hover_path); | |||
4047 | ||||
4048 | return FALSE(0); | |||
4049 | } | |||
4050 | ||||
4051 | ||||
4052 | static gboolean | |||
4053 | file_leave_notify_callback (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
4054 | CdkEventCrossing *event G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
4055 | gpointer user_data) | |||
4056 | { | |||
4057 | FrWindow *window = user_data; | |||
4058 | CtkTreeIter iter; | |||
4059 | ||||
4060 | if (window->priv->single_click && (window->priv->list_hover_path != NULL((void*)0))) { | |||
4061 | ctk_tree_model_get_iter (CTK_TREE_MODEL (window->priv->list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_store)), ((ctk_tree_model_get_type ())))))), | |||
4062 | &iter, | |||
4063 | window->priv->list_hover_path); | |||
4064 | ctk_tree_model_row_changed (CTK_TREE_MODEL (window->priv->list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_store)), ((ctk_tree_model_get_type ())))))), | |||
4065 | window->priv->list_hover_path, | |||
4066 | &iter); | |||
4067 | ||||
4068 | ctk_tree_path_free (window->priv->list_hover_path); | |||
4069 | window->priv->list_hover_path = NULL((void*)0); | |||
4070 | } | |||
4071 | ||||
4072 | return FALSE(0); | |||
4073 | } | |||
4074 | ||||
4075 | ||||
4076 | /* -- drag and drop -- */ | |||
4077 | ||||
4078 | ||||
4079 | static GList * | |||
4080 | get_uri_list_from_selection_data (char *uri_list) | |||
4081 | { | |||
4082 | GList *list = NULL((void*)0); | |||
4083 | char **uris; | |||
4084 | int i; | |||
4085 | ||||
4086 | if (uri_list == NULL((void*)0)) | |||
4087 | return NULL((void*)0); | |||
4088 | ||||
4089 | uris = g_uri_list_extract_uris (uri_list); | |||
4090 | for (i = 0; uris[i] != NULL((void*)0); i++) | |||
4091 | list = g_list_prepend (list, g_strdup (uris[i])g_strdup_inline (uris[i])); | |||
4092 | g_strfreev (uris); | |||
4093 | ||||
4094 | return g_list_reverse (list); | |||
4095 | } | |||
4096 | ||||
4097 | ||||
4098 | static gboolean | |||
4099 | fr_window_drag_motion (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
4100 | CdkDragContext *context, | |||
4101 | gint x G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
4102 | gint y G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
4103 | guint time, | |||
4104 | gpointer user_data) | |||
4105 | { | |||
4106 | FrWindow *window = user_data; | |||
4107 | ||||
4108 | if ((ctk_drag_get_source_widget (context) == window->priv->list_view) | |||
4109 | || (ctk_drag_get_source_widget (context) == window->priv->tree_view)) | |||
4110 | { | |||
4111 | cdk_drag_status (context, 0, time); | |||
4112 | return FALSE(0); | |||
4113 | } | |||
4114 | ||||
4115 | return TRUE(!(0)); | |||
4116 | } | |||
4117 | ||||
4118 | ||||
4119 | static void fr_window_paste_from_clipboard_data (FrWindow *window, FrClipboardData *data); | |||
4120 | ||||
4121 | ||||
4122 | static FrClipboardData* | |||
4123 | get_clipboard_data_from_selection_data (FrWindow *window, | |||
4124 | const char *data) | |||
4125 | { | |||
4126 | FrClipboardData *clipboard_data; | |||
4127 | char **uris; | |||
4128 | int i; | |||
4129 | ||||
4130 | clipboard_data = fr_clipboard_data_new (); | |||
4131 | ||||
4132 | uris = g_strsplit (data, "\r\n", -1); | |||
4133 | ||||
4134 | clipboard_data->archive_filename = g_strdup (uris[0])g_strdup_inline (uris[0]); | |||
4135 | if (window->priv->password_for_paste != NULL((void*)0)) | |||
4136 | clipboard_data->archive_password = g_strdup (window->priv->password_for_paste)g_strdup_inline (window->priv->password_for_paste); | |||
4137 | else if (strcmp (uris[1], "") != 0) | |||
4138 | clipboard_data->archive_password = g_strdup (uris[1])g_strdup_inline (uris[1]); | |||
4139 | clipboard_data->op = (strcmp (uris[2], "copy") == 0) ? FR_CLIPBOARD_OP_COPY : FR_CLIPBOARD_OP_CUT; | |||
4140 | clipboard_data->base_dir = g_strdup (uris[3])g_strdup_inline (uris[3]); | |||
4141 | for (i = 4; uris[i] != NULL((void*)0); i++) | |||
4142 | if (uris[i][0] != '\0') | |||
4143 | clipboard_data->files = g_list_prepend (clipboard_data->files, g_strdup (uris[i])g_strdup_inline (uris[i])); | |||
4144 | clipboard_data->files = g_list_reverse (clipboard_data->files); | |||
4145 | ||||
4146 | g_strfreev (uris); | |||
4147 | ||||
4148 | return clipboard_data; | |||
4149 | } | |||
4150 | ||||
4151 | ||||
4152 | static void | |||
4153 | fr_window_drag_data_received (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
4154 | CdkDragContext *context, | |||
4155 | gint x G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
4156 | gint y G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
4157 | CtkSelectionData *data, | |||
4158 | guint info G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
4159 | guint time, | |||
4160 | gpointer extra_data) | |||
4161 | { | |||
4162 | FrWindow *window = extra_data; | |||
4163 | GList *list; | |||
4164 | gboolean one_file; | |||
4165 | gboolean is_an_archive; | |||
4166 | ||||
4167 | debug (DEBUG_INFO"fr-window.c", 4167, __FUNCTION__, "::DragDataReceived -->\n"); | |||
4168 | ||||
4169 | if ((ctk_drag_get_source_widget (context) == window->priv->list_view) | |||
4170 | || (ctk_drag_get_source_widget (context) == window->priv->tree_view)) | |||
4171 | { | |||
4172 | ctk_drag_finish (context, FALSE(0), FALSE(0), time); | |||
4173 | return; | |||
4174 | } | |||
4175 | ||||
4176 | if (! ((ctk_selection_data_get_length (data) >= 0) && (ctk_selection_data_get_format (data) == 8))) { | |||
4177 | ctk_drag_finish (context, FALSE(0), FALSE(0), time); | |||
4178 | return; | |||
4179 | } | |||
4180 | ||||
4181 | if (window->priv->activity_ref > 0) { | |||
4182 | ctk_drag_finish (context, FALSE(0), FALSE(0), time); | |||
4183 | return; | |||
4184 | } | |||
4185 | ||||
4186 | ctk_drag_finish (context, TRUE(!(0)), FALSE(0), time); | |||
4187 | ||||
4188 | if (ctk_selection_data_get_target (data) == XFR_ATOMcdk_atom_intern ("XdndGrapa0", (0))) { | |||
4189 | FrClipboardData *dnd_data; | |||
4190 | ||||
4191 | dnd_data = get_clipboard_data_from_selection_data (window, (char*) ctk_selection_data_get_data (data)); | |||
4192 | dnd_data->current_dir = g_strdup (fr_window_get_current_location (window))g_strdup_inline (fr_window_get_current_location (window)); | |||
4193 | fr_window_paste_from_clipboard_data (window, dnd_data); | |||
4194 | ||||
4195 | return; | |||
4196 | } | |||
4197 | ||||
4198 | list = get_uri_list_from_selection_data ((char*) ctk_selection_data_get_data (data)); | |||
4199 | if (list == NULL((void*)0)) { | |||
4200 | CtkWidget *d; | |||
4201 | ||||
4202 | d = _ctk_error_dialog_new (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), | |||
4203 | CTK_DIALOG_MODAL, | |||
4204 | NULL((void*)0), | |||
4205 | _("Could not perform the operation")gettext ("Could not perform the operation"), | |||
4206 | NULL((void*)0)); | |||
4207 | ctk_dialog_run (CTK_DIALOG (d)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((d)), ((ctk_dialog_get_type ()))))))); | |||
4208 | ctk_widget_destroy(d); | |||
4209 | ||||
4210 | return; | |||
4211 | } | |||
4212 | ||||
4213 | one_file = (list->next == NULL((void*)0)); | |||
4214 | if (one_file) | |||
4215 | is_an_archive = uri_is_archive (list->data); | |||
4216 | else | |||
4217 | is_an_archive = FALSE(0); | |||
4218 | ||||
4219 | if (window->priv->archive_present | |||
4220 | && (window->archive != NULL((void*)0)) | |||
4221 | && ! window->archive->read_only | |||
4222 | && ! window->archive->is_compressed_file) | |||
4223 | { | |||
4224 | if (one_file && is_an_archive) { | |||
4225 | CtkWidget *d; | |||
4226 | gint r; | |||
4227 | ||||
4228 | d = _ctk_message_dialog_new (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), | |||
4229 | CTK_DIALOG_MODAL, | |||
4230 | "dialog-question", | |||
4231 | _("Do you want to add this file to the current archive or open it as a new archive?")gettext ("Do you want to add this file to the current archive or open it as a new archive?" ), | |||
4232 | NULL((void*)0), | |||
4233 | CTK_STOCK_CANCEL((CtkStock)"ctk-cancel"), CTK_RESPONSE_CANCEL, | |||
4234 | CTK_STOCK_ADD((CtkStock)"ctk-add"), 0, | |||
4235 | CTK_STOCK_OPEN((CtkStock)"ctk-open"), 1, | |||
4236 | NULL((void*)0)); | |||
4237 | ||||
4238 | ctk_dialog_set_default_response (CTK_DIALOG (d)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((d)), ((ctk_dialog_get_type ())))))), 2); | |||
4239 | ||||
4240 | r = ctk_dialog_run (CTK_DIALOG (d)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((d)), ((ctk_dialog_get_type ()))))))); | |||
4241 | ctk_widget_destroy (CTK_WIDGET (d)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((d)), ((ctk_widget_get_type ()))))))); | |||
4242 | ||||
4243 | if (r == 0) /* Add */ | |||
4244 | fr_window_archive_add_dropped_items (window, list, FALSE(0)); | |||
4245 | else if (r == 1) /* Open */ | |||
4246 | fr_window_archive_open (window, list->data, CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ()))))))); | |||
4247 | } | |||
4248 | else | |||
4249 | fr_window_archive_add_dropped_items (window, list, FALSE(0)); | |||
4250 | } | |||
4251 | else { | |||
4252 | if (one_file && is_an_archive) | |||
4253 | fr_window_archive_open (window, list->data, CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ()))))))); | |||
4254 | else { | |||
4255 | CtkWidget *d; | |||
4256 | int r; | |||
4257 | ||||
4258 | d = _ctk_message_dialog_new (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), | |||
4259 | CTK_DIALOG_MODAL, | |||
4260 | "dialog-question", | |||
4261 | _("Do you want to create a new archive with these files?")gettext ("Do you want to create a new archive with these files?" ), | |||
4262 | NULL((void*)0), | |||
4263 | CTK_STOCK_CANCEL((CtkStock)"ctk-cancel"), CTK_RESPONSE_CANCEL, | |||
4264 | _("Create _Archive")gettext ("Create _Archive"), CTK_RESPONSE_YES, | |||
4265 | NULL((void*)0)); | |||
4266 | ||||
4267 | ctk_dialog_set_default_response (CTK_DIALOG (d)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((d)), ((ctk_dialog_get_type ())))))), CTK_RESPONSE_YES); | |||
4268 | r = ctk_dialog_run (CTK_DIALOG (d)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((d)), ((ctk_dialog_get_type ()))))))); | |||
4269 | ctk_widget_destroy (CTK_WIDGET (d)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((d)), ((ctk_widget_get_type ()))))))); | |||
4270 | ||||
4271 | if (r == CTK_RESPONSE_YES) { | |||
4272 | char *first_item; | |||
4273 | char *folder; | |||
4274 | char *local_path = NULL((void*)0); | |||
4275 | char *utf8_path = NULL((void*)0); | |||
4276 | const char *archive_name; | |||
4277 | ||||
4278 | fr_window_free_batch_data (window); | |||
4279 | fr_window_append_batch_action (window, | |||
4280 | FR_BATCH_ACTION_ADD, | |||
4281 | path_list_dup (list), | |||
4282 | (GFreeFunc) path_list_free); | |||
4283 | ||||
4284 | first_item = (char*) list->data; | |||
4285 | folder = remove_level_from_path (first_item); | |||
4286 | if (folder != NULL((void*)0)) | |||
4287 | fr_window_set_open_default_dir (window, folder); | |||
4288 | ||||
4289 | if ((list->next != NULL((void*)0)) && (folder != NULL((void*)0))) { | |||
4290 | archive_name = file_name_from_path (folder); | |||
4291 | } | |||
4292 | else { | |||
4293 | if (uri_is_local (first_item)) { | |||
4294 | local_path = g_filename_from_uri (first_item, NULL((void*)0), NULL((void*)0)); | |||
4295 | if (local_path) | |||
4296 | utf8_path = g_filename_to_utf8 (local_path, -1, NULL((void*)0), NULL((void*)0), NULL((void*)0)); | |||
4297 | if (!utf8_path) | |||
4298 | utf8_path= g_strdup (first_item)g_strdup_inline (first_item); | |||
4299 | g_free (local_path); | |||
4300 | } | |||
4301 | else { | |||
4302 | utf8_path = g_strdup (first_item)g_strdup_inline (first_item); | |||
4303 | } | |||
4304 | archive_name = file_name_from_path (utf8_path); | |||
4305 | } | |||
4306 | ||||
4307 | show_new_archive_dialog (window, archive_name); | |||
4308 | g_free (utf8_path); | |||
4309 | ||||
4310 | g_free (folder); | |||
4311 | } | |||
4312 | } | |||
4313 | } | |||
4314 | ||||
4315 | path_list_free (list); | |||
4316 | ||||
4317 | debug (DEBUG_INFO"fr-window.c", 4317, __FUNCTION__, "::DragDataReceived <--\n"); | |||
4318 | } | |||
4319 | ||||
4320 | ||||
4321 | static gboolean | |||
4322 | file_list_drag_begin (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
4323 | CdkDragContext *context, | |||
4324 | gpointer data) | |||
4325 | { | |||
4326 | FrWindow *window = data; | |||
4327 | ||||
4328 | debug (DEBUG_INFO"fr-window.c", 4328, __FUNCTION__, "::DragBegin -->\n"); | |||
4329 | ||||
4330 | if (window->priv->activity_ref > 0) | |||
4331 | return FALSE(0); | |||
4332 | ||||
4333 | g_free (window->priv->drag_destination_folder); | |||
4334 | window->priv->drag_destination_folder = NULL((void*)0); | |||
4335 | ||||
4336 | g_free (window->priv->drag_base_dir); | |||
4337 | window->priv->drag_base_dir = NULL((void*)0); | |||
4338 | ||||
4339 | cdk_property_change (cdk_drag_context_get_source_window (context), | |||
4340 | XDS_ATOMcdk_atom_intern ("XdndDirectSave0", (0)), TEXT_ATOMcdk_atom_intern ("text/plain", (0)), | |||
4341 | 8, CDK_PROP_MODE_REPLACE, | |||
4342 | (guchar *) XDS_FILENAME"xds.txt", | |||
4343 | strlen (XDS_FILENAME"xds.txt")); | |||
4344 | ||||
4345 | return TRUE(!(0)); | |||
4346 | } | |||
4347 | ||||
4348 | ||||
4349 | static void | |||
4350 | file_list_drag_end (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
4351 | CdkDragContext *context, | |||
4352 | gpointer data) | |||
4353 | { | |||
4354 | FrWindow *window = data; | |||
4355 | ||||
4356 | debug (DEBUG_INFO"fr-window.c", 4356, __FUNCTION__, "::DragEnd -->\n"); | |||
4357 | ||||
4358 | cdk_property_delete (cdk_drag_context_get_source_window (context), XDS_ATOMcdk_atom_intern ("XdndDirectSave0", (0))); | |||
4359 | ||||
4360 | if (window->priv->drag_error != NULL((void*)0)) { | |||
4361 | _ctk_error_dialog_run (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), | |||
4362 | _("Extraction not performed")gettext ("Extraction not performed"), | |||
4363 | "%s", | |||
4364 | window->priv->drag_error->message); | |||
4365 | g_clear_error (&window->priv->drag_error); | |||
4366 | } | |||
4367 | else if (window->priv->drag_destination_folder != NULL((void*)0)) { | |||
4368 | fr_window_archive_extract (window, | |||
4369 | window->priv->drag_file_list, | |||
4370 | window->priv->drag_destination_folder, | |||
4371 | window->priv->drag_base_dir, | |||
4372 | FALSE(0), | |||
4373 | FR_OVERWRITE_ASK, | |||
4374 | FALSE(0), | |||
4375 | FALSE(0)); | |||
4376 | path_list_free (window->priv->drag_file_list); | |||
4377 | window->priv->drag_file_list = NULL((void*)0); | |||
4378 | } | |||
4379 | ||||
4380 | debug (DEBUG_INFO"fr-window.c", 4380, __FUNCTION__, "::DragEnd <--\n"); | |||
4381 | } | |||
4382 | ||||
4383 | ||||
4384 | /* The following three functions taken from bugzilla | |||
4385 | * (http://bugzilla.cafe.org/attachment.cgi?id=49362&action=view) | |||
4386 | * Author: Christian Neumair | |||
4387 | * Copyright: 2005 Free Software Foundation, Inc | |||
4388 | * License: GPL */ | |||
4389 | static char * | |||
4390 | get_xds_atom_value (CdkDragContext *context) | |||
4391 | { | |||
4392 | gint actual_length; | |||
4393 | char *data; | |||
4394 | char *ret; | |||
4395 | ||||
4396 | g_return_val_if_fail (context != NULL, NULL)do { if ((context != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "context != NULL" ); return (((void*)0)); } } while (0); | |||
4397 | g_return_val_if_fail (cdk_drag_context_get_source_window (context) != NULL, NULL)do { if ((cdk_drag_context_get_source_window (context) != ((void *)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "cdk_drag_context_get_source_window (context) != NULL" ); return (((void*)0)); } } while (0); | |||
4398 | ||||
4399 | if (cdk_property_get (cdk_drag_context_get_source_window (context), | |||
4400 | XDS_ATOMcdk_atom_intern ("XdndDirectSave0", (0)), TEXT_ATOMcdk_atom_intern ("text/plain", (0)), | |||
4401 | 0, MAX_XDS_ATOM_VAL_LEN4096, | |||
4402 | FALSE(0), NULL((void*)0), NULL((void*)0), &actual_length, | |||
4403 | (unsigned char **) &data)) { | |||
4404 | /* add not included \0 to the end of the string */ | |||
4405 | ret = g_strndup ((gchar *) data, actual_length); | |||
4406 | g_free (data); | |||
4407 | return ret; | |||
4408 | } | |||
4409 | ||||
4410 | return NULL((void*)0); | |||
4411 | } | |||
4412 | ||||
4413 | ||||
4414 | static gboolean | |||
4415 | context_offers_target (CdkDragContext *context, | |||
4416 | CdkAtom target) | |||
4417 | { | |||
4418 | return (g_list_find (cdk_drag_context_list_targets (context), target) != NULL((void*)0)); | |||
4419 | } | |||
4420 | ||||
4421 | ||||
4422 | static gboolean | |||
4423 | baul_xds_dnd_is_valid_xds_context (CdkDragContext *context) | |||
4424 | { | |||
4425 | char *tmp; | |||
4426 | gboolean ret; | |||
4427 | ||||
4428 | g_return_val_if_fail (context != NULL, FALSE)do { if ((context != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "context != NULL" ); return ((0)); } } while (0); | |||
4429 | ||||
4430 | tmp = NULL((void*)0); | |||
4431 | if (context_offers_target (context, XDS_ATOMcdk_atom_intern ("XdndDirectSave0", (0)))) { | |||
4432 | tmp = get_xds_atom_value (context); | |||
4433 | } | |||
4434 | ||||
4435 | ret = (tmp != NULL((void*)0)); | |||
4436 | g_free (tmp); | |||
4437 | ||||
4438 | return ret; | |||
4439 | } | |||
4440 | ||||
4441 | ||||
4442 | static char * | |||
4443 | get_selection_data_from_clipboard_data (FrWindow *window, | |||
4444 | FrClipboardData *data) | |||
4445 | { | |||
4446 | GString *list; | |||
4447 | char *local_filename; | |||
4448 | GList *scan; | |||
4449 | ||||
4450 | list = g_string_new (NULL((void*)0)); | |||
4451 | ||||
4452 | local_filename = g_file_get_uri (window->archive->local_copy); | |||
4453 | g_string_append (list, local_filename)(__builtin_constant_p (local_filename) ? __extension__ ({ const char * const __val = (local_filename); g_string_append_len_inline (list, __val, (__val != ((void*)0)) ? (gssize) strlen (((__val ) + !(__val))) : (gssize) -1); }) : g_string_append_len_inline (list, local_filename, (gssize) -1)); | |||
4454 | g_free (local_filename); | |||
4455 | ||||
4456 | g_string_append (list, "\r\n")(__builtin_constant_p ("\r\n") ? __extension__ ({ const char * const __val = ("\r\n"); g_string_append_len_inline (list, __val , (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val ))) : (gssize) -1); }) : g_string_append_len_inline (list, "\r\n" , (gssize) -1)); | |||
4457 | if (window->priv->password != NULL((void*)0)) | |||
4458 | g_string_append (list, window->priv->password)(__builtin_constant_p (window->priv->password) ? __extension__ ({ const char * const __val = (window->priv->password) ; g_string_append_len_inline (list, __val, (__val != ((void*) 0)) ? (gssize) strlen (((__val) + !(__val))) : (gssize) -1); } ) : g_string_append_len_inline (list, window->priv->password , (gssize) -1)); | |||
4459 | g_string_append (list, "\r\n")(__builtin_constant_p ("\r\n") ? __extension__ ({ const char * const __val = ("\r\n"); g_string_append_len_inline (list, __val , (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val ))) : (gssize) -1); }) : g_string_append_len_inline (list, "\r\n" , (gssize) -1)); | |||
4460 | g_string_append (list, (data->op == FR_CLIPBOARD_OP_COPY) ? "copy" : "cut")(__builtin_constant_p ((data->op == FR_CLIPBOARD_OP_COPY) ? "copy" : "cut") ? __extension__ ({ const char * const __val = ((data->op == FR_CLIPBOARD_OP_COPY) ? "copy" : "cut"); g_string_append_len_inline (list, __val, (__val != ((void*)0)) ? (gssize) strlen (((__val ) + !(__val))) : (gssize) -1); }) : g_string_append_len_inline (list, (data->op == FR_CLIPBOARD_OP_COPY) ? "copy" : "cut" , (gssize) -1)); | |||
4461 | g_string_append (list, "\r\n")(__builtin_constant_p ("\r\n") ? __extension__ ({ const char * const __val = ("\r\n"); g_string_append_len_inline (list, __val , (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val ))) : (gssize) -1); }) : g_string_append_len_inline (list, "\r\n" , (gssize) -1)); | |||
4462 | g_string_append (list, data->base_dir)(__builtin_constant_p (data->base_dir) ? __extension__ ({ const char * const __val = (data->base_dir); g_string_append_len_inline (list, __val, (__val != ((void*)0)) ? (gssize) strlen (((__val ) + !(__val))) : (gssize) -1); }) : g_string_append_len_inline (list, data->base_dir, (gssize) -1)); | |||
4463 | g_string_append (list, "\r\n")(__builtin_constant_p ("\r\n") ? __extension__ ({ const char * const __val = ("\r\n"); g_string_append_len_inline (list, __val , (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val ))) : (gssize) -1); }) : g_string_append_len_inline (list, "\r\n" , (gssize) -1)); | |||
4464 | for (scan = data->files; scan; scan = scan->next) { | |||
4465 | g_string_append (list, scan->data)(__builtin_constant_p (scan->data) ? __extension__ ({ const char * const __val = (scan->data); g_string_append_len_inline (list, __val, (__val != ((void*)0)) ? (gssize) strlen (((__val ) + !(__val))) : (gssize) -1); }) : g_string_append_len_inline (list, scan->data, (gssize) -1)); | |||
4466 | g_string_append (list, "\r\n")(__builtin_constant_p ("\r\n") ? __extension__ ({ const char * const __val = ("\r\n"); g_string_append_len_inline (list, __val , (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val ))) : (gssize) -1); }) : g_string_append_len_inline (list, "\r\n" , (gssize) -1)); | |||
4467 | } | |||
4468 | ||||
4469 | return g_string_free (list, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((list ), ((0))) : g_string_free_and_steal (list)) : (g_string_free) ((list), ((0)))); | |||
4470 | } | |||
4471 | ||||
4472 | ||||
4473 | static gboolean | |||
4474 | fr_window_folder_tree_drag_data_get (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
4475 | CdkDragContext *context, | |||
4476 | CtkSelectionData *selection_data, | |||
4477 | guint info G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
4478 | guint time G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
4479 | gpointer user_data) | |||
4480 | { | |||
4481 | FrWindow *window = user_data; | |||
4482 | GList *file_list; | |||
4483 | char *destination; | |||
4484 | char *destination_folder; | |||
4485 | ||||
4486 | debug (DEBUG_INFO"fr-window.c", 4486, __FUNCTION__, "::DragDataGet -->\n"); | |||
4487 | ||||
4488 | if (window->priv->activity_ref > 0) | |||
4489 | return FALSE(0); | |||
4490 | ||||
4491 | file_list = fr_window_get_folder_tree_selection (window, TRUE(!(0)), NULL((void*)0)); | |||
4492 | if (file_list == NULL((void*)0)) | |||
4493 | return FALSE(0); | |||
4494 | ||||
4495 | if (ctk_selection_data_get_target (selection_data) == XFR_ATOMcdk_atom_intern ("XdndGrapa0", (0))) { | |||
4496 | FrClipboardData *tmp; | |||
4497 | char *data; | |||
4498 | ||||
4499 | tmp = fr_clipboard_data_new (); | |||
4500 | tmp->files = file_list; | |||
4501 | tmp->op = FR_CLIPBOARD_OP_COPY; | |||
4502 | tmp->base_dir = g_strdup (fr_window_get_current_location (window))g_strdup_inline (fr_window_get_current_location (window)); | |||
4503 | ||||
4504 | data = get_selection_data_from_clipboard_data (window, tmp); | |||
4505 | ctk_selection_data_set (selection_data, XFR_ATOMcdk_atom_intern ("XdndGrapa0", (0)), 8, (guchar *) data, strlen (data)); | |||
4506 | ||||
4507 | fr_clipboard_data_unref (tmp); | |||
4508 | g_free (data); | |||
4509 | ||||
4510 | return TRUE(!(0)); | |||
4511 | } | |||
4512 | ||||
4513 | if (! baul_xds_dnd_is_valid_xds_context (context)) | |||
4514 | return FALSE(0); | |||
4515 | ||||
4516 | destination = get_xds_atom_value (context); | |||
4517 | g_return_val_if_fail (destination != NULL, FALSE)do { if ((destination != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "destination != NULL" ); return ((0)); } } while (0); | |||
4518 | ||||
4519 | destination_folder = remove_level_from_path (destination); | |||
4520 | g_free (destination); | |||
4521 | ||||
4522 | /* check whether the extraction can be performed in the destination | |||
4523 | * folder */ | |||
4524 | ||||
4525 | g_clear_error (&window->priv->drag_error); | |||
4526 | ||||
4527 | if (! check_permissions (destination_folder, R_OK4 | W_OK2)) { | |||
4528 | char *destination_folder_display_name; | |||
4529 | ||||
4530 | destination_folder_display_name = g_filename_display_name (destination_folder); | |||
4531 | window->priv->drag_error = g_error_new (FR_ERRORfr_error_quark (), 0, _("You don't have the right permissions to extract archives in the folder \"%s\"")gettext ("You don't have the right permissions to extract archives in the folder \"%s\"" ), destination_folder_display_name); | |||
4532 | g_free (destination_folder_display_name); | |||
4533 | } | |||
4534 | ||||
4535 | if (window->priv->drag_error == NULL((void*)0)) { | |||
4536 | g_free (window->priv->drag_destination_folder); | |||
4537 | g_free (window->priv->drag_base_dir); | |||
4538 | path_list_free (window->priv->drag_file_list); | |||
4539 | window->priv->drag_destination_folder = g_strdup (destination_folder)g_strdup_inline (destination_folder); | |||
4540 | window->priv->drag_base_dir = fr_window_get_selected_folder_in_tree_view (window); | |||
4541 | window->priv->drag_file_list = file_list; | |||
4542 | } | |||
4543 | ||||
4544 | g_free (destination_folder); | |||
4545 | ||||
4546 | /* sends back the response */ | |||
4547 | ||||
4548 | ctk_selection_data_set (selection_data, ctk_selection_data_get_target (selection_data), 8, (guchar *) ((window->priv->drag_error == NULL((void*)0)) ? "S" : "E"), 1); | |||
4549 | ||||
4550 | debug (DEBUG_INFO"fr-window.c", 4550, __FUNCTION__, "::DragDataGet <--\n"); | |||
4551 | ||||
4552 | return TRUE(!(0)); | |||
4553 | } | |||
4554 | ||||
4555 | ||||
4556 | gboolean | |||
4557 | fr_window_file_list_drag_data_get (FrWindow *window, | |||
4558 | CdkDragContext *context, | |||
4559 | CtkSelectionData *selection_data, | |||
4560 | GList *path_list) | |||
4561 | { | |||
4562 | char *destination; | |||
4563 | char *destination_folder; | |||
4564 | ||||
4565 | debug (DEBUG_INFO"fr-window.c", 4565, __FUNCTION__, "::DragDataGet -->\n"); | |||
4566 | ||||
4567 | if (window->priv->path_clicked != NULL((void*)0)) { | |||
4568 | ctk_tree_path_free (window->priv->path_clicked); | |||
4569 | window->priv->path_clicked = NULL((void*)0); | |||
4570 | } | |||
4571 | ||||
4572 | if (window->priv->activity_ref > 0) | |||
4573 | return FALSE(0); | |||
4574 | ||||
4575 | if (ctk_selection_data_get_target (selection_data) == XFR_ATOMcdk_atom_intern ("XdndGrapa0", (0))) { | |||
4576 | FrClipboardData *tmp; | |||
4577 | char *data; | |||
4578 | ||||
4579 | tmp = fr_clipboard_data_new (); | |||
4580 | tmp->files = fr_window_get_file_list_selection (window, TRUE(!(0)), NULL((void*)0)); | |||
4581 | tmp->op = FR_CLIPBOARD_OP_COPY; | |||
4582 | tmp->base_dir = g_strdup (fr_window_get_current_location (window))g_strdup_inline (fr_window_get_current_location (window)); | |||
4583 | ||||
4584 | data = get_selection_data_from_clipboard_data (window, tmp); | |||
4585 | ctk_selection_data_set (selection_data, XFR_ATOMcdk_atom_intern ("XdndGrapa0", (0)), 8, (guchar *) data, strlen (data)); | |||
4586 | ||||
4587 | fr_clipboard_data_unref (tmp); | |||
4588 | g_free (data); | |||
4589 | ||||
4590 | return TRUE(!(0)); | |||
4591 | } | |||
4592 | ||||
4593 | if (! baul_xds_dnd_is_valid_xds_context (context)) | |||
4594 | return FALSE(0); | |||
4595 | ||||
4596 | destination = get_xds_atom_value (context); | |||
4597 | g_return_val_if_fail (destination != NULL, FALSE)do { if ((destination != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "destination != NULL" ); return ((0)); } } while (0); | |||
4598 | ||||
4599 | destination_folder = remove_level_from_path (destination); | |||
4600 | g_free (destination); | |||
4601 | ||||
4602 | /* check whether the extraction can be performed in the destination | |||
4603 | * folder */ | |||
4604 | ||||
4605 | g_clear_error (&window->priv->drag_error); | |||
4606 | ||||
4607 | if (! check_permissions (destination_folder, R_OK4 | W_OK2)) { | |||
4608 | char *destination_folder_display_name; | |||
4609 | ||||
4610 | destination_folder_display_name = g_filename_display_name (destination_folder); | |||
4611 | window->priv->drag_error = g_error_new (FR_ERRORfr_error_quark (), 0, _("You don't have the right permissions to extract archives in the folder \"%s\"")gettext ("You don't have the right permissions to extract archives in the folder \"%s\"" ), destination_folder_display_name); | |||
4612 | g_free (destination_folder_display_name); | |||
4613 | } | |||
4614 | ||||
4615 | if (window->priv->drag_error == NULL((void*)0)) { | |||
4616 | g_free (window->priv->drag_destination_folder); | |||
4617 | g_free (window->priv->drag_base_dir); | |||
4618 | path_list_free (window->priv->drag_file_list); | |||
4619 | window->priv->drag_destination_folder = g_strdup (destination_folder)g_strdup_inline (destination_folder); | |||
4620 | window->priv->drag_base_dir = g_strdup (fr_window_get_current_location (window))g_strdup_inline (fr_window_get_current_location (window)); | |||
4621 | window->priv->drag_file_list = fr_window_get_file_list_from_path_list (window, path_list, NULL((void*)0)); | |||
4622 | } | |||
4623 | ||||
4624 | g_free (destination_folder); | |||
4625 | ||||
4626 | /* sends back the response */ | |||
4627 | ||||
4628 | ctk_selection_data_set (selection_data, ctk_selection_data_get_target (selection_data), 8, (guchar *) ((window->priv->drag_error == NULL((void*)0)) ? "S" : "E"), 1); | |||
4629 | ||||
4630 | debug (DEBUG_INFO"fr-window.c", 4630, __FUNCTION__, "::DragDataGet <--\n"); | |||
4631 | ||||
4632 | return TRUE(!(0)); | |||
4633 | } | |||
4634 | ||||
4635 | ||||
4636 | /* -- window_new -- */ | |||
4637 | ||||
4638 | ||||
4639 | static void | |||
4640 | fr_window_deactivate_filter (FrWindow *window) | |||
4641 | { | |||
4642 | window->priv->filter_mode = FALSE(0); | |||
4643 | window->priv->list_mode = window->priv->last_list_mode; | |||
4644 | ||||
4645 | ctk_entry_set_text (CTK_ENTRY (window->priv->filter_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->filter_entry)), ((ctk_entry_get_type ())))))), ""); | |||
4646 | fr_window_update_filter_bar_visibility (window); | |||
4647 | ||||
4648 | ctk_list_store_clear (window->priv->list_store); | |||
4649 | ||||
4650 | fr_window_update_columns_visibility (window); | |||
4651 | fr_window_update_file_list (window, TRUE(!(0))); | |||
4652 | fr_window_update_dir_tree (window); | |||
4653 | fr_window_update_current_location (window); | |||
4654 | } | |||
4655 | ||||
4656 | ||||
4657 | static gboolean | |||
4658 | key_press_cb (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
4659 | CdkEventKey *event, | |||
4660 | gpointer data) | |||
4661 | { | |||
4662 | FrWindow *window = data; | |||
4663 | gboolean retval = FALSE(0); | |||
4664 | gboolean alt; | |||
4665 | ||||
4666 | if (ctk_widget_has_focus (window->priv->location_entry)) | |||
4667 | return FALSE(0); | |||
4668 | ||||
4669 | if (ctk_widget_has_focus (window->priv->filter_entry)) { | |||
4670 | switch (event->keyval) { | |||
4671 | case CDK_KEY_Escape0xff1b: | |||
4672 | fr_window_deactivate_filter (window); | |||
4673 | retval = TRUE(!(0)); | |||
4674 | break; | |||
4675 | default: | |||
4676 | break; | |||
4677 | } | |||
4678 | return retval; | |||
4679 | } | |||
4680 | ||||
4681 | alt = (event->state & CDK_MOD1_MASK) == CDK_MOD1_MASK; | |||
4682 | ||||
4683 | switch (event->keyval) { | |||
4684 | case CDK_KEY_Escape0xff1b: | |||
4685 | activate_action_stop (NULL((void*)0), window); | |||
4686 | if (window->priv->filter_mode) | |||
4687 | fr_window_deactivate_filter (window); | |||
4688 | retval = TRUE(!(0)); | |||
4689 | break; | |||
4690 | ||||
4691 | case CDK_KEY_F100xffc7: | |||
4692 | if (event->state & CDK_SHIFT_MASK) { | |||
4693 | CtkTreeSelection *selection; | |||
4694 | ||||
4695 | selection = ctk_tree_view_get_selection (CTK_TREE_VIEW (window->priv->list_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_view)), ((ctk_tree_view_get_type ()))))))); | |||
4696 | if (selection == NULL((void*)0)) | |||
4697 | return FALSE(0); | |||
4698 | ||||
4699 | ctk_menu_popup_at_pointer (CTK_MENU (window->priv->file_popup_menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->file_popup_menu)), ((ctk_menu_get_type ())))))), | |||
4700 | (const CdkEvent*) event); | |||
4701 | retval = TRUE(!(0)); | |||
4702 | } | |||
4703 | break; | |||
4704 | ||||
4705 | case CDK_KEY_Up0xff52: | |||
4706 | case CDK_KEY_KP_Up0xff97: | |||
4707 | if (alt) { | |||
4708 | fr_window_go_up_one_level (window); | |||
4709 | retval = TRUE(!(0)); | |||
4710 | } | |||
4711 | break; | |||
4712 | ||||
4713 | case CDK_KEY_BackSpace0xff08: | |||
4714 | fr_window_go_up_one_level (window); | |||
4715 | retval = TRUE(!(0)); | |||
4716 | break; | |||
4717 | ||||
4718 | case CDK_KEY_Right0xff53: | |||
4719 | case CDK_KEY_KP_Right0xff98: | |||
4720 | if (alt) { | |||
4721 | fr_window_go_forward (window); | |||
4722 | retval = TRUE(!(0)); | |||
4723 | } | |||
4724 | break; | |||
4725 | ||||
4726 | case CDK_KEY_Left0xff51: | |||
4727 | case CDK_KEY_KP_Left0xff96: | |||
4728 | if (alt) { | |||
4729 | fr_window_go_back (window); | |||
4730 | retval = TRUE(!(0)); | |||
4731 | } | |||
4732 | break; | |||
4733 | ||||
4734 | case CDK_KEY_Home0xff50: | |||
4735 | case CDK_KEY_KP_Home0xff95: | |||
4736 | if (alt) { | |||
4737 | fr_window_go_to_location (window, "/", FALSE(0)); | |||
4738 | retval = TRUE(!(0)); | |||
4739 | } | |||
4740 | break; | |||
4741 | ||||
4742 | default: | |||
4743 | break; | |||
4744 | } | |||
4745 | ||||
4746 | return retval; | |||
4747 | } | |||
4748 | ||||
4749 | ||||
4750 | static gboolean | |||
4751 | dir_tree_selection_changed_cb (CtkTreeSelection *selection, | |||
4752 | gpointer user_data) | |||
4753 | { | |||
4754 | FrWindow *window = user_data; | |||
4755 | CtkTreeIter iter; | |||
4756 | ||||
4757 | if (ctk_tree_selection_get_selected (selection, NULL((void*)0), &iter)) { | |||
4758 | char *path; | |||
4759 | ||||
4760 | ctk_tree_model_get (CTK_TREE_MODEL (window->priv->tree_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->tree_store)), ((ctk_tree_model_get_type ())))))), | |||
4761 | &iter, | |||
4762 | TREE_COLUMN_PATH, &path, | |||
4763 | -1); | |||
4764 | fr_window_go_to_location (window, path, FALSE(0)); | |||
4765 | g_free (path); | |||
4766 | } | |||
4767 | ||||
4768 | return FALSE(0); | |||
4769 | } | |||
4770 | ||||
4771 | ||||
4772 | static gboolean | |||
4773 | selection_changed_cb (CtkTreeSelection *selection G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
4774 | gpointer user_data) | |||
4775 | { | |||
4776 | FrWindow *window = user_data; | |||
4777 | ||||
4778 | fr_window_update_statusbar_list_info (window); | |||
4779 | fr_window_update_sensitivity (window); | |||
4780 | ||||
4781 | return FALSE(0); | |||
4782 | } | |||
4783 | ||||
4784 | ||||
4785 | static void | |||
4786 | fr_window_delete_event_cb (CtkWidget *caller G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
4787 | CdkEvent *event G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
4788 | FrWindow *window) | |||
4789 | { | |||
4790 | fr_window_close (window); | |||
4791 | } | |||
4792 | ||||
4793 | ||||
4794 | static gboolean | |||
4795 | is_single_click_policy (FrWindow *window) | |||
4796 | { | |||
4797 | char *value; | |||
4798 | gboolean result = FALSE(0); | |||
4799 | ||||
4800 | if (window->priv->settings_baul) { | |||
4801 | value = g_settings_get_string (window->priv->settings_baul, BAUL_CLICK_POLICY"click-policy"); | |||
4802 | result = (value != NULL((void*)0)) && (strncmp (value, "single", 6) == 0); | |||
4803 | g_free (value); | |||
4804 | } | |||
4805 | ||||
4806 | return result; | |||
4807 | } | |||
4808 | ||||
4809 | ||||
4810 | static void | |||
4811 | filename_cell_data_func (CtkTreeViewColumn *column G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
4812 | CtkCellRenderer *renderer, | |||
4813 | CtkTreeModel *model, | |||
4814 | CtkTreeIter *iter, | |||
4815 | FrWindow *window) | |||
4816 | { | |||
4817 | char *text; | |||
4818 | CtkTreePath *path; | |||
4819 | PangoUnderline underline; | |||
4820 | ||||
4821 | ctk_tree_model_get (model, iter, | |||
4822 | COLUMN_NAME, &text, | |||
4823 | -1); | |||
4824 | ||||
4825 | if (window->priv->single_click) { | |||
4826 | path = ctk_tree_model_get_path (model, iter); | |||
4827 | ||||
4828 | if ((window->priv->list_hover_path == NULL((void*)0)) | |||
4829 | || ctk_tree_path_compare (path, window->priv->list_hover_path)) | |||
4830 | underline = PANGO_UNDERLINE_NONE; | |||
4831 | else | |||
4832 | underline = PANGO_UNDERLINE_SINGLE; | |||
4833 | ||||
4834 | ctk_tree_path_free (path); | |||
4835 | } | |||
4836 | else | |||
4837 | underline = PANGO_UNDERLINE_NONE; | |||
4838 | ||||
4839 | g_object_set (G_OBJECT (renderer)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((renderer)), (((GType) ((20) << (2)))))))), | |||
4840 | "text", text, | |||
4841 | "underline", underline, | |||
4842 | NULL((void*)0)); | |||
4843 | ||||
4844 | g_free (text); | |||
4845 | } | |||
4846 | ||||
4847 | ||||
4848 | static void | |||
4849 | add_dir_tree_columns (FrWindow *window G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
4850 | CtkTreeView *treeview) | |||
4851 | { | |||
4852 | CtkCellRenderer *renderer; | |||
4853 | CtkTreeViewColumn *column; | |||
4854 | GValue value = { 0, }; | |||
4855 | ||||
4856 | /* First column. */ | |||
4857 | ||||
4858 | column = ctk_tree_view_column_new (); | |||
4859 | ctk_tree_view_column_set_title (column, _("Folders")gettext ("Folders")); | |||
4860 | ||||
4861 | /* icon */ | |||
4862 | ||||
4863 | renderer = ctk_cell_renderer_pixbuf_new (); | |||
4864 | ctk_tree_view_column_pack_start (column, renderer, FALSE(0)); | |||
4865 | ctk_tree_view_column_set_attributes (column, renderer, | |||
4866 | "pixbuf", TREE_COLUMN_ICON, | |||
4867 | NULL((void*)0)); | |||
4868 | ||||
4869 | /* name */ | |||
4870 | ||||
4871 | renderer = ctk_cell_renderer_text_new (); | |||
4872 | ||||
4873 | g_value_init (&value, PANGO_TYPE_ELLIPSIZE_MODE(pango_ellipsize_mode_get_type ())); | |||
4874 | g_value_set_enum (&value, PANGO_ELLIPSIZE_END); | |||
4875 | g_object_set_property (G_OBJECT (renderer)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((renderer)), (((GType) ((20) << (2)))))))), "ellipsize", &value); | |||
4876 | g_value_unset (&value); | |||
4877 | ||||
4878 | ctk_tree_view_column_pack_start (column, | |||
4879 | renderer, | |||
4880 | TRUE(!(0))); | |||
4881 | ctk_tree_view_column_set_attributes (column, renderer, | |||
4882 | "text", TREE_COLUMN_NAME, | |||
4883 | "weight", TREE_COLUMN_WEIGHT, | |||
4884 | NULL((void*)0)); | |||
4885 | ||||
4886 | ctk_tree_view_column_set_sizing (column, CTK_TREE_VIEW_COLUMN_AUTOSIZE); | |||
4887 | ctk_tree_view_column_set_sort_column_id (column, TREE_COLUMN_NAME); | |||
4888 | ||||
4889 | ctk_tree_view_append_column (CTK_TREE_VIEW (treeview)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((treeview)), ((ctk_tree_view_get_type ())))))), column); | |||
4890 | } | |||
4891 | ||||
4892 | ||||
4893 | static void | |||
4894 | add_file_list_columns (FrWindow *window, | |||
4895 | CtkTreeView *treeview) | |||
4896 | { | |||
4897 | static const char *titles[] = {NC_("File", "Size")("Size"), | |||
4898 | NC_("File", "Type")("Type"), | |||
4899 | NC_("File", "Date Modified")("Date Modified"), | |||
4900 | NC_("File", "Location")("Location")}; | |||
4901 | CtkCellRenderer *renderer; | |||
4902 | CtkTreeViewColumn *column; | |||
4903 | GValue value = { 0, }; | |||
4904 | int i, j, w; | |||
4905 | ||||
4906 | /* First column. */ | |||
4907 | ||||
4908 | window->priv->filename_column = column = ctk_tree_view_column_new (); | |||
4909 | ctk_tree_view_column_set_title (column, C_("File", "Name")g_dpgettext (((void*)0), "File" "\004" "Name", strlen ("File" ) + 1)); | |||
4910 | ||||
4911 | /* emblem */ | |||
4912 | ||||
4913 | renderer = ctk_cell_renderer_pixbuf_new (); | |||
4914 | ctk_tree_view_column_pack_end (column, renderer, FALSE(0)); | |||
4915 | ctk_tree_view_column_set_attributes (column, renderer, | |||
4916 | "pixbuf", COLUMN_EMBLEM, | |||
4917 | NULL((void*)0)); | |||
4918 | ||||
4919 | /* icon */ | |||
4920 | ||||
4921 | renderer = ctk_cell_renderer_pixbuf_new (); | |||
4922 | ctk_tree_view_column_pack_start (column, renderer, FALSE(0)); | |||
4923 | ctk_tree_view_column_set_attributes (column, renderer, | |||
4924 | "pixbuf", COLUMN_ICON, | |||
4925 | NULL((void*)0)); | |||
4926 | ||||
4927 | /* name */ | |||
4928 | ||||
4929 | window->priv->single_click = is_single_click_policy (window); | |||
4930 | ||||
4931 | renderer = ctk_cell_renderer_text_new (); | |||
4932 | ||||
4933 | g_value_init (&value, PANGO_TYPE_ELLIPSIZE_MODE(pango_ellipsize_mode_get_type ())); | |||
4934 | g_value_set_enum (&value, PANGO_ELLIPSIZE_END); | |||
4935 | g_object_set_property (G_OBJECT (renderer)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((renderer)), (((GType) ((20) << (2)))))))), "ellipsize", &value); | |||
4936 | g_value_unset (&value); | |||
4937 | ||||
4938 | ctk_tree_view_column_pack_start (column, | |||
4939 | renderer, | |||
4940 | TRUE(!(0))); | |||
4941 | ctk_tree_view_column_set_attributes (column, renderer, | |||
4942 | "text", COLUMN_NAME, | |||
4943 | NULL((void*)0)); | |||
4944 | ||||
4945 | ctk_tree_view_column_set_sizing (column, CTK_TREE_VIEW_COLUMN_FIXED); | |||
4946 | w = g_settings_get_int (window->priv->settings_listing, PREF_LISTING_NAME_COLUMN_WIDTH"name-column-width"); | |||
4947 | if (w <= 0) | |||
4948 | w = DEFAULT_NAME_COLUMN_WIDTH250; | |||
4949 | ctk_tree_view_column_set_fixed_width (column, w); | |||
4950 | ctk_tree_view_column_set_resizable (column, TRUE(!(0))); | |||
4951 | ctk_tree_view_column_set_sort_column_id (column, COLUMN_NAME); | |||
4952 | ctk_tree_view_column_set_cell_data_func (column, renderer, | |||
4953 | (CtkTreeCellDataFunc) filename_cell_data_func, | |||
4954 | window, NULL((void*)0)); | |||
4955 | ||||
4956 | ctk_tree_view_append_column (CTK_TREE_VIEW (treeview)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((treeview)), ((ctk_tree_view_get_type ())))))), column); | |||
4957 | ||||
4958 | /* Other columns */ | |||
4959 | ||||
4960 | for (j = 0, i = COLUMN_SIZE; i < NUMBER_OF_COLUMNS; i++, j++) { | |||
4961 | GValue value_oc = { 0, }; | |||
4962 | ||||
4963 | renderer = ctk_cell_renderer_text_new (); | |||
4964 | column = ctk_tree_view_column_new_with_attributes (g_dpgettext2 (NULL((void*)0), "File", titles[j]), | |||
4965 | renderer, | |||
4966 | "text", i, | |||
4967 | NULL((void*)0)); | |||
4968 | ||||
4969 | ctk_tree_view_column_set_sizing (column, CTK_TREE_VIEW_COLUMN_FIXED); | |||
4970 | ctk_tree_view_column_set_fixed_width (column, OTHER_COLUMNS_WIDTH100); | |||
4971 | ctk_tree_view_column_set_resizable (column, TRUE(!(0))); | |||
4972 | ||||
4973 | ctk_tree_view_column_set_sort_column_id (column, i); | |||
4974 | ||||
4975 | g_value_init (&value_oc, PANGO_TYPE_ELLIPSIZE_MODE(pango_ellipsize_mode_get_type ())); | |||
4976 | g_value_set_enum (&value_oc, PANGO_ELLIPSIZE_END); | |||
4977 | g_object_set_property (G_OBJECT (renderer)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((renderer)), (((GType) ((20) << (2)))))))), "ellipsize", &value_oc); | |||
4978 | g_value_unset (&value_oc); | |||
4979 | ||||
4980 | ctk_tree_view_append_column (treeview, column); | |||
4981 | } | |||
4982 | } | |||
4983 | ||||
4984 | ||||
4985 | static int | |||
4986 | name_column_sort_func (CtkTreeModel *model, | |||
4987 | CtkTreeIter *a, | |||
4988 | CtkTreeIter *b, | |||
4989 | gpointer user_data G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
4990 | { | |||
4991 | FileData *fdata1, *fdata2; | |||
4992 | ||||
4993 | ctk_tree_model_get (model, a, COLUMN_FILE_DATA, &fdata1, -1); | |||
4994 | ctk_tree_model_get (model, b, COLUMN_FILE_DATA, &fdata2, -1); | |||
4995 | ||||
4996 | return sort_by_name (&fdata1, &fdata2); | |||
4997 | } | |||
4998 | ||||
4999 | ||||
5000 | static int | |||
5001 | size_column_sort_func (CtkTreeModel *model, | |||
5002 | CtkTreeIter *a, | |||
5003 | CtkTreeIter *b, | |||
5004 | gpointer user_data G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
5005 | { | |||
5006 | FileData *fdata1, *fdata2; | |||
5007 | ||||
5008 | ctk_tree_model_get (model, a, COLUMN_FILE_DATA, &fdata1, -1); | |||
5009 | ctk_tree_model_get (model, b, COLUMN_FILE_DATA, &fdata2, -1); | |||
5010 | ||||
5011 | return sort_by_size (&fdata1, &fdata2); | |||
5012 | } | |||
5013 | ||||
5014 | ||||
5015 | static int | |||
5016 | type_column_sort_func (CtkTreeModel *model, | |||
5017 | CtkTreeIter *a, | |||
5018 | CtkTreeIter *b, | |||
5019 | gpointer user_data G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
5020 | { | |||
5021 | FileData *fdata1, *fdata2; | |||
5022 | ||||
5023 | ctk_tree_model_get (model, a, COLUMN_FILE_DATA, &fdata1, -1); | |||
5024 | ctk_tree_model_get (model, b, COLUMN_FILE_DATA, &fdata2, -1); | |||
5025 | ||||
5026 | return sort_by_type (&fdata1, &fdata2); | |||
5027 | } | |||
5028 | ||||
5029 | ||||
5030 | static int | |||
5031 | time_column_sort_func (CtkTreeModel *model, | |||
5032 | CtkTreeIter *a, | |||
5033 | CtkTreeIter *b, | |||
5034 | gpointer user_data G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
5035 | { | |||
5036 | FileData *fdata1, *fdata2; | |||
5037 | ||||
5038 | ctk_tree_model_get (model, a, COLUMN_FILE_DATA, &fdata1, -1); | |||
5039 | ctk_tree_model_get (model, b, COLUMN_FILE_DATA, &fdata2, -1); | |||
5040 | ||||
5041 | return sort_by_time (&fdata1, &fdata2); | |||
5042 | } | |||
5043 | ||||
5044 | ||||
5045 | static int | |||
5046 | path_column_sort_func (CtkTreeModel *model, | |||
5047 | CtkTreeIter *a, | |||
5048 | CtkTreeIter *b, | |||
5049 | gpointer user_data G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
5050 | { | |||
5051 | FileData *fdata1, *fdata2; | |||
5052 | ||||
5053 | ctk_tree_model_get (model, a, COLUMN_FILE_DATA, &fdata1, -1); | |||
5054 | ctk_tree_model_get (model, b, COLUMN_FILE_DATA, &fdata2, -1); | |||
5055 | ||||
5056 | return sort_by_path (&fdata1, &fdata2); | |||
5057 | } | |||
5058 | ||||
5059 | ||||
5060 | static int | |||
5061 | no_sort_column_sort_func (CtkTreeModel *model G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
5062 | CtkTreeIter *a G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
5063 | CtkTreeIter *b G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
5064 | gpointer user_data G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
5065 | { | |||
5066 | return -1; | |||
5067 | } | |||
5068 | ||||
5069 | ||||
5070 | static void | |||
5071 | sort_column_changed_cb (CtkTreeSortable *sortable, | |||
5072 | gpointer user_data) | |||
5073 | { | |||
5074 | FrWindow *window = user_data; | |||
5075 | CtkSortType order; | |||
5076 | int column_id; | |||
5077 | ||||
5078 | if (! ctk_tree_sortable_get_sort_column_id (sortable, | |||
5079 | &column_id, | |||
5080 | &order)) | |||
5081 | return; | |||
5082 | ||||
5083 | window->priv->sort_method = get_sort_method_from_column (column_id); | |||
5084 | window->priv->sort_type = order; | |||
5085 | ||||
5086 | /*set_active (window, get_action_from_sort_method (window->priv->sort_method), TRUE); | |||
5087 | set_active (window, "SortReverseOrder", (window->priv->sort_type == CTK_SORT_DESCENDING));*/ | |||
5088 | } | |||
5089 | ||||
5090 | ||||
5091 | static gboolean | |||
5092 | fr_window_show_cb (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
5093 | FrWindow *window) | |||
5094 | { | |||
5095 | fr_window_update_current_location (window); | |||
5096 | ||||
5097 | set_active (window, "ViewToolbar", g_settings_get_boolean (window->priv->settings_ui, PREF_UI_VIEW_TOOLBAR"view-toolbar")); | |||
5098 | set_active (window, "ViewStatusbar", g_settings_get_boolean (window->priv->settings_ui, PREF_UI_VIEW_STATUSBAR"view-statusbar")); | |||
5099 | ||||
5100 | window->priv->view_folders = g_settings_get_boolean (window->priv->settings_ui, PREF_UI_VIEW_FOLDERS"view-folders"); | |||
5101 | set_active (window, "ViewFolders", window->priv->view_folders); | |||
5102 | ||||
5103 | fr_window_update_filter_bar_visibility (window); | |||
5104 | ||||
5105 | return TRUE(!(0)); | |||
5106 | } | |||
5107 | ||||
5108 | ||||
5109 | /* preferences changes notification callbacks */ | |||
5110 | ||||
5111 | ||||
5112 | static void | |||
5113 | pref_history_len_changed (GSettings *settings, | |||
5114 | const char *key G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
5115 | gpointer user_data) | |||
5116 | { | |||
5117 | FrWindow *window = user_data; | |||
5118 | int limit; | |||
5119 | CtkAction *action; | |||
5120 | ||||
5121 | limit = g_settings_get_int (settings, PREF_UI_HISTORY_LEN"history-len"); | |||
5122 | ||||
5123 | action = ctk_action_group_get_action (window->priv->actions, "OpenRecent"); | |||
5124 | ctk_recent_chooser_set_limit (CTK_RECENT_CHOOSER (action)((((CtkRecentChooser*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((action)), ((ctk_recent_chooser_get_type ()) ))))), limit); | |||
5125 | ||||
5126 | action = ctk_action_group_get_action (window->priv->actions, "OpenRecent_Toolbar"); | |||
5127 | ctk_recent_chooser_set_limit (CTK_RECENT_CHOOSER (action)((((CtkRecentChooser*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((action)), ((ctk_recent_chooser_get_type ()) ))))), limit); | |||
5128 | } | |||
5129 | ||||
5130 | ||||
5131 | static void | |||
5132 | pref_view_toolbar_changed (GSettings *settings, | |||
5133 | const char *key, | |||
5134 | gpointer user_data) | |||
5135 | { | |||
5136 | FrWindow *window = user_data; | |||
5137 | ||||
5138 | fr_window_set_toolbar_visibility (window, g_settings_get_boolean (settings, key)); | |||
5139 | } | |||
5140 | ||||
5141 | ||||
5142 | static void | |||
5143 | pref_view_statusbar_changed (GSettings *settings, | |||
5144 | const char *key, | |||
5145 | gpointer user_data) | |||
5146 | { | |||
5147 | FrWindow *window = user_data; | |||
5148 | ||||
5149 | fr_window_set_statusbar_visibility (window, g_settings_get_boolean (settings, key)); | |||
5150 | } | |||
5151 | ||||
5152 | ||||
5153 | static void | |||
5154 | pref_view_folders_changed (GSettings *settings, | |||
5155 | const char *key, | |||
5156 | gpointer user_data) | |||
5157 | { | |||
5158 | FrWindow *window = user_data; | |||
5159 | ||||
5160 | fr_window_set_folders_visibility (window, g_settings_get_boolean (settings, key)); | |||
5161 | } | |||
5162 | ||||
5163 | ||||
5164 | static void | |||
5165 | pref_show_field_changed (GSettings *settings G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
5166 | const char *key G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
5167 | gpointer user_data) | |||
5168 | { | |||
5169 | FrWindow *window = user_data; | |||
5170 | ||||
5171 | fr_window_update_columns_visibility (window); | |||
5172 | } | |||
5173 | ||||
5174 | ||||
5175 | static void | |||
5176 | pref_click_policy_changed (GSettings *settings G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
5177 | const char *key G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
5178 | gpointer user_data) | |||
5179 | { | |||
5180 | FrWindow *window = user_data; | |||
5181 | CdkWindow *win = ctk_tree_view_get_bin_window (CTK_TREE_VIEW (window->priv->list_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_view)), ((ctk_tree_view_get_type ()))))))); | |||
5182 | CdkDisplay *display; | |||
5183 | ||||
5184 | window->priv->single_click = is_single_click_policy (window); | |||
5185 | ||||
5186 | cdk_window_set_cursor (win, NULL((void*)0)); | |||
5187 | display = ctk_widget_get_display (CTK_WIDGET (window->priv->list_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_view)), ((ctk_widget_get_type ( )))))))); | |||
5188 | if (display != NULL((void*)0)) | |||
5189 | cdk_display_flush (display); | |||
5190 | } | |||
5191 | ||||
5192 | ||||
5193 | static void | |||
5194 | pref_use_mime_icons_changed (GSettings *settings G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
5195 | const char *key G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
5196 | gpointer user_data) | |||
5197 | { | |||
5198 | FrWindow *window = user_data; | |||
5199 | ||||
5200 | if (pixbuf_hash != NULL((void*)0)) { | |||
5201 | g_hash_table_foreach (pixbuf_hash, | |||
5202 | gh_unref_pixbuf, | |||
5203 | NULL((void*)0)); | |||
5204 | g_hash_table_destroy (pixbuf_hash); | |||
5205 | pixbuf_hash = g_hash_table_new (g_str_hash, g_str_equal); | |||
5206 | } | |||
5207 | if (tree_pixbuf_hash != NULL((void*)0)) { | |||
5208 | g_hash_table_foreach (tree_pixbuf_hash, | |||
5209 | gh_unref_pixbuf, | |||
5210 | NULL((void*)0)); | |||
5211 | g_hash_table_destroy (tree_pixbuf_hash); | |||
5212 | tree_pixbuf_hash = g_hash_table_new (g_str_hash, g_str_equal); | |||
5213 | } | |||
5214 | ||||
5215 | fr_window_update_file_list (window, FALSE(0)); | |||
5216 | fr_window_update_dir_tree (window); | |||
5217 | } | |||
5218 | ||||
5219 | ||||
5220 | static void | |||
5221 | theme_changed_cb (CtkIconTheme *theme G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
5222 | FrWindow *window) | |||
5223 | { | |||
5224 | file_list_icon_size = _ctk_widget_lookup_for_size (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))), FILE_LIST_ICON_SIZECTK_ICON_SIZE_LARGE_TOOLBAR); | |||
5225 | dir_tree_icon_size = _ctk_widget_lookup_for_size (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))), DIR_TREE_ICON_SIZECTK_ICON_SIZE_MENU); | |||
5226 | ||||
5227 | if (pixbuf_hash != NULL((void*)0)) { | |||
5228 | g_hash_table_foreach (pixbuf_hash, | |||
5229 | gh_unref_pixbuf, | |||
5230 | NULL((void*)0)); | |||
5231 | g_hash_table_destroy (pixbuf_hash); | |||
5232 | pixbuf_hash = g_hash_table_new (g_str_hash, g_str_equal); | |||
5233 | } | |||
5234 | if (tree_pixbuf_hash != NULL((void*)0)) { | |||
5235 | g_hash_table_foreach (tree_pixbuf_hash, | |||
5236 | gh_unref_pixbuf, | |||
5237 | NULL((void*)0)); | |||
5238 | g_hash_table_destroy (tree_pixbuf_hash); | |||
5239 | tree_pixbuf_hash = g_hash_table_new (g_str_hash, g_str_equal); | |||
5240 | } | |||
5241 | ||||
5242 | fr_window_update_file_list (window, TRUE(!(0))); | |||
5243 | fr_window_update_dir_tree (window); | |||
5244 | } | |||
5245 | ||||
5246 | ||||
5247 | static gboolean | |||
5248 | fr_window_stoppable_cb (FrCommand *command G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
5249 | gboolean stoppable, | |||
5250 | FrWindow *window) | |||
5251 | { | |||
5252 | window->priv->stoppable = stoppable; | |||
5253 | set_sensitive (window, "Stop", stoppable); | |||
5254 | if (window->priv->progress_dialog != NULL((void*)0)) | |||
5255 | ctk_dialog_set_response_sensitive (CTK_DIALOG (window->priv->progress_dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->progress_dialog)), ((ctk_dialog_get_type ())))))), | |||
5256 | CTK_RESPONSE_OK, | |||
5257 | stoppable); | |||
5258 | return TRUE(!(0)); | |||
5259 | } | |||
5260 | ||||
5261 | ||||
5262 | static gboolean | |||
5263 | fr_window_fake_load (FrArchive *archive G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
5264 | gpointer data G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
5265 | { | |||
5266 | /* fake loads are disabled to allow exact progress dialogs (#153281) */ | |||
5267 | ||||
5268 | return FALSE(0); | |||
5269 | ||||
5270 | #if 0 | |||
5271 | FrWindow *window = data; | |||
5272 | gboolean add_after_opening = FALSE(0); | |||
5273 | gboolean extract_after_opening = FALSE(0); | |||
5274 | GList *scan; | |||
5275 | ||||
5276 | /* fake loads are used only in batch mode to avoid unnecessary | |||
5277 | * archive loadings. */ | |||
5278 | ||||
5279 | if (! window->priv->batch_mode) | |||
5280 | return FALSE(0); | |||
5281 | ||||
5282 | /* Check whether there is an ADD or EXTRACT action in the batch list. */ | |||
5283 | ||||
5284 | for (scan = window->priv->batch_action; scan; scan = scan->next) { | |||
5285 | FRBatchAction *action; | |||
5286 | ||||
5287 | action = (FRBatchAction *) scan->data; | |||
5288 | if (action->type == FR_BATCH_ACTION_ADD) { | |||
5289 | add_after_opening = TRUE(!(0)); | |||
5290 | break; | |||
5291 | } | |||
5292 | if ((action->type == FR_BATCH_ACTION_EXTRACT) | |||
5293 | || (action->type == FR_BATCH_ACTION_EXTRACT_HERE) | |||
5294 | || (action->type == FR_BATCH_ACTION_EXTRACT_INTERACT)) | |||
5295 | { | |||
5296 | extract_after_opening = TRUE(!(0)); | |||
5297 | break; | |||
5298 | } | |||
5299 | } | |||
5300 | ||||
5301 | /* use fake load when in batch mode and the archive type supports all | |||
5302 | * of the required features */ | |||
5303 | ||||
5304 | return (window->priv->batch_mode | |||
5305 | && ! (add_after_opening && window->priv->update_dropped_files && ! archive->command->propAddCanUpdate) | |||
5306 | && ! (add_after_opening && ! window->priv->update_dropped_files && ! archive->command->propAddCanReplace) | |||
5307 | && ! (extract_after_opening && !archive->command->propCanExtractAll)); | |||
5308 | #endif | |||
5309 | } | |||
5310 | ||||
5311 | ||||
5312 | static void | |||
5313 | menu_item_select_cb (CtkMenuItem *proxy, | |||
5314 | FrWindow *window) | |||
5315 | { | |||
5316 | CtkAction *action; | |||
5317 | char *message; | |||
5318 | ||||
5319 | action = ctk_activatable_get_related_action (CTK_ACTIVATABLE (proxy)((((CtkActivatable*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((proxy)), ((ctk_activatable_get_type ()))))))); | |||
5320 | g_return_if_fail (action != NULL)do { if ((action != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "action != NULL") ; return; } } while (0); | |||
5321 | ||||
5322 | g_object_get (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), (((GType) ((20) << (2)))))))), "tooltip", &message, NULL((void*)0)); | |||
5323 | if (message) { | |||
5324 | ctk_statusbar_push (CTK_STATUSBAR (window->priv->statusbar)((((CtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->statusbar)), ((ctk_statusbar_get_type ())))))), | |||
5325 | window->priv->help_message_cid, message); | |||
5326 | g_free (message); | |||
5327 | } | |||
5328 | } | |||
5329 | ||||
5330 | ||||
5331 | static void | |||
5332 | menu_item_deselect_cb (CtkMenuItem *proxy G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
5333 | FrWindow *window) | |||
5334 | { | |||
5335 | ctk_statusbar_pop (CTK_STATUSBAR (window->priv->statusbar)((((CtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->statusbar)), ((ctk_statusbar_get_type ())))))), | |||
5336 | window->priv->help_message_cid); | |||
5337 | } | |||
5338 | ||||
5339 | ||||
5340 | static void | |||
5341 | disconnect_proxy_cb (CtkUIManager *manager G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
5342 | CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
5343 | CtkWidget *proxy, | |||
5344 | FrWindow *window) | |||
5345 | { | |||
5346 | if (CTK_IS_MENU_ITEM (proxy)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (proxy)); GType __t = ((ctk_menu_item_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) { | |||
5347 | g_signal_handlers_disconnect_by_funcg_signal_handlers_disconnect_matched ((proxy), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (menu_item_select_cb))), (window)) | |||
5348 | (proxy, G_CALLBACK (menu_item_select_cb), window)g_signal_handlers_disconnect_matched ((proxy), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (menu_item_select_cb))), (window)); | |||
5349 | g_signal_handlers_disconnect_by_funcg_signal_handlers_disconnect_matched ((proxy), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (menu_item_deselect_cb))), (window)) | |||
5350 | (proxy, G_CALLBACK (menu_item_deselect_cb), window)g_signal_handlers_disconnect_matched ((proxy), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (menu_item_deselect_cb))), (window)); | |||
5351 | } | |||
5352 | } | |||
5353 | ||||
5354 | ||||
5355 | static void | |||
5356 | connect_proxy_cb (CtkUIManager *manager G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
5357 | CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
5358 | CtkWidget *proxy, | |||
5359 | FrWindow *window) | |||
5360 | { | |||
5361 | if (CTK_IS_MENU_ITEM (proxy)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (proxy)); GType __t = ((ctk_menu_item_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) { | |||
5362 | g_signal_connect (proxy, "select",g_signal_connect_data ((proxy), ("select"), (((GCallback) (menu_item_select_cb ))), (window), ((void*)0), (GConnectFlags) 0) | |||
5363 | G_CALLBACK (menu_item_select_cb), window)g_signal_connect_data ((proxy), ("select"), (((GCallback) (menu_item_select_cb ))), (window), ((void*)0), (GConnectFlags) 0); | |||
5364 | g_signal_connect (proxy, "deselect",g_signal_connect_data ((proxy), ("deselect"), (((GCallback) ( menu_item_deselect_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5365 | G_CALLBACK (menu_item_deselect_cb), window)g_signal_connect_data ((proxy), ("deselect"), (((GCallback) ( menu_item_deselect_cb))), (window), ((void*)0), (GConnectFlags ) 0); | |||
5366 | } | |||
5367 | } | |||
5368 | ||||
5369 | ||||
5370 | static void | |||
5371 | view_as_radio_action (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
5372 | CtkRadioAction *current, | |||
5373 | gpointer data) | |||
5374 | { | |||
5375 | FrWindow *window = data; | |||
5376 | fr_window_set_list_mode (window, ctk_radio_action_get_current_value (current)); | |||
5377 | } | |||
5378 | ||||
5379 | ||||
5380 | static void | |||
5381 | sort_by_radio_action (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
5382 | CtkRadioAction *current, | |||
5383 | gpointer data) | |||
5384 | { | |||
5385 | FrWindow *window = data; | |||
5386 | ||||
5387 | window->priv->sort_method = ctk_radio_action_get_current_value (current); | |||
5388 | window->priv->sort_type = CTK_SORT_ASCENDING; | |||
5389 | fr_window_update_list_order (window); | |||
5390 | } | |||
5391 | ||||
5392 | ||||
5393 | static void | |||
5394 | recent_chooser_item_activated_cb (CtkRecentChooser *chooser, | |||
5395 | FrWindow *window) | |||
5396 | { | |||
5397 | char *uri; | |||
5398 | ||||
5399 | uri = ctk_recent_chooser_get_current_uri (chooser); | |||
5400 | if (uri != NULL((void*)0)) { | |||
5401 | fr_window_archive_open (window, uri, CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ()))))))); | |||
5402 | g_free (uri); | |||
5403 | } | |||
5404 | } | |||
5405 | ||||
5406 | ||||
5407 | static void | |||
5408 | fr_window_init_recent_chooser (FrWindow *window, | |||
5409 | CtkRecentChooser *chooser) | |||
5410 | { | |||
5411 | CtkRecentFilter *filter; | |||
5412 | int i; | |||
5413 | ||||
5414 | g_return_if_fail (chooser != NULL)do { if ((chooser != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "chooser != NULL" ); return; } } while (0); | |||
5415 | ||||
5416 | filter = ctk_recent_filter_new (); | |||
5417 | ctk_recent_filter_set_name (filter, _("All archives")gettext ("All archives")); | |||
5418 | for (i = 0; open_type[i] != -1; i++) | |||
5419 | ctk_recent_filter_add_mime_type (filter, mime_type_desc[open_type[i]].mime_type); | |||
5420 | ctk_recent_filter_add_application (filter, "Grapa"); | |||
5421 | ctk_recent_chooser_add_filter (chooser, filter); | |||
5422 | ||||
5423 | ctk_recent_chooser_set_local_only (chooser, FALSE(0)); | |||
5424 | ctk_recent_chooser_set_limit (chooser, g_settings_get_int (window->priv->settings_ui, PREF_UI_HISTORY_LEN"history-len")); | |||
5425 | ctk_recent_chooser_set_show_not_found (chooser, TRUE(!(0))); | |||
5426 | ctk_recent_chooser_set_sort_type (chooser, CTK_RECENT_SORT_MRU); | |||
5427 | ||||
5428 | g_signal_connect (G_OBJECT (chooser),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((chooser)), (((GType) ((20) << (2)) ))))))), ("item_activated"), (((GCallback) (recent_chooser_item_activated_cb ))), (window), ((void*)0), (GConnectFlags) 0) | |||
5429 | "item_activated",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((chooser)), (((GType) ((20) << (2)) ))))))), ("item_activated"), (((GCallback) (recent_chooser_item_activated_cb ))), (window), ((void*)0), (GConnectFlags) 0) | |||
5430 | G_CALLBACK (recent_chooser_item_activated_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((chooser)), (((GType) ((20) << (2)) ))))))), ("item_activated"), (((GCallback) (recent_chooser_item_activated_cb ))), (window), ((void*)0), (GConnectFlags) 0) | |||
5431 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((chooser)), (((GType) ((20) << (2)) ))))))), ("item_activated"), (((GCallback) (recent_chooser_item_activated_cb ))), (window), ((void*)0), (GConnectFlags) 0); | |||
5432 | } | |||
5433 | ||||
5434 | ||||
5435 | static void | |||
5436 | close_sidepane_button_clicked_cb (CtkButton *button G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
5437 | FrWindow *window) | |||
5438 | { | |||
5439 | fr_window_set_folders_visibility (window, FALSE(0)); | |||
5440 | } | |||
5441 | ||||
5442 | ||||
5443 | static void | |||
5444 | fr_window_activate_filter (FrWindow *window) | |||
5445 | { | |||
5446 | CtkTreeView *tree_view = CTK_TREE_VIEW (window->priv->list_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_view)), ((ctk_tree_view_get_type ())))))); | |||
5447 | CtkTreeViewColumn *column; | |||
5448 | ||||
5449 | fr_window_update_filter_bar_visibility (window); | |||
5450 | window->priv->list_mode = FR_WINDOW_LIST_MODE_FLAT; | |||
5451 | ||||
5452 | ctk_list_store_clear (window->priv->list_store); | |||
5453 | ||||
5454 | column = ctk_tree_view_get_column (tree_view, 4); | |||
5455 | ctk_tree_view_column_set_visible (column, TRUE(!(0))); | |||
5456 | ||||
5457 | fr_window_update_file_list (window, TRUE(!(0))); | |||
5458 | fr_window_update_dir_tree (window); | |||
5459 | fr_window_update_current_location (window); | |||
5460 | } | |||
5461 | ||||
5462 | ||||
5463 | static void | |||
5464 | filter_entry_activate_cb (CtkEntry *entry G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
5465 | FrWindow *window) | |||
5466 | { | |||
5467 | fr_window_activate_filter (window); | |||
5468 | } | |||
5469 | ||||
5470 | ||||
5471 | static void | |||
5472 | filter_entry_icon_release_cb (CtkEntry *entry G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
5473 | CtkEntryIconPosition icon_pos, | |||
5474 | CdkEventButton *event, | |||
5475 | gpointer user_data) | |||
5476 | { | |||
5477 | FrWindow *window = FR_WINDOW (user_data)((((FrWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((user_data)), ((fr_window_get_type ())))))); | |||
5478 | ||||
5479 | if ((event->button == 1) && (icon_pos == CTK_ENTRY_ICON_SECONDARY)) | |||
5480 | fr_window_deactivate_filter (window); | |||
5481 | } | |||
5482 | ||||
5483 | ||||
5484 | static void | |||
5485 | fr_window_attach (FrWindow *window, | |||
5486 | CtkWidget *child, | |||
5487 | FrWindowArea area) | |||
5488 | { | |||
5489 | int position; | |||
5490 | ||||
5491 | g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return; } } while (0); | |||
5492 | g_return_if_fail (FR_IS_WINDOW (window))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((window)); GType __t = ((fr_window_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FR_IS_WINDOW (window)"); return; } } while (0 ); | |||
5493 | g_return_if_fail (child != NULL)do { if ((child != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "child != NULL"); return; } } while (0); | |||
5494 | g_return_if_fail (CTK_IS_WIDGET (child))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((child)); GType __t = ((ctk_widget_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "CTK_IS_WIDGET (child)"); return; } } while (0 ); | |||
5495 | ||||
5496 | switch (area) { | |||
5497 | case FR_WINDOW_AREA_MENUBAR: | |||
5498 | position = 0; | |||
5499 | break; | |||
5500 | case FR_WINDOW_AREA_TOOLBAR: | |||
5501 | position = 1; | |||
5502 | break; | |||
5503 | case FR_WINDOW_AREA_LOCATIONBAR: | |||
5504 | position = 2; | |||
5505 | break; | |||
5506 | case FR_WINDOW_AREA_CONTENTS: | |||
5507 | position = 3; | |||
5508 | if (window->priv->contents != NULL((void*)0)) | |||
5509 | ctk_widget_destroy (window->priv->contents); | |||
5510 | window->priv->contents = child; | |||
5511 | ctk_widget_set_vexpand (child, TRUE(!(0))); | |||
5512 | break; | |||
5513 | case FR_WINDOW_AREA_FILTERBAR: | |||
5514 | position = 4; | |||
5515 | break; | |||
5516 | case FR_WINDOW_AREA_STATUSBAR: | |||
5517 | position = 5; | |||
5518 | break; | |||
5519 | default: | |||
5520 | g_critical ("%s: area not recognized!", G_STRFUNC((const char*) (__func__))); | |||
5521 | return; | |||
5522 | break; | |||
5523 | } | |||
5524 | ||||
5525 | ctk_widget_set_hexpand (child, TRUE(!(0))); | |||
5526 | ctk_grid_attach (CTK_GRID (window->priv->layout)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->layout)), ((ctk_grid_get_type ())))) )), | |||
5527 | child, | |||
5528 | 0, position, | |||
5529 | 1, 1); | |||
5530 | } | |||
5531 | ||||
5532 | ||||
5533 | static void | |||
5534 | set_action_important (CtkUIManager *ui, | |||
5535 | const char *action_name) | |||
5536 | { | |||
5537 | CtkAction *action; | |||
5538 | ||||
5539 | action = ctk_ui_manager_get_action (ui, action_name); | |||
5540 | g_object_set (action, "is_important", TRUE(!(0)), NULL((void*)0)); | |||
5541 | g_object_unref (action); | |||
5542 | } | |||
5543 | ||||
5544 | ||||
5545 | static void | |||
5546 | fr_window_construct (FrWindow *window) | |||
5547 | { | |||
5548 | CtkWidget *menubar; | |||
5549 | CtkWidget *toolbar; | |||
5550 | CtkWidget *list_scrolled_window; | |||
5551 | CtkWidget *location_box; | |||
5552 | CtkStatusbar *statusbar; | |||
5553 | CtkWidget *statusbar_box; | |||
5554 | CtkWidget *filter_box; | |||
5555 | CtkWidget *tree_scrolled_window; | |||
5556 | CtkWidget *sidepane_title; | |||
5557 | CtkWidget *sidepane_title_box; | |||
5558 | CtkWidget *sidepane_title_label; | |||
5559 | CtkWidget *close_sidepane_button; | |||
5560 | CtkTreeSelection *selection; | |||
5561 | CtkActionGroup *actions; | |||
5562 | CtkAction *action; | |||
5563 | CtkUIManager *ui; | |||
5564 | GError *error = NULL((void*)0); | |||
5565 | GSettingsSchemaSource *schema_source; | |||
5566 | GSettingsSchema *baul_schema; | |||
5567 | ||||
5568 | /* data common to all windows. */ | |||
5569 | ||||
5570 | if (pixbuf_hash == NULL((void*)0)) | |||
5571 | pixbuf_hash = g_hash_table_new (g_str_hash, g_str_equal); | |||
5572 | if (tree_pixbuf_hash == NULL((void*)0)) | |||
5573 | tree_pixbuf_hash = g_hash_table_new (g_str_hash, g_str_equal); | |||
5574 | ||||
5575 | if (icon_theme == NULL((void*)0)) | |||
5576 | icon_theme = ctk_icon_theme_get_default (); | |||
5577 | ||||
5578 | /* Create the settings objects */ | |||
5579 | ||||
5580 | window->priv->settings_listing = g_settings_new (GRAPA_SCHEMA_LISTING"org.cafe.grapa" ".listing"); | |||
5581 | window->priv->settings_ui = g_settings_new (GRAPA_SCHEMA_UI"org.cafe.grapa" ".ui"); | |||
5582 | window->priv->settings_general = g_settings_new (GRAPA_SCHEMA_GENERAL"org.cafe.grapa" ".general"); | |||
5583 | window->priv->settings_dialogs = g_settings_new (GRAPA_SCHEMA_DIALOGS"org.cafe.grapa" ".dialogs"); | |||
5584 | ||||
5585 | schema_source = g_settings_schema_source_get_default (); | |||
5586 | baul_schema = g_settings_schema_source_lookup (schema_source, BAUL_SCHEMA"org.cafe.baul.preferences", FALSE(0)); | |||
5587 | if (baul_schema) { | |||
5588 | window->priv->settings_baul = g_settings_new (BAUL_SCHEMA"org.cafe.baul.preferences"); | |||
5589 | g_settings_schema_unref (baul_schema); | |||
5590 | } | |||
5591 | ||||
5592 | /* Create the application. */ | |||
5593 | ||||
5594 | window->priv->layout = ctk_grid_new (); | |||
5595 | ctk_container_add (CTK_CONTAINER (window)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_container_get_type ())))))), window->priv->layout); | |||
5596 | ctk_widget_show (window->priv->layout); | |||
5597 | ||||
5598 | ctk_window_set_title (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), _("Archive Manager")gettext ("Archive Manager")); | |||
5599 | ||||
5600 | g_signal_connect (G_OBJECT (window),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), (((GType) ((20) << (2))) )))))), ("delete_event"), (((GCallback) (fr_window_delete_event_cb ))), (window), ((void*)0), (GConnectFlags) 0) | |||
5601 | "delete_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), (((GType) ((20) << (2))) )))))), ("delete_event"), (((GCallback) (fr_window_delete_event_cb ))), (window), ((void*)0), (GConnectFlags) 0) | |||
5602 | G_CALLBACK (fr_window_delete_event_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), (((GType) ((20) << (2))) )))))), ("delete_event"), (((GCallback) (fr_window_delete_event_cb ))), (window), ((void*)0), (GConnectFlags) 0) | |||
5603 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), (((GType) ((20) << (2))) )))))), ("delete_event"), (((GCallback) (fr_window_delete_event_cb ))), (window), ((void*)0), (GConnectFlags) 0); | |||
5604 | ||||
5605 | g_signal_connect (G_OBJECT (window),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), (((GType) ((20) << (2))) )))))), ("show"), (((GCallback) (fr_window_show_cb))), (window ), ((void*)0), (GConnectFlags) 0) | |||
5606 | "show",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), (((GType) ((20) << (2))) )))))), ("show"), (((GCallback) (fr_window_show_cb))), (window ), ((void*)0), (GConnectFlags) 0) | |||
5607 | G_CALLBACK (fr_window_show_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), (((GType) ((20) << (2))) )))))), ("show"), (((GCallback) (fr_window_show_cb))), (window ), ((void*)0), (GConnectFlags) 0) | |||
5608 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), (((GType) ((20) << (2))) )))))), ("show"), (((GCallback) (fr_window_show_cb))), (window ), ((void*)0), (GConnectFlags) 0); | |||
5609 | ||||
5610 | window->priv->theme_changed_handler_id = | |||
5611 | g_signal_connect (icon_theme,g_signal_connect_data ((icon_theme), ("changed"), (((GCallback ) (theme_changed_cb))), (window), ((void*)0), (GConnectFlags) 0) | |||
5612 | "changed",g_signal_connect_data ((icon_theme), ("changed"), (((GCallback ) (theme_changed_cb))), (window), ((void*)0), (GConnectFlags) 0) | |||
5613 | G_CALLBACK (theme_changed_cb),g_signal_connect_data ((icon_theme), ("changed"), (((GCallback ) (theme_changed_cb))), (window), ((void*)0), (GConnectFlags) 0) | |||
5614 | window)g_signal_connect_data ((icon_theme), ("changed"), (((GCallback ) (theme_changed_cb))), (window), ((void*)0), (GConnectFlags) 0); | |||
5615 | ||||
5616 | file_list_icon_size = _ctk_widget_lookup_for_size (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))), FILE_LIST_ICON_SIZECTK_ICON_SIZE_LARGE_TOOLBAR); | |||
5617 | dir_tree_icon_size = _ctk_widget_lookup_for_size (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))), DIR_TREE_ICON_SIZECTK_ICON_SIZE_MENU); | |||
5618 | ||||
5619 | ctk_window_set_default_size (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), | |||
5620 | g_settings_get_int (window->priv->settings_ui, PREF_UI_WINDOW_WIDTH"window-width"), | |||
5621 | g_settings_get_int (window->priv->settings_ui, PREF_UI_WINDOW_HEIGHT"window-height")); | |||
5622 | ||||
5623 | ctk_drag_dest_set (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))), | |||
5624 | CTK_DEST_DEFAULT_ALL, | |||
5625 | target_table, G_N_ELEMENTS (target_table)(sizeof (target_table) / sizeof ((target_table)[0])), | |||
5626 | CDK_ACTION_COPY); | |||
5627 | ||||
5628 | g_signal_connect (G_OBJECT (window),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), (((GType) ((20) << (2))) )))))), ("drag_data_received"), (((GCallback) (fr_window_drag_data_received ))), (window), ((void*)0), (GConnectFlags) 0) | |||
5629 | "drag_data_received",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), (((GType) ((20) << (2))) )))))), ("drag_data_received"), (((GCallback) (fr_window_drag_data_received ))), (window), ((void*)0), (GConnectFlags) 0) | |||
5630 | G_CALLBACK (fr_window_drag_data_received),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), (((GType) ((20) << (2))) )))))), ("drag_data_received"), (((GCallback) (fr_window_drag_data_received ))), (window), ((void*)0), (GConnectFlags) 0) | |||
5631 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), (((GType) ((20) << (2))) )))))), ("drag_data_received"), (((GCallback) (fr_window_drag_data_received ))), (window), ((void*)0), (GConnectFlags) 0); | |||
5632 | g_signal_connect (G_OBJECT (window),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), (((GType) ((20) << (2))) )))))), ("drag_motion"), (((GCallback) (fr_window_drag_motion ))), (window), ((void*)0), (GConnectFlags) 0) | |||
5633 | "drag_motion",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), (((GType) ((20) << (2))) )))))), ("drag_motion"), (((GCallback) (fr_window_drag_motion ))), (window), ((void*)0), (GConnectFlags) 0) | |||
5634 | G_CALLBACK (fr_window_drag_motion),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), (((GType) ((20) << (2))) )))))), ("drag_motion"), (((GCallback) (fr_window_drag_motion ))), (window), ((void*)0), (GConnectFlags) 0) | |||
5635 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), (((GType) ((20) << (2))) )))))), ("drag_motion"), (((GCallback) (fr_window_drag_motion ))), (window), ((void*)0), (GConnectFlags) 0); | |||
5636 | ||||
5637 | g_signal_connect (G_OBJECT (window),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), (((GType) ((20) << (2))) )))))), ("key_press_event"), (((GCallback) (key_press_cb))), ( window), ((void*)0), (GConnectFlags) 0) | |||
5638 | "key_press_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), (((GType) ((20) << (2))) )))))), ("key_press_event"), (((GCallback) (key_press_cb))), ( window), ((void*)0), (GConnectFlags) 0) | |||
5639 | G_CALLBACK (key_press_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), (((GType) ((20) << (2))) )))))), ("key_press_event"), (((GCallback) (key_press_cb))), ( window), ((void*)0), (GConnectFlags) 0) | |||
5640 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), (((GType) ((20) << (2))) )))))), ("key_press_event"), (((GCallback) (key_press_cb))), ( window), ((void*)0), (GConnectFlags) 0); | |||
5641 | ||||
5642 | /* Initialize Data. */ | |||
5643 | ||||
5644 | window->archive = fr_archive_new (); | |||
5645 | g_signal_connect (G_OBJECT (window->archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->archive)), (((GType) ((20) << (2))))))))), ("start"), (((GCallback) (action_started))), (window ), ((void*)0), (GConnectFlags) 0) | |||
5646 | "start",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->archive)), (((GType) ((20) << (2))))))))), ("start"), (((GCallback) (action_started))), (window ), ((void*)0), (GConnectFlags) 0) | |||
5647 | G_CALLBACK (action_started),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->archive)), (((GType) ((20) << (2))))))))), ("start"), (((GCallback) (action_started))), (window ), ((void*)0), (GConnectFlags) 0) | |||
5648 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->archive)), (((GType) ((20) << (2))))))))), ("start"), (((GCallback) (action_started))), (window ), ((void*)0), (GConnectFlags) 0); | |||
5649 | g_signal_connect (G_OBJECT (window->archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->archive)), (((GType) ((20) << (2))))))))), ("done"), (((GCallback) (action_performed))), ( window), ((void*)0), (GConnectFlags) 0) | |||
5650 | "done",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->archive)), (((GType) ((20) << (2))))))))), ("done"), (((GCallback) (action_performed))), ( window), ((void*)0), (GConnectFlags) 0) | |||
5651 | G_CALLBACK (action_performed),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->archive)), (((GType) ((20) << (2))))))))), ("done"), (((GCallback) (action_performed))), ( window), ((void*)0), (GConnectFlags) 0) | |||
5652 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->archive)), (((GType) ((20) << (2))))))))), ("done"), (((GCallback) (action_performed))), ( window), ((void*)0), (GConnectFlags) 0); | |||
5653 | g_signal_connect (G_OBJECT (window->archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->archive)), (((GType) ((20) << (2))))))))), ("progress"), (((GCallback) (fr_window_progress_cb ))), (window), ((void*)0), (GConnectFlags) 0) | |||
5654 | "progress",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->archive)), (((GType) ((20) << (2))))))))), ("progress"), (((GCallback) (fr_window_progress_cb ))), (window), ((void*)0), (GConnectFlags) 0) | |||
5655 | G_CALLBACK (fr_window_progress_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->archive)), (((GType) ((20) << (2))))))))), ("progress"), (((GCallback) (fr_window_progress_cb ))), (window), ((void*)0), (GConnectFlags) 0) | |||
5656 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->archive)), (((GType) ((20) << (2))))))))), ("progress"), (((GCallback) (fr_window_progress_cb ))), (window), ((void*)0), (GConnectFlags) 0); | |||
5657 | g_signal_connect (G_OBJECT (window->archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->archive)), (((GType) ((20) << (2))))))))), ("message"), (((GCallback) (fr_window_message_cb ))), (window), ((void*)0), (GConnectFlags) 0) | |||
5658 | "message",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->archive)), (((GType) ((20) << (2))))))))), ("message"), (((GCallback) (fr_window_message_cb ))), (window), ((void*)0), (GConnectFlags) 0) | |||
5659 | G_CALLBACK (fr_window_message_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->archive)), (((GType) ((20) << (2))))))))), ("message"), (((GCallback) (fr_window_message_cb ))), (window), ((void*)0), (GConnectFlags) 0) | |||
5660 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->archive)), (((GType) ((20) << (2))))))))), ("message"), (((GCallback) (fr_window_message_cb ))), (window), ((void*)0), (GConnectFlags) 0); | |||
5661 | g_signal_connect (G_OBJECT (window->archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->archive)), (((GType) ((20) << (2))))))))), ("stoppable"), (((GCallback) (fr_window_stoppable_cb ))), (window), ((void*)0), (GConnectFlags) 0) | |||
5662 | "stoppable",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->archive)), (((GType) ((20) << (2))))))))), ("stoppable"), (((GCallback) (fr_window_stoppable_cb ))), (window), ((void*)0), (GConnectFlags) 0) | |||
5663 | G_CALLBACK (fr_window_stoppable_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->archive)), (((GType) ((20) << (2))))))))), ("stoppable"), (((GCallback) (fr_window_stoppable_cb ))), (window), ((void*)0), (GConnectFlags) 0) | |||
5664 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->archive)), (((GType) ((20) << (2))))))))), ("stoppable"), (((GCallback) (fr_window_stoppable_cb ))), (window), ((void*)0), (GConnectFlags) 0); | |||
5665 | g_signal_connect (G_OBJECT (window->archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->archive)), (((GType) ((20) << (2))))))))), ("working_archive"), (((GCallback) (fr_window_working_archive_cb ))), (window), ((void*)0), (GConnectFlags) 0) | |||
5666 | "working_archive",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->archive)), (((GType) ((20) << (2))))))))), ("working_archive"), (((GCallback) (fr_window_working_archive_cb ))), (window), ((void*)0), (GConnectFlags) 0) | |||
5667 | G_CALLBACK (fr_window_working_archive_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->archive)), (((GType) ((20) << (2))))))))), ("working_archive"), (((GCallback) (fr_window_working_archive_cb ))), (window), ((void*)0), (GConnectFlags) 0) | |||
5668 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->archive)), (((GType) ((20) << (2))))))))), ("working_archive"), (((GCallback) (fr_window_working_archive_cb ))), (window), ((void*)0), (GConnectFlags) 0); | |||
5669 | ||||
5670 | fr_archive_set_fake_load_func (window->archive, | |||
5671 | fr_window_fake_load, | |||
5672 | window); | |||
5673 | ||||
5674 | window->priv->sort_method = g_settings_get_enum (window->priv->settings_listing, PREF_LISTING_SORT_METHOD"sort-method"); | |||
5675 | window->priv->sort_type = g_settings_get_enum (window->priv->settings_listing, PREF_LISTING_SORT_TYPE"sort-type"); | |||
5676 | ||||
5677 | window->priv->list_mode = window->priv->last_list_mode = g_settings_get_enum (window->priv->settings_listing, PREF_LISTING_LIST_MODE"list-mode"); | |||
5678 | g_settings_set_boolean (window->priv->settings_listing, PREF_LISTING_SHOW_PATH"show-path", (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT)); | |||
5679 | ||||
5680 | window->priv->history = NULL((void*)0); | |||
5681 | window->priv->history_current = NULL((void*)0); | |||
5682 | ||||
5683 | window->priv->action = FR_ACTION_NONE; | |||
5684 | ||||
5685 | window->priv->open_default_dir = g_strdup (get_home_uri ())g_strdup_inline (get_home_uri ()); | |||
5686 | window->priv->add_default_dir = g_strdup (get_home_uri ())g_strdup_inline (get_home_uri ()); | |||
5687 | window->priv->extract_default_dir = g_strdup (get_home_uri ())g_strdup_inline (get_home_uri ()); | |||
5688 | ||||
5689 | window->priv->give_focus_to_the_list = FALSE(0); | |||
5690 | ||||
5691 | window->priv->activity_ref = 0; | |||
5692 | window->priv->activity_timeout_handle = 0; | |||
5693 | ||||
5694 | window->priv->update_timeout_handle = 0; | |||
5695 | ||||
5696 | window->priv->archive_present = FALSE(0); | |||
5697 | window->priv->archive_new = FALSE(0); | |||
5698 | window->priv->archive_uri = NULL((void*)0); | |||
5699 | ||||
5700 | window->priv->drag_destination_folder = NULL((void*)0); | |||
5701 | window->priv->drag_base_dir = NULL((void*)0); | |||
5702 | window->priv->drag_error = NULL((void*)0); | |||
5703 | window->priv->drag_file_list = NULL((void*)0); | |||
5704 | ||||
5705 | window->priv->batch_mode = FALSE(0); | |||
5706 | window->priv->batch_action_list = NULL((void*)0); | |||
5707 | window->priv->batch_action = NULL((void*)0); | |||
5708 | window->priv->extract_interact_use_default_dir = FALSE(0); | |||
5709 | window->priv->non_interactive = FALSE(0); | |||
5710 | ||||
5711 | window->priv->password = NULL((void*)0); | |||
5712 | window->priv->compression = g_settings_get_enum (window->priv->settings_general, PREF_GENERAL_COMPRESSION_LEVEL"compression-level"); | |||
5713 | window->priv->encrypt_header = g_settings_get_boolean (window->priv->settings_general, PREF_GENERAL_ENCRYPT_HEADER"encrypt-header"); | |||
5714 | window->priv->volume_size = 0; | |||
5715 | ||||
5716 | window->priv->convert_data.converting = FALSE(0); | |||
5717 | window->priv->convert_data.temp_dir = NULL((void*)0); | |||
5718 | window->priv->convert_data.new_archive = NULL((void*)0); | |||
5719 | window->priv->convert_data.password = NULL((void*)0); | |||
5720 | window->priv->convert_data.encrypt_header = FALSE(0); | |||
5721 | window->priv->convert_data.volume_size = 0; | |||
5722 | ||||
5723 | window->priv->stoppable = TRUE(!(0)); | |||
5724 | ||||
5725 | window->priv->batch_adding_one_file = FALSE(0); | |||
5726 | ||||
5727 | window->priv->path_clicked = NULL((void*)0); | |||
5728 | ||||
5729 | window->priv->current_view_length = 0; | |||
5730 | ||||
5731 | window->priv->current_batch_action.type = FR_BATCH_ACTION_NONE; | |||
5732 | window->priv->current_batch_action.data = NULL((void*)0); | |||
5733 | window->priv->current_batch_action.free_func = NULL((void*)0); | |||
5734 | ||||
5735 | window->priv->pd_last_archive = NULL((void*)0); | |||
5736 | window->priv->pd_last_message = NULL((void*)0); | |||
5737 | window->priv->pd_last_fraction = 0.0; | |||
5738 | ||||
5739 | /* Create the widgets. */ | |||
5740 | ||||
5741 | /* * File list. */ | |||
5742 | ||||
5743 | window->priv->list_store = fr_list_model_new (NUMBER_OF_COLUMNS, | |||
5744 | G_TYPE_POINTER((GType) ((17) << (2))), | |||
5745 | GDK_TYPE_PIXBUF(gdk_pixbuf_get_type ()), | |||
5746 | G_TYPE_STRING((GType) ((16) << (2))), | |||
5747 | GDK_TYPE_PIXBUF(gdk_pixbuf_get_type ()), | |||
5748 | G_TYPE_STRING((GType) ((16) << (2))), | |||
5749 | G_TYPE_STRING((GType) ((16) << (2))), | |||
5750 | G_TYPE_STRING((GType) ((16) << (2))), | |||
5751 | G_TYPE_STRING((GType) ((16) << (2)))); | |||
5752 | g_object_set_data (G_OBJECT (window->priv->list_store)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_store)), (((GType) ((20) << (2)))))))), "FrWindow", window); | |||
5753 | window->priv->list_view = ctk_tree_view_new_with_model (CTK_TREE_MODEL (window->priv->list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_store)), ((ctk_tree_model_get_type ()))))))); | |||
5754 | ||||
5755 | add_file_list_columns (window, CTK_TREE_VIEW (window->priv->list_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_view)), ((ctk_tree_view_get_type ()))))))); | |||
5756 | ctk_tree_view_set_enable_search (CTK_TREE_VIEW (window->priv->list_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_view)), ((ctk_tree_view_get_type ())))))), | |||
5757 | TRUE(!(0))); | |||
5758 | ctk_tree_view_set_search_column (CTK_TREE_VIEW (window->priv->list_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_view)), ((ctk_tree_view_get_type ())))))), | |||
5759 | COLUMN_NAME); | |||
5760 | ||||
5761 | ctk_tree_sortable_set_sort_func (CTK_TREE_SORTABLE (window->priv->list_store)((((CtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_store)), ((ctk_tree_sortable_get_type ())))))), | |||
5762 | COLUMN_NAME, name_column_sort_func, | |||
5763 | NULL((void*)0), NULL((void*)0)); | |||
5764 | ctk_tree_sortable_set_sort_func (CTK_TREE_SORTABLE (window->priv->list_store)((((CtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_store)), ((ctk_tree_sortable_get_type ())))))), | |||
5765 | COLUMN_SIZE, size_column_sort_func, | |||
5766 | NULL((void*)0), NULL((void*)0)); | |||
5767 | ctk_tree_sortable_set_sort_func (CTK_TREE_SORTABLE (window->priv->list_store)((((CtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_store)), ((ctk_tree_sortable_get_type ())))))), | |||
5768 | COLUMN_TYPE, type_column_sort_func, | |||
5769 | NULL((void*)0), NULL((void*)0)); | |||
5770 | ctk_tree_sortable_set_sort_func (CTK_TREE_SORTABLE (window->priv->list_store)((((CtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_store)), ((ctk_tree_sortable_get_type ())))))), | |||
5771 | COLUMN_TIME, time_column_sort_func, | |||
5772 | NULL((void*)0), NULL((void*)0)); | |||
5773 | ctk_tree_sortable_set_sort_func (CTK_TREE_SORTABLE (window->priv->list_store)((((CtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_store)), ((ctk_tree_sortable_get_type ())))))), | |||
5774 | COLUMN_PATH, path_column_sort_func, | |||
5775 | NULL((void*)0), NULL((void*)0)); | |||
5776 | ||||
5777 | ctk_tree_sortable_set_default_sort_func (CTK_TREE_SORTABLE (window->priv->list_store)((((CtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_store)), ((ctk_tree_sortable_get_type ())))))), | |||
5778 | no_sort_column_sort_func, | |||
5779 | NULL((void*)0), NULL((void*)0)); | |||
5780 | ||||
5781 | selection = ctk_tree_view_get_selection (CTK_TREE_VIEW (window->priv->list_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_view)), ((ctk_tree_view_get_type ()))))))); | |||
5782 | ctk_tree_selection_set_mode (selection, CTK_SELECTION_MULTIPLE); | |||
5783 | ||||
5784 | g_signal_connect (selection,g_signal_connect_data ((selection), ("changed"), (((GCallback ) (selection_changed_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5785 | "changed",g_signal_connect_data ((selection), ("changed"), (((GCallback ) (selection_changed_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5786 | G_CALLBACK (selection_changed_cb),g_signal_connect_data ((selection), ("changed"), (((GCallback ) (selection_changed_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5787 | window)g_signal_connect_data ((selection), ("changed"), (((GCallback ) (selection_changed_cb))), (window), ((void*)0), (GConnectFlags ) 0); | |||
5788 | g_signal_connect (G_OBJECT (window->priv->list_view),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->list_view)), (((GType ) ((20) << (2))))))))), ("row_activated"), (((GCallback ) (row_activated_cb))), (window), ((void*)0), (GConnectFlags) 0) | |||
5789 | "row_activated",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->list_view)), (((GType ) ((20) << (2))))))))), ("row_activated"), (((GCallback ) (row_activated_cb))), (window), ((void*)0), (GConnectFlags) 0) | |||
5790 | G_CALLBACK (row_activated_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->list_view)), (((GType ) ((20) << (2))))))))), ("row_activated"), (((GCallback ) (row_activated_cb))), (window), ((void*)0), (GConnectFlags) 0) | |||
5791 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->list_view)), (((GType ) ((20) << (2))))))))), ("row_activated"), (((GCallback ) (row_activated_cb))), (window), ((void*)0), (GConnectFlags) 0); | |||
5792 | ||||
5793 | g_signal_connect (G_OBJECT (window->priv->list_view),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->list_view)), (((GType ) ((20) << (2))))))))), ("button_press_event"), (((GCallback ) (file_button_press_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5794 | "button_press_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->list_view)), (((GType ) ((20) << (2))))))))), ("button_press_event"), (((GCallback ) (file_button_press_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5795 | G_CALLBACK (file_button_press_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->list_view)), (((GType ) ((20) << (2))))))))), ("button_press_event"), (((GCallback ) (file_button_press_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5796 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->list_view)), (((GType ) ((20) << (2))))))))), ("button_press_event"), (((GCallback ) (file_button_press_cb))), (window), ((void*)0), (GConnectFlags ) 0); | |||
5797 | g_signal_connect (G_OBJECT (window->priv->list_view),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->list_view)), (((GType ) ((20) << (2))))))))), ("button_release_event"), (((GCallback ) (file_button_release_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5798 | "button_release_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->list_view)), (((GType ) ((20) << (2))))))))), ("button_release_event"), (((GCallback ) (file_button_release_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5799 | G_CALLBACK (file_button_release_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->list_view)), (((GType ) ((20) << (2))))))))), ("button_release_event"), (((GCallback ) (file_button_release_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5800 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->list_view)), (((GType ) ((20) << (2))))))))), ("button_release_event"), (((GCallback ) (file_button_release_cb))), (window), ((void*)0), (GConnectFlags ) 0); | |||
5801 | g_signal_connect (G_OBJECT (window->priv->list_view),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->list_view)), (((GType ) ((20) << (2))))))))), ("motion_notify_event"), (((GCallback ) (file_motion_notify_callback))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5802 | "motion_notify_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->list_view)), (((GType ) ((20) << (2))))))))), ("motion_notify_event"), (((GCallback ) (file_motion_notify_callback))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5803 | G_CALLBACK (file_motion_notify_callback),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->list_view)), (((GType ) ((20) << (2))))))))), ("motion_notify_event"), (((GCallback ) (file_motion_notify_callback))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5804 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->list_view)), (((GType ) ((20) << (2))))))))), ("motion_notify_event"), (((GCallback ) (file_motion_notify_callback))), (window), ((void*)0), (GConnectFlags ) 0); | |||
5805 | g_signal_connect (G_OBJECT (window->priv->list_view),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->list_view)), (((GType ) ((20) << (2))))))))), ("leave_notify_event"), (((GCallback ) (file_leave_notify_callback))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5806 | "leave_notify_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->list_view)), (((GType ) ((20) << (2))))))))), ("leave_notify_event"), (((GCallback ) (file_leave_notify_callback))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5807 | G_CALLBACK (file_leave_notify_callback),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->list_view)), (((GType ) ((20) << (2))))))))), ("leave_notify_event"), (((GCallback ) (file_leave_notify_callback))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5808 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->list_view)), (((GType ) ((20) << (2))))))))), ("leave_notify_event"), (((GCallback ) (file_leave_notify_callback))), (window), ((void*)0), (GConnectFlags ) 0); | |||
5809 | ||||
5810 | g_signal_connect (G_OBJECT (window->priv->list_store),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->list_store)), (((GType ) ((20) << (2))))))))), ("sort_column_changed"), (((GCallback ) (sort_column_changed_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5811 | "sort_column_changed",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->list_store)), (((GType ) ((20) << (2))))))))), ("sort_column_changed"), (((GCallback ) (sort_column_changed_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5812 | G_CALLBACK (sort_column_changed_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->list_store)), (((GType ) ((20) << (2))))))))), ("sort_column_changed"), (((GCallback ) (sort_column_changed_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5813 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->list_store)), (((GType ) ((20) << (2))))))))), ("sort_column_changed"), (((GCallback ) (sort_column_changed_cb))), (window), ((void*)0), (GConnectFlags ) 0); | |||
5814 | ||||
5815 | g_signal_connect (G_OBJECT (window->priv->list_view),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->list_view)), (((GType ) ((20) << (2))))))))), ("drag_begin"), (((GCallback) ( file_list_drag_begin))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5816 | "drag_begin",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->list_view)), (((GType ) ((20) << (2))))))))), ("drag_begin"), (((GCallback) ( file_list_drag_begin))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5817 | G_CALLBACK (file_list_drag_begin),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->list_view)), (((GType ) ((20) << (2))))))))), ("drag_begin"), (((GCallback) ( file_list_drag_begin))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5818 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->list_view)), (((GType ) ((20) << (2))))))))), ("drag_begin"), (((GCallback) ( file_list_drag_begin))), (window), ((void*)0), (GConnectFlags ) 0); | |||
5819 | g_signal_connect (G_OBJECT (window->priv->list_view),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->list_view)), (((GType ) ((20) << (2))))))))), ("drag_end"), (((GCallback) (file_list_drag_end ))), (window), ((void*)0), (GConnectFlags) 0) | |||
5820 | "drag_end",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->list_view)), (((GType ) ((20) << (2))))))))), ("drag_end"), (((GCallback) (file_list_drag_end ))), (window), ((void*)0), (GConnectFlags) 0) | |||
5821 | G_CALLBACK (file_list_drag_end),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->list_view)), (((GType ) ((20) << (2))))))))), ("drag_end"), (((GCallback) (file_list_drag_end ))), (window), ((void*)0), (GConnectFlags) 0) | |||
5822 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->list_view)), (((GType ) ((20) << (2))))))))), ("drag_end"), (((GCallback) (file_list_drag_end ))), (window), ((void*)0), (GConnectFlags) 0); | |||
5823 | egg_tree_multi_drag_add_drag_support (CTK_TREE_VIEW (window->priv->list_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_view)), ((ctk_tree_view_get_type ()))))))); | |||
5824 | ||||
5825 | list_scrolled_window = ctk_scrolled_window_new (NULL((void*)0), NULL((void*)0)); | |||
5826 | ctk_scrolled_window_set_policy (CTK_SCROLLED_WINDOW (list_scrolled_window)((((CtkScrolledWindow*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((list_scrolled_window)), ((ctk_scrolled_window_get_type ())))))), | |||
5827 | CTK_POLICY_AUTOMATIC, | |||
5828 | CTK_POLICY_AUTOMATIC); | |||
5829 | ctk_scrolled_window_set_shadow_type (CTK_SCROLLED_WINDOW (list_scrolled_window)((((CtkScrolledWindow*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((list_scrolled_window)), ((ctk_scrolled_window_get_type ())))))), | |||
5830 | CTK_SHADOW_IN); | |||
5831 | ctk_container_add (CTK_CONTAINER (list_scrolled_window)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list_scrolled_window)), ((ctk_container_get_type ()))))) ), window->priv->list_view); | |||
5832 | ||||
5833 | /* filter bar */ | |||
5834 | ||||
5835 | window->priv->filter_bar = filter_box = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 6); | |||
5836 | ctk_container_set_border_width (CTK_CONTAINER (filter_box)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((filter_box)), ((ctk_container_get_type ())))))), 3); | |||
5837 | fr_window_attach (FR_WINDOW (window)((((FrWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((fr_window_get_type ())))))), window->priv->filter_bar, FR_WINDOW_AREA_FILTERBAR); | |||
5838 | ||||
5839 | ctk_box_pack_start (CTK_BOX (filter_box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((filter_box)), ((ctk_box_get_type ())))))), | |||
5840 | ctk_label_new (_("Find:")gettext ("Find:")), FALSE(0), FALSE(0), 0); | |||
5841 | ||||
5842 | /* * filter entry */ | |||
5843 | ||||
5844 | window->priv->filter_entry = CTK_WIDGET (ctk_entry_new ())((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_entry_new ())), ((ctk_widget_get_type ())))))); | |||
5845 | ctk_entry_set_icon_from_icon_name (CTK_ENTRY (window->priv->filter_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->filter_entry)), ((ctk_entry_get_type ())))))), | |||
5846 | CTK_ENTRY_ICON_SECONDARY, | |||
5847 | "edit-clear"); | |||
5848 | ||||
5849 | ctk_widget_set_size_request (window->priv->filter_entry, 300, -1); | |||
5850 | ctk_box_pack_start (CTK_BOX (filter_box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((filter_box)), ((ctk_box_get_type ())))))), | |||
5851 | window->priv->filter_entry, FALSE(0), FALSE(0), 6); | |||
5852 | ||||
5853 | g_signal_connect (G_OBJECT (window->priv->filter_entry),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->filter_entry)), (((GType ) ((20) << (2))))))))), ("activate"), (((GCallback) (filter_entry_activate_cb ))), (window), ((void*)0), (GConnectFlags) 0) | |||
5854 | "activate",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->filter_entry)), (((GType ) ((20) << (2))))))))), ("activate"), (((GCallback) (filter_entry_activate_cb ))), (window), ((void*)0), (GConnectFlags) 0) | |||
5855 | G_CALLBACK (filter_entry_activate_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->filter_entry)), (((GType ) ((20) << (2))))))))), ("activate"), (((GCallback) (filter_entry_activate_cb ))), (window), ((void*)0), (GConnectFlags) 0) | |||
5856 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->filter_entry)), (((GType ) ((20) << (2))))))))), ("activate"), (((GCallback) (filter_entry_activate_cb ))), (window), ((void*)0), (GConnectFlags) 0); | |||
5857 | g_signal_connect (G_OBJECT (window->priv->filter_entry),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->filter_entry)), (((GType ) ((20) << (2))))))))), ("icon-release"), (((GCallback) (filter_entry_icon_release_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5858 | "icon-release",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->filter_entry)), (((GType ) ((20) << (2))))))))), ("icon-release"), (((GCallback) (filter_entry_icon_release_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5859 | G_CALLBACK (filter_entry_icon_release_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->filter_entry)), (((GType ) ((20) << (2))))))))), ("icon-release"), (((GCallback) (filter_entry_icon_release_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5860 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->filter_entry)), (((GType ) ((20) << (2))))))))), ("icon-release"), (((GCallback) (filter_entry_icon_release_cb))), (window), ((void*)0), (GConnectFlags ) 0); | |||
5861 | ||||
5862 | ctk_widget_show_all (filter_box); | |||
5863 | ||||
5864 | /* tree view */ | |||
5865 | ||||
5866 | window->priv->tree_store = ctk_tree_store_new (TREE_NUMBER_OF_COLUMNS, | |||
5867 | G_TYPE_STRING((GType) ((16) << (2))), | |||
5868 | GDK_TYPE_PIXBUF(gdk_pixbuf_get_type ()), | |||
5869 | G_TYPE_STRING((GType) ((16) << (2))), | |||
5870 | PANGO_TYPE_WEIGHT(pango_weight_get_type ())); | |||
5871 | window->priv->tree_view = ctk_tree_view_new_with_model (CTK_TREE_MODEL (window->priv->tree_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->tree_store)), ((ctk_tree_model_get_type ()))))))); | |||
5872 | ctk_tree_view_set_headers_visible (CTK_TREE_VIEW (window->priv->tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->tree_view)), ((ctk_tree_view_get_type ())))))), FALSE(0)); | |||
5873 | add_dir_tree_columns (window, CTK_TREE_VIEW (window->priv->tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->tree_view)), ((ctk_tree_view_get_type ()))))))); | |||
5874 | ||||
5875 | g_signal_connect (G_OBJECT (window->priv->tree_view),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->tree_view)), (((GType ) ((20) << (2))))))))), ("button_press_event"), (((GCallback ) (dir_tree_button_press_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5876 | "button_press_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->tree_view)), (((GType ) ((20) << (2))))))))), ("button_press_event"), (((GCallback ) (dir_tree_button_press_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5877 | G_CALLBACK (dir_tree_button_press_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->tree_view)), (((GType ) ((20) << (2))))))))), ("button_press_event"), (((GCallback ) (dir_tree_button_press_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5878 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->tree_view)), (((GType ) ((20) << (2))))))))), ("button_press_event"), (((GCallback ) (dir_tree_button_press_cb))), (window), ((void*)0), (GConnectFlags ) 0); | |||
5879 | ||||
5880 | selection = ctk_tree_view_get_selection (CTK_TREE_VIEW (window->priv->tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->tree_view)), ((ctk_tree_view_get_type ()))))))); | |||
5881 | g_signal_connect (selection,g_signal_connect_data ((selection), ("changed"), (((GCallback ) (dir_tree_selection_changed_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5882 | "changed",g_signal_connect_data ((selection), ("changed"), (((GCallback ) (dir_tree_selection_changed_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5883 | G_CALLBACK (dir_tree_selection_changed_cb),g_signal_connect_data ((selection), ("changed"), (((GCallback ) (dir_tree_selection_changed_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5884 | window)g_signal_connect_data ((selection), ("changed"), (((GCallback ) (dir_tree_selection_changed_cb))), (window), ((void*)0), (GConnectFlags ) 0); | |||
5885 | ||||
5886 | g_signal_connect (G_OBJECT (window->priv->tree_view),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->tree_view)), (((GType ) ((20) << (2))))))))), ("drag_begin"), (((GCallback) ( file_list_drag_begin))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5887 | "drag_begin",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->tree_view)), (((GType ) ((20) << (2))))))))), ("drag_begin"), (((GCallback) ( file_list_drag_begin))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5888 | G_CALLBACK (file_list_drag_begin),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->tree_view)), (((GType ) ((20) << (2))))))))), ("drag_begin"), (((GCallback) ( file_list_drag_begin))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5889 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->tree_view)), (((GType ) ((20) << (2))))))))), ("drag_begin"), (((GCallback) ( file_list_drag_begin))), (window), ((void*)0), (GConnectFlags ) 0); | |||
5890 | g_signal_connect (G_OBJECT (window->priv->tree_view),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->tree_view)), (((GType ) ((20) << (2))))))))), ("drag_end"), (((GCallback) (file_list_drag_end ))), (window), ((void*)0), (GConnectFlags) 0) | |||
5891 | "drag_end",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->tree_view)), (((GType ) ((20) << (2))))))))), ("drag_end"), (((GCallback) (file_list_drag_end ))), (window), ((void*)0), (GConnectFlags) 0) | |||
5892 | G_CALLBACK (file_list_drag_end),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->tree_view)), (((GType ) ((20) << (2))))))))), ("drag_end"), (((GCallback) (file_list_drag_end ))), (window), ((void*)0), (GConnectFlags) 0) | |||
5893 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->tree_view)), (((GType ) ((20) << (2))))))))), ("drag_end"), (((GCallback) (file_list_drag_end ))), (window), ((void*)0), (GConnectFlags) 0); | |||
5894 | g_signal_connect (G_OBJECT (window->priv->tree_view),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->tree_view)), (((GType ) ((20) << (2))))))))), ("drag_data_get"), (((GCallback ) (fr_window_folder_tree_drag_data_get))), (window), ((void*) 0), (GConnectFlags) 0) | |||
5895 | "drag_data_get",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->tree_view)), (((GType ) ((20) << (2))))))))), ("drag_data_get"), (((GCallback ) (fr_window_folder_tree_drag_data_get))), (window), ((void*) 0), (GConnectFlags) 0) | |||
5896 | G_CALLBACK (fr_window_folder_tree_drag_data_get),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->tree_view)), (((GType ) ((20) << (2))))))))), ("drag_data_get"), (((GCallback ) (fr_window_folder_tree_drag_data_get))), (window), ((void*) 0), (GConnectFlags) 0) | |||
5897 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->tree_view)), (((GType ) ((20) << (2))))))))), ("drag_data_get"), (((GCallback ) (fr_window_folder_tree_drag_data_get))), (window), ((void*) 0), (GConnectFlags) 0); | |||
5898 | ctk_drag_source_set (window->priv->tree_view, | |||
5899 | CDK_BUTTON1_MASK, | |||
5900 | folder_tree_targets, G_N_ELEMENTS (folder_tree_targets)(sizeof (folder_tree_targets) / sizeof ((folder_tree_targets) [0])), | |||
5901 | CDK_ACTION_COPY); | |||
5902 | ||||
5903 | tree_scrolled_window = ctk_scrolled_window_new (NULL((void*)0), NULL((void*)0)); | |||
5904 | ctk_scrolled_window_set_policy (CTK_SCROLLED_WINDOW (tree_scrolled_window)((((CtkScrolledWindow*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((tree_scrolled_window)), ((ctk_scrolled_window_get_type ())))))), | |||
5905 | CTK_POLICY_AUTOMATIC, | |||
5906 | CTK_POLICY_AUTOMATIC); | |||
5907 | ctk_scrolled_window_set_shadow_type (CTK_SCROLLED_WINDOW (tree_scrolled_window)((((CtkScrolledWindow*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((tree_scrolled_window)), ((ctk_scrolled_window_get_type ())))))), | |||
5908 | CTK_SHADOW_IN); | |||
5909 | ctk_container_add (CTK_CONTAINER (tree_scrolled_window)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tree_scrolled_window)), ((ctk_container_get_type ()))))) ), window->priv->tree_view); | |||
5910 | ||||
5911 | /* side pane */ | |||
5912 | ||||
5913 | window->priv->sidepane = ctk_box_new (CTK_ORIENTATION_VERTICAL, 0); | |||
5914 | ||||
5915 | sidepane_title = ctk_frame_new (NULL((void*)0)); | |||
5916 | ctk_frame_set_shadow_type (CTK_FRAME (sidepane_title)((((CtkFrame*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((sidepane_title)), ((ctk_frame_get_type ())))))), CTK_SHADOW_ETCHED_IN); | |||
5917 | ||||
5918 | sidepane_title_box = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 0); | |||
5919 | ctk_container_set_border_width (CTK_CONTAINER (sidepane_title_box)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((sidepane_title_box)), ((ctk_container_get_type ())))))), 2); | |||
5920 | ctk_container_add (CTK_CONTAINER (sidepane_title)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((sidepane_title)), ((ctk_container_get_type ())))))), sidepane_title_box); | |||
5921 | sidepane_title_label = ctk_label_new (_("Folders")gettext ("Folders")); | |||
5922 | ||||
5923 | ctk_label_set_xalign (CTK_LABEL (sidepane_title_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((sidepane_title_label)), ((ctk_label_get_type ())))))), 0.0); | |||
5924 | ctk_box_pack_start (CTK_BOX (sidepane_title_box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((sidepane_title_box)), ((ctk_box_get_type ())))))), sidepane_title_label, TRUE(!(0)), TRUE(!(0)), 0); | |||
5925 | ||||
5926 | close_sidepane_button = ctk_button_new (); | |||
5927 | ctk_container_add (CTK_CONTAINER (close_sidepane_button)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((close_sidepane_button)), ((ctk_container_get_type ())))) )), | |||
5928 | ctk_image_new_from_icon_name ("window-close", | |||
5929 | CTK_ICON_SIZE_MENU)); | |||
5930 | ctk_button_set_relief (CTK_BUTTON (close_sidepane_button)((((CtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((close_sidepane_button)), ((ctk_button_get_type ())))))), CTK_RELIEF_NONE); | |||
5931 | ctk_widget_set_tooltip_text (close_sidepane_button, _("Close the folders pane")gettext ("Close the folders pane")); | |||
5932 | g_signal_connect (close_sidepane_button,g_signal_connect_data ((close_sidepane_button), ("clicked"), ( ((GCallback) (close_sidepane_button_clicked_cb))), (window), ( (void*)0), (GConnectFlags) 0) | |||
5933 | "clicked",g_signal_connect_data ((close_sidepane_button), ("clicked"), ( ((GCallback) (close_sidepane_button_clicked_cb))), (window), ( (void*)0), (GConnectFlags) 0) | |||
5934 | G_CALLBACK (close_sidepane_button_clicked_cb),g_signal_connect_data ((close_sidepane_button), ("clicked"), ( ((GCallback) (close_sidepane_button_clicked_cb))), (window), ( (void*)0), (GConnectFlags) 0) | |||
5935 | window)g_signal_connect_data ((close_sidepane_button), ("clicked"), ( ((GCallback) (close_sidepane_button_clicked_cb))), (window), ( (void*)0), (GConnectFlags) 0); | |||
5936 | ctk_box_pack_end (CTK_BOX (sidepane_title_box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((sidepane_title_box)), ((ctk_box_get_type ())))))), close_sidepane_button, FALSE(0), FALSE(0), 0); | |||
5937 | ||||
5938 | ctk_box_pack_start (CTK_BOX (window->priv->sidepane)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->sidepane)), ((ctk_box_get_type ()))) ))), sidepane_title, FALSE(0), FALSE(0), 0); | |||
5939 | ctk_box_pack_start (CTK_BOX (window->priv->sidepane)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->sidepane)), ((ctk_box_get_type ()))) ))), tree_scrolled_window, TRUE(!(0)), TRUE(!(0)), 0); | |||
5940 | ||||
5941 | /* main content */ | |||
5942 | ||||
5943 | window->priv->paned = ctk_paned_new (CTK_ORIENTATION_HORIZONTAL); | |||
5944 | ctk_paned_pack1 (CTK_PANED (window->priv->paned)((((CtkPaned*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->paned)), ((ctk_paned_get_type ())))) )), window->priv->sidepane, FALSE(0), TRUE(!(0))); | |||
5945 | ctk_paned_pack2 (CTK_PANED (window->priv->paned)((((CtkPaned*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->paned)), ((ctk_paned_get_type ())))) )), list_scrolled_window, TRUE(!(0)), TRUE(!(0))); | |||
5946 | ctk_paned_set_position (CTK_PANED (window->priv->paned)((((CtkPaned*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->paned)), ((ctk_paned_get_type ())))) )), g_settings_get_int (window->priv->settings_ui, PREF_UI_SIDEBAR_WIDTH"sidebar-width")); | |||
5947 | ||||
5948 | fr_window_attach (FR_WINDOW (window)((((FrWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((fr_window_get_type ())))))), window->priv->paned, FR_WINDOW_AREA_CONTENTS); | |||
5949 | ctk_widget_show_all (window->priv->paned); | |||
5950 | ||||
5951 | /* Build the menu and the toolbar. */ | |||
5952 | ||||
5953 | ui = ctk_ui_manager_new (); | |||
5954 | ||||
5955 | window->priv->actions = actions = ctk_action_group_new ("Actions"); | |||
5956 | ||||
5957 | /* open recent toolbar item action */ | |||
5958 | ||||
5959 | action = g_object_new (CTK_TYPE_RECENT_ACTION(ctk_recent_action_get_type ()), | |||
5960 | "name", "OpenRecent", | |||
5961 | /* Translators: this is the label for the "open recent file" sub-menu. */ | |||
5962 | "label", _("Open _Recent")gettext ("Open _Recent"), | |||
5963 | "tooltip", _("Open a recently used archive")gettext ("Open a recently used archive"), | |||
5964 | "icon-name", "document-open", | |||
5965 | NULL((void*)0)); | |||
5966 | fr_window_init_recent_chooser (window, CTK_RECENT_CHOOSER (action)((((CtkRecentChooser*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((action)), ((ctk_recent_chooser_get_type ()) )))))); | |||
5967 | ctk_action_group_add_action (actions, action); | |||
5968 | g_object_unref (action); | |||
5969 | ||||
5970 | /* open recent toolbar item action */ | |||
5971 | ||||
5972 | action = g_object_new (CTK_TYPE_RECENT_ACTION(ctk_recent_action_get_type ()), | |||
5973 | "name", "OpenRecent_Toolbar", | |||
5974 | "label", _("Open")gettext ("Open"), | |||
5975 | "tooltip", _("Open a recently used archive")gettext ("Open a recently used archive"), | |||
5976 | "icon-name", "document-open", | |||
5977 | "is-important", TRUE(!(0)), | |||
5978 | NULL((void*)0)); | |||
5979 | fr_window_init_recent_chooser (window, CTK_RECENT_CHOOSER (action)((((CtkRecentChooser*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((action)), ((ctk_recent_chooser_get_type ()) )))))); | |||
5980 | g_signal_connect (action,g_signal_connect_data ((action), ("activate"), (((GCallback) ( activate_action_open))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5981 | "activate",g_signal_connect_data ((action), ("activate"), (((GCallback) ( activate_action_open))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5982 | G_CALLBACK (activate_action_open),g_signal_connect_data ((action), ("activate"), (((GCallback) ( activate_action_open))), (window), ((void*)0), (GConnectFlags ) 0) | |||
5983 | window)g_signal_connect_data ((action), ("activate"), (((GCallback) ( activate_action_open))), (window), ((void*)0), (GConnectFlags ) 0); | |||
5984 | ctk_action_group_add_action (actions, action); | |||
5985 | g_object_unref (action); | |||
5986 | ||||
5987 | /* other actions */ | |||
5988 | ||||
5989 | ctk_action_group_set_translation_domain (actions, NULL((void*)0)); | |||
5990 | ctk_action_group_add_actions (actions, | |||
5991 | action_entries, | |||
5992 | n_action_entries, | |||
5993 | window); | |||
5994 | ctk_action_group_add_toggle_actions (actions, | |||
5995 | action_toggle_entries, | |||
5996 | n_action_toggle_entries, | |||
5997 | window); | |||
5998 | ctk_action_group_add_radio_actions (actions, | |||
5999 | view_as_entries, | |||
6000 | n_view_as_entries, | |||
6001 | window->priv->list_mode, | |||
6002 | G_CALLBACK (view_as_radio_action)((GCallback) (view_as_radio_action)), | |||
6003 | window); | |||
6004 | ctk_action_group_add_radio_actions (actions, | |||
6005 | sort_by_entries, | |||
6006 | n_sort_by_entries, | |||
6007 | window->priv->sort_type, | |||
6008 | G_CALLBACK (sort_by_radio_action)((GCallback) (sort_by_radio_action)), | |||
6009 | window); | |||
6010 | ||||
6011 | g_signal_connect (ui, "connect_proxy",g_signal_connect_data ((ui), ("connect_proxy"), (((GCallback) (connect_proxy_cb))), (window), ((void*)0), (GConnectFlags) 0 ) | |||
6012 | G_CALLBACK (connect_proxy_cb), window)g_signal_connect_data ((ui), ("connect_proxy"), (((GCallback) (connect_proxy_cb))), (window), ((void*)0), (GConnectFlags) 0 ); | |||
6013 | g_signal_connect (ui, "disconnect_proxy",g_signal_connect_data ((ui), ("disconnect_proxy"), (((GCallback ) (disconnect_proxy_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
6014 | G_CALLBACK (disconnect_proxy_cb), window)g_signal_connect_data ((ui), ("disconnect_proxy"), (((GCallback ) (disconnect_proxy_cb))), (window), ((void*)0), (GConnectFlags ) 0); | |||
6015 | ||||
6016 | ctk_ui_manager_insert_action_group (ui, actions, 0); | |||
6017 | ctk_window_add_accel_group (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), | |||
6018 | ctk_ui_manager_get_accel_group (ui)); | |||
6019 | ||||
6020 | /* Add a hidden short cut Ctrl-Q for power users */ | |||
6021 | ctk_accel_group_connect (ctk_ui_manager_get_accel_group (ui), | |||
6022 | CDK_KEY_q0x071, CDK_CONTROL_MASK, 0, | |||
6023 | g_cclosure_new_swap (G_CALLBACK (fr_window_close)((GCallback) (fr_window_close)), window, NULL((void*)0))); | |||
6024 | ||||
6025 | ||||
6026 | if (! ctk_ui_manager_add_ui_from_resource (ui, GRAPA_RESOURCE_UI_PATH"/org/cafe/Grapa/ui" G_DIR_SEPARATOR_S"/" "menus-toolbars.ui", &error)) { | |||
6027 | g_message ("building menus failed: %s", error->message); | |||
6028 | g_error_free (error); | |||
6029 | } | |||
6030 | ||||
6031 | menubar = ctk_ui_manager_get_widget (ui, "/MenuBar"); | |||
6032 | fr_window_attach (FR_WINDOW (window)((((FrWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((fr_window_get_type ())))))), menubar, FR_WINDOW_AREA_MENUBAR); | |||
6033 | ctk_widget_show (menubar); | |||
6034 | ||||
6035 | window->priv->toolbar = toolbar = ctk_ui_manager_get_widget (ui, "/ToolBar"); | |||
6036 | ctk_toolbar_set_show_arrow (CTK_TOOLBAR (toolbar)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((toolbar)), ((ctk_toolbar_get_type ())))))), TRUE(!(0))); | |||
6037 | ctk_style_context_add_class (ctk_widget_get_style_context (toolbar), CTK_STYLE_CLASS_PRIMARY_TOOLBAR"primary-toolbar"); | |||
6038 | set_action_important (ui, "/ToolBar/Extract_Toolbar"); | |||
6039 | ||||
6040 | /* location bar */ | |||
6041 | ||||
6042 | window->priv->location_bar = ctk_ui_manager_get_widget (ui, "/LocationBar"); | |||
6043 | ctk_toolbar_set_show_arrow (CTK_TOOLBAR (window->priv->location_bar)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->location_bar)), ((ctk_toolbar_get_type ())))))), FALSE(0)); | |||
6044 | ctk_toolbar_set_style (CTK_TOOLBAR (window->priv->location_bar)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->location_bar)), ((ctk_toolbar_get_type ())))))), CTK_TOOLBAR_BOTH_HORIZ); | |||
6045 | ctk_style_context_add_class (ctk_widget_get_style_context (window->priv->location_bar), CTK_STYLE_CLASS_TOOLBAR"toolbar"); | |||
6046 | set_action_important (ui, "/LocationBar/GoBack"); | |||
6047 | ||||
6048 | /* current location */ | |||
6049 | ||||
6050 | location_box = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 6); | |||
6051 | /* Translators: after the colon there is a folder name. */ | |||
6052 | window->priv->location_label = ctk_label_new_with_mnemonic (_("_Location:")gettext ("_Location:")); | |||
6053 | ctk_box_pack_start (CTK_BOX (location_box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((location_box)), ((ctk_box_get_type ())))))), | |||
6054 | window->priv->location_label, FALSE(0), FALSE(0), 5); | |||
6055 | ||||
6056 | window->priv->location_entry = ctk_entry_new (); | |||
6057 | ctk_entry_set_icon_from_icon_name (CTK_ENTRY (window->priv->location_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->location_entry)), ((ctk_entry_get_type ())))))), | |||
6058 | CTK_ENTRY_ICON_PRIMARY, | |||
6059 | "folder"); | |||
6060 | ||||
6061 | ctk_box_pack_start (CTK_BOX (location_box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((location_box)), ((ctk_box_get_type ())))))), | |||
6062 | window->priv->location_entry, TRUE(!(0)), TRUE(!(0)), 5); | |||
6063 | ||||
6064 | g_signal_connect (G_OBJECT (window->priv->location_entry),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->location_entry)), (( (GType) ((20) << (2))))))))), ("key_press_event"), (((GCallback ) (location_entry_key_press_event_cb))), (window), ((void*)0) , (GConnectFlags) 0) | |||
6065 | "key_press_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->location_entry)), (( (GType) ((20) << (2))))))))), ("key_press_event"), (((GCallback ) (location_entry_key_press_event_cb))), (window), ((void*)0) , (GConnectFlags) 0) | |||
6066 | G_CALLBACK (location_entry_key_press_event_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->location_entry)), (( (GType) ((20) << (2))))))))), ("key_press_event"), (((GCallback ) (location_entry_key_press_event_cb))), (window), ((void*)0) , (GConnectFlags) 0) | |||
6067 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->location_entry)), (( (GType) ((20) << (2))))))))), ("key_press_event"), (((GCallback ) (location_entry_key_press_event_cb))), (window), ((void*)0) , (GConnectFlags) 0); | |||
6068 | ||||
6069 | { | |||
6070 | CtkToolItem *tool_item; | |||
6071 | ||||
6072 | tool_item = ctk_separator_tool_item_new (); | |||
6073 | ctk_widget_show_all (CTK_WIDGET (tool_item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tool_item)), ((ctk_widget_get_type ()))))))); | |||
6074 | ctk_toolbar_insert (CTK_TOOLBAR (window->priv->location_bar)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->location_bar)), ((ctk_toolbar_get_type ())))))), tool_item, -1); | |||
6075 | ||||
6076 | tool_item = ctk_tool_item_new (); | |||
6077 | ctk_tool_item_set_expand (tool_item, TRUE(!(0))); | |||
6078 | ctk_container_add (CTK_CONTAINER (tool_item)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tool_item)), ((ctk_container_get_type ())))))), location_box); | |||
6079 | ctk_widget_show_all (CTK_WIDGET (tool_item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tool_item)), ((ctk_widget_get_type ()))))))); | |||
6080 | ctk_toolbar_insert (CTK_TOOLBAR (window->priv->location_bar)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->location_bar)), ((ctk_toolbar_get_type ())))))), tool_item, -1); | |||
6081 | } | |||
6082 | ||||
6083 | fr_window_attach (FR_WINDOW (window)((((FrWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((fr_window_get_type ())))))), window->priv->location_bar, FR_WINDOW_AREA_LOCATIONBAR); | |||
6084 | if (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT) | |||
6085 | ctk_widget_hide (window->priv->location_bar); | |||
6086 | else | |||
6087 | ctk_widget_show (window->priv->location_bar); | |||
6088 | ||||
6089 | /**/ | |||
6090 | ||||
6091 | fr_window_attach (FR_WINDOW (window)((((FrWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((fr_window_get_type ())))))), window->priv->toolbar, FR_WINDOW_AREA_TOOLBAR); | |||
6092 | if (g_settings_get_boolean (window->priv->settings_ui, PREF_UI_VIEW_TOOLBAR"view-toolbar")) | |||
6093 | ctk_widget_show (toolbar); | |||
6094 | else | |||
6095 | ctk_widget_hide (toolbar); | |||
6096 | ||||
6097 | window->priv->file_popup_menu = ctk_ui_manager_get_widget (ui, "/FilePopupMenu"); | |||
6098 | window->priv->folder_popup_menu = ctk_ui_manager_get_widget (ui, "/FolderPopupMenu"); | |||
6099 | window->priv->sidebar_folder_popup_menu = ctk_ui_manager_get_widget (ui, "/SidebarFolderPopupMenu"); | |||
6100 | ||||
6101 | /* Create the statusbar. */ | |||
6102 | ||||
6103 | window->priv->statusbar = ctk_statusbar_new (); | |||
6104 | window->priv->help_message_cid = ctk_statusbar_get_context_id (CTK_STATUSBAR (window->priv->statusbar)((((CtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->statusbar)), ((ctk_statusbar_get_type ())))))), "help_message"); | |||
6105 | window->priv->list_info_cid = ctk_statusbar_get_context_id (CTK_STATUSBAR (window->priv->statusbar)((((CtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->statusbar)), ((ctk_statusbar_get_type ())))))), "list_info"); | |||
6106 | window->priv->progress_cid = ctk_statusbar_get_context_id (CTK_STATUSBAR (window->priv->statusbar)((((CtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->statusbar)), ((ctk_statusbar_get_type ())))))), "progress"); | |||
6107 | ||||
6108 | statusbar = CTK_STATUSBAR (window->priv->statusbar)((((CtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->statusbar)), ((ctk_statusbar_get_type ())))))); | |||
6109 | ||||
6110 | /*reduce size of statusbar */ | |||
6111 | ctk_widget_set_margin_top (CTK_WIDGET (statusbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((statusbar)), ((ctk_widget_get_type ())))))), 0); | |||
6112 | ctk_widget_set_margin_bottom (CTK_WIDGET (statusbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((statusbar)), ((ctk_widget_get_type ())))))), 0); | |||
6113 | ||||
6114 | statusbar_box = ctk_statusbar_get_message_area (statusbar); | |||
6115 | ctk_box_set_homogeneous (CTK_BOX (statusbar_box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((statusbar_box)), ((ctk_box_get_type ())))))), FALSE(0)); | |||
6116 | ctk_box_set_spacing (CTK_BOX (statusbar_box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((statusbar_box)), ((ctk_box_get_type ())))))), 4); | |||
6117 | ctk_box_set_child_packing (CTK_BOX (statusbar_box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((statusbar_box)), ((ctk_box_get_type ())))))), ctk_statusbar_get_message_area (statusbar), TRUE(!(0)), TRUE(!(0)), 0, CTK_PACK_START ); | |||
6118 | ||||
6119 | window->priv->progress_bar = ctk_progress_bar_new (); | |||
6120 | ctk_progress_bar_set_pulse_step (CTK_PROGRESS_BAR (window->priv->progress_bar)((((CtkProgressBar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->progress_bar)), ((ctk_progress_bar_get_type ())))))), ACTIVITY_PULSE_STEP(0.033)); | |||
6121 | ctk_widget_set_size_request (window->priv->progress_bar, -1, PROGRESS_BAR_HEIGHT10); | |||
6122 | { | |||
6123 | CtkWidget *vbox; | |||
6124 | ||||
6125 | vbox = ctk_box_new (CTK_ORIENTATION_VERTICAL, 0); | |||
6126 | ctk_box_pack_start (CTK_BOX (statusbar_box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((statusbar_box)), ((ctk_box_get_type ())))))), vbox, FALSE(0), FALSE(0), 0); | |||
6127 | ctk_box_pack_start (CTK_BOX (vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((vbox)), ((ctk_box_get_type ())))))), window->priv->progress_bar, TRUE(!(0)), TRUE(!(0)), 1); | |||
6128 | ctk_widget_show (vbox); | |||
6129 | } | |||
6130 | ctk_widget_show (statusbar_box); | |||
6131 | ||||
6132 | fr_window_attach (FR_WINDOW (window)((((FrWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((fr_window_get_type ())))))), window->priv->statusbar, FR_WINDOW_AREA_STATUSBAR); | |||
6133 | if (g_settings_get_boolean (window->priv->settings_ui, PREF_UI_VIEW_STATUSBAR"view-statusbar")) | |||
6134 | ctk_widget_show (window->priv->statusbar); | |||
6135 | else | |||
6136 | ctk_widget_hide (window->priv->statusbar); | |||
6137 | ||||
6138 | /**/ | |||
6139 | ||||
6140 | fr_window_update_title (window); | |||
6141 | fr_window_update_sensitivity (window); | |||
6142 | fr_window_update_file_list (window, FALSE(0)); | |||
6143 | fr_window_update_dir_tree (window); | |||
6144 | fr_window_update_current_location (window); | |||
6145 | fr_window_update_columns_visibility (window); | |||
6146 | ||||
6147 | /* Add notification callbacks. */ | |||
6148 | ||||
6149 | g_signal_connect (window->priv->settings_ui,g_signal_connect_data ((window->priv->settings_ui), ("changed::" "history-len"), (((GCallback) (pref_history_len_changed))), ( window), ((void*)0), (GConnectFlags) 0) | |||
6150 | "changed::" PREF_UI_HISTORY_LEN,g_signal_connect_data ((window->priv->settings_ui), ("changed::" "history-len"), (((GCallback) (pref_history_len_changed))), ( window), ((void*)0), (GConnectFlags) 0) | |||
6151 | G_CALLBACK (pref_history_len_changed),g_signal_connect_data ((window->priv->settings_ui), ("changed::" "history-len"), (((GCallback) (pref_history_len_changed))), ( window), ((void*)0), (GConnectFlags) 0) | |||
6152 | window)g_signal_connect_data ((window->priv->settings_ui), ("changed::" "history-len"), (((GCallback) (pref_history_len_changed))), ( window), ((void*)0), (GConnectFlags) 0); | |||
6153 | g_signal_connect (window->priv->settings_ui,g_signal_connect_data ((window->priv->settings_ui), ("changed::" "view-toolbar"), (((GCallback) (pref_view_toolbar_changed))) , (window), ((void*)0), (GConnectFlags) 0) | |||
6154 | "changed::" PREF_UI_VIEW_TOOLBAR,g_signal_connect_data ((window->priv->settings_ui), ("changed::" "view-toolbar"), (((GCallback) (pref_view_toolbar_changed))) , (window), ((void*)0), (GConnectFlags) 0) | |||
6155 | G_CALLBACK (pref_view_toolbar_changed),g_signal_connect_data ((window->priv->settings_ui), ("changed::" "view-toolbar"), (((GCallback) (pref_view_toolbar_changed))) , (window), ((void*)0), (GConnectFlags) 0) | |||
6156 | window)g_signal_connect_data ((window->priv->settings_ui), ("changed::" "view-toolbar"), (((GCallback) (pref_view_toolbar_changed))) , (window), ((void*)0), (GConnectFlags) 0); | |||
6157 | g_signal_connect (window->priv->settings_ui,g_signal_connect_data ((window->priv->settings_ui), ("changed::" "view-statusbar"), (((GCallback) (pref_view_statusbar_changed ))), (window), ((void*)0), (GConnectFlags) 0) | |||
6158 | "changed::" PREF_UI_VIEW_STATUSBAR,g_signal_connect_data ((window->priv->settings_ui), ("changed::" "view-statusbar"), (((GCallback) (pref_view_statusbar_changed ))), (window), ((void*)0), (GConnectFlags) 0) | |||
6159 | G_CALLBACK (pref_view_statusbar_changed),g_signal_connect_data ((window->priv->settings_ui), ("changed::" "view-statusbar"), (((GCallback) (pref_view_statusbar_changed ))), (window), ((void*)0), (GConnectFlags) 0) | |||
6160 | window)g_signal_connect_data ((window->priv->settings_ui), ("changed::" "view-statusbar"), (((GCallback) (pref_view_statusbar_changed ))), (window), ((void*)0), (GConnectFlags) 0); | |||
6161 | g_signal_connect (window->priv->settings_ui,g_signal_connect_data ((window->priv->settings_ui), ("changed::" "view-folders"), (((GCallback) (pref_view_folders_changed))) , (window), ((void*)0), (GConnectFlags) 0) | |||
6162 | "changed::" PREF_UI_VIEW_FOLDERS,g_signal_connect_data ((window->priv->settings_ui), ("changed::" "view-folders"), (((GCallback) (pref_view_folders_changed))) , (window), ((void*)0), (GConnectFlags) 0) | |||
6163 | G_CALLBACK (pref_view_folders_changed),g_signal_connect_data ((window->priv->settings_ui), ("changed::" "view-folders"), (((GCallback) (pref_view_folders_changed))) , (window), ((void*)0), (GConnectFlags) 0) | |||
6164 | window)g_signal_connect_data ((window->priv->settings_ui), ("changed::" "view-folders"), (((GCallback) (pref_view_folders_changed))) , (window), ((void*)0), (GConnectFlags) 0); | |||
6165 | g_signal_connect (window->priv->settings_listing,g_signal_connect_data ((window->priv->settings_listing) , ("changed::" "show-type"), (((GCallback) (pref_show_field_changed ))), (window), ((void*)0), (GConnectFlags) 0) | |||
6166 | "changed::" PREF_LISTING_SHOW_TYPE,g_signal_connect_data ((window->priv->settings_listing) , ("changed::" "show-type"), (((GCallback) (pref_show_field_changed ))), (window), ((void*)0), (GConnectFlags) 0) | |||
6167 | G_CALLBACK (pref_show_field_changed),g_signal_connect_data ((window->priv->settings_listing) , ("changed::" "show-type"), (((GCallback) (pref_show_field_changed ))), (window), ((void*)0), (GConnectFlags) 0) | |||
6168 | window)g_signal_connect_data ((window->priv->settings_listing) , ("changed::" "show-type"), (((GCallback) (pref_show_field_changed ))), (window), ((void*)0), (GConnectFlags) 0); | |||
6169 | g_signal_connect (window->priv->settings_listing,g_signal_connect_data ((window->priv->settings_listing) , ("changed::" "show-size"), (((GCallback) (pref_show_field_changed ))), (window), ((void*)0), (GConnectFlags) 0) | |||
6170 | "changed::" PREF_LISTING_SHOW_SIZE,g_signal_connect_data ((window->priv->settings_listing) , ("changed::" "show-size"), (((GCallback) (pref_show_field_changed ))), (window), ((void*)0), (GConnectFlags) 0) | |||
6171 | G_CALLBACK (pref_show_field_changed),g_signal_connect_data ((window->priv->settings_listing) , ("changed::" "show-size"), (((GCallback) (pref_show_field_changed ))), (window), ((void*)0), (GConnectFlags) 0) | |||
6172 | window)g_signal_connect_data ((window->priv->settings_listing) , ("changed::" "show-size"), (((GCallback) (pref_show_field_changed ))), (window), ((void*)0), (GConnectFlags) 0); | |||
6173 | g_signal_connect (window->priv->settings_listing,g_signal_connect_data ((window->priv->settings_listing) , ("changed::" "show-time"), (((GCallback) (pref_show_field_changed ))), (window), ((void*)0), (GConnectFlags) 0) | |||
6174 | "changed::" PREF_LISTING_SHOW_TIME,g_signal_connect_data ((window->priv->settings_listing) , ("changed::" "show-time"), (((GCallback) (pref_show_field_changed ))), (window), ((void*)0), (GConnectFlags) 0) | |||
6175 | G_CALLBACK (pref_show_field_changed),g_signal_connect_data ((window->priv->settings_listing) , ("changed::" "show-time"), (((GCallback) (pref_show_field_changed ))), (window), ((void*)0), (GConnectFlags) 0) | |||
6176 | window)g_signal_connect_data ((window->priv->settings_listing) , ("changed::" "show-time"), (((GCallback) (pref_show_field_changed ))), (window), ((void*)0), (GConnectFlags) 0); | |||
6177 | g_signal_connect (window->priv->settings_listing,g_signal_connect_data ((window->priv->settings_listing) , ("changed::" "show-path"), (((GCallback) (pref_show_field_changed ))), (window), ((void*)0), (GConnectFlags) 0) | |||
6178 | "changed::" PREF_LISTING_SHOW_PATH,g_signal_connect_data ((window->priv->settings_listing) , ("changed::" "show-path"), (((GCallback) (pref_show_field_changed ))), (window), ((void*)0), (GConnectFlags) 0) | |||
6179 | G_CALLBACK (pref_show_field_changed),g_signal_connect_data ((window->priv->settings_listing) , ("changed::" "show-path"), (((GCallback) (pref_show_field_changed ))), (window), ((void*)0), (GConnectFlags) 0) | |||
6180 | window)g_signal_connect_data ((window->priv->settings_listing) , ("changed::" "show-path"), (((GCallback) (pref_show_field_changed ))), (window), ((void*)0), (GConnectFlags) 0); | |||
6181 | g_signal_connect (window->priv->settings_listing,g_signal_connect_data ((window->priv->settings_listing) , ("changed::" "use-mime-icons"), (((GCallback) (pref_use_mime_icons_changed ))), (window), ((void*)0), (GConnectFlags) 0) | |||
6182 | "changed::" PREF_LISTING_USE_MIME_ICONS,g_signal_connect_data ((window->priv->settings_listing) , ("changed::" "use-mime-icons"), (((GCallback) (pref_use_mime_icons_changed ))), (window), ((void*)0), (GConnectFlags) 0) | |||
6183 | G_CALLBACK (pref_use_mime_icons_changed),g_signal_connect_data ((window->priv->settings_listing) , ("changed::" "use-mime-icons"), (((GCallback) (pref_use_mime_icons_changed ))), (window), ((void*)0), (GConnectFlags) 0) | |||
6184 | window)g_signal_connect_data ((window->priv->settings_listing) , ("changed::" "use-mime-icons"), (((GCallback) (pref_use_mime_icons_changed ))), (window), ((void*)0), (GConnectFlags) 0); | |||
6185 | ||||
6186 | if (window->priv->settings_baul) | |||
6187 | g_signal_connect (window->priv->settings_baul,g_signal_connect_data ((window->priv->settings_baul), ( "changed::" "click-policy"), (((GCallback) (pref_click_policy_changed ))), (window), ((void*)0), (GConnectFlags) 0) | |||
6188 | "changed::" BAUL_CLICK_POLICY,g_signal_connect_data ((window->priv->settings_baul), ( "changed::" "click-policy"), (((GCallback) (pref_click_policy_changed ))), (window), ((void*)0), (GConnectFlags) 0) | |||
6189 | G_CALLBACK (pref_click_policy_changed),g_signal_connect_data ((window->priv->settings_baul), ( "changed::" "click-policy"), (((GCallback) (pref_click_policy_changed ))), (window), ((void*)0), (GConnectFlags) 0) | |||
6190 | window)g_signal_connect_data ((window->priv->settings_baul), ( "changed::" "click-policy"), (((GCallback) (pref_click_policy_changed ))), (window), ((void*)0), (GConnectFlags) 0); | |||
6191 | ||||
6192 | /* Give focus to the list. */ | |||
6193 | ||||
6194 | ctk_widget_grab_focus (window->priv->list_view); | |||
6195 | } | |||
6196 | ||||
6197 | ||||
6198 | CtkWidget * | |||
6199 | fr_window_new (void) | |||
6200 | { | |||
6201 | CtkWidget *window; | |||
6202 | ||||
6203 | window = g_object_new (FR_TYPE_WINDOW(fr_window_get_type ()), "application", g_application_get_default (), NULL((void*)0)); | |||
6204 | fr_window_construct ((FrWindow*) window); | |||
6205 | ||||
6206 | return window; | |||
6207 | } | |||
6208 | ||||
6209 | ||||
6210 | static void | |||
6211 | fr_window_set_archive_uri (FrWindow *window, | |||
6212 | const char *uri) | |||
6213 | { | |||
6214 | if (window->priv->archive_uri != NULL((void*)0)) | |||
6215 | g_free (window->priv->archive_uri); | |||
6216 | window->priv->archive_uri = g_strdup (uri)g_strdup_inline (uri); | |||
6217 | } | |||
6218 | ||||
6219 | ||||
6220 | gboolean | |||
6221 | fr_window_archive_new (FrWindow *window, | |||
6222 | const char *uri) | |||
6223 | { | |||
6224 | g_return_val_if_fail (window != NULL, FALSE)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return ((0)); } } while (0); | |||
6225 | ||||
6226 | if (! fr_archive_create (window->archive, uri)) { | |||
6227 | CtkWindow *file_sel = g_object_get_data (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), "fr_file_sel"); | |||
6228 | ||||
6229 | window->priv->load_error_parent_window = file_sel; | |||
6230 | fr_archive_action_completed (window->archive, | |||
6231 | FR_ACTION_CREATING_NEW_ARCHIVE, | |||
6232 | FR_PROC_ERROR_GENERIC, | |||
6233 | _("Archive type not supported.")gettext ("Archive type not supported.")); | |||
6234 | ||||
6235 | return FALSE(0); | |||
6236 | } | |||
6237 | ||||
6238 | fr_window_set_archive_uri (window, uri); | |||
6239 | window->priv->archive_present = TRUE(!(0)); | |||
6240 | window->priv->archive_new = TRUE(!(0)); | |||
6241 | ||||
6242 | fr_archive_action_completed (window->archive, | |||
6243 | FR_ACTION_CREATING_NEW_ARCHIVE, | |||
6244 | FR_PROC_ERROR_NONE, | |||
6245 | NULL((void*)0)); | |||
6246 | ||||
6247 | return TRUE(!(0)); | |||
6248 | } | |||
6249 | ||||
6250 | ||||
6251 | FrWindow * | |||
6252 | fr_window_archive_open (FrWindow *current_window, | |||
6253 | const char *uri, | |||
6254 | CtkWindow *parent) | |||
6255 | { | |||
6256 | FrWindow *window = current_window; | |||
6257 | ||||
6258 | if (current_window->priv->archive_present) | |||
6259 | window = (FrWindow *) fr_window_new (); | |||
6260 | ||||
6261 | g_return_val_if_fail (window != NULL, FALSE)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return ((0)); } } while (0); | |||
6262 | ||||
6263 | fr_window_archive_close (window); | |||
6264 | ||||
6265 | fr_window_set_archive_uri (window, uri); | |||
6266 | window->priv->archive_present = FALSE(0); | |||
6267 | window->priv->give_focus_to_the_list = TRUE(!(0)); | |||
6268 | window->priv->load_error_parent_window = parent; | |||
6269 | ||||
6270 | fr_window_set_current_batch_action (window, | |||
6271 | FR_BATCH_ACTION_LOAD, | |||
6272 | g_strdup (window->priv->archive_uri)g_strdup_inline (window->priv->archive_uri), | |||
6273 | (GFreeFunc) g_free); | |||
6274 | ||||
6275 | fr_archive_load (window->archive, window->priv->archive_uri, window->priv->password); | |||
6276 | ||||
6277 | return window; | |||
6278 | } | |||
6279 | ||||
6280 | ||||
6281 | void | |||
6282 | fr_window_archive_close (FrWindow *window) | |||
6283 | { | |||
6284 | g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return; } } while (0); | |||
6285 | ||||
6286 | if (! window->priv->archive_new && ! window->priv->archive_present) | |||
6287 | return; | |||
6288 | ||||
6289 | fr_window_free_open_files (window); | |||
6290 | fr_clipboard_data_unref (window->priv->copy_data); | |||
6291 | window->priv->copy_data = NULL((void*)0); | |||
6292 | ||||
6293 | fr_window_set_password (window, NULL((void*)0)); | |||
6294 | fr_window_set_volume_size(window, 0); | |||
6295 | fr_window_history_clear (window); | |||
6296 | ||||
6297 | window->priv->archive_new = FALSE(0); | |||
6298 | window->priv->archive_present = FALSE(0); | |||
6299 | ||||
6300 | fr_window_update_title (window); | |||
6301 | fr_window_update_sensitivity (window); | |||
6302 | fr_window_update_file_list (window, FALSE(0)); | |||
6303 | fr_window_update_dir_tree (window); | |||
6304 | fr_window_update_current_location (window); | |||
6305 | fr_window_update_statusbar_list_info (window); | |||
6306 | } | |||
6307 | ||||
6308 | ||||
6309 | const char * | |||
6310 | fr_window_get_archive_uri (FrWindow *window) | |||
6311 | { | |||
6312 | g_return_val_if_fail (window != NULL, NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return (((void*)0)); } } while (0); | |||
6313 | ||||
6314 | return window->priv->archive_uri; | |||
6315 | } | |||
6316 | ||||
6317 | ||||
6318 | const char * | |||
6319 | fr_window_get_paste_archive_uri (FrWindow *window) | |||
6320 | { | |||
6321 | g_return_val_if_fail (window != NULL, NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return (((void*)0)); } } while (0); | |||
6322 | ||||
6323 | if (window->priv->clipboard_data != NULL((void*)0)) | |||
6324 | return window->priv->clipboard_data->archive_filename; | |||
6325 | else | |||
6326 | return NULL((void*)0); | |||
6327 | } | |||
6328 | ||||
6329 | ||||
6330 | gboolean | |||
6331 | fr_window_archive_is_present (FrWindow *window) | |||
6332 | { | |||
6333 | g_return_val_if_fail (window != NULL, FALSE)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return ((0)); } } while (0); | |||
6334 | ||||
6335 | return window->priv->archive_present; | |||
6336 | } | |||
6337 | ||||
6338 | ||||
6339 | typedef struct { | |||
6340 | char *uri; | |||
6341 | char *password; | |||
6342 | gboolean encrypt_header; | |||
6343 | guint volume_size; | |||
6344 | } SaveAsData; | |||
6345 | ||||
6346 | ||||
6347 | static SaveAsData * | |||
6348 | save_as_data_new (const char *uri, | |||
6349 | const char *password, | |||
6350 | gboolean encrypt_header, | |||
6351 | guint volume_size) | |||
6352 | { | |||
6353 | SaveAsData *sdata; | |||
6354 | ||||
6355 | sdata = g_new0 (SaveAsData, 1)((SaveAsData *) g_malloc0_n ((1), sizeof (SaveAsData))); | |||
6356 | if (uri != NULL((void*)0)) | |||
6357 | sdata->uri = g_strdup (uri)g_strdup_inline (uri); | |||
6358 | if (password != NULL((void*)0)) | |||
6359 | sdata->password = g_strdup (password)g_strdup_inline (password); | |||
6360 | sdata->encrypt_header = encrypt_header; | |||
6361 | sdata->volume_size = volume_size; | |||
6362 | ||||
6363 | return sdata; | |||
6364 | } | |||
6365 | ||||
6366 | ||||
6367 | static void | |||
6368 | save_as_data_free (SaveAsData *sdata) | |||
6369 | { | |||
6370 | if (sdata == NULL((void*)0)) | |||
6371 | return; | |||
6372 | g_free (sdata->uri); | |||
6373 | g_free (sdata->password); | |||
6374 | g_free (sdata); | |||
6375 | } | |||
6376 | ||||
6377 | ||||
6378 | void | |||
6379 | fr_window_archive_save_as (FrWindow *window, | |||
6380 | const char *uri, | |||
6381 | const char *password, | |||
6382 | gboolean encrypt_header, | |||
6383 | guint volume_size) | |||
6384 | { | |||
6385 | g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return; } } while (0); | |||
6386 | g_return_if_fail (uri != NULL)do { if ((uri != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "uri != NULL"); return ; } } while (0); | |||
6387 | g_return_if_fail (window->archive != NULL)do { if ((window->archive != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window->archive != NULL" ); return; } } while (0); | |||
6388 | ||||
6389 | fr_window_convert_data_free (window, TRUE(!(0))); | |||
6390 | window->priv->convert_data.new_file = g_strdup (uri)g_strdup_inline (uri); | |||
6391 | ||||
6392 | /* create the new archive */ | |||
6393 | ||||
6394 | window->priv->convert_data.new_archive = fr_archive_new (); | |||
6395 | if (! fr_archive_create (window->priv->convert_data.new_archive, uri)) { | |||
6396 | CtkWidget *d; | |||
6397 | char *utf8_name; | |||
6398 | char *message; | |||
6399 | ||||
6400 | utf8_name = g_uri_display_basename (uri); | |||
6401 | message = g_strdup_printf (_("Could not save the archive \"%s\"")gettext ("Could not save the archive \"%s\""), utf8_name); | |||
6402 | g_free (utf8_name); | |||
6403 | ||||
6404 | d = _ctk_error_dialog_new (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), | |||
6405 | CTK_DIALOG_DESTROY_WITH_PARENT, | |||
6406 | NULL((void*)0), | |||
6407 | message, | |||
6408 | "%s", | |||
6409 | _("Archive type not supported.")gettext ("Archive type not supported.")); | |||
6410 | ctk_dialog_run (CTK_DIALOG (d)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((d)), ((ctk_dialog_get_type ()))))))); | |||
6411 | ctk_widget_destroy (d); | |||
6412 | ||||
6413 | g_free (message); | |||
6414 | ||||
6415 | g_object_unref (window->priv->convert_data.new_archive); | |||
6416 | window->priv->convert_data.new_archive = NULL((void*)0); | |||
6417 | ||||
6418 | return; | |||
6419 | } | |||
6420 | ||||
6421 | g_return_if_fail (window->priv->convert_data.new_archive->command != NULL)do { if ((window->priv->convert_data.new_archive->command != ((void*)0))) { } else { g_return_if_fail_warning (((gchar *) 0), ((const char*) (__func__)), "window->priv->convert_data.new_archive->command != NULL" ); return; } } while (0); | |||
6422 | ||||
6423 | if (password != NULL((void*)0)) { | |||
6424 | window->priv->convert_data.password = g_strdup (password)g_strdup_inline (password); | |||
6425 | window->priv->convert_data.encrypt_header = encrypt_header; | |||
6426 | } | |||
6427 | else | |||
6428 | window->priv->convert_data.encrypt_header = FALSE(0); | |||
6429 | window->priv->convert_data.volume_size = volume_size; | |||
6430 | ||||
6431 | fr_window_set_current_batch_action (window, | |||
6432 | FR_BATCH_ACTION_SAVE_AS, | |||
6433 | save_as_data_new (uri, password, encrypt_header, volume_size), | |||
6434 | (GFreeFunc) save_as_data_free); | |||
6435 | ||||
6436 | g_signal_connect (G_OBJECT (window->priv->convert_data.new_archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->convert_data.new_archive )), (((GType) ((20) << (2))))))))), ("start"), (((GCallback ) (action_started))), (window), ((void*)0), (GConnectFlags) 0 ) | |||
6437 | "start",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->convert_data.new_archive )), (((GType) ((20) << (2))))))))), ("start"), (((GCallback ) (action_started))), (window), ((void*)0), (GConnectFlags) 0 ) | |||
6438 | G_CALLBACK (action_started),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->convert_data.new_archive )), (((GType) ((20) << (2))))))))), ("start"), (((GCallback ) (action_started))), (window), ((void*)0), (GConnectFlags) 0 ) | |||
6439 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->convert_data.new_archive )), (((GType) ((20) << (2))))))))), ("start"), (((GCallback ) (action_started))), (window), ((void*)0), (GConnectFlags) 0 ); | |||
6440 | g_signal_connect (G_OBJECT (window->priv->convert_data.new_archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->convert_data.new_archive )), (((GType) ((20) << (2))))))))), ("done"), (((GCallback ) (convert__action_performed))), (window), ((void*)0), (GConnectFlags ) 0) | |||
6441 | "done",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->convert_data.new_archive )), (((GType) ((20) << (2))))))))), ("done"), (((GCallback ) (convert__action_performed))), (window), ((void*)0), (GConnectFlags ) 0) | |||
6442 | G_CALLBACK (convert__action_performed),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->convert_data.new_archive )), (((GType) ((20) << (2))))))))), ("done"), (((GCallback ) (convert__action_performed))), (window), ((void*)0), (GConnectFlags ) 0) | |||
6443 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->convert_data.new_archive )), (((GType) ((20) << (2))))))))), ("done"), (((GCallback ) (convert__action_performed))), (window), ((void*)0), (GConnectFlags ) 0); | |||
6444 | g_signal_connect (G_OBJECT (window->priv->convert_data.new_archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->convert_data.new_archive )), (((GType) ((20) << (2))))))))), ("progress"), (((GCallback ) (fr_window_progress_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
6445 | "progress",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->convert_data.new_archive )), (((GType) ((20) << (2))))))))), ("progress"), (((GCallback ) (fr_window_progress_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
6446 | G_CALLBACK (fr_window_progress_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->convert_data.new_archive )), (((GType) ((20) << (2))))))))), ("progress"), (((GCallback ) (fr_window_progress_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
6447 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->convert_data.new_archive )), (((GType) ((20) << (2))))))))), ("progress"), (((GCallback ) (fr_window_progress_cb))), (window), ((void*)0), (GConnectFlags ) 0); | |||
6448 | g_signal_connect (G_OBJECT (window->priv->convert_data.new_archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->convert_data.new_archive )), (((GType) ((20) << (2))))))))), ("message"), (((GCallback ) (fr_window_message_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
6449 | "message",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->convert_data.new_archive )), (((GType) ((20) << (2))))))))), ("message"), (((GCallback ) (fr_window_message_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
6450 | G_CALLBACK (fr_window_message_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->convert_data.new_archive )), (((GType) ((20) << (2))))))))), ("message"), (((GCallback ) (fr_window_message_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
6451 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->convert_data.new_archive )), (((GType) ((20) << (2))))))))), ("message"), (((GCallback ) (fr_window_message_cb))), (window), ((void*)0), (GConnectFlags ) 0); | |||
6452 | g_signal_connect (G_OBJECT (window->priv->convert_data.new_archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->convert_data.new_archive )), (((GType) ((20) << (2))))))))), ("stoppable"), (((GCallback ) (fr_window_stoppable_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
6453 | "stoppable",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->convert_data.new_archive )), (((GType) ((20) << (2))))))))), ("stoppable"), (((GCallback ) (fr_window_stoppable_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
6454 | G_CALLBACK (fr_window_stoppable_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->convert_data.new_archive )), (((GType) ((20) << (2))))))))), ("stoppable"), (((GCallback ) (fr_window_stoppable_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
6455 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->convert_data.new_archive )), (((GType) ((20) << (2))))))))), ("stoppable"), (((GCallback ) (fr_window_stoppable_cb))), (window), ((void*)0), (GConnectFlags ) 0); | |||
6456 | ||||
6457 | window->priv->convert_data.converting = TRUE(!(0)); | |||
6458 | window->priv->convert_data.temp_dir = get_temp_work_dir (NULL((void*)0)); | |||
6459 | ||||
6460 | fr_process_clear (window->archive->process); | |||
6461 | fr_archive_extract_to_local (window->archive, | |||
6462 | NULL((void*)0), | |||
6463 | window->priv->convert_data.temp_dir, | |||
6464 | NULL((void*)0), | |||
6465 | TRUE(!(0)), | |||
6466 | FALSE(0), | |||
6467 | FALSE(0), | |||
6468 | window->priv->password); | |||
6469 | fr_process_start (window->archive->process); | |||
6470 | } | |||
6471 | ||||
6472 | ||||
6473 | void | |||
6474 | fr_window_archive_reload (FrWindow *window) | |||
6475 | { | |||
6476 | g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return; } } while (0); | |||
6477 | ||||
6478 | if (window->priv->activity_ref > 0) | |||
6479 | return; | |||
6480 | if (window->priv->archive_new) | |||
6481 | return; | |||
6482 | ||||
6483 | fr_archive_reload (window->archive, window->priv->password); | |||
6484 | } | |||
6485 | ||||
6486 | ||||
6487 | /**/ | |||
6488 | ||||
6489 | ||||
6490 | void | |||
6491 | fr_window_archive_add_files (FrWindow *window, | |||
6492 | GList *file_list, /* GFile list */ | |||
6493 | gboolean update) | |||
6494 | { | |||
6495 | GFile *base; | |||
6496 | char *base_dir; | |||
6497 | int base_len; | |||
6498 | GList *files = NULL((void*)0); | |||
6499 | GList *scan; | |||
6500 | char *base_uri; | |||
6501 | ||||
6502 | base = g_file_get_parent ((GFile *) file_list->data); | |||
6503 | base_dir = g_file_get_path (base); | |||
6504 | base_len = 0; | |||
6505 | if (strcmp (base_dir, "/") != 0) | |||
6506 | base_len = strlen (base_dir); | |||
6507 | ||||
6508 | for (scan = file_list; scan; scan = scan->next) { | |||
6509 | GFile *file = scan->data; | |||
6510 | char *path; | |||
6511 | char *rel_path; | |||
6512 | ||||
6513 | path = g_file_get_path (file); | |||
6514 | rel_path = g_strdup (path + base_len + 1)g_strdup_inline (path + base_len + 1); | |||
6515 | files = g_list_prepend (files, rel_path); | |||
6516 | ||||
6517 | g_free (path); | |||
6518 | } | |||
6519 | ||||
6520 | base_uri = g_file_get_uri (base); | |||
6521 | ||||
6522 | fr_archive_add_files (window->archive, | |||
6523 | files, | |||
6524 | base_uri, | |||
6525 | fr_window_get_current_location (window), | |||
6526 | update, | |||
6527 | window->priv->password, | |||
6528 | window->priv->encrypt_header, | |||
6529 | window->priv->compression, | |||
6530 | window->priv->volume_size); | |||
6531 | ||||
6532 | g_free (base_uri); | |||
6533 | path_list_free (files); | |||
6534 | g_free (base_dir); | |||
6535 | g_object_unref (base); | |||
6536 | } | |||
6537 | ||||
6538 | ||||
6539 | void | |||
6540 | fr_window_archive_add_with_wildcard (FrWindow *window, | |||
6541 | const char *include_files, | |||
6542 | const char *exclude_files, | |||
6543 | const char *exclude_folders, | |||
6544 | const char *base_dir, | |||
6545 | const char *dest_dir, | |||
6546 | gboolean update, | |||
6547 | gboolean follow_links) | |||
6548 | { | |||
6549 | fr_archive_add_with_wildcard (window->archive, | |||
6550 | include_files, | |||
6551 | exclude_files, | |||
6552 | exclude_folders, | |||
6553 | base_dir, | |||
6554 | (dest_dir == NULL((void*)0))? fr_window_get_current_location (window): dest_dir, | |||
6555 | update, | |||
6556 | follow_links, | |||
6557 | window->priv->password, | |||
6558 | window->priv->encrypt_header, | |||
6559 | window->priv->compression, | |||
6560 | window->priv->volume_size); | |||
6561 | } | |||
6562 | ||||
6563 | ||||
6564 | void | |||
6565 | fr_window_archive_add_directory (FrWindow *window, | |||
6566 | const char *directory, | |||
6567 | const char *base_dir, | |||
6568 | const char *dest_dir, | |||
6569 | gboolean update) | |||
6570 | { | |||
6571 | fr_archive_add_directory (window->archive, | |||
6572 | directory, | |||
6573 | base_dir, | |||
6574 | (dest_dir == NULL((void*)0))? fr_window_get_current_location (window): dest_dir, | |||
6575 | update, | |||
6576 | window->priv->password, | |||
6577 | window->priv->encrypt_header, | |||
6578 | window->priv->compression, | |||
6579 | window->priv->volume_size); | |||
6580 | } | |||
6581 | ||||
6582 | ||||
6583 | void | |||
6584 | fr_window_archive_add_items (FrWindow *window, | |||
6585 | GList *item_list, | |||
6586 | const char *base_dir, | |||
6587 | const char *dest_dir, | |||
6588 | gboolean update) | |||
6589 | { | |||
6590 | fr_archive_add_items (window->archive, | |||
6591 | item_list, | |||
6592 | base_dir, | |||
6593 | (dest_dir == NULL((void*)0))? fr_window_get_current_location (window): dest_dir, | |||
6594 | update, | |||
6595 | window->priv->password, | |||
6596 | window->priv->encrypt_header, | |||
6597 | window->priv->compression, | |||
6598 | window->priv->volume_size); | |||
6599 | } | |||
6600 | ||||
6601 | ||||
6602 | void | |||
6603 | fr_window_archive_add_dropped_items (FrWindow *window, | |||
6604 | GList *item_list, | |||
6605 | gboolean update) | |||
6606 | { | |||
6607 | fr_archive_add_dropped_items (window->archive, | |||
6608 | item_list, | |||
6609 | fr_window_get_current_location (window), | |||
6610 | fr_window_get_current_location (window), | |||
6611 | update, | |||
6612 | window->priv->password, | |||
6613 | window->priv->encrypt_header, | |||
6614 | window->priv->compression, | |||
6615 | window->priv->volume_size); | |||
6616 | } | |||
6617 | ||||
6618 | ||||
6619 | void | |||
6620 | fr_window_archive_remove (FrWindow *window, | |||
6621 | GList *file_list) | |||
6622 | { | |||
6623 | fr_window_clipboard_remove_file_list (window, file_list); | |||
6624 | ||||
6625 | fr_process_clear (window->archive->process); | |||
6626 | fr_archive_remove (window->archive, file_list, window->priv->compression); | |||
6627 | fr_process_start (window->archive->process); | |||
6628 | } | |||
6629 | ||||
6630 | ||||
6631 | /* -- window_archive_extract -- */ | |||
6632 | ||||
6633 | ||||
6634 | static ExtractData* | |||
6635 | extract_data_new (GList *file_list, | |||
6636 | const char *extract_to_dir, | |||
6637 | const char *base_dir, | |||
6638 | gboolean skip_older, | |||
6639 | FrOverwrite overwrite, | |||
6640 | gboolean junk_paths, | |||
6641 | gboolean extract_here, | |||
6642 | gboolean ask_to_open_destination) | |||
6643 | { | |||
6644 | ExtractData *edata; | |||
6645 | ||||
6646 | edata = g_new0 (ExtractData, 1)((ExtractData *) g_malloc0_n ((1), sizeof (ExtractData))); | |||
6647 | edata->file_list = path_list_dup (file_list); | |||
6648 | if (extract_to_dir != NULL((void*)0)) | |||
6649 | edata->extract_to_dir = g_strdup (extract_to_dir)g_strdup_inline (extract_to_dir); | |||
6650 | edata->skip_older = skip_older; | |||
6651 | edata->overwrite = overwrite; | |||
6652 | edata->junk_paths = junk_paths; | |||
6653 | if (base_dir != NULL((void*)0)) | |||
6654 | edata->base_dir = g_strdup (base_dir)g_strdup_inline (base_dir); | |||
6655 | edata->extract_here = extract_here; | |||
6656 | edata->ask_to_open_destination = ask_to_open_destination; | |||
6657 | ||||
6658 | return edata; | |||
6659 | } | |||
6660 | ||||
6661 | ||||
6662 | static ExtractData* | |||
6663 | extract_to_data_new (const char *extract_to_dir) | |||
6664 | { | |||
6665 | return extract_data_new (NULL((void*)0), | |||
6666 | extract_to_dir, | |||
6667 | NULL((void*)0), | |||
6668 | FALSE(0), | |||
6669 | TRUE(!(0)), | |||
6670 | FALSE(0), | |||
6671 | FALSE(0), | |||
6672 | FALSE(0)); | |||
6673 | } | |||
6674 | ||||
6675 | ||||
6676 | static void | |||
6677 | extract_data_free (ExtractData *edata) | |||
6678 | { | |||
6679 | g_return_if_fail (edata != NULL)do { if ((edata != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "edata != NULL"); return; } } while (0); | |||
6680 | ||||
6681 | path_list_free (edata->file_list); | |||
6682 | g_free (edata->extract_to_dir); | |||
6683 | g_free (edata->base_dir); | |||
6684 | ||||
6685 | g_free (edata); | |||
6686 | } | |||
6687 | ||||
6688 | ||||
6689 | static gboolean | |||
6690 | archive_is_encrypted (FrWindow *window, | |||
6691 | GList *file_list) | |||
6692 | { | |||
6693 | gboolean encrypted = FALSE(0); | |||
6694 | ||||
6695 | if (file_list == NULL((void*)0)) { | |||
6696 | guint i; | |||
6697 | ||||
6698 | for (i = 0; ! encrypted && i < window->archive->command->files->len; i++) { | |||
6699 | FileData *fdata = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i]; | |||
6700 | ||||
6701 | if (fdata->encrypted) | |||
6702 | encrypted = TRUE(!(0)); | |||
6703 | } | |||
6704 | } | |||
6705 | else { | |||
6706 | ||||
6707 | GHashTable *file_hash; | |||
6708 | guint i; | |||
6709 | GList *scan; | |||
6710 | ||||
6711 | file_hash = g_hash_table_new (g_str_hash, g_str_equal); | |||
6712 | for (i = 0; i < window->archive->command->files->len; i++) { | |||
6713 | FileData *fdata = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i]; | |||
6714 | g_hash_table_insert (file_hash, fdata->original_path, fdata); | |||
6715 | } | |||
6716 | ||||
6717 | for (scan = file_list; ! encrypted && scan; scan = scan->next) { | |||
6718 | char *filename = scan->data; | |||
6719 | FileData *fdata; | |||
6720 | ||||
6721 | fdata = g_hash_table_lookup (file_hash, filename); | |||
6722 | g_return_val_if_fail (fdata != NULL, FALSE)do { if ((fdata != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "fdata != NULL"); return ((0)); } } while (0); | |||
6723 | ||||
6724 | if (fdata->encrypted) | |||
6725 | encrypted = TRUE(!(0)); | |||
6726 | } | |||
6727 | ||||
6728 | g_hash_table_destroy (file_hash); | |||
6729 | } | |||
6730 | ||||
6731 | return encrypted; | |||
6732 | } | |||
6733 | ||||
6734 | ||||
6735 | void | |||
6736 | fr_window_archive_extract_here (FrWindow *window, | |||
6737 | gboolean skip_older, | |||
6738 | gboolean overwrite, | |||
6739 | gboolean junk_paths) | |||
6740 | { | |||
6741 | ExtractData *edata; | |||
6742 | ||||
6743 | edata = extract_data_new (NULL((void*)0), | |||
6744 | NULL((void*)0), | |||
6745 | NULL((void*)0), | |||
6746 | skip_older, | |||
6747 | overwrite, | |||
6748 | junk_paths, | |||
6749 | TRUE(!(0)), | |||
6750 | FALSE(0)); | |||
6751 | fr_window_set_current_batch_action (window, | |||
6752 | FR_BATCH_ACTION_EXTRACT, | |||
6753 | edata, | |||
6754 | (GFreeFunc) extract_data_free); | |||
6755 | ||||
6756 | if (archive_is_encrypted (window, NULL((void*)0)) && (window->priv->password == NULL((void*)0))) { | |||
6757 | dlg_ask_password (window); | |||
6758 | return; | |||
6759 | } | |||
6760 | ||||
6761 | window->priv->ask_to_open_destination_after_extraction = edata->ask_to_open_destination; | |||
6762 | ||||
6763 | fr_process_clear (window->archive->process); | |||
6764 | if (fr_archive_extract_here (window->archive, | |||
6765 | edata->skip_older, | |||
6766 | edata->overwrite, | |||
6767 | edata->junk_paths, | |||
6768 | window->priv->password)) | |||
6769 | { | |||
6770 | fr_process_start (window->archive->process); | |||
6771 | } | |||
6772 | } | |||
6773 | ||||
6774 | ||||
6775 | /* -- fr_window_archive_extract -- */ | |||
6776 | ||||
6777 | ||||
6778 | typedef struct { | |||
6779 | FrWindow *window; | |||
6780 | ExtractData *edata; | |||
6781 | GList *current_file; | |||
6782 | gboolean extract_all; | |||
6783 | } OverwriteData; | |||
6784 | ||||
6785 | ||||
6786 | #define _FR_RESPONSE_OVERWRITE_YES_ALL100 100 | |||
6787 | #define _FR_RESPONSE_OVERWRITE_YES101 101 | |||
6788 | #define _FR_RESPONSE_OVERWRITE_NO102 102 | |||
6789 | ||||
6790 | ||||
6791 | static void | |||
6792 | _fr_window_archive_extract_from_edata (FrWindow *window, | |||
6793 | ExtractData *edata) | |||
6794 | { | |||
6795 | window->priv->ask_to_open_destination_after_extraction = edata->ask_to_open_destination; | |||
6796 | ||||
6797 | fr_process_clear (window->archive->process); | |||
6798 | fr_archive_extract (window->archive, | |||
6799 | edata->file_list, | |||
6800 | edata->extract_to_dir, | |||
6801 | edata->base_dir, | |||
6802 | edata->skip_older, | |||
6803 | edata->overwrite == FR_OVERWRITE_YES, | |||
6804 | edata->junk_paths, | |||
6805 | window->priv->password); | |||
6806 | fr_process_start (window->archive->process); | |||
6807 | } | |||
6808 | ||||
6809 | ||||
6810 | static void _fr_window_ask_overwrite_dialog (OverwriteData *odata); | |||
6811 | ||||
6812 | ||||
6813 | static void | |||
6814 | overwrite_dialog_response_cb (CtkDialog *dialog, | |||
6815 | int response_id, | |||
6816 | gpointer user_data) | |||
6817 | { | |||
6818 | OverwriteData *odata = user_data; | |||
6819 | gboolean do_not_extract = FALSE(0); | |||
6820 | ||||
6821 | switch (response_id) { | |||
6822 | case _FR_RESPONSE_OVERWRITE_YES_ALL100: | |||
6823 | odata->edata->overwrite = FR_OVERWRITE_YES; | |||
6824 | break; | |||
6825 | ||||
6826 | case _FR_RESPONSE_OVERWRITE_YES101: | |||
6827 | odata->current_file = odata->current_file->next; | |||
6828 | break; | |||
6829 | ||||
6830 | case _FR_RESPONSE_OVERWRITE_NO102: | |||
6831 | { | |||
6832 | /* remove the file from the list to extract */ | |||
6833 | GList *next = odata->current_file->next; | |||
6834 | odata->edata->file_list = g_list_remove_link (odata->edata->file_list, odata->current_file); | |||
6835 | path_list_free (odata->current_file); | |||
6836 | odata->current_file = next; | |||
6837 | odata->extract_all = FALSE(0); | |||
6838 | } | |||
6839 | break; | |||
6840 | ||||
6841 | case CTK_RESPONSE_DELETE_EVENT: | |||
6842 | case CTK_RESPONSE_CANCEL: | |||
6843 | do_not_extract = TRUE(!(0)); | |||
6844 | break; | |||
6845 | ||||
6846 | default: | |||
6847 | break; | |||
6848 | } | |||
6849 | ||||
6850 | ctk_widget_destroy (CTK_WIDGET (dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_widget_get_type ()))))))); | |||
6851 | ||||
6852 | if (do_not_extract) { | |||
6853 | fr_window_stop_batch (odata->window); | |||
6854 | g_free (odata); | |||
6855 | return; | |||
6856 | } | |||
6857 | ||||
6858 | _fr_window_ask_overwrite_dialog (odata); | |||
6859 | } | |||
6860 | ||||
6861 | ||||
6862 | static void | |||
6863 | _fr_window_ask_overwrite_dialog (OverwriteData *odata) | |||
6864 | { | |||
6865 | while ((odata->edata->overwrite == FR_OVERWRITE_ASK) && (odata->current_file != NULL((void*)0))) { | |||
6866 | const char *base_name; | |||
6867 | char *e_base_name; | |||
6868 | char *dest_uri; | |||
6869 | GFile *file; | |||
6870 | GFileInfo *info; | |||
6871 | GFileType file_type; | |||
6872 | ||||
6873 | base_name = _g_path_get_base_name ((char *) odata->current_file->data, odata->edata->base_dir, odata->edata->junk_paths); | |||
6874 | e_base_name = g_uri_escape_string (base_name, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH"!$&'()*+,;=" ":@" "/", TRUE(!(0))); | |||
6875 | dest_uri = g_strdup_printf ("%s/%s", odata->edata->extract_to_dir, e_base_name); | |||
6876 | file = g_file_new_for_uri (dest_uri); | |||
6877 | info = g_file_query_info (file, | |||
6878 | G_FILE_ATTRIBUTE_STANDARD_TYPE"standard::type" "," G_FILE_ATTRIBUTE_STANDARD_NAME"standard::name" "," G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME"standard::display-name", | |||
6879 | G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, | |||
6880 | NULL((void*)0), | |||
6881 | NULL((void*)0)); | |||
6882 | ||||
6883 | g_free (dest_uri); | |||
6884 | g_free (e_base_name); | |||
6885 | ||||
6886 | if (info == NULL((void*)0)) { | |||
6887 | g_object_unref (file); | |||
6888 | odata->current_file = odata->current_file->next; | |||
6889 | continue; | |||
6890 | } | |||
6891 | ||||
6892 | file_type = g_file_info_get_file_type (info); | |||
6893 | if ((file_type != G_FILE_TYPE_UNKNOWN) && (file_type != G_FILE_TYPE_DIRECTORY)) { | |||
6894 | char *msg; | |||
6895 | GFile *parent; | |||
6896 | char *parent_name; | |||
6897 | char *details; | |||
6898 | CtkWidget *d; | |||
6899 | ||||
6900 | msg = g_strdup_printf (_("Replace file \"%s\"?")gettext ("Replace file \"%s\"?"), g_file_info_get_display_name (info)); | |||
6901 | parent = g_file_get_parent (file); | |||
6902 | parent_name = g_file_get_parse_name (parent); | |||
6903 | details = g_strdup_printf (_("Another file with the same name already exists in \"%s\".")gettext ("Another file with the same name already exists in \"%s\"." ), parent_name); | |||
6904 | d = _ctk_message_dialog_new (CTK_WINDOW (odata->window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((odata->window)), ((ctk_window_get_type ())))))), | |||
6905 | CTK_DIALOG_MODAL, | |||
6906 | "dialog-question", | |||
6907 | msg, | |||
6908 | details, | |||
6909 | CTK_STOCK_CANCEL((CtkStock)"ctk-cancel"), CTK_RESPONSE_CANCEL, | |||
6910 | _("Replace _All")gettext ("Replace _All"), _FR_RESPONSE_OVERWRITE_YES_ALL100, | |||
6911 | _("_Skip")gettext ("_Skip"), _FR_RESPONSE_OVERWRITE_NO102, | |||
6912 | _("_Replace")gettext ("_Replace"), _FR_RESPONSE_OVERWRITE_YES101, | |||
6913 | NULL((void*)0)); | |||
6914 | ctk_dialog_set_default_response (CTK_DIALOG (d)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((d)), ((ctk_dialog_get_type ())))))), _FR_RESPONSE_OVERWRITE_YES101); | |||
6915 | g_signal_connect (d,g_signal_connect_data ((d), ("response"), (((GCallback) (overwrite_dialog_response_cb ))), (odata), ((void*)0), (GConnectFlags) 0) | |||
6916 | "response",g_signal_connect_data ((d), ("response"), (((GCallback) (overwrite_dialog_response_cb ))), (odata), ((void*)0), (GConnectFlags) 0) | |||
6917 | G_CALLBACK (overwrite_dialog_response_cb),g_signal_connect_data ((d), ("response"), (((GCallback) (overwrite_dialog_response_cb ))), (odata), ((void*)0), (GConnectFlags) 0) | |||
6918 | odata)g_signal_connect_data ((d), ("response"), (((GCallback) (overwrite_dialog_response_cb ))), (odata), ((void*)0), (GConnectFlags) 0); | |||
6919 | ctk_widget_show (d); | |||
6920 | ||||
6921 | g_free (parent_name); | |||
6922 | g_object_unref (parent); | |||
6923 | g_object_unref (info); | |||
6924 | g_object_unref (file); | |||
6925 | ||||
6926 | return; | |||
6927 | } | |||
6928 | else | |||
6929 | odata->current_file = odata->current_file->next; | |||
6930 | ||||
6931 | g_object_unref (info); | |||
6932 | g_object_unref (file); | |||
6933 | } | |||
6934 | ||||
6935 | if (odata->edata->file_list != NULL((void*)0)) { | |||
6936 | /* speed optimization: passing NULL when extracting all the | |||
6937 | * files is faster if the command supports the | |||
6938 | * propCanExtractAll property. */ | |||
6939 | if (odata->extract_all) { | |||
6940 | path_list_free (odata->edata->file_list); | |||
6941 | odata->edata->file_list = NULL((void*)0); | |||
6942 | } | |||
6943 | odata->edata->overwrite = FR_OVERWRITE_YES; | |||
6944 | _fr_window_archive_extract_from_edata (odata->window, odata->edata); | |||
6945 | } | |||
6946 | else { | |||
6947 | CtkWidget *d; | |||
6948 | ||||
6949 | d = _ctk_message_dialog_new (CTK_WINDOW (odata->window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((odata->window)), ((ctk_window_get_type ())))))), | |||
6950 | 0, | |||
6951 | "dialog-warning", | |||
6952 | _("Extraction not performed")gettext ("Extraction not performed"), | |||
6953 | NULL((void*)0), | |||
6954 | CTK_STOCK_OK((CtkStock)"ctk-ok"), CTK_RESPONSE_OK, | |||
6955 | NULL((void*)0)); | |||
6956 | ctk_dialog_set_default_response (CTK_DIALOG (d)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((d)), ((ctk_dialog_get_type ())))))), CTK_RESPONSE_OK); | |||
6957 | fr_window_show_error_dialog (odata->window, d, CTK_WINDOW (odata->window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((odata->window)), ((ctk_window_get_type ())))))), _("Extraction not performed")gettext ("Extraction not performed")); | |||
6958 | ||||
6959 | fr_window_stop_batch (odata->window); | |||
6960 | } | |||
6961 | g_free (odata); | |||
6962 | } | |||
6963 | ||||
6964 | ||||
6965 | void | |||
6966 | fr_window_archive_extract (FrWindow *window, | |||
6967 | GList *file_list, | |||
6968 | const char *extract_to_dir, | |||
6969 | const char *base_dir, | |||
6970 | gboolean skip_older, | |||
6971 | FrOverwrite overwrite, | |||
6972 | gboolean junk_paths, | |||
6973 | gboolean ask_to_open_destination) | |||
6974 | { | |||
6975 | ExtractData *edata; | |||
6976 | gboolean do_not_extract = FALSE(0); | |||
6977 | GError *error = NULL((void*)0); | |||
6978 | ||||
6979 | edata = extract_data_new (file_list, | |||
6980 | extract_to_dir, | |||
6981 | base_dir, | |||
6982 | skip_older, | |||
6983 | overwrite, | |||
6984 | junk_paths, | |||
6985 | FALSE(0), | |||
6986 | ask_to_open_destination); | |||
6987 | ||||
6988 | fr_window_set_current_batch_action (window, | |||
6989 | FR_BATCH_ACTION_EXTRACT, | |||
6990 | edata, | |||
6991 | (GFreeFunc) extract_data_free); | |||
6992 | ||||
6993 | if (archive_is_encrypted (window, edata->file_list) && (window->priv->password == NULL((void*)0))) { | |||
6994 | dlg_ask_password (window); | |||
6995 | return; | |||
6996 | } | |||
6997 | ||||
6998 | if (! uri_is_dir (edata->extract_to_dir)) { | |||
6999 | ||||
7000 | /* There is nothing to ask if the destination doesn't exist. */ | |||
7001 | if (edata->overwrite == FR_OVERWRITE_ASK) | |||
7002 | edata->overwrite = FR_OVERWRITE_YES; | |||
7003 | ||||
7004 | if (! ForceDirectoryCreation) { | |||
7005 | CtkWidget *d; | |||
7006 | int r; | |||
7007 | char *folder_name; | |||
7008 | char *msg; | |||
7009 | ||||
7010 | folder_name = g_filename_display_name (edata->extract_to_dir); | |||
7011 | msg = g_strdup_printf (_("Destination folder \"%s\" does not exist.\n\nDo you want to create it?")gettext ("Destination folder \"%s\" does not exist.\n\nDo you want to create it?" ), folder_name); | |||
7012 | g_free (folder_name); | |||
7013 | ||||
7014 | d = _ctk_message_dialog_new (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), | |||
7015 | CTK_DIALOG_MODAL, | |||
7016 | "dialog-question", | |||
7017 | msg, | |||
7018 | NULL((void*)0), | |||
7019 | CTK_STOCK_CANCEL((CtkStock)"ctk-cancel"), CTK_RESPONSE_CANCEL, | |||
7020 | _("Create _Folder")gettext ("Create _Folder"), CTK_RESPONSE_YES, | |||
7021 | NULL((void*)0)); | |||
7022 | ||||
7023 | ctk_dialog_set_default_response (CTK_DIALOG (d)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((d)), ((ctk_dialog_get_type ())))))), CTK_RESPONSE_YES); | |||
7024 | r = ctk_dialog_run (CTK_DIALOG (d)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((d)), ((ctk_dialog_get_type ()))))))); | |||
7025 | ctk_widget_destroy (CTK_WIDGET (d)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((d)), ((ctk_widget_get_type ()))))))); | |||
7026 | ||||
7027 | g_free (msg); | |||
7028 | ||||
7029 | if (r != CTK_RESPONSE_YES) | |||
7030 | do_not_extract = TRUE(!(0)); | |||
7031 | } | |||
7032 | ||||
7033 | if (! do_not_extract && ! ensure_dir_exists (edata->extract_to_dir, 0755, &error)) { | |||
7034 | CtkWidget *d; | |||
7035 | char *details; | |||
7036 | ||||
7037 | details = g_strdup_printf (_("Could not create the destination folder: %s.")gettext ("Could not create the destination folder: %s."), error->message); | |||
7038 | d = _ctk_error_dialog_new (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), | |||
7039 | 0, | |||
7040 | NULL((void*)0), | |||
7041 | _("Extraction not performed")gettext ("Extraction not performed"), | |||
7042 | "%s", | |||
7043 | details); | |||
7044 | g_clear_error (&error); | |||
7045 | fr_window_show_error_dialog (window, d, CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), details); | |||
7046 | fr_window_stop_batch (window); | |||
7047 | ||||
7048 | g_free (details); | |||
7049 | ||||
7050 | return; | |||
7051 | } | |||
7052 | } | |||
7053 | ||||
7054 | if (do_not_extract) { | |||
7055 | CtkWidget *d; | |||
7056 | ||||
7057 | d = _ctk_message_dialog_new (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), | |||
7058 | 0, | |||
7059 | "dialog-warning", | |||
7060 | _("Extraction not performed")gettext ("Extraction not performed"), | |||
7061 | NULL((void*)0), | |||
7062 | CTK_STOCK_OK((CtkStock)"ctk-ok"), CTK_RESPONSE_OK, | |||
7063 | NULL((void*)0)); | |||
7064 | ctk_dialog_set_default_response (CTK_DIALOG (d)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((d)), ((ctk_dialog_get_type ())))))), CTK_RESPONSE_OK); | |||
7065 | fr_window_show_error_dialog (window, d, CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), _("Extraction not performed")gettext ("Extraction not performed")); | |||
7066 | fr_window_stop_batch (window); | |||
7067 | ||||
7068 | return; | |||
7069 | } | |||
7070 | ||||
7071 | if (edata->overwrite == FR_OVERWRITE_ASK) { | |||
7072 | OverwriteData *odata; | |||
7073 | ||||
7074 | odata = g_new0 (OverwriteData, 1)((OverwriteData *) g_malloc0_n ((1), sizeof (OverwriteData))); | |||
7075 | odata->window = window; | |||
7076 | odata->edata = edata; | |||
7077 | odata->extract_all = (edata->file_list == NULL((void*)0)) || (g_list_length (edata->file_list) == window->archive->command->files->len); | |||
7078 | if (edata->file_list == NULL((void*)0)) | |||
7079 | edata->file_list = fr_window_get_file_list (window); | |||
7080 | odata->current_file = odata->edata->file_list; | |||
7081 | _fr_window_ask_overwrite_dialog (odata); | |||
7082 | } | |||
7083 | else | |||
7084 | _fr_window_archive_extract_from_edata (window, edata); | |||
7085 | } | |||
7086 | ||||
7087 | ||||
7088 | void | |||
7089 | fr_window_archive_test (FrWindow *window) | |||
7090 | { | |||
7091 | fr_window_set_current_batch_action (window, | |||
7092 | FR_BATCH_ACTION_TEST, | |||
7093 | NULL((void*)0), | |||
7094 | NULL((void*)0)); | |||
7095 | fr_archive_test (window->archive, window->priv->password); | |||
7096 | } | |||
7097 | ||||
7098 | ||||
7099 | void | |||
7100 | fr_window_set_password (FrWindow *window, | |||
7101 | const char *password) | |||
7102 | { | |||
7103 | g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return; } } while (0); | |||
7104 | ||||
7105 | if (window->priv->password != NULL((void*)0)) { | |||
7106 | g_free (window->priv->password); | |||
7107 | window->priv->password = NULL((void*)0); | |||
7108 | } | |||
7109 | ||||
7110 | if ((password != NULL((void*)0)) && (password[0] != '\0')) | |||
7111 | window->priv->password = g_strdup (password)g_strdup_inline (password); | |||
7112 | } | |||
7113 | ||||
7114 | void | |||
7115 | fr_window_set_password_for_paste (FrWindow *window, | |||
7116 | const char *password) | |||
7117 | { | |||
7118 | g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return; } } while (0); | |||
7119 | ||||
7120 | if (window->priv->password_for_paste != NULL((void*)0)) { | |||
7121 | g_free (window->priv->password_for_paste); | |||
7122 | window->priv->password_for_paste = NULL((void*)0); | |||
7123 | } | |||
7124 | ||||
7125 | if ((password != NULL((void*)0)) && (password[0] != '\0')) | |||
7126 | window->priv->password_for_paste = g_strdup (password)g_strdup_inline (password); | |||
7127 | } | |||
7128 | ||||
7129 | const char * | |||
7130 | fr_window_get_password (FrWindow *window) | |||
7131 | { | |||
7132 | g_return_val_if_fail (window != NULL, NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return (((void*)0)); } } while (0); | |||
7133 | ||||
7134 | return window->priv->password; | |||
7135 | } | |||
7136 | ||||
7137 | ||||
7138 | void | |||
7139 | fr_window_set_encrypt_header (FrWindow *window, | |||
7140 | gboolean encrypt_header) | |||
7141 | { | |||
7142 | g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return; } } while (0); | |||
7143 | ||||
7144 | window->priv->encrypt_header = encrypt_header; | |||
7145 | } | |||
7146 | ||||
7147 | ||||
7148 | gboolean | |||
7149 | fr_window_get_encrypt_header (FrWindow *window) | |||
7150 | { | |||
7151 | return window->priv->encrypt_header; | |||
7152 | } | |||
7153 | ||||
7154 | ||||
7155 | void | |||
7156 | fr_window_set_compression (FrWindow *window, | |||
7157 | FrCompression compression) | |||
7158 | { | |||
7159 | g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return; } } while (0); | |||
7160 | ||||
7161 | window->priv->compression = compression; | |||
7162 | } | |||
7163 | ||||
7164 | ||||
7165 | FrCompression | |||
7166 | fr_window_get_compression (FrWindow *window) | |||
7167 | { | |||
7168 | return window->priv->compression; | |||
7169 | } | |||
7170 | ||||
7171 | ||||
7172 | void | |||
7173 | fr_window_set_volume_size (FrWindow *window, | |||
7174 | guint volume_size) | |||
7175 | { | |||
7176 | g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return; } } while (0); | |||
7177 | ||||
7178 | window->priv->volume_size = volume_size; | |||
7179 | } | |||
7180 | ||||
7181 | ||||
7182 | guint | |||
7183 | fr_window_get_volume_size (FrWindow *window) | |||
7184 | { | |||
7185 | return window->priv->volume_size; | |||
7186 | } | |||
7187 | ||||
7188 | ||||
7189 | void | |||
7190 | fr_window_go_to_location (FrWindow *window, | |||
7191 | const char *path, | |||
7192 | gboolean force_update) | |||
7193 | { | |||
7194 | char *dir; | |||
7195 | ||||
7196 | g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return; } } while (0); | |||
7197 | g_return_if_fail (path != NULL)do { if ((path != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "path != NULL"); return ; } } while (0); | |||
7198 | ||||
7199 | if (force_update) { | |||
7200 | g_free (window->priv->last_location); | |||
7201 | window->priv->last_location = NULL((void*)0); | |||
7202 | } | |||
7203 | ||||
7204 | if (path[strlen (path) - 1] != '/') | |||
7205 | dir = g_strconcat (path, "/", NULL((void*)0)); | |||
7206 | else | |||
7207 | dir = g_strdup (path)g_strdup_inline (path); | |||
7208 | ||||
7209 | if ((window->priv->last_location == NULL((void*)0)) || (strcmp (window->priv->last_location, dir) != 0)) { | |||
7210 | g_free (window->priv->last_location); | |||
7211 | window->priv->last_location = dir; | |||
7212 | ||||
7213 | fr_window_history_add (window, dir); | |||
7214 | fr_window_update_file_list (window, TRUE(!(0))); | |||
7215 | fr_window_update_current_location (window); | |||
7216 | } | |||
7217 | else | |||
7218 | g_free (dir); | |||
7219 | } | |||
7220 | ||||
7221 | ||||
7222 | const char * | |||
7223 | fr_window_get_current_location (FrWindow *window) | |||
7224 | { | |||
7225 | if (window->priv->history_current == NULL((void*)0)) { | |||
7226 | fr_window_history_add (window, "/"); | |||
7227 | return window->priv->history_current->data; | |||
7228 | } | |||
7229 | else | |||
7230 | return (const char*) window->priv->history_current->data; | |||
7231 | } | |||
7232 | ||||
7233 | ||||
7234 | void | |||
7235 | fr_window_go_up_one_level (FrWindow *window) | |||
7236 | { | |||
7237 | char *parent_dir; | |||
7238 | ||||
7239 | g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return; } } while (0); | |||
7240 | ||||
7241 | parent_dir = get_parent_dir (fr_window_get_current_location (window)); | |||
7242 | fr_window_go_to_location (window, parent_dir, FALSE(0)); | |||
7243 | g_free (parent_dir); | |||
7244 | } | |||
7245 | ||||
7246 | ||||
7247 | void | |||
7248 | fr_window_go_back (FrWindow *window) | |||
7249 | { | |||
7250 | g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return; } } while (0); | |||
7251 | ||||
7252 | if (window->priv->history == NULL((void*)0)) | |||
7253 | return; | |||
7254 | if (window->priv->history_current == NULL((void*)0)) | |||
7255 | return; | |||
7256 | if (window->priv->history_current->next == NULL((void*)0)) | |||
7257 | return; | |||
7258 | window->priv->history_current = window->priv->history_current->next; | |||
7259 | ||||
7260 | fr_window_go_to_location (window, window->priv->history_current->data, FALSE(0)); | |||
7261 | } | |||
7262 | ||||
7263 | ||||
7264 | void | |||
7265 | fr_window_go_forward (FrWindow *window) | |||
7266 | { | |||
7267 | g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return; } } while (0); | |||
7268 | ||||
7269 | if (window->priv->history == NULL((void*)0)) | |||
7270 | return; | |||
7271 | if (window->priv->history_current == NULL((void*)0)) | |||
7272 | return; | |||
7273 | if (window->priv->history_current->prev == NULL((void*)0)) | |||
7274 | return; | |||
7275 | window->priv->history_current = window->priv->history_current->prev; | |||
7276 | ||||
7277 | fr_window_go_to_location (window, window->priv->history_current->data, FALSE(0)); | |||
7278 | } | |||
7279 | ||||
7280 | ||||
7281 | void | |||
7282 | fr_window_set_list_mode (FrWindow *window, | |||
7283 | FrWindowListMode list_mode) | |||
7284 | { | |||
7285 | g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return; } } while (0); | |||
7286 | ||||
7287 | window->priv->list_mode = window->priv->last_list_mode = list_mode; | |||
7288 | if (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT) { | |||
7289 | fr_window_history_clear (window); | |||
7290 | fr_window_history_add (window, "/"); | |||
7291 | } | |||
7292 | ||||
7293 | g_settings_set_enum (window->priv->settings_listing, PREF_LISTING_LIST_MODE"list-mode", window->priv->last_list_mode); | |||
7294 | g_settings_set_boolean (window->priv->settings_listing, PREF_LISTING_SHOW_PATH"show-path", (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT)); | |||
7295 | ||||
7296 | fr_window_update_file_list (window, TRUE(!(0))); | |||
7297 | fr_window_update_dir_tree (window); | |||
7298 | fr_window_update_current_location (window); | |||
7299 | } | |||
7300 | ||||
7301 | ||||
7302 | CtkTreeModel * | |||
7303 | fr_window_get_list_store (FrWindow *window) | |||
7304 | { | |||
7305 | return CTK_TREE_MODEL (window->priv->list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_store)), ((ctk_tree_model_get_type ())))))); | |||
7306 | } | |||
7307 | ||||
7308 | ||||
7309 | void | |||
7310 | fr_window_find (FrWindow *window) | |||
7311 | { | |||
7312 | window->priv->filter_mode = TRUE(!(0)); | |||
7313 | ctk_widget_show (window->priv->filter_bar); | |||
7314 | ctk_widget_grab_focus (window->priv->filter_entry); | |||
7315 | } | |||
7316 | ||||
7317 | ||||
7318 | void | |||
7319 | fr_window_select_all (FrWindow *window) | |||
7320 | { | |||
7321 | ctk_tree_selection_select_all (ctk_tree_view_get_selection (CTK_TREE_VIEW (window->priv->list_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_view)), ((ctk_tree_view_get_type ())))))))); | |||
7322 | } | |||
7323 | ||||
7324 | ||||
7325 | void | |||
7326 | fr_window_unselect_all (FrWindow *window) | |||
7327 | { | |||
7328 | ctk_tree_selection_unselect_all (ctk_tree_view_get_selection (CTK_TREE_VIEW (window->priv->list_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_view)), ((ctk_tree_view_get_type ())))))))); | |||
7329 | } | |||
7330 | ||||
7331 | ||||
7332 | void | |||
7333 | fr_window_set_sort_type (FrWindow *window, | |||
7334 | CtkSortType sort_type) | |||
7335 | { | |||
7336 | window->priv->sort_type = sort_type; | |||
7337 | fr_window_update_list_order (window); | |||
7338 | } | |||
7339 | ||||
7340 | ||||
7341 | void | |||
7342 | fr_window_stop (FrWindow *window) | |||
7343 | { | |||
7344 | if (! window->priv->stoppable) | |||
7345 | return; | |||
7346 | ||||
7347 | if (window->priv->activity_ref > 0) | |||
7348 | fr_archive_stop (window->archive); | |||
7349 | ||||
7350 | if (window->priv->convert_data.converting) | |||
7351 | fr_window_convert_data_free (window, TRUE(!(0))); | |||
7352 | } | |||
7353 | ||||
7354 | ||||
7355 | /* -- start/stop activity mode -- */ | |||
7356 | ||||
7357 | ||||
7358 | static int | |||
7359 | activity_cb (gpointer data) | |||
7360 | { | |||
7361 | FrWindow *window = data; | |||
7362 | ||||
7363 | if ((window->priv->pd_progress_bar != NULL((void*)0)) && window->priv->progress_pulse) | |||
7364 | ctk_progress_bar_pulse (CTK_PROGRESS_BAR (window->priv->pd_progress_bar)((((CtkProgressBar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->pd_progress_bar)), ((ctk_progress_bar_get_type ()))))))); | |||
7365 | if (window->priv->progress_pulse) | |||
7366 | ctk_progress_bar_pulse (CTK_PROGRESS_BAR (window->priv->progress_bar)((((CtkProgressBar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->progress_bar)), ((ctk_progress_bar_get_type ()))))))); | |||
7367 | ||||
7368 | return TRUE(!(0)); | |||
7369 | } | |||
7370 | ||||
7371 | ||||
7372 | void | |||
7373 | fr_window_start_activity_mode (FrWindow *window) | |||
7374 | { | |||
7375 | g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return; } } while (0); | |||
7376 | ||||
7377 | if (window->priv->activity_ref++ > 0) | |||
7378 | return; | |||
7379 | ||||
7380 | window->priv->activity_timeout_handle = g_timeout_add (ACTIVITY_DELAY100, | |||
7381 | activity_cb, | |||
7382 | window); | |||
7383 | fr_window_update_sensitivity (window); | |||
7384 | } | |||
7385 | ||||
7386 | ||||
7387 | void | |||
7388 | fr_window_stop_activity_mode (FrWindow *window) | |||
7389 | { | |||
7390 | g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return; } } while (0); | |||
7391 | ||||
7392 | if (window->priv->activity_ref == 0) | |||
7393 | return; | |||
7394 | ||||
7395 | window->priv->activity_ref--; | |||
7396 | ||||
7397 | if (window->priv->activity_ref > 0) | |||
7398 | return; | |||
7399 | ||||
7400 | if (window->priv->activity_timeout_handle == 0) | |||
7401 | return; | |||
7402 | ||||
7403 | g_source_remove (window->priv->activity_timeout_handle); | |||
7404 | window->priv->activity_timeout_handle = 0; | |||
7405 | ||||
7406 | if (! ctk_widget_get_realized (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))) | |||
7407 | return; | |||
7408 | ||||
7409 | if (window->priv->progress_dialog != NULL((void*)0)) | |||
7410 | ctk_progress_bar_set_fraction (CTK_PROGRESS_BAR (window->priv->pd_progress_bar)((((CtkProgressBar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->pd_progress_bar)), ((ctk_progress_bar_get_type ())))))), 0.0); | |||
7411 | ||||
7412 | if (! window->priv->batch_mode) { | |||
7413 | if (window->priv->progress_bar != NULL((void*)0)) | |||
7414 | ctk_progress_bar_set_fraction (CTK_PROGRESS_BAR (window->priv->progress_bar)((((CtkProgressBar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->progress_bar)), ((ctk_progress_bar_get_type ())))))), 0.0); | |||
7415 | fr_window_update_sensitivity (window); | |||
7416 | } | |||
7417 | } | |||
7418 | ||||
7419 | ||||
7420 | static gboolean | |||
7421 | last_output_window__unrealize_cb (CtkWidget *widget, | |||
7422 | gpointer data G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
7423 | { | |||
7424 | pref_util_save_window_geometry (CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_window_get_type ())))))), LAST_OUTPUT_DIALOG_NAME"last-output"); | |||
7425 | return FALSE(0); | |||
7426 | } | |||
7427 | ||||
7428 | ||||
7429 | static void | |||
7430 | fr_window_view_last_output_print(CtkTextBuffer *text_buffer, | |||
7431 | CtkTextIter *iter, | |||
7432 | GList *scan) | |||
7433 | { | |||
7434 | for (; scan; scan = scan->next) { | |||
7435 | char *line = scan->data; | |||
7436 | char *utf8_line; | |||
7437 | gsize bytes_written; | |||
7438 | ||||
7439 | utf8_line = g_locale_to_utf8 (line, -1, NULL((void*)0), &bytes_written, NULL((void*)0)); | |||
7440 | ctk_text_buffer_insert_with_tags_by_name (text_buffer, | |||
7441 | iter, | |||
7442 | utf8_line, | |||
7443 | bytes_written, | |||
7444 | "monospace", NULL((void*)0)); | |||
7445 | g_free (utf8_line); | |||
7446 | ctk_text_buffer_insert (text_buffer, iter, "\n", 1); | |||
7447 | } | |||
7448 | } | |||
7449 | ||||
7450 | void | |||
7451 | fr_window_view_last_output (FrWindow *window, | |||
7452 | const char *title) | |||
7453 | { | |||
7454 | CtkWidget *dialog; | |||
7455 | CtkWidget *vbox; | |||
7456 | CtkWidget *text_view; | |||
7457 | CtkWidget *scrolled; | |||
7458 | CtkTextBuffer *text_buffer; | |||
7459 | CtkTextIter iter; | |||
7460 | ||||
7461 | if (title == NULL((void*)0)) | |||
7462 | title = _("Last Output")gettext ("Last Output"); | |||
7463 | ||||
7464 | dialog = ctk_dialog_new (); | |||
7465 | ctk_window_set_title (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), title); | |||
7466 | ctk_window_set_transient_for (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ()))))))); | |||
7467 | ctk_window_set_destroy_with_parent (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), TRUE(!(0))); | |||
7468 | ctk_dialog_add_button (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), CTK_STOCK_CLOSE((CtkStock)"ctk-close"), CTK_RESPONSE_CLOSE); | |||
7469 | ||||
7470 | ctk_dialog_set_default_response (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), CTK_RESPONSE_CLOSE); | |||
7471 | ctk_window_set_resizable (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), TRUE(!(0))); | |||
7472 | ctk_widget_set_size_request (dialog, 500, 300); | |||
7473 | ||||
7474 | /* Add text */ | |||
7475 | ||||
7476 | scrolled = ctk_scrolled_window_new (NULL((void*)0), NULL((void*)0)); | |||
7477 | ctk_scrolled_window_set_policy (CTK_SCROLLED_WINDOW (scrolled)((((CtkScrolledWindow*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((scrolled)), ((ctk_scrolled_window_get_type ())))))), | |||
7478 | CTK_POLICY_AUTOMATIC, | |||
7479 | CTK_POLICY_AUTOMATIC); | |||
7480 | ctk_scrolled_window_set_shadow_type (CTK_SCROLLED_WINDOW (scrolled)((((CtkScrolledWindow*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((scrolled)), ((ctk_scrolled_window_get_type ())))))), | |||
7481 | CTK_SHADOW_ETCHED_IN); | |||
7482 | ||||
7483 | text_buffer = ctk_text_buffer_new (NULL((void*)0)); | |||
7484 | ctk_text_buffer_create_tag (text_buffer, "monospace", | |||
7485 | "family", "monospace", NULL((void*)0)); | |||
7486 | ||||
7487 | text_view = ctk_text_view_new_with_buffer (text_buffer); | |||
7488 | g_object_unref (text_buffer); | |||
7489 | ctk_text_view_set_editable (CTK_TEXT_VIEW (text_view)((((CtkTextView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((text_view)), ((ctk_text_view_get_type ())))))), FALSE(0)); | |||
7490 | ctk_text_view_set_cursor_visible (CTK_TEXT_VIEW (text_view)((((CtkTextView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((text_view)), ((ctk_text_view_get_type ())))))), FALSE(0)); | |||
7491 | ||||
7492 | /**/ | |||
7493 | ||||
7494 | vbox = ctk_box_new (CTK_ORIENTATION_VERTICAL, 6); | |||
7495 | ctk_container_set_border_width (CTK_CONTAINER (vbox)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((vbox)), ((ctk_container_get_type ())))))), 5); | |||
7496 | ||||
7497 | ctk_container_add (CTK_CONTAINER (scrolled)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((scrolled)), ((ctk_container_get_type ())))))), text_view); | |||
7498 | ctk_box_pack_start (CTK_BOX (vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((vbox)), ((ctk_box_get_type ())))))), scrolled, | |||
7499 | TRUE(!(0)), TRUE(!(0)), 0); | |||
7500 | ||||
7501 | ctk_widget_show_all (vbox); | |||
7502 | ctk_box_pack_start (CTK_BOX (ctk_dialog_get_content_area (CTK_DIALOG (dialog)))((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_dialog_get_content_area (((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((dialog)), ((ctk_dialog_get_type ())))))) ))), ((ctk_box_get_type ())))))), | |||
7503 | vbox, | |||
7504 | TRUE(!(0)), TRUE(!(0)), 0); | |||
7505 | ||||
7506 | /* signals */ | |||
7507 | ||||
7508 | g_signal_connect (G_OBJECT (dialog),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((dialog)), (((GType) ((20) << (2))) )))))), ("response"), (((GCallback) (ctk_widget_destroy))), ( ((void*)0)), ((void*)0), (GConnectFlags) 0) | |||
7509 | "response",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((dialog)), (((GType) ((20) << (2))) )))))), ("response"), (((GCallback) (ctk_widget_destroy))), ( ((void*)0)), ((void*)0), (GConnectFlags) 0) | |||
7510 | G_CALLBACK (ctk_widget_destroy),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((dialog)), (((GType) ((20) << (2))) )))))), ("response"), (((GCallback) (ctk_widget_destroy))), ( ((void*)0)), ((void*)0), (GConnectFlags) 0) | |||
7511 | NULL)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((dialog)), (((GType) ((20) << (2))) )))))), ("response"), (((GCallback) (ctk_widget_destroy))), ( ((void*)0)), ((void*)0), (GConnectFlags) 0); | |||
7512 | ||||
7513 | g_signal_connect (G_OBJECT (dialog),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((dialog)), (((GType) ((20) << (2))) )))))), ("unrealize"), (((GCallback) (last_output_window__unrealize_cb ))), (((void*)0)), ((void*)0), (GConnectFlags) 0) | |||
7514 | "unrealize",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((dialog)), (((GType) ((20) << (2))) )))))), ("unrealize"), (((GCallback) (last_output_window__unrealize_cb ))), (((void*)0)), ((void*)0), (GConnectFlags) 0) | |||
7515 | G_CALLBACK (last_output_window__unrealize_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((dialog)), (((GType) ((20) << (2))) )))))), ("unrealize"), (((GCallback) (last_output_window__unrealize_cb ))), (((void*)0)), ((void*)0), (GConnectFlags) 0) | |||
7516 | NULL)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((dialog)), (((GType) ((20) << (2))) )))))), ("unrealize"), (((GCallback) (last_output_window__unrealize_cb ))), (((void*)0)), ((void*)0), (GConnectFlags) 0); | |||
7517 | ||||
7518 | ctk_text_buffer_get_iter_at_offset (text_buffer, &iter, 0); | |||
7519 | /* Show STDOUT of process */ | |||
7520 | fr_window_view_last_output_print(text_buffer, &iter, window->archive->process->out.raw); | |||
7521 | /* Show STDERR of process */ | |||
7522 | fr_window_view_last_output_print(text_buffer, &iter, window->archive->process->err.raw); | |||
7523 | ||||
7524 | /**/ | |||
7525 | ||||
7526 | pref_util_restore_window_geometry (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), LAST_OUTPUT_DIALOG_NAME"last-output"); | |||
7527 | } | |||
7528 | ||||
7529 | ||||
7530 | /* -- fr_window_rename_selection -- */ | |||
7531 | ||||
7532 | ||||
7533 | typedef struct { | |||
7534 | char *path_to_rename; | |||
7535 | char *old_name; | |||
7536 | char *new_name; | |||
7537 | char *current_dir; | |||
7538 | gboolean is_dir; | |||
7539 | gboolean dir_in_archive; | |||
7540 | char *original_path; | |||
7541 | } RenameData; | |||
7542 | ||||
7543 | ||||
7544 | static RenameData* | |||
7545 | rename_data_new (const char *path_to_rename, | |||
7546 | const char *old_name, | |||
7547 | const char *new_name, | |||
7548 | const char *current_dir, | |||
7549 | gboolean is_dir, | |||
7550 | gboolean dir_in_archive, | |||
7551 | const char *original_path) | |||
7552 | { | |||
7553 | RenameData *rdata; | |||
7554 | ||||
7555 | rdata = g_new0 (RenameData, 1)((RenameData *) g_malloc0_n ((1), sizeof (RenameData))); | |||
7556 | rdata->path_to_rename = g_strdup (path_to_rename)g_strdup_inline (path_to_rename); | |||
7557 | if (old_name != NULL((void*)0)) | |||
7558 | rdata->old_name = g_strdup (old_name)g_strdup_inline (old_name); | |||
7559 | if (new_name != NULL((void*)0)) | |||
7560 | rdata->new_name = g_strdup (new_name)g_strdup_inline (new_name); | |||
7561 | if (current_dir != NULL((void*)0)) | |||
7562 | rdata->current_dir = g_strdup (current_dir)g_strdup_inline (current_dir); | |||
7563 | rdata->is_dir = is_dir; | |||
7564 | rdata->dir_in_archive = dir_in_archive; | |||
7565 | if (original_path != NULL((void*)0)) | |||
7566 | rdata->original_path = g_strdup (original_path)g_strdup_inline (original_path); | |||
7567 | ||||
7568 | return rdata; | |||
7569 | } | |||
7570 | ||||
7571 | ||||
7572 | static void | |||
7573 | rename_data_free (RenameData *rdata) | |||
7574 | { | |||
7575 | g_return_if_fail (rdata != NULL)do { if ((rdata != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "rdata != NULL"); return; } } while (0); | |||
7576 | ||||
7577 | g_free (rdata->path_to_rename); | |||
7578 | g_free (rdata->old_name); | |||
7579 | g_free (rdata->new_name); | |||
7580 | g_free (rdata->current_dir); | |||
7581 | g_free (rdata->original_path); | |||
7582 | g_free (rdata); | |||
7583 | } | |||
7584 | ||||
7585 | ||||
7586 | static void | |||
7587 | rename_selection (FrWindow *window, | |||
7588 | const char *path_to_rename, | |||
7589 | const char *old_name, | |||
7590 | const char *new_name, | |||
7591 | const char *current_dir, | |||
7592 | gboolean is_dir, | |||
7593 | gboolean dir_in_archive, | |||
7594 | const char *original_path) | |||
7595 | { | |||
7596 | FrArchive *archive = window->archive; | |||
7597 | RenameData *rdata; | |||
7598 | char *tmp_dir; | |||
7599 | GList *file_list; | |||
7600 | gboolean added_dir; | |||
7601 | char *new_dirname; | |||
7602 | GList *new_file_list; | |||
7603 | GList *scan; | |||
7604 | ||||
7605 | rdata = rename_data_new (path_to_rename, | |||
7606 | old_name, | |||
7607 | new_name, | |||
7608 | current_dir, | |||
7609 | is_dir, | |||
7610 | dir_in_archive, | |||
7611 | original_path); | |||
7612 | fr_window_set_current_batch_action (window, | |||
7613 | FR_BATCH_ACTION_RENAME, | |||
7614 | rdata, | |||
7615 | (GFreeFunc) rename_data_free); | |||
7616 | ||||
7617 | fr_process_clear (archive->process); | |||
7618 | ||||
7619 | tmp_dir = get_temp_work_dir (NULL((void*)0)); | |||
7620 | ||||
7621 | if (is_dir) | |||
7622 | file_list = get_dir_list_from_path (window, rdata->path_to_rename); | |||
7623 | else | |||
7624 | file_list = g_list_append (NULL((void*)0), g_strdup (rdata->path_to_rename)g_strdup_inline (rdata->path_to_rename)); | |||
7625 | ||||
7626 | fr_archive_extract_to_local (archive, | |||
7627 | file_list, | |||
7628 | tmp_dir, | |||
7629 | NULL((void*)0), | |||
7630 | FALSE(0), | |||
7631 | TRUE(!(0)), | |||
7632 | FALSE(0), | |||
7633 | window->priv->password); | |||
7634 | ||||
7635 | /* temporarily add the dir to rename to the list if it's stored in the | |||
7636 | * archive, this way it will be removed from the archive... */ | |||
7637 | added_dir = FALSE(0); | |||
7638 | if (is_dir
| |||
7639 | file_list = g_list_prepend (file_list, g_strdup (original_path)g_strdup_inline (original_path)); | |||
7640 | added_dir = TRUE(!(0)); | |||
7641 | } | |||
7642 | ||||
7643 | fr_archive_remove (archive, file_list, window->priv->compression); | |||
7644 | fr_window_clipboard_remove_file_list (window, file_list); | |||
7645 | ||||
7646 | /* ...and remove it from the list again */ | |||
7647 | if (added_dir
| |||
7648 | GList *tmp; | |||
7649 | ||||
7650 | tmp = file_list; | |||
7651 | file_list = g_list_remove_link (file_list, tmp); | |||
7652 | ||||
7653 | g_free (tmp->data); | |||
7654 | g_list_free (tmp); | |||
7655 | } | |||
7656 | ||||
7657 | /* rename the files. */ | |||
7658 | ||||
7659 | new_dirname = g_build_filename (rdata->current_dir + 1, rdata->new_name, "/", NULL((void*)0)); | |||
7660 | new_file_list = NULL((void*)0); | |||
7661 | if (rdata->is_dir
| |||
7662 | char *old_path; | |||
7663 | char *new_path; | |||
7664 | ||||
7665 | old_path = g_build_filename (tmp_dir, rdata->current_dir, rdata->old_name, NULL((void*)0)); | |||
7666 | new_path = g_build_filename (tmp_dir, rdata->current_dir, rdata->new_name, NULL((void*)0)); | |||
7667 | ||||
7668 | fr_process_begin_command (archive->process, "mv"); | |||
7669 | fr_process_add_arg (archive->process, "-f"); | |||
7670 | fr_process_add_arg (archive->process, old_path); | |||
7671 | fr_process_add_arg (archive->process, new_path); | |||
7672 | fr_process_end_command (archive->process); | |||
7673 | ||||
7674 | g_free (old_path); | |||
7675 | g_free (new_path); | |||
7676 | } | |||
7677 | ||||
7678 | for (scan = file_list; scan; scan = scan->next) { | |||
7679 | const char *current_dir_relative = rdata->current_dir + 1; | |||
7680 | const char *filename = (char*) scan->data; | |||
7681 | char *old_path = NULL((void*)0), *common = NULL((void*)0), *new_path = NULL((void*)0); | |||
7682 | char *new_filename; | |||
7683 | ||||
7684 | old_path = g_build_filename (tmp_dir, filename, NULL((void*)0)); | |||
7685 | ||||
7686 | if (strlen (filename) > (strlen (rdata->current_dir) + strlen (rdata->old_name))) | |||
| ||||
7687 | common = g_strdup (filename + strlen (rdata->current_dir) + strlen (rdata->old_name))g_strdup_inline (filename + strlen (rdata->current_dir) + strlen (rdata->old_name)); | |||
7688 | new_path = g_build_filename (tmp_dir, rdata->current_dir, rdata->new_name, common, NULL((void*)0)); | |||
7689 | ||||
7690 | if (! rdata->is_dir) { | |||
7691 | fr_process_begin_command (archive->process, "mv"); | |||
7692 | fr_process_add_arg (archive->process, "-f"); | |||
7693 | fr_process_add_arg (archive->process, old_path); | |||
7694 | fr_process_add_arg (archive->process, new_path); | |||
7695 | fr_process_end_command (archive->process); | |||
7696 | } | |||
7697 | ||||
7698 | new_filename = g_build_filename (current_dir_relative, rdata->new_name, common, NULL((void*)0)); | |||
7699 | new_file_list = g_list_prepend (new_file_list, new_filename); | |||
7700 | ||||
7701 | g_free (old_path); | |||
7702 | g_free (common); | |||
7703 | g_free (new_path); | |||
7704 | } | |||
7705 | new_file_list = g_list_reverse (new_file_list); | |||
7706 | ||||
7707 | /* FIXME: this is broken for tar archives. | |||
7708 | if (is_dir && dir_in_archive && ! g_list_find_custom (new_file_list, new_dirname, (GCompareFunc) strcmp)) | |||
7709 | new_file_list = g_list_prepend (new_file_list, g_build_filename (rdata->current_dir + 1, rdata->new_name, NULL)); | |||
7710 | */ | |||
7711 | ||||
7712 | fr_archive_add (archive, | |||
7713 | new_file_list, | |||
7714 | tmp_dir, | |||
7715 | NULL((void*)0), | |||
7716 | FALSE(0), | |||
7717 | FALSE(0), | |||
7718 | window->priv->password, | |||
7719 | window->priv->encrypt_header, | |||
7720 | window->priv->compression, | |||
7721 | window->priv->volume_size); | |||
7722 | ||||
7723 | g_free (new_dirname); | |||
7724 | path_list_free (new_file_list); | |||
7725 | path_list_free (file_list); | |||
7726 | ||||
7727 | /* remove the tmp dir */ | |||
7728 | ||||
7729 | fr_process_begin_command (archive->process, "rm"); | |||
7730 | fr_process_set_working_dir (archive->process, g_get_tmp_dir ()); | |||
7731 | fr_process_set_sticky (archive->process, TRUE(!(0))); | |||
7732 | fr_process_add_arg (archive->process, "-rf"); | |||
7733 | fr_process_add_arg (archive->process, tmp_dir); | |||
7734 | fr_process_end_command (archive->process); | |||
7735 | ||||
7736 | fr_process_start (archive->process); | |||
7737 | ||||
7738 | g_free (tmp_dir); | |||
7739 | } | |||
7740 | ||||
7741 | ||||
7742 | static gboolean | |||
7743 | valid_name (const char *new_name, | |||
7744 | const char *old_name, | |||
7745 | char **reason) | |||
7746 | { | |||
7747 | char *utf8_new_name; | |||
7748 | gboolean retval = TRUE(!(0)); | |||
7749 | ||||
7750 | new_name = eat_spaces (new_name); | |||
7751 | utf8_new_name = g_filename_display_name (new_name); | |||
7752 | ||||
7753 | if (*new_name == '\0') { | |||
7754 | /* Translators: the name references to a filename. This message can appear when renaming a file. */ | |||
7755 | *reason = g_strdup (_("New name is void, please type a name."))g_strdup_inline (gettext ("New name is void, please type a name." )); | |||
7756 | retval = FALSE(0); | |||
7757 | } | |||
7758 | else if (strcmp (new_name, old_name) == 0) { | |||
7759 | /* Translators: the name references to a filename. This message can appear when renaming a file. */ | |||
7760 | *reason = g_strdup (_("New name is the same as old one, please type other name."))g_strdup_inline (gettext ("New name is the same as old one, please type other name." )); | |||
7761 | retval = FALSE(0); | |||
7762 | } | |||
7763 | else if (strchrs (new_name, BAD_CHARS"/\\*")) { | |||
7764 | /* Translators: the %s references to a filename. This message can appear when renaming a file. */ | |||
7765 | *reason = g_strdup_printf (_("Name \"%s\" is not valid because it contains at least one of the following characters: %s, please type other name.")gettext ("Name \"%s\" is not valid because it contains at least one of the following characters: %s, please type other name." ), utf8_new_name, BAD_CHARS"/\\*"); | |||
7766 | retval = FALSE(0); | |||
7767 | } | |||
7768 | ||||
7769 | g_free (utf8_new_name); | |||
7770 | ||||
7771 | return retval; | |||
7772 | } | |||
7773 | ||||
7774 | ||||
7775 | static gboolean | |||
7776 | name_is_present (FrWindow *window, | |||
7777 | const char *current_dir, | |||
7778 | const char *new_name, | |||
7779 | char **reason) | |||
7780 | { | |||
7781 | gboolean retval = FALSE(0); | |||
7782 | guint i; | |||
7783 | char *new_filename; | |||
7784 | int new_filename_l; | |||
7785 | ||||
7786 | *reason = NULL((void*)0); | |||
7787 | ||||
7788 | new_filename = g_build_filename (current_dir, new_name, NULL((void*)0)); | |||
7789 | new_filename_l = strlen (new_filename); | |||
7790 | ||||
7791 | for (i = 0; i < window->archive->command->files->len; i++) { | |||
7792 | FileData *fdata = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i]; | |||
7793 | const char *filename = fdata->full_path; | |||
7794 | ||||
7795 | if ((strncmp (filename, new_filename, new_filename_l) == 0) | |||
7796 | && ((filename[new_filename_l] == '\0') | |||
7797 | || (filename[new_filename_l] == G_DIR_SEPARATOR'/'))) { | |||
7798 | char *utf8_name = g_filename_display_name (new_name); | |||
7799 | ||||
7800 | if (filename[new_filename_l] == G_DIR_SEPARATOR'/') | |||
7801 | *reason = g_strdup_printf (_("A folder named \"%s\" already exists.\n\n%s")gettext ("A folder named \"%s\" already exists.\n\n%s"), utf8_name, _("Please use a different name.")gettext ("Please use a different name.")); | |||
7802 | else | |||
7803 | *reason = g_strdup_printf (_("A file named \"%s\" already exists.\n\n%s")gettext ("A file named \"%s\" already exists.\n\n%s"), utf8_name, _("Please use a different name.")gettext ("Please use a different name.")); | |||
7804 | ||||
7805 | retval = TRUE(!(0)); | |||
7806 | break; | |||
7807 | } | |||
7808 | } | |||
7809 | ||||
7810 | g_free (new_filename); | |||
7811 | ||||
7812 | return retval; | |||
7813 | } | |||
7814 | ||||
7815 | ||||
7816 | void | |||
7817 | fr_window_rename_selection (FrWindow *window, | |||
7818 | gboolean from_sidebar) | |||
7819 | { | |||
7820 | char *path_to_rename; | |||
7821 | char *parent_dir; | |||
7822 | char *old_name; | |||
7823 | gboolean renaming_dir = FALSE(0); | |||
7824 | gboolean dir_in_archive = FALSE(0); | |||
7825 | char *original_path = NULL((void*)0); | |||
7826 | char *utf8_old_name; | |||
7827 | char *utf8_new_name; | |||
7828 | ||||
7829 | if (from_sidebar) { | |||
7830 | path_to_rename = fr_window_get_selected_folder_in_tree_view (window); | |||
7831 | if (path_to_rename == NULL((void*)0)) | |||
7832 | return; | |||
7833 | parent_dir = remove_level_from_path (path_to_rename); | |||
7834 | old_name = g_strdup (file_name_from_path (path_to_rename))g_strdup_inline (file_name_from_path (path_to_rename)); | |||
7835 | renaming_dir = TRUE(!(0)); | |||
7836 | } | |||
7837 | else { | |||
7838 | FileData *selected_item; | |||
7839 | ||||
7840 | selected_item = fr_window_get_selected_item_from_file_list (window); | |||
7841 | if (selected_item == NULL((void*)0)) | |||
7842 | return; | |||
7843 | ||||
7844 | renaming_dir = file_data_is_dir (selected_item); | |||
7845 | dir_in_archive = selected_item->dir; | |||
7846 | original_path = g_strdup (selected_item->original_path)g_strdup_inline (selected_item->original_path); | |||
7847 | ||||
7848 | if (renaming_dir && ! dir_in_archive) { | |||
7849 | parent_dir = g_strdup (fr_window_get_current_location (window))g_strdup_inline (fr_window_get_current_location (window)); | |||
7850 | old_name = g_strdup (selected_item->list_name)g_strdup_inline (selected_item->list_name); | |||
7851 | path_to_rename = g_build_filename (parent_dir, old_name, NULL((void*)0)); | |||
7852 | } | |||
7853 | else { | |||
7854 | if (renaming_dir) { | |||
7855 | path_to_rename = remove_ending_separator (selected_item->full_path); | |||
7856 | parent_dir = remove_level_from_path (path_to_rename); | |||
7857 | } | |||
7858 | else { | |||
7859 | path_to_rename = g_strdup (selected_item->original_path)g_strdup_inline (selected_item->original_path); | |||
7860 | parent_dir = remove_level_from_path (selected_item->full_path); | |||
7861 | } | |||
7862 | old_name = g_strdup (selected_item->name)g_strdup_inline (selected_item->name); | |||
7863 | } | |||
7864 | ||||
7865 | file_data_free (selected_item); | |||
7866 | } | |||
7867 | ||||
7868 | retry__rename_selection: | |||
7869 | utf8_old_name = g_locale_to_utf8 (old_name, -1 ,0 ,0 ,0); | |||
7870 | utf8_new_name = _ctk_request_dialog_run (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), | |||
7871 | (CTK_DIALOG_DESTROY_WITH_PARENT | |||
7872 | | CTK_DIALOG_MODAL), | |||
7873 | _("Rename")gettext ("Rename"), | |||
7874 | (renaming_dir ? _("_New folder name:")gettext ("_New folder name:") : _("_New file name:")gettext ("_New file name:")), | |||
7875 | utf8_old_name, | |||
7876 | 1024, | |||
7877 | _("_Cancel")gettext ("_Cancel"), | |||
7878 | _("_Rename")gettext ("_Rename")); | |||
7879 | g_free (utf8_old_name); | |||
7880 | ||||
7881 | if (utf8_new_name != NULL((void*)0)) { | |||
7882 | char *new_name; | |||
7883 | char *reason = NULL((void*)0); | |||
7884 | ||||
7885 | new_name = g_filename_from_utf8 (utf8_new_name, -1, 0, 0, 0); | |||
7886 | g_free (utf8_new_name); | |||
7887 | ||||
7888 | if (! valid_name (new_name, old_name, &reason)) { | |||
7889 | char *utf8_name = g_filename_display_name (new_name); | |||
7890 | CtkWidget *dlg; | |||
7891 | ||||
7892 | dlg = _ctk_error_dialog_new (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), | |||
7893 | CTK_DIALOG_DESTROY_WITH_PARENT, | |||
7894 | NULL((void*)0), | |||
7895 | (renaming_dir ? _("Could not rename the folder")gettext ("Could not rename the folder") : _("Could not rename the file")gettext ("Could not rename the file")), | |||
7896 | "%s", | |||
7897 | reason); | |||
7898 | ctk_dialog_run (CTK_DIALOG (dlg)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dlg)), ((ctk_dialog_get_type ()))))))); | |||
7899 | ctk_widget_destroy (dlg); | |||
7900 | ||||
7901 | g_free (reason); | |||
7902 | g_free (utf8_name); | |||
7903 | g_free (new_name); | |||
7904 | ||||
7905 | goto retry__rename_selection; | |||
7906 | } | |||
7907 | ||||
7908 | if (name_is_present (window, parent_dir, new_name, &reason)) { | |||
7909 | CtkWidget *dlg; | |||
7910 | ||||
7911 | dlg = _ctk_message_dialog_new (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), | |||
7912 | CTK_DIALOG_MODAL, | |||
7913 | "dialog-question", | |||
7914 | (renaming_dir ? _("Could not rename the folder")gettext ("Could not rename the folder") : _("Could not rename the file")gettext ("Could not rename the file")), | |||
7915 | reason, | |||
7916 | CTK_STOCK_CLOSE((CtkStock)"ctk-close"), CTK_RESPONSE_OK, | |||
7917 | NULL((void*)0)); | |||
7918 | ctk_dialog_run (CTK_DIALOG (dlg)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dlg)), ((ctk_dialog_get_type ()))))))); | |||
7919 | ctk_widget_destroy (dlg); | |||
7920 | g_free (reason); | |||
7921 | g_free (new_name); | |||
7922 | goto retry__rename_selection; | |||
7923 | } | |||
7924 | ||||
7925 | rename_selection (window, | |||
7926 | path_to_rename, | |||
7927 | old_name, | |||
7928 | new_name, | |||
7929 | parent_dir, | |||
7930 | renaming_dir, | |||
7931 | dir_in_archive, | |||
7932 | original_path); | |||
7933 | ||||
7934 | g_free (new_name); | |||
7935 | } | |||
7936 | ||||
7937 | g_free (old_name); | |||
7938 | g_free (parent_dir); | |||
7939 | g_free (path_to_rename); | |||
7940 | g_free (original_path); | |||
7941 | } | |||
7942 | ||||
7943 | ||||
7944 | static void | |||
7945 | fr_clipboard_get (CtkClipboard *clipboard G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
7946 | CtkSelectionData *selection_data, | |||
7947 | guint info G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
7948 | gpointer user_data_or_owner) | |||
7949 | { | |||
7950 | FrWindow *window = user_data_or_owner; | |||
7951 | char *data; | |||
7952 | ||||
7953 | if (ctk_selection_data_get_target (selection_data) != FR_SPECIAL_URI_LIST(cdk_atom_intern_static_string ("application/grapa-uri-list") )) | |||
7954 | return; | |||
7955 | ||||
7956 | data = get_selection_data_from_clipboard_data (window, window->priv->copy_data); | |||
7957 | ctk_selection_data_set (selection_data, | |||
7958 | ctk_selection_data_get_target (selection_data), | |||
7959 | 8, | |||
7960 | (guchar *) data, | |||
7961 | strlen (data)); | |||
7962 | g_free (data); | |||
7963 | } | |||
7964 | ||||
7965 | ||||
7966 | static void | |||
7967 | fr_clipboard_clear (CtkClipboard *clipboard G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
7968 | gpointer user_data_or_owner) | |||
7969 | { | |||
7970 | FrWindow *window = user_data_or_owner; | |||
7971 | ||||
7972 | if (window->priv->copy_data != NULL((void*)0)) { | |||
7973 | fr_clipboard_data_unref (window->priv->copy_data); | |||
7974 | window->priv->copy_data = NULL((void*)0); | |||
7975 | } | |||
7976 | } | |||
7977 | ||||
7978 | ||||
7979 | GList * | |||
7980 | fr_window_get_selection (FrWindow *window, | |||
7981 | gboolean from_sidebar, | |||
7982 | char **return_base_dir) | |||
7983 | { | |||
7984 | GList *files; | |||
7985 | char *base_dir; | |||
7986 | ||||
7987 | if (from_sidebar) { | |||
7988 | char *selected_folder; | |||
7989 | char *parent_folder; | |||
7990 | ||||
7991 | files = fr_window_get_folder_tree_selection (window, TRUE(!(0)), NULL((void*)0)); | |||
7992 | selected_folder = fr_window_get_selected_folder_in_tree_view (window); | |||
7993 | parent_folder = remove_level_from_path (selected_folder); | |||
7994 | if (parent_folder == NULL((void*)0)) | |||
7995 | base_dir = g_strdup ("/")g_strdup_inline ("/"); | |||
7996 | else if (parent_folder[strlen (parent_folder) - 1] == '/') | |||
7997 | base_dir = g_strdup (parent_folder)g_strdup_inline (parent_folder); | |||
7998 | else | |||
7999 | base_dir = g_strconcat (parent_folder, "/", NULL((void*)0)); | |||
8000 | g_free (selected_folder); | |||
8001 | g_free (parent_folder); | |||
8002 | } | |||
8003 | else { | |||
8004 | files = fr_window_get_file_list_selection (window, TRUE(!(0)), NULL((void*)0)); | |||
8005 | base_dir = g_strdup (fr_window_get_current_location (window))g_strdup_inline (fr_window_get_current_location (window)); | |||
8006 | } | |||
8007 | ||||
8008 | if (return_base_dir) | |||
8009 | *return_base_dir = base_dir; | |||
8010 | else | |||
8011 | g_free (base_dir); | |||
8012 | ||||
8013 | return files; | |||
8014 | } | |||
8015 | ||||
8016 | ||||
8017 | static void | |||
8018 | fr_window_copy_or_cut_selection (FrWindow *window, | |||
8019 | FRClipboardOp op, | |||
8020 | gboolean from_sidebar) | |||
8021 | { | |||
8022 | GList *files; | |||
8023 | char *base_dir; | |||
8024 | CtkClipboard *clipboard; | |||
8025 | ||||
8026 | files = fr_window_get_selection (window, from_sidebar, &base_dir); | |||
8027 | ||||
8028 | if (window->priv->copy_data != NULL((void*)0)) | |||
8029 | fr_clipboard_data_unref (window->priv->copy_data); | |||
8030 | window->priv->copy_data = fr_clipboard_data_new (); | |||
8031 | window->priv->copy_data->files = files; | |||
8032 | window->priv->copy_data->op = op; | |||
8033 | window->priv->copy_data->base_dir = base_dir; | |||
8034 | ||||
8035 | clipboard = ctk_clipboard_get (FR_CLIPBOARD(cdk_atom_intern_static_string ("_RNGRAMPA_SPECIAL_CLIPBOARD" ))); | |||
8036 | ctk_clipboard_set_with_owner (clipboard, | |||
8037 | clipboard_targets, | |||
8038 | G_N_ELEMENTS (clipboard_targets)(sizeof (clipboard_targets) / sizeof ((clipboard_targets)[0]) ), | |||
8039 | fr_clipboard_get, | |||
8040 | fr_clipboard_clear, | |||
8041 | G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2))))))))); | |||
8042 | ||||
8043 | fr_window_update_sensitivity (window); | |||
8044 | } | |||
8045 | ||||
8046 | ||||
8047 | void | |||
8048 | fr_window_copy_selection (FrWindow *window, | |||
8049 | gboolean from_sidebar) | |||
8050 | { | |||
8051 | fr_window_copy_or_cut_selection (window, FR_CLIPBOARD_OP_COPY, from_sidebar); | |||
8052 | } | |||
8053 | ||||
8054 | ||||
8055 | void | |||
8056 | fr_window_cut_selection (FrWindow *window, | |||
8057 | gboolean from_sidebar) | |||
8058 | { | |||
8059 | fr_window_copy_or_cut_selection (window, FR_CLIPBOARD_OP_CUT, from_sidebar); | |||
8060 | } | |||
8061 | ||||
8062 | ||||
8063 | static gboolean | |||
8064 | always_fake_load (FrArchive *archive G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
8065 | gpointer data G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
8066 | { | |||
8067 | return TRUE(!(0)); | |||
8068 | } | |||
8069 | ||||
8070 | ||||
8071 | static void | |||
8072 | add_pasted_files (FrWindow *window, | |||
8073 | FrClipboardData *data) | |||
8074 | { | |||
8075 | const char *current_dir_relative = data->current_dir + 1; | |||
8076 | GList *scan; | |||
8077 | GList *new_file_list = NULL((void*)0); | |||
8078 | ||||
8079 | if (window->priv->password_for_paste != NULL((void*)0)) { | |||
8080 | g_free (window->priv->password_for_paste); | |||
8081 | window->priv->password_for_paste = NULL((void*)0); | |||
8082 | } | |||
8083 | ||||
8084 | fr_process_clear (window->archive->process); | |||
8085 | for (scan = data->files; scan; scan = scan->next) { | |||
8086 | const char *old_name = (char*) scan->data; | |||
8087 | char *new_name = g_build_filename (current_dir_relative, old_name + strlen (data->base_dir) - 1, NULL((void*)0)); | |||
8088 | ||||
8089 | /* skip folders */ | |||
8090 | ||||
8091 | if ((strcmp (old_name, new_name) != 0) | |||
8092 | && (old_name[strlen (old_name) - 1] != '/')) | |||
8093 | { | |||
8094 | fr_process_begin_command (window->archive->process, "mv"); | |||
8095 | fr_process_set_working_dir (window->archive->process, data->tmp_dir); | |||
8096 | fr_process_add_arg (window->archive->process, "-f"); | |||
8097 | if (old_name[0] == '/') | |||
8098 | old_name = old_name + 1; | |||
8099 | fr_process_add_arg (window->archive->process, old_name); | |||
8100 | fr_process_add_arg (window->archive->process, new_name); | |||
8101 | fr_process_end_command (window->archive->process); | |||
8102 | } | |||
8103 | ||||
8104 | new_file_list = g_list_prepend (new_file_list, new_name); | |||
8105 | } | |||
8106 | ||||
8107 | fr_archive_add (window->archive, | |||
8108 | new_file_list, | |||
8109 | data->tmp_dir, | |||
8110 | NULL((void*)0), | |||
8111 | FALSE(0), | |||
8112 | FALSE(0), | |||
8113 | window->priv->password, | |||
8114 | window->priv->encrypt_header, | |||
8115 | window->priv->compression, | |||
8116 | window->priv->volume_size); | |||
8117 | ||||
8118 | path_list_free (new_file_list); | |||
8119 | ||||
8120 | /* remove the tmp dir */ | |||
8121 | ||||
8122 | fr_process_begin_command (window->archive->process, "rm"); | |||
8123 | fr_process_set_working_dir (window->archive->process, g_get_tmp_dir ()); | |||
8124 | fr_process_set_sticky (window->archive->process, TRUE(!(0))); | |||
8125 | fr_process_add_arg (window->archive->process, "-rf"); | |||
8126 | fr_process_add_arg (window->archive->process, data->tmp_dir); | |||
8127 | fr_process_end_command (window->archive->process); | |||
8128 | ||||
8129 | fr_process_start (window->archive->process); | |||
8130 | } | |||
8131 | ||||
8132 | ||||
8133 | static void | |||
8134 | copy_from_archive_action_performed_cb (FrArchive *archive, | |||
8135 | FrAction action, | |||
8136 | FrProcError *error, | |||
8137 | gpointer data) | |||
8138 | { | |||
8139 | FrWindow *window = data; | |||
8140 | gboolean UNUSED_VARIABLE__attribute__ ((unused)) continue_batch = FALSE(0); | |||
8141 | ||||
8142 | #ifdef CAFE_ENABLE_DEBUG | |||
8143 | debug (DEBUG_INFO"fr-window.c", 8143, __FUNCTION__, "%s [DONE] (FR::Window)\n", get_action_name (action)); | |||
8144 | #endif | |||
8145 | ||||
8146 | fr_window_stop_activity_mode (window); | |||
8147 | fr_window_pop_message (window); | |||
8148 | close_progress_dialog (window, FALSE(0)); | |||
8149 | ||||
8150 | if (error->type == FR_PROC_ERROR_ASK_PASSWORD) { | |||
8151 | dlg_ask_password_for_paste_operation (window); | |||
8152 | return; | |||
8153 | } | |||
8154 | ||||
8155 | (void) handle_errors (window, archive, action, error); | |||
8156 | ||||
8157 | if (error->type != FR_PROC_ERROR_NONE) { | |||
8158 | fr_clipboard_data_unref (window->priv->clipboard_data); | |||
8159 | window->priv->clipboard_data = NULL((void*)0); | |||
8160 | return; | |||
8161 | } | |||
8162 | ||||
8163 | switch (action) { | |||
8164 | case FR_ACTION_LISTING_CONTENT: | |||
8165 | fr_process_clear (window->priv->copy_from_archive->process); | |||
8166 | fr_archive_extract_to_local (window->priv->copy_from_archive, | |||
8167 | window->priv->clipboard_data->files, | |||
8168 | window->priv->clipboard_data->tmp_dir, | |||
8169 | NULL((void*)0), | |||
8170 | FALSE(0), | |||
8171 | TRUE(!(0)), | |||
8172 | FALSE(0), | |||
8173 | window->priv->clipboard_data->archive_password); | |||
8174 | fr_process_start (window->priv->copy_from_archive->process); | |||
8175 | break; | |||
8176 | ||||
8177 | case FR_ACTION_EXTRACTING_FILES: | |||
8178 | if (window->priv->clipboard_data->op == FR_CLIPBOARD_OP_CUT) { | |||
8179 | fr_process_clear (window->priv->copy_from_archive->process); | |||
8180 | fr_archive_remove (window->priv->copy_from_archive, | |||
8181 | window->priv->clipboard_data->files, | |||
8182 | window->priv->compression); | |||
8183 | fr_process_start (window->priv->copy_from_archive->process); | |||
8184 | } | |||
8185 | else | |||
8186 | add_pasted_files (window, window->priv->clipboard_data); | |||
8187 | break; | |||
8188 | ||||
8189 | case FR_ACTION_DELETING_FILES: | |||
8190 | add_pasted_files (window, window->priv->clipboard_data); | |||
8191 | break; | |||
8192 | ||||
8193 | default: | |||
8194 | break; | |||
8195 | } | |||
8196 | } | |||
8197 | ||||
8198 | ||||
8199 | static void | |||
8200 | fr_window_paste_from_clipboard_data (FrWindow *window, | |||
8201 | FrClipboardData *data) | |||
8202 | { | |||
8203 | const char *current_dir_relative; | |||
8204 | GHashTable *created_dirs; | |||
8205 | GList *scan; | |||
8206 | ||||
8207 | if (window->priv->password_for_paste != NULL((void*)0)) | |||
8208 | fr_clipboard_data_set_password (data, window->priv->password_for_paste); | |||
8209 | ||||
8210 | if (window->priv->clipboard_data != data) { | |||
8211 | fr_clipboard_data_unref (window->priv->clipboard_data); | |||
8212 | window->priv->clipboard_data = data; | |||
8213 | } | |||
8214 | ||||
8215 | fr_window_set_current_batch_action (window, | |||
8216 | FR_BATCH_ACTION_PASTE, | |||
8217 | fr_clipboard_data_ref (data), | |||
8218 | (GFreeFunc) fr_clipboard_data_unref); | |||
8219 | ||||
8220 | current_dir_relative = data->current_dir + 1; | |||
8221 | ||||
8222 | data->tmp_dir = get_temp_work_dir (NULL((void*)0)); | |||
8223 | created_dirs = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL((void*)0)); | |||
8224 | for (scan = data->files; scan; scan = scan->next) { | |||
8225 | const char *old_name = (char*) scan->data; | |||
8226 | char *new_name = g_build_filename (current_dir_relative, old_name + strlen (data->base_dir) - 1, NULL((void*)0)); | |||
8227 | char *dir = remove_level_from_path (new_name); | |||
8228 | ||||
8229 | if ((dir != NULL((void*)0)) && (g_hash_table_lookup (created_dirs, dir) == NULL((void*)0))) { | |||
8230 | char *dir_path; | |||
8231 | ||||
8232 | dir_path = g_build_filename (data->tmp_dir, dir, NULL((void*)0)); | |||
8233 | debug (DEBUG_INFO"fr-window.c", 8233, __FUNCTION__, "mktree %s\n", dir_path); | |||
8234 | make_directory_tree_from_path (dir_path, 0700, NULL((void*)0)); | |||
8235 | ||||
8236 | g_free (dir_path); | |||
8237 | g_hash_table_replace (created_dirs, g_strdup (dir)g_strdup_inline (dir), "1"); | |||
8238 | } | |||
8239 | ||||
8240 | g_free (dir); | |||
8241 | g_free (new_name); | |||
8242 | } | |||
8243 | g_hash_table_destroy (created_dirs); | |||
8244 | ||||
8245 | /**/ | |||
8246 | ||||
8247 | if (window->priv->copy_from_archive == NULL((void*)0)) { | |||
8248 | window->priv->copy_from_archive = fr_archive_new (); | |||
8249 | g_signal_connect (G_OBJECT (window->priv->copy_from_archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->copy_from_archive)), (((GType) ((20) << (2))))))))), ("start"), (((GCallback ) (action_started))), (window), ((void*)0), (GConnectFlags) 0 ) | |||
8250 | "start",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->copy_from_archive)), (((GType) ((20) << (2))))))))), ("start"), (((GCallback ) (action_started))), (window), ((void*)0), (GConnectFlags) 0 ) | |||
8251 | G_CALLBACK (action_started),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->copy_from_archive)), (((GType) ((20) << (2))))))))), ("start"), (((GCallback ) (action_started))), (window), ((void*)0), (GConnectFlags) 0 ) | |||
8252 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->copy_from_archive)), (((GType) ((20) << (2))))))))), ("start"), (((GCallback ) (action_started))), (window), ((void*)0), (GConnectFlags) 0 ); | |||
8253 | g_signal_connect (G_OBJECT (window->priv->copy_from_archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->copy_from_archive)), (((GType) ((20) << (2))))))))), ("done"), (((GCallback ) (copy_from_archive_action_performed_cb))), (window), ((void *)0), (GConnectFlags) 0) | |||
8254 | "done",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->copy_from_archive)), (((GType) ((20) << (2))))))))), ("done"), (((GCallback ) (copy_from_archive_action_performed_cb))), (window), ((void *)0), (GConnectFlags) 0) | |||
8255 | G_CALLBACK (copy_from_archive_action_performed_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->copy_from_archive)), (((GType) ((20) << (2))))))))), ("done"), (((GCallback ) (copy_from_archive_action_performed_cb))), (window), ((void *)0), (GConnectFlags) 0) | |||
8256 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->copy_from_archive)), (((GType) ((20) << (2))))))))), ("done"), (((GCallback ) (copy_from_archive_action_performed_cb))), (window), ((void *)0), (GConnectFlags) 0); | |||
8257 | g_signal_connect (G_OBJECT (window->priv->copy_from_archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->copy_from_archive)), (((GType) ((20) << (2))))))))), ("progress"), (((GCallback ) (fr_window_progress_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
8258 | "progress",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->copy_from_archive)), (((GType) ((20) << (2))))))))), ("progress"), (((GCallback ) (fr_window_progress_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
8259 | G_CALLBACK (fr_window_progress_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->copy_from_archive)), (((GType) ((20) << (2))))))))), ("progress"), (((GCallback ) (fr_window_progress_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
8260 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->copy_from_archive)), (((GType) ((20) << (2))))))))), ("progress"), (((GCallback ) (fr_window_progress_cb))), (window), ((void*)0), (GConnectFlags ) 0); | |||
8261 | g_signal_connect (G_OBJECT (window->priv->copy_from_archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->copy_from_archive)), (((GType) ((20) << (2))))))))), ("message"), (((GCallback ) (fr_window_message_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
8262 | "message",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->copy_from_archive)), (((GType) ((20) << (2))))))))), ("message"), (((GCallback ) (fr_window_message_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
8263 | G_CALLBACK (fr_window_message_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->copy_from_archive)), (((GType) ((20) << (2))))))))), ("message"), (((GCallback ) (fr_window_message_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
8264 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->copy_from_archive)), (((GType) ((20) << (2))))))))), ("message"), (((GCallback ) (fr_window_message_cb))), (window), ((void*)0), (GConnectFlags ) 0); | |||
8265 | g_signal_connect (G_OBJECT (window->priv->copy_from_archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->copy_from_archive)), (((GType) ((20) << (2))))))))), ("stoppable"), (((GCallback ) (fr_window_stoppable_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
8266 | "stoppable",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->copy_from_archive)), (((GType) ((20) << (2))))))))), ("stoppable"), (((GCallback ) (fr_window_stoppable_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
8267 | G_CALLBACK (fr_window_stoppable_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->copy_from_archive)), (((GType) ((20) << (2))))))))), ("stoppable"), (((GCallback ) (fr_window_stoppable_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
8268 | window)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->priv->copy_from_archive)), (((GType) ((20) << (2))))))))), ("stoppable"), (((GCallback ) (fr_window_stoppable_cb))), (window), ((void*)0), (GConnectFlags ) 0); | |||
8269 | fr_archive_set_fake_load_func (window->priv->copy_from_archive, always_fake_load, NULL((void*)0)); | |||
8270 | } | |||
8271 | fr_archive_load_local (window->priv->copy_from_archive, | |||
8272 | data->archive_filename, | |||
8273 | data->archive_password); | |||
8274 | } | |||
8275 | ||||
8276 | ||||
8277 | static void | |||
8278 | fr_window_paste_selection_to (FrWindow *window, | |||
8279 | const char *current_dir) | |||
8280 | { | |||
8281 | CtkClipboard *clipboard; | |||
8282 | CtkSelectionData *selection_data; | |||
8283 | FrClipboardData *paste_data; | |||
8284 | ||||
8285 | clipboard = ctk_clipboard_get (FR_CLIPBOARD(cdk_atom_intern_static_string ("_RNGRAMPA_SPECIAL_CLIPBOARD" ))); | |||
8286 | selection_data = ctk_clipboard_wait_for_contents (clipboard, FR_SPECIAL_URI_LIST(cdk_atom_intern_static_string ("application/grapa-uri-list") )); | |||
8287 | if (selection_data == NULL((void*)0)) | |||
8288 | return; | |||
8289 | ||||
8290 | paste_data = get_clipboard_data_from_selection_data (window, (char*) ctk_selection_data_get_data (selection_data)); | |||
8291 | paste_data->current_dir = g_strdup (current_dir)g_strdup_inline (current_dir); | |||
8292 | fr_window_paste_from_clipboard_data (window, paste_data); | |||
8293 | ||||
8294 | ctk_selection_data_free (selection_data); | |||
8295 | } | |||
8296 | ||||
8297 | ||||
8298 | void | |||
8299 | fr_window_paste_selection (FrWindow *window, | |||
8300 | gboolean from_sidebar G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
8301 | { | |||
8302 | char *utf8_path, *utf8_old_path, *destination; | |||
8303 | char *current_dir; | |||
8304 | ||||
8305 | if (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT) | |||
8306 | return; | |||
8307 | ||||
8308 | /**/ | |||
8309 | ||||
8310 | utf8_old_path = g_filename_to_utf8 (fr_window_get_current_location (window), -1, NULL((void*)0), NULL((void*)0), NULL((void*)0)); | |||
8311 | utf8_path = _ctk_request_dialog_run (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), | |||
8312 | (CTK_DIALOG_DESTROY_WITH_PARENT | |||
8313 | | CTK_DIALOG_MODAL), | |||
8314 | _("Paste Selection")gettext ("Paste Selection"), | |||
8315 | _("_Destination folder:")gettext ("_Destination folder:"), | |||
8316 | utf8_old_path, | |||
8317 | 1024, | |||
8318 | _("_Cancel")gettext ("_Cancel"), | |||
8319 | _("_Paste")gettext ("_Paste")); | |||
8320 | g_free (utf8_old_path); | |||
8321 | if (utf8_path == NULL((void*)0)) | |||
8322 | return; | |||
8323 | ||||
8324 | destination = g_filename_from_utf8 (utf8_path, -1, NULL((void*)0), NULL((void*)0), NULL((void*)0)); | |||
8325 | g_free (utf8_path); | |||
8326 | ||||
8327 | if (destination[0] != '/') | |||
8328 | current_dir = build_uri (fr_window_get_current_location (window), destination, NULL((void*)0)); | |||
8329 | else | |||
8330 | current_dir = g_strdup (destination)g_strdup_inline (destination); | |||
8331 | g_free (destination); | |||
8332 | ||||
8333 | fr_window_paste_selection_to (window, current_dir); | |||
8334 | ||||
8335 | g_free (current_dir); | |||
8336 | } | |||
8337 | ||||
8338 | ||||
8339 | /* -- fr_window_open_files -- */ | |||
8340 | ||||
8341 | ||||
8342 | void | |||
8343 | fr_window_open_files_with_command (FrWindow *window, | |||
8344 | GList *file_list, | |||
8345 | char *command) | |||
8346 | { | |||
8347 | GAppInfo *app; | |||
8348 | GError *error = NULL((void*)0); | |||
8349 | ||||
8350 | app = g_app_info_create_from_commandline (command, NULL((void*)0), G_APP_INFO_CREATE_NONE, &error); | |||
8351 | if (error != NULL((void*)0)) { | |||
8352 | _ctk_error_dialog_run (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), | |||
8353 | _("Could not perform the operation")gettext ("Could not perform the operation"), | |||
8354 | "%s", | |||
8355 | error->message); | |||
8356 | g_clear_error (&error); | |||
8357 | return; | |||
8358 | } | |||
8359 | ||||
8360 | fr_window_open_files_with_application (window, file_list, app); | |||
8361 | } | |||
8362 | ||||
8363 | ||||
8364 | void | |||
8365 | fr_window_open_files_with_application (FrWindow *window, | |||
8366 | GList *file_list, | |||
8367 | GAppInfo *app) | |||
8368 | { | |||
8369 | GList *uris; | |||
8370 | GList *scan; | |||
8371 | CdkAppLaunchContext *context; | |||
8372 | GError *error = NULL((void*)0); | |||
8373 | ||||
8374 | if (window->priv->activity_ref > 0) | |||
8375 | return; | |||
8376 | ||||
8377 | g_assert (file_list != NULL)do { if (file_list != ((void*)0)) ; else g_assertion_message_expr (((gchar*) 0), "fr-window.c", 8377, ((const char*) (__func__ )), "file_list != NULL"); } while (0); | |||
8378 | ||||
8379 | uris = NULL((void*)0); | |||
8380 | for (scan = file_list; scan; scan = scan->next) | |||
8381 | uris = g_list_prepend (uris, g_filename_to_uri (scan->data, NULL((void*)0), NULL((void*)0))); | |||
8382 | ||||
8383 | context = cdk_display_get_app_launch_context (ctk_widget_get_display (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))); | |||
8384 | cdk_app_launch_context_set_screen (context, ctk_widget_get_screen (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))); | |||
8385 | cdk_app_launch_context_set_timestamp (context, 0); | |||
8386 | ||||
8387 | if (! g_app_info_launch_uris (app, uris, G_APP_LAUNCH_CONTEXT (context)((((GAppLaunchContext*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((context)), ((g_app_launch_context_get_type ())))))), &error)) { | |||
8388 | _ctk_error_dialog_run (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), | |||
8389 | _("Could not perform the operation")gettext ("Could not perform the operation"), | |||
8390 | "%s", | |||
8391 | error->message); | |||
8392 | g_clear_error (&error); | |||
8393 | } | |||
8394 | ||||
8395 | g_object_unref (context); | |||
8396 | path_list_free (uris); | |||
8397 | } | |||
8398 | ||||
8399 | ||||
8400 | typedef struct { | |||
8401 | FrWindow *window; | |||
8402 | GList *file_list; | |||
8403 | gboolean ask_application; | |||
8404 | CommandData *cdata; | |||
8405 | } OpenFilesData; | |||
8406 | ||||
8407 | ||||
8408 | static OpenFilesData* | |||
8409 | open_files_data_new (FrWindow *window, | |||
8410 | GList *file_list, | |||
8411 | gboolean ask_application) | |||
8412 | ||||
8413 | { | |||
8414 | OpenFilesData *odata; | |||
8415 | GList *scan; | |||
8416 | ||||
8417 | odata = g_new0 (OpenFilesData, 1)((OpenFilesData *) g_malloc0_n ((1), sizeof (OpenFilesData))); | |||
8418 | odata->window = window; | |||
8419 | odata->file_list = path_list_dup (file_list); | |||
8420 | odata->ask_application = ask_application; | |||
8421 | odata->cdata = g_new0 (CommandData, 1)((CommandData *) g_malloc0_n ((1), sizeof (CommandData))); | |||
8422 | odata->cdata->temp_dir = get_temp_work_dir (NULL((void*)0)); | |||
8423 | odata->cdata->file_list = NULL((void*)0); | |||
8424 | for (scan = file_list; scan; scan = scan->next) { | |||
8425 | char *file = scan->data; | |||
8426 | char *filename; | |||
8427 | ||||
8428 | filename = g_strconcat (odata->cdata->temp_dir, | |||
8429 | "/", | |||
8430 | file, | |||
8431 | NULL((void*)0)); | |||
8432 | odata->cdata->file_list = g_list_prepend (odata->cdata->file_list, filename); | |||
8433 | } | |||
8434 | ||||
8435 | /* Add to CommandList so the cdata is released on exit. */ | |||
8436 | CommandList = g_list_prepend (CommandList, odata->cdata); | |||
8437 | ||||
8438 | return odata; | |||
8439 | } | |||
8440 | ||||
8441 | ||||
8442 | static void | |||
8443 | open_files_data_free (OpenFilesData *odata) | |||
8444 | { | |||
8445 | g_return_if_fail (odata != NULL)do { if ((odata != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "odata != NULL"); return; } } while (0); | |||
8446 | ||||
8447 | path_list_free (odata->file_list); | |||
8448 | g_free (odata); | |||
8449 | } | |||
8450 | ||||
8451 | ||||
8452 | void | |||
8453 | fr_window_update_dialog_closed (FrWindow *window) | |||
8454 | { | |||
8455 | window->priv->update_dialog = NULL((void*)0); | |||
8456 | } | |||
8457 | ||||
8458 | ||||
8459 | gboolean | |||
8460 | fr_window_update_files (FrWindow *window, | |||
8461 | GList *file_list) | |||
8462 | { | |||
8463 | GList *scan; | |||
8464 | ||||
8465 | if (window->priv->activity_ref > 0) | |||
8466 | return FALSE(0); | |||
8467 | ||||
8468 | if (window->archive->read_only) | |||
8469 | return FALSE(0); | |||
8470 | ||||
8471 | fr_process_clear (window->archive->process); | |||
8472 | ||||
8473 | for (scan = file_list; scan; scan = scan->next) { | |||
8474 | OpenFile *file = scan->data; | |||
8475 | GList *local_file_list; | |||
8476 | ||||
8477 | local_file_list = g_list_append (NULL((void*)0), file->path); | |||
8478 | fr_archive_add (window->archive, | |||
8479 | local_file_list, | |||
8480 | file->temp_dir, | |||
8481 | "/", | |||
8482 | FALSE(0), | |||
8483 | FALSE(0), | |||
8484 | window->priv->password, | |||
8485 | window->priv->encrypt_header, | |||
8486 | window->priv->compression, | |||
8487 | window->priv->volume_size); | |||
8488 | g_list_free (local_file_list); | |||
8489 | } | |||
8490 | ||||
8491 | fr_process_start (window->archive->process); | |||
8492 | ||||
8493 | return TRUE(!(0)); | |||
8494 | } | |||
8495 | ||||
8496 | ||||
8497 | static void | |||
8498 | open_file_modified_cb (GFileMonitor *monitor G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
8499 | GFile *monitor_file, | |||
8500 | GFile *other_file G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
8501 | GFileMonitorEvent event_type, | |||
8502 | gpointer user_data) | |||
8503 | { | |||
8504 | FrWindow *window = user_data; | |||
8505 | char *monitor_uri; | |||
8506 | OpenFile *file; | |||
8507 | GList *scan; | |||
8508 | ||||
8509 | if ((event_type != G_FILE_MONITOR_EVENT_CHANGED) | |||
8510 | && (event_type != G_FILE_MONITOR_EVENT_CREATED)) | |||
8511 | { | |||
8512 | return; | |||
8513 | } | |||
8514 | ||||
8515 | monitor_uri = g_file_get_uri (monitor_file); | |||
8516 | file = NULL((void*)0); | |||
8517 | for (scan = window->priv->open_files; scan; scan = scan->next) { | |||
8518 | OpenFile *test = scan->data; | |||
8519 | if (uricmp (test->extracted_uri, monitor_uri) == 0) { | |||
8520 | file = test; | |||
8521 | break; | |||
8522 | } | |||
8523 | } | |||
8524 | g_free (monitor_uri); | |||
8525 | ||||
8526 | g_return_if_fail (file != NULL)do { if ((file != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "file != NULL"); return ; } } while (0); | |||
8527 | ||||
8528 | if (window->priv->update_dialog == NULL((void*)0)) | |||
8529 | window->priv->update_dialog = dlg_update (window); | |||
8530 | dlg_update_add_file (window->priv->update_dialog, file); | |||
8531 | } | |||
8532 | ||||
8533 | ||||
8534 | static void | |||
8535 | fr_window_monitor_open_file (FrWindow *window, | |||
8536 | OpenFile *file) | |||
8537 | { | |||
8538 | GFile *f; | |||
8539 | ||||
8540 | window->priv->open_files = g_list_prepend (window->priv->open_files, file); | |||
8541 | f = g_file_new_for_uri (file->extracted_uri); | |||
8542 | file->monitor = g_file_monitor_file (f, 0, NULL((void*)0), NULL((void*)0)); | |||
8543 | g_signal_connect (file->monitor,g_signal_connect_data ((file->monitor), ("changed"), (((GCallback ) (open_file_modified_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
8544 | "changed",g_signal_connect_data ((file->monitor), ("changed"), (((GCallback ) (open_file_modified_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
8545 | G_CALLBACK (open_file_modified_cb),g_signal_connect_data ((file->monitor), ("changed"), (((GCallback ) (open_file_modified_cb))), (window), ((void*)0), (GConnectFlags ) 0) | |||
8546 | window)g_signal_connect_data ((file->monitor), ("changed"), (((GCallback ) (open_file_modified_cb))), (window), ((void*)0), (GConnectFlags ) 0); | |||
8547 | g_object_unref (f); | |||
8548 | } | |||
8549 | ||||
8550 | ||||
8551 | static void | |||
8552 | monitor_extracted_files (OpenFilesData *odata) | |||
8553 | { | |||
8554 | FrWindow *window = odata->window; | |||
8555 | GList *scan1, *scan2; | |||
8556 | ||||
8557 | for (scan1 = odata->file_list, scan2 = odata->cdata->file_list; | |||
8558 | scan1 && scan2; | |||
8559 | scan1 = scan1->next, scan2 = scan2->next) | |||
8560 | { | |||
8561 | OpenFile *ofile; | |||
8562 | const char *file = scan1->data; | |||
8563 | const char *extracted_path = scan2->data; | |||
8564 | ||||
8565 | ofile = open_file_new (file, extracted_path, odata->cdata->temp_dir); | |||
8566 | if (ofile != NULL((void*)0)) | |||
8567 | fr_window_monitor_open_file (window, ofile); | |||
8568 | } | |||
8569 | } | |||
8570 | ||||
8571 | ||||
8572 | static gboolean | |||
8573 | fr_window_open_extracted_files (OpenFilesData *odata) | |||
8574 | { | |||
8575 | GList *file_list = odata->cdata->file_list; | |||
8576 | const char *first_file; | |||
8577 | const char *first_mime_type; | |||
8578 | GAppInfo *app; | |||
8579 | GList *files_to_open = NULL((void*)0); | |||
8580 | CdkAppLaunchContext *context; | |||
8581 | gboolean result; | |||
8582 | GError *error = NULL((void*)0); | |||
8583 | ||||
8584 | g_return_val_if_fail (file_list != NULL, FALSE)do { if ((file_list != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "file_list != NULL" ); return ((0)); } } while (0); | |||
8585 | ||||
8586 | first_file = (char*) file_list->data; | |||
8587 | if (first_file == NULL((void*)0)) | |||
8588 | return FALSE(0); | |||
8589 | ||||
8590 | if (! odata->window->archive->read_only) | |||
8591 | monitor_extracted_files (odata); | |||
8592 | ||||
8593 | if (odata->ask_application) { | |||
8594 | dlg_open_with (odata->window, file_list); | |||
8595 | return FALSE(0); | |||
8596 | } | |||
8597 | ||||
8598 | first_mime_type = get_file_mime_type_for_path (first_file, FALSE(0)); | |||
8599 | app = g_app_info_get_default_for_type (first_mime_type, FALSE(0)); | |||
8600 | ||||
8601 | if (app == NULL((void*)0)) { | |||
8602 | dlg_open_with (odata->window, file_list); | |||
8603 | return FALSE(0); | |||
8604 | } | |||
8605 | ||||
8606 | files_to_open = g_list_append (files_to_open, g_filename_to_uri (first_file, NULL((void*)0), NULL((void*)0))); | |||
8607 | ||||
8608 | if (g_app_info_supports_files (app)) { | |||
8609 | GList *scan; | |||
8610 | ||||
8611 | for (scan = file_list->next; scan; scan = scan->next) { | |||
8612 | const char *path = scan->data; | |||
8613 | const char *mime_type; | |||
8614 | ||||
8615 | mime_type = get_file_mime_type_for_path (path, FALSE(0)); | |||
8616 | if (mime_type == NULL((void*)0)) | |||
8617 | continue; | |||
8618 | ||||
8619 | if (strcmp (mime_type, first_mime_type) == 0) { | |||
8620 | files_to_open = g_list_append (files_to_open, g_filename_to_uri (path, NULL((void*)0), NULL((void*)0))); | |||
8621 | } | |||
8622 | else { | |||
8623 | GAppInfo *app2; | |||
8624 | ||||
8625 | app2 = g_app_info_get_default_for_type (mime_type, FALSE(0)); | |||
8626 | if (g_app_info_equal (app, app2)) | |||
8627 | files_to_open = g_list_append (files_to_open, g_filename_to_uri (path, NULL((void*)0), NULL((void*)0))); | |||
8628 | g_object_unref (app2); | |||
8629 | } | |||
8630 | } | |||
8631 | } | |||
8632 | ||||
8633 | context = cdk_display_get_app_launch_context (ctk_widget_get_display (CTK_WIDGET (odata->window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((odata->window)), ((ctk_widget_get_type ())))))))); | |||
8634 | cdk_app_launch_context_set_screen (context, ctk_widget_get_screen (CTK_WIDGET (odata->window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((odata->window)), ((ctk_widget_get_type ())))))))); | |||
8635 | cdk_app_launch_context_set_timestamp (context, 0); | |||
8636 | result = g_app_info_launch_uris (app, files_to_open, G_APP_LAUNCH_CONTEXT (context)((((GAppLaunchContext*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((context)), ((g_app_launch_context_get_type ())))))), &error); | |||
8637 | if (! result) { | |||
8638 | _ctk_error_dialog_run (CTK_WINDOW (odata->window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((odata->window)), ((ctk_window_get_type ())))))), | |||
8639 | _("Could not perform the operation")gettext ("Could not perform the operation"), | |||
8640 | "%s", | |||
8641 | error->message); | |||
8642 | g_clear_error (&error); | |||
8643 | } | |||
8644 | ||||
8645 | g_object_unref (context); | |||
8646 | g_object_unref (app); | |||
8647 | path_list_free (files_to_open); | |||
8648 | ||||
8649 | return result; | |||
8650 | } | |||
8651 | ||||
8652 | ||||
8653 | static void | |||
8654 | fr_window_open_files__extract_done_cb (FrArchive *archive, | |||
8655 | FrAction action G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
8656 | FrProcError *error, | |||
8657 | gpointer callback_data) | |||
8658 | { | |||
8659 | OpenFilesData *odata = callback_data; | |||
8660 | ||||
8661 | g_signal_handlers_disconnect_matched (G_OBJECT (archive)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((archive)), (((GType) ((20) << (2)))))))), | |||
8662 | G_SIGNAL_MATCH_DATA, | |||
8663 | 0, | |||
8664 | 0, NULL((void*)0), | |||
8665 | 0, | |||
8666 | odata); | |||
8667 | ||||
8668 | if (error->type == FR_PROC_ERROR_NONE) | |||
8669 | fr_window_open_extracted_files (odata); | |||
8670 | } | |||
8671 | ||||
8672 | ||||
8673 | void | |||
8674 | fr_window_open_files (FrWindow *window, | |||
8675 | GList *file_list, | |||
8676 | gboolean ask_application) | |||
8677 | { | |||
8678 | OpenFilesData *odata; | |||
8679 | ||||
8680 | if (window->priv->activity_ref > 0) | |||
8681 | return; | |||
8682 | ||||
8683 | odata = open_files_data_new (window, file_list, ask_application); | |||
8684 | fr_window_set_current_batch_action (window, | |||
8685 | FR_BATCH_ACTION_OPEN_FILES, | |||
8686 | odata, | |||
8687 | (GFreeFunc) open_files_data_free); | |||
8688 | ||||
8689 | g_signal_connect (G_OBJECT (window->archive),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->archive)), (((GType) ((20) << (2))))))))), ("done"), (((GCallback) (fr_window_open_files__extract_done_cb ))), (odata), ((void*)0), (GConnectFlags) 0) | |||
8690 | "done",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->archive)), (((GType) ((20) << (2))))))))), ("done"), (((GCallback) (fr_window_open_files__extract_done_cb ))), (odata), ((void*)0), (GConnectFlags) 0) | |||
8691 | G_CALLBACK (fr_window_open_files__extract_done_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->archive)), (((GType) ((20) << (2))))))))), ("done"), (((GCallback) (fr_window_open_files__extract_done_cb ))), (odata), ((void*)0), (GConnectFlags) 0) | |||
8692 | odata)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->archive)), (((GType) ((20) << (2))))))))), ("done"), (((GCallback) (fr_window_open_files__extract_done_cb ))), (odata), ((void*)0), (GConnectFlags) 0); | |||
8693 | ||||
8694 | fr_process_clear (window->archive->process); | |||
8695 | fr_archive_extract_to_local (window->archive, | |||
8696 | odata->file_list, | |||
8697 | odata->cdata->temp_dir, | |||
8698 | NULL((void*)0), | |||
8699 | FALSE(0), | |||
8700 | TRUE(!(0)), | |||
8701 | FALSE(0), | |||
8702 | window->priv->password); | |||
8703 | fr_process_start (window->archive->process); | |||
8704 | } | |||
8705 | ||||
8706 | ||||
8707 | /**/ | |||
8708 | ||||
8709 | ||||
8710 | static char* | |||
8711 | get_default_dir (const char *dir) | |||
8712 | { | |||
8713 | if (! is_temp_dir (dir)) | |||
8714 | return g_strdup (dir)g_strdup_inline (dir); | |||
8715 | else | |||
8716 | return NULL((void*)0); | |||
8717 | } | |||
8718 | ||||
8719 | ||||
8720 | void | |||
8721 | fr_window_set_open_default_dir (FrWindow *window, | |||
8722 | const char *default_dir) | |||
8723 | { | |||
8724 | g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return; } } while (0); | |||
8725 | g_return_if_fail (default_dir != NULL)do { if ((default_dir != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "default_dir != NULL" ); return; } } while (0); | |||
8726 | ||||
8727 | if (window->priv->open_default_dir != NULL((void*)0)) | |||
8728 | g_free (window->priv->open_default_dir); | |||
8729 | window->priv->open_default_dir = get_default_dir (default_dir); | |||
8730 | } | |||
8731 | ||||
8732 | ||||
8733 | const char * | |||
8734 | fr_window_get_open_default_dir (FrWindow *window) | |||
8735 | { | |||
8736 | if (window->priv->open_default_dir == NULL((void*)0)) | |||
8737 | return get_home_uri (); | |||
8738 | else | |||
8739 | return window->priv->open_default_dir; | |||
8740 | } | |||
8741 | ||||
8742 | ||||
8743 | void | |||
8744 | fr_window_set_add_default_dir (FrWindow *window, | |||
8745 | const char *default_dir) | |||
8746 | { | |||
8747 | g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return; } } while (0); | |||
8748 | g_return_if_fail (default_dir != NULL)do { if ((default_dir != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "default_dir != NULL" ); return; } } while (0); | |||
8749 | ||||
8750 | if (window->priv->add_default_dir != NULL((void*)0)) | |||
8751 | g_free (window->priv->add_default_dir); | |||
8752 | window->priv->add_default_dir = get_default_dir (default_dir); | |||
8753 | } | |||
8754 | ||||
8755 | ||||
8756 | const char * | |||
8757 | fr_window_get_add_default_dir (FrWindow *window) | |||
8758 | { | |||
8759 | if (window->priv->add_default_dir == NULL((void*)0)) | |||
8760 | return get_home_uri (); | |||
8761 | else | |||
8762 | return window->priv->add_default_dir; | |||
8763 | } | |||
8764 | ||||
8765 | ||||
8766 | void | |||
8767 | fr_window_set_extract_default_dir (FrWindow *window, | |||
8768 | const char *default_dir, | |||
8769 | gboolean freeze) | |||
8770 | { | |||
8771 | g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return; } } while (0); | |||
8772 | g_return_if_fail (default_dir != NULL)do { if ((default_dir != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "default_dir != NULL" ); return; } } while (0); | |||
8773 | ||||
8774 | /* do not change this dir while it's used by the non-interactive | |||
8775 | * extraction operation. */ | |||
8776 | if (window->priv->extract_interact_use_default_dir) | |||
8777 | return; | |||
8778 | ||||
8779 | window->priv->extract_interact_use_default_dir = freeze; | |||
8780 | ||||
8781 | if (window->priv->extract_default_dir != NULL((void*)0)) | |||
8782 | g_free (window->priv->extract_default_dir); | |||
8783 | window->priv->extract_default_dir = get_default_dir (default_dir); | |||
8784 | } | |||
8785 | ||||
8786 | ||||
8787 | const char * | |||
8788 | fr_window_get_extract_default_dir (FrWindow *window) | |||
8789 | { | |||
8790 | if (window->priv->extract_default_dir == NULL((void*)0)) | |||
8791 | return get_home_uri (); | |||
8792 | else | |||
8793 | return window->priv->extract_default_dir; | |||
8794 | } | |||
8795 | ||||
8796 | ||||
8797 | void | |||
8798 | fr_window_set_default_dir (FrWindow *window, | |||
8799 | const char *default_dir, | |||
8800 | gboolean freeze) | |||
8801 | { | |||
8802 | g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return; } } while (0); | |||
8803 | g_return_if_fail (default_dir != NULL)do { if ((default_dir != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "default_dir != NULL" ); return; } } while (0); | |||
8804 | ||||
8805 | window->priv->freeze_default_dir = freeze; | |||
8806 | ||||
8807 | fr_window_set_open_default_dir (window, default_dir); | |||
8808 | fr_window_set_add_default_dir (window, default_dir); | |||
8809 | fr_window_set_extract_default_dir (window, default_dir, FALSE(0)); | |||
8810 | } | |||
8811 | ||||
8812 | ||||
8813 | void | |||
8814 | fr_window_update_columns_visibility (FrWindow *window) | |||
8815 | { | |||
8816 | CtkTreeView *tree_view = CTK_TREE_VIEW (window->priv->list_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->list_view)), ((ctk_tree_view_get_type ())))))); | |||
8817 | CtkTreeViewColumn *column; | |||
8818 | ||||
8819 | column = ctk_tree_view_get_column (tree_view, 1); | |||
8820 | ctk_tree_view_column_set_visible (column, g_settings_get_boolean (window->priv->settings_listing, PREF_LISTING_SHOW_SIZE"show-size")); | |||
8821 | ||||
8822 | column = ctk_tree_view_get_column (tree_view, 2); | |||
8823 | ctk_tree_view_column_set_visible (column, g_settings_get_boolean (window->priv->settings_listing, PREF_LISTING_SHOW_TYPE"show-type")); | |||
8824 | ||||
8825 | column = ctk_tree_view_get_column (tree_view, 3); | |||
8826 | ctk_tree_view_column_set_visible (column, g_settings_get_boolean (window->priv->settings_listing, PREF_LISTING_SHOW_TIME"show-time")); | |||
8827 | ||||
8828 | column = ctk_tree_view_get_column (tree_view, 4); | |||
8829 | ctk_tree_view_column_set_visible (column, g_settings_get_boolean (window->priv->settings_listing, PREF_LISTING_SHOW_PATH"show-path")); | |||
8830 | } | |||
8831 | ||||
8832 | ||||
8833 | void | |||
8834 | fr_window_set_toolbar_visibility (FrWindow *window, | |||
8835 | gboolean visible) | |||
8836 | { | |||
8837 | g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return; } } while (0); | |||
8838 | ||||
8839 | if (visible) | |||
8840 | ctk_widget_show (window->priv->toolbar); | |||
8841 | else | |||
8842 | ctk_widget_hide (window->priv->toolbar); | |||
8843 | ||||
8844 | set_active (window, "ViewToolbar", visible); | |||
8845 | } | |||
8846 | ||||
8847 | ||||
8848 | void | |||
8849 | fr_window_set_statusbar_visibility (FrWindow *window, | |||
8850 | gboolean visible) | |||
8851 | { | |||
8852 | g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return; } } while (0); | |||
8853 | ||||
8854 | if (visible) | |||
8855 | ctk_widget_show (window->priv->statusbar); | |||
8856 | else | |||
8857 | ctk_widget_hide (window->priv->statusbar); | |||
8858 | ||||
8859 | set_active (window, "ViewStatusbar", visible); | |||
8860 | } | |||
8861 | ||||
8862 | ||||
8863 | void | |||
8864 | fr_window_set_folders_visibility (FrWindow *window, | |||
8865 | gboolean value) | |||
8866 | { | |||
8867 | g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return; } } while (0); | |||
8868 | ||||
8869 | window->priv->view_folders = value; | |||
8870 | fr_window_update_dir_tree (window); | |||
8871 | ||||
8872 | set_active (window, "ViewFolders", window->priv->view_folders); | |||
8873 | } | |||
8874 | ||||
8875 | ||||
8876 | void | |||
8877 | fr_window_use_progress_dialog (FrWindow *window, | |||
8878 | gboolean value) | |||
8879 | { | |||
8880 | window->priv->use_progress_dialog = value; | |||
8881 | } | |||
8882 | ||||
8883 | ||||
8884 | /* -- batch mode procedures -- */ | |||
8885 | ||||
8886 | ||||
8887 | static void fr_window_exec_current_batch_action (FrWindow *window); | |||
8888 | ||||
8889 | ||||
8890 | static void | |||
8891 | fr_window_exec_batch_action (FrWindow *window, | |||
8892 | FRBatchAction *action) | |||
8893 | { | |||
8894 | ExtractData *edata; | |||
8895 | RenameData *rdata; | |||
8896 | OpenFilesData *odata; | |||
8897 | SaveAsData *sdata; | |||
8898 | ||||
8899 | switch (action->type) { | |||
8900 | case FR_BATCH_ACTION_LOAD: | |||
8901 | debug (DEBUG_INFO"fr-window.c", 8901, __FUNCTION__, "[BATCH] LOAD\n"); | |||
8902 | ||||
8903 | if (! uri_exists ((char*) action->data)) | |||
8904 | fr_window_archive_new (window, (char*) action->data); | |||
8905 | else | |||
8906 | fr_window_archive_open (window, (char*) action->data, CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ()))))))); | |||
8907 | break; | |||
8908 | ||||
8909 | case FR_BATCH_ACTION_ADD: | |||
8910 | debug (DEBUG_INFO"fr-window.c", 8910, __FUNCTION__, "[BATCH] ADD\n"); | |||
8911 | ||||
8912 | fr_window_archive_add_dropped_items (window, (GList*) action->data, FALSE(0)); | |||
8913 | break; | |||
8914 | ||||
8915 | case FR_BATCH_ACTION_OPEN: | |||
8916 | debug (DEBUG_INFO"fr-window.c", 8916, __FUNCTION__, "[BATCH] OPEN\n"); | |||
8917 | ||||
8918 | fr_window_push_message (window, _("Add files to an archive")gettext ("Add files to an archive")); | |||
8919 | dlg_batch_add_files (window, (GList*) action->data); | |||
8920 | break; | |||
8921 | ||||
8922 | case FR_BATCH_ACTION_EXTRACT: | |||
8923 | debug (DEBUG_INFO"fr-window.c", 8923, __FUNCTION__, "[BATCH] EXTRACT\n"); | |||
8924 | ||||
8925 | edata = action->data; | |||
8926 | fr_window_archive_extract (window, | |||
8927 | edata->file_list, | |||
8928 | edata->extract_to_dir, | |||
8929 | edata->base_dir, | |||
8930 | edata->skip_older, | |||
8931 | edata->overwrite, | |||
8932 | edata->junk_paths, | |||
8933 | TRUE(!(0))); | |||
8934 | break; | |||
8935 | ||||
8936 | case FR_BATCH_ACTION_EXTRACT_HERE: | |||
8937 | debug (DEBUG_INFO"fr-window.c", 8937, __FUNCTION__, "[BATCH] EXTRACT HERE\n"); | |||
8938 | ||||
8939 | fr_window_archive_extract_here (window, | |||
8940 | FALSE(0), | |||
8941 | TRUE(!(0)), | |||
8942 | FALSE(0)); | |||
8943 | break; | |||
8944 | ||||
8945 | case FR_BATCH_ACTION_EXTRACT_INTERACT: | |||
8946 | debug (DEBUG_INFO"fr-window.c", 8946, __FUNCTION__, "[BATCH] EXTRACT_INTERACT\n"); | |||
8947 | ||||
8948 | if (window->priv->extract_interact_use_default_dir | |||
8949 | && (window->priv->extract_default_dir != NULL((void*)0))) | |||
8950 | { | |||
8951 | fr_window_archive_extract (window, | |||
8952 | NULL((void*)0), | |||
8953 | window->priv->extract_default_dir, | |||
8954 | NULL((void*)0), | |||
8955 | FALSE(0), | |||
8956 | FR_OVERWRITE_ASK, | |||
8957 | FALSE(0), | |||
8958 | TRUE(!(0))); | |||
8959 | } | |||
8960 | else { | |||
8961 | fr_window_push_message (window, _("Extract archive")gettext ("Extract archive")); | |||
8962 | dlg_extract (NULL((void*)0), window); | |||
8963 | } | |||
8964 | break; | |||
8965 | ||||
8966 | case FR_BATCH_ACTION_RENAME: | |||
8967 | debug (DEBUG_INFO"fr-window.c", 8967, __FUNCTION__, "[BATCH] RENAME\n"); | |||
8968 | ||||
8969 | rdata = action->data; | |||
8970 | rename_selection (window, | |||
8971 | rdata->path_to_rename, | |||
8972 | rdata->old_name, | |||
8973 | rdata->new_name, | |||
8974 | rdata->current_dir, | |||
8975 | rdata->is_dir, | |||
8976 | rdata->dir_in_archive, | |||
8977 | rdata->original_path); | |||
8978 | break; | |||
8979 | ||||
8980 | case FR_BATCH_ACTION_PASTE: | |||
8981 | debug (DEBUG_INFO"fr-window.c", 8981, __FUNCTION__, "[BATCH] PASTE\n"); | |||
8982 | ||||
8983 | fr_window_paste_from_clipboard_data (window, (FrClipboardData*) action->data); | |||
8984 | break; | |||
8985 | ||||
8986 | case FR_BATCH_ACTION_OPEN_FILES: | |||
8987 | debug (DEBUG_INFO"fr-window.c", 8987, __FUNCTION__, "[BATCH] OPEN FILES\n"); | |||
8988 | ||||
8989 | odata = action->data; | |||
8990 | fr_window_open_files (window, odata->file_list, odata->ask_application); | |||
8991 | break; | |||
8992 | ||||
8993 | case FR_BATCH_ACTION_SAVE_AS: | |||
8994 | debug (DEBUG_INFO"fr-window.c", 8994, __FUNCTION__, "[BATCH] SAVE_AS\n"); | |||
8995 | ||||
8996 | sdata = action->data; | |||
8997 | fr_window_archive_save_as (window, | |||
8998 | sdata->uri, | |||
8999 | sdata->password, | |||
9000 | sdata->encrypt_header, | |||
9001 | sdata->volume_size); | |||
9002 | break; | |||
9003 | ||||
9004 | case FR_BATCH_ACTION_TEST: | |||
9005 | debug (DEBUG_INFO"fr-window.c", 9005, __FUNCTION__, "[BATCH] TEST\n"); | |||
9006 | ||||
9007 | fr_window_archive_test (window); | |||
9008 | break; | |||
9009 | ||||
9010 | case FR_BATCH_ACTION_CLOSE: | |||
9011 | debug (DEBUG_INFO"fr-window.c", 9011, __FUNCTION__, "[BATCH] CLOSE\n"); | |||
9012 | ||||
9013 | fr_window_archive_close (window); | |||
9014 | fr_window_exec_next_batch_action (window); | |||
9015 | break; | |||
9016 | ||||
9017 | case FR_BATCH_ACTION_QUIT: | |||
9018 | debug (DEBUG_INFO"fr-window.c", 9018, __FUNCTION__, "[BATCH] QUIT\n"); | |||
9019 | ||||
9020 | g_signal_emit (window, | |||
9021 | fr_window_signals[READY], | |||
9022 | 0, | |||
9023 | NULL((void*)0)); | |||
9024 | ||||
9025 | if ((window->priv->progress_dialog != NULL((void*)0)) && (ctk_widget_get_parent (window->priv->progress_dialog) != CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))) | |||
9026 | ctk_widget_destroy (window->priv->progress_dialog); | |||
9027 | ctk_widget_destroy (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
9028 | break; | |||
9029 | ||||
9030 | default: | |||
9031 | break; | |||
9032 | } | |||
9033 | } | |||
9034 | ||||
9035 | ||||
9036 | void | |||
9037 | fr_window_reset_current_batch_action (FrWindow *window) | |||
9038 | { | |||
9039 | FRBatchAction *adata = &window->priv->current_batch_action; | |||
9040 | ||||
9041 | if ((adata->data != NULL((void*)0)) && (adata->free_func != NULL((void*)0))) | |||
9042 | (*adata->free_func) (adata->data); | |||
9043 | adata->type = FR_BATCH_ACTION_NONE; | |||
9044 | adata->data = NULL((void*)0); | |||
9045 | adata->free_func = NULL((void*)0); | |||
9046 | } | |||
9047 | ||||
9048 | ||||
9049 | void | |||
9050 | fr_window_set_current_batch_action (FrWindow *window, | |||
9051 | FrBatchActionType action, | |||
9052 | void *data, | |||
9053 | GFreeFunc free_func) | |||
9054 | { | |||
9055 | FRBatchAction *adata = &window->priv->current_batch_action; | |||
9056 | ||||
9057 | fr_window_reset_current_batch_action (window); | |||
9058 | ||||
9059 | adata->type = action; | |||
9060 | adata->data = data; | |||
9061 | adata->free_func = free_func; | |||
9062 | } | |||
9063 | ||||
9064 | ||||
9065 | void | |||
9066 | fr_window_restart_current_batch_action (FrWindow *window) | |||
9067 | { | |||
9068 | fr_window_exec_batch_action (window, &window->priv->current_batch_action); | |||
| ||||
9069 | } | |||
9070 | ||||
9071 | ||||
9072 | void | |||
9073 | fr_window_append_batch_action (FrWindow *window, | |||
9074 | FrBatchActionType action, | |||
9075 | void *data, | |||
9076 | GFreeFunc free_func) | |||
9077 | { | |||
9078 | FRBatchAction *a_desc; | |||
9079 | ||||
9080 | g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return; } } while (0); | |||
9081 | ||||
9082 | a_desc = g_new0 (FRBatchAction, 1)((FRBatchAction *) g_malloc0_n ((1), sizeof (FRBatchAction))); | |||
9083 | a_desc->type = action; | |||
9084 | a_desc->data = data; | |||
9085 | a_desc->free_func = free_func; | |||
9086 | ||||
9087 | window->priv->batch_action_list = g_list_append (window->priv->batch_action_list, a_desc); | |||
9088 | } | |||
9089 | ||||
9090 | ||||
9091 | static void | |||
9092 | fr_window_exec_current_batch_action (FrWindow *window) | |||
9093 | { | |||
9094 | FRBatchAction *action; | |||
9095 | ||||
9096 | if (window->priv->batch_action == NULL((void*)0)) { | |||
9097 | window->priv->batch_mode = FALSE(0); | |||
9098 | return; | |||
9099 | } | |||
9100 | action = (FRBatchAction *) window->priv->batch_action->data; | |||
9101 | fr_window_exec_batch_action (window, action); | |||
9102 | } | |||
9103 | ||||
9104 | ||||
9105 | static void | |||
9106 | fr_window_exec_next_batch_action (FrWindow *window) | |||
9107 | { | |||
9108 | if (window->priv->batch_action != NULL((void*)0)) | |||
9109 | window->priv->batch_action = g_list_next (window->priv->batch_action)((window->priv->batch_action) ? (((GList *)(window-> priv->batch_action))->next) : ((void*)0)); | |||
9110 | else | |||
9111 | window->priv->batch_action = window->priv->batch_action_list; | |||
9112 | fr_window_exec_current_batch_action (window); | |||
9113 | } | |||
9114 | ||||
9115 | ||||
9116 | void | |||
9117 | fr_window_start_batch (FrWindow *window) | |||
9118 | { | |||
9119 | g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return; } } while (0); | |||
9120 | ||||
9121 | if (window->priv->batch_mode) | |||
9122 | return; | |||
9123 | ||||
9124 | if (window->priv->batch_action_list == NULL((void*)0)) | |||
9125 | return; | |||
9126 | ||||
9127 | if (window->priv->progress_dialog != NULL((void*)0)) | |||
9128 | ctk_window_set_title (CTK_WINDOW (window->priv->progress_dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->progress_dialog)), ((ctk_window_get_type ())))))), | |||
9129 | window->priv->batch_title); | |||
9130 | ||||
9131 | window->priv->batch_mode = TRUE(!(0)); | |||
9132 | window->priv->batch_action = window->priv->batch_action_list; | |||
9133 | window->archive->can_create_compressed_file = window->priv->batch_adding_one_file; | |||
9134 | ||||
9135 | fr_window_exec_current_batch_action (window); | |||
9136 | } | |||
9137 | ||||
9138 | ||||
9139 | void | |||
9140 | fr_window_stop_batch (FrWindow *window) | |||
9141 | { | |||
9142 | if (! window->priv->non_interactive) | |||
9143 | return; | |||
9144 | ||||
9145 | window->priv->extract_interact_use_default_dir = FALSE(0); | |||
9146 | window->archive->can_create_compressed_file = FALSE(0); | |||
9147 | ||||
9148 | if (window->priv->batch_mode) { | |||
9149 | if (! window->priv->showing_error_dialog) { | |||
9150 | ctk_widget_destroy (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | |||
9151 | return; | |||
9152 | } | |||
9153 | } | |||
9154 | else { | |||
9155 | ctk_window_present (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ()))))))); | |||
9156 | fr_window_archive_close (window); | |||
9157 | } | |||
9158 | ||||
9159 | window->priv->batch_mode = FALSE(0); | |||
9160 | } | |||
9161 | ||||
9162 | ||||
9163 | void | |||
9164 | fr_window_resume_batch (FrWindow *window) | |||
9165 | { | |||
9166 | fr_window_exec_current_batch_action (window); | |||
9167 | } | |||
9168 | ||||
9169 | ||||
9170 | gboolean | |||
9171 | fr_window_is_batch_mode (FrWindow *window) | |||
9172 | { | |||
9173 | return window->priv->batch_mode; | |||
9174 | } | |||
9175 | ||||
9176 | ||||
9177 | void | |||
9178 | fr_window_new_batch (FrWindow *window, | |||
9179 | const char *title) | |||
9180 | { | |||
9181 | fr_window_free_batch_data (window); | |||
9182 | window->priv->non_interactive = TRUE(!(0)); | |||
9183 | g_free (window->priv->batch_title); | |||
9184 | window->priv->batch_title = g_strdup (title)g_strdup_inline (title); | |||
9185 | } | |||
9186 | ||||
9187 | ||||
9188 | void | |||
9189 | fr_window_set_batch__extract_here (FrWindow *window, | |||
9190 | const char *filename) | |||
9191 | { | |||
9192 | g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return; } } while (0); | |||
9193 | g_return_if_fail (filename != NULL)do { if ((filename != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "filename != NULL" ); return; } } while (0); | |||
9194 | ||||
9195 | fr_window_append_batch_action (window, | |||
9196 | FR_BATCH_ACTION_LOAD, | |||
9197 | g_strdup (filename)g_strdup_inline (filename), | |||
9198 | (GFreeFunc) g_free); | |||
9199 | fr_window_append_batch_action (window, | |||
9200 | FR_BATCH_ACTION_EXTRACT_HERE, | |||
9201 | extract_to_data_new (NULL((void*)0)), | |||
9202 | (GFreeFunc) extract_data_free); | |||
9203 | fr_window_append_batch_action (window, | |||
9204 | FR_BATCH_ACTION_CLOSE, | |||
9205 | NULL((void*)0), | |||
9206 | NULL((void*)0)); | |||
9207 | } | |||
9208 | ||||
9209 | ||||
9210 | void | |||
9211 | fr_window_set_batch__extract (FrWindow *window, | |||
9212 | const char *filename, | |||
9213 | const char *dest_dir) | |||
9214 | { | |||
9215 | g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window != NULL") ; return; } } while (0); | |||
9216 | g_return_if_fail (filename != NULL)do { if ((filename != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "filename != NULL" ); return; } } while (0); | |||
9217 | ||||
9218 | enable_notifications = FALSE(0); | |||
9219 | ||||
9220 | fr_window_append_batch_action (window, | |||
9221 | FR_BATCH_ACTION_LOAD, | |||
9222 | g_strdup (filename)g_strdup_inline (filename), | |||
9223 | (GFreeFunc) g_free); | |||
9224 | if (dest_dir != NULL((void*)0)) | |||
9225 | fr_window_append_batch_action (window, | |||
9226 | FR_BATCH_ACTION_EXTRACT, | |||
9227 | extract_to_data_new (dest_dir), | |||
9228 | (GFreeFunc) extract_data_free); | |||
9229 | else | |||
9230 | fr_window_append_batch_action (window, | |||
9231 | FR_BATCH_ACTION_EXTRACT_INTERACT, | |||
9232 | NULL((void*)0), | |||
9233 | NULL((void*)0)); | |||
9234 | fr_window_append_batch_action (window, | |||
9235 | FR_BATCH_ACTION_CLOSE, | |||
9236 | NULL((void*)0), | |||
9237 | NULL((void*)0)); | |||
9238 | } | |||
9239 | ||||
9240 | ||||
9241 | void | |||
9242 | fr_window_set_batch__add (FrWindow *window, | |||
9243 | const char *archive, | |||
9244 | GList *file_list) | |||
9245 | { | |||
9246 | window->priv->batch_adding_one_file = (file_list->next == NULL((void*)0)) && (uri_is_file (file_list->data)); | |||
9247 | ||||
9248 | if (archive != NULL((void*)0)) | |||
9249 | fr_window_append_batch_action (window, | |||
9250 | FR_BATCH_ACTION_LOAD, | |||
9251 | g_strdup (archive)g_strdup_inline (archive), | |||
9252 | (GFreeFunc) g_free); | |||
9253 | else | |||
9254 | fr_window_append_batch_action (window, | |||
9255 | FR_BATCH_ACTION_OPEN, | |||
9256 | file_list, | |||
9257 | NULL((void*)0)); | |||
9258 | fr_window_append_batch_action (window, | |||
9259 | FR_BATCH_ACTION_ADD, | |||
9260 | file_list, | |||
9261 | NULL((void*)0)); | |||
9262 | fr_window_append_batch_action (window, | |||
9263 | FR_BATCH_ACTION_CLOSE, | |||
9264 | NULL((void*)0), | |||
9265 | NULL((void*)0)); | |||
9266 | } |