File: | fr-window.c |
Warning: | line 2146, column 104 Access to field 'command' results in a dereference of a null pointer (loaded from field 'archive') |
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 MAX_HISTORY_LEN5 5 | ||||
66 | #define ACTIVITY_DELAY100 100 | ||||
67 | #define ACTIVITY_PULSE_STEP(0.033) (0.033) | ||||
68 | #define MAX_MESSAGE_LENGTH50 50 | ||||
69 | |||||
70 | #define PROGRESS_TIMEOUT_MSECS5000 5000 | ||||
71 | #define PROGRESS_DIALOG_DEFAULT_WIDTH500 500 | ||||
72 | #define PROGRESS_BAR_HEIGHT10 10 | ||||
73 | #undef LOG_PROGRESS | ||||
74 | |||||
75 | #define HIDE_PROGRESS_TIMEOUT_MSECS500 500 | ||||
76 | #define DEFAULT_NAME_COLUMN_WIDTH250 250 | ||||
77 | #define OTHER_COLUMNS_WIDTH100 100 | ||||
78 | #define RECENT_ITEM_MAX_WIDTH25 25 | ||||
79 | |||||
80 | #define DEF_WIN_WIDTH600 600 | ||||
81 | #define DEF_WIN_HEIGHT480 480 | ||||
82 | #define DEF_SIDEBAR_WIDTH200 200 | ||||
83 | |||||
84 | #define FILE_LIST_ICON_SIZECTK_ICON_SIZE_LARGE_TOOLBAR CTK_ICON_SIZE_LARGE_TOOLBAR | ||||
85 | #define DIR_TREE_ICON_SIZECTK_ICON_SIZE_MENU CTK_ICON_SIZE_MENU | ||||
86 | |||||
87 | #define BAD_CHARS"/\\*" "/\\*" | ||||
88 | |||||
89 | static GHashTable *pixbuf_hash = NULL((void*)0); | ||||
90 | static GHashTable *tree_pixbuf_hash = NULL((void*)0); | ||||
91 | static CtkIconTheme *icon_theme = NULL((void*)0); | ||||
92 | static int file_list_icon_size = 0; | ||||
93 | static int dir_tree_icon_size = 0; | ||||
94 | static gboolean enable_notifications = TRUE(!(0)); | ||||
95 | |||||
96 | #define XDS_FILENAME"xds.txt" "xds.txt" | ||||
97 | #define MAX_XDS_ATOM_VAL_LEN4096 4096 | ||||
98 | #define XDS_ATOMcdk_atom_intern ("XdndDirectSave0", (0)) cdk_atom_intern ("XdndDirectSave0", FALSE(0)) | ||||
99 | #define TEXT_ATOMcdk_atom_intern ("text/plain", (0)) cdk_atom_intern ("text/plain", FALSE(0)) | ||||
100 | #define OCTET_ATOMcdk_atom_intern ("application/octet-stream", (0)) cdk_atom_intern ("application/octet-stream", FALSE(0)) | ||||
101 | #define XFR_ATOMcdk_atom_intern ("XdndGrapa0", (0)) cdk_atom_intern ("XdndGrapa0", FALSE(0)) | ||||
102 | |||||
103 | #define FR_CLIPBOARD(cdk_atom_intern_static_string ("_RNGRAMPA_SPECIAL_CLIPBOARD" )) (cdk_atom_intern_static_string ("_RNGRAMPA_SPECIAL_CLIPBOARD")) | ||||
104 | #define FR_SPECIAL_URI_LIST(cdk_atom_intern_static_string ("application/grapa-uri-list") ) (cdk_atom_intern_static_string ("application/grapa-uri-list")) | ||||
105 | |||||
106 | static CtkTargetEntry clipboard_targets[] = { | ||||
107 | { "application/grapa-uri-list", 0, 1 } | ||||
108 | }; | ||||
109 | |||||
110 | static CtkTargetEntry target_table[] = { | ||||
111 | { "XdndGrapa0", 0, 0 }, | ||||
112 | { "text/uri-list", 0, 1 }, | ||||
113 | }; | ||||
114 | |||||
115 | static CtkTargetEntry folder_tree_targets[] = { | ||||
116 | { "XdndGrapa0", 0, 0 }, | ||||
117 | { "XdndDirectSave0", 0, 2 } | ||||
118 | }; | ||||
119 | |||||
120 | |||||
121 | typedef struct { | ||||
122 | FrBatchActionType type; | ||||
123 | void * data; | ||||
124 | GFreeFunc free_func; | ||||
125 | } FRBatchAction; | ||||
126 | |||||
127 | |||||
128 | typedef struct { | ||||
129 | guint converting : 1; | ||||
130 | char *temp_dir; | ||||
131 | FrArchive *new_archive; | ||||
132 | char *password; | ||||
133 | gboolean encrypt_header; | ||||
134 | guint volume_size; | ||||
135 | char *new_file; | ||||
136 | } FRConvertData; | ||||
137 | |||||
138 | |||||
139 | typedef enum { | ||||
140 | FR_CLIPBOARD_OP_CUT, | ||||
141 | FR_CLIPBOARD_OP_COPY | ||||
142 | } FRClipboardOp; | ||||
143 | |||||
144 | |||||
145 | typedef struct { | ||||
146 | GList *file_list; | ||||
147 | char *extract_to_dir; | ||||
148 | char *base_dir; | ||||
149 | gboolean skip_older; | ||||
150 | FrOverwrite overwrite; | ||||
151 | gboolean junk_paths; | ||||
152 | char *password; | ||||
153 | gboolean extract_here; | ||||
154 | gboolean ask_to_open_destination; | ||||
155 | } ExtractData; | ||||
156 | |||||
157 | |||||
158 | typedef enum { | ||||
159 | FR_WINDOW_AREA_MENUBAR, | ||||
160 | FR_WINDOW_AREA_TOOLBAR, | ||||
161 | FR_WINDOW_AREA_LOCATIONBAR, | ||||
162 | FR_WINDOW_AREA_CONTENTS, | ||||
163 | FR_WINDOW_AREA_FILTERBAR, | ||||
164 | FR_WINDOW_AREA_STATUSBAR, | ||||
165 | } FrWindowArea; | ||||
166 | |||||
167 | |||||
168 | typedef enum { | ||||
169 | DIALOG_RESPONSE_NONE = 1, | ||||
170 | DIALOG_RESPONSE_OPEN_ARCHIVE, | ||||
171 | DIALOG_RESPONSE_OPEN_DESTINATION_FOLDER, | ||||
172 | DIALOG_RESPONSE_OPEN_DESTINATION_FOLDER_AND_QUIT, | ||||
173 | DIALOG_RESPONSE_QUIT | ||||
174 | } DialogResponse; | ||||
175 | |||||
176 | |||||
177 | /* -- FrClipboardData -- */ | ||||
178 | |||||
179 | |||||
180 | typedef struct { | ||||
181 | int refs; | ||||
182 | char *archive_filename; | ||||
183 | char *archive_password; | ||||
184 | FRClipboardOp op; | ||||
185 | char *base_dir; | ||||
186 | GList *files; | ||||
187 | char *tmp_dir; | ||||
188 | char *current_dir; | ||||
189 | } FrClipboardData; | ||||
190 | |||||
191 | |||||
192 | static FrClipboardData* | ||||
193 | fr_clipboard_data_new (void) | ||||
194 | { | ||||
195 | FrClipboardData *data; | ||||
196 | |||||
197 | data = g_new0 (FrClipboardData, 1)((FrClipboardData *) g_malloc0_n ((1), sizeof (FrClipboardData ))); | ||||
198 | data->refs = 1; | ||||
199 | |||||
200 | return data; | ||||
201 | } | ||||
202 | |||||
203 | |||||
204 | static FrClipboardData * | ||||
205 | fr_clipboard_data_ref (FrClipboardData *clipboard_data) | ||||
206 | { | ||||
207 | clipboard_data->refs++; | ||||
208 | return clipboard_data; | ||||
209 | } | ||||
210 | |||||
211 | |||||
212 | static void | ||||
213 | fr_clipboard_data_unref (FrClipboardData *clipboard_data) | ||||
214 | { | ||||
215 | if (clipboard_data == NULL((void*)0)) | ||||
216 | return; | ||||
217 | if (--clipboard_data->refs > 0) | ||||
218 | return; | ||||
219 | |||||
220 | g_free (clipboard_data->archive_filename); | ||||
221 | g_free (clipboard_data->archive_password); | ||||
222 | g_free (clipboard_data->base_dir); | ||||
223 | g_free (clipboard_data->tmp_dir); | ||||
224 | g_free (clipboard_data->current_dir); | ||||
225 | g_list_free_full (clipboard_data->files, g_free); | ||||
226 | g_free (clipboard_data); | ||||
227 | } | ||||
228 | |||||
229 | |||||
230 | static void | ||||
231 | fr_clipboard_data_set_password (FrClipboardData *clipboard_data, | ||||
232 | const char *password) | ||||
233 | { | ||||
234 | if (clipboard_data->archive_password != password) | ||||
235 | g_free (clipboard_data->archive_password); | ||||
236 | if (password != NULL((void*)0)) | ||||
237 | clipboard_data->archive_password = g_strdup (password)g_strdup_inline (password); | ||||
238 | } | ||||
239 | |||||
240 | |||||
241 | /**/ | ||||
242 | |||||
243 | enum { | ||||
244 | ARCHIVE_LOADED, | ||||
245 | PROGRESS, | ||||
246 | READY, | ||||
247 | LAST_SIGNAL | ||||
248 | }; | ||||
249 | |||||
250 | static CtkApplicationWindowClass *parent_class = NULL((void*)0); | ||||
251 | static guint fr_window_signals[LAST_SIGNAL] = { 0 }; | ||||
252 | |||||
253 | struct _FrWindowPrivateData { | ||||
254 | CtkWidget *layout; | ||||
255 | CtkWidget *contents; | ||||
256 | CtkWidget *list_view; | ||||
257 | CtkListStore *list_store; | ||||
258 | CtkWidget *tree_view; | ||||
259 | CtkTreeStore *tree_store; | ||||
260 | CtkWidget *toolbar; | ||||
261 | CtkWidget *statusbar; | ||||
262 | CtkWidget *progress_bar; | ||||
263 | CtkWidget *location_bar; | ||||
264 | CtkWidget *location_entry; | ||||
265 | CtkWidget *location_label; | ||||
266 | CtkWidget *filter_bar; | ||||
267 | CtkWidget *filter_entry; | ||||
268 | CtkWidget *paned; | ||||
269 | CtkWidget *sidepane; | ||||
270 | CtkTreePath *list_hover_path; | ||||
271 | CtkTreeViewColumn *filename_column; | ||||
272 | |||||
273 | gboolean filter_mode; | ||||
274 | gint current_view_length; | ||||
275 | |||||
276 | guint help_message_cid; | ||||
277 | guint list_info_cid; | ||||
278 | guint progress_cid; | ||||
279 | |||||
280 | CtkWidget * up_arrows[5]; | ||||
281 | CtkWidget * down_arrows[5]; | ||||
282 | |||||
283 | FrAction action; | ||||
284 | gboolean archive_present; | ||||
285 | gboolean archive_new; /* A new archive has been created | ||||
286 | * but it doesn't contain any | ||||
287 | * file yet. The real file will | ||||
288 | * be created only when the user | ||||
289 | * adds some file to the | ||||
290 | * archive.*/ | ||||
291 | |||||
292 | char * archive_uri; | ||||
293 | char * open_default_dir; /* default directory to be used | ||||
294 | * in the Open dialog. */ | ||||
295 | char * add_default_dir; /* default directory to be used | ||||
296 | * in the Add dialog. */ | ||||
297 | char * extract_default_dir; /* default directory to be used | ||||
298 | * in the Extract dialog. */ | ||||
299 | gboolean freeze_default_dir; | ||||
300 | gboolean asked_for_password; | ||||
301 | gboolean ask_to_open_destination_after_extraction; | ||||
302 | gboolean destroy_with_error_dialog; | ||||
303 | |||||
304 | FRBatchAction current_batch_action; | ||||
305 | |||||
306 | gboolean give_focus_to_the_list; | ||||
307 | gboolean single_click; | ||||
308 | CtkTreePath *path_clicked; | ||||
309 | |||||
310 | FrWindowSortMethod sort_method; | ||||
311 | CtkSortType sort_type; | ||||
312 | |||||
313 | char * last_location; | ||||
314 | |||||
315 | gboolean view_folders; | ||||
316 | FrWindowListMode list_mode; | ||||
317 | FrWindowListMode last_list_mode; | ||||
318 | GList * history; | ||||
319 | GList * history_current; | ||||
320 | char * password; | ||||
321 | char * password_for_paste; | ||||
322 | gboolean encrypt_header; | ||||
323 | FrCompression compression; | ||||
324 | guint volume_size; | ||||
325 | |||||
326 | guint activity_timeout_handle; /* activity timeout | ||||
327 | * handle. */ | ||||
328 | gint activity_ref; /* when > 0 some activity | ||||
329 | * is present. */ | ||||
330 | |||||
331 | guint update_timeout_handle; /* update file list | ||||
332 | * timeout handle. */ | ||||
333 | |||||
334 | FRConvertData convert_data; | ||||
335 | |||||
336 | gboolean stoppable; | ||||
337 | gboolean closing; | ||||
338 | |||||
339 | FrClipboardData *clipboard_data; | ||||
340 | FrClipboardData *copy_data; | ||||
341 | |||||
342 | FrArchive *copy_from_archive; | ||||
343 | |||||
344 | CtkActionGroup *actions; | ||||
345 | |||||
346 | CtkWidget *file_popup_menu; | ||||
347 | CtkWidget *folder_popup_menu; | ||||
348 | CtkWidget *sidebar_folder_popup_menu; | ||||
349 | |||||
350 | /* dragged files data */ | ||||
351 | |||||
352 | char *drag_destination_folder; | ||||
353 | char *drag_base_dir; | ||||
354 | GError *drag_error; | ||||
355 | GList *drag_file_list; /* the list of files we are | ||||
356 | * dragging*/ | ||||
357 | |||||
358 | /* progress dialog data */ | ||||
359 | |||||
360 | CtkWidget *progress_dialog; | ||||
361 | CtkWidget *pd_action; | ||||
362 | CtkWidget *pd_message; | ||||
363 | CtkWidget *pd_progress_bar; | ||||
364 | CtkWidget *pd_cancel_button; | ||||
365 | CtkWidget *pd_close_button; | ||||
366 | CtkWidget *pd_open_archive_button; | ||||
367 | CtkWidget *pd_open_destination_button; | ||||
368 | CtkWidget *pd_open_destination_and_quit_button; | ||||
369 | CtkWidget *pd_quit_button; | ||||
370 | CtkWidget *pd_state_button; //Switch state, pause state or start state | ||||
371 | CtkWidget *pd_icon; | ||||
372 | gboolean progress_pulse; | ||||
373 | guint progress_timeout; /* Timeout to display the progress dialog. */ | ||||
374 | guint hide_progress_timeout; /* Timeout to hide the progress dialog. */ | ||||
375 | char *pd_last_archive; | ||||
376 | char *working_archive; | ||||
377 | double pd_last_fraction; | ||||
378 | char *pd_last_message; | ||||
379 | gboolean use_progress_dialog; | ||||
380 | |||||
381 | /* update dialog data */ | ||||
382 | |||||
383 | gpointer update_dialog; | ||||
384 | GList *open_files; | ||||
385 | |||||
386 | /* batch mode data */ | ||||
387 | |||||
388 | gboolean batch_mode; /* whether we are in a non interactive | ||||
389 | * mode. */ | ||||
390 | GList *batch_action_list; /* FRBatchAction * elements */ | ||||
391 | GList *batch_action; /* current action. */ | ||||
392 | char *batch_title; | ||||
393 | |||||
394 | /* misc */ | ||||
395 | |||||
396 | GSettings *settings_listing; | ||||
397 | GSettings *settings_ui; | ||||
398 | GSettings *settings_general; | ||||
399 | GSettings *settings_dialogs; | ||||
400 | GSettings *settings_baul; | ||||
401 | |||||
402 | gulong theme_changed_handler_id; | ||||
403 | gboolean non_interactive; | ||||
404 | char *extract_here_dir; | ||||
405 | gboolean extract_interact_use_default_dir; | ||||
406 | gboolean update_dropped_files; | ||||
407 | gboolean batch_adding_one_file; | ||||
408 | |||||
409 | CtkWindow *load_error_parent_window; | ||||
410 | gboolean showing_error_dialog; | ||||
411 | CtkWindow *error_dialog_parent; | ||||
412 | }; | ||||
413 | |||||
414 | |||||
415 | /* -- fr_window_free_private_data -- */ | ||||
416 | |||||
417 | |||||
418 | static void | ||||
419 | fr_window_free_batch_data (FrWindow *window) | ||||
420 | { | ||||
421 | GList *scan; | ||||
422 | |||||
423 | for (scan = window->priv->batch_action_list; scan; scan = scan->next) { | ||||
424 | FRBatchAction *adata = scan->data; | ||||
425 | |||||
426 | if ((adata->data != NULL((void*)0)) && (adata->free_func != NULL((void*)0))) | ||||
427 | (*adata->free_func) (adata->data); | ||||
428 | g_free (adata); | ||||
429 | } | ||||
430 | |||||
431 | g_list_free (window->priv->batch_action_list); | ||||
432 | window->priv->batch_action_list = NULL((void*)0); | ||||
433 | window->priv->batch_action = NULL((void*)0); | ||||
434 | |||||
435 | g_free (window->priv->batch_title); | ||||
436 | window->priv->batch_title = NULL((void*)0); | ||||
437 | } | ||||
438 | |||||
439 | |||||
440 | static void | ||||
441 | gh_unref_pixbuf (gpointer key, | ||||
442 | gpointer value, | ||||
443 | gpointer user_data) | ||||
444 | { | ||||
445 | g_object_unref (value); | ||||
446 | } | ||||
447 | |||||
448 | |||||
449 | static void | ||||
450 | fr_window_clipboard_remove_file_list (FrWindow *window, | ||||
451 | GList *file_list) | ||||
452 | { | ||||
453 | GList *scan1; | ||||
454 | |||||
455 | if (window->priv->copy_data == NULL((void*)0)) | ||||
456 | return; | ||||
457 | |||||
458 | if (file_list == NULL((void*)0)) { | ||||
459 | fr_clipboard_data_unref (window->priv->copy_data); | ||||
460 | window->priv->copy_data = NULL((void*)0); | ||||
461 | return; | ||||
462 | } | ||||
463 | |||||
464 | for (scan1 = file_list; scan1; scan1 = scan1->next) { | ||||
465 | const char *name1 = scan1->data; | ||||
466 | GList *scan2; | ||||
467 | |||||
468 | for (scan2 = window->priv->copy_data->files; scan2;) { | ||||
469 | const char *name2 = scan2->data; | ||||
470 | |||||
471 | if (strcmp (name1, name2) == 0) { | ||||
472 | GList *tmp = scan2->next; | ||||
473 | window->priv->copy_data->files = g_list_remove_link (window->priv->copy_data->files, scan2); | ||||
474 | g_free (scan2->data); | ||||
475 | g_list_free (scan2); | ||||
476 | scan2 = tmp; | ||||
477 | } | ||||
478 | else | ||||
479 | scan2 = scan2->next; | ||||
480 | } | ||||
481 | } | ||||
482 | |||||
483 | if (window->priv->copy_data->files == NULL((void*)0)) { | ||||
484 | fr_clipboard_data_unref (window->priv->copy_data); | ||||
485 | window->priv->copy_data = NULL((void*)0); | ||||
486 | } | ||||
487 | } | ||||
488 | |||||
489 | |||||
490 | static void | ||||
491 | fr_window_history_clear (FrWindow *window) | ||||
492 | { | ||||
493 | if (window->priv->history != NULL((void*)0)) | ||||
494 | path_list_free (window->priv->history); | ||||
495 | window->priv->history = NULL((void*)0); | ||||
496 | window->priv->history_current = NULL((void*)0); | ||||
497 | g_free (window->priv->last_location); | ||||
498 | window->priv->last_location = NULL((void*)0); | ||||
499 | } | ||||
500 | |||||
501 | |||||
502 | static void | ||||
503 | fr_window_free_open_files (FrWindow *window) | ||||
504 | { | ||||
505 | GList *scan; | ||||
506 | |||||
507 | for (scan = window->priv->open_files; scan; scan = scan->next) { | ||||
508 | OpenFile *file = scan->data; | ||||
509 | |||||
510 | if (file->monitor != NULL((void*)0)) | ||||
511 | g_file_monitor_cancel (file->monitor); | ||||
512 | open_file_free (file); | ||||
513 | } | ||||
514 | g_list_free (window->priv->open_files); | ||||
515 | window->priv->open_files = NULL((void*)0); | ||||
516 | } | ||||
517 | |||||
518 | |||||
519 | static void | ||||
520 | fr_window_convert_data_free (FrWindow *window, | ||||
521 | gboolean all) | ||||
522 | { | ||||
523 | if (all) { | ||||
524 | g_free (window->priv->convert_data.new_file); | ||||
525 | window->priv->convert_data.new_file = NULL((void*)0); | ||||
526 | } | ||||
527 | |||||
528 | window->priv->convert_data.converting = FALSE(0); | ||||
529 | |||||
530 | if (window->priv->convert_data.temp_dir != NULL((void*)0)) { | ||||
531 | g_free (window->priv->convert_data.temp_dir); | ||||
532 | window->priv->convert_data.temp_dir = NULL((void*)0); | ||||
533 | } | ||||
534 | |||||
535 | if (window->priv->convert_data.new_archive != NULL((void*)0)) { | ||||
536 | g_object_unref (window->priv->convert_data.new_archive); | ||||
537 | window->priv->convert_data.new_archive = NULL((void*)0); | ||||
538 | } | ||||
539 | |||||
540 | if (window->priv->convert_data.password != NULL((void*)0)) { | ||||
541 | g_free (window->priv->convert_data.password); | ||||
542 | window->priv->convert_data.password = NULL((void*)0); | ||||
543 | } | ||||
544 | } | ||||
545 | |||||
546 | |||||
547 | static void | ||||
548 | fr_window_free_private_data (FrWindow *window) | ||||
549 | { | ||||
550 | if (window->priv->update_timeout_handle != 0) { | ||||
551 | g_source_remove (window->priv->update_timeout_handle); | ||||
552 | window->priv->update_timeout_handle = 0; | ||||
553 | } | ||||
554 | |||||
555 | while (window->priv->activity_ref > 0) | ||||
556 | fr_window_stop_activity_mode (window); | ||||
557 | |||||
558 | if (window->priv->progress_timeout != 0) { | ||||
559 | g_source_remove (window->priv->progress_timeout); | ||||
560 | window->priv->progress_timeout = 0; | ||||
561 | } | ||||
562 | |||||
563 | if (window->priv->hide_progress_timeout != 0) { | ||||
564 | g_source_remove (window->priv->hide_progress_timeout); | ||||
565 | window->priv->hide_progress_timeout = 0; | ||||
566 | } | ||||
567 | |||||
568 | if (window->priv->theme_changed_handler_id != 0) | ||||
569 | g_signal_handler_disconnect (icon_theme, window->priv->theme_changed_handler_id); | ||||
570 | |||||
571 | fr_window_history_clear (window); | ||||
572 | |||||
573 | g_free (window->priv->open_default_dir); | ||||
574 | g_free (window->priv->add_default_dir); | ||||
575 | g_free (window->priv->extract_default_dir); | ||||
576 | g_free (window->priv->archive_uri); | ||||
577 | |||||
578 | g_free (window->priv->password); | ||||
579 | g_free (window->priv->password_for_paste); | ||||
580 | |||||
581 | g_object_unref (window->priv->list_store); | ||||
582 | |||||
583 | if (window->priv->clipboard_data != NULL((void*)0)) { | ||||
584 | fr_clipboard_data_unref (window->priv->clipboard_data); | ||||
585 | window->priv->clipboard_data = NULL((void*)0); | ||||
586 | } | ||||
587 | if (window->priv->copy_data != NULL((void*)0)) { | ||||
588 | fr_clipboard_data_unref (window->priv->copy_data); | ||||
589 | window->priv->copy_data = NULL((void*)0); | ||||
590 | } | ||||
591 | if (window->priv->copy_from_archive != NULL((void*)0)) { | ||||
592 | g_object_unref (window->priv->copy_from_archive); | ||||
593 | window->priv->copy_from_archive = NULL((void*)0); | ||||
594 | } | ||||
595 | |||||
596 | fr_window_free_open_files (window); | ||||
597 | |||||
598 | fr_window_convert_data_free (window, TRUE(!(0))); | ||||
599 | |||||
600 | g_clear_error (&window->priv->drag_error); | ||||
601 | path_list_free (window->priv->drag_file_list); | ||||
602 | window->priv->drag_file_list = NULL((void*)0); | ||||
603 | |||||
604 | if (window->priv->file_popup_menu != NULL((void*)0)) { | ||||
605 | ctk_widget_destroy (window->priv->file_popup_menu); | ||||
606 | window->priv->file_popup_menu = NULL((void*)0); | ||||
607 | } | ||||
608 | |||||
609 | if (window->priv->folder_popup_menu != NULL((void*)0)) { | ||||
610 | ctk_widget_destroy (window->priv->folder_popup_menu); | ||||
611 | window->priv->folder_popup_menu = NULL((void*)0); | ||||
612 | } | ||||
613 | |||||
614 | if (window->priv->sidebar_folder_popup_menu != NULL((void*)0)) { | ||||
615 | ctk_widget_destroy (window->priv->sidebar_folder_popup_menu); | ||||
616 | window->priv->sidebar_folder_popup_menu = NULL((void*)0); | ||||
617 | } | ||||
618 | |||||
619 | g_free (window->priv->last_location); | ||||
620 | |||||
621 | fr_window_free_batch_data (window); | ||||
622 | fr_window_reset_current_batch_action (window); | ||||
623 | |||||
624 | g_free (window->priv->pd_last_archive); | ||||
625 | g_free (window->priv->pd_last_message); | ||||
626 | g_free (window->priv->extract_here_dir); | ||||
627 | |||||
628 | g_settings_set_enum (window->priv->settings_listing, PREF_LISTING_SORT_METHOD"sort-method", window->priv->sort_method); | ||||
629 | g_settings_set_enum (window->priv->settings_listing, PREF_LISTING_SORT_TYPE"sort-type", window->priv->sort_type); | ||||
630 | g_settings_set_enum (window->priv->settings_listing, PREF_LISTING_LIST_MODE"list-mode", window->priv->last_list_mode); | ||||
631 | |||||
632 | _g_object_unref (window->priv->settings_listing); | ||||
633 | _g_object_unref (window->priv->settings_ui); | ||||
634 | _g_object_unref (window->priv->settings_general); | ||||
635 | _g_object_unref (window->priv->settings_dialogs); | ||||
636 | |||||
637 | if (window->priv->settings_baul) | ||||
638 | _g_object_unref (window->priv->settings_baul); | ||||
639 | } | ||||
640 | |||||
641 | |||||
642 | static void | ||||
643 | fr_window_finalize (GObject *object) | ||||
644 | { | ||||
645 | FrWindow *window = FR_WINDOW (object)((((FrWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((fr_window_get_type ())))))); | ||||
646 | |||||
647 | fr_window_free_open_files (window); | ||||
648 | |||||
649 | if (window->archive != NULL((void*)0)) { | ||||
650 | g_object_unref (window->archive); | ||||
651 | window->archive = NULL((void*)0); | ||||
652 | } | ||||
653 | |||||
654 | if (window->priv != NULL((void*)0)) { | ||||
655 | fr_window_free_private_data (window); | ||||
656 | g_free (window->priv); | ||||
657 | window->priv = NULL((void*)0); | ||||
658 | } | ||||
659 | |||||
660 | 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)) { | ||||
661 | if (pixbuf_hash != NULL((void*)0)) { | ||||
662 | g_hash_table_foreach (pixbuf_hash, | ||||
663 | gh_unref_pixbuf, | ||||
664 | NULL((void*)0)); | ||||
665 | g_hash_table_destroy (pixbuf_hash); | ||||
666 | pixbuf_hash = NULL((void*)0); | ||||
667 | } | ||||
668 | if (tree_pixbuf_hash != NULL((void*)0)) { | ||||
669 | g_hash_table_foreach (tree_pixbuf_hash, | ||||
670 | gh_unref_pixbuf, | ||||
671 | NULL((void*)0)); | ||||
672 | g_hash_table_destroy (tree_pixbuf_hash); | ||||
673 | tree_pixbuf_hash = NULL((void*)0); | ||||
674 | } | ||||
675 | } | ||||
676 | |||||
677 | G_OBJECT_CLASS (parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((parent_class)), (((GType) ((20) << (2))))))))->finalize (object); | ||||
678 | } | ||||
679 | |||||
680 | |||||
681 | static gboolean | ||||
682 | close__step2 (gpointer data) | ||||
683 | { | ||||
684 | ctk_widget_destroy (CTK_WIDGET (data)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), ((ctk_widget_get_type ()))))))); | ||||
685 | return FALSE(0); | ||||
686 | } | ||||
687 | |||||
688 | |||||
689 | void | ||||
690 | fr_window_close (FrWindow *window) | ||||
691 | { | ||||
692 | if (window->priv->activity_ref > 0) | ||||
693 | return; | ||||
694 | |||||
695 | window->priv->closing = TRUE(!(0)); | ||||
696 | |||||
697 | if (ctk_widget_get_realized (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))) { | ||||
698 | int width, height; | ||||
699 | |||||
700 | width = ctk_widget_get_allocated_width (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | ||||
701 | height = ctk_widget_get_allocated_height (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | ||||
702 | g_settings_set_int (window->priv->settings_ui, PREF_UI_WINDOW_WIDTH"window-width", width); | ||||
703 | g_settings_set_int (window->priv->settings_ui, PREF_UI_WINDOW_HEIGHT"window-height", height); | ||||
704 | |||||
705 | 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 ())))) ))); | ||||
706 | if (width > 0) | ||||
707 | g_settings_set_int (window->priv->settings_ui, PREF_UI_SIDEBAR_WIDTH"sidebar-width", width); | ||||
708 | |||||
709 | width = ctk_tree_view_column_get_width (window->priv->filename_column); | ||||
710 | if (width > 0) | ||||
711 | g_settings_set_int (window->priv->settings_listing, PREF_LISTING_NAME_COLUMN_WIDTH"name-column-width", width); | ||||
712 | } | ||||
713 | |||||
714 | g_idle_add (close__step2, window); | ||||
715 | } | ||||
716 | |||||
717 | |||||
718 | static void | ||||
719 | fr_window_class_init (FrWindowClass *class) | ||||
720 | { | ||||
721 | GObjectClass *gobject_class; | ||||
722 | |||||
723 | parent_class = g_type_class_peek_parent (class); | ||||
724 | |||||
725 | fr_window_signals[ARCHIVE_LOADED] = | ||||
726 | g_signal_new ("archive-loaded", | ||||
727 | G_TYPE_FROM_CLASS (class)(((GTypeClass*) (class))->g_type), | ||||
728 | G_SIGNAL_RUN_LAST, | ||||
729 | G_STRUCT_OFFSET (FrWindowClass, archive_loaded)((glong) __builtin_offsetof(FrWindowClass, archive_loaded)), | ||||
730 | NULL((void*)0), NULL((void*)0), | ||||
731 | fr_marshal_VOID__BOOLEANg_cclosure_marshal_VOID__BOOLEAN, | ||||
732 | G_TYPE_NONE((GType) ((1) << (2))), 1, | ||||
733 | G_TYPE_BOOLEAN((GType) ((5) << (2)))); | ||||
734 | fr_window_signals[PROGRESS] = | ||||
735 | g_signal_new ("progress", | ||||
736 | G_TYPE_FROM_CLASS (class)(((GTypeClass*) (class))->g_type), | ||||
737 | G_SIGNAL_RUN_LAST, | ||||
738 | G_STRUCT_OFFSET (FrWindowClass, progress)((glong) __builtin_offsetof(FrWindowClass, progress)), | ||||
739 | NULL((void*)0), NULL((void*)0), | ||||
740 | fr_marshal_VOID__DOUBLE_STRING, | ||||
741 | G_TYPE_NONE((GType) ((1) << (2))), 2, | ||||
742 | G_TYPE_DOUBLE((GType) ((15) << (2))), | ||||
743 | G_TYPE_STRING((GType) ((16) << (2)))); | ||||
744 | fr_window_signals[READY] = | ||||
745 | g_signal_new ("ready", | ||||
746 | G_TYPE_FROM_CLASS (class)(((GTypeClass*) (class))->g_type), | ||||
747 | G_SIGNAL_RUN_LAST, | ||||
748 | G_STRUCT_OFFSET (FrWindowClass, ready)((glong) __builtin_offsetof(FrWindowClass, ready)), | ||||
749 | NULL((void*)0), NULL((void*)0), | ||||
750 | fr_marshal_VOID__POINTERg_cclosure_marshal_VOID__POINTER, | ||||
751 | G_TYPE_NONE((GType) ((1) << (2))), 1, | ||||
752 | G_TYPE_POINTER((GType) ((17) << (2)))); | ||||
753 | |||||
754 | gobject_class = (GObjectClass*) class; | ||||
755 | gobject_class->finalize = fr_window_finalize; | ||||
756 | } | ||||
757 | |||||
758 | |||||
759 | static void fr_window_update_paste_command_sensitivity (FrWindow *, CtkClipboard *); | ||||
760 | |||||
761 | |||||
762 | static void | ||||
763 | clipboard_owner_change_cb (CtkClipboard *clipboard, | ||||
764 | CdkEvent *event, | ||||
765 | gpointer user_data) | ||||
766 | { | ||||
767 | fr_window_update_paste_command_sensitivity ((FrWindow *) user_data, clipboard); | ||||
768 | } | ||||
769 | |||||
770 | |||||
771 | static void | ||||
772 | fr_window_realized (CtkWidget *window, | ||||
773 | gpointer *data) | ||||
774 | { | ||||
775 | CtkClipboard *clipboard; | ||||
776 | |||||
777 | clipboard = ctk_widget_get_clipboard (window, FR_CLIPBOARD(cdk_atom_intern_static_string ("_RNGRAMPA_SPECIAL_CLIPBOARD" ))); | ||||
778 | g_signal_connect (clipboard,g_signal_connect_data ((clipboard), ("owner_change"), (((GCallback ) (clipboard_owner_change_cb))), (window), ((void*)0), (GConnectFlags ) 0) | ||||
779 | "owner_change",g_signal_connect_data ((clipboard), ("owner_change"), (((GCallback ) (clipboard_owner_change_cb))), (window), ((void*)0), (GConnectFlags ) 0) | ||||
780 | G_CALLBACK (clipboard_owner_change_cb),g_signal_connect_data ((clipboard), ("owner_change"), (((GCallback ) (clipboard_owner_change_cb))), (window), ((void*)0), (GConnectFlags ) 0) | ||||
781 | window)g_signal_connect_data ((clipboard), ("owner_change"), (((GCallback ) (clipboard_owner_change_cb))), (window), ((void*)0), (GConnectFlags ) 0); | ||||
782 | } | ||||
783 | |||||
784 | |||||
785 | static void | ||||
786 | fr_window_unrealized (CtkWidget *window, | ||||
787 | gpointer *data) | ||||
788 | { | ||||
789 | CtkClipboard *clipboard; | ||||
790 | |||||
791 | clipboard = ctk_widget_get_clipboard (window, FR_CLIPBOARD(cdk_atom_intern_static_string ("_RNGRAMPA_SPECIAL_CLIPBOARD" ))); | ||||
792 | 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)) | ||||
793 | 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)) | ||||
794 | 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)); | ||||
795 | } | ||||
796 | |||||
797 | |||||
798 | static void | ||||
799 | fr_window_init (FrWindow *window) | ||||
800 | { | ||||
801 | CtkStyleContext *context; | ||||
802 | |||||
803 | window->priv = g_new0 (FrWindowPrivateData, 1)((FrWindowPrivateData *) g_malloc0_n ((1), sizeof (FrWindowPrivateData ))); | ||||
804 | window->priv->update_dropped_files = FALSE(0); | ||||
805 | window->priv->filter_mode = FALSE(0); | ||||
806 | window->priv->batch_title = NULL((void*)0); | ||||
807 | window->priv->use_progress_dialog = TRUE(!(0)); | ||||
808 | window->priv->batch_title = NULL((void*)0); | ||||
809 | |||||
810 | context = ctk_widget_get_style_context (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | ||||
811 | ctk_style_context_add_class (context, "grapa-window"); | ||||
812 | |||||
813 | g_signal_connect (window,g_signal_connect_data ((window), ("realize"), (((GCallback) ( fr_window_realized))), (((void*)0)), ((void*)0), (GConnectFlags ) 0) | ||||
814 | "realize",g_signal_connect_data ((window), ("realize"), (((GCallback) ( fr_window_realized))), (((void*)0)), ((void*)0), (GConnectFlags ) 0) | ||||
815 | G_CALLBACK (fr_window_realized),g_signal_connect_data ((window), ("realize"), (((GCallback) ( fr_window_realized))), (((void*)0)), ((void*)0), (GConnectFlags ) 0) | ||||
816 | NULL)g_signal_connect_data ((window), ("realize"), (((GCallback) ( fr_window_realized))), (((void*)0)), ((void*)0), (GConnectFlags ) 0); | ||||
817 | g_signal_connect (window,g_signal_connect_data ((window), ("unrealize"), (((GCallback) (fr_window_unrealized))), (((void*)0)), ((void*)0), (GConnectFlags ) 0) | ||||
818 | "unrealize",g_signal_connect_data ((window), ("unrealize"), (((GCallback) (fr_window_unrealized))), (((void*)0)), ((void*)0), (GConnectFlags ) 0) | ||||
819 | G_CALLBACK (fr_window_unrealized),g_signal_connect_data ((window), ("unrealize"), (((GCallback) (fr_window_unrealized))), (((void*)0)), ((void*)0), (GConnectFlags ) 0) | ||||
820 | NULL)g_signal_connect_data ((window), ("unrealize"), (((GCallback) (fr_window_unrealized))), (((void*)0)), ((void*)0), (GConnectFlags ) 0); | ||||
821 | } | ||||
822 | |||||
823 | |||||
824 | GType | ||||
825 | fr_window_get_type (void) | ||||
826 | { | ||||
827 | static GType type = 0; | ||||
828 | |||||
829 | if (! type) { | ||||
830 | GTypeInfo type_info = { | ||||
831 | sizeof (FrWindowClass), | ||||
832 | NULL((void*)0), | ||||
833 | NULL((void*)0), | ||||
834 | (GClassInitFunc) fr_window_class_init, | ||||
835 | NULL((void*)0), | ||||
836 | NULL((void*)0), | ||||
837 | sizeof (FrWindow), | ||||
838 | 0, | ||||
839 | (GInstanceInitFunc) fr_window_init, | ||||
840 | NULL((void*)0) | ||||
841 | }; | ||||
842 | |||||
843 | type = g_type_register_static (CTK_TYPE_APPLICATION_WINDOW(ctk_application_window_get_type ()), | ||||
844 | "FrWindow", | ||||
845 | &type_info, | ||||
846 | 0); | ||||
847 | } | ||||
848 | |||||
849 | return type; | ||||
850 | } | ||||
851 | |||||
852 | |||||
853 | /* -- window history -- */ | ||||
854 | |||||
855 | |||||
856 | #if 0 | ||||
857 | static void | ||||
858 | fr_window_history_print (FrWindow *window) | ||||
859 | { | ||||
860 | GList *list; | ||||
861 | |||||
862 | debug (DEBUG_INFO"fr-window.c", 862, __FUNCTION__, "history:\n"); | ||||
863 | for (list = window->priv->history; list; list = list->next) | ||||
864 | g_print ("\t%s %s\n", | ||||
865 | (char*) list->data, | ||||
866 | (list == window->priv->history_current)? "<-": ""); | ||||
867 | g_print ("\n"); | ||||
868 | } | ||||
869 | #endif | ||||
870 | |||||
871 | |||||
872 | static void | ||||
873 | fr_window_history_add (FrWindow *window, | ||||
874 | const char *path) | ||||
875 | { | ||||
876 | if ((window->priv->history_current == NULL((void*)0)) || (g_strcmp0 (path, window->priv->history_current->data) != 0)) { | ||||
877 | GList *scan; | ||||
878 | GList *new_current = NULL((void*)0); | ||||
879 | |||||
880 | /* search the path in the history */ | ||||
881 | for (scan = window->priv->history_current; scan; scan = scan->next) { | ||||
882 | char *path_in_history = scan->data; | ||||
883 | |||||
884 | if (g_strcmp0 (path, path_in_history) == 0) { | ||||
885 | new_current = scan; | ||||
886 | break; | ||||
887 | } | ||||
888 | } | ||||
889 | |||||
890 | if (new_current != NULL((void*)0)) { | ||||
891 | window->priv->history_current = new_current; | ||||
892 | } | ||||
893 | else { | ||||
894 | /* remove all the paths after the current position */ | ||||
895 | for (scan = window->priv->history; scan && (scan != window->priv->history_current); /* void */) { | ||||
896 | GList *next = scan->next; | ||||
897 | |||||
898 | window->priv->history = g_list_remove_link (window->priv->history, scan); | ||||
899 | path_list_free (scan); | ||||
900 | |||||
901 | scan = next; | ||||
902 | } | ||||
903 | |||||
904 | window->priv->history = g_list_prepend (window->priv->history, g_strdup (path)g_strdup_inline (path)); | ||||
905 | window->priv->history_current = window->priv->history; | ||||
906 | } | ||||
907 | } | ||||
908 | } | ||||
909 | |||||
910 | |||||
911 | static void | ||||
912 | fr_window_history_pop (FrWindow *window) | ||||
913 | { | ||||
914 | GList *first; | ||||
915 | |||||
916 | if (window->priv->history == NULL((void*)0)) | ||||
917 | return; | ||||
918 | |||||
919 | first = window->priv->history; | ||||
920 | window->priv->history = g_list_remove_link (window->priv->history, first); | ||||
921 | if (window->priv->history_current == first) | ||||
922 | window->priv->history_current = window->priv->history; | ||||
923 | g_free (first->data); | ||||
924 | g_list_free (first); | ||||
925 | } | ||||
926 | |||||
927 | |||||
928 | /* -- window_update_file_list -- */ | ||||
929 | |||||
930 | |||||
931 | static GPtrArray * | ||||
932 | fr_window_get_current_dir_list (FrWindow *window) | ||||
933 | { | ||||
934 | GPtrArray *files; | ||||
935 | guint i; | ||||
936 | |||||
937 | files = g_ptr_array_sized_new (128); | ||||
938 | |||||
939 | for (i = 0; i < window->archive->command->files->len; i++) { | ||||
940 | FileData *fdata = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i]; | ||||
941 | |||||
942 | if (fdata->list_name == NULL((void*)0)) | ||||
943 | continue; | ||||
944 | g_ptr_array_add (files, fdata); | ||||
945 | } | ||||
946 | |||||
947 | return files; | ||||
948 | } | ||||
949 | |||||
950 | |||||
951 | static gint | ||||
952 | sort_by_name (gconstpointer ptr1, | ||||
953 | gconstpointer ptr2) | ||||
954 | { | ||||
955 | FileData *fdata1 = *((FileData **) ptr1); | ||||
956 | FileData *fdata2 = *((FileData **) ptr2); | ||||
957 | |||||
958 | if (file_data_is_dir (fdata1) != file_data_is_dir (fdata2)) { | ||||
959 | if (file_data_is_dir (fdata1)) | ||||
960 | return -1; | ||||
961 | else | ||||
962 | return 1; | ||||
963 | } | ||||
964 | |||||
965 | return strcmp (fdata1->sort_key, fdata2->sort_key); | ||||
966 | } | ||||
967 | |||||
968 | |||||
969 | static gint | ||||
970 | sort_by_size (gconstpointer ptr1, | ||||
971 | gconstpointer ptr2) | ||||
972 | { | ||||
973 | FileData *fdata1 = *((FileData **) ptr1); | ||||
974 | FileData *fdata2 = *((FileData **) ptr2); | ||||
975 | |||||
976 | if (file_data_is_dir (fdata1) != file_data_is_dir (fdata2)) { | ||||
977 | if (file_data_is_dir (fdata1)) | ||||
978 | return -1; | ||||
979 | else | ||||
980 | return 1; | ||||
981 | } | ||||
982 | else if (file_data_is_dir (fdata1) && file_data_is_dir (fdata2)) { | ||||
983 | if (fdata1->dir_size > fdata2->dir_size) | ||||
984 | return 1; | ||||
985 | else | ||||
986 | return -1; | ||||
987 | } | ||||
988 | |||||
989 | if (fdata1->size == fdata2->size) | ||||
990 | return sort_by_name (ptr1, ptr2); | ||||
991 | else if (fdata1->size > fdata2->size) | ||||
992 | return 1; | ||||
993 | else | ||||
994 | return -1; | ||||
995 | } | ||||
996 | |||||
997 | |||||
998 | static gint | ||||
999 | sort_by_type (gconstpointer ptr1, | ||||
1000 | gconstpointer ptr2) | ||||
1001 | { | ||||
1002 | FileData *fdata1 = *((FileData **) ptr1); | ||||
1003 | FileData *fdata2 = *((FileData **) ptr2); | ||||
1004 | int result; | ||||
1005 | const char *desc1, *desc2; | ||||
1006 | |||||
1007 | if (file_data_is_dir (fdata1) != file_data_is_dir (fdata2)) { | ||||
1008 | if (file_data_is_dir (fdata1)) | ||||
1009 | return -1; | ||||
1010 | else | ||||
1011 | return 1; | ||||
1012 | } | ||||
1013 | else if (file_data_is_dir (fdata1) && file_data_is_dir (fdata2)) | ||||
1014 | return sort_by_name (ptr1, ptr2); | ||||
1015 | |||||
1016 | desc1 = g_content_type_get_description (fdata1->content_type); | ||||
1017 | desc2 = g_content_type_get_description (fdata2->content_type); | ||||
1018 | |||||
1019 | result = strcasecmp (desc1, desc2); | ||||
1020 | if (result == 0) | ||||
1021 | return sort_by_name (ptr1, ptr2); | ||||
1022 | else | ||||
1023 | return result; | ||||
1024 | } | ||||
1025 | |||||
1026 | |||||
1027 | static gint | ||||
1028 | sort_by_time (gconstpointer ptr1, | ||||
1029 | gconstpointer ptr2) | ||||
1030 | { | ||||
1031 | FileData *fdata1 = *((FileData **) ptr1); | ||||
1032 | FileData *fdata2 = *((FileData **) ptr2); | ||||
1033 | |||||
1034 | if (file_data_is_dir (fdata1) != file_data_is_dir (fdata2)) { | ||||
1035 | if (file_data_is_dir (fdata1)) | ||||
1036 | return -1; | ||||
1037 | else | ||||
1038 | return 1; | ||||
1039 | } | ||||
1040 | else if (file_data_is_dir (fdata1) && file_data_is_dir (fdata2)) | ||||
1041 | return sort_by_name (ptr1, ptr2); | ||||
1042 | |||||
1043 | if (fdata1->modified == fdata2->modified) | ||||
1044 | return sort_by_name (ptr1, ptr2); | ||||
1045 | else if (fdata1->modified > fdata2->modified) | ||||
1046 | return 1; | ||||
1047 | else | ||||
1048 | return -1; | ||||
1049 | } | ||||
1050 | |||||
1051 | |||||
1052 | static gint | ||||
1053 | sort_by_path (gconstpointer ptr1, | ||||
1054 | gconstpointer ptr2) | ||||
1055 | { | ||||
1056 | FileData *fdata1 = *((FileData **) ptr1); | ||||
1057 | FileData *fdata2 = *((FileData **) ptr2); | ||||
1058 | int result; | ||||
1059 | |||||
1060 | if (file_data_is_dir (fdata1) != file_data_is_dir (fdata2)) { | ||||
1061 | if (file_data_is_dir (fdata1)) | ||||
1062 | return -1; | ||||
1063 | else | ||||
1064 | return 1; | ||||
1065 | } | ||||
1066 | else if (file_data_is_dir (fdata1) && file_data_is_dir (fdata2)) | ||||
1067 | return sort_by_name (ptr1, ptr2); | ||||
1068 | |||||
1069 | /* 2 files */ | ||||
1070 | |||||
1071 | result = strcasecmp (fdata1->path, fdata2->path); | ||||
1072 | if (result == 0) | ||||
1073 | return sort_by_name (ptr1, ptr2); | ||||
1074 | else | ||||
1075 | return result; | ||||
1076 | } | ||||
1077 | |||||
1078 | |||||
1079 | static guint64 | ||||
1080 | get_dir_size (FrWindow *window, | ||||
1081 | const char *current_dir, | ||||
1082 | const char *name) | ||||
1083 | { | ||||
1084 | guint64 size; | ||||
1085 | char *dirname; | ||||
1086 | int dirname_l; | ||||
1087 | guint i; | ||||
1088 | |||||
1089 | dirname = g_strconcat (current_dir, name, "/", NULL((void*)0)); | ||||
1090 | dirname_l = strlen (dirname); | ||||
1091 | |||||
1092 | size = 0; | ||||
1093 | for (i = 0; i < window->archive->command->files->len; i++) { | ||||
1094 | FileData *fd = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i]; | ||||
1095 | |||||
1096 | if (strncmp (dirname, fd->full_path, dirname_l) == 0) | ||||
1097 | size += fd->size; | ||||
1098 | } | ||||
1099 | |||||
1100 | g_free (dirname); | ||||
1101 | |||||
1102 | return size; | ||||
1103 | } | ||||
1104 | |||||
1105 | |||||
1106 | static gboolean | ||||
1107 | file_data_respects_filter (FrWindow *window, | ||||
1108 | FileData *fdata) | ||||
1109 | { | ||||
1110 | const char *filter; | ||||
1111 | |||||
1112 | 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 ()))))))); | ||||
1113 | if ((fdata == NULL((void*)0)) || (filter == NULL((void*)0)) || (*filter == '\0')) | ||||
1114 | return TRUE(!(0)); | ||||
1115 | |||||
1116 | if (fdata->dir || (fdata->name == NULL((void*)0))) | ||||
1117 | return FALSE(0); | ||||
1118 | |||||
1119 | return strncasecmp (fdata->name, filter, strlen (filter)) == 0; | ||||
1120 | } | ||||
1121 | |||||
1122 | |||||
1123 | static gboolean | ||||
1124 | compute_file_list_name (FrWindow *window, | ||||
1125 | FileData *fdata, | ||||
1126 | const char *current_dir, | ||||
1127 | size_t current_dir_len, | ||||
1128 | GHashTable *names_hash, | ||||
1129 | gboolean *different_name) | ||||
1130 | { | ||||
1131 | register char *scan, *end; | ||||
1132 | |||||
1133 | *different_name = FALSE(0); | ||||
1134 | |||||
1135 | if (! file_data_respects_filter (window, fdata)) | ||||
1136 | return FALSE(0); | ||||
1137 | |||||
1138 | if (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT) { | ||||
1139 | if (!(fdata->dir)) | ||||
1140 | file_data_set_list_name (fdata, fdata->name); | ||||
1141 | return FALSE(0); | ||||
1142 | } | ||||
1143 | |||||
1144 | if (strncmp (fdata->full_path, current_dir, current_dir_len) != 0) { | ||||
1145 | *different_name = TRUE(!(0)); | ||||
1146 | return FALSE(0); | ||||
1147 | } | ||||
1148 | |||||
1149 | if (strlen (fdata->full_path) == current_dir_len) | ||||
1150 | return FALSE(0); | ||||
1151 | |||||
1152 | scan = fdata->full_path + current_dir_len; | ||||
1153 | end = strchr (scan, '/'); | ||||
1154 | if ((end == NULL((void*)0)) && ! fdata->dir) { /* file */ | ||||
1155 | file_data_set_list_name (fdata, scan); | ||||
1156 | } | ||||
1157 | else { /* folder */ | ||||
1158 | char *dir_name; | ||||
1159 | |||||
1160 | if (end != NULL((void*)0)) | ||||
1161 | dir_name = g_strndup (scan, end - scan); | ||||
1162 | else | ||||
1163 | dir_name = g_strdup (scan)g_strdup_inline (scan); | ||||
1164 | |||||
1165 | /* avoid to insert duplicated folders */ | ||||
1166 | if (g_hash_table_lookup (names_hash, dir_name) != NULL((void*)0)) { | ||||
1167 | g_free (dir_name); | ||||
1168 | return FALSE(0); | ||||
1169 | } | ||||
1170 | g_hash_table_insert (names_hash, dir_name, GINT_TO_POINTER (1)((gpointer) (glong) (1))); | ||||
1171 | |||||
1172 | if ((end != NULL((void*)0)) && (*(end + 1) != '\0')) | ||||
1173 | fdata->list_dir = TRUE(!(0)); | ||||
1174 | file_data_set_list_name (fdata, dir_name); | ||||
1175 | fdata->dir_size = get_dir_size (window, current_dir, dir_name); | ||||
1176 | } | ||||
1177 | |||||
1178 | return TRUE(!(0)); | ||||
1179 | } | ||||
1180 | |||||
1181 | |||||
1182 | static void | ||||
1183 | fr_window_compute_list_names (FrWindow *window, | ||||
1184 | GPtrArray *files) | ||||
1185 | { | ||||
1186 | const char *current_dir; | ||||
1187 | size_t current_dir_len; | ||||
1188 | GHashTable *names_hash; | ||||
1189 | guint i; | ||||
1190 | gboolean visible_list_started = FALSE(0); | ||||
1191 | gboolean visible_list_completed = FALSE(0); | ||||
1192 | gboolean different_name; | ||||
1193 | |||||
1194 | current_dir = fr_window_get_current_location (window); | ||||
1195 | current_dir_len = strlen (current_dir); | ||||
1196 | names_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL((void*)0)); | ||||
1197 | |||||
1198 | for (i = 0; i < files->len; i++) { | ||||
1199 | FileData *fdata = g_ptr_array_index (files, i)((files)->pdata)[i]; | ||||
1200 | |||||
1201 | file_data_set_list_name (fdata, NULL((void*)0)); | ||||
1202 | fdata->list_dir = FALSE(0); | ||||
1203 | |||||
1204 | /* the files array is sorted by path, when the visible list | ||||
1205 | * is started and we find a path that doesn't match the | ||||
1206 | * current_dir path, the following files can't match | ||||
1207 | * the current_dir path. */ | ||||
1208 | |||||
1209 | if (visible_list_completed) | ||||
1210 | continue; | ||||
1211 | |||||
1212 | if (compute_file_list_name (window, fdata, current_dir, current_dir_len, names_hash, &different_name)) { | ||||
1213 | visible_list_started = TRUE(!(0)); | ||||
1214 | } | ||||
1215 | else if (visible_list_started && different_name) | ||||
1216 | visible_list_completed = TRUE(!(0)); | ||||
1217 | } | ||||
1218 | |||||
1219 | g_hash_table_destroy (names_hash); | ||||
1220 | } | ||||
1221 | |||||
1222 | |||||
1223 | static gboolean | ||||
1224 | fr_window_dir_exists_in_archive (FrWindow *window, | ||||
1225 | const char *dir_name) | ||||
1226 | { | ||||
1227 | int dir_name_len; | ||||
1228 | guint i; | ||||
1229 | |||||
1230 | if (dir_name == NULL((void*)0)) | ||||
1231 | return FALSE(0); | ||||
1232 | |||||
1233 | dir_name_len = strlen (dir_name); | ||||
1234 | if (dir_name_len == 0) | ||||
1235 | return TRUE(!(0)); | ||||
1236 | |||||
1237 | if (strcmp (dir_name, "/") == 0) | ||||
1238 | return TRUE(!(0)); | ||||
1239 | |||||
1240 | for (i = 0; i < window->archive->command->files->len; i++) { | ||||
1241 | FileData *fdata = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i]; | ||||
1242 | |||||
1243 | if (strncmp (dir_name, fdata->full_path, dir_name_len) == 0) { | ||||
1244 | return TRUE(!(0)); | ||||
1245 | } | ||||
1246 | else if (fdata->dir | ||||
1247 | && (fdata->full_path[strlen (fdata->full_path) -1] != '/') | ||||
1248 | && (strncmp (dir_name, fdata->full_path, dir_name_len - 1) == 0)) | ||||
1249 | { | ||||
1250 | return TRUE(!(0)); | ||||
1251 | } | ||||
1252 | } | ||||
1253 | |||||
1254 | return FALSE(0); | ||||
1255 | } | ||||
1256 | |||||
1257 | |||||
1258 | static char * | ||||
1259 | get_parent_dir (const char *current_dir) | ||||
1260 | { | ||||
1261 | char *dir; | ||||
1262 | char *new_dir; | ||||
1263 | char *retval; | ||||
1264 | |||||
1265 | if (current_dir == NULL((void*)0)) | ||||
1266 | return NULL((void*)0); | ||||
1267 | if (strcmp (current_dir, "/") == 0) | ||||
1268 | return g_strdup ("/")g_strdup_inline ("/"); | ||||
1269 | |||||
1270 | dir = g_strdup (current_dir)g_strdup_inline (current_dir); | ||||
1271 | dir[strlen (dir) - 1] = 0; | ||||
1272 | new_dir = remove_level_from_path (dir); | ||||
1273 | g_free (dir); | ||||
1274 | |||||
1275 | if (new_dir[strlen (new_dir) - 1] == '/') | ||||
1276 | retval = new_dir; | ||||
1277 | else { | ||||
1278 | retval = g_strconcat (new_dir, "/", NULL((void*)0)); | ||||
1279 | g_free (new_dir); | ||||
1280 | } | ||||
1281 | |||||
1282 | return retval; | ||||
1283 | } | ||||
1284 | |||||
1285 | |||||
1286 | static void fr_window_update_statusbar_list_info (FrWindow *window); | ||||
1287 | |||||
1288 | |||||
1289 | static GdkPixbuf * | ||||
1290 | get_mime_type_icon (const char *mime_type) | ||||
1291 | { | ||||
1292 | GdkPixbuf *pixbuf = NULL((void*)0); | ||||
1293 | |||||
1294 | pixbuf = g_hash_table_lookup (tree_pixbuf_hash, mime_type); | ||||
1295 | if (pixbuf != NULL((void*)0)) { | ||||
1296 | 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))) ))))))); | ||||
1297 | return pixbuf; | ||||
1298 | } | ||||
1299 | |||||
1300 | pixbuf = get_mime_type_pixbuf (mime_type, file_list_icon_size, icon_theme); | ||||
1301 | if (pixbuf == NULL((void*)0)) | ||||
1302 | return NULL((void*)0); | ||||
1303 | |||||
1304 | pixbuf = gdk_pixbuf_copy (pixbuf); | ||||
1305 | g_hash_table_insert (tree_pixbuf_hash, (gpointer) mime_type, pixbuf); | ||||
1306 | 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))) ))))))); | ||||
1307 | |||||
1308 | return pixbuf; | ||||
1309 | } | ||||
1310 | |||||
1311 | |||||
1312 | static GdkPixbuf * | ||||
1313 | get_icon (CtkWidget *widget, | ||||
1314 | FileData *fdata) | ||||
1315 | { | ||||
1316 | GdkPixbuf *pixbuf = NULL((void*)0); | ||||
1317 | const char *content_type; | ||||
1318 | GIcon *icon; | ||||
1319 | |||||
1320 | if (file_data_is_dir (fdata)) | ||||
1321 | content_type = MIME_TYPE_DIRECTORY"folder"; | ||||
1322 | else | ||||
1323 | content_type = fdata->content_type; | ||||
1324 | |||||
1325 | /* look in the hash table. */ | ||||
1326 | |||||
1327 | pixbuf = g_hash_table_lookup (pixbuf_hash, content_type); | ||||
1328 | if (pixbuf != NULL((void*)0)) { | ||||
1329 | 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))) ))))))); | ||||
1330 | return pixbuf; | ||||
1331 | } | ||||
1332 | |||||
1333 | icon = g_content_type_get_icon (content_type); | ||||
1334 | pixbuf = get_icon_pixbuf (icon, file_list_icon_size, icon_theme); | ||||
1335 | g_object_unref (icon); | ||||
1336 | |||||
1337 | if (pixbuf == NULL((void*)0)) | ||||
1338 | return NULL((void*)0); | ||||
1339 | |||||
1340 | pixbuf = gdk_pixbuf_copy (pixbuf); | ||||
1341 | g_hash_table_insert (pixbuf_hash, (gpointer) content_type, pixbuf); | ||||
1342 | 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))) ))))))); | ||||
1343 | |||||
1344 | return pixbuf; | ||||
1345 | } | ||||
1346 | |||||
1347 | |||||
1348 | static GdkPixbuf * | ||||
1349 | get_emblem (CtkWidget *widget, | ||||
1350 | FileData *fdata) | ||||
1351 | { | ||||
1352 | GdkPixbuf *pixbuf = NULL((void*)0); | ||||
1353 | |||||
1354 | if (! fdata->encrypted) | ||||
1355 | return NULL((void*)0); | ||||
1356 | |||||
1357 | /* encrypted */ | ||||
1358 | |||||
1359 | pixbuf = g_hash_table_lookup (pixbuf_hash, "emblem-nowrite"); | ||||
1360 | if (pixbuf != NULL((void*)0)) { | ||||
1361 | 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))) ))))))); | ||||
1362 | return pixbuf; | ||||
1363 | } | ||||
1364 | |||||
1365 | pixbuf = ctk_icon_theme_load_icon (icon_theme, | ||||
1366 | "emblem-nowrite", | ||||
1367 | file_list_icon_size, | ||||
1368 | 0, | ||||
1369 | NULL((void*)0)); | ||||
1370 | if (pixbuf == NULL((void*)0)) | ||||
1371 | return NULL((void*)0); | ||||
1372 | |||||
1373 | pixbuf = gdk_pixbuf_copy (pixbuf); | ||||
1374 | g_hash_table_insert (pixbuf_hash, (gpointer) "emblem-nowrite", pixbuf); | ||||
1375 | 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))) ))))))); | ||||
1376 | |||||
1377 | return pixbuf; | ||||
1378 | } | ||||
1379 | |||||
1380 | |||||
1381 | static int | ||||
1382 | get_column_from_sort_method (FrWindowSortMethod sort_method) | ||||
1383 | { | ||||
1384 | switch (sort_method) { | ||||
1385 | case FR_WINDOW_SORT_BY_NAME: return COLUMN_NAME; | ||||
1386 | case FR_WINDOW_SORT_BY_SIZE: return COLUMN_SIZE; | ||||
1387 | case FR_WINDOW_SORT_BY_TYPE: return COLUMN_TYPE; | ||||
1388 | case FR_WINDOW_SORT_BY_TIME: return COLUMN_TIME; | ||||
1389 | case FR_WINDOW_SORT_BY_PATH: return COLUMN_PATH; | ||||
1390 | default: | ||||
1391 | break; | ||||
1392 | } | ||||
1393 | |||||
1394 | return COLUMN_NAME; | ||||
1395 | } | ||||
1396 | |||||
1397 | |||||
1398 | static int | ||||
1399 | get_sort_method_from_column (int column_id) | ||||
1400 | { | ||||
1401 | switch (column_id) { | ||||
1402 | case COLUMN_NAME: return FR_WINDOW_SORT_BY_NAME; | ||||
1403 | case COLUMN_SIZE: return FR_WINDOW_SORT_BY_SIZE; | ||||
1404 | case COLUMN_TYPE: return FR_WINDOW_SORT_BY_TYPE; | ||||
1405 | case COLUMN_TIME: return FR_WINDOW_SORT_BY_TIME; | ||||
1406 | case COLUMN_PATH: return FR_WINDOW_SORT_BY_PATH; | ||||
1407 | default: | ||||
1408 | break; | ||||
1409 | } | ||||
1410 | |||||
1411 | return FR_WINDOW_SORT_BY_NAME; | ||||
1412 | } | ||||
1413 | |||||
1414 | |||||
1415 | static void | ||||
1416 | add_selected_from_list_view (CtkTreeModel *model, | ||||
1417 | CtkTreePath *path, | ||||
1418 | CtkTreeIter *iter, | ||||
1419 | gpointer data) | ||||
1420 | { | ||||
1421 | GList **list = data; | ||||
1422 | FileData *fdata; | ||||
1423 | |||||
1424 | ctk_tree_model_get (model, iter, | ||||
1425 | COLUMN_FILE_DATA, &fdata, | ||||
1426 | -1); | ||||
1427 | *list = g_list_prepend (*list, fdata); | ||||
1428 | } | ||||
1429 | |||||
1430 | |||||
1431 | static void | ||||
1432 | add_selected_from_tree_view (CtkTreeModel *model, | ||||
1433 | CtkTreePath *path, | ||||
1434 | CtkTreeIter *iter, | ||||
1435 | gpointer data) | ||||
1436 | { | ||||
1437 | GList **list = data; | ||||
1438 | char *dir_path; | ||||
1439 | |||||
1440 | ctk_tree_model_get (model, iter, | ||||
1441 | TREE_COLUMN_PATH, &dir_path, | ||||
1442 | -1); | ||||
1443 | *list = g_list_prepend (*list, dir_path); | ||||
1444 | } | ||||
1445 | |||||
1446 | |||||
1447 | static void | ||||
1448 | add_selected_fd (CtkTreeModel *model, | ||||
1449 | CtkTreePath *path, | ||||
1450 | CtkTreeIter *iter, | ||||
1451 | gpointer data) | ||||
1452 | { | ||||
1453 | GList **list = data; | ||||
1454 | FileData *fdata; | ||||
1455 | |||||
1456 | ctk_tree_model_get (model, iter, | ||||
1457 | COLUMN_FILE_DATA, &fdata, | ||||
1458 | -1); | ||||
1459 | if (! fdata->list_dir) | ||||
1460 | *list = g_list_prepend (*list, fdata); | ||||
1461 | } | ||||
1462 | |||||
1463 | |||||
1464 | static GList * | ||||
1465 | get_selection_as_fd (FrWindow *window) | ||||
1466 | { | ||||
1467 | CtkTreeSelection *selection; | ||||
1468 | GList *list = NULL((void*)0); | ||||
1469 | |||||
1470 | if (! ctk_widget_get_realized (window->priv->list_view)) | ||||
1471 | return NULL((void*)0); | ||||
1472 | |||||
1473 | 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 ()))))))); | ||||
1474 | if (selection == NULL((void*)0)) | ||||
1475 | return NULL((void*)0); | ||||
1476 | ctk_tree_selection_selected_foreach (selection, add_selected_fd, &list); | ||||
1477 | |||||
1478 | return list; | ||||
1479 | } | ||||
1480 | |||||
1481 | |||||
1482 | static void | ||||
1483 | fr_window_update_statusbar_list_info (FrWindow *window) | ||||
1484 | { | ||||
1485 | char *info, *archive_info, *selected_info; | ||||
1486 | char *size_txt, *sel_size_txt; | ||||
1487 | int tot_n, sel_n; | ||||
1488 | goffset tot_size, sel_size; | ||||
1489 | GList *scan; | ||||
1490 | |||||
1491 | if (window == NULL((void*)0)) | ||||
1492 | return; | ||||
1493 | |||||
1494 | if ((window->archive == NULL((void*)0)) || (window->archive->command == NULL((void*)0))) { | ||||
1495 | 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); | ||||
1496 | return; | ||||
1497 | } | ||||
1498 | |||||
1499 | tot_n = 0; | ||||
1500 | tot_size = 0; | ||||
1501 | |||||
1502 | if (window->priv->archive_present) { | ||||
1503 | GPtrArray *files = fr_window_get_current_dir_list (window); | ||||
1504 | guint i; | ||||
1505 | |||||
1506 | for (i = 0; i < files->len; i++) { | ||||
1507 | FileData *fd = g_ptr_array_index (files, i)((files)->pdata)[i]; | ||||
1508 | |||||
1509 | tot_n++; | ||||
1510 | if (! file_data_is_dir (fd)) | ||||
1511 | tot_size += fd->size; | ||||
1512 | else | ||||
1513 | tot_size += fd->dir_size; | ||||
1514 | } | ||||
1515 | g_ptr_array_free (files, TRUE(!(0))); | ||||
1516 | } | ||||
1517 | |||||
1518 | sel_n = 0; | ||||
1519 | sel_size = 0; | ||||
1520 | |||||
1521 | if (window->priv->archive_present) { | ||||
1522 | GList *selection = get_selection_as_fd (window); | ||||
1523 | |||||
1524 | for (scan = selection; scan; scan = scan->next) { | ||||
1525 | FileData *fd = scan->data; | ||||
1526 | |||||
1527 | sel_n++; | ||||
1528 | if (! file_data_is_dir (fd)) | ||||
1529 | sel_size += fd->size; | ||||
1530 | } | ||||
1531 | g_list_free (selection); | ||||
1532 | } | ||||
1533 | |||||
1534 | size_txt = g_format_size (tot_size); | ||||
1535 | sel_size_txt = g_format_size (sel_size); | ||||
1536 | |||||
1537 | if (tot_n == 0) | ||||
1538 | archive_info = g_strdup ("")g_strdup_inline (""); | ||||
1539 | else | ||||
1540 | archive_info = g_strdup_printf (ngettext ("%d object (%s)", "%d objects (%s)", tot_n), tot_n, size_txt); | ||||
1541 | |||||
1542 | if (sel_n == 0) | ||||
1543 | selected_info = g_strdup ("")g_strdup_inline (""); | ||||
1544 | else | ||||
1545 | selected_info = g_strdup_printf (ngettext ("%d object selected (%s)", "%d objects selected (%s)", sel_n), sel_n, sel_size_txt); | ||||
1546 | |||||
1547 | info = g_strconcat (archive_info, | ||||
1548 | ((sel_n == 0) ? NULL((void*)0) : ", "), | ||||
1549 | selected_info, | ||||
1550 | NULL((void*)0)); | ||||
1551 | |||||
1552 | 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); | ||||
1553 | |||||
1554 | g_free (size_txt); | ||||
1555 | g_free (sel_size_txt); | ||||
1556 | g_free (archive_info); | ||||
1557 | g_free (selected_info); | ||||
1558 | g_free (info); | ||||
1559 | } | ||||
1560 | |||||
1561 | |||||
1562 | static void | ||||
1563 | fr_window_populate_file_list (FrWindow *window, | ||||
1564 | GPtrArray *files) | ||||
1565 | { | ||||
1566 | guint i; | ||||
1567 | |||||
1568 | ctk_list_store_clear (window->priv->list_store); | ||||
1569 | |||||
1570 | 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 ())))))), | ||||
1571 | CTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID(-1), | ||||
1572 | CTK_SORT_ASCENDING); | ||||
1573 | |||||
1574 | for (i = 0; i < files->len; i++) { | ||||
1575 | FileData *fdata = g_ptr_array_index (files, i)((files)->pdata)[i]; | ||||
1576 | CtkTreeIter iter; | ||||
1577 | GdkPixbuf *icon, *emblem; | ||||
1578 | char *utf8_name; | ||||
1579 | |||||
1580 | if (fdata->list_name == NULL((void*)0)) | ||||
1581 | continue; | ||||
1582 | |||||
1583 | ctk_list_store_append (window->priv->list_store, &iter); | ||||
1584 | |||||
1585 | icon = get_icon (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))), fdata); | ||||
1586 | utf8_name = g_filename_display_name (fdata->list_name); | ||||
1587 | emblem = get_emblem (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))), fdata); | ||||
1588 | |||||
1589 | if (file_data_is_dir (fdata)) { | ||||
1590 | char *utf8_path; | ||||
1591 | char *tmp; | ||||
1592 | char *s_size; | ||||
1593 | char *s_time; | ||||
1594 | |||||
1595 | if (fdata->list_dir) | ||||
1596 | tmp = remove_ending_separator (fr_window_get_current_location (window)); | ||||
1597 | |||||
1598 | else | ||||
1599 | tmp = remove_level_from_path (fdata->path); | ||||
1600 | utf8_path = g_filename_display_name (tmp); | ||||
1601 | g_free (tmp); | ||||
1602 | |||||
1603 | s_size = g_format_size (fdata->dir_size); | ||||
1604 | |||||
1605 | if (fdata->list_dir) { | ||||
1606 | s_time = g_strdup ("")g_strdup_inline (""); | ||||
1607 | } else { | ||||
1608 | GDateTime *date_time; | ||||
1609 | date_time = g_date_time_new_from_unix_local (fdata->modified); | ||||
1610 | s_time = g_date_time_format (date_time, _("%d %B %Y, %H:%M")gettext ("%d %B %Y, %H:%M")); | ||||
1611 | g_date_time_unref (date_time); | ||||
1612 | } | ||||
1613 | |||||
1614 | ctk_list_store_set (window->priv->list_store, &iter, | ||||
1615 | COLUMN_FILE_DATA, fdata, | ||||
1616 | COLUMN_ICON, icon, | ||||
1617 | COLUMN_NAME, utf8_name, | ||||
1618 | COLUMN_EMBLEM, emblem, | ||||
1619 | COLUMN_TYPE, _("Folder")gettext ("Folder"), | ||||
1620 | COLUMN_SIZE, s_size, | ||||
1621 | COLUMN_TIME, s_time, | ||||
1622 | COLUMN_PATH, utf8_path, | ||||
1623 | -1); | ||||
1624 | g_free (utf8_path); | ||||
1625 | g_free (s_size); | ||||
1626 | g_free (s_time); | ||||
1627 | } | ||||
1628 | else { | ||||
1629 | GDateTime *date_time; | ||||
1630 | char *utf8_path; | ||||
1631 | char *s_size; | ||||
1632 | char *s_time; | ||||
1633 | const char *desc; | ||||
1634 | |||||
1635 | utf8_path = g_filename_display_name (fdata->path); | ||||
1636 | |||||
1637 | s_size = g_format_size (fdata->size); | ||||
1638 | date_time = g_date_time_new_from_unix_local (fdata->modified); | ||||
1639 | s_time = g_date_time_format (date_time, _("%d %B %Y, %H:%M")gettext ("%d %B %Y, %H:%M")); | ||||
1640 | g_date_time_unref (date_time); | ||||
1641 | desc = g_content_type_get_description (fdata->content_type); | ||||
1642 | |||||
1643 | ctk_list_store_set (window->priv->list_store, &iter, | ||||
1644 | COLUMN_FILE_DATA, fdata, | ||||
1645 | COLUMN_ICON, icon, | ||||
1646 | COLUMN_NAME, utf8_name, | ||||
1647 | COLUMN_EMBLEM, emblem, | ||||
1648 | COLUMN_TYPE, desc, | ||||
1649 | COLUMN_SIZE, s_size, | ||||
1650 | COLUMN_TIME, s_time, | ||||
1651 | COLUMN_PATH, utf8_path, | ||||
1652 | -1); | ||||
1653 | g_free (utf8_path); | ||||
1654 | g_free (s_size); | ||||
1655 | g_free (s_time); | ||||
1656 | } | ||||
1657 | g_free (utf8_name); | ||||
1658 | if (icon != NULL((void*)0)) | ||||
1659 | g_object_unref (icon); | ||||
1660 | if (emblem != NULL((void*)0)) | ||||
1661 | g_object_unref (emblem); | ||||
1662 | } | ||||
1663 | |||||
1664 | 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 ())))))), | ||||
1665 | get_column_from_sort_method (window->priv->sort_method), | ||||
1666 | window->priv->sort_type); | ||||
1667 | |||||
1668 | fr_window_update_statusbar_list_info (window); | ||||
1669 | fr_window_stop_activity_mode (window); | ||||
1670 | } | ||||
1671 | |||||
1672 | |||||
1673 | static int | ||||
1674 | path_compare (gconstpointer a, | ||||
1675 | gconstpointer b) | ||||
1676 | { | ||||
1677 | char *path_a = *((char**) a); | ||||
1678 | char *path_b = *((char**) b); | ||||
1679 | |||||
1680 | return strcmp (path_a, path_b); | ||||
1681 | } | ||||
1682 | |||||
1683 | |||||
1684 | static gboolean | ||||
1685 | get_tree_iter_from_path (FrWindow *window, | ||||
1686 | const char *path, | ||||
1687 | CtkTreeIter *parent, | ||||
1688 | CtkTreeIter *iter) | ||||
1689 | { | ||||
1690 | gboolean result = FALSE(0); | ||||
1691 | |||||
1692 | 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)) | ||||
1693 | return FALSE(0); | ||||
1694 | |||||
1695 | do { | ||||
1696 | CtkTreeIter tmp; | ||||
1697 | char *iter_path; | ||||
1698 | |||||
1699 | if (get_tree_iter_from_path (window, path, iter, &tmp)) { | ||||
1700 | *iter = tmp; | ||||
1701 | return TRUE(!(0)); | ||||
1702 | } | ||||
1703 | |||||
1704 | 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 ())))))), | ||||
1705 | iter, | ||||
1706 | TREE_COLUMN_PATH, &iter_path, | ||||
1707 | -1); | ||||
1708 | |||||
1709 | if ((iter_path != NULL((void*)0)) && (strcmp (path, iter_path) == 0)) { | ||||
1710 | result = TRUE(!(0)); | ||||
1711 | g_free (iter_path); | ||||
1712 | break; | ||||
1713 | } | ||||
1714 | g_free (iter_path); | ||||
1715 | } 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)); | ||||
1716 | |||||
1717 | return result; | ||||
1718 | } | ||||
1719 | |||||
1720 | |||||
1721 | static void | ||||
1722 | set_sensitive (FrWindow *window, | ||||
1723 | const char *action_name, | ||||
1724 | gboolean sensitive) | ||||
1725 | { | ||||
1726 | CtkAction *action; | ||||
1727 | |||||
1728 | action = ctk_action_group_get_action (window->priv->actions, action_name); | ||||
1729 | g_object_set (action, "sensitive", sensitive, NULL((void*)0)); | ||||
1730 | } | ||||
1731 | |||||
1732 | |||||
1733 | static void | ||||
1734 | fr_window_update_current_location (FrWindow *window) | ||||
1735 | { | ||||
1736 | const char *current_dir = fr_window_get_current_location (window); | ||||
1737 | char *path; | ||||
1738 | CtkTreeIter iter; | ||||
1739 | |||||
1740 | if (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT) { | ||||
1741 | ctk_widget_hide (window->priv->location_bar); | ||||
1742 | return; | ||||
1743 | } | ||||
1744 | |||||
1745 | ctk_widget_show (window->priv->location_bar); | ||||
1746 | |||||
1747 | 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: ""); | ||||
1748 | |||||
1749 | 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))); | ||||
1750 | 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))); | ||||
1751 | set_sensitive (window, "GoUp", window->priv->archive_present && (current_dir != NULL((void*)0)) && (strcmp (current_dir, "/") != 0)); | ||||
1752 | set_sensitive (window, "GoHome", window->priv->archive_present); | ||||
1753 | ctk_widget_set_sensitive (window->priv->location_entry, window->priv->archive_present); | ||||
1754 | ctk_widget_set_sensitive (window->priv->location_label, window->priv->archive_present); | ||||
1755 | ctk_widget_set_sensitive (window->priv->filter_entry, window->priv->archive_present); | ||||
1756 | |||||
1757 | #if 0 | ||||
1758 | fr_window_history_print (window); | ||||
1759 | #endif | ||||
1760 | |||||
1761 | path = remove_ending_separator (current_dir); | ||||
1762 | if (get_tree_iter_from_path (window, path, NULL((void*)0), &iter)) { | ||||
1763 | CtkTreeSelection *selection; | ||||
1764 | CtkTreePath *t_path; | ||||
1765 | |||||
1766 | 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); | ||||
1767 | 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); | ||||
1768 | ctk_tree_path_free (t_path); | ||||
1769 | |||||
1770 | 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 ()))))))); | ||||
1771 | ctk_tree_selection_select_iter (selection, &iter); | ||||
1772 | } | ||||
1773 | g_free (path); | ||||
1774 | } | ||||
1775 | |||||
1776 | |||||
1777 | static void | ||||
1778 | fr_window_update_dir_tree (FrWindow *window) | ||||
1779 | { | ||||
1780 | GPtrArray *dirs; | ||||
1781 | GHashTable *dir_cache; | ||||
1782 | guint i; | ||||
1783 | GdkPixbuf *icon; | ||||
1784 | |||||
1785 | ctk_tree_store_clear (window->priv->tree_store); | ||||
1786 | |||||
1787 | if (! window->priv->view_folders | ||||
1788 | || ! window->priv->archive_present | ||||
1789 | || (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT)) | ||||
1790 | { | ||||
1791 | ctk_widget_set_sensitive (window->priv->tree_view, FALSE(0)); | ||||
1792 | ctk_widget_hide (window->priv->sidepane); | ||||
1793 | return; | ||||
1794 | } | ||||
1795 | else { | ||||
1796 | ctk_widget_set_sensitive (window->priv->tree_view, TRUE(!(0))); | ||||
1797 | if (! ctk_widget_get_visible (window->priv->sidepane)) | ||||
1798 | ctk_widget_show_all (window->priv->sidepane); | ||||
1799 | } | ||||
1800 | |||||
1801 | if (ctk_widget_get_realized (window->priv->tree_view)) | ||||
1802 | 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); | ||||
1803 | |||||
1804 | /**/ | ||||
1805 | |||||
1806 | dirs = g_ptr_array_sized_new (128); | ||||
1807 | |||||
1808 | dir_cache = g_hash_table_new_full (g_str_hash, g_str_equal, NULL((void*)0), NULL((void*)0)); | ||||
1809 | for (i = 0; i < window->archive->command->files->len; i++) { | ||||
1810 | FileData *fdata = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i]; | ||||
1811 | char *dir; | ||||
1812 | |||||
1813 | 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)) { | ||||
1814 | if (! file_data_respects_filter (window, fdata)) | ||||
1815 | continue; | ||||
1816 | } | ||||
1817 | |||||
1818 | if (fdata->dir) | ||||
1819 | dir = remove_ending_separator (fdata->full_path); | ||||
1820 | else | ||||
1821 | dir = remove_level_from_path (fdata->full_path); | ||||
1822 | |||||
1823 | while ((dir != NULL((void*)0)) && (strcmp (dir, "/") != 0)) { | ||||
1824 | char *new_dir; | ||||
1825 | |||||
1826 | if (g_hash_table_lookup (dir_cache, dir) != NULL((void*)0)) | ||||
1827 | break; | ||||
1828 | |||||
1829 | new_dir = dir; | ||||
1830 | g_ptr_array_add (dirs, new_dir); | ||||
1831 | g_hash_table_replace (dir_cache, new_dir, "1"); | ||||
1832 | |||||
1833 | dir = remove_level_from_path (new_dir); | ||||
1834 | } | ||||
1835 | |||||
1836 | g_free (dir); | ||||
1837 | } | ||||
1838 | g_hash_table_destroy (dir_cache); | ||||
1839 | |||||
1840 | g_ptr_array_sort (dirs, path_compare); | ||||
1841 | dir_cache = g_hash_table_new_full (g_str_hash, g_str_equal, NULL((void*)0), (GDestroyNotify) ctk_tree_path_free); | ||||
1842 | |||||
1843 | /**/ | ||||
1844 | |||||
1845 | icon = get_mime_type_icon (MIME_TYPE_ARCHIVE"application/x-archive"); | ||||
1846 | { | ||||
1847 | CtkTreeIter node; | ||||
1848 | char *uri; | ||||
1849 | char *name; | ||||
1850 | |||||
1851 | uri = g_file_get_uri (window->archive->file); | ||||
1852 | name = g_uri_display_basename (uri); | ||||
1853 | |||||
1854 | ctk_tree_store_append (window->priv->tree_store, &node, NULL((void*)0)); | ||||
1855 | ctk_tree_store_set (window->priv->tree_store, &node, | ||||
1856 | TREE_COLUMN_ICON, icon, | ||||
1857 | TREE_COLUMN_NAME, name, | ||||
1858 | TREE_COLUMN_PATH, "/", | ||||
1859 | TREE_COLUMN_WEIGHT, PANGO_WEIGHT_BOLD, | ||||
1860 | -1); | ||||
1861 | 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)); | ||||
1862 | |||||
1863 | g_free (name); | ||||
1864 | g_free (uri); | ||||
1865 | } | ||||
1866 | g_object_unref (icon); | ||||
1867 | |||||
1868 | /**/ | ||||
1869 | |||||
1870 | icon = get_mime_type_icon (MIME_TYPE_DIRECTORY"folder"); | ||||
1871 | for (i = 0; i < dirs->len; i++) { | ||||
1872 | char *dir = g_ptr_array_index (dirs, i)((dirs)->pdata)[i]; | ||||
1873 | char *parent_dir; | ||||
1874 | CtkTreePath *parent_path; | ||||
1875 | CtkTreeIter parent; | ||||
1876 | CtkTreeIter node; | ||||
1877 | |||||
1878 | parent_dir = remove_level_from_path (dir); | ||||
1879 | if (parent_dir == NULL((void*)0)) | ||||
1880 | continue; | ||||
1881 | |||||
1882 | parent_path = g_hash_table_lookup (dir_cache, parent_dir); | ||||
1883 | 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 ())))))), | ||||
1884 | &parent, | ||||
1885 | parent_path); | ||||
1886 | ctk_tree_store_append (window->priv->tree_store, &node, &parent); | ||||
1887 | ctk_tree_store_set (window->priv->tree_store, &node, | ||||
1888 | TREE_COLUMN_ICON, icon, | ||||
1889 | TREE_COLUMN_NAME, file_name_from_path (dir), | ||||
1890 | TREE_COLUMN_PATH, dir, | ||||
1891 | TREE_COLUMN_WEIGHT, PANGO_WEIGHT_NORMAL, | ||||
1892 | -1); | ||||
1893 | 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)); | ||||
1894 | |||||
1895 | g_free (parent_dir); | ||||
1896 | } | ||||
1897 | g_hash_table_destroy (dir_cache); | ||||
1898 | if (icon != NULL((void*)0)) | ||||
1899 | g_object_unref (icon); | ||||
1900 | |||||
1901 | g_ptr_array_free (dirs, TRUE(!(0))); | ||||
1902 | |||||
1903 | fr_window_update_current_location (window); | ||||
1904 | } | ||||
1905 | |||||
1906 | |||||
1907 | static void | ||||
1908 | fr_window_update_filter_bar_visibility (FrWindow *window) | ||||
1909 | { | ||||
1910 | const char *filter; | ||||
1911 | |||||
1912 | 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 ()))))))); | ||||
1913 | if ((filter == NULL((void*)0)) || (*filter == '\0')) | ||||
1914 | ctk_widget_hide (window->priv->filter_bar); | ||||
1915 | else | ||||
1916 | ctk_widget_show (window->priv->filter_bar); | ||||
1917 | } | ||||
1918 | |||||
1919 | |||||
1920 | static void | ||||
1921 | fr_window_update_file_list (FrWindow *window, | ||||
1922 | gboolean update_view) | ||||
1923 | { | ||||
1924 | GPtrArray *files; | ||||
1925 | gboolean free_files = FALSE(0); | ||||
1926 | |||||
1927 | if (ctk_widget_get_realized (window->priv->list_view)) | ||||
1928 | 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); | ||||
1929 | |||||
1930 | if (! window->priv->archive_present || window->priv->archive_new) { | ||||
1931 | if (update_view) | ||||
1932 | ctk_list_store_clear (window->priv->list_store); | ||||
1933 | |||||
1934 | window->priv->current_view_length = 0; | ||||
1935 | |||||
1936 | if (window->priv->archive_new) { | ||||
1937 | ctk_widget_set_sensitive (window->priv->list_view, TRUE(!(0))); | ||||
1938 | ctk_widget_show_all (ctk_widget_get_parent (window->priv->list_view)); | ||||
1939 | } | ||||
1940 | else { | ||||
1941 | ctk_widget_set_sensitive (window->priv->list_view, FALSE(0)); | ||||
1942 | ctk_widget_hide (ctk_widget_get_parent (window->priv->list_view)); | ||||
1943 | } | ||||
1944 | |||||
1945 | return; | ||||
1946 | } | ||||
1947 | else { | ||||
1948 | ctk_widget_set_sensitive (window->priv->list_view, TRUE(!(0))); | ||||
1949 | ctk_widget_show_all (ctk_widget_get_parent (window->priv->list_view)); | ||||
1950 | } | ||||
1951 | |||||
1952 | if (window->priv->give_focus_to_the_list) { | ||||
1953 | ctk_widget_grab_focus (window->priv->list_view); | ||||
1954 | window->priv->give_focus_to_the_list = FALSE(0); | ||||
1955 | } | ||||
1956 | |||||
1957 | /**/ | ||||
1958 | |||||
1959 | fr_window_start_activity_mode (window); | ||||
1960 | |||||
1961 | if (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT) { | ||||
1962 | fr_window_compute_list_names (window, window->archive->command->files); | ||||
1963 | files = window->archive->command->files; | ||||
1964 | free_files = FALSE(0); | ||||
1965 | } | ||||
1966 | else { | ||||
1967 | char *current_dir = g_strdup (fr_window_get_current_location (window))g_strdup_inline (fr_window_get_current_location (window)); | ||||
1968 | |||||
1969 | while (! fr_window_dir_exists_in_archive (window, current_dir)) { | ||||
1970 | char *tmp; | ||||
1971 | |||||
1972 | fr_window_history_pop (window); | ||||
1973 | |||||
1974 | tmp = get_parent_dir (current_dir); | ||||
1975 | g_free (current_dir); | ||||
1976 | current_dir = tmp; | ||||
1977 | |||||
1978 | fr_window_history_add (window, current_dir); | ||||
1979 | } | ||||
1980 | g_free (current_dir); | ||||
1981 | |||||
1982 | fr_window_compute_list_names (window, window->archive->command->files); | ||||
1983 | files = fr_window_get_current_dir_list (window); | ||||
1984 | free_files = TRUE(!(0)); | ||||
1985 | } | ||||
1986 | |||||
1987 | if (files != NULL((void*)0)) | ||||
1988 | window->priv->current_view_length = files->len; | ||||
1989 | else | ||||
1990 | window->priv->current_view_length = 0; | ||||
1991 | |||||
1992 | if (update_view) | ||||
1993 | fr_window_populate_file_list (window, files); | ||||
1994 | |||||
1995 | if (free_files) | ||||
1996 | g_ptr_array_free (files, TRUE(!(0))); | ||||
1997 | } | ||||
1998 | |||||
1999 | |||||
2000 | void | ||||
2001 | fr_window_update_list_order (FrWindow *window) | ||||
2002 | { | ||||
2003 | 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); | ||||
2004 | } | ||||
2005 | |||||
2006 | |||||
2007 | static void | ||||
2008 | fr_window_update_title (FrWindow *window) | ||||
2009 | { | ||||
2010 | if (! window->priv->archive_present) | ||||
2011 | 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")); | ||||
2012 | else { | ||||
2013 | char *title; | ||||
2014 | char *name; | ||||
2015 | |||||
2016 | name = g_uri_display_basename (fr_window_get_archive_uri (window)); | ||||
2017 | title = g_strdup_printf ("%s %s", | ||||
2018 | name, | ||||
2019 | window->archive->read_only ? _("[read only]")gettext ("[read only]") : ""); | ||||
2020 | |||||
2021 | ctk_window_set_title (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), title); | ||||
2022 | g_free (title); | ||||
2023 | g_free (name); | ||||
2024 | } | ||||
2025 | } | ||||
2026 | |||||
2027 | |||||
2028 | static void | ||||
2029 | check_whether_has_a_dir (CtkTreeModel *model, | ||||
2030 | CtkTreePath *path, | ||||
2031 | CtkTreeIter *iter, | ||||
2032 | gpointer data) | ||||
2033 | { | ||||
2034 | gboolean *has_a_dir = data; | ||||
2035 | FileData *fdata; | ||||
2036 | |||||
2037 | ctk_tree_model_get (model, iter, | ||||
2038 | COLUMN_FILE_DATA, &fdata, | ||||
2039 | -1); | ||||
2040 | if (file_data_is_dir (fdata)) | ||||
2041 | *has_a_dir = TRUE(!(0)); | ||||
2042 | } | ||||
2043 | |||||
2044 | |||||
2045 | static gboolean | ||||
2046 | selection_has_a_dir (FrWindow *window) | ||||
2047 | { | ||||
2048 | CtkTreeSelection *selection; | ||||
2049 | gboolean has_a_dir = FALSE(0); | ||||
2050 | |||||
2051 | if (! ctk_widget_get_realized (window->priv->list_view)) | ||||
2052 | return FALSE(0); | ||||
2053 | |||||
2054 | 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 ()))))))); | ||||
2055 | if (selection == NULL((void*)0)) | ||||
2056 | return FALSE(0); | ||||
2057 | |||||
2058 | ctk_tree_selection_selected_foreach (selection, | ||||
2059 | check_whether_has_a_dir, | ||||
2060 | &has_a_dir); | ||||
2061 | |||||
2062 | return has_a_dir; | ||||
2063 | } | ||||
2064 | |||||
2065 | |||||
2066 | static void | ||||
2067 | set_active (FrWindow *window, | ||||
2068 | const char *action_name, | ||||
2069 | gboolean is_active) | ||||
2070 | { | ||||
2071 | CtkAction *action; | ||||
2072 | |||||
2073 | action = ctk_action_group_get_action (window->priv->actions, action_name); | ||||
2074 | 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); | ||||
2075 | } | ||||
2076 | |||||
2077 | |||||
2078 | static void | ||||
2079 | fr_window_update_paste_command_sensitivity (FrWindow *window, | ||||
2080 | CtkClipboard *clipboard) | ||||
2081 | { | ||||
2082 | gboolean running; | ||||
2083 | gboolean no_archive; | ||||
2084 | gboolean ro; | ||||
2085 | gboolean compr_file; | ||||
2086 | |||||
2087 | if (window->priv->closing) | ||||
2088 | return; | ||||
2089 | |||||
2090 | if (clipboard == NULL((void*)0)) | ||||
2091 | 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" ))); | ||||
2092 | running = window->priv->activity_ref > 0; | ||||
2093 | no_archive = (window->archive == NULL((void*)0)) || ! window->priv->archive_present; | ||||
2094 | ro = ! no_archive && window->archive->read_only; | ||||
2095 | compr_file = ! no_archive && window->archive->is_compressed_file; | ||||
2096 | |||||
2097 | 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") ))); | ||||
2098 | } | ||||
2099 | |||||
2100 | |||||
2101 | static void | ||||
2102 | fr_window_update_sensitivity (FrWindow *window) | ||||
2103 | { | ||||
2104 | gboolean no_archive; | ||||
2105 | gboolean ro; | ||||
2106 | gboolean file_op; | ||||
2107 | gboolean running; | ||||
2108 | gboolean compr_file; | ||||
2109 | gboolean sel_not_null; | ||||
2110 | gboolean one_file_selected; | ||||
2111 | gboolean dir_selected; | ||||
2112 | int n_selected; | ||||
2113 | |||||
2114 | if (window->priv->batch_mode) | ||||
2115 | return; | ||||
2116 | |||||
2117 | running = window->priv->activity_ref > 0; | ||||
2118 | no_archive = (window->archive == NULL((void*)0)) || ! window->priv->archive_present; | ||||
2119 | ro = ! no_archive
| ||||
2120 | file_op = ! no_archive
| ||||
2121 | compr_file = ! no_archive
| ||||
2122 | n_selected = fr_window_get_n_selected_files (window); | ||||
2123 | sel_not_null = n_selected > 0; | ||||
2124 | one_file_selected = n_selected
| ||||
2125 | dir_selected = selection_has_a_dir (window); | ||||
2126 | |||||
2127 | set_sensitive (window, "AddFiles", ! no_archive
| ||||
2128 | set_sensitive (window, "AddFiles_Toolbar", ! no_archive
| ||||
2129 | set_sensitive (window, "AddFolder", ! no_archive
| ||||
2130 | set_sensitive (window, "AddFolder_Toolbar", ! no_archive
| ||||
2131 | set_sensitive (window, "Copy", ! no_archive
| ||||
2132 | set_sensitive (window, "Cut", ! no_archive
| ||||
2133 | set_sensitive (window, "Delete", ! no_archive
| ||||
2134 | set_sensitive (window, "DeselectAll", ! no_archive
| ||||
2135 | set_sensitive (window, "Extract", file_op); | ||||
2136 | set_sensitive (window, "Extract_Toolbar", file_op); | ||||
2137 | set_sensitive (window, "Find", ! no_archive); | ||||
2138 | set_sensitive (window, "LastOutput", ((window->archive != NULL((void*)0)) | ||||
2139 | && (window->archive->process != NULL((void*)0)) | ||||
2140 | && (window->archive->process->out.raw != NULL((void*)0)))); | ||||
2141 | set_sensitive (window, "New", ! running); | ||||
2142 | set_sensitive (window, "Open", ! running); | ||||
2143 | set_sensitive (window, "Open_Toolbar", ! running); | ||||
2144 | set_sensitive (window, "OpenSelection", file_op
| ||||
2145 | set_sensitive (window, "OpenFolder", file_op
| ||||
2146 | set_sensitive (window, "Password", ! running
| ||||
| |||||
2147 | set_sensitive (window, "Properties", file_op); | ||||
2148 | set_sensitive (window, "Close", !running || window->priv->stoppable); | ||||
2149 | set_sensitive (window, "Reload", ! (no_archive || running)); | ||||
2150 | set_sensitive (window, "Rename", ! no_archive && ! ro && ! running && ! compr_file && one_file_selected); | ||||
2151 | set_sensitive (window, "SaveAs", ! no_archive && ! compr_file && ! running); | ||||
2152 | set_sensitive (window, "SelectAll", ! no_archive); | ||||
2153 | set_sensitive (window, "Stop", running && window->priv->stoppable); | ||||
2154 | set_sensitive (window, "TestArchive", ! no_archive && ! running && window->archive->command->propTest); | ||||
2155 | set_sensitive (window, "ViewSelection", file_op && one_file_selected && ! dir_selected); | ||||
2156 | set_sensitive (window, "ViewSelection_Toolbar", file_op && one_file_selected && ! dir_selected); | ||||
2157 | |||||
2158 | if (window->priv->progress_dialog != NULL((void*)0)) | ||||
2159 | 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 ())))))), | ||||
2160 | CTK_RESPONSE_OK, | ||||
2161 | running && window->priv->stoppable); | ||||
2162 | |||||
2163 | fr_window_update_paste_command_sensitivity (window, NULL((void*)0)); | ||||
2164 | |||||
2165 | set_sensitive (window, "SelectAll", (window->priv->current_view_length > 0) && (window->priv->current_view_length != n_selected)); | ||||
2166 | set_sensitive (window, "DeselectAll", n_selected > 0); | ||||
2167 | set_sensitive (window, "OpenRecent", ! running); | ||||
2168 | set_sensitive (window, "OpenRecent_Toolbar", ! running); | ||||
2169 | |||||
2170 | set_sensitive (window, "ViewFolders", (window->priv->list_mode == FR_WINDOW_LIST_MODE_AS_DIR)); | ||||
2171 | |||||
2172 | set_sensitive (window, "ViewAllFiles", ! window->priv->filter_mode); | ||||
2173 | set_sensitive (window, "ViewAsFolder", ! window->priv->filter_mode); | ||||
2174 | } | ||||
2175 | |||||
2176 | |||||
2177 | static gboolean | ||||
2178 | location_entry_key_press_event_cb (CtkWidget *widget, | ||||
2179 | CdkEventKey *event, | ||||
2180 | FrWindow *window) | ||||
2181 | { | ||||
2182 | if ((event->keyval == CDK_KEY_Return0xff0d) | ||||
2183 | || (event->keyval == CDK_KEY_KP_Enter0xff8d) | ||||
2184 | || (event->keyval == CDK_KEY_ISO_Enter0xfe34)) | ||||
2185 | { | ||||
2186 | 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)); | ||||
2187 | } | ||||
2188 | |||||
2189 | return FALSE(0); | ||||
2190 | } | ||||
2191 | |||||
2192 | |||||
2193 | static void | ||||
2194 | show_notification (FrWindow *window) | ||||
2195 | { | ||||
2196 | GSettings *settings; | ||||
2197 | settings = g_settings_new ("org.cafe.grapa.general"); | ||||
2198 | |||||
2199 | if ((g_settings_get_boolean (settings, "notifications")) && | ||||
2200 | (window->priv->use_progress_dialog) && | ||||
2201 | (window->priv->progress_dialog != NULL((void*)0)) && | ||||
2202 | (ctk_widget_get_visible (window->priv->progress_dialog)) && | ||||
2203 | (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)) && | ||||
2204 | (ctk_window_is_active (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ()))))))) == FALSE(0)) && | ||||
2205 | enable_notifications) { | ||||
2206 | notify_init ("grapa"); | ||||
2207 | NotifyNotification *notification; | ||||
2208 | |||||
2209 | notification = notify_notification_new ("grapa", | ||||
2210 | _("Process completed")gettext ("Process completed"), | ||||
2211 | "grapa"); | ||||
2212 | |||||
2213 | notify_notification_show (notification, NULL((void*)0)); | ||||
2214 | g_object_unref (G_OBJECT (notification)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notification)), (((GType) ((20) << (2))))))))); | ||||
2215 | notify_uninit (); | ||||
2216 | } | ||||
2217 | |||||
2218 | enable_notifications = TRUE(!(0)); | ||||
2219 | g_object_unref (settings); | ||||
2220 | } | ||||
2221 | |||||
2222 | |||||
2223 | static gboolean | ||||
2224 | real_close_progress_dialog (gpointer data) | ||||
2225 | { | ||||
2226 | FrWindow *window = data; | ||||
2227 | |||||
2228 | show_notification (window); | ||||
2229 | |||||
2230 | if (window->priv->hide_progress_timeout != 0) { | ||||
2231 | g_source_remove (window->priv->hide_progress_timeout); | ||||
2232 | window->priv->hide_progress_timeout = 0; | ||||
2233 | } | ||||
2234 | |||||
2235 | if (window->priv->progress_dialog != NULL((void*)0)) | ||||
2236 | ctk_widget_hide (window->priv->progress_dialog); | ||||
2237 | |||||
2238 | return FALSE(0); | ||||
2239 | } | ||||
2240 | |||||
2241 | |||||
2242 | static void close_suspend_process(FrWindow *window) | ||||
2243 | { | ||||
2244 | if (window->archive->process != NULL((void*)0)) | ||||
2245 | { | ||||
2246 | start_close_suspend_process(window->archive->process); | ||||
2247 | } | ||||
2248 | } | ||||
2249 | static void | ||||
2250 | close_progress_dialog (FrWindow *window, | ||||
2251 | gboolean close_now) | ||||
2252 | { | ||||
2253 | if (window->priv->progress_timeout != 0) { | ||||
2254 | g_source_remove (window->priv->progress_timeout); | ||||
2255 | window->priv->progress_timeout = 0; | ||||
2256 | } | ||||
2257 | |||||
2258 | 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 ())))))))) | ||||
2259 | ctk_widget_hide (window->priv->progress_bar); | ||||
2260 | |||||
2261 | if (window->priv->progress_dialog == NULL((void*)0)) | ||||
2262 | return; | ||||
2263 | |||||
2264 | if (close_now) { | ||||
2265 | if (window->priv->hide_progress_timeout != 0) { | ||||
2266 | g_source_remove (window->priv->hide_progress_timeout); | ||||
2267 | window->priv->hide_progress_timeout = 0; | ||||
2268 | } | ||||
2269 | real_close_progress_dialog (window); | ||||
2270 | } | ||||
2271 | else { | ||||
2272 | if (window->priv->hide_progress_timeout != 0) | ||||
2273 | return; | ||||
2274 | window->priv->hide_progress_timeout = g_timeout_add (HIDE_PROGRESS_TIMEOUT_MSECS500, | ||||
2275 | real_close_progress_dialog, | ||||
2276 | window); | ||||
2277 | } | ||||
2278 | close_suspend_process(window); | ||||
2279 | } | ||||
2280 | |||||
2281 | |||||
2282 | static gboolean | ||||
2283 | progress_dialog_delete_event (CtkWidget *caller, | ||||
2284 | CdkEvent *event, | ||||
2285 | FrWindow *window) | ||||
2286 | { | ||||
2287 | if (window->priv->stoppable) { | ||||
2288 | activate_action_stop (NULL((void*)0), window); | ||||
2289 | close_progress_dialog (window, TRUE(!(0))); | ||||
2290 | } | ||||
2291 | |||||
2292 | return TRUE(!(0)); | ||||
2293 | } | ||||
2294 | |||||
2295 | |||||
2296 | static void | ||||
2297 | open_folder (CtkWindow *parent, | ||||
2298 | const char *folder) | ||||
2299 | { | ||||
2300 | GError *error = NULL((void*)0); | ||||
2301 | |||||
2302 | if (folder == NULL((void*)0)) | ||||
2303 | return; | ||||
2304 | |||||
2305 | if (! ctk_show_uri_on_window (parent, folder, CDK_CURRENT_TIME0L, &error)) { | ||||
2306 | CtkWidget *d; | ||||
2307 | char *utf8_name; | ||||
2308 | char *message; | ||||
2309 | |||||
2310 | utf8_name = g_filename_display_name (folder); | ||||
2311 | message = g_strdup_printf (_("Could not display the folder \"%s\"")gettext ("Could not display the folder \"%s\""), utf8_name); | ||||
2312 | g_free (utf8_name); | ||||
2313 | |||||
2314 | d = _ctk_error_dialog_new (parent, | ||||
2315 | CTK_DIALOG_MODAL, | ||||
2316 | NULL((void*)0), | ||||
2317 | message, | ||||
2318 | "%s", | ||||
2319 | error->message); | ||||
2320 | ctk_dialog_run (CTK_DIALOG (d)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((d)), ((ctk_dialog_get_type ()))))))); | ||||
2321 | ctk_widget_destroy (d); | ||||
2322 | |||||
2323 | g_free (message); | ||||
2324 | g_clear_error (&error); | ||||
2325 | } | ||||
2326 | } | ||||
2327 | |||||
2328 | |||||
2329 | static void | ||||
2330 | fr_window_view_extraction_destination_folder (FrWindow *window) | ||||
2331 | { | ||||
2332 | 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)); | ||||
2333 | } | ||||
2334 | |||||
2335 | static void change_button_label (FrWindow *window, | ||||
2336 | CtkWidget *button) | ||||
2337 | { | ||||
2338 | const gchar *state; | ||||
2339 | state = ctk_button_get_label (CTK_BUTTON (button)((((CtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((button)), ((ctk_button_get_type ()))))))); | ||||
2340 | |||||
2341 | if (g_strrstr (_("_Pause")gettext ("_Pause"), state) != NULL((void*)0)) | ||||
2342 | { | ||||
2343 | ctk_widget_set_visible (window->priv->pd_progress_bar, FALSE(0)); | ||||
2344 | fr_command_message (window->archive->command, _("Process paused")gettext ("Process paused")); | ||||
2345 | |||||
2346 | ctk_button_set_label (CTK_BUTTON (button)((((CtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((button)), ((ctk_button_get_type ())))))), _("_Resume")gettext ("_Resume")); | ||||
2347 | ctk_button_set_image (CTK_BUTTON (button)((((CtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((button)), ((ctk_button_get_type ())))))), | ||||
2348 | ctk_image_new_from_icon_name ("media-playback-start", | ||||
2349 | CTK_ICON_SIZE_BUTTON)); | ||||
2350 | } | ||||
2351 | else | ||||
2352 | { | ||||
2353 | ctk_widget_set_visible (window->priv->pd_progress_bar, TRUE(!(0))); | ||||
2354 | fr_command_message (window->archive->command, _("Please wait…")gettext ("Please wait…")); | ||||
2355 | |||||
2356 | ctk_button_set_label (CTK_BUTTON(button)((((CtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((button)), ((ctk_button_get_type ())))))), _("_Pause")gettext ("_Pause")); | ||||
2357 | ctk_button_set_image (CTK_BUTTON (button)((((CtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((button)), ((ctk_button_get_type ())))))), | ||||
2358 | ctk_image_new_from_icon_name ("media-playback-pause", | ||||
2359 | CTK_ICON_SIZE_BUTTON)); | ||||
2360 | } | ||||
2361 | } | ||||
2362 | static void fr_state_switch (FrWindow *window) | ||||
2363 | { | ||||
2364 | int ret; | ||||
2365 | if (window->archive->process != NULL((void*)0)) | ||||
2366 | { | ||||
2367 | ret = start_switch_state (window->archive->process); | ||||
2368 | if (ret == 0) | ||||
2369 | { | ||||
2370 | change_button_label (window, window->priv->pd_state_button); | ||||
2371 | } | ||||
2372 | } | ||||
2373 | } | ||||
2374 | |||||
2375 | static void | ||||
2376 | progress_dialog_response (CtkDialog *dialog, | ||||
2377 | int response_id, | ||||
2378 | FrWindow *window) | ||||
2379 | { | ||||
2380 | CtkWidget *new_window; | ||||
2381 | |||||
2382 | switch (response_id) { | ||||
2383 | case CTK_RESPONSE_CANCEL: | ||||
2384 | if (window->priv->stoppable) { | ||||
2385 | activate_action_stop (NULL((void*)0), window); | ||||
2386 | close_progress_dialog (window, TRUE(!(0))); | ||||
2387 | } | ||||
2388 | break; | ||||
2389 | case CTK_RESPONSE_CLOSE: | ||||
2390 | close_progress_dialog (window, TRUE(!(0))); | ||||
2391 | break; | ||||
2392 | case DIALOG_RESPONSE_OPEN_ARCHIVE: | ||||
2393 | new_window = fr_window_new (); | ||||
2394 | ctk_widget_show (new_window); | ||||
2395 | 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 ()))))))); | ||||
2396 | close_progress_dialog (window, TRUE(!(0))); | ||||
2397 | break; | ||||
2398 | case DIALOG_RESPONSE_OPEN_DESTINATION_FOLDER: | ||||
2399 | fr_window_view_extraction_destination_folder (window); | ||||
2400 | close_progress_dialog (window, TRUE(!(0))); | ||||
2401 | break; | ||||
2402 | case DIALOG_RESPONSE_OPEN_DESTINATION_FOLDER_AND_QUIT: | ||||
2403 | fr_window_view_extraction_destination_folder (window); | ||||
2404 | close_progress_dialog (window, TRUE(!(0))); | ||||
2405 | fr_window_close (window); | ||||
2406 | break; | ||||
2407 | case DIALOG_RESPONSE_QUIT: | ||||
2408 | fr_window_close (window); | ||||
2409 | break; | ||||
2410 | case CTK_RESPONSE_ACCEPT: | ||||
2411 | fr_state_switch (window); | ||||
2412 | break; | ||||
2413 | default: | ||||
2414 | break; | ||||
2415 | } | ||||
2416 | } | ||||
2417 | |||||
2418 | |||||
2419 | static char* | ||||
2420 | get_action_description (FrAction action, | ||||
2421 | const char *uri) | ||||
2422 | { | ||||
2423 | char *basename; | ||||
2424 | char *message; | ||||
2425 | |||||
2426 | basename = (uri != NULL((void*)0)) ? g_uri_display_basename (uri) : NULL((void*)0); | ||||
2427 | |||||
2428 | message = NULL((void*)0); | ||||
2429 | switch (action) { | ||||
2430 | case FR_ACTION_CREATING_NEW_ARCHIVE: | ||||
2431 | /* Translators: %s is a filename */ | ||||
2432 | message = g_strdup_printf (_("Creating \"%s\"")gettext ("Creating \"%s\""), basename); | ||||
2433 | break; | ||||
2434 | case FR_ACTION_LOADING_ARCHIVE: | ||||
2435 | /* Translators: %s is a filename */ | ||||
2436 | message = g_strdup_printf (_("Loading \"%s\"")gettext ("Loading \"%s\""), basename); | ||||
2437 | break; | ||||
2438 | case FR_ACTION_LISTING_CONTENT: | ||||
2439 | /* Translators: %s is a filename */ | ||||
2440 | message = g_strdup_printf (_("Reading \"%s\"")gettext ("Reading \"%s\""), basename); | ||||
2441 | break; | ||||
2442 | case FR_ACTION_DELETING_FILES: | ||||
2443 | /* Translators: %s is a filename */ | ||||
2444 | message = g_strdup_printf (_("Deleting files from \"%s\"")gettext ("Deleting files from \"%s\""), basename); | ||||
2445 | break; | ||||
2446 | case FR_ACTION_TESTING_ARCHIVE: | ||||
2447 | /* Translators: %s is a filename */ | ||||
2448 | message = g_strdup_printf (_("Testing \"%s\"")gettext ("Testing \"%s\""), basename); | ||||
2449 | break; | ||||
2450 | case FR_ACTION_GETTING_FILE_LIST: | ||||
2451 | message = g_strdup (_("Getting the file list"))g_strdup_inline (gettext ("Getting the file list")); | ||||
2452 | break; | ||||
2453 | case FR_ACTION_COPYING_FILES_FROM_REMOTE: | ||||
2454 | /* Translators: %s is a filename */ | ||||
2455 | message = g_strdup_printf (_("Copying the files to add to \"%s\"")gettext ("Copying the files to add to \"%s\""), basename); | ||||
2456 | break; | ||||
2457 | case FR_ACTION_ADDING_FILES: | ||||
2458 | /* Translators: %s is a filename */ | ||||
2459 | message = g_strdup_printf (_("Adding files to \"%s\"")gettext ("Adding files to \"%s\""), basename); | ||||
2460 | break; | ||||
2461 | case FR_ACTION_EXTRACTING_FILES: | ||||
2462 | /* Translators: %s is a filename */ | ||||
2463 | message = g_strdup_printf (_("Extracting files from \"%s\"")gettext ("Extracting files from \"%s\""), basename); | ||||
2464 | break; | ||||
2465 | case FR_ACTION_COPYING_FILES_TO_REMOTE: | ||||
2466 | message = g_strdup (_("Copying the extracted files to the destination"))g_strdup_inline (gettext ("Copying the extracted files to the destination" )); | ||||
2467 | break; | ||||
2468 | case FR_ACTION_CREATING_ARCHIVE: | ||||
2469 | /* Translators: %s is a filename */ | ||||
2470 | message = g_strdup_printf (_("Creating \"%s\"")gettext ("Creating \"%s\""), basename); | ||||
2471 | break; | ||||
2472 | case FR_ACTION_SAVING_REMOTE_ARCHIVE: | ||||
2473 | /* Translators: %s is a filename */ | ||||
2474 | message = g_strdup_printf (_("Saving \"%s\"")gettext ("Saving \"%s\""), basename); | ||||
2475 | break; | ||||
2476 | case FR_ACTION_NONE: | ||||
2477 | break; | ||||
2478 | } | ||||
2479 | g_free (basename); | ||||
2480 | |||||
2481 | return message; | ||||
2482 | } | ||||
2483 | |||||
2484 | |||||
2485 | static void | ||||
2486 | progress_dialog_update_action_description (FrWindow *window) | ||||
2487 | { | ||||
2488 | const char *current_archive; | ||||
2489 | char *description; | ||||
2490 | char *description_markup; | ||||
2491 | |||||
2492 | if (window->priv->progress_dialog == NULL((void*)0)) | ||||
2493 | return; | ||||
2494 | |||||
2495 | if (window->priv->convert_data.converting) | ||||
2496 | current_archive = window->priv->convert_data.new_file; | ||||
2497 | else if (window->priv->working_archive != NULL((void*)0)) | ||||
2498 | current_archive = window->priv->working_archive; | ||||
2499 | else | ||||
2500 | current_archive = window->priv->archive_uri; | ||||
2501 | |||||
2502 | g_free (window->priv->pd_last_archive); | ||||
2503 | window->priv->pd_last_archive = NULL((void*)0); | ||||
2504 | if (current_archive != NULL((void*)0)) | ||||
2505 | window->priv->pd_last_archive = g_strdup (current_archive)g_strdup_inline (current_archive); | ||||
2506 | |||||
2507 | description = get_action_description (window->priv->action, window->priv->pd_last_archive); | ||||
2508 | description_markup = g_markup_printf_escaped ("<span weight=\"bold\" size=\"larger\">%s</span>", description); | ||||
2509 | 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); | ||||
2510 | |||||
2511 | g_free (description_markup); | ||||
2512 | g_free (description); | ||||
2513 | } | ||||
2514 | |||||
2515 | |||||
2516 | static gboolean | ||||
2517 | fr_window_working_archive_cb (FrCommand *command, | ||||
2518 | const char *archive_filename, | ||||
2519 | FrWindow *window) | ||||
2520 | { | ||||
2521 | g_free (window->priv->working_archive); | ||||
2522 | window->priv->working_archive = NULL((void*)0); | ||||
2523 | if (archive_filename != NULL((void*)0)) | ||||
2524 | window->priv->working_archive = g_strdup (archive_filename)g_strdup_inline (archive_filename); | ||||
2525 | progress_dialog_update_action_description (window); | ||||
2526 | |||||
2527 | return TRUE(!(0)); | ||||
2528 | } | ||||
2529 | |||||
2530 | |||||
2531 | static gboolean | ||||
2532 | fr_window_message_cb (FrCommand *command, | ||||
2533 | const char *msg, | ||||
2534 | FrWindow *window) | ||||
2535 | { | ||||
2536 | if (window->priv->pd_last_message != msg) { | ||||
2537 | g_free (window->priv->pd_last_message); | ||||
2538 | window->priv->pd_last_message = g_strdup (msg)g_strdup_inline (msg); | ||||
2539 | } | ||||
2540 | |||||
2541 | if (window->priv->progress_dialog == NULL((void*)0)) | ||||
2542 | return TRUE(!(0)); | ||||
2543 | |||||
2544 | if (msg != NULL((void*)0)) { | ||||
2545 | while (*msg == ' ') | ||||
2546 | msg++; | ||||
2547 | if (*msg == 0) | ||||
2548 | msg = NULL((void*)0); | ||||
2549 | } | ||||
2550 | |||||
2551 | if (msg != NULL((void*)0)) { | ||||
2552 | char *utf8_msg; | ||||
2553 | |||||
2554 | if (! g_utf8_validate (msg, -1, NULL((void*)0))) | ||||
2555 | utf8_msg = g_locale_to_utf8 (msg, -1 , 0, 0, 0); | ||||
2556 | else | ||||
2557 | utf8_msg = g_strdup (msg)g_strdup_inline (msg); | ||||
2558 | if (utf8_msg == NULL((void*)0)) | ||||
2559 | return TRUE(!(0)); | ||||
2560 | |||||
2561 | if (g_utf8_validate (utf8_msg, -1, NULL((void*)0))) | ||||
2562 | 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); | ||||
2563 | |||||
2564 | g_free (window->priv->pd_last_message); | ||||
2565 | window->priv->pd_last_message = g_strdup (utf8_msg)g_strdup_inline (utf8_msg); | ||||
2566 | |||||
2567 | g_signal_emit (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), | ||||
2568 | fr_window_signals[PROGRESS], | ||||
2569 | 0, | ||||
2570 | window->priv->pd_last_fraction, | ||||
2571 | window->priv->pd_last_message); | ||||
2572 | |||||
2573 | #ifdef LOG_PROGRESS | ||||
2574 | g_print ("message > %s\n", utf8_msg); | ||||
2575 | #endif | ||||
2576 | |||||
2577 | g_free (utf8_msg); | ||||
2578 | } | ||||
2579 | else | ||||
2580 | 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 ( ))))))), ""); | ||||
2581 | |||||
2582 | progress_dialog_update_action_description (window); | ||||
2583 | |||||
2584 | return TRUE(!(0)); | ||||
2585 | } | ||||
2586 | |||||
2587 | |||||
2588 | static void | ||||
2589 | create_the_progress_dialog (FrWindow *window) | ||||
2590 | { | ||||
2591 | CtkWindow *parent; | ||||
2592 | CtkDialogFlags flags; | ||||
2593 | CtkDialog *d; | ||||
2594 | CtkWidget *hbox; | ||||
2595 | CtkWidget *vbox; | ||||
2596 | CtkWidget *progress_vbox; | ||||
2597 | CtkWidget *lbl; | ||||
2598 | PangoAttrList *attr_list; | ||||
2599 | GdkPixbuf *icon; | ||||
2600 | |||||
2601 | if (window->priv->progress_dialog != NULL((void*)0)) | ||||
2602 | return; | ||||
2603 | |||||
2604 | flags = CTK_DIALOG_DESTROY_WITH_PARENT; | ||||
2605 | if (window->priv->batch_mode) { | ||||
2606 | parent = NULL((void*)0); | ||||
2607 | } | ||||
2608 | else { | ||||
2609 | parent = CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))); | ||||
2610 | flags |= CTK_DIALOG_MODAL; | ||||
2611 | } | ||||
2612 | |||||
2613 | window->priv->progress_dialog = ctk_dialog_new_with_buttons ((window->priv->batch_mode ? window->priv->batch_title : NULL((void*)0)), | ||||
2614 | parent, | ||||
2615 | flags, | ||||
2616 | NULL((void*)0), | ||||
2617 | NULL((void*)0)); | ||||
2618 | |||||
2619 | 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); | ||||
2620 | 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); | ||||
2621 | 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); | ||||
2622 | 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); | ||||
2623 | 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); | ||||
2624 | 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); | ||||
2625 | /*add start button default suspend*/ | ||||
2626 | 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); | ||||
2627 | d = CTK_DIALOG (window->priv->progress_dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->progress_dialog)), ((ctk_dialog_get_type ())))))); | ||||
2628 | ctk_window_set_resizable (CTK_WINDOW (d)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((d)), ((ctk_window_get_type ())))))), TRUE(!(0))); | ||||
2629 | ctk_dialog_set_default_response (CTK_DIALOG (d)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((d)), ((ctk_dialog_get_type ())))))), CTK_RESPONSE_OK); | ||||
2630 | 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); | ||||
2631 | |||||
2632 | /* Main */ | ||||
2633 | |||||
2634 | hbox = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 24); | ||||
2635 | ctk_container_set_border_width (CTK_CONTAINER (hbox)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), ((ctk_container_get_type ())))))), 6); | ||||
2636 | 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); | ||||
2637 | |||||
2638 | 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)); | ||||
2639 | window->priv->pd_icon = ctk_image_new_from_pixbuf (icon); | ||||
2640 | g_object_unref (icon); | ||||
2641 | |||||
2642 | ctk_widget_set_valign (window->priv->pd_icon, CTK_ALIGN_START); | ||||
2643 | 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); | ||||
2644 | |||||
2645 | vbox = ctk_box_new (CTK_ORIENTATION_VERTICAL, 5); | ||||
2646 | 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); | ||||
2647 | |||||
2648 | /* action description */ | ||||
2649 | |||||
2650 | lbl = window->priv->pd_action = ctk_label_new (""); | ||||
2651 | ctk_widget_set_halign (lbl, CTK_ALIGN_START); | ||||
2652 | ctk_widget_set_valign (lbl, CTK_ALIGN_START); | ||||
2653 | ctk_widget_set_hexpand (lbl, TRUE(!(0))); | ||||
2654 | ctk_widget_set_vexpand (lbl, TRUE(!(0))); | ||||
2655 | ctk_widget_set_margin_bottom (lbl, 12); | ||||
2656 | |||||
2657 | ctk_label_set_xalign (CTK_LABEL (lbl)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((lbl)), ((ctk_label_get_type ())))))), 0.0); | ||||
2658 | ctk_label_set_ellipsize (CTK_LABEL (lbl)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((lbl)), ((ctk_label_get_type ())))))), PANGO_ELLIPSIZE_END); | ||||
2659 | 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); | ||||
2660 | |||||
2661 | /* archive name */ | ||||
2662 | |||||
2663 | g_free (window->priv->pd_last_archive); | ||||
2664 | window->priv->pd_last_archive = NULL((void*)0); | ||||
2665 | |||||
2666 | if (window->priv->archive_uri != NULL((void*)0)) | ||||
2667 | window->priv->pd_last_archive = g_strdup (window->priv->archive_uri)g_strdup_inline (window->priv->archive_uri); | ||||
2668 | |||||
2669 | /* progress and details */ | ||||
2670 | |||||
2671 | progress_vbox = ctk_box_new (CTK_ORIENTATION_VERTICAL, 6); | ||||
2672 | ctk_widget_set_valign (progress_vbox, CTK_ALIGN_START); | ||||
2673 | ctk_widget_set_hexpand (progress_vbox, TRUE(!(0))); | ||||
2674 | ctk_widget_set_vexpand (progress_vbox, TRUE(!(0))); | ||||
2675 | ctk_widget_set_margin_bottom (progress_vbox, 6); | ||||
2676 | 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); | ||||
2677 | |||||
2678 | /* progress bar */ | ||||
2679 | |||||
2680 | window->priv->pd_progress_bar = ctk_progress_bar_new (); | ||||
2681 | 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)); | ||||
2682 | 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); | ||||
2683 | |||||
2684 | /* details label */ | ||||
2685 | |||||
2686 | lbl = window->priv->pd_message = ctk_label_new (""); | ||||
2687 | |||||
2688 | attr_list = pango_attr_list_new (); | ||||
2689 | pango_attr_list_insert (attr_list, pango_attr_size_new (9000)); | ||||
2690 | ctk_label_set_attributes (CTK_LABEL (lbl)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((lbl)), ((ctk_label_get_type ())))))), attr_list); | ||||
2691 | pango_attr_list_unref (attr_list); | ||||
2692 | |||||
2693 | ctk_label_set_xalign (CTK_LABEL (lbl)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((lbl)), ((ctk_label_get_type ())))))), 0.0); | ||||
2694 | ctk_label_set_ellipsize (CTK_LABEL (lbl)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((lbl)), ((ctk_label_get_type ())))))), PANGO_ELLIPSIZE_END); | ||||
2695 | 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); | ||||
2696 | |||||
2697 | ctk_widget_show_all (hbox); | ||||
2698 | |||||
2699 | progress_dialog_update_action_description (window); | ||||
2700 | |||||
2701 | /* signals */ | ||||
2702 | |||||
2703 | 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) | ||||
2704 | "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) | ||||
2705 | 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) | ||||
2706 | 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); | ||||
2707 | 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) | ||||
2708 | "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) | ||||
2709 | 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) | ||||
2710 | 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); | ||||
2711 | } | ||||
2712 | |||||
2713 | |||||
2714 | static gboolean | ||||
2715 | display_progress_dialog (gpointer data) | ||||
2716 | { | ||||
2717 | FrWindow *window = data; | ||||
2718 | |||||
2719 | if (window->priv->progress_timeout != 0) | ||||
2720 | g_source_remove (window->priv->progress_timeout); | ||||
2721 | |||||
2722 | if (window->priv->use_progress_dialog && (window->priv->progress_dialog != NULL((void*)0))) { | ||||
2723 | 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 ())))))), | ||||
2724 | CTK_RESPONSE_OK, | ||||
2725 | window->priv->stoppable); | ||||
2726 | if (! window->priv->non_interactive) | ||||
2727 | ctk_widget_show (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | ||||
2728 | ctk_widget_hide (window->priv->progress_bar); | ||||
2729 | ctk_widget_show (window->priv->progress_dialog); | ||||
2730 | fr_window_message_cb (NULL((void*)0), window->priv->pd_last_message, window); | ||||
2731 | } | ||||
2732 | |||||
2733 | window->priv->progress_timeout = 0; | ||||
2734 | |||||
2735 | return FALSE(0); | ||||
2736 | } | ||||
2737 | |||||
2738 | |||||
2739 | static void | ||||
2740 | open_progress_dialog (FrWindow *window, | ||||
2741 | gboolean open_now) | ||||
2742 | { | ||||
2743 | if (window->priv->hide_progress_timeout != 0) { | ||||
2744 | g_source_remove (window->priv->hide_progress_timeout); | ||||
2745 | window->priv->hide_progress_timeout = 0; | ||||
2746 | } | ||||
2747 | |||||
2748 | if (open_now) { | ||||
2749 | if (window->priv->progress_timeout != 0) | ||||
2750 | g_source_remove (window->priv->progress_timeout); | ||||
2751 | window->priv->progress_timeout = 0; | ||||
2752 | } | ||||
2753 | |||||
2754 | if ((window->priv->progress_timeout != 0) | ||||
2755 | || ((window->priv->progress_dialog != NULL((void*)0)) && ctk_widget_get_visible (window->priv->progress_dialog))) | ||||
2756 | return; | ||||
2757 | |||||
2758 | if (! window->priv->batch_mode && ! open_now) | ||||
2759 | ctk_widget_show (window->priv->progress_bar); | ||||
2760 | |||||
2761 | create_the_progress_dialog (window); | ||||
2762 | ctk_widget_show (window->priv->pd_cancel_button); | ||||
2763 | ctk_widget_show (window->priv->pd_state_button); | ||||
2764 | ctk_widget_hide (window->priv->pd_open_archive_button); | ||||
2765 | ctk_widget_hide (window->priv->pd_open_destination_button); | ||||
2766 | ctk_widget_hide (window->priv->pd_open_destination_and_quit_button); | ||||
2767 | ctk_widget_hide (window->priv->pd_quit_button); | ||||
2768 | ctk_widget_hide (window->priv->pd_close_button); | ||||
2769 | |||||
2770 | if (open_now) | ||||
2771 | display_progress_dialog (window); | ||||
2772 | else | ||||
2773 | window->priv->progress_timeout = g_timeout_add (PROGRESS_TIMEOUT_MSECS5000, | ||||
2774 | display_progress_dialog, | ||||
2775 | window); | ||||
2776 | } | ||||
2777 | |||||
2778 | |||||
2779 | static gboolean | ||||
2780 | fr_window_progress_cb (FrArchive *archive, | ||||
2781 | double fraction, | ||||
2782 | FrWindow *window) | ||||
2783 | { | ||||
2784 | window->priv->progress_pulse = (fraction < 0.0); | ||||
2785 | if (! window->priv->progress_pulse) { | ||||
2786 | fraction = CLAMP (fraction, 0.0, 1.0)(((fraction) > (1.0)) ? (1.0) : (((fraction) < (0.0)) ? (0.0) : (fraction))); | ||||
2787 | if (window->priv->progress_dialog != NULL((void*)0)) | ||||
2788 | 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); | ||||
2789 | 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); | ||||
2790 | |||||
2791 | if ((archive != NULL((void*)0)) && (archive->command != NULL((void*)0)) && (archive->command->n_files > 0)) { | ||||
2792 | char *message = NULL((void*)0); | ||||
2793 | int remaining_files; | ||||
2794 | |||||
2795 | remaining_files = archive->command->n_files - archive->command->n_file + 1; | ||||
2796 | |||||
2797 | switch (window->priv->action) { | ||||
2798 | case FR_ACTION_ADDING_FILES: | ||||
2799 | case FR_ACTION_EXTRACTING_FILES: | ||||
2800 | case FR_ACTION_DELETING_FILES: | ||||
2801 | message = g_strdup_printf (ngettext ("%d file remaining", | ||||
2802 | "%d files remaining", | ||||
2803 | remaining_files), remaining_files); | ||||
2804 | break; | ||||
2805 | default: | ||||
2806 | break; | ||||
2807 | } | ||||
2808 | |||||
2809 | if (message != NULL((void*)0)) | ||||
2810 | fr_command_message (archive->command, message); | ||||
2811 | } | ||||
2812 | |||||
2813 | window->priv->pd_last_fraction = fraction; | ||||
2814 | |||||
2815 | g_signal_emit (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2)))))))), | ||||
2816 | fr_window_signals[PROGRESS], | ||||
2817 | 0, | ||||
2818 | window->priv->pd_last_fraction, | ||||
2819 | window->priv->pd_last_message); | ||||
2820 | |||||
2821 | #ifdef LOG_PROGRESS | ||||
2822 | g_print ("progress > %2.2f\n", fraction); | ||||
2823 | #endif | ||||
2824 | } | ||||
2825 | return TRUE(!(0)); | ||||
2826 | } | ||||
2827 | |||||
2828 | |||||
2829 | static void | ||||
2830 | open_progress_dialog_with_open_destination (FrWindow *window) | ||||
2831 | { | ||||
2832 | window->priv->ask_to_open_destination_after_extraction = FALSE(0); | ||||
2833 | |||||
2834 | if (window->priv->hide_progress_timeout != 0) { | ||||
2835 | g_source_remove (window->priv->hide_progress_timeout); | ||||
2836 | window->priv->hide_progress_timeout = 0; | ||||
2837 | } | ||||
2838 | if (window->priv->progress_timeout != 0) { | ||||
2839 | g_source_remove (window->priv->progress_timeout); | ||||
2840 | window->priv->progress_timeout = 0; | ||||
2841 | } | ||||
2842 | |||||
2843 | create_the_progress_dialog (window); | ||||
2844 | ctk_widget_hide (window->priv->pd_cancel_button); | ||||
2845 | ctk_widget_hide (window->priv->pd_state_button); | ||||
2846 | ctk_widget_hide (window->priv->pd_open_archive_button); | ||||
2847 | ctk_widget_show (window->priv->pd_open_destination_button); | ||||
2848 | ctk_widget_show (window->priv->pd_open_destination_and_quit_button); | ||||
2849 | ctk_widget_show (window->priv->pd_quit_button); | ||||
2850 | ctk_widget_show (window->priv->pd_close_button); | ||||
2851 | display_progress_dialog (window); | ||||
2852 | fr_window_progress_cb (NULL((void*)0), 1.0, window); | ||||
2853 | fr_window_message_cb (NULL((void*)0), _("Extraction completed successfully")gettext ("Extraction completed successfully"), window); | ||||
2854 | } | ||||
2855 | |||||
2856 | |||||
2857 | static void | ||||
2858 | open_progress_dialog_with_open_archive (FrWindow *window) | ||||
2859 | { | ||||
2860 | if (window->priv->hide_progress_timeout != 0) { | ||||
2861 | g_source_remove (window->priv->hide_progress_timeout); | ||||
2862 | window->priv->hide_progress_timeout = 0; | ||||
2863 | } | ||||
2864 | if (window->priv->progress_timeout != 0) { | ||||
2865 | g_source_remove (window->priv->progress_timeout); | ||||
2866 | window->priv->progress_timeout = 0; | ||||
2867 | } | ||||
2868 | |||||
2869 | create_the_progress_dialog (window); | ||||
2870 | ctk_widget_hide (window->priv->pd_cancel_button); | ||||
2871 | ctk_widget_hide (window->priv->pd_state_button); | ||||
2872 | ctk_widget_hide (window->priv->pd_open_destination_button); | ||||
2873 | ctk_widget_hide (window->priv->pd_open_destination_and_quit_button); | ||||
2874 | ctk_widget_show (window->priv->pd_open_archive_button); | ||||
2875 | ctk_widget_show (window->priv->pd_close_button); | ||||
2876 | display_progress_dialog (window); | ||||
2877 | fr_window_progress_cb (NULL((void*)0), 1.0, window); | ||||
2878 | fr_window_message_cb (NULL((void*)0), _("Archive created successfully")gettext ("Archive created successfully"), window); | ||||
2879 | } | ||||
2880 | |||||
2881 | |||||
2882 | void | ||||
2883 | fr_window_push_message (FrWindow *window, | ||||
2884 | const char *msg) | ||||
2885 | { | ||||
2886 | if (! ctk_widget_get_mapped (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))) | ||||
2887 | return; | ||||
2888 | |||||
2889 | ctk_statusbar_push (CTK_STATUSBAR (window->priv->statusbar)((((CtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->statusbar)), ((ctk_statusbar_get_type ())))))), | ||||
2890 | window->priv->progress_cid, | ||||
2891 | msg); | ||||
2892 | } | ||||
2893 | |||||
2894 | |||||
2895 | void | ||||
2896 | fr_window_pop_message (FrWindow *window) | ||||
2897 | { | ||||
2898 | if (! ctk_widget_get_mapped (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))) | ||||
2899 | return; | ||||
2900 | 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); | ||||
2901 | if (window->priv->progress_dialog != NULL((void*)0)) | ||||
2902 | 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 ( ))))))), ""); | ||||
2903 | } | ||||
2904 | |||||
2905 | |||||
2906 | static void | ||||
2907 | action_started (FrArchive *archive, | ||||
2908 | FrAction action, | ||||
2909 | gpointer data) | ||||
2910 | { | ||||
2911 | FrWindow *window = data; | ||||
2912 | char *message; | ||||
2913 | |||||
2914 | window->priv->action = action; | ||||
2915 | fr_window_start_activity_mode (window); | ||||
2916 | |||||
2917 | #ifdef CAFE_ENABLE_DEBUG | ||||
2918 | debug (DEBUG_INFO"fr-window.c", 2918, __FUNCTION__, "%s [START] (FR::Window)\n", get_action_name (action)); | ||||
2919 | #endif | ||||
2920 | |||||
2921 | message = get_action_description (action, window->priv->pd_last_archive); | ||||
2922 | fr_window_push_message (window, message); | ||||
2923 | g_free (message); | ||||
2924 | |||||
2925 | switch (action) { | ||||
2926 | case FR_ACTION_EXTRACTING_FILES: | ||||
2927 | open_progress_dialog (window, window->priv->ask_to_open_destination_after_extraction || window->priv->convert_data.converting || window->priv->batch_mode); | ||||
2928 | break; | ||||
2929 | default: | ||||
2930 | open_progress_dialog (window, window->priv->batch_mode); | ||||
2931 | break; | ||||
2932 | } | ||||
2933 | |||||
2934 | if (archive->command != NULL((void*)0)) { | ||||
2935 | fr_command_progress (archive->command, -1.0); | ||||
2936 | fr_command_message (archive->command, _("Please wait…")gettext ("Please wait…")); | ||||
2937 | } | ||||
2938 | } | ||||
2939 | |||||
2940 | |||||
2941 | static void | ||||
2942 | fr_window_add_to_recent_list (FrWindow *window, | ||||
2943 | char *uri) | ||||
2944 | { | ||||
2945 | if (window->priv->batch_mode) | ||||
2946 | return; | ||||
2947 | |||||
2948 | if (is_temp_dir (uri)) | ||||
2949 | return; | ||||
2950 | |||||
2951 | if (window->archive->content_type != NULL((void*)0)) { | ||||
2952 | CtkRecentData *recent_data; | ||||
2953 | |||||
2954 | recent_data = g_new0 (CtkRecentData, 1)((CtkRecentData *) g_malloc0_n ((1), sizeof (CtkRecentData))); | ||||
2955 | recent_data->mime_type = g_content_type_get_mime_type (window->archive->content_type); | ||||
2956 | recent_data->app_name = "Grapa"; | ||||
2957 | recent_data->app_exec = "grapa"; | ||||
2958 | ctk_recent_manager_add_full (ctk_recent_manager_get_default (), uri, recent_data); | ||||
2959 | |||||
2960 | g_free (recent_data); | ||||
2961 | } | ||||
2962 | else | ||||
2963 | ctk_recent_manager_add_item (ctk_recent_manager_get_default (), uri); | ||||
2964 | } | ||||
2965 | |||||
2966 | |||||
2967 | static void | ||||
2968 | fr_window_remove_from_recent_list (FrWindow *window, | ||||
2969 | char *filename) | ||||
2970 | { | ||||
2971 | if (filename != NULL((void*)0)) | ||||
2972 | ctk_recent_manager_remove_item (ctk_recent_manager_get_default (), filename, NULL((void*)0)); | ||||
2973 | } | ||||
2974 | |||||
2975 | |||||
2976 | static void | ||||
2977 | error_dialog_response_cb (CtkDialog *dialog, | ||||
2978 | gint arg1, | ||||
2979 | gpointer user_data) | ||||
2980 | { | ||||
2981 | FrWindow *window = user_data; | ||||
2982 | CtkWindow *dialog_parent = window->priv->error_dialog_parent; | ||||
2983 | |||||
2984 | window->priv->showing_error_dialog = FALSE(0); | ||||
2985 | window->priv->error_dialog_parent = NULL((void*)0); | ||||
2986 | |||||
2987 | 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)) | ||||
2988 | ctk_window_set_modal (dialog_parent, TRUE(!(0))); | ||||
2989 | ctk_widget_destroy (CTK_WIDGET (dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_widget_get_type ()))))))); | ||||
2990 | |||||
2991 | if (window->priv->destroy_with_error_dialog) | ||||
2992 | ctk_widget_destroy (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | ||||
2993 | } | ||||
2994 | |||||
2995 | |||||
2996 | static void | ||||
2997 | fr_window_show_error_dialog (FrWindow *window, | ||||
2998 | CtkWidget *dialog, | ||||
2999 | CtkWindow *dialog_parent, | ||||
3000 | const char *details) | ||||
3001 | { | ||||
3002 | if (window->priv->batch_mode && ! window->priv->use_progress_dialog) { | ||||
3003 | GError *error; | ||||
3004 | |||||
3005 | error = g_error_new_literal (FR_ERRORfr_error_quark (), FR_PROC_ERROR_GENERIC, details ? details : _("Command exited abnormally.")gettext ("Command exited abnormally.")); | ||||
3006 | g_signal_emit (window, | ||||
3007 | fr_window_signals[READY], | ||||
3008 | 0, | ||||
3009 | error); | ||||
3010 | |||||
3011 | ctk_widget_destroy (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | ||||
3012 | |||||
3013 | return; | ||||
3014 | } | ||||
3015 | |||||
3016 | close_progress_dialog (window, TRUE(!(0))); | ||||
3017 | |||||
3018 | if (window->priv->batch_mode) | ||||
3019 | fr_window_destroy_with_error_dialog (window); | ||||
3020 | |||||
3021 | if (dialog_parent != NULL((void*)0)) | ||||
3022 | ctk_window_set_modal (dialog_parent, FALSE(0)); | ||||
3023 | g_signal_connect (dialog,g_signal_connect_data ((dialog), ("response"), (((GCallback) ( error_dialog_response_cb))), (window), ((void*)0), (GConnectFlags ) 0) | ||||
3024 | "response",g_signal_connect_data ((dialog), ("response"), (((GCallback) ( error_dialog_response_cb))), (window), ((void*)0), (GConnectFlags ) 0) | ||||
3025 | G_CALLBACK (error_dialog_response_cb),g_signal_connect_data ((dialog), ("response"), (((GCallback) ( error_dialog_response_cb))), (window), ((void*)0), (GConnectFlags ) 0) | ||||
3026 | window)g_signal_connect_data ((dialog), ("response"), (((GCallback) ( error_dialog_response_cb))), (window), ((void*)0), (GConnectFlags ) 0); | ||||
3027 | ctk_window_set_modal (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), TRUE(!(0))); | ||||
3028 | ctk_widget_show (dialog); | ||||
3029 | |||||
3030 | window->priv->showing_error_dialog = TRUE(!(0)); | ||||
3031 | window->priv->error_dialog_parent = dialog_parent; | ||||
3032 | } | ||||
3033 | |||||
3034 | |||||
3035 | void | ||||
3036 | fr_window_destroy_with_error_dialog (FrWindow *window) | ||||
3037 | { | ||||
3038 | window->priv->destroy_with_error_dialog = TRUE(!(0)); | ||||
3039 | } | ||||
3040 | |||||
3041 | |||||
3042 | static gboolean | ||||
3043 | handle_errors (FrWindow *window, | ||||
3044 | FrArchive *archive, | ||||
3045 | FrAction action, | ||||
3046 | FrProcError *error) | ||||
3047 | { | ||||
3048 | if (error->type == FR_PROC_ERROR_ASK_PASSWORD) { | ||||
3049 | close_progress_dialog (window, TRUE(!(0))); | ||||
3050 | dlg_ask_password (window); | ||||
3051 | return FALSE(0); | ||||
3052 | } | ||||
3053 | else if (error->type == FR_PROC_ERROR_UNSUPPORTED_FORMAT) { | ||||
3054 | close_progress_dialog (window, TRUE(!(0))); | ||||
3055 | dlg_package_installer (window, archive, action); | ||||
3056 | return FALSE(0); | ||||
3057 | } | ||||
3058 | #if 0 | ||||
3059 | else if (error->type == FR_PROC_ERROR_BAD_CHARSET) { | ||||
3060 | close_progress_dialog (window, TRUE(!(0))); | ||||
3061 | /* dlg_ask_archive_charset (window); FIXME: implement after feature freeze */ | ||||
3062 | return FALSE(0); | ||||
3063 | } | ||||
3064 | #endif | ||||
3065 | else if (error->type == FR_PROC_ERROR_STOPPED) { | ||||
3066 | /* nothing */ | ||||
3067 | } | ||||
3068 | else if (error->type != FR_PROC_ERROR_NONE) { | ||||
3069 | char *msg = NULL((void*)0); | ||||
3070 | char *utf8_name; | ||||
3071 | char *details = NULL((void*)0); | ||||
3072 | CtkWindow *dialog_parent; | ||||
3073 | CtkWidget *dialog; | ||||
3074 | FrProcess *process = archive->process; | ||||
3075 | GList *output = NULL((void*)0); | ||||
3076 | |||||
3077 | if (window->priv->batch_mode) { | ||||
3078 | dialog_parent = NULL((void*)0); | ||||
3079 | window->priv->load_error_parent_window = NULL((void*)0); | ||||
3080 | } | ||||
3081 | else { | ||||
3082 | dialog_parent = (CtkWindow *) window; | ||||
3083 | if (window->priv->load_error_parent_window == NULL((void*)0)) | ||||
3084 | window->priv->load_error_parent_window = (CtkWindow *) window; | ||||
3085 | } | ||||
3086 | |||||
3087 | if ((action == FR_ACTION_LISTING_CONTENT) || (action == FR_ACTION_LOADING_ARCHIVE)) | ||||
3088 | fr_window_archive_close (window); | ||||
3089 | |||||
3090 | switch (action) { | ||||
3091 | case FR_ACTION_CREATING_NEW_ARCHIVE: | ||||
3092 | dialog_parent = window->priv->load_error_parent_window; | ||||
3093 | msg = _("Could not create the archive")gettext ("Could not create the archive"); | ||||
3094 | break; | ||||
3095 | |||||
3096 | case FR_ACTION_EXTRACTING_FILES: | ||||
3097 | case FR_ACTION_COPYING_FILES_TO_REMOTE: | ||||
3098 | msg = _("An error occurred while extracting files.")gettext ("An error occurred while extracting files."); | ||||
3099 | break; | ||||
3100 | |||||
3101 | case FR_ACTION_LOADING_ARCHIVE: | ||||
3102 | dialog_parent = window->priv->load_error_parent_window; | ||||
3103 | utf8_name = g_uri_display_basename (window->priv->archive_uri); | ||||
3104 | msg = g_strdup_printf (_("Could not open \"%s\"")gettext ("Could not open \"%s\""), utf8_name); | ||||
3105 | g_free (utf8_name); | ||||
3106 | break; | ||||
3107 | |||||
3108 | case FR_ACTION_LISTING_CONTENT: | ||||
3109 | msg = _("An error occurred while loading the archive.")gettext ("An error occurred while loading the archive."); | ||||
3110 | break; | ||||
3111 | |||||
3112 | case FR_ACTION_DELETING_FILES: | ||||
3113 | msg = _("An error occurred while deleting files from the archive.")gettext ("An error occurred while deleting files from the archive." ); | ||||
3114 | break; | ||||
3115 | |||||
3116 | case FR_ACTION_ADDING_FILES: | ||||
3117 | case FR_ACTION_GETTING_FILE_LIST: | ||||
3118 | case FR_ACTION_COPYING_FILES_FROM_REMOTE: | ||||
3119 | msg = _("An error occurred while adding files to the archive.")gettext ("An error occurred while adding files to the archive." ); | ||||
3120 | break; | ||||
3121 | |||||
3122 | case FR_ACTION_TESTING_ARCHIVE: | ||||
3123 | msg = _("An error occurred while testing archive.")gettext ("An error occurred while testing archive."); | ||||
3124 | break; | ||||
3125 | |||||
3126 | case FR_ACTION_SAVING_REMOTE_ARCHIVE: | ||||
3127 | msg = _("An error occurred while saving the archive.")gettext ("An error occurred while saving the archive."); | ||||
3128 | break; | ||||
3129 | |||||
3130 | default: | ||||
3131 | msg = _("An error occurred.")gettext ("An error occurred."); | ||||
3132 | break; | ||||
3133 | } | ||||
3134 | |||||
3135 | switch (error->type) { | ||||
3136 | case FR_PROC_ERROR_COMMAND_NOT_FOUND: | ||||
3137 | details = _("Command not found.")gettext ("Command not found."); | ||||
3138 | break; | ||||
3139 | case FR_PROC_ERROR_EXITED_ABNORMALLY: | ||||
3140 | details = _("Command exited abnormally.")gettext ("Command exited abnormally."); | ||||
3141 | break; | ||||
3142 | case FR_PROC_ERROR_SPAWN: | ||||
3143 | details = error->gerror->message; | ||||
3144 | break; | ||||
3145 | default: | ||||
3146 | if (error->gerror != NULL((void*)0)) | ||||
3147 | details = error->gerror->message; | ||||
3148 | else | ||||
3149 | details = NULL((void*)0); | ||||
3150 | break; | ||||
3151 | } | ||||
3152 | |||||
3153 | if (error->type != FR_PROC_ERROR_GENERIC) | ||||
3154 | output = (process->err.raw != NULL((void*)0)) ? process->err.raw : process->out.raw; | ||||
3155 | |||||
3156 | dialog = _ctk_error_dialog_new (dialog_parent, | ||||
3157 | 0, | ||||
3158 | output, | ||||
3159 | msg, | ||||
3160 | ((details != NULL((void*)0)) ? "%s" : NULL((void*)0)), | ||||
3161 | details); | ||||
3162 | fr_window_show_error_dialog (window, dialog, dialog_parent, details); | ||||
3163 | |||||
3164 | return FALSE(0); | ||||
3165 | } | ||||
3166 | |||||
3167 | return TRUE(!(0)); | ||||
3168 | } | ||||
3169 | |||||
3170 | |||||
3171 | static void | ||||
3172 | convert__action_performed (FrArchive *archive, | ||||
3173 | FrAction action, | ||||
3174 | FrProcError *error, | ||||
3175 | gpointer data) | ||||
3176 | { | ||||
3177 | FrWindow *window = data; | ||||
3178 | |||||
3179 | #ifdef CAFE_ENABLE_DEBUG | ||||
3180 | debug (DEBUG_INFO"fr-window.c", 3180, __FUNCTION__, "%s [CONVERT::DONE] (FR::Window)\n", get_action_name (action)); | ||||
3181 | #endif | ||||
3182 | |||||
3183 | if ((action == FR_ACTION_GETTING_FILE_LIST) || (action == FR_ACTION_ADDING_FILES)) { | ||||
3184 | fr_window_stop_activity_mode (window); | ||||
3185 | fr_window_pop_message (window); | ||||
3186 | close_progress_dialog (window, FALSE(0)); | ||||
3187 | } | ||||
3188 | |||||
3189 | if (action != FR_ACTION_ADDING_FILES) | ||||
3190 | return; | ||||
3191 | |||||
3192 | handle_errors (window, archive, action, error); | ||||
3193 | |||||
3194 | if (error->type == FR_PROC_ERROR_NONE) | ||||
3195 | open_progress_dialog_with_open_archive (window); | ||||
3196 | |||||
3197 | remove_local_directory (window->priv->convert_data.temp_dir); | ||||
3198 | fr_window_convert_data_free (window, FALSE(0)); | ||||
3199 | |||||
3200 | fr_window_update_sensitivity (window); | ||||
3201 | fr_window_update_statusbar_list_info (window); | ||||
3202 | } | ||||
3203 | |||||
3204 | |||||
3205 | static void fr_window_exec_next_batch_action (FrWindow *window); | ||||
3206 | |||||
3207 | |||||
3208 | static void | ||||
3209 | action_performed (FrArchive *archive, | ||||
3210 | FrAction action, | ||||
3211 | FrProcError *error, | ||||
3212 | gpointer data) | ||||
3213 | { | ||||
3214 | FrWindow *window = data; | ||||
3215 | gboolean continue_batch = FALSE(0); | ||||
3216 | char *archive_dir; | ||||
3217 | gboolean temp_dir; | ||||
3218 | |||||
3219 | #ifdef CAFE_ENABLE_DEBUG | ||||
3220 | debug (DEBUG_INFO"fr-window.c", 3220, __FUNCTION__, "%s [DONE] (FR::Window)\n", get_action_name (action)); | ||||
3221 | #endif | ||||
3222 | |||||
3223 | fr_window_stop_activity_mode (window); | ||||
3224 | fr_window_pop_message (window); | ||||
3225 | |||||
3226 | continue_batch = handle_errors (window, archive, action, error); | ||||
3227 | |||||
3228 | if ((error->type == FR_PROC_ERROR_ASK_PASSWORD) | ||||
3229 | || (error->type == FR_PROC_ERROR_UNSUPPORTED_FORMAT) | ||||
3230 | /*|| (error->type == FR_PROC_ERROR_BAD_CHARSET)*/) | ||||
3231 | { | ||||
3232 | return; | ||||
3233 | } | ||||
3234 | |||||
3235 | switch (action) { | ||||
3236 | case FR_ACTION_CREATING_NEW_ARCHIVE: | ||||
3237 | case FR_ACTION_CREATING_ARCHIVE: | ||||
3238 | close_progress_dialog (window, FALSE(0)); | ||||
3239 | if (error->type != FR_PROC_ERROR_STOPPED) { | ||||
3240 | fr_window_history_clear (window); | ||||
3241 | fr_window_go_to_location (window, "/", TRUE(!(0))); | ||||
3242 | fr_window_update_dir_tree (window); | ||||
3243 | fr_window_update_title (window); | ||||
3244 | fr_window_update_sensitivity (window); | ||||
3245 | } | ||||
3246 | break; | ||||
3247 | |||||
3248 | case FR_ACTION_LOADING_ARCHIVE: | ||||
3249 | close_progress_dialog (window, FALSE(0)); | ||||
3250 | if (error->type != FR_PROC_ERROR_NONE) { | ||||
3251 | fr_window_remove_from_recent_list (window, window->priv->archive_uri); | ||||
3252 | if (window->priv->non_interactive) { | ||||
3253 | fr_window_archive_close (window); | ||||
3254 | fr_window_stop_batch (window); | ||||
3255 | } | ||||
3256 | } | ||||
3257 | else { | ||||
3258 | fr_window_add_to_recent_list (window, window->priv->archive_uri); | ||||
3259 | if (! window->priv->non_interactive) | ||||
3260 | ctk_window_present (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ()))))))); | ||||
3261 | } | ||||
3262 | continue_batch = FALSE(0); | ||||
3263 | g_signal_emit (window, | ||||
3264 | fr_window_signals[ARCHIVE_LOADED], | ||||
3265 | 0, | ||||
3266 | error->type == FR_PROC_ERROR_NONE); | ||||
3267 | break; | ||||
3268 | |||||
3269 | case FR_ACTION_LISTING_CONTENT: | ||||
3270 | /* update the uri because multi-volume archives can have | ||||
3271 | * a different name after loading. */ | ||||
3272 | g_free (window->priv->archive_uri); | ||||
3273 | window->priv->archive_uri = g_file_get_uri (window->archive->file); | ||||
3274 | |||||
3275 | close_progress_dialog (window, FALSE(0)); | ||||
3276 | if (error->type != FR_PROC_ERROR_NONE) { | ||||
3277 | fr_window_remove_from_recent_list (window, window->priv->archive_uri); | ||||
3278 | fr_window_archive_close (window); | ||||
3279 | fr_window_set_password (window, NULL((void*)0)); | ||||
3280 | break; | ||||
3281 | } | ||||
3282 | |||||
3283 | archive_dir = remove_level_from_path (window->priv->archive_uri); | ||||
3284 | temp_dir = is_temp_dir (archive_dir); | ||||
3285 | if (! window->priv->archive_present) { | ||||
3286 | window->priv->archive_present = TRUE(!(0)); | ||||
3287 | |||||
3288 | fr_window_history_clear (window); | ||||
3289 | fr_window_history_add (window, "/"); | ||||
3290 | |||||
3291 | if (! temp_dir) { | ||||
3292 | fr_window_set_open_default_dir (window, archive_dir); | ||||
3293 | fr_window_set_add_default_dir (window, archive_dir); | ||||
3294 | if (! window->priv->freeze_default_dir) | ||||
3295 | fr_window_set_extract_default_dir (window, archive_dir, FALSE(0)); | ||||
3296 | } | ||||
3297 | |||||
3298 | window->priv->archive_new = FALSE(0); | ||||
3299 | } | ||||
3300 | g_free (archive_dir); | ||||
3301 | |||||
3302 | if (! temp_dir) | ||||
3303 | fr_window_add_to_recent_list (window, window->priv->archive_uri); | ||||
3304 | |||||
3305 | fr_window_update_title (window); | ||||
3306 | fr_window_go_to_location (window, fr_window_get_current_location (window), TRUE(!(0))); | ||||
3307 | fr_window_update_dir_tree (window); | ||||
3308 | if (! window->priv->batch_mode && window->priv->non_interactive) | ||||
3309 | ctk_window_present (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ()))))))); | ||||
3310 | break; | ||||
3311 | |||||
3312 | case FR_ACTION_DELETING_FILES: | ||||
3313 | close_progress_dialog (window, FALSE(0)); | ||||
3314 | if (error->type != FR_PROC_ERROR_STOPPED) | ||||
3315 | fr_window_archive_reload (window); | ||||
3316 | return; | ||||
3317 | |||||
3318 | case FR_ACTION_ADDING_FILES: | ||||
3319 | if (ctk_widget_get_visible (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))) == FALSE(0)) | ||||
3320 | show_notification (window); | ||||
3321 | |||||
3322 | close_progress_dialog (window, FALSE(0)); | ||||
3323 | |||||
3324 | /* update the uri because multi-volume archives can have | ||||
3325 | * a different name after creation. */ | ||||
3326 | g_free (window->priv->archive_uri); | ||||
3327 | window->priv->archive_uri = g_file_get_uri (window->archive->file); | ||||
3328 | |||||
3329 | if (error->type == FR_PROC_ERROR_NONE) { | ||||
3330 | if (window->priv->archive_new) | ||||
3331 | window->priv->archive_new = FALSE(0); | ||||
3332 | fr_window_add_to_recent_list (window, window->priv->archive_uri); | ||||
3333 | } | ||||
3334 | if (! window->priv->batch_mode && (error->type != FR_PROC_ERROR_STOPPED)) { | ||||
3335 | fr_window_archive_reload (window); | ||||
3336 | return; | ||||
3337 | } | ||||
3338 | break; | ||||
3339 | |||||
3340 | case FR_ACTION_TESTING_ARCHIVE: | ||||
3341 | close_progress_dialog (window, FALSE(0)); | ||||
3342 | if (error->type == FR_PROC_ERROR_NONE) | ||||
3343 | fr_window_view_last_output (window, _("Test Result")gettext ("Test Result")); | ||||
3344 | return; | ||||
3345 | |||||
3346 | case FR_ACTION_EXTRACTING_FILES: | ||||
3347 | if (error->type != FR_PROC_ERROR_NONE) { | ||||
3348 | if (window->priv->convert_data.converting) { | ||||
3349 | remove_local_directory (window->priv->convert_data.temp_dir); | ||||
3350 | fr_window_convert_data_free (window, TRUE(!(0))); | ||||
3351 | } | ||||
3352 | break; | ||||
3353 | } | ||||
3354 | if (window->priv->convert_data.converting) { | ||||
3355 | char *source_dir; | ||||
3356 | |||||
3357 | source_dir = g_filename_to_uri (window->priv->convert_data.temp_dir, NULL((void*)0), NULL((void*)0)); | ||||
3358 | fr_archive_add_with_wildcard ( | ||||
3359 | window->priv->convert_data.new_archive, | ||||
3360 | "*", | ||||
3361 | NULL((void*)0), | ||||
3362 | NULL((void*)0), | ||||
3363 | source_dir, | ||||
3364 | NULL((void*)0), | ||||
3365 | FALSE(0), | ||||
3366 | TRUE(!(0)), | ||||
3367 | window->priv->convert_data.password, | ||||
3368 | window->priv->convert_data.encrypt_header, | ||||
3369 | window->priv->compression, | ||||
3370 | window->priv->convert_data.volume_size); | ||||
3371 | g_free (source_dir); | ||||
3372 | } | ||||
3373 | else { | ||||
3374 | if ((window->priv->ask_to_open_destination_after_extraction) && (window->priv->drag_destination_folder == NULL((void*)0))) { | ||||
3375 | open_progress_dialog_with_open_destination (window); | ||||
3376 | show_notification (window); | ||||
3377 | } | ||||
3378 | else { | ||||
3379 | if (ctk_widget_get_visible (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))) == FALSE(0)) | ||||
3380 | show_notification (window); | ||||
3381 | |||||
3382 | close_progress_dialog (window, FALSE(0)); | ||||
3383 | |||||
3384 | if (window->priv->drag_destination_folder) { | ||||
3385 | g_free (window->priv->drag_destination_folder); | ||||
3386 | window->priv->drag_destination_folder = NULL((void*)0); | ||||
3387 | } | ||||
3388 | } | ||||
3389 | } | ||||
3390 | break; | ||||
3391 | |||||
3392 | default: | ||||
3393 | close_progress_dialog (window, FALSE(0)); | ||||
3394 | continue_batch = FALSE(0); | ||||
3395 | break; | ||||
3396 | } | ||||
3397 | |||||
3398 | if (window->priv->batch_action == NULL((void*)0)) { | ||||
3399 | fr_window_update_sensitivity (window); | ||||
3400 | fr_window_update_statusbar_list_info (window); | ||||
3401 | } | ||||
3402 | |||||
3403 | if (continue_batch) { | ||||
3404 | if (error->type != FR_PROC_ERROR_NONE) | ||||
3405 | fr_window_stop_batch (window); | ||||
3406 | else | ||||
3407 | fr_window_exec_next_batch_action (window); | ||||
3408 | } | ||||
3409 | } | ||||
3410 | |||||
3411 | |||||
3412 | /* -- selections -- */ | ||||
3413 | |||||
3414 | |||||
3415 | #undef DEBUG_GET_DIR_LIST_FROM_PATH | ||||
3416 | |||||
3417 | |||||
3418 | static GList * | ||||
3419 | get_dir_list_from_path (FrWindow *window, | ||||
3420 | char *path) | ||||
3421 | { | ||||
3422 | char *dirname; | ||||
3423 | int dirname_l; | ||||
3424 | GList *list = NULL((void*)0); | ||||
3425 | guint i; | ||||
3426 | |||||
3427 | if (path[strlen (path) - 1] != '/') | ||||
3428 | dirname = g_strconcat (path, "/", NULL((void*)0)); | ||||
3429 | else | ||||
3430 | dirname = g_strdup (path)g_strdup_inline (path); | ||||
3431 | dirname_l = strlen (dirname); | ||||
3432 | for (i = 0; i < window->archive->command->files->len; i++) { | ||||
3433 | FileData *fd = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i]; | ||||
3434 | gboolean matches = FALSE(0); | ||||
3435 | |||||
3436 | #ifdef DEBUG_GET_DIR_LIST_FROM_PATH | ||||
3437 | g_print ("%s <=> %s (%d)\n", dirname, fd->full_path, dirname_l); | ||||
3438 | #endif | ||||
3439 | |||||
3440 | if (fd->dir) { | ||||
3441 | int full_path_l = strlen (fd->full_path); | ||||
3442 | if ((full_path_l == dirname_l - 1) && (strncmp (dirname, fd->full_path, full_path_l) == 0)) | ||||
3443 | /* example: dirname is '/path/to/dir/' and fd->full_path is '/path/to/dir' */ | ||||
3444 | matches = TRUE(!(0)); | ||||
3445 | else if (strcmp (dirname, fd->full_path) == 0) | ||||
3446 | matches = TRUE(!(0)); | ||||
3447 | } | ||||
3448 | |||||
3449 | if (! matches && strncmp (dirname, fd->full_path, dirname_l) == 0) { | ||||
3450 | matches = TRUE(!(0)); | ||||
3451 | } | ||||
3452 | |||||
3453 | if (matches) { | ||||
3454 | #ifdef DEBUG_GET_DIR_LIST_FROM_PATH | ||||
3455 | g_print ("`-> OK\n"); | ||||
3456 | #endif | ||||
3457 | list = g_list_prepend (list, g_strdup (fd->original_path)g_strdup_inline (fd->original_path)); | ||||
3458 | } | ||||
3459 | } | ||||
3460 | g_free (dirname); | ||||
3461 | |||||
3462 | return g_list_reverse (list); | ||||
3463 | } | ||||
3464 | |||||
3465 | |||||
3466 | static GList * | ||||
3467 | get_dir_list_from_file_data (FrWindow *window, | ||||
3468 | FileData *fdata) | ||||
3469 | { | ||||
3470 | char *dirname; | ||||
3471 | GList *list; | ||||
3472 | |||||
3473 | dirname = g_strconcat (fr_window_get_current_location (window), | ||||
3474 | fdata->list_name, | ||||
3475 | NULL((void*)0)); | ||||
3476 | list = get_dir_list_from_path (window, dirname); | ||||
3477 | g_free (dirname); | ||||
3478 | |||||
3479 | return list; | ||||
3480 | } | ||||
3481 | |||||
3482 | |||||
3483 | GList * | ||||
3484 | fr_window_get_file_list_selection (FrWindow *window, | ||||
3485 | gboolean recursive, | ||||
3486 | gboolean *has_dirs) | ||||
3487 | { | ||||
3488 | CtkTreeSelection *selection; | ||||
3489 | GList *selections = NULL((void*)0), *list, *scan; | ||||
3490 | |||||
3491 | 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); | ||||
3492 | |||||
3493 | if (has_dirs != NULL((void*)0)) | ||||
3494 | *has_dirs = FALSE(0); | ||||
3495 | |||||
3496 | 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 ()))))))); | ||||
3497 | if (selection == NULL((void*)0)) | ||||
3498 | return NULL((void*)0); | ||||
3499 | ctk_tree_selection_selected_foreach (selection, add_selected_from_list_view, &selections); | ||||
3500 | |||||
3501 | list = NULL((void*)0); | ||||
3502 | for (scan = selections; scan; scan = scan->next) { | ||||
3503 | FileData *fd = scan->data; | ||||
3504 | |||||
3505 | if (!fd) | ||||
3506 | continue; | ||||
3507 | |||||
3508 | if (file_data_is_dir (fd)) { | ||||
3509 | if (has_dirs != NULL((void*)0)) | ||||
3510 | *has_dirs = TRUE(!(0)); | ||||
3511 | |||||
3512 | if (recursive) | ||||
3513 | list = g_list_concat (list, get_dir_list_from_file_data (window, fd)); | ||||
3514 | } | ||||
3515 | else | ||||
3516 | list = g_list_prepend (list, g_strdup (fd->original_path)g_strdup_inline (fd->original_path)); | ||||
3517 | } | ||||
3518 | if (selections) | ||||
3519 | g_list_free (selections); | ||||
3520 | |||||
3521 | return g_list_reverse (list); | ||||
3522 | } | ||||
3523 | |||||
3524 | |||||
3525 | GList * | ||||
3526 | fr_window_get_folder_tree_selection (FrWindow *window, | ||||
3527 | gboolean recursive, | ||||
3528 | gboolean *has_dirs) | ||||
3529 | { | ||||
3530 | CtkTreeSelection *tree_selection; | ||||
3531 | GList *selections, *list, *scan; | ||||
3532 | |||||
3533 | 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); | ||||
3534 | |||||
3535 | if (has_dirs != NULL((void*)0)) | ||||
3536 | *has_dirs = FALSE(0); | ||||
3537 | |||||
3538 | 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 ()))))))); | ||||
3539 | if (tree_selection == NULL((void*)0)) | ||||
3540 | return NULL((void*)0); | ||||
3541 | |||||
3542 | selections = NULL((void*)0); | ||||
3543 | ctk_tree_selection_selected_foreach (tree_selection, add_selected_from_tree_view, &selections); | ||||
3544 | if (selections == NULL((void*)0)) | ||||
3545 | return NULL((void*)0); | ||||
3546 | |||||
3547 | if (has_dirs != NULL((void*)0)) | ||||
3548 | *has_dirs = TRUE(!(0)); | ||||
3549 | |||||
3550 | list = NULL((void*)0); | ||||
3551 | for (scan = selections; scan; scan = scan->next) { | ||||
3552 | char *path = scan->data; | ||||
3553 | |||||
3554 | if (recursive) | ||||
3555 | list = g_list_concat (list, get_dir_list_from_path (window, path)); | ||||
3556 | } | ||||
3557 | path_list_free (selections); | ||||
3558 | |||||
3559 | return g_list_reverse (list); | ||||
3560 | } | ||||
3561 | |||||
3562 | |||||
3563 | GList * | ||||
3564 | fr_window_get_file_list_from_path_list (FrWindow *window, | ||||
3565 | GList *path_list, | ||||
3566 | gboolean *has_dirs) | ||||
3567 | { | ||||
3568 | CtkTreeModel *model; | ||||
3569 | GList *selections, *list, *scan; | ||||
3570 | |||||
3571 | 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); | ||||
3572 | |||||
3573 | 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 ())))))); | ||||
3574 | selections = NULL((void*)0); | ||||
3575 | |||||
3576 | if (has_dirs != NULL((void*)0)) | ||||
3577 | *has_dirs = FALSE(0); | ||||
3578 | |||||
3579 | for (scan = path_list; scan; scan = scan->next) { | ||||
3580 | CtkTreeRowReference *reference = scan->data; | ||||
3581 | CtkTreePath *path; | ||||
3582 | CtkTreeIter iter; | ||||
3583 | FileData *fdata; | ||||
3584 | |||||
3585 | path = ctk_tree_row_reference_get_path (reference); | ||||
3586 | if (path == NULL((void*)0)) | ||||
3587 | continue; | ||||
3588 | |||||
3589 | if (! ctk_tree_model_get_iter (model, &iter, path)) | ||||
3590 | continue; | ||||
3591 | |||||
3592 | ctk_tree_model_get (model, &iter, | ||||
3593 | COLUMN_FILE_DATA, &fdata, | ||||
3594 | -1); | ||||
3595 | |||||
3596 | selections = g_list_prepend (selections, fdata); | ||||
3597 | } | ||||
3598 | |||||
3599 | list = NULL((void*)0); | ||||
3600 | for (scan = selections; scan; scan = scan->next) { | ||||
3601 | FileData *fd = scan->data; | ||||
3602 | |||||
3603 | if (!fd) | ||||
3604 | continue; | ||||
3605 | |||||
3606 | if (file_data_is_dir (fd)) { | ||||
3607 | if (has_dirs != NULL((void*)0)) | ||||
3608 | *has_dirs = TRUE(!(0)); | ||||
3609 | list = g_list_concat (list, get_dir_list_from_file_data (window, fd)); | ||||
3610 | } | ||||
3611 | else | ||||
3612 | list = g_list_prepend (list, g_strdup (fd->original_path)g_strdup_inline (fd->original_path)); | ||||
3613 | } | ||||
3614 | |||||
3615 | if (selections != NULL((void*)0)) | ||||
3616 | g_list_free (selections); | ||||
3617 | |||||
3618 | return g_list_reverse (list); | ||||
3619 | } | ||||
3620 | |||||
3621 | |||||
3622 | GList * | ||||
3623 | fr_window_get_file_list_pattern (FrWindow *window, | ||||
3624 | const char *pattern) | ||||
3625 | { | ||||
3626 | GRegex **regexps; | ||||
3627 | GList *list; | ||||
3628 | guint i; | ||||
3629 | |||||
3630 | 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); | ||||
3631 | |||||
3632 | regexps = search_util_get_regexps (pattern, G_REGEX_CASELESS); | ||||
3633 | list = NULL((void*)0); | ||||
3634 | for (i = 0; i < window->archive->command->files->len; i++) { | ||||
3635 | FileData *fd = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i]; | ||||
3636 | char *utf8_name; | ||||
3637 | |||||
3638 | /* FIXME: only files in the current location ? */ | ||||
3639 | |||||
3640 | if (fd == NULL((void*)0)) | ||||
3641 | continue; | ||||
3642 | |||||
3643 | utf8_name = g_filename_to_utf8 (fd->name, -1, NULL((void*)0), NULL((void*)0), NULL((void*)0)); | ||||
3644 | if (match_regexps (regexps, utf8_name, 0)) | ||||
3645 | list = g_list_prepend (list, g_strdup (fd->original_path)g_strdup_inline (fd->original_path)); | ||||
3646 | g_free (utf8_name); | ||||
3647 | } | ||||
3648 | free_regexps (regexps); | ||||
3649 | |||||
3650 | return g_list_reverse (list); | ||||
3651 | } | ||||
3652 | |||||
3653 | |||||
3654 | static GList * | ||||
3655 | fr_window_get_file_list (FrWindow *window) | ||||
3656 | { | ||||
3657 | GList *list; | ||||
3658 | guint i; | ||||
3659 | |||||
3660 | 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); | ||||
3661 | |||||
3662 | list = NULL((void*)0); | ||||
3663 | for (i = 0; i < window->archive->command->files->len; i++) { | ||||
3664 | FileData *fd = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i]; | ||||
3665 | list = g_list_prepend (list, g_strdup (fd->original_path)g_strdup_inline (fd->original_path)); | ||||
3666 | } | ||||
3667 | |||||
3668 | return g_list_reverse (list); | ||||
3669 | } | ||||
3670 | |||||
3671 | |||||
3672 | int | ||||
3673 | fr_window_get_n_selected_files (FrWindow *window) | ||||
3674 | { | ||||
3675 | 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 ())))))))); | ||||
3676 | } | ||||
3677 | |||||
3678 | |||||
3679 | /**/ | ||||
3680 | |||||
3681 | |||||
3682 | static int | ||||
3683 | dir_tree_button_press_cb (CtkWidget *widget, | ||||
3684 | CdkEventButton *event, | ||||
3685 | gpointer data) | ||||
3686 | { | ||||
3687 | FrWindow *window = data; | ||||
3688 | CtkTreeSelection *selection; | ||||
3689 | |||||
3690 | 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 ())))))))) | ||||
3691 | return FALSE(0); | ||||
3692 | |||||
3693 | 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 ()))))))); | ||||
3694 | if (selection == NULL((void*)0)) | ||||
3695 | return FALSE(0); | ||||
3696 | |||||
3697 | if ((event->type == CDK_BUTTON_PRESS) && (event->button == 3)) { | ||||
3698 | CtkTreePath *path; | ||||
3699 | CtkTreeIter iter; | ||||
3700 | |||||
3701 | 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 ())))))), | ||||
3702 | event->x, event->y, | ||||
3703 | &path, NULL((void*)0), NULL((void*)0), NULL((void*)0))) { | ||||
3704 | |||||
3705 | 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)) { | ||||
3706 | ctk_tree_path_free (path); | ||||
3707 | return FALSE(0); | ||||
3708 | } | ||||
3709 | ctk_tree_path_free (path); | ||||
3710 | |||||
3711 | if (! ctk_tree_selection_iter_is_selected (selection, &iter)) { | ||||
3712 | ctk_tree_selection_unselect_all (selection); | ||||
3713 | ctk_tree_selection_select_iter (selection, &iter); | ||||
3714 | } | ||||
3715 | |||||
3716 | 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 ())))))), | ||||
3717 | (const CdkEvent*) event); | ||||
3718 | } | ||||
3719 | else | ||||
3720 | ctk_tree_selection_unselect_all (selection); | ||||
3721 | |||||
3722 | return TRUE(!(0)); | ||||
3723 | } | ||||
3724 | else if ((event->type == CDK_BUTTON_PRESS) && (event->button == 8)) { | ||||
3725 | fr_window_go_back (window); | ||||
3726 | return TRUE(!(0)); | ||||
3727 | } | ||||
3728 | else if ((event->type == CDK_BUTTON_PRESS) && (event->button == 9)) { | ||||
3729 | fr_window_go_forward (window); | ||||
3730 | return TRUE(!(0)); | ||||
3731 | } | ||||
3732 | |||||
3733 | return FALSE(0); | ||||
3734 | } | ||||
3735 | |||||
3736 | |||||
3737 | static FileData * | ||||
3738 | fr_window_get_selected_item_from_file_list (FrWindow *window) | ||||
3739 | { | ||||
3740 | CtkTreeSelection *tree_selection; | ||||
3741 | GList *selection; | ||||
3742 | FileData *fdata = NULL((void*)0); | ||||
3743 | |||||
3744 | 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); | ||||
3745 | |||||
3746 | 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 ()))))))); | ||||
3747 | if (tree_selection == NULL((void*)0)) | ||||
3748 | return NULL((void*)0); | ||||
3749 | |||||
3750 | selection = NULL((void*)0); | ||||
3751 | ctk_tree_selection_selected_foreach (tree_selection, add_selected_from_list_view, &selection); | ||||
3752 | if ((selection == NULL((void*)0)) || (selection->next != NULL((void*)0))) { | ||||
3753 | /* return NULL if the selection contains more than one entry. */ | ||||
3754 | g_list_free (selection); | ||||
3755 | return NULL((void*)0); | ||||
3756 | } | ||||
3757 | |||||
3758 | fdata = file_data_copy (selection->data); | ||||
3759 | g_list_free (selection); | ||||
3760 | |||||
3761 | return fdata; | ||||
3762 | } | ||||
3763 | |||||
3764 | |||||
3765 | static char * | ||||
3766 | fr_window_get_selected_folder_in_tree_view (FrWindow *window) | ||||
3767 | { | ||||
3768 | CtkTreeSelection *tree_selection; | ||||
3769 | GList *selections; | ||||
3770 | char *path = NULL((void*)0); | ||||
3771 | |||||
3772 | 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); | ||||
3773 | |||||
3774 | 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 ()))))))); | ||||
3775 | if (tree_selection == NULL((void*)0)) | ||||
3776 | return NULL((void*)0); | ||||
3777 | |||||
3778 | selections = NULL((void*)0); | ||||
3779 | ctk_tree_selection_selected_foreach (tree_selection, add_selected_from_tree_view, &selections); | ||||
3780 | |||||
3781 | if (selections != NULL((void*)0)) { | ||||
3782 | path = selections->data; | ||||
3783 | g_list_free (selections); | ||||
3784 | } | ||||
3785 | |||||
3786 | return path; | ||||
3787 | } | ||||
3788 | |||||
3789 | |||||
3790 | void | ||||
3791 | fr_window_current_folder_activated (FrWindow *window, | ||||
3792 | gboolean from_sidebar) | ||||
3793 | { | ||||
3794 | char *dir_path; | ||||
3795 | |||||
3796 | if (! from_sidebar) { | ||||
3797 | FileData *fdata; | ||||
3798 | char *dir_name; | ||||
3799 | |||||
3800 | fdata = fr_window_get_selected_item_from_file_list (window); | ||||
3801 | if ((fdata == NULL((void*)0)) || ! file_data_is_dir (fdata)) { | ||||
3802 | file_data_free (fdata); | ||||
3803 | return; | ||||
3804 | } | ||||
3805 | dir_name = g_strdup (fdata->list_name)g_strdup_inline (fdata->list_name); | ||||
3806 | dir_path = g_strconcat (fr_window_get_current_location (window), | ||||
3807 | dir_name, | ||||
3808 | "/", | ||||
3809 | NULL((void*)0)); | ||||
3810 | g_free (dir_name); | ||||
3811 | file_data_free (fdata); | ||||
3812 | } | ||||
3813 | else | ||||
3814 | dir_path = fr_window_get_selected_folder_in_tree_view (window); | ||||
3815 | |||||
3816 | fr_window_go_to_location (window, dir_path, FALSE(0)); | ||||
3817 | |||||
3818 | g_free (dir_path); | ||||
3819 | } | ||||
3820 | |||||
3821 | |||||
3822 | static gboolean | ||||
3823 | row_activated_cb (CtkTreeView *tree_view, | ||||
3824 | CtkTreePath *path, | ||||
3825 | CtkTreeViewColumn *column, | ||||
3826 | gpointer data) | ||||
3827 | { | ||||
3828 | FrWindow *window = data; | ||||
3829 | FileData *fdata; | ||||
3830 | CtkTreeIter iter; | ||||
3831 | |||||
3832 | 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 ())))))), | ||||
3833 | &iter, | ||||
3834 | path)) | ||||
3835 | return FALSE(0); | ||||
3836 | |||||
3837 | 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, | ||||
3838 | COLUMN_FILE_DATA, &fdata, | ||||
3839 | -1); | ||||
3840 | |||||
3841 | if (! file_data_is_dir (fdata)) { | ||||
3842 | GList *list = g_list_prepend (NULL((void*)0), fdata->original_path); | ||||
3843 | fr_window_open_files (window, list, FALSE(0)); | ||||
3844 | g_list_free (list); | ||||
3845 | } | ||||
3846 | else if (window->priv->list_mode == FR_WINDOW_LIST_MODE_AS_DIR) { | ||||
3847 | char *new_dir; | ||||
3848 | new_dir = g_strconcat (fr_window_get_current_location (window), | ||||
3849 | fdata->list_name, | ||||
3850 | "/", | ||||
3851 | NULL((void*)0)); | ||||
3852 | fr_window_go_to_location (window, new_dir, FALSE(0)); | ||||
3853 | g_free (new_dir); | ||||
3854 | } | ||||
3855 | |||||
3856 | return FALSE(0); | ||||
3857 | } | ||||
3858 | |||||
3859 | |||||
3860 | static int | ||||
3861 | file_button_press_cb (CtkWidget *widget, | ||||
3862 | CdkEventButton *event, | ||||
3863 | gpointer data) | ||||
3864 | { | ||||
3865 | FrWindow *window = data; | ||||
3866 | CtkTreeSelection *selection; | ||||
3867 | |||||
3868 | 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 ())))))))) | ||||
3869 | return FALSE(0); | ||||
3870 | |||||
3871 | 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 ()))))))); | ||||
3872 | if (selection == NULL((void*)0)) | ||||
3873 | return FALSE(0); | ||||
3874 | |||||
3875 | if (window->priv->path_clicked != NULL((void*)0)) { | ||||
3876 | ctk_tree_path_free (window->priv->path_clicked); | ||||
3877 | window->priv->path_clicked = NULL((void*)0); | ||||
3878 | } | ||||
3879 | |||||
3880 | if ((event->type == CDK_BUTTON_PRESS) && (event->button == 3)) { | ||||
3881 | CtkTreePath *path; | ||||
3882 | CtkTreeIter iter; | ||||
3883 | int n_selected; | ||||
3884 | |||||
3885 | 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 ())))))), | ||||
3886 | event->x, event->y, | ||||
3887 | &path, NULL((void*)0), NULL((void*)0), NULL((void*)0))) { | ||||
3888 | |||||
3889 | 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)) { | ||||
3890 | ctk_tree_path_free (path); | ||||
3891 | return FALSE(0); | ||||
3892 | } | ||||
3893 | ctk_tree_path_free (path); | ||||
3894 | |||||
3895 | if (! ctk_tree_selection_iter_is_selected (selection, &iter)) { | ||||
3896 | ctk_tree_selection_unselect_all (selection); | ||||
3897 | ctk_tree_selection_select_iter (selection, &iter); | ||||
3898 | } | ||||
3899 | } | ||||
3900 | else | ||||
3901 | ctk_tree_selection_unselect_all (selection); | ||||
3902 | |||||
3903 | n_selected = fr_window_get_n_selected_files (window); | ||||
3904 | if ((n_selected == 1) && selection_has_a_dir (window)) | ||||
3905 | 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 ())))))), | ||||
3906 | (const CdkEvent*) event); | ||||
3907 | else | ||||
3908 | 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 ())))))), | ||||
3909 | (const CdkEvent*) event); | ||||
3910 | return TRUE(!(0)); | ||||
3911 | } | ||||
3912 | else if ((event->type == CDK_BUTTON_PRESS) && (event->button == 1)) { | ||||
3913 | CtkTreePath *path = NULL((void*)0); | ||||
3914 | |||||
3915 | 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 ())))))), | ||||
3916 | event->x, event->y, | ||||
3917 | &path, NULL((void*)0), NULL((void*)0), NULL((void*)0))) { | ||||
3918 | ctk_tree_selection_unselect_all (selection); | ||||
3919 | } | ||||
3920 | |||||
3921 | if (window->priv->path_clicked != NULL((void*)0)) { | ||||
3922 | ctk_tree_path_free (window->priv->path_clicked); | ||||
3923 | window->priv->path_clicked = NULL((void*)0); | ||||
3924 | } | ||||
3925 | |||||
3926 | if (path != NULL((void*)0)) { | ||||
3927 | window->priv->path_clicked = ctk_tree_path_copy (path); | ||||
3928 | ctk_tree_path_free (path); | ||||
3929 | } | ||||
3930 | |||||
3931 | return FALSE(0); | ||||
3932 | } | ||||
3933 | else if ((event->type == CDK_BUTTON_PRESS) && (event->button == 8)) { | ||||
3934 | // go back | ||||
3935 | fr_window_go_back (window); | ||||
3936 | return TRUE(!(0)); | ||||
3937 | } | ||||
3938 | else if ((event->type == CDK_BUTTON_PRESS) && (event->button == 9)) { | ||||
3939 | // go forward | ||||
3940 | fr_window_go_forward (window); | ||||
3941 | return TRUE(!(0)); | ||||
3942 | } | ||||
3943 | |||||
3944 | return FALSE(0); | ||||
3945 | } | ||||
3946 | |||||
3947 | |||||
3948 | static int | ||||
3949 | file_button_release_cb (CtkWidget *widget, | ||||
3950 | CdkEventButton *event, | ||||
3951 | gpointer data) | ||||
3952 | { | ||||
3953 | FrWindow *window = data; | ||||
3954 | CtkTreeSelection *selection; | ||||
3955 | |||||
3956 | 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 ())))))))) | ||||
3957 | return FALSE(0); | ||||
3958 | |||||
3959 | 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 ()))))))); | ||||
3960 | if (selection == NULL((void*)0)) | ||||
3961 | return FALSE(0); | ||||
3962 | |||||
3963 | if (window->priv->path_clicked == NULL((void*)0)) | ||||
3964 | return FALSE(0); | ||||
3965 | |||||
3966 | if ((event->type == CDK_BUTTON_RELEASE) | ||||
3967 | && (event->button == 1) | ||||
3968 | && (window->priv->path_clicked != NULL((void*)0))) { | ||||
3969 | CtkTreePath *path = NULL((void*)0); | ||||
3970 | |||||
3971 | 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 ())))))), | ||||
3972 | event->x, event->y, | ||||
3973 | &path, NULL((void*)0), NULL((void*)0), NULL((void*)0))) { | ||||
3974 | |||||
3975 | if ((ctk_tree_path_compare (window->priv->path_clicked, path) == 0) | ||||
3976 | && window->priv->single_click | ||||
3977 | && ! ((event->state & CDK_CONTROL_MASK) || (event->state & CDK_SHIFT_MASK))) { | ||||
3978 | ctk_tree_view_set_cursor (CTK_TREE_VIEW (widget)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_tree_view_get_type ())))))), | ||||
3979 | path, | ||||
3980 | NULL((void*)0), | ||||
3981 | FALSE(0)); | ||||
3982 | ctk_tree_view_row_activated (CTK_TREE_VIEW (widget)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_tree_view_get_type ())))))), | ||||
3983 | path, | ||||
3984 | NULL((void*)0)); | ||||
3985 | } | ||||
3986 | } | ||||
3987 | |||||
3988 | if (path != NULL((void*)0)) | ||||
3989 | ctk_tree_path_free (path); | ||||
3990 | } | ||||
3991 | |||||
3992 | if (window->priv->path_clicked != NULL((void*)0)) { | ||||
3993 | ctk_tree_path_free (window->priv->path_clicked); | ||||
3994 | window->priv->path_clicked = NULL((void*)0); | ||||
3995 | } | ||||
3996 | |||||
3997 | return FALSE(0); | ||||
3998 | } | ||||
3999 | |||||
4000 | |||||
4001 | static gboolean | ||||
4002 | file_motion_notify_callback (CtkWidget *widget, | ||||
4003 | CdkEventMotion *event, | ||||
4004 | gpointer user_data) | ||||
4005 | { | ||||
4006 | FrWindow *window = user_data; | ||||
4007 | CdkCursor *cursor; | ||||
4008 | CtkTreePath *last_hover_path; | ||||
4009 | CdkDisplay *display; | ||||
4010 | CtkTreeIter iter; | ||||
4011 | |||||
4012 | if (! window->priv->single_click) | ||||
4013 | return FALSE(0); | ||||
4014 | |||||
4015 | 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 ())))))))) | ||||
4016 | return FALSE(0); | ||||
4017 | |||||
4018 | last_hover_path = window->priv->list_hover_path; | ||||
4019 | |||||
4020 | 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 ())))))), | ||||
4021 | event->x, event->y, | ||||
4022 | &window->priv->list_hover_path, | ||||
4023 | NULL((void*)0), NULL((void*)0), NULL((void*)0)); | ||||
4024 | |||||
4025 | display = ctk_widget_get_display (CTK_WIDGET (widget)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_widget_get_type ()))))))); | ||||
4026 | |||||
4027 | if (window->priv->list_hover_path != NULL((void*)0)) | ||||
4028 | cursor = cdk_cursor_new_for_display (display, CDK_HAND2); | ||||
4029 | else | ||||
4030 | cursor = NULL((void*)0); | ||||
4031 | |||||
4032 | cdk_window_set_cursor (event->window, cursor); | ||||
4033 | |||||
4034 | /* only redraw if the hover row has changed */ | ||||
4035 | if (!(last_hover_path == NULL((void*)0) && window->priv->list_hover_path == NULL((void*)0)) && | ||||
4036 | (!(last_hover_path != NULL((void*)0) && window->priv->list_hover_path != NULL((void*)0)) || | ||||
4037 | ctk_tree_path_compare (last_hover_path, window->priv->list_hover_path))) | ||||
4038 | { | ||||
4039 | if (last_hover_path) { | ||||
4040 | 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 ())))))), | ||||
4041 | &iter, last_hover_path); | ||||
4042 | 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 ())))))), | ||||
4043 | last_hover_path, &iter); | ||||
4044 | } | ||||
4045 | |||||
4046 | if (window->priv->list_hover_path) { | ||||
4047 | 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 ())))))), | ||||
4048 | &iter, window->priv->list_hover_path); | ||||
4049 | 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 ())))))), | ||||
4050 | window->priv->list_hover_path, &iter); | ||||
4051 | } | ||||
4052 | } | ||||
4053 | |||||
4054 | ctk_tree_path_free (last_hover_path); | ||||
4055 | |||||
4056 | return FALSE(0); | ||||
4057 | } | ||||
4058 | |||||
4059 | |||||
4060 | static gboolean | ||||
4061 | file_leave_notify_callback (CtkWidget *widget, | ||||
4062 | CdkEventCrossing *event, | ||||
4063 | gpointer user_data) | ||||
4064 | { | ||||
4065 | FrWindow *window = user_data; | ||||
4066 | CtkTreeIter iter; | ||||
4067 | |||||
4068 | if (window->priv->single_click && (window->priv->list_hover_path != NULL((void*)0))) { | ||||
4069 | 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 ())))))), | ||||
4070 | &iter, | ||||
4071 | window->priv->list_hover_path); | ||||
4072 | 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 ())))))), | ||||
4073 | window->priv->list_hover_path, | ||||
4074 | &iter); | ||||
4075 | |||||
4076 | ctk_tree_path_free (window->priv->list_hover_path); | ||||
4077 | window->priv->list_hover_path = NULL((void*)0); | ||||
4078 | } | ||||
4079 | |||||
4080 | return FALSE(0); | ||||
4081 | } | ||||
4082 | |||||
4083 | |||||
4084 | /* -- drag and drop -- */ | ||||
4085 | |||||
4086 | |||||
4087 | static GList * | ||||
4088 | get_uri_list_from_selection_data (char *uri_list) | ||||
4089 | { | ||||
4090 | GList *list = NULL((void*)0); | ||||
4091 | char **uris; | ||||
4092 | int i; | ||||
4093 | |||||
4094 | if (uri_list == NULL((void*)0)) | ||||
4095 | return NULL((void*)0); | ||||
4096 | |||||
4097 | uris = g_uri_list_extract_uris (uri_list); | ||||
4098 | for (i = 0; uris[i] != NULL((void*)0); i++) | ||||
4099 | list = g_list_prepend (list, g_strdup (uris[i])g_strdup_inline (uris[i])); | ||||
4100 | g_strfreev (uris); | ||||
4101 | |||||
4102 | return g_list_reverse (list); | ||||
4103 | } | ||||
4104 | |||||
4105 | |||||
4106 | static gboolean | ||||
4107 | fr_window_drag_motion (CtkWidget *widget, | ||||
4108 | CdkDragContext *context, | ||||
4109 | gint x, | ||||
4110 | gint y, | ||||
4111 | guint time, | ||||
4112 | gpointer user_data) | ||||
4113 | { | ||||
4114 | FrWindow *window = user_data; | ||||
4115 | |||||
4116 | if ((ctk_drag_get_source_widget (context) == window->priv->list_view) | ||||
4117 | || (ctk_drag_get_source_widget (context) == window->priv->tree_view)) | ||||
4118 | { | ||||
4119 | cdk_drag_status (context, 0, time); | ||||
4120 | return FALSE(0); | ||||
4121 | } | ||||
4122 | |||||
4123 | return TRUE(!(0)); | ||||
4124 | } | ||||
4125 | |||||
4126 | |||||
4127 | static void fr_window_paste_from_clipboard_data (FrWindow *window, FrClipboardData *data); | ||||
4128 | |||||
4129 | |||||
4130 | static FrClipboardData* | ||||
4131 | get_clipboard_data_from_selection_data (FrWindow *window, | ||||
4132 | const char *data) | ||||
4133 | { | ||||
4134 | FrClipboardData *clipboard_data; | ||||
4135 | char **uris; | ||||
4136 | int i; | ||||
4137 | |||||
4138 | clipboard_data = fr_clipboard_data_new (); | ||||
4139 | |||||
4140 | uris = g_strsplit (data, "\r\n", -1); | ||||
4141 | |||||
4142 | clipboard_data->archive_filename = g_strdup (uris[0])g_strdup_inline (uris[0]); | ||||
4143 | if (window->priv->password_for_paste != NULL((void*)0)) | ||||
4144 | clipboard_data->archive_password = g_strdup (window->priv->password_for_paste)g_strdup_inline (window->priv->password_for_paste); | ||||
4145 | else if (strcmp (uris[1], "") != 0) | ||||
4146 | clipboard_data->archive_password = g_strdup (uris[1])g_strdup_inline (uris[1]); | ||||
4147 | clipboard_data->op = (strcmp (uris[2], "copy") == 0) ? FR_CLIPBOARD_OP_COPY : FR_CLIPBOARD_OP_CUT; | ||||
4148 | clipboard_data->base_dir = g_strdup (uris[3])g_strdup_inline (uris[3]); | ||||
4149 | for (i = 4; uris[i] != NULL((void*)0); i++) | ||||
4150 | if (uris[i][0] != '\0') | ||||
4151 | clipboard_data->files = g_list_prepend (clipboard_data->files, g_strdup (uris[i])g_strdup_inline (uris[i])); | ||||
4152 | clipboard_data->files = g_list_reverse (clipboard_data->files); | ||||
4153 | |||||
4154 | g_strfreev (uris); | ||||
4155 | |||||
4156 | return clipboard_data; | ||||
4157 | } | ||||
4158 | |||||
4159 | |||||
4160 | static void | ||||
4161 | fr_window_drag_data_received (CtkWidget *widget, | ||||
4162 | CdkDragContext *context, | ||||
4163 | gint x, | ||||
4164 | gint y, | ||||
4165 | CtkSelectionData *data, | ||||
4166 | guint info, | ||||
4167 | guint time, | ||||
4168 | gpointer extra_data) | ||||
4169 | { | ||||
4170 | FrWindow *window = extra_data; | ||||
4171 | GList *list; | ||||
4172 | gboolean one_file; | ||||
4173 | gboolean is_an_archive; | ||||
4174 | |||||
4175 | debug (DEBUG_INFO"fr-window.c", 4175, __FUNCTION__, "::DragDataReceived -->\n"); | ||||
4176 | |||||
4177 | if ((ctk_drag_get_source_widget (context) == window->priv->list_view) | ||||
4178 | || (ctk_drag_get_source_widget (context) == window->priv->tree_view)) | ||||
4179 | { | ||||
4180 | ctk_drag_finish (context, FALSE(0), FALSE(0), time); | ||||
4181 | return; | ||||
4182 | } | ||||
4183 | |||||
4184 | if (! ((ctk_selection_data_get_length (data) >= 0) && (ctk_selection_data_get_format (data) == 8))) { | ||||
4185 | ctk_drag_finish (context, FALSE(0), FALSE(0), time); | ||||
4186 | return; | ||||
4187 | } | ||||
4188 | |||||
4189 | if (window->priv->activity_ref > 0) { | ||||
4190 | ctk_drag_finish (context, FALSE(0), FALSE(0), time); | ||||
4191 | return; | ||||
4192 | } | ||||
4193 | |||||
4194 | ctk_drag_finish (context, TRUE(!(0)), FALSE(0), time); | ||||
4195 | |||||
4196 | if (ctk_selection_data_get_target (data) == XFR_ATOMcdk_atom_intern ("XdndGrapa0", (0))) { | ||||
4197 | FrClipboardData *dnd_data; | ||||
4198 | |||||
4199 | dnd_data = get_clipboard_data_from_selection_data (window, (char*) ctk_selection_data_get_data (data)); | ||||
4200 | dnd_data->current_dir = g_strdup (fr_window_get_current_location (window))g_strdup_inline (fr_window_get_current_location (window)); | ||||
4201 | fr_window_paste_from_clipboard_data (window, dnd_data); | ||||
4202 | |||||
4203 | return; | ||||
4204 | } | ||||
4205 | |||||
4206 | list = get_uri_list_from_selection_data ((char*) ctk_selection_data_get_data (data)); | ||||
4207 | if (list == NULL((void*)0)) { | ||||
4208 | CtkWidget *d; | ||||
4209 | |||||
4210 | d = _ctk_error_dialog_new (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), | ||||
4211 | CTK_DIALOG_MODAL, | ||||
4212 | NULL((void*)0), | ||||
4213 | _("Could not perform the operation")gettext ("Could not perform the operation"), | ||||
4214 | NULL((void*)0)); | ||||
4215 | ctk_dialog_run (CTK_DIALOG (d)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((d)), ((ctk_dialog_get_type ()))))))); | ||||
4216 | ctk_widget_destroy(d); | ||||
4217 | |||||
4218 | return; | ||||
4219 | } | ||||
4220 | |||||
4221 | one_file = (list->next == NULL((void*)0)); | ||||
4222 | if (one_file) | ||||
4223 | is_an_archive = uri_is_archive (list->data); | ||||
4224 | else | ||||
4225 | is_an_archive = FALSE(0); | ||||
4226 | |||||
4227 | if (window->priv->archive_present | ||||
4228 | && (window->archive != NULL((void*)0)) | ||||
4229 | && ! window->archive->read_only | ||||
4230 | && ! window->archive->is_compressed_file) | ||||
4231 | { | ||||
4232 | if (one_file && is_an_archive) { | ||||
4233 | CtkWidget *d; | ||||
4234 | gint r; | ||||
4235 | |||||
4236 | d = _ctk_message_dialog_new (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), | ||||
4237 | CTK_DIALOG_MODAL, | ||||
4238 | "dialog-question", | ||||
4239 | _("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?" ), | ||||
4240 | NULL((void*)0), | ||||
4241 | CTK_STOCK_CANCEL((CtkStock)"ctk-cancel"), CTK_RESPONSE_CANCEL, | ||||
4242 | CTK_STOCK_ADD((CtkStock)"ctk-add"), 0, | ||||
4243 | CTK_STOCK_OPEN((CtkStock)"ctk-open"), 1, | ||||
4244 | NULL((void*)0)); | ||||
4245 | |||||
4246 | ctk_dialog_set_default_response (CTK_DIALOG (d)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((d)), ((ctk_dialog_get_type ())))))), 2); | ||||
4247 | |||||
4248 | r = ctk_dialog_run (CTK_DIALOG (d)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((d)), ((ctk_dialog_get_type ()))))))); | ||||
4249 | ctk_widget_destroy (CTK_WIDGET (d)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((d)), ((ctk_widget_get_type ()))))))); | ||||
4250 | |||||
4251 | if (r == 0) /* Add */ | ||||
4252 | fr_window_archive_add_dropped_items (window, list, FALSE(0)); | ||||
4253 | else if (r == 1) /* Open */ | ||||
4254 | fr_window_archive_open (window, list->data, CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ()))))))); | ||||
4255 | } | ||||
4256 | else | ||||
4257 | fr_window_archive_add_dropped_items (window, list, FALSE(0)); | ||||
4258 | } | ||||
4259 | else { | ||||
4260 | if (one_file && is_an_archive) | ||||
4261 | fr_window_archive_open (window, list->data, CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ()))))))); | ||||
4262 | else { | ||||
4263 | CtkWidget *d; | ||||
4264 | int r; | ||||
4265 | |||||
4266 | d = _ctk_message_dialog_new (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), | ||||
4267 | CTK_DIALOG_MODAL, | ||||
4268 | "dialog-question", | ||||
4269 | _("Do you want to create a new archive with these files?")gettext ("Do you want to create a new archive with these files?" ), | ||||
4270 | NULL((void*)0), | ||||
4271 | CTK_STOCK_CANCEL((CtkStock)"ctk-cancel"), CTK_RESPONSE_CANCEL, | ||||
4272 | _("Create _Archive")gettext ("Create _Archive"), CTK_RESPONSE_YES, | ||||
4273 | NULL((void*)0)); | ||||
4274 | |||||
4275 | ctk_dialog_set_default_response (CTK_DIALOG (d)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((d)), ((ctk_dialog_get_type ())))))), CTK_RESPONSE_YES); | ||||
4276 | r = ctk_dialog_run (CTK_DIALOG (d)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((d)), ((ctk_dialog_get_type ()))))))); | ||||
4277 | ctk_widget_destroy (CTK_WIDGET (d)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((d)), ((ctk_widget_get_type ()))))))); | ||||
4278 | |||||
4279 | if (r == CTK_RESPONSE_YES) { | ||||
4280 | char *first_item; | ||||
4281 | char *folder; | ||||
4282 | char *local_path = NULL((void*)0); | ||||
4283 | char *utf8_path = NULL((void*)0); | ||||
4284 | const char *archive_name; | ||||
4285 | |||||
4286 | fr_window_free_batch_data (window); | ||||
4287 | fr_window_append_batch_action (window, | ||||
4288 | FR_BATCH_ACTION_ADD, | ||||
4289 | path_list_dup (list), | ||||
4290 | (GFreeFunc) path_list_free); | ||||
4291 | |||||
4292 | first_item = (char*) list->data; | ||||
4293 | folder = remove_level_from_path (first_item); | ||||
4294 | if (folder != NULL((void*)0)) | ||||
4295 | fr_window_set_open_default_dir (window, folder); | ||||
4296 | |||||
4297 | if ((list->next != NULL((void*)0)) && (folder != NULL((void*)0))) { | ||||
4298 | archive_name = file_name_from_path (folder); | ||||
4299 | } | ||||
4300 | else { | ||||
4301 | if (uri_is_local (first_item)) { | ||||
4302 | local_path = g_filename_from_uri (first_item, NULL((void*)0), NULL((void*)0)); | ||||
4303 | if (local_path) | ||||
4304 | utf8_path = g_filename_to_utf8 (local_path, -1, NULL((void*)0), NULL((void*)0), NULL((void*)0)); | ||||
4305 | if (!utf8_path) | ||||
4306 | utf8_path= g_strdup (first_item)g_strdup_inline (first_item); | ||||
4307 | g_free (local_path); | ||||
4308 | } | ||||
4309 | else { | ||||
4310 | utf8_path = g_strdup (first_item)g_strdup_inline (first_item); | ||||
4311 | } | ||||
4312 | archive_name = file_name_from_path (utf8_path); | ||||
4313 | } | ||||
4314 | |||||
4315 | show_new_archive_dialog (window, archive_name); | ||||
4316 | g_free (utf8_path); | ||||
4317 | |||||
4318 | g_free (folder); | ||||
4319 | } | ||||
4320 | } | ||||
4321 | } | ||||
4322 | |||||
4323 | path_list_free (list); | ||||
4324 | |||||
4325 | debug (DEBUG_INFO"fr-window.c", 4325, __FUNCTION__, "::DragDataReceived <--\n"); | ||||
4326 | } | ||||
4327 | |||||
4328 | |||||
4329 | static gboolean | ||||
4330 | file_list_drag_begin (CtkWidget *widget, | ||||
4331 | CdkDragContext *context, | ||||
4332 | gpointer data) | ||||
4333 | { | ||||
4334 | FrWindow *window = data; | ||||
4335 | |||||
4336 | debug (DEBUG_INFO"fr-window.c", 4336, __FUNCTION__, "::DragBegin -->\n"); | ||||
4337 | |||||
4338 | if (window->priv->activity_ref > 0) | ||||
4339 | return FALSE(0); | ||||
4340 | |||||
4341 | g_free (window->priv->drag_destination_folder); | ||||
4342 | window->priv->drag_destination_folder = NULL((void*)0); | ||||
4343 | |||||
4344 | g_free (window->priv->drag_base_dir); | ||||
4345 | window->priv->drag_base_dir = NULL((void*)0); | ||||
4346 | |||||
4347 | cdk_property_change (cdk_drag_context_get_source_window (context), | ||||
4348 | XDS_ATOMcdk_atom_intern ("XdndDirectSave0", (0)), TEXT_ATOMcdk_atom_intern ("text/plain", (0)), | ||||
4349 | 8, CDK_PROP_MODE_REPLACE, | ||||
4350 | (guchar *) XDS_FILENAME"xds.txt", | ||||
4351 | strlen (XDS_FILENAME"xds.txt")); | ||||
4352 | |||||
4353 | return TRUE(!(0)); | ||||
4354 | } | ||||
4355 | |||||
4356 | |||||
4357 | static void | ||||
4358 | file_list_drag_end (CtkWidget *widget, | ||||
4359 | CdkDragContext *context, | ||||
4360 | gpointer data) | ||||
4361 | { | ||||
4362 | FrWindow *window = data; | ||||
4363 | |||||
4364 | debug (DEBUG_INFO"fr-window.c", 4364, __FUNCTION__, "::DragEnd -->\n"); | ||||
4365 | |||||
4366 | cdk_property_delete (cdk_drag_context_get_source_window (context), XDS_ATOMcdk_atom_intern ("XdndDirectSave0", (0))); | ||||
4367 | |||||
4368 | if (window->priv->drag_error != NULL((void*)0)) { | ||||
4369 | _ctk_error_dialog_run (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), | ||||
4370 | _("Extraction not performed")gettext ("Extraction not performed"), | ||||
4371 | "%s", | ||||
4372 | window->priv->drag_error->message); | ||||
4373 | g_clear_error (&window->priv->drag_error); | ||||
4374 | } | ||||
4375 | else if (window->priv->drag_destination_folder != NULL((void*)0)) { | ||||
4376 | fr_window_archive_extract (window, | ||||
4377 | window->priv->drag_file_list, | ||||
4378 | window->priv->drag_destination_folder, | ||||
4379 | window->priv->drag_base_dir, | ||||
4380 | FALSE(0), | ||||
4381 | FR_OVERWRITE_ASK, | ||||
4382 | FALSE(0), | ||||
4383 | FALSE(0)); | ||||
4384 | path_list_free (window->priv->drag_file_list); | ||||
4385 | window->priv->drag_file_list = NULL((void*)0); | ||||
4386 | } | ||||
4387 | |||||
4388 | debug (DEBUG_INFO"fr-window.c", 4388, __FUNCTION__, "::DragEnd <--\n"); | ||||
4389 | } | ||||
4390 | |||||
4391 | |||||
4392 | /* The following three functions taken from bugzilla | ||||
4393 | * (http://bugzilla.cafe.org/attachment.cgi?id=49362&action=view) | ||||
4394 | * Author: Christian Neumair | ||||
4395 | * Copyright: 2005 Free Software Foundation, Inc | ||||
4396 | * License: GPL */ | ||||
4397 | static char * | ||||
4398 | get_xds_atom_value (CdkDragContext *context) | ||||
4399 | { | ||||
4400 | gint actual_length; | ||||
4401 | char *data; | ||||
4402 | char *ret; | ||||
4403 | |||||
4404 | 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); | ||||
4405 | 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); | ||||
4406 | |||||
4407 | if (cdk_property_get (cdk_drag_context_get_source_window (context), | ||||
4408 | XDS_ATOMcdk_atom_intern ("XdndDirectSave0", (0)), TEXT_ATOMcdk_atom_intern ("text/plain", (0)), | ||||
4409 | 0, MAX_XDS_ATOM_VAL_LEN4096, | ||||
4410 | FALSE(0), NULL((void*)0), NULL((void*)0), &actual_length, | ||||
4411 | (unsigned char **) &data)) { | ||||
4412 | /* add not included \0 to the end of the string */ | ||||
4413 | ret = g_strndup ((gchar *) data, actual_length); | ||||
4414 | g_free (data); | ||||
4415 | return ret; | ||||
4416 | } | ||||
4417 | |||||
4418 | return NULL((void*)0); | ||||
4419 | } | ||||
4420 | |||||
4421 | |||||
4422 | static gboolean | ||||
4423 | context_offers_target (CdkDragContext *context, | ||||
4424 | CdkAtom target) | ||||
4425 | { | ||||
4426 | return (g_list_find (cdk_drag_context_list_targets (context), target) != NULL((void*)0)); | ||||
4427 | } | ||||
4428 | |||||
4429 | |||||
4430 | static gboolean | ||||
4431 | baul_xds_dnd_is_valid_xds_context (CdkDragContext *context) | ||||
4432 | { | ||||
4433 | char *tmp; | ||||
4434 | gboolean ret; | ||||
4435 | |||||
4436 | 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); | ||||
4437 | |||||
4438 | tmp = NULL((void*)0); | ||||
4439 | if (context_offers_target (context, XDS_ATOMcdk_atom_intern ("XdndDirectSave0", (0)))) { | ||||
4440 | tmp = get_xds_atom_value (context); | ||||
4441 | } | ||||
4442 | |||||
4443 | ret = (tmp != NULL((void*)0)); | ||||
4444 | g_free (tmp); | ||||
4445 | |||||
4446 | return ret; | ||||
4447 | } | ||||
4448 | |||||
4449 | |||||
4450 | static char * | ||||
4451 | get_selection_data_from_clipboard_data (FrWindow *window, | ||||
4452 | FrClipboardData *data) | ||||
4453 | { | ||||
4454 | GString *list; | ||||
4455 | char *local_filename; | ||||
4456 | GList *scan; | ||||
4457 | |||||
4458 | list = g_string_new (NULL((void*)0)); | ||||
4459 | |||||
4460 | local_filename = g_file_get_uri (window->archive->local_copy); | ||||
4461 | 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)); | ||||
4462 | g_free (local_filename); | ||||
4463 | |||||
4464 | 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)); | ||||
4465 | if (window->priv->password != NULL((void*)0)) | ||||
4466 | 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)); | ||||
4467 | 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)); | ||||
4468 | 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)); | ||||
4469 | 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)); | ||||
4470 | 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)); | ||||
4471 | 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)); | ||||
4472 | for (scan = data->files; scan; scan = scan->next) { | ||||
4473 | 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)); | ||||
4474 | 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)); | ||||
4475 | } | ||||
4476 | |||||
4477 | 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)))); | ||||
4478 | } | ||||
4479 | |||||
4480 | |||||
4481 | static gboolean | ||||
4482 | fr_window_folder_tree_drag_data_get (CtkWidget *widget, | ||||
4483 | CdkDragContext *context, | ||||
4484 | CtkSelectionData *selection_data, | ||||
4485 | guint info, | ||||
4486 | guint time, | ||||
4487 | gpointer user_data) | ||||
4488 | { | ||||
4489 | FrWindow *window = user_data; | ||||
4490 | GList *file_list; | ||||
4491 | char *destination; | ||||
4492 | char *destination_folder; | ||||
4493 | |||||
4494 | debug (DEBUG_INFO"fr-window.c", 4494, __FUNCTION__, "::DragDataGet -->\n"); | ||||
4495 | |||||
4496 | if (window->priv->activity_ref > 0) | ||||
4497 | return FALSE(0); | ||||
4498 | |||||
4499 | file_list = fr_window_get_folder_tree_selection (window, TRUE(!(0)), NULL((void*)0)); | ||||
4500 | if (file_list == NULL((void*)0)) | ||||
4501 | return FALSE(0); | ||||
4502 | |||||
4503 | if (ctk_selection_data_get_target (selection_data) == XFR_ATOMcdk_atom_intern ("XdndGrapa0", (0))) { | ||||
4504 | FrClipboardData *tmp; | ||||
4505 | char *data; | ||||
4506 | |||||
4507 | tmp = fr_clipboard_data_new (); | ||||
4508 | tmp->files = file_list; | ||||
4509 | tmp->op = FR_CLIPBOARD_OP_COPY; | ||||
4510 | tmp->base_dir = g_strdup (fr_window_get_current_location (window))g_strdup_inline (fr_window_get_current_location (window)); | ||||
4511 | |||||
4512 | data = get_selection_data_from_clipboard_data (window, tmp); | ||||
4513 | ctk_selection_data_set (selection_data, XFR_ATOMcdk_atom_intern ("XdndGrapa0", (0)), 8, (guchar *) data, strlen (data)); | ||||
4514 | |||||
4515 | fr_clipboard_data_unref (tmp); | ||||
4516 | g_free (data); | ||||
4517 | |||||
4518 | return TRUE(!(0)); | ||||
4519 | } | ||||
4520 | |||||
4521 | if (! baul_xds_dnd_is_valid_xds_context (context)) | ||||
4522 | return FALSE(0); | ||||
4523 | |||||
4524 | destination = get_xds_atom_value (context); | ||||
4525 | 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); | ||||
4526 | |||||
4527 | destination_folder = remove_level_from_path (destination); | ||||
4528 | g_free (destination); | ||||
4529 | |||||
4530 | /* check whether the extraction can be performed in the destination | ||||
4531 | * folder */ | ||||
4532 | |||||
4533 | g_clear_error (&window->priv->drag_error); | ||||
4534 | |||||
4535 | if (! check_permissions (destination_folder, R_OK4 | W_OK2)) { | ||||
4536 | char *destination_folder_display_name; | ||||
4537 | |||||
4538 | destination_folder_display_name = g_filename_display_name (destination_folder); | ||||
4539 | 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); | ||||
4540 | g_free (destination_folder_display_name); | ||||
4541 | } | ||||
4542 | |||||
4543 | if (window->priv->drag_error == NULL((void*)0)) { | ||||
4544 | g_free (window->priv->drag_destination_folder); | ||||
4545 | g_free (window->priv->drag_base_dir); | ||||
4546 | path_list_free (window->priv->drag_file_list); | ||||
4547 | window->priv->drag_destination_folder = g_strdup (destination_folder)g_strdup_inline (destination_folder); | ||||
4548 | window->priv->drag_base_dir = fr_window_get_selected_folder_in_tree_view (window); | ||||
4549 | window->priv->drag_file_list = file_list; | ||||
4550 | } | ||||
4551 | |||||
4552 | g_free (destination_folder); | ||||
4553 | |||||
4554 | /* sends back the response */ | ||||
4555 | |||||
4556 | 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); | ||||
4557 | |||||
4558 | debug (DEBUG_INFO"fr-window.c", 4558, __FUNCTION__, "::DragDataGet <--\n"); | ||||
4559 | |||||
4560 | return TRUE(!(0)); | ||||
4561 | } | ||||
4562 | |||||
4563 | |||||
4564 | gboolean | ||||
4565 | fr_window_file_list_drag_data_get (FrWindow *window, | ||||
4566 | CdkDragContext *context, | ||||
4567 | CtkSelectionData *selection_data, | ||||
4568 | GList *path_list) | ||||
4569 | { | ||||
4570 | char *destination; | ||||
4571 | char *destination_folder; | ||||
4572 | |||||
4573 | debug (DEBUG_INFO"fr-window.c", 4573, __FUNCTION__, "::DragDataGet -->\n"); | ||||
4574 | |||||
4575 | if (window->priv->path_clicked != NULL((void*)0)) { | ||||
4576 | ctk_tree_path_free (window->priv->path_clicked); | ||||
4577 | window->priv->path_clicked = NULL((void*)0); | ||||
4578 | } | ||||
4579 | |||||
4580 | if (window->priv->activity_ref > 0) | ||||
4581 | return FALSE(0); | ||||
4582 | |||||
4583 | if (ctk_selection_data_get_target (selection_data) == XFR_ATOMcdk_atom_intern ("XdndGrapa0", (0))) { | ||||
4584 | FrClipboardData *tmp; | ||||
4585 | char *data; | ||||
4586 | |||||
4587 | tmp = fr_clipboard_data_new (); | ||||
4588 | tmp->files = fr_window_get_file_list_selection (window, TRUE(!(0)), NULL((void*)0)); | ||||
4589 | tmp->op = FR_CLIPBOARD_OP_COPY; | ||||
4590 | tmp->base_dir = g_strdup (fr_window_get_current_location (window))g_strdup_inline (fr_window_get_current_location (window)); | ||||
4591 | |||||
4592 | data = get_selection_data_from_clipboard_data (window, tmp); | ||||
4593 | ctk_selection_data_set (selection_data, XFR_ATOMcdk_atom_intern ("XdndGrapa0", (0)), 8, (guchar *) data, strlen (data)); | ||||
4594 | |||||
4595 | fr_clipboard_data_unref (tmp); | ||||
4596 | g_free (data); | ||||
4597 | |||||
4598 | return TRUE(!(0)); | ||||
4599 | } | ||||
4600 | |||||
4601 | if (! baul_xds_dnd_is_valid_xds_context (context)) | ||||
4602 | return FALSE(0); | ||||
4603 | |||||
4604 | destination = get_xds_atom_value (context); | ||||
4605 | 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); | ||||
4606 | |||||
4607 | destination_folder = remove_level_from_path (destination); | ||||
4608 | g_free (destination); | ||||
4609 | |||||
4610 | /* check whether the extraction can be performed in the destination | ||||
4611 | * folder */ | ||||
4612 | |||||
4613 | g_clear_error (&window->priv->drag_error); | ||||
4614 | |||||
4615 | if (! check_permissions (destination_folder, R_OK4 | W_OK2)) { | ||||
4616 | char *destination_folder_display_name; | ||||
4617 | |||||
4618 | destination_folder_display_name = g_filename_display_name (destination_folder); | ||||
4619 | 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); | ||||
4620 | g_free (destination_folder_display_name); | ||||
4621 | } | ||||
4622 | |||||
4623 | if (window->priv->drag_error == NULL((void*)0)) { | ||||
4624 | g_free (window->priv->drag_destination_folder); | ||||
4625 | g_free (window->priv->drag_base_dir); | ||||
4626 | path_list_free (window->priv->drag_file_list); | ||||
4627 | window->priv->drag_destination_folder = g_strdup (destination_folder)g_strdup_inline (destination_folder); | ||||
4628 | window->priv->drag_base_dir = g_strdup (fr_window_get_current_location (window))g_strdup_inline (fr_window_get_current_location (window)); | ||||
4629 | window->priv->drag_file_list = fr_window_get_file_list_from_path_list (window, path_list, NULL((void*)0)); | ||||
4630 | } | ||||
4631 | |||||
4632 | g_free (destination_folder); | ||||
4633 | |||||
4634 | /* sends back the response */ | ||||
4635 | |||||
4636 | 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); | ||||
4637 | |||||
4638 | debug (DEBUG_INFO"fr-window.c", 4638, __FUNCTION__, "::DragDataGet <--\n"); | ||||
4639 | |||||
4640 | return TRUE(!(0)); | ||||
4641 | } | ||||
4642 | |||||
4643 | |||||
4644 | /* -- window_new -- */ | ||||
4645 | |||||
4646 | |||||
4647 | static void | ||||
4648 | fr_window_deactivate_filter (FrWindow *window) | ||||
4649 | { | ||||
4650 | window->priv->filter_mode = FALSE(0); | ||||
4651 | window->priv->list_mode = window->priv->last_list_mode; | ||||
4652 | |||||
4653 | 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 ())))))), ""); | ||||
4654 | fr_window_update_filter_bar_visibility (window); | ||||
4655 | |||||
4656 | ctk_list_store_clear (window->priv->list_store); | ||||
4657 | |||||
4658 | fr_window_update_columns_visibility (window); | ||||
4659 | fr_window_update_file_list (window, TRUE(!(0))); | ||||
4660 | fr_window_update_dir_tree (window); | ||||
4661 | fr_window_update_current_location (window); | ||||
4662 | } | ||||
4663 | |||||
4664 | |||||
4665 | static gboolean | ||||
4666 | key_press_cb (CtkWidget *widget, | ||||
4667 | CdkEventKey *event, | ||||
4668 | gpointer data) | ||||
4669 | { | ||||
4670 | FrWindow *window = data; | ||||
4671 | gboolean retval = FALSE(0); | ||||
4672 | gboolean alt; | ||||
4673 | |||||
4674 | if (ctk_widget_has_focus (window->priv->location_entry)) | ||||
4675 | return FALSE(0); | ||||
4676 | |||||
4677 | if (ctk_widget_has_focus (window->priv->filter_entry)) { | ||||
4678 | switch (event->keyval) { | ||||
4679 | case CDK_KEY_Escape0xff1b: | ||||
4680 | fr_window_deactivate_filter (window); | ||||
4681 | retval = TRUE(!(0)); | ||||
4682 | break; | ||||
4683 | default: | ||||
4684 | break; | ||||
4685 | } | ||||
4686 | return retval; | ||||
4687 | } | ||||
4688 | |||||
4689 | alt = (event->state & CDK_MOD1_MASK) == CDK_MOD1_MASK; | ||||
4690 | |||||
4691 | switch (event->keyval) { | ||||
4692 | case CDK_KEY_Escape0xff1b: | ||||
4693 | activate_action_stop (NULL((void*)0), window); | ||||
4694 | if (window->priv->filter_mode) | ||||
4695 | fr_window_deactivate_filter (window); | ||||
4696 | retval = TRUE(!(0)); | ||||
4697 | break; | ||||
4698 | |||||
4699 | case CDK_KEY_F100xffc7: | ||||
4700 | if (event->state & CDK_SHIFT_MASK) { | ||||
4701 | CtkTreeSelection *selection; | ||||
4702 | |||||
4703 | 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 ()))))))); | ||||
4704 | if (selection == NULL((void*)0)) | ||||
4705 | return FALSE(0); | ||||
4706 | |||||
4707 | 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 ())))))), | ||||
4708 | (const CdkEvent*) event); | ||||
4709 | retval = TRUE(!(0)); | ||||
4710 | } | ||||
4711 | break; | ||||
4712 | |||||
4713 | case CDK_KEY_Up0xff52: | ||||
4714 | case CDK_KEY_KP_Up0xff97: | ||||
4715 | if (alt) { | ||||
4716 | fr_window_go_up_one_level (window); | ||||
4717 | retval = TRUE(!(0)); | ||||
4718 | } | ||||
4719 | break; | ||||
4720 | |||||
4721 | case CDK_KEY_BackSpace0xff08: | ||||
4722 | fr_window_go_up_one_level (window); | ||||
4723 | retval = TRUE(!(0)); | ||||
4724 | break; | ||||
4725 | |||||
4726 | case CDK_KEY_Right0xff53: | ||||
4727 | case CDK_KEY_KP_Right0xff98: | ||||
4728 | if (alt) { | ||||
4729 | fr_window_go_forward (window); | ||||
4730 | retval = TRUE(!(0)); | ||||
4731 | } | ||||
4732 | break; | ||||
4733 | |||||
4734 | case CDK_KEY_Left0xff51: | ||||
4735 | case CDK_KEY_KP_Left0xff96: | ||||
4736 | if (alt) { | ||||
4737 | fr_window_go_back (window); | ||||
4738 | retval = TRUE(!(0)); | ||||
4739 | } | ||||
4740 | break; | ||||
4741 | |||||
4742 | case CDK_KEY_Home0xff50: | ||||
4743 | case CDK_KEY_KP_Home0xff95: | ||||
4744 | if (alt) { | ||||
4745 | fr_window_go_to_location (window, "/", FALSE(0)); | ||||
4746 | retval = TRUE(!(0)); | ||||
4747 | } | ||||
4748 | break; | ||||
4749 | |||||
4750 | default: | ||||
4751 | break; | ||||
4752 | } | ||||
4753 | |||||
4754 | return retval; | ||||
4755 | } | ||||
4756 | |||||
4757 | |||||
4758 | static gboolean | ||||
4759 | dir_tree_selection_changed_cb (CtkTreeSelection *selection, | ||||
4760 | gpointer user_data) | ||||
4761 | { | ||||
4762 | FrWindow *window = user_data; | ||||
4763 | CtkTreeIter iter; | ||||
4764 | |||||
4765 | if (ctk_tree_selection_get_selected (selection, NULL((void*)0), &iter)) { | ||||
4766 | char *path; | ||||
4767 | |||||
4768 | 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 ())))))), | ||||
4769 | &iter, | ||||
4770 | TREE_COLUMN_PATH, &path, | ||||
4771 | -1); | ||||
4772 | fr_window_go_to_location (window, path, FALSE(0)); | ||||
4773 | g_free (path); | ||||
4774 | } | ||||
4775 | |||||
4776 | return FALSE(0); | ||||
4777 | } | ||||
4778 | |||||
4779 | |||||
4780 | static gboolean | ||||
4781 | selection_changed_cb (CtkTreeSelection *selection, | ||||
4782 | gpointer user_data) | ||||
4783 | { | ||||
4784 | FrWindow *window = user_data; | ||||
4785 | |||||
4786 | fr_window_update_statusbar_list_info (window); | ||||
4787 | fr_window_update_sensitivity (window); | ||||
4788 | |||||
4789 | return FALSE(0); | ||||
4790 | } | ||||
4791 | |||||
4792 | |||||
4793 | static void | ||||
4794 | fr_window_delete_event_cb (CtkWidget *caller, | ||||
4795 | CdkEvent *event, | ||||
4796 | FrWindow *window) | ||||
4797 | { | ||||
4798 | fr_window_close (window); | ||||
4799 | } | ||||
4800 | |||||
4801 | |||||
4802 | static gboolean | ||||
4803 | is_single_click_policy (FrWindow *window) | ||||
4804 | { | ||||
4805 | char *value; | ||||
4806 | gboolean result = FALSE(0); | ||||
4807 | |||||
4808 | if (window->priv->settings_baul) { | ||||
4809 | value = g_settings_get_string (window->priv->settings_baul, BAUL_CLICK_POLICY"click-policy"); | ||||
4810 | result = (value != NULL((void*)0)) && (strncmp (value, "single", 6) == 0); | ||||
4811 | g_free (value); | ||||
4812 | } | ||||
4813 | |||||
4814 | return result; | ||||
4815 | } | ||||
4816 | |||||
4817 | |||||
4818 | static void | ||||
4819 | filename_cell_data_func (CtkTreeViewColumn *column, | ||||
4820 | CtkCellRenderer *renderer, | ||||
4821 | CtkTreeModel *model, | ||||
4822 | CtkTreeIter *iter, | ||||
4823 | FrWindow *window) | ||||
4824 | { | ||||
4825 | char *text; | ||||
4826 | CtkTreePath *path; | ||||
4827 | PangoUnderline underline; | ||||
4828 | |||||
4829 | ctk_tree_model_get (model, iter, | ||||
4830 | COLUMN_NAME, &text, | ||||
4831 | -1); | ||||
4832 | |||||
4833 | if (window->priv->single_click) { | ||||
4834 | path = ctk_tree_model_get_path (model, iter); | ||||
4835 | |||||
4836 | if ((window->priv->list_hover_path == NULL((void*)0)) | ||||
4837 | || ctk_tree_path_compare (path, window->priv->list_hover_path)) | ||||
4838 | underline = PANGO_UNDERLINE_NONE; | ||||
4839 | else | ||||
4840 | underline = PANGO_UNDERLINE_SINGLE; | ||||
4841 | |||||
4842 | ctk_tree_path_free (path); | ||||
4843 | } | ||||
4844 | else | ||||
4845 | underline = PANGO_UNDERLINE_NONE; | ||||
4846 | |||||
4847 | g_object_set (G_OBJECT (renderer)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((renderer)), (((GType) ((20) << (2)))))))), | ||||
4848 | "text", text, | ||||
4849 | "underline", underline, | ||||
4850 | NULL((void*)0)); | ||||
4851 | |||||
4852 | g_free (text); | ||||
4853 | } | ||||
4854 | |||||
4855 | |||||
4856 | static void | ||||
4857 | add_dir_tree_columns (FrWindow *window, | ||||
4858 | CtkTreeView *treeview) | ||||
4859 | { | ||||
4860 | CtkCellRenderer *renderer; | ||||
4861 | CtkTreeViewColumn *column; | ||||
4862 | GValue value = { 0, }; | ||||
4863 | |||||
4864 | /* First column. */ | ||||
4865 | |||||
4866 | column = ctk_tree_view_column_new (); | ||||
4867 | ctk_tree_view_column_set_title (column, _("Folders")gettext ("Folders")); | ||||
4868 | |||||
4869 | /* icon */ | ||||
4870 | |||||
4871 | renderer = ctk_cell_renderer_pixbuf_new (); | ||||
4872 | ctk_tree_view_column_pack_start (column, renderer, FALSE(0)); | ||||
4873 | ctk_tree_view_column_set_attributes (column, renderer, | ||||
4874 | "pixbuf", TREE_COLUMN_ICON, | ||||
4875 | NULL((void*)0)); | ||||
4876 | |||||
4877 | /* name */ | ||||
4878 | |||||
4879 | renderer = ctk_cell_renderer_text_new (); | ||||
4880 | |||||
4881 | g_value_init (&value, PANGO_TYPE_ELLIPSIZE_MODE(pango_ellipsize_mode_get_type ())); | ||||
4882 | g_value_set_enum (&value, PANGO_ELLIPSIZE_END); | ||||
4883 | g_object_set_property (G_OBJECT (renderer)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((renderer)), (((GType) ((20) << (2)))))))), "ellipsize", &value); | ||||
4884 | g_value_unset (&value); | ||||
4885 | |||||
4886 | ctk_tree_view_column_pack_start (column, | ||||
4887 | renderer, | ||||
4888 | TRUE(!(0))); | ||||
4889 | ctk_tree_view_column_set_attributes (column, renderer, | ||||
4890 | "text", TREE_COLUMN_NAME, | ||||
4891 | "weight", TREE_COLUMN_WEIGHT, | ||||
4892 | NULL((void*)0)); | ||||
4893 | |||||
4894 | ctk_tree_view_column_set_sizing (column, CTK_TREE_VIEW_COLUMN_AUTOSIZE); | ||||
4895 | ctk_tree_view_column_set_sort_column_id (column, TREE_COLUMN_NAME); | ||||
4896 | |||||
4897 | ctk_tree_view_append_column (CTK_TREE_VIEW (treeview)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((treeview)), ((ctk_tree_view_get_type ())))))), column); | ||||
4898 | } | ||||
4899 | |||||
4900 | |||||
4901 | static void | ||||
4902 | add_file_list_columns (FrWindow *window, | ||||
4903 | CtkTreeView *treeview) | ||||
4904 | { | ||||
4905 | static const char *titles[] = {NC_("File", "Size")("Size"), | ||||
4906 | NC_("File", "Type")("Type"), | ||||
4907 | NC_("File", "Date Modified")("Date Modified"), | ||||
4908 | NC_("File", "Location")("Location")}; | ||||
4909 | CtkCellRenderer *renderer; | ||||
4910 | CtkTreeViewColumn *column; | ||||
4911 | GValue value = { 0, }; | ||||
4912 | int i, j, w; | ||||
4913 | |||||
4914 | /* First column. */ | ||||
4915 | |||||
4916 | window->priv->filename_column = column = ctk_tree_view_column_new (); | ||||
4917 | ctk_tree_view_column_set_title (column, C_("File", "Name")g_dpgettext (((void*)0), "File" "\004" "Name", strlen ("File" ) + 1)); | ||||
4918 | |||||
4919 | /* emblem */ | ||||
4920 | |||||
4921 | renderer = ctk_cell_renderer_pixbuf_new (); | ||||
4922 | ctk_tree_view_column_pack_end (column, renderer, FALSE(0)); | ||||
4923 | ctk_tree_view_column_set_attributes (column, renderer, | ||||
4924 | "pixbuf", COLUMN_EMBLEM, | ||||
4925 | NULL((void*)0)); | ||||
4926 | |||||
4927 | /* icon */ | ||||
4928 | |||||
4929 | renderer = ctk_cell_renderer_pixbuf_new (); | ||||
4930 | ctk_tree_view_column_pack_start (column, renderer, FALSE(0)); | ||||
4931 | ctk_tree_view_column_set_attributes (column, renderer, | ||||
4932 | "pixbuf", COLUMN_ICON, | ||||
4933 | NULL((void*)0)); | ||||
4934 | |||||
4935 | /* name */ | ||||
4936 | |||||
4937 | window->priv->single_click = is_single_click_policy (window); | ||||
4938 | |||||
4939 | renderer = ctk_cell_renderer_text_new (); | ||||
4940 | |||||
4941 | g_value_init (&value, PANGO_TYPE_ELLIPSIZE_MODE(pango_ellipsize_mode_get_type ())); | ||||
4942 | g_value_set_enum (&value, PANGO_ELLIPSIZE_END); | ||||
4943 | g_object_set_property (G_OBJECT (renderer)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((renderer)), (((GType) ((20) << (2)))))))), "ellipsize", &value); | ||||
4944 | g_value_unset (&value); | ||||
4945 | |||||
4946 | ctk_tree_view_column_pack_start (column, | ||||
4947 | renderer, | ||||
4948 | TRUE(!(0))); | ||||
4949 | ctk_tree_view_column_set_attributes (column, renderer, | ||||
4950 | "text", COLUMN_NAME, | ||||
4951 | NULL((void*)0)); | ||||
4952 | |||||
4953 | ctk_tree_view_column_set_sizing (column, CTK_TREE_VIEW_COLUMN_FIXED); | ||||
4954 | w = g_settings_get_int (window->priv->settings_listing, PREF_LISTING_NAME_COLUMN_WIDTH"name-column-width"); | ||||
4955 | if (w <= 0) | ||||
4956 | w = DEFAULT_NAME_COLUMN_WIDTH250; | ||||
4957 | ctk_tree_view_column_set_fixed_width (column, w); | ||||
4958 | ctk_tree_view_column_set_resizable (column, TRUE(!(0))); | ||||
4959 | ctk_tree_view_column_set_sort_column_id (column, COLUMN_NAME); | ||||
4960 | ctk_tree_view_column_set_cell_data_func (column, renderer, | ||||
4961 | (CtkTreeCellDataFunc) filename_cell_data_func, | ||||
4962 | window, NULL((void*)0)); | ||||
4963 | |||||
4964 | ctk_tree_view_append_column (CTK_TREE_VIEW (treeview)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((treeview)), ((ctk_tree_view_get_type ())))))), column); | ||||
4965 | |||||
4966 | /* Other columns */ | ||||
4967 | |||||
4968 | for (j = 0, i = COLUMN_SIZE; i < NUMBER_OF_COLUMNS; i++, j++) { | ||||
4969 | GValue value_oc = { 0, }; | ||||
4970 | |||||
4971 | renderer = ctk_cell_renderer_text_new (); | ||||
4972 | column = ctk_tree_view_column_new_with_attributes (g_dpgettext2 (NULL((void*)0), "File", titles[j]), | ||||
4973 | renderer, | ||||
4974 | "text", i, | ||||
4975 | NULL((void*)0)); | ||||
4976 | |||||
4977 | ctk_tree_view_column_set_sizing (column, CTK_TREE_VIEW_COLUMN_FIXED); | ||||
4978 | ctk_tree_view_column_set_fixed_width (column, OTHER_COLUMNS_WIDTH100); | ||||
4979 | ctk_tree_view_column_set_resizable (column, TRUE(!(0))); | ||||
4980 | |||||
4981 | ctk_tree_view_column_set_sort_column_id (column, i); | ||||
4982 | |||||
4983 | g_value_init (&value_oc, PANGO_TYPE_ELLIPSIZE_MODE(pango_ellipsize_mode_get_type ())); | ||||
4984 | g_value_set_enum (&value_oc, PANGO_ELLIPSIZE_END); | ||||
4985 | g_object_set_property (G_OBJECT (renderer)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((renderer)), (((GType) ((20) << (2)))))))), "ellipsize", &value_oc); | ||||
4986 | g_value_unset (&value_oc); | ||||
4987 | |||||
4988 | ctk_tree_view_append_column (treeview, column); | ||||
4989 | } | ||||
4990 | } | ||||
4991 | |||||
4992 | |||||
4993 | static int | ||||
4994 | name_column_sort_func (CtkTreeModel *model, | ||||
4995 | CtkTreeIter *a, | ||||
4996 | CtkTreeIter *b, | ||||
4997 | gpointer user_data) | ||||
4998 | { | ||||
4999 | FileData *fdata1, *fdata2; | ||||
5000 | |||||
5001 | ctk_tree_model_get (model, a, COLUMN_FILE_DATA, &fdata1, -1); | ||||
5002 | ctk_tree_model_get (model, b, COLUMN_FILE_DATA, &fdata2, -1); | ||||
5003 | |||||
5004 | return sort_by_name (&fdata1, &fdata2); | ||||
5005 | } | ||||
5006 | |||||
5007 | |||||
5008 | static int | ||||
5009 | size_column_sort_func (CtkTreeModel *model, | ||||
5010 | CtkTreeIter *a, | ||||
5011 | CtkTreeIter *b, | ||||
5012 | gpointer user_data) | ||||
5013 | { | ||||
5014 | FileData *fdata1, *fdata2; | ||||
5015 | |||||
5016 | ctk_tree_model_get (model, a, COLUMN_FILE_DATA, &fdata1, -1); | ||||
5017 | ctk_tree_model_get (model, b, COLUMN_FILE_DATA, &fdata2, -1); | ||||
5018 | |||||
5019 | return sort_by_size (&fdata1, &fdata2); | ||||
5020 | } | ||||
5021 | |||||
5022 | |||||
5023 | static int | ||||
5024 | type_column_sort_func (CtkTreeModel *model, | ||||
5025 | CtkTreeIter *a, | ||||
5026 | CtkTreeIter *b, | ||||
5027 | gpointer user_data) | ||||
5028 | { | ||||
5029 | FileData *fdata1, *fdata2; | ||||
5030 | |||||
5031 | ctk_tree_model_get (model, a, COLUMN_FILE_DATA, &fdata1, -1); | ||||
5032 | ctk_tree_model_get (model, b, COLUMN_FILE_DATA, &fdata2, -1); | ||||
5033 | |||||
5034 | return sort_by_type (&fdata1, &fdata2); | ||||
5035 | } | ||||
5036 | |||||
5037 | |||||
5038 | static int | ||||
5039 | time_column_sort_func (CtkTreeModel *model, | ||||
5040 | CtkTreeIter *a, | ||||
5041 | CtkTreeIter *b, | ||||
5042 | gpointer user_data) | ||||
5043 | { | ||||
5044 | FileData *fdata1, *fdata2; | ||||
5045 | |||||
5046 | ctk_tree_model_get (model, a, COLUMN_FILE_DATA, &fdata1, -1); | ||||
5047 | ctk_tree_model_get (model, b, COLUMN_FILE_DATA, &fdata2, -1); | ||||
5048 | |||||
5049 | return sort_by_time (&fdata1, &fdata2); | ||||
5050 | } | ||||
5051 | |||||
5052 | |||||
5053 | static int | ||||
5054 | path_column_sort_func (CtkTreeModel *model, | ||||
5055 | CtkTreeIter *a, | ||||
5056 | CtkTreeIter *b, | ||||
5057 | gpointer user_data) | ||||
5058 | { | ||||
5059 | FileData *fdata1, *fdata2; | ||||
5060 | |||||
5061 | ctk_tree_model_get (model, a, COLUMN_FILE_DATA, &fdata1, -1); | ||||
5062 | ctk_tree_model_get (model, b, COLUMN_FILE_DATA, &fdata2, -1); | ||||
5063 | |||||
5064 | return sort_by_path (&fdata1, &fdata2); | ||||
5065 | } | ||||
5066 | |||||
5067 | |||||
5068 | static int | ||||
5069 | no_sort_column_sort_func (CtkTreeModel *model, | ||||
5070 | CtkTreeIter *a, | ||||
5071 | CtkTreeIter *b, | ||||
5072 | gpointer user_data) | ||||
5073 | { | ||||
5074 | return -1; | ||||
5075 | } | ||||
5076 | |||||
5077 | |||||
5078 | static void | ||||
5079 | sort_column_changed_cb (CtkTreeSortable *sortable, | ||||
5080 | gpointer user_data) | ||||
5081 | { | ||||
5082 | FrWindow *window = user_data; | ||||
5083 | CtkSortType order; | ||||
5084 | int column_id; | ||||
5085 | |||||
5086 | if (! ctk_tree_sortable_get_sort_column_id (sortable, | ||||
5087 | &column_id, | ||||
5088 | &order)) | ||||
5089 | return; | ||||
5090 | |||||
5091 | window->priv->sort_method = get_sort_method_from_column (column_id); | ||||
5092 | window->priv->sort_type = order; | ||||
5093 | |||||
5094 | /*set_active (window, get_action_from_sort_method (window->priv->sort_method), TRUE); | ||||
5095 | set_active (window, "SortReverseOrder", (window->priv->sort_type == CTK_SORT_DESCENDING));*/ | ||||
5096 | } | ||||
5097 | |||||
5098 | |||||
5099 | static gboolean | ||||
5100 | fr_window_show_cb (CtkWidget *widget, | ||||
5101 | FrWindow *window) | ||||
5102 | { | ||||
5103 | fr_window_update_current_location (window); | ||||
5104 | |||||
5105 | set_active (window, "ViewToolbar", g_settings_get_boolean (window->priv->settings_ui, PREF_UI_VIEW_TOOLBAR"view-toolbar")); | ||||
5106 | set_active (window, "ViewStatusbar", g_settings_get_boolean (window->priv->settings_ui, PREF_UI_VIEW_STATUSBAR"view-statusbar")); | ||||
5107 | |||||
5108 | window->priv->view_folders = g_settings_get_boolean (window->priv->settings_ui, PREF_UI_VIEW_FOLDERS"view-folders"); | ||||
5109 | set_active (window, "ViewFolders", window->priv->view_folders); | ||||
5110 | |||||
5111 | fr_window_update_filter_bar_visibility (window); | ||||
5112 | |||||
5113 | return TRUE(!(0)); | ||||
5114 | } | ||||
5115 | |||||
5116 | |||||
5117 | /* preferences changes notification callbacks */ | ||||
5118 | |||||
5119 | |||||
5120 | static void | ||||
5121 | pref_history_len_changed (GSettings *settings, | ||||
5122 | const char *key, | ||||
5123 | gpointer user_data) | ||||
5124 | { | ||||
5125 | FrWindow *window = user_data; | ||||
5126 | int limit; | ||||
5127 | CtkAction *action; | ||||
5128 | |||||
5129 | limit = g_settings_get_int (settings, PREF_UI_HISTORY_LEN"history-len"); | ||||
5130 | |||||
5131 | action = ctk_action_group_get_action (window->priv->actions, "OpenRecent"); | ||||
5132 | ctk_recent_chooser_set_limit (CTK_RECENT_CHOOSER (action)((((CtkRecentChooser*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((action)), ((ctk_recent_chooser_get_type ()) ))))), limit); | ||||
5133 | |||||
5134 | action = ctk_action_group_get_action (window->priv->actions, "OpenRecent_Toolbar"); | ||||
5135 | ctk_recent_chooser_set_limit (CTK_RECENT_CHOOSER (action)((((CtkRecentChooser*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((action)), ((ctk_recent_chooser_get_type ()) ))))), limit); | ||||
5136 | } | ||||
5137 | |||||
5138 | |||||
5139 | static void | ||||
5140 | pref_view_toolbar_changed (GSettings *settings, | ||||
5141 | const char *key, | ||||
5142 | gpointer user_data) | ||||
5143 | { | ||||
5144 | FrWindow *window = user_data; | ||||
5145 | |||||
5146 | fr_window_set_toolbar_visibility (window, g_settings_get_boolean (settings, key)); | ||||
5147 | } | ||||
5148 | |||||
5149 | |||||
5150 | static void | ||||
5151 | pref_view_statusbar_changed (GSettings *settings, | ||||
5152 | const char *key, | ||||
5153 | gpointer user_data) | ||||
5154 | { | ||||
5155 | FrWindow *window = user_data; | ||||
5156 | |||||
5157 | fr_window_set_statusbar_visibility (window, g_settings_get_boolean (settings, key)); | ||||
5158 | } | ||||
5159 | |||||
5160 | |||||
5161 | static void | ||||
5162 | pref_view_folders_changed (GSettings *settings, | ||||
5163 | const char *key, | ||||
5164 | gpointer user_data) | ||||
5165 | { | ||||
5166 | FrWindow *window = user_data; | ||||
5167 | |||||
5168 | fr_window_set_folders_visibility (window, g_settings_get_boolean (settings, key)); | ||||
5169 | } | ||||
5170 | |||||
5171 | |||||
5172 | static void | ||||
5173 | pref_show_field_changed (GSettings *settings, | ||||
5174 | const char *key, | ||||
5175 | gpointer user_data) | ||||
5176 | { | ||||
5177 | FrWindow *window = user_data; | ||||
5178 | |||||
5179 | fr_window_update_columns_visibility (window); | ||||
5180 | } | ||||
5181 | |||||
5182 | |||||
5183 | static void | ||||
5184 | pref_click_policy_changed (GSettings *settings, | ||||
5185 | const char *key, | ||||
5186 | gpointer user_data) | ||||
5187 | { | ||||
5188 | FrWindow *window = user_data; | ||||
5189 | 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 ()))))))); | ||||
5190 | CdkDisplay *display; | ||||
5191 | |||||
5192 | window->priv->single_click = is_single_click_policy (window); | ||||
5193 | |||||
5194 | cdk_window_set_cursor (win, NULL((void*)0)); | ||||
5195 | 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 ( )))))))); | ||||
5196 | if (display != NULL((void*)0)) | ||||
5197 | cdk_display_flush (display); | ||||
5198 | } | ||||
5199 | |||||
5200 | |||||
5201 | static void | ||||
5202 | pref_use_mime_icons_changed (GSettings *settings, | ||||
5203 | const char *key, | ||||
5204 | gpointer user_data) | ||||
5205 | { | ||||
5206 | FrWindow *window = user_data; | ||||
5207 | |||||
5208 | if (pixbuf_hash != NULL((void*)0)) { | ||||
5209 | g_hash_table_foreach (pixbuf_hash, | ||||
5210 | gh_unref_pixbuf, | ||||
5211 | NULL((void*)0)); | ||||
5212 | g_hash_table_destroy (pixbuf_hash); | ||||
5213 | pixbuf_hash = g_hash_table_new (g_str_hash, g_str_equal); | ||||
5214 | } | ||||
5215 | if (tree_pixbuf_hash != NULL((void*)0)) { | ||||
5216 | g_hash_table_foreach (tree_pixbuf_hash, | ||||
5217 | gh_unref_pixbuf, | ||||
5218 | NULL((void*)0)); | ||||
5219 | g_hash_table_destroy (tree_pixbuf_hash); | ||||
5220 | tree_pixbuf_hash = g_hash_table_new (g_str_hash, g_str_equal); | ||||
5221 | } | ||||
5222 | |||||
5223 | fr_window_update_file_list (window, FALSE(0)); | ||||
5224 | fr_window_update_dir_tree (window); | ||||
5225 | } | ||||
5226 | |||||
5227 | |||||
5228 | static void | ||||
5229 | theme_changed_cb (CtkIconTheme *theme, FrWindow *window) | ||||
5230 | { | ||||
5231 | 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); | ||||
5232 | 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); | ||||
5233 | |||||
5234 | if (pixbuf_hash != NULL((void*)0)) { | ||||
5235 | g_hash_table_foreach (pixbuf_hash, | ||||
5236 | gh_unref_pixbuf, | ||||
5237 | NULL((void*)0)); | ||||
5238 | g_hash_table_destroy (pixbuf_hash); | ||||
5239 | pixbuf_hash = g_hash_table_new (g_str_hash, g_str_equal); | ||||
5240 | } | ||||
5241 | if (tree_pixbuf_hash != NULL((void*)0)) { | ||||
5242 | g_hash_table_foreach (tree_pixbuf_hash, | ||||
5243 | gh_unref_pixbuf, | ||||
5244 | NULL((void*)0)); | ||||
5245 | g_hash_table_destroy (tree_pixbuf_hash); | ||||
5246 | tree_pixbuf_hash = g_hash_table_new (g_str_hash, g_str_equal); | ||||
5247 | } | ||||
5248 | |||||
5249 | fr_window_update_file_list (window, TRUE(!(0))); | ||||
5250 | fr_window_update_dir_tree (window); | ||||
5251 | } | ||||
5252 | |||||
5253 | |||||
5254 | static gboolean | ||||
5255 | fr_window_stoppable_cb (FrCommand *command, | ||||
5256 | gboolean stoppable, | ||||
5257 | FrWindow *window) | ||||
5258 | { | ||||
5259 | window->priv->stoppable = stoppable; | ||||
5260 | set_sensitive (window, "Stop", stoppable); | ||||
5261 | if (window->priv->progress_dialog != NULL((void*)0)) | ||||
5262 | 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 ())))))), | ||||
5263 | CTK_RESPONSE_OK, | ||||
5264 | stoppable); | ||||
5265 | return TRUE(!(0)); | ||||
5266 | } | ||||
5267 | |||||
5268 | |||||
5269 | static gboolean | ||||
5270 | fr_window_fake_load (FrArchive *archive, | ||||
5271 | gpointer data) | ||||
5272 | { | ||||
5273 | /* fake loads are disabled to allow exact progress dialogs (#153281) */ | ||||
5274 | |||||
5275 | return FALSE(0); | ||||
5276 | |||||
5277 | #if 0 | ||||
5278 | FrWindow *window = data; | ||||
5279 | gboolean add_after_opening = FALSE(0); | ||||
5280 | gboolean extract_after_opening = FALSE(0); | ||||
5281 | GList *scan; | ||||
5282 | |||||
5283 | /* fake loads are used only in batch mode to avoid unnecessary | ||||
5284 | * archive loadings. */ | ||||
5285 | |||||
5286 | if (! window->priv->batch_mode) | ||||
5287 | return FALSE(0); | ||||
5288 | |||||
5289 | /* Check whether there is an ADD or EXTRACT action in the batch list. */ | ||||
5290 | |||||
5291 | for (scan = window->priv->batch_action; scan; scan = scan->next) { | ||||
5292 | FRBatchAction *action; | ||||
5293 | |||||
5294 | action = (FRBatchAction *) scan->data; | ||||
5295 | if (action->type == FR_BATCH_ACTION_ADD) { | ||||
5296 | add_after_opening = TRUE(!(0)); | ||||
5297 | break; | ||||
5298 | } | ||||
5299 | if ((action->type == FR_BATCH_ACTION_EXTRACT) | ||||
5300 | || (action->type == FR_BATCH_ACTION_EXTRACT_HERE) | ||||
5301 | || (action->type == FR_BATCH_ACTION_EXTRACT_INTERACT)) | ||||
5302 | { | ||||
5303 | extract_after_opening = TRUE(!(0)); | ||||
5304 | break; | ||||
5305 | } | ||||
5306 | } | ||||
5307 | |||||
5308 | /* use fake load when in batch mode and the archive type supports all | ||||
5309 | * of the required features */ | ||||
5310 | |||||
5311 | return (window->priv->batch_mode | ||||
5312 | && ! (add_after_opening && window->priv->update_dropped_files && ! archive->command->propAddCanUpdate) | ||||
5313 | && ! (add_after_opening && ! window->priv->update_dropped_files && ! archive->command->propAddCanReplace) | ||||
5314 | && ! (extract_after_opening && !archive->command->propCanExtractAll)); | ||||
5315 | #endif | ||||
5316 | } | ||||
5317 | |||||
5318 | |||||
5319 | static void | ||||
5320 | menu_item_select_cb (CtkMenuItem *proxy, | ||||
5321 | FrWindow *window) | ||||
5322 | { | ||||
5323 | CtkAction *action; | ||||
5324 | char *message; | ||||
5325 | |||||
5326 | action = ctk_activatable_get_related_action (CTK_ACTIVATABLE (proxy)((((CtkActivatable*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((proxy)), ((ctk_activatable_get_type ()))))))); | ||||
5327 | 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); | ||||
5328 | |||||
5329 | g_object_get (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), (((GType) ((20) << (2)))))))), "tooltip", &message, NULL((void*)0)); | ||||
5330 | if (message) { | ||||
5331 | ctk_statusbar_push (CTK_STATUSBAR (window->priv->statusbar)((((CtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->statusbar)), ((ctk_statusbar_get_type ())))))), | ||||
5332 | window->priv->help_message_cid, message); | ||||
5333 | g_free (message); | ||||
5334 | } | ||||
5335 | } | ||||
5336 | |||||
5337 | |||||
5338 | static void | ||||
5339 | menu_item_deselect_cb (CtkMenuItem *proxy, | ||||
5340 | FrWindow *window) | ||||
5341 | { | ||||
5342 | ctk_statusbar_pop (CTK_STATUSBAR (window->priv->statusbar)((((CtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->statusbar)), ((ctk_statusbar_get_type ())))))), | ||||
5343 | window->priv->help_message_cid); | ||||
5344 | } | ||||
5345 | |||||
5346 | |||||
5347 | static void | ||||
5348 | disconnect_proxy_cb (CtkUIManager *manager, | ||||
5349 | CtkAction *action, | ||||
5350 | CtkWidget *proxy, | ||||
5351 | FrWindow *window) | ||||
5352 | { | ||||
5353 | 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; }))))) { | ||||
5354 | 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)) | ||||
5355 | (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)); | ||||
5356 | 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)) | ||||
5357 | (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)); | ||||
5358 | } | ||||
5359 | } | ||||
5360 | |||||
5361 | |||||
5362 | static void | ||||
5363 | connect_proxy_cb (CtkUIManager *manager, | ||||
5364 | CtkAction *action, | ||||
5365 | CtkWidget *proxy, | ||||
5366 | FrWindow *window) | ||||
5367 | { | ||||
5368 | 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; }))))) { | ||||
5369 | g_signal_connect (proxy, "select",g_signal_connect_data ((proxy), ("select"), (((GCallback) (menu_item_select_cb ))), (window), ((void*)0), (GConnectFlags) 0) | ||||
5370 | G_CALLBACK (menu_item_select_cb), window)g_signal_connect_data ((proxy), ("select"), (((GCallback) (menu_item_select_cb ))), (window), ((void*)0), (GConnectFlags) 0); | ||||
5371 | g_signal_connect (proxy, "deselect",g_signal_connect_data ((proxy), ("deselect"), (((GCallback) ( menu_item_deselect_cb))), (window), ((void*)0), (GConnectFlags ) 0) | ||||
5372 | G_CALLBACK (menu_item_deselect_cb), window)g_signal_connect_data ((proxy), ("deselect"), (((GCallback) ( menu_item_deselect_cb))), (window), ((void*)0), (GConnectFlags ) 0); | ||||
5373 | } | ||||
5374 | } | ||||
5375 | |||||
5376 | |||||
5377 | static void | ||||
5378 | view_as_radio_action (CtkAction *action, | ||||
5379 | CtkRadioAction *current, | ||||
5380 | gpointer data) | ||||
5381 | { | ||||
5382 | FrWindow *window = data; | ||||
5383 | fr_window_set_list_mode (window, ctk_radio_action_get_current_value (current)); | ||||
5384 | } | ||||
5385 | |||||
5386 | |||||
5387 | static void | ||||
5388 | sort_by_radio_action (CtkAction *action, | ||||
5389 | CtkRadioAction *current, | ||||
5390 | gpointer data) | ||||
5391 | { | ||||
5392 | FrWindow *window = data; | ||||
5393 | |||||
5394 | window->priv->sort_method = ctk_radio_action_get_current_value (current); | ||||
5395 | window->priv->sort_type = CTK_SORT_ASCENDING; | ||||
5396 | fr_window_update_list_order (window); | ||||
5397 | } | ||||
5398 | |||||
5399 | |||||
5400 | static void | ||||
5401 | recent_chooser_item_activated_cb (CtkRecentChooser *chooser, | ||||
5402 | FrWindow *window) | ||||
5403 | { | ||||
5404 | char *uri; | ||||
5405 | |||||
5406 | uri = ctk_recent_chooser_get_current_uri (chooser); | ||||
5407 | if (uri != NULL((void*)0)) { | ||||
5408 | fr_window_archive_open (window, uri, CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ()))))))); | ||||
5409 | g_free (uri); | ||||
5410 | } | ||||
5411 | } | ||||
5412 | |||||
5413 | |||||
5414 | static void | ||||
5415 | fr_window_init_recent_chooser (FrWindow *window, | ||||
5416 | CtkRecentChooser *chooser) | ||||
5417 | { | ||||
5418 | CtkRecentFilter *filter; | ||||
5419 | int i; | ||||
5420 | |||||
5421 | 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); | ||||
5422 | |||||
5423 | filter = ctk_recent_filter_new (); | ||||
5424 | ctk_recent_filter_set_name (filter, _("All archives")gettext ("All archives")); | ||||
5425 | for (i = 0; open_type[i] != -1; i++) | ||||
5426 | ctk_recent_filter_add_mime_type (filter, mime_type_desc[open_type[i]].mime_type); | ||||
5427 | ctk_recent_filter_add_application (filter, "Grapa"); | ||||
5428 | ctk_recent_chooser_add_filter (chooser, filter); | ||||
5429 | |||||
5430 | ctk_recent_chooser_set_local_only (chooser, FALSE(0)); | ||||
5431 | ctk_recent_chooser_set_limit (chooser, g_settings_get_int (window->priv->settings_ui, PREF_UI_HISTORY_LEN"history-len")); | ||||
5432 | ctk_recent_chooser_set_show_not_found (chooser, TRUE(!(0))); | ||||
5433 | ctk_recent_chooser_set_sort_type (chooser, CTK_RECENT_SORT_MRU); | ||||
5434 | |||||
5435 | 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) | ||||
5436 | "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) | ||||
5437 | 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) | ||||
5438 | 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); | ||||
5439 | } | ||||
5440 | |||||
5441 | |||||
5442 | static void | ||||
5443 | close_sidepane_button_clicked_cb (CtkButton *button, | ||||
5444 | FrWindow *window) | ||||
5445 | { | ||||
5446 | fr_window_set_folders_visibility (window, FALSE(0)); | ||||
5447 | } | ||||
5448 | |||||
5449 | |||||
5450 | static void | ||||
5451 | fr_window_activate_filter (FrWindow *window) | ||||
5452 | { | ||||
5453 | 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 ())))))); | ||||
5454 | CtkTreeViewColumn *column; | ||||
5455 | |||||
5456 | fr_window_update_filter_bar_visibility (window); | ||||
5457 | window->priv->list_mode = FR_WINDOW_LIST_MODE_FLAT; | ||||
5458 | |||||
5459 | ctk_list_store_clear (window->priv->list_store); | ||||
5460 | |||||
5461 | column = ctk_tree_view_get_column (tree_view, 4); | ||||
5462 | ctk_tree_view_column_set_visible (column, TRUE(!(0))); | ||||
5463 | |||||
5464 | fr_window_update_file_list (window, TRUE(!(0))); | ||||
5465 | fr_window_update_dir_tree (window); | ||||
5466 | fr_window_update_current_location (window); | ||||
5467 | } | ||||
5468 | |||||
5469 | |||||
5470 | static void | ||||
5471 | filter_entry_activate_cb (CtkEntry *entry, | ||||
5472 | FrWindow *window) | ||||
5473 | { | ||||
5474 | fr_window_activate_filter (window); | ||||
5475 | } | ||||
5476 | |||||
5477 | |||||
5478 | static void | ||||
5479 | filter_entry_icon_release_cb (CtkEntry *entry, | ||||
5480 | CtkEntryIconPosition icon_pos, | ||||
5481 | CdkEventButton *event, | ||||
5482 | gpointer user_data) | ||||
5483 | { | ||||
5484 | FrWindow *window = FR_WINDOW (user_data)((((FrWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((user_data)), ((fr_window_get_type ())))))); | ||||
5485 | |||||
5486 | if ((event->button == 1) && (icon_pos == CTK_ENTRY_ICON_SECONDARY)) | ||||
5487 | fr_window_deactivate_filter (window); | ||||
5488 | } | ||||
5489 | |||||
5490 | |||||
5491 | static void | ||||
5492 | fr_window_attach (FrWindow *window, | ||||
5493 | CtkWidget *child, | ||||
5494 | FrWindowArea area) | ||||
5495 | { | ||||
5496 | int position; | ||||
5497 | |||||
5498 | 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); | ||||
5499 | 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 ); | ||||
5500 | 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); | ||||
5501 | 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 ); | ||||
5502 | |||||
5503 | switch (area) { | ||||
5504 | case FR_WINDOW_AREA_MENUBAR: | ||||
5505 | position = 0; | ||||
5506 | break; | ||||
5507 | case FR_WINDOW_AREA_TOOLBAR: | ||||
5508 | position = 1; | ||||
5509 | break; | ||||
5510 | case FR_WINDOW_AREA_LOCATIONBAR: | ||||
5511 | position = 2; | ||||
5512 | break; | ||||
5513 | case FR_WINDOW_AREA_CONTENTS: | ||||
5514 | position = 3; | ||||
5515 | if (window->priv->contents != NULL((void*)0)) | ||||
5516 | ctk_widget_destroy (window->priv->contents); | ||||
5517 | window->priv->contents = child; | ||||
5518 | ctk_widget_set_vexpand (child, TRUE(!(0))); | ||||
5519 | break; | ||||
5520 | case FR_WINDOW_AREA_FILTERBAR: | ||||
5521 | position = 4; | ||||
5522 | break; | ||||
5523 | case FR_WINDOW_AREA_STATUSBAR: | ||||
5524 | position = 5; | ||||
5525 | break; | ||||
5526 | default: | ||||
5527 | g_critical ("%s: area not recognized!", G_STRFUNC((const char*) (__func__))); | ||||
5528 | return; | ||||
5529 | break; | ||||
5530 | } | ||||
5531 | |||||
5532 | ctk_widget_set_hexpand (child, TRUE(!(0))); | ||||
5533 | ctk_grid_attach (CTK_GRID (window->priv->layout)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->layout)), ((ctk_grid_get_type ())))) )), | ||||
5534 | child, | ||||
5535 | 0, position, | ||||
5536 | 1, 1); | ||||
5537 | } | ||||
5538 | |||||
5539 | |||||
5540 | static void | ||||
5541 | set_action_important (CtkUIManager *ui, | ||||
5542 | const char *action_name) | ||||
5543 | { | ||||
5544 | CtkAction *action; | ||||
5545 | |||||
5546 | action = ctk_ui_manager_get_action (ui, action_name); | ||||
5547 | g_object_set (action, "is_important", TRUE(!(0)), NULL((void*)0)); | ||||
5548 | g_object_unref (action); | ||||
5549 | } | ||||
5550 | |||||
5551 | |||||
5552 | static void | ||||
5553 | fr_window_construct (FrWindow *window) | ||||
5554 | { | ||||
5555 | CtkWidget *menubar; | ||||
5556 | CtkWidget *toolbar; | ||||
5557 | CtkWidget *list_scrolled_window; | ||||
5558 | CtkWidget *location_box; | ||||
5559 | CtkStatusbar *statusbar; | ||||
5560 | CtkWidget *statusbar_box; | ||||
5561 | CtkWidget *filter_box; | ||||
5562 | CtkWidget *tree_scrolled_window; | ||||
5563 | CtkWidget *sidepane_title; | ||||
5564 | CtkWidget *sidepane_title_box; | ||||
5565 | CtkWidget *sidepane_title_label; | ||||
5566 | CtkWidget *close_sidepane_button; | ||||
5567 | CtkTreeSelection *selection; | ||||
5568 | CtkActionGroup *actions; | ||||
5569 | CtkAction *action; | ||||
5570 | CtkUIManager *ui; | ||||
5571 | GError *error = NULL((void*)0); | ||||
5572 | GSettingsSchemaSource *schema_source; | ||||
5573 | GSettingsSchema *baul_schema; | ||||
5574 | |||||
5575 | /* data common to all windows. */ | ||||
5576 | |||||
5577 | if (pixbuf_hash == NULL((void*)0)) | ||||
5578 | pixbuf_hash = g_hash_table_new (g_str_hash, g_str_equal); | ||||
5579 | if (tree_pixbuf_hash == NULL((void*)0)) | ||||
5580 | tree_pixbuf_hash = g_hash_table_new (g_str_hash, g_str_equal); | ||||
5581 | |||||
5582 | if (icon_theme == NULL((void*)0)) | ||||
5583 | icon_theme = ctk_icon_theme_get_default (); | ||||
5584 | |||||
5585 | /* Create the settings objects */ | ||||
5586 | |||||
5587 | window->priv->settings_listing = g_settings_new (GRAPA_SCHEMA_LISTING"org.cafe.grapa" ".listing"); | ||||
5588 | window->priv->settings_ui = g_settings_new (GRAPA_SCHEMA_UI"org.cafe.grapa" ".ui"); | ||||
5589 | window->priv->settings_general = g_settings_new (GRAPA_SCHEMA_GENERAL"org.cafe.grapa" ".general"); | ||||
5590 | window->priv->settings_dialogs = g_settings_new (GRAPA_SCHEMA_DIALOGS"org.cafe.grapa" ".dialogs"); | ||||
5591 | |||||
5592 | schema_source = g_settings_schema_source_get_default (); | ||||
5593 | baul_schema = g_settings_schema_source_lookup (schema_source, BAUL_SCHEMA"org.cafe.baul.preferences", FALSE(0)); | ||||
5594 | if (baul_schema) { | ||||
5595 | window->priv->settings_baul = g_settings_new (BAUL_SCHEMA"org.cafe.baul.preferences"); | ||||
5596 | g_settings_schema_unref (baul_schema); | ||||
5597 | } | ||||
5598 | |||||
5599 | /* Create the application. */ | ||||
5600 | |||||
5601 | window->priv->layout = ctk_grid_new (); | ||||
5602 | ctk_container_add (CTK_CONTAINER (window)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_container_get_type ())))))), window->priv->layout); | ||||
5603 | ctk_widget_show (window->priv->layout); | ||||
5604 | |||||
5605 | 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")); | ||||
5606 | |||||
5607 | 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) | ||||
5608 | "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) | ||||
5609 | 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) | ||||
5610 | 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); | ||||
5611 | |||||
5612 | 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) | ||||
5613 | "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) | ||||
5614 | 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) | ||||
5615 | 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); | ||||
5616 | |||||
5617 | window->priv->theme_changed_handler_id = | ||||
5618 | g_signal_connect (icon_theme,g_signal_connect_data ((icon_theme), ("changed"), (((GCallback ) (theme_changed_cb))), (window), ((void*)0), (GConnectFlags) 0) | ||||
5619 | "changed",g_signal_connect_data ((icon_theme), ("changed"), (((GCallback ) (theme_changed_cb))), (window), ((void*)0), (GConnectFlags) 0) | ||||
5620 | G_CALLBACK (theme_changed_cb),g_signal_connect_data ((icon_theme), ("changed"), (((GCallback ) (theme_changed_cb))), (window), ((void*)0), (GConnectFlags) 0) | ||||
5621 | window)g_signal_connect_data ((icon_theme), ("changed"), (((GCallback ) (theme_changed_cb))), (window), ((void*)0), (GConnectFlags) 0); | ||||
5622 | |||||
5623 | 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); | ||||
5624 | 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); | ||||
5625 | |||||
5626 | ctk_window_set_default_size (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), | ||||
5627 | g_settings_get_int (window->priv->settings_ui, PREF_UI_WINDOW_WIDTH"window-width"), | ||||
5628 | g_settings_get_int (window->priv->settings_ui, PREF_UI_WINDOW_HEIGHT"window-height")); | ||||
5629 | |||||
5630 | ctk_drag_dest_set (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))), | ||||
5631 | CTK_DEST_DEFAULT_ALL, | ||||
5632 | target_table, G_N_ELEMENTS (target_table)(sizeof (target_table) / sizeof ((target_table)[0])), | ||||
5633 | CDK_ACTION_COPY); | ||||
5634 | |||||
5635 | 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) | ||||
5636 | "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) | ||||
5637 | 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) | ||||
5638 | 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); | ||||
5639 | 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) | ||||
5640 | "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) | ||||
5641 | 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) | ||||
5642 | 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); | ||||
5643 | |||||
5644 | 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) | ||||
5645 | "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) | ||||
5646 | 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) | ||||
5647 | 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); | ||||
5648 | |||||
5649 | /* Initialize Data. */ | ||||
5650 | |||||
5651 | window->archive = fr_archive_new (); | ||||
5652 | 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) | ||||
5653 | "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) | ||||
5654 | 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) | ||||
5655 | 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); | ||||
5656 | 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) | ||||
5657 | "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) | ||||
5658 | 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) | ||||
5659 | 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); | ||||
5660 | 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) | ||||
5661 | "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) | ||||
5662 | 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) | ||||
5663 | 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); | ||||
5664 | 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) | ||||
5665 | "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) | ||||
5666 | 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) | ||||
5667 | 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); | ||||
5668 | 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) | ||||
5669 | "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) | ||||
5670 | 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) | ||||
5671 | 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); | ||||
5672 | 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) | ||||
5673 | "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) | ||||
5674 | 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) | ||||
5675 | 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); | ||||
5676 | |||||
5677 | fr_archive_set_fake_load_func (window->archive, | ||||
5678 | fr_window_fake_load, | ||||
5679 | window); | ||||
5680 | |||||
5681 | window->priv->sort_method = g_settings_get_enum (window->priv->settings_listing, PREF_LISTING_SORT_METHOD"sort-method"); | ||||
5682 | window->priv->sort_type = g_settings_get_enum (window->priv->settings_listing, PREF_LISTING_SORT_TYPE"sort-type"); | ||||
5683 | |||||
5684 | window->priv->list_mode = window->priv->last_list_mode = g_settings_get_enum (window->priv->settings_listing, PREF_LISTING_LIST_MODE"list-mode"); | ||||
5685 | g_settings_set_boolean (window->priv->settings_listing, PREF_LISTING_SHOW_PATH"show-path", (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT)); | ||||
5686 | |||||
5687 | window->priv->history = NULL((void*)0); | ||||
5688 | window->priv->history_current = NULL((void*)0); | ||||
5689 | |||||
5690 | window->priv->action = FR_ACTION_NONE; | ||||
5691 | |||||
5692 | window->priv->open_default_dir = g_strdup (get_home_uri ())g_strdup_inline (get_home_uri ()); | ||||
5693 | window->priv->add_default_dir = g_strdup (get_home_uri ())g_strdup_inline (get_home_uri ()); | ||||
5694 | window->priv->extract_default_dir = g_strdup (get_home_uri ())g_strdup_inline (get_home_uri ()); | ||||
5695 | |||||
5696 | window->priv->give_focus_to_the_list = FALSE(0); | ||||
5697 | |||||
5698 | window->priv->activity_ref = 0; | ||||
5699 | window->priv->activity_timeout_handle = 0; | ||||
5700 | |||||
5701 | window->priv->update_timeout_handle = 0; | ||||
5702 | |||||
5703 | window->priv->archive_present = FALSE(0); | ||||
5704 | window->priv->archive_new = FALSE(0); | ||||
5705 | window->priv->archive_uri = NULL((void*)0); | ||||
5706 | |||||
5707 | window->priv->drag_destination_folder = NULL((void*)0); | ||||
5708 | window->priv->drag_base_dir = NULL((void*)0); | ||||
5709 | window->priv->drag_error = NULL((void*)0); | ||||
5710 | window->priv->drag_file_list = NULL((void*)0); | ||||
5711 | |||||
5712 | window->priv->batch_mode = FALSE(0); | ||||
5713 | window->priv->batch_action_list = NULL((void*)0); | ||||
5714 | window->priv->batch_action = NULL((void*)0); | ||||
5715 | window->priv->extract_interact_use_default_dir = FALSE(0); | ||||
5716 | window->priv->non_interactive = FALSE(0); | ||||
5717 | |||||
5718 | window->priv->password = NULL((void*)0); | ||||
5719 | window->priv->compression = g_settings_get_enum (window->priv->settings_general, PREF_GENERAL_COMPRESSION_LEVEL"compression-level"); | ||||
5720 | window->priv->encrypt_header = g_settings_get_boolean (window->priv->settings_general, PREF_GENERAL_ENCRYPT_HEADER"encrypt-header"); | ||||
5721 | window->priv->volume_size = 0; | ||||
5722 | |||||
5723 | window->priv->convert_data.converting = FALSE(0); | ||||
5724 | window->priv->convert_data.temp_dir = NULL((void*)0); | ||||
5725 | window->priv->convert_data.new_archive = NULL((void*)0); | ||||
5726 | window->priv->convert_data.password = NULL((void*)0); | ||||
5727 | window->priv->convert_data.encrypt_header = FALSE(0); | ||||
5728 | window->priv->convert_data.volume_size = 0; | ||||
5729 | |||||
5730 | window->priv->stoppable = TRUE(!(0)); | ||||
5731 | |||||
5732 | window->priv->batch_adding_one_file = FALSE(0); | ||||
5733 | |||||
5734 | window->priv->path_clicked = NULL((void*)0); | ||||
5735 | |||||
5736 | window->priv->current_view_length = 0; | ||||
5737 | |||||
5738 | window->priv->current_batch_action.type = FR_BATCH_ACTION_NONE; | ||||
5739 | window->priv->current_batch_action.data = NULL((void*)0); | ||||
5740 | window->priv->current_batch_action.free_func = NULL((void*)0); | ||||
5741 | |||||
5742 | window->priv->pd_last_archive = NULL((void*)0); | ||||
5743 | window->priv->pd_last_message = NULL((void*)0); | ||||
5744 | window->priv->pd_last_fraction = 0.0; | ||||
5745 | |||||
5746 | /* Create the widgets. */ | ||||
5747 | |||||
5748 | /* * File list. */ | ||||
5749 | |||||
5750 | window->priv->list_store = fr_list_model_new (NUMBER_OF_COLUMNS, | ||||
5751 | G_TYPE_POINTER((GType) ((17) << (2))), | ||||
5752 | GDK_TYPE_PIXBUF(gdk_pixbuf_get_type ()), | ||||
5753 | G_TYPE_STRING((GType) ((16) << (2))), | ||||
5754 | GDK_TYPE_PIXBUF(gdk_pixbuf_get_type ()), | ||||
5755 | G_TYPE_STRING((GType) ((16) << (2))), | ||||
5756 | G_TYPE_STRING((GType) ((16) << (2))), | ||||
5757 | G_TYPE_STRING((GType) ((16) << (2))), | ||||
5758 | G_TYPE_STRING((GType) ((16) << (2)))); | ||||
5759 | 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); | ||||
5760 | 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 ()))))))); | ||||
5761 | |||||
5762 | 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 ()))))))); | ||||
5763 | 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 ())))))), | ||||
5764 | TRUE(!(0))); | ||||
5765 | 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 ())))))), | ||||
5766 | COLUMN_NAME); | ||||
5767 | |||||
5768 | 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 ())))))), | ||||
5769 | COLUMN_NAME, name_column_sort_func, | ||||
5770 | NULL((void*)0), NULL((void*)0)); | ||||
5771 | 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 ())))))), | ||||
5772 | COLUMN_SIZE, size_column_sort_func, | ||||
5773 | NULL((void*)0), NULL((void*)0)); | ||||
5774 | 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 ())))))), | ||||
5775 | COLUMN_TYPE, type_column_sort_func, | ||||
5776 | NULL((void*)0), NULL((void*)0)); | ||||
5777 | 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 ())))))), | ||||
5778 | COLUMN_TIME, time_column_sort_func, | ||||
5779 | NULL((void*)0), NULL((void*)0)); | ||||
5780 | 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 ())))))), | ||||
5781 | COLUMN_PATH, path_column_sort_func, | ||||
5782 | NULL((void*)0), NULL((void*)0)); | ||||
5783 | |||||
5784 | 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 ())))))), | ||||
5785 | no_sort_column_sort_func, | ||||
5786 | NULL((void*)0), NULL((void*)0)); | ||||
5787 | |||||
5788 | 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 ()))))))); | ||||
5789 | ctk_tree_selection_set_mode (selection, CTK_SELECTION_MULTIPLE); | ||||
5790 | |||||
5791 | g_signal_connect (selection,g_signal_connect_data ((selection), ("changed"), (((GCallback ) (selection_changed_cb))), (window), ((void*)0), (GConnectFlags ) 0) | ||||
5792 | "changed",g_signal_connect_data ((selection), ("changed"), (((GCallback ) (selection_changed_cb))), (window), ((void*)0), (GConnectFlags ) 0) | ||||
5793 | G_CALLBACK (selection_changed_cb),g_signal_connect_data ((selection), ("changed"), (((GCallback ) (selection_changed_cb))), (window), ((void*)0), (GConnectFlags ) 0) | ||||
5794 | window)g_signal_connect_data ((selection), ("changed"), (((GCallback ) (selection_changed_cb))), (window), ((void*)0), (GConnectFlags ) 0); | ||||
5795 | 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) | ||||
5796 | "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) | ||||
5797 | 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) | ||||
5798 | 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); | ||||
5799 | |||||
5800 | 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) | ||||
5801 | "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) | ||||
5802 | 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) | ||||
5803 | 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); | ||||
5804 | 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) | ||||
5805 | "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) | ||||
5806 | 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) | ||||
5807 | 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); | ||||
5808 | 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) | ||||
5809 | "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) | ||||
5810 | 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) | ||||
5811 | 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); | ||||
5812 | 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) | ||||
5813 | "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) | ||||
5814 | 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) | ||||
5815 | 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); | ||||
5816 | |||||
5817 | 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) | ||||
5818 | "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) | ||||
5819 | 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) | ||||
5820 | 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); | ||||
5821 | |||||
5822 | 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) | ||||
5823 | "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) | ||||
5824 | 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) | ||||
5825 | 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); | ||||
5826 | 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) | ||||
5827 | "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) | ||||
5828 | 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) | ||||
5829 | 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); | ||||
5830 | 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 ()))))))); | ||||
5831 | |||||
5832 | list_scrolled_window = ctk_scrolled_window_new (NULL((void*)0), NULL((void*)0)); | ||||
5833 | 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 ())))))), | ||||
5834 | CTK_POLICY_AUTOMATIC, | ||||
5835 | CTK_POLICY_AUTOMATIC); | ||||
5836 | 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 ())))))), | ||||
5837 | CTK_SHADOW_IN); | ||||
5838 | 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); | ||||
5839 | |||||
5840 | /* filter bar */ | ||||
5841 | |||||
5842 | window->priv->filter_bar = filter_box = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 6); | ||||
5843 | ctk_container_set_border_width (CTK_CONTAINER (filter_box)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((filter_box)), ((ctk_container_get_type ())))))), 3); | ||||
5844 | 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); | ||||
5845 | |||||
5846 | ctk_box_pack_start (CTK_BOX (filter_box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((filter_box)), ((ctk_box_get_type ())))))), | ||||
5847 | ctk_label_new (_("Find:")gettext ("Find:")), FALSE(0), FALSE(0), 0); | ||||
5848 | |||||
5849 | /* * filter entry */ | ||||
5850 | |||||
5851 | window->priv->filter_entry = CTK_WIDGET (ctk_entry_new ())((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_entry_new ())), ((ctk_widget_get_type ())))))); | ||||
5852 | 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 ())))))), | ||||
5853 | CTK_ENTRY_ICON_SECONDARY, | ||||
5854 | "edit-clear"); | ||||
5855 | |||||
5856 | ctk_widget_set_size_request (window->priv->filter_entry, 300, -1); | ||||
5857 | ctk_box_pack_start (CTK_BOX (filter_box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((filter_box)), ((ctk_box_get_type ())))))), | ||||
5858 | window->priv->filter_entry, FALSE(0), FALSE(0), 6); | ||||
5859 | |||||
5860 | 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) | ||||
5861 | "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) | ||||
5862 | 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) | ||||
5863 | 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); | ||||
5864 | 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) | ||||
5865 | "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) | ||||
5866 | 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) | ||||
5867 | 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); | ||||
5868 | |||||
5869 | ctk_widget_show_all (filter_box); | ||||
5870 | |||||
5871 | /* tree view */ | ||||
5872 | |||||
5873 | window->priv->tree_store = ctk_tree_store_new (TREE_NUMBER_OF_COLUMNS, | ||||
5874 | G_TYPE_STRING((GType) ((16) << (2))), | ||||
5875 | GDK_TYPE_PIXBUF(gdk_pixbuf_get_type ()), | ||||
5876 | G_TYPE_STRING((GType) ((16) << (2))), | ||||
5877 | PANGO_TYPE_WEIGHT(pango_weight_get_type ())); | ||||
5878 | 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 ()))))))); | ||||
5879 | 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)); | ||||
5880 | 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 ()))))))); | ||||
5881 | |||||
5882 | 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) | ||||
5883 | "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) | ||||
5884 | 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) | ||||
5885 | 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); | ||||
5886 | |||||
5887 | 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 ()))))))); | ||||
5888 | g_signal_connect (selection,g_signal_connect_data ((selection), ("changed"), (((GCallback ) (dir_tree_selection_changed_cb))), (window), ((void*)0), (GConnectFlags ) 0) | ||||
5889 | "changed",g_signal_connect_data ((selection), ("changed"), (((GCallback ) (dir_tree_selection_changed_cb))), (window), ((void*)0), (GConnectFlags ) 0) | ||||
5890 | G_CALLBACK (dir_tree_selection_changed_cb),g_signal_connect_data ((selection), ("changed"), (((GCallback ) (dir_tree_selection_changed_cb))), (window), ((void*)0), (GConnectFlags ) 0) | ||||
5891 | window)g_signal_connect_data ((selection), ("changed"), (((GCallback ) (dir_tree_selection_changed_cb))), (window), ((void*)0), (GConnectFlags ) 0); | ||||
5892 | |||||
5893 | 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) | ||||
5894 | "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) | ||||
5895 | 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) | ||||
5896 | 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); | ||||
5897 | 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) | ||||
5898 | "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) | ||||
5899 | 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) | ||||
5900 | 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); | ||||
5901 | 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) | ||||
5902 | "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) | ||||
5903 | 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) | ||||
5904 | 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); | ||||
5905 | ctk_drag_source_set (window->priv->tree_view, | ||||
5906 | CDK_BUTTON1_MASK, | ||||
5907 | folder_tree_targets, G_N_ELEMENTS (folder_tree_targets)(sizeof (folder_tree_targets) / sizeof ((folder_tree_targets) [0])), | ||||
5908 | CDK_ACTION_COPY); | ||||
5909 | |||||
5910 | tree_scrolled_window = ctk_scrolled_window_new (NULL((void*)0), NULL((void*)0)); | ||||
5911 | 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 ())))))), | ||||
5912 | CTK_POLICY_AUTOMATIC, | ||||
5913 | CTK_POLICY_AUTOMATIC); | ||||
5914 | 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 ())))))), | ||||
5915 | CTK_SHADOW_IN); | ||||
5916 | 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); | ||||
5917 | |||||
5918 | /* side pane */ | ||||
5919 | |||||
5920 | window->priv->sidepane = ctk_box_new (CTK_ORIENTATION_VERTICAL, 0); | ||||
5921 | |||||
5922 | sidepane_title = ctk_frame_new (NULL((void*)0)); | ||||
5923 | 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); | ||||
5924 | |||||
5925 | sidepane_title_box = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 0); | ||||
5926 | 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); | ||||
5927 | ctk_container_add (CTK_CONTAINER (sidepane_title)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((sidepane_title)), ((ctk_container_get_type ())))))), sidepane_title_box); | ||||
5928 | sidepane_title_label = ctk_label_new (_("Folders")gettext ("Folders")); | ||||
5929 | |||||
5930 | 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); | ||||
5931 | 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); | ||||
5932 | |||||
5933 | close_sidepane_button = ctk_button_new (); | ||||
5934 | ctk_container_add (CTK_CONTAINER (close_sidepane_button)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((close_sidepane_button)), ((ctk_container_get_type ())))) )), | ||||
5935 | ctk_image_new_from_icon_name ("window-close", | ||||
5936 | CTK_ICON_SIZE_MENU)); | ||||
5937 | 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); | ||||
5938 | ctk_widget_set_tooltip_text (close_sidepane_button, _("Close the folders pane")gettext ("Close the folders pane")); | ||||
5939 | 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) | ||||
5940 | "clicked",g_signal_connect_data ((close_sidepane_button), ("clicked"), ( ((GCallback) (close_sidepane_button_clicked_cb))), (window), ( (void*)0), (GConnectFlags) 0) | ||||
5941 | 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) | ||||
5942 | window)g_signal_connect_data ((close_sidepane_button), ("clicked"), ( ((GCallback) (close_sidepane_button_clicked_cb))), (window), ( (void*)0), (GConnectFlags) 0); | ||||
5943 | 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); | ||||
5944 | |||||
5945 | 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); | ||||
5946 | 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); | ||||
5947 | |||||
5948 | /* main content */ | ||||
5949 | |||||
5950 | window->priv->paned = ctk_paned_new (CTK_ORIENTATION_HORIZONTAL); | ||||
5951 | 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))); | ||||
5952 | 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))); | ||||
5953 | 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")); | ||||
5954 | |||||
5955 | 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); | ||||
5956 | ctk_widget_show_all (window->priv->paned); | ||||
5957 | |||||
5958 | /* Build the menu and the toolbar. */ | ||||
5959 | |||||
5960 | ui = ctk_ui_manager_new (); | ||||
5961 | |||||
5962 | window->priv->actions = actions = ctk_action_group_new ("Actions"); | ||||
5963 | |||||
5964 | /* open recent toolbar item action */ | ||||
5965 | |||||
5966 | action = g_object_new (CTK_TYPE_RECENT_ACTION(ctk_recent_action_get_type ()), | ||||
5967 | "name", "OpenRecent", | ||||
5968 | /* Translators: this is the label for the "open recent file" sub-menu. */ | ||||
5969 | "label", _("Open _Recent")gettext ("Open _Recent"), | ||||
5970 | "tooltip", _("Open a recently used archive")gettext ("Open a recently used archive"), | ||||
5971 | "icon-name", "document-open", | ||||
5972 | NULL((void*)0)); | ||||
5973 | fr_window_init_recent_chooser (window, CTK_RECENT_CHOOSER (action)((((CtkRecentChooser*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((action)), ((ctk_recent_chooser_get_type ()) )))))); | ||||
5974 | ctk_action_group_add_action (actions, action); | ||||
5975 | g_object_unref (action); | ||||
5976 | |||||
5977 | /* open recent toolbar item action */ | ||||
5978 | |||||
5979 | action = g_object_new (CTK_TYPE_RECENT_ACTION(ctk_recent_action_get_type ()), | ||||
5980 | "name", "OpenRecent_Toolbar", | ||||
5981 | "label", _("Open")gettext ("Open"), | ||||
5982 | "tooltip", _("Open a recently used archive")gettext ("Open a recently used archive"), | ||||
5983 | "icon-name", "document-open", | ||||
5984 | "is-important", TRUE(!(0)), | ||||
5985 | NULL((void*)0)); | ||||
5986 | fr_window_init_recent_chooser (window, CTK_RECENT_CHOOSER (action)((((CtkRecentChooser*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((action)), ((ctk_recent_chooser_get_type ()) )))))); | ||||
5987 | g_signal_connect (action,g_signal_connect_data ((action), ("activate"), (((GCallback) ( activate_action_open))), (window), ((void*)0), (GConnectFlags ) 0) | ||||
5988 | "activate",g_signal_connect_data ((action), ("activate"), (((GCallback) ( activate_action_open))), (window), ((void*)0), (GConnectFlags ) 0) | ||||
5989 | G_CALLBACK (activate_action_open),g_signal_connect_data ((action), ("activate"), (((GCallback) ( activate_action_open))), (window), ((void*)0), (GConnectFlags ) 0) | ||||
5990 | window)g_signal_connect_data ((action), ("activate"), (((GCallback) ( activate_action_open))), (window), ((void*)0), (GConnectFlags ) 0); | ||||
5991 | ctk_action_group_add_action (actions, action); | ||||
5992 | g_object_unref (action); | ||||
5993 | |||||
5994 | /* other actions */ | ||||
5995 | |||||
5996 | ctk_action_group_set_translation_domain (actions, NULL((void*)0)); | ||||
5997 | ctk_action_group_add_actions (actions, | ||||
5998 | action_entries, | ||||
5999 | n_action_entries, | ||||
6000 | window); | ||||
6001 | ctk_action_group_add_toggle_actions (actions, | ||||
6002 | action_toggle_entries, | ||||
6003 | n_action_toggle_entries, | ||||
6004 | window); | ||||
6005 | ctk_action_group_add_radio_actions (actions, | ||||
6006 | view_as_entries, | ||||
6007 | n_view_as_entries, | ||||
6008 | window->priv->list_mode, | ||||
6009 | G_CALLBACK (view_as_radio_action)((GCallback) (view_as_radio_action)), | ||||
6010 | window); | ||||
6011 | ctk_action_group_add_radio_actions (actions, | ||||
6012 | sort_by_entries, | ||||
6013 | n_sort_by_entries, | ||||
6014 | window->priv->sort_type, | ||||
6015 | G_CALLBACK (sort_by_radio_action)((GCallback) (sort_by_radio_action)), | ||||
6016 | window); | ||||
6017 | |||||
6018 | g_signal_connect (ui, "connect_proxy",g_signal_connect_data ((ui), ("connect_proxy"), (((GCallback) (connect_proxy_cb))), (window), ((void*)0), (GConnectFlags) 0 ) | ||||
6019 | G_CALLBACK (connect_proxy_cb), window)g_signal_connect_data ((ui), ("connect_proxy"), (((GCallback) (connect_proxy_cb))), (window), ((void*)0), (GConnectFlags) 0 ); | ||||
6020 | g_signal_connect (ui, "disconnect_proxy",g_signal_connect_data ((ui), ("disconnect_proxy"), (((GCallback ) (disconnect_proxy_cb))), (window), ((void*)0), (GConnectFlags ) 0) | ||||
6021 | G_CALLBACK (disconnect_proxy_cb), window)g_signal_connect_data ((ui), ("disconnect_proxy"), (((GCallback ) (disconnect_proxy_cb))), (window), ((void*)0), (GConnectFlags ) 0); | ||||
6022 | |||||
6023 | ctk_ui_manager_insert_action_group (ui, actions, 0); | ||||
6024 | ctk_window_add_accel_group (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), | ||||
6025 | ctk_ui_manager_get_accel_group (ui)); | ||||
6026 | |||||
6027 | /* Add a hidden short cut Ctrl-Q for power users */ | ||||
6028 | ctk_accel_group_connect (ctk_ui_manager_get_accel_group (ui), | ||||
6029 | CDK_KEY_q0x071, CDK_CONTROL_MASK, 0, | ||||
6030 | g_cclosure_new_swap (G_CALLBACK (fr_window_close)((GCallback) (fr_window_close)), window, NULL((void*)0))); | ||||
6031 | |||||
6032 | |||||
6033 | 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)) { | ||||
6034 | g_message ("building menus failed: %s", error->message); | ||||
6035 | g_error_free (error); | ||||
6036 | } | ||||
6037 | |||||
6038 | menubar = ctk_ui_manager_get_widget (ui, "/MenuBar"); | ||||
6039 | fr_window_attach (FR_WINDOW (window)((((FrWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((fr_window_get_type ())))))), menubar, FR_WINDOW_AREA_MENUBAR); | ||||
6040 | ctk_widget_show (menubar); | ||||
6041 | |||||
6042 | window->priv->toolbar = toolbar = ctk_ui_manager_get_widget (ui, "/ToolBar"); | ||||
6043 | ctk_toolbar_set_show_arrow (CTK_TOOLBAR (toolbar)((((CtkToolbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((toolbar)), ((ctk_toolbar_get_type ())))))), TRUE(!(0))); | ||||
6044 | ctk_style_context_add_class (ctk_widget_get_style_context (toolbar), CTK_STYLE_CLASS_PRIMARY_TOOLBAR"primary-toolbar"); | ||||
6045 | set_action_important (ui, "/ToolBar/Extract_Toolbar"); | ||||
6046 | |||||
6047 | /* location bar */ | ||||
6048 | |||||
6049 | window->priv->location_bar = ctk_ui_manager_get_widget (ui, "/LocationBar"); | ||||
6050 | 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)); | ||||
6051 | 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); | ||||
6052 | ctk_style_context_add_class (ctk_widget_get_style_context (window->priv->location_bar), CTK_STYLE_CLASS_TOOLBAR"toolbar"); | ||||
6053 | set_action_important (ui, "/LocationBar/GoBack"); | ||||
6054 | |||||
6055 | /* current location */ | ||||
6056 | |||||
6057 | location_box = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 6); | ||||
6058 | /* Translators: after the colon there is a folder name. */ | ||||
6059 | window->priv->location_label = ctk_label_new_with_mnemonic (_("_Location:")gettext ("_Location:")); | ||||
6060 | ctk_box_pack_start (CTK_BOX (location_box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((location_box)), ((ctk_box_get_type ())))))), | ||||
6061 | window->priv->location_label, FALSE(0), FALSE(0), 5); | ||||
6062 | |||||
6063 | window->priv->location_entry = ctk_entry_new (); | ||||
6064 | 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 ())))))), | ||||
6065 | CTK_ENTRY_ICON_PRIMARY, | ||||
6066 | "folder"); | ||||
6067 | |||||
6068 | ctk_box_pack_start (CTK_BOX (location_box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((location_box)), ((ctk_box_get_type ())))))), | ||||
6069 | window->priv->location_entry, TRUE(!(0)), TRUE(!(0)), 5); | ||||
6070 | |||||
6071 | 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) | ||||
6072 | "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) | ||||
6073 | 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) | ||||
6074 | 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); | ||||
6075 | |||||
6076 | { | ||||
6077 | CtkToolItem *tool_item; | ||||
6078 | |||||
6079 | tool_item = ctk_separator_tool_item_new (); | ||||
6080 | ctk_widget_show_all (CTK_WIDGET (tool_item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tool_item)), ((ctk_widget_get_type ()))))))); | ||||
6081 | 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); | ||||
6082 | |||||
6083 | tool_item = ctk_tool_item_new (); | ||||
6084 | ctk_tool_item_set_expand (tool_item, TRUE(!(0))); | ||||
6085 | ctk_container_add (CTK_CONTAINER (tool_item)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tool_item)), ((ctk_container_get_type ())))))), location_box); | ||||
6086 | ctk_widget_show_all (CTK_WIDGET (tool_item)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tool_item)), ((ctk_widget_get_type ()))))))); | ||||
6087 | 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); | ||||
6088 | } | ||||
6089 | |||||
6090 | 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); | ||||
6091 | if (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT) | ||||
6092 | ctk_widget_hide (window->priv->location_bar); | ||||
6093 | else | ||||
6094 | ctk_widget_show (window->priv->location_bar); | ||||
6095 | |||||
6096 | /**/ | ||||
6097 | |||||
6098 | 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); | ||||
6099 | if (g_settings_get_boolean (window->priv->settings_ui, PREF_UI_VIEW_TOOLBAR"view-toolbar")) | ||||
6100 | ctk_widget_show (toolbar); | ||||
6101 | else | ||||
6102 | ctk_widget_hide (toolbar); | ||||
6103 | |||||
6104 | window->priv->file_popup_menu = ctk_ui_manager_get_widget (ui, "/FilePopupMenu"); | ||||
6105 | window->priv->folder_popup_menu = ctk_ui_manager_get_widget (ui, "/FolderPopupMenu"); | ||||
6106 | window->priv->sidebar_folder_popup_menu = ctk_ui_manager_get_widget (ui, "/SidebarFolderPopupMenu"); | ||||
6107 | |||||
6108 | /* Create the statusbar. */ | ||||
6109 | |||||
6110 | window->priv->statusbar = ctk_statusbar_new (); | ||||
6111 | 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"); | ||||
6112 | 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"); | ||||
6113 | 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"); | ||||
6114 | |||||
6115 | statusbar = CTK_STATUSBAR (window->priv->statusbar)((((CtkStatusbar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->priv->statusbar)), ((ctk_statusbar_get_type ())))))); | ||||
6116 | |||||
6117 | /*reduce size of statusbar */ | ||||
6118 | ctk_widget_set_margin_top (CTK_WIDGET (statusbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((statusbar)), ((ctk_widget_get_type ())))))), 0); | ||||
6119 | ctk_widget_set_margin_bottom (CTK_WIDGET (statusbar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((statusbar)), ((ctk_widget_get_type ())))))), 0); | ||||
6120 | |||||
6121 | statusbar_box = ctk_statusbar_get_message_area (statusbar); | ||||
6122 | ctk_box_set_homogeneous (CTK_BOX (statusbar_box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((statusbar_box)), ((ctk_box_get_type ())))))), FALSE(0)); | ||||
6123 | ctk_box_set_spacing (CTK_BOX (statusbar_box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((statusbar_box)), ((ctk_box_get_type ())))))), 4); | ||||
6124 | 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 ); | ||||
6125 | |||||
6126 | window->priv->progress_bar = ctk_progress_bar_new (); | ||||
6127 | 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)); | ||||
6128 | ctk_widget_set_size_request (window->priv->progress_bar, -1, PROGRESS_BAR_HEIGHT10); | ||||
6129 | { | ||||
6130 | CtkWidget *vbox; | ||||
6131 | |||||
6132 | vbox = ctk_box_new (CTK_ORIENTATION_VERTICAL, 0); | ||||
6133 | 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); | ||||
6134 | 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); | ||||
6135 | ctk_widget_show (vbox); | ||||
6136 | } | ||||
6137 | ctk_widget_show (statusbar_box); | ||||
6138 | |||||
6139 | 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); | ||||
6140 | if (g_settings_get_boolean (window->priv->settings_ui, PREF_UI_VIEW_STATUSBAR"view-statusbar")) | ||||
6141 | ctk_widget_show (window->priv->statusbar); | ||||
6142 | else | ||||
6143 | ctk_widget_hide (window->priv->statusbar); | ||||
6144 | |||||
6145 | /**/ | ||||
6146 | |||||
6147 | fr_window_update_title (window); | ||||
6148 | fr_window_update_sensitivity (window); | ||||
6149 | fr_window_update_file_list (window, FALSE(0)); | ||||
6150 | fr_window_update_dir_tree (window); | ||||
6151 | fr_window_update_current_location (window); | ||||
6152 | fr_window_update_columns_visibility (window); | ||||
6153 | |||||
6154 | /* Add notification callbacks. */ | ||||
6155 | |||||
6156 | 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) | ||||
6157 | "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) | ||||
6158 | 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) | ||||
6159 | window)g_signal_connect_data ((window->priv->settings_ui), ("changed::" "history-len"), (((GCallback) (pref_history_len_changed))), ( window), ((void*)0), (GConnectFlags) 0); | ||||
6160 | 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) | ||||
6161 | "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) | ||||
6162 | 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) | ||||
6163 | window)g_signal_connect_data ((window->priv->settings_ui), ("changed::" "view-toolbar"), (((GCallback) (pref_view_toolbar_changed))) , (window), ((void*)0), (GConnectFlags) 0); | ||||
6164 | 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) | ||||
6165 | "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) | ||||
6166 | 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) | ||||
6167 | window)g_signal_connect_data ((window->priv->settings_ui), ("changed::" "view-statusbar"), (((GCallback) (pref_view_statusbar_changed ))), (window), ((void*)0), (GConnectFlags) 0); | ||||
6168 | 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) | ||||
6169 | "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) | ||||
6170 | 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) | ||||
6171 | window)g_signal_connect_data ((window->priv->settings_ui), ("changed::" "view-folders"), (((GCallback) (pref_view_folders_changed))) , (window), ((void*)0), (GConnectFlags) 0); | ||||
6172 | 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) | ||||
6173 | "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) | ||||
6174 | 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) | ||||
6175 | window)g_signal_connect_data ((window->priv->settings_listing) , ("changed::" "show-type"), (((GCallback) (pref_show_field_changed ))), (window), ((void*)0), (GConnectFlags) 0); | ||||
6176 | 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) | ||||
6177 | "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) | ||||
6178 | 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) | ||||
6179 | window)g_signal_connect_data ((window->priv->settings_listing) , ("changed::" "show-size"), (((GCallback) (pref_show_field_changed ))), (window), ((void*)0), (GConnectFlags) 0); | ||||
6180 | 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) | ||||
6181 | "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) | ||||
6182 | 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) | ||||
6183 | window)g_signal_connect_data ((window->priv->settings_listing) , ("changed::" "show-time"), (((GCallback) (pref_show_field_changed ))), (window), ((void*)0), (GConnectFlags) 0); | ||||
6184 | 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) | ||||
6185 | "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) | ||||
6186 | 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) | ||||
6187 | window)g_signal_connect_data ((window->priv->settings_listing) , ("changed::" "show-path"), (((GCallback) (pref_show_field_changed ))), (window), ((void*)0), (GConnectFlags) 0); | ||||
6188 | 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) | ||||
6189 | "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) | ||||
6190 | 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) | ||||
6191 | window)g_signal_connect_data ((window->priv->settings_listing) , ("changed::" "use-mime-icons"), (((GCallback) (pref_use_mime_icons_changed ))), (window), ((void*)0), (GConnectFlags) 0); | ||||
6192 | |||||
6193 | if (window->priv->settings_baul) | ||||
6194 | 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) | ||||
6195 | "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) | ||||
6196 | 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) | ||||
6197 | window)g_signal_connect_data ((window->priv->settings_baul), ( "changed::" "click-policy"), (((GCallback) (pref_click_policy_changed ))), (window), ((void*)0), (GConnectFlags) 0); | ||||
6198 | |||||
6199 | /* Give focus to the list. */ | ||||
6200 | |||||
6201 | ctk_widget_grab_focus (window->priv->list_view); | ||||
6202 | } | ||||
6203 | |||||
6204 | |||||
6205 | CtkWidget * | ||||
6206 | fr_window_new (void) | ||||
6207 | { | ||||
6208 | CtkWidget *window; | ||||
6209 | |||||
6210 | window = g_object_new (FR_TYPE_WINDOW(fr_window_get_type ()), "application", g_application_get_default (), NULL((void*)0)); | ||||
6211 | fr_window_construct ((FrWindow*) window); | ||||
6212 | |||||
6213 | return window; | ||||
6214 | } | ||||
6215 | |||||
6216 | |||||
6217 | static void | ||||
6218 | fr_window_set_archive_uri (FrWindow *window, | ||||
6219 | const char *uri) | ||||
6220 | { | ||||
6221 | if (window->priv->archive_uri != NULL((void*)0)) | ||||
6222 | g_free (window->priv->archive_uri); | ||||
6223 | window->priv->archive_uri = g_strdup (uri)g_strdup_inline (uri); | ||||
6224 | } | ||||
6225 | |||||
6226 | |||||
6227 | gboolean | ||||
6228 | fr_window_archive_new (FrWindow *window, | ||||
6229 | const char *uri) | ||||
6230 | { | ||||
6231 | 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); | ||||
6232 | |||||
6233 | if (! fr_archive_create (window->archive, uri)) { | ||||
6234 | 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"); | ||||
6235 | |||||
6236 | window->priv->load_error_parent_window = file_sel; | ||||
6237 | fr_archive_action_completed (window->archive, | ||||
6238 | FR_ACTION_CREATING_NEW_ARCHIVE, | ||||
6239 | FR_PROC_ERROR_GENERIC, | ||||
6240 | _("Archive type not supported.")gettext ("Archive type not supported.")); | ||||
6241 | |||||
6242 | return FALSE(0); | ||||
6243 | } | ||||
6244 | |||||
6245 | fr_window_set_archive_uri (window, uri); | ||||
6246 | window->priv->archive_present = TRUE(!(0)); | ||||
6247 | window->priv->archive_new = TRUE(!(0)); | ||||
6248 | |||||
6249 | fr_archive_action_completed (window->archive, | ||||
6250 | FR_ACTION_CREATING_NEW_ARCHIVE, | ||||
6251 | FR_PROC_ERROR_NONE, | ||||
6252 | NULL((void*)0)); | ||||
6253 | |||||
6254 | return TRUE(!(0)); | ||||
6255 | } | ||||
6256 | |||||
6257 | |||||
6258 | FrWindow * | ||||
6259 | fr_window_archive_open (FrWindow *current_window, | ||||
6260 | const char *uri, | ||||
6261 | CtkWindow *parent) | ||||
6262 | { | ||||
6263 | FrWindow *window = current_window; | ||||
6264 | |||||
6265 | if (current_window->priv->archive_present) | ||||
6266 | window = (FrWindow *) fr_window_new (); | ||||
6267 | |||||
6268 | 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); | ||||
6269 | |||||
6270 | fr_window_archive_close (window); | ||||
6271 | |||||
6272 | fr_window_set_archive_uri (window, uri); | ||||
6273 | window->priv->archive_present = FALSE(0); | ||||
6274 | window->priv->give_focus_to_the_list = TRUE(!(0)); | ||||
6275 | window->priv->load_error_parent_window = parent; | ||||
6276 | |||||
6277 | fr_window_set_current_batch_action (window, | ||||
6278 | FR_BATCH_ACTION_LOAD, | ||||
6279 | g_strdup (window->priv->archive_uri)g_strdup_inline (window->priv->archive_uri), | ||||
6280 | (GFreeFunc) g_free); | ||||
6281 | |||||
6282 | fr_archive_load (window->archive, window->priv->archive_uri, window->priv->password); | ||||
6283 | |||||
6284 | return window; | ||||
6285 | } | ||||
6286 | |||||
6287 | |||||
6288 | void | ||||
6289 | fr_window_archive_close (FrWindow *window) | ||||
6290 | { | ||||
6291 | 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); | ||||
6292 | |||||
6293 | if (! window->priv->archive_new && ! window->priv->archive_present) | ||||
6294 | return; | ||||
6295 | |||||
6296 | fr_window_free_open_files (window); | ||||
6297 | fr_clipboard_data_unref (window->priv->copy_data); | ||||
6298 | window->priv->copy_data = NULL((void*)0); | ||||
6299 | |||||
6300 | fr_window_set_password (window, NULL((void*)0)); | ||||
6301 | fr_window_set_volume_size(window, 0); | ||||
6302 | fr_window_history_clear (window); | ||||
6303 | |||||
6304 | window->priv->archive_new = FALSE(0); | ||||
6305 | window->priv->archive_present = FALSE(0); | ||||
6306 | |||||
6307 | fr_window_update_title (window); | ||||
6308 | fr_window_update_sensitivity (window); | ||||
6309 | fr_window_update_file_list (window, FALSE(0)); | ||||
6310 | fr_window_update_dir_tree (window); | ||||
6311 | fr_window_update_current_location (window); | ||||
6312 | fr_window_update_statusbar_list_info (window); | ||||
6313 | } | ||||
6314 | |||||
6315 | |||||
6316 | const char * | ||||
6317 | fr_window_get_archive_uri (FrWindow *window) | ||||
6318 | { | ||||
6319 | 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); | ||||
6320 | |||||
6321 | return window->priv->archive_uri; | ||||
6322 | } | ||||
6323 | |||||
6324 | |||||
6325 | const char * | ||||
6326 | fr_window_get_paste_archive_uri (FrWindow *window) | ||||
6327 | { | ||||
6328 | 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); | ||||
6329 | |||||
6330 | if (window->priv->clipboard_data != NULL((void*)0)) | ||||
6331 | return window->priv->clipboard_data->archive_filename; | ||||
6332 | else | ||||
6333 | return NULL((void*)0); | ||||
6334 | } | ||||
6335 | |||||
6336 | |||||
6337 | gboolean | ||||
6338 | fr_window_archive_is_present (FrWindow *window) | ||||
6339 | { | ||||
6340 | 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); | ||||
6341 | |||||
6342 | return window->priv->archive_present; | ||||
6343 | } | ||||
6344 | |||||
6345 | |||||
6346 | typedef struct { | ||||
6347 | char *uri; | ||||
6348 | char *password; | ||||
6349 | gboolean encrypt_header; | ||||
6350 | guint volume_size; | ||||
6351 | } SaveAsData; | ||||
6352 | |||||
6353 | |||||
6354 | static SaveAsData * | ||||
6355 | save_as_data_new (const char *uri, | ||||
6356 | const char *password, | ||||
6357 | gboolean encrypt_header, | ||||
6358 | guint volume_size) | ||||
6359 | { | ||||
6360 | SaveAsData *sdata; | ||||
6361 | |||||
6362 | sdata = g_new0 (SaveAsData, 1)((SaveAsData *) g_malloc0_n ((1), sizeof (SaveAsData))); | ||||
6363 | if (uri != NULL((void*)0)) | ||||
6364 | sdata->uri = g_strdup (uri)g_strdup_inline (uri); | ||||
6365 | if (password != NULL((void*)0)) | ||||
6366 | sdata->password = g_strdup (password)g_strdup_inline (password); | ||||
6367 | sdata->encrypt_header = encrypt_header; | ||||
6368 | sdata->volume_size = volume_size; | ||||
6369 | |||||
6370 | return sdata; | ||||
6371 | } | ||||
6372 | |||||
6373 | |||||
6374 | static void | ||||
6375 | save_as_data_free (SaveAsData *sdata) | ||||
6376 | { | ||||
6377 | if (sdata == NULL((void*)0)) | ||||
6378 | return; | ||||
6379 | g_free (sdata->uri); | ||||
6380 | g_free (sdata->password); | ||||
6381 | g_free (sdata); | ||||
6382 | } | ||||
6383 | |||||
6384 | |||||
6385 | void | ||||
6386 | fr_window_archive_save_as (FrWindow *window, | ||||
6387 | const char *uri, | ||||
6388 | const char *password, | ||||
6389 | gboolean encrypt_header, | ||||
6390 | guint volume_size) | ||||
6391 | { | ||||
6392 | 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); | ||||
6393 | 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); | ||||
6394 | 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); | ||||
6395 | |||||
6396 | fr_window_convert_data_free (window, TRUE(!(0))); | ||||
6397 | window->priv->convert_data.new_file = g_strdup (uri)g_strdup_inline (uri); | ||||
6398 | |||||
6399 | /* create the new archive */ | ||||
6400 | |||||
6401 | window->priv->convert_data.new_archive = fr_archive_new (); | ||||
6402 | if (! fr_archive_create (window->priv->convert_data.new_archive, uri)) { | ||||
6403 | CtkWidget *d; | ||||
6404 | char *utf8_name; | ||||
6405 | char *message; | ||||
6406 | |||||
6407 | utf8_name = g_uri_display_basename (uri); | ||||
6408 | message = g_strdup_printf (_("Could not save the archive \"%s\"")gettext ("Could not save the archive \"%s\""), utf8_name); | ||||
6409 | g_free (utf8_name); | ||||
6410 | |||||
6411 | d = _ctk_error_dialog_new (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), | ||||
6412 | CTK_DIALOG_DESTROY_WITH_PARENT, | ||||
6413 | NULL((void*)0), | ||||
6414 | message, | ||||
6415 | "%s", | ||||
6416 | _("Archive type not supported.")gettext ("Archive type not supported.")); | ||||
6417 | ctk_dialog_run (CTK_DIALOG (d)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((d)), ((ctk_dialog_get_type ()))))))); | ||||
6418 | ctk_widget_destroy (d); | ||||
6419 | |||||
6420 | g_free (message); | ||||
6421 | |||||
6422 | g_object_unref (window->priv->convert_data.new_archive); | ||||
6423 | window->priv->convert_data.new_archive = NULL((void*)0); | ||||
6424 | |||||
6425 | return; | ||||
6426 | } | ||||
6427 | |||||
6428 | 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); | ||||
6429 | |||||
6430 | if (password != NULL((void*)0)) { | ||||
6431 | window->priv->convert_data.password = g_strdup (password)g_strdup_inline (password); | ||||
6432 | window->priv->convert_data.encrypt_header = encrypt_header; | ||||
6433 | } | ||||
6434 | else | ||||
6435 | window->priv->convert_data.encrypt_header = FALSE(0); | ||||
6436 | window->priv->convert_data.volume_size = volume_size; | ||||
6437 | |||||
6438 | fr_window_set_current_batch_action (window, | ||||
6439 | FR_BATCH_ACTION_SAVE_AS, | ||||
6440 | save_as_data_new (uri, password, encrypt_header, volume_size), | ||||
6441 | (GFreeFunc) save_as_data_free); | ||||
6442 | |||||
6443 | 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 ) | ||||
6444 | "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 ) | ||||
6445 | 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 ) | ||||
6446 | 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 ); | ||||
6447 | 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) | ||||
6448 | "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) | ||||
6449 | 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) | ||||
6450 | 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); | ||||
6451 | 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) | ||||
6452 | "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) | ||||
6453 | 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) | ||||
6454 | 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); | ||||
6455 | 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) | ||||
6456 | "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) | ||||
6457 | 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) | ||||
6458 | 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); | ||||
6459 | 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) | ||||
6460 | "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) | ||||
6461 | 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) | ||||
6462 | 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); | ||||
6463 | |||||
6464 | window->priv->convert_data.converting = TRUE(!(0)); | ||||
6465 | window->priv->convert_data.temp_dir = get_temp_work_dir (NULL((void*)0)); | ||||
6466 | |||||
6467 | fr_process_clear (window->archive->process); | ||||
6468 | fr_archive_extract_to_local (window->archive, | ||||
6469 | NULL((void*)0), | ||||
6470 | window->priv->convert_data.temp_dir, | ||||
6471 | NULL((void*)0), | ||||
6472 | TRUE(!(0)), | ||||
6473 | FALSE(0), | ||||
6474 | FALSE(0), | ||||
6475 | window->priv->password); | ||||
6476 | fr_process_start (window->archive->process); | ||||
6477 | } | ||||
6478 | |||||
6479 | |||||
6480 | void | ||||
6481 | fr_window_archive_reload (FrWindow *window) | ||||
6482 | { | ||||
6483 | 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); | ||||
6484 | |||||
6485 | if (window->priv->activity_ref > 0) | ||||
6486 | return; | ||||
6487 | if (window->priv->archive_new) | ||||
6488 | return; | ||||
6489 | |||||
6490 | fr_archive_reload (window->archive, window->priv->password); | ||||
6491 | } | ||||
6492 | |||||
6493 | |||||
6494 | /**/ | ||||
6495 | |||||
6496 | |||||
6497 | void | ||||
6498 | fr_window_archive_add_files (FrWindow *window, | ||||
6499 | GList *file_list, /* GFile list */ | ||||
6500 | gboolean update) | ||||
6501 | { | ||||
6502 | GFile *base; | ||||
6503 | char *base_dir; | ||||
6504 | int base_len; | ||||
6505 | GList *files = NULL((void*)0); | ||||
6506 | GList *scan; | ||||
6507 | char *base_uri; | ||||
6508 | |||||
6509 | base = g_file_get_parent ((GFile *) file_list->data); | ||||
6510 | base_dir = g_file_get_path (base); | ||||
6511 | base_len = 0; | ||||
6512 | if (strcmp (base_dir, "/") != 0) | ||||
6513 | base_len = strlen (base_dir); | ||||
6514 | |||||
6515 | for (scan = file_list; scan; scan = scan->next) { | ||||
6516 | GFile *file = scan->data; | ||||
6517 | char *path; | ||||
6518 | char *rel_path; | ||||
6519 | |||||
6520 | path = g_file_get_path (file); | ||||
6521 | rel_path = g_strdup (path + base_len + 1)g_strdup_inline (path + base_len + 1); | ||||
6522 | files = g_list_prepend (files, rel_path); | ||||
6523 | |||||
6524 | g_free (path); | ||||
6525 | } | ||||
6526 | |||||
6527 | base_uri = g_file_get_uri (base); | ||||
6528 | |||||
6529 | fr_archive_add_files (window->archive, | ||||
6530 | files, | ||||
6531 | base_uri, | ||||
6532 | fr_window_get_current_location (window), | ||||
6533 | update, | ||||
6534 | window->priv->password, | ||||
6535 | window->priv->encrypt_header, | ||||
6536 | window->priv->compression, | ||||
6537 | window->priv->volume_size); | ||||
6538 | |||||
6539 | g_free (base_uri); | ||||
6540 | path_list_free (files); | ||||
6541 | g_free (base_dir); | ||||
6542 | g_object_unref (base); | ||||
6543 | } | ||||
6544 | |||||
6545 | |||||
6546 | void | ||||
6547 | fr_window_archive_add_with_wildcard (FrWindow *window, | ||||
6548 | const char *include_files, | ||||
6549 | const char *exclude_files, | ||||
6550 | const char *exclude_folders, | ||||
6551 | const char *base_dir, | ||||
6552 | const char *dest_dir, | ||||
6553 | gboolean update, | ||||
6554 | gboolean follow_links) | ||||
6555 | { | ||||
6556 | fr_archive_add_with_wildcard (window->archive, | ||||
6557 | include_files, | ||||
6558 | exclude_files, | ||||
6559 | exclude_folders, | ||||
6560 | base_dir, | ||||
6561 | (dest_dir == NULL((void*)0))? fr_window_get_current_location (window): dest_dir, | ||||
6562 | update, | ||||
6563 | follow_links, | ||||
6564 | window->priv->password, | ||||
6565 | window->priv->encrypt_header, | ||||
6566 | window->priv->compression, | ||||
6567 | window->priv->volume_size); | ||||
6568 | } | ||||
6569 | |||||
6570 | |||||
6571 | void | ||||
6572 | fr_window_archive_add_directory (FrWindow *window, | ||||
6573 | const char *directory, | ||||
6574 | const char *base_dir, | ||||
6575 | const char *dest_dir, | ||||
6576 | gboolean update) | ||||
6577 | { | ||||
6578 | fr_archive_add_directory (window->archive, | ||||
6579 | directory, | ||||
6580 | base_dir, | ||||
6581 | (dest_dir == NULL((void*)0))? fr_window_get_current_location (window): dest_dir, | ||||
6582 | update, | ||||
6583 | window->priv->password, | ||||
6584 | window->priv->encrypt_header, | ||||
6585 | window->priv->compression, | ||||
6586 | window->priv->volume_size); | ||||
6587 | } | ||||
6588 | |||||
6589 | |||||
6590 | void | ||||
6591 | fr_window_archive_add_items (FrWindow *window, | ||||
6592 | GList *item_list, | ||||
6593 | const char *base_dir, | ||||
6594 | const char *dest_dir, | ||||
6595 | gboolean update) | ||||
6596 | { | ||||
6597 | fr_archive_add_items (window->archive, | ||||
6598 | item_list, | ||||
6599 | base_dir, | ||||
6600 | (dest_dir == NULL((void*)0))? fr_window_get_current_location (window): dest_dir, | ||||
6601 | update, | ||||
6602 | window->priv->password, | ||||
6603 | window->priv->encrypt_header, | ||||
6604 | window->priv->compression, | ||||
6605 | window->priv->volume_size); | ||||
6606 | } | ||||
6607 | |||||
6608 | |||||
6609 | void | ||||
6610 | fr_window_archive_add_dropped_items (FrWindow *window, | ||||
6611 | GList *item_list, | ||||
6612 | gboolean update) | ||||
6613 | { | ||||
6614 | fr_archive_add_dropped_items (window->archive, | ||||
6615 | item_list, | ||||
6616 | fr_window_get_current_location (window), | ||||
6617 | fr_window_get_current_location (window), | ||||
6618 | update, | ||||
6619 | window->priv->password, | ||||
6620 | window->priv->encrypt_header, | ||||
6621 | window->priv->compression, | ||||
6622 | window->priv->volume_size); | ||||
6623 | } | ||||
6624 | |||||
6625 | |||||
6626 | void | ||||
6627 | fr_window_archive_remove (FrWindow *window, | ||||
6628 | GList *file_list) | ||||
6629 | { | ||||
6630 | fr_window_clipboard_remove_file_list (window, file_list); | ||||
6631 | |||||
6632 | fr_process_clear (window->archive->process); | ||||
6633 | fr_archive_remove (window->archive, file_list, window->priv->compression); | ||||
6634 | fr_process_start (window->archive->process); | ||||
6635 | } | ||||
6636 | |||||
6637 | |||||
6638 | /* -- window_archive_extract -- */ | ||||
6639 | |||||
6640 | |||||
6641 | static ExtractData* | ||||
6642 | extract_data_new (GList *file_list, | ||||
6643 | const char *extract_to_dir, | ||||
6644 | const char *base_dir, | ||||
6645 | gboolean skip_older, | ||||
6646 | FrOverwrite overwrite, | ||||
6647 | gboolean junk_paths, | ||||
6648 | gboolean extract_here, | ||||
6649 | gboolean ask_to_open_destination) | ||||
6650 | { | ||||
6651 | ExtractData *edata; | ||||
6652 | |||||
6653 | edata = g_new0 (ExtractData, 1)((ExtractData *) g_malloc0_n ((1), sizeof (ExtractData))); | ||||
6654 | edata->file_list = path_list_dup (file_list); | ||||
6655 | if (extract_to_dir != NULL((void*)0)) | ||||
6656 | edata->extract_to_dir = g_strdup (extract_to_dir)g_strdup_inline (extract_to_dir); | ||||
6657 | edata->skip_older = skip_older; | ||||
6658 | edata->overwrite = overwrite; | ||||
6659 | edata->junk_paths = junk_paths; | ||||
6660 | if (base_dir != NULL((void*)0)) | ||||
6661 | edata->base_dir = g_strdup (base_dir)g_strdup_inline (base_dir); | ||||
6662 | edata->extract_here = extract_here; | ||||
6663 | edata->ask_to_open_destination = ask_to_open_destination; | ||||
6664 | |||||
6665 | return edata; | ||||
6666 | } | ||||
6667 | |||||
6668 | |||||
6669 | static ExtractData* | ||||
6670 | extract_to_data_new (const char *extract_to_dir) | ||||
6671 | { | ||||
6672 | return extract_data_new (NULL((void*)0), | ||||
6673 | extract_to_dir, | ||||
6674 | NULL((void*)0), | ||||
6675 | FALSE(0), | ||||
6676 | TRUE(!(0)), | ||||
6677 | FALSE(0), | ||||
6678 | FALSE(0), | ||||
6679 | FALSE(0)); | ||||
6680 | } | ||||
6681 | |||||
6682 | |||||
6683 | static void | ||||
6684 | extract_data_free (ExtractData *edata) | ||||
6685 | { | ||||
6686 | 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); | ||||
6687 | |||||
6688 | path_list_free (edata->file_list); | ||||
6689 | g_free (edata->extract_to_dir); | ||||
6690 | g_free (edata->base_dir); | ||||
6691 | |||||
6692 | g_free (edata); | ||||
6693 | } | ||||
6694 | |||||
6695 | |||||
6696 | static gboolean | ||||
6697 | archive_is_encrypted (FrWindow *window, | ||||
6698 | GList *file_list) | ||||
6699 | { | ||||
6700 | gboolean encrypted = FALSE(0); | ||||
6701 | |||||
6702 | if (file_list == NULL((void*)0)) { | ||||
6703 | guint i; | ||||
6704 | |||||
6705 | for (i = 0; ! encrypted && i < window->archive->command->files->len; i++) { | ||||
6706 | FileData *fdata = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i]; | ||||
6707 | |||||
6708 | if (fdata->encrypted) | ||||
6709 | encrypted = TRUE(!(0)); | ||||
6710 | } | ||||
6711 | } | ||||
6712 | else { | ||||
6713 | |||||
6714 | GHashTable *file_hash; | ||||
6715 | guint i; | ||||
6716 | GList *scan; | ||||
6717 | |||||
6718 | file_hash = g_hash_table_new (g_str_hash, g_str_equal); | ||||
6719 | for (i = 0; i < window->archive->command->files->len; i++) { | ||||
6720 | FileData *fdata = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i]; | ||||
6721 | g_hash_table_insert (file_hash, fdata->original_path, fdata); | ||||
6722 | } | ||||
6723 | |||||
6724 | for (scan = file_list; ! encrypted && scan; scan = scan->next) { | ||||
6725 | char *filename = scan->data; | ||||
6726 | FileData *fdata; | ||||
6727 | |||||
6728 | fdata = g_hash_table_lookup (file_hash, filename); | ||||
6729 | 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); | ||||
6730 | |||||
6731 | if (fdata->encrypted) | ||||
6732 | encrypted = TRUE(!(0)); | ||||
6733 | } | ||||
6734 | |||||
6735 | g_hash_table_destroy (file_hash); | ||||
6736 | } | ||||
6737 | |||||
6738 | return encrypted; | ||||
6739 | } | ||||
6740 | |||||
6741 | |||||
6742 | void | ||||
6743 | fr_window_archive_extract_here (FrWindow *window, | ||||
6744 | gboolean skip_older, | ||||
6745 | gboolean overwrite, | ||||
6746 | gboolean junk_paths) | ||||
6747 | { | ||||
6748 | ExtractData *edata; | ||||
6749 | |||||
6750 | edata = extract_data_new (NULL((void*)0), | ||||
6751 | NULL((void*)0), | ||||
6752 | NULL((void*)0), | ||||
6753 | skip_older, | ||||
6754 | overwrite, | ||||
6755 | junk_paths, | ||||
6756 | TRUE(!(0)), | ||||
6757 | FALSE(0)); | ||||
6758 | fr_window_set_current_batch_action (window, | ||||
6759 | FR_BATCH_ACTION_EXTRACT, | ||||
6760 | edata, | ||||
6761 | (GFreeFunc) extract_data_free); | ||||
6762 | |||||
6763 | if (archive_is_encrypted (window, NULL((void*)0)) && (window->priv->password == NULL((void*)0))) { | ||||
6764 | dlg_ask_password (window); | ||||
6765 | return; | ||||
6766 | } | ||||
6767 | |||||
6768 | window->priv->ask_to_open_destination_after_extraction = edata->ask_to_open_destination; | ||||
6769 | |||||
6770 | fr_process_clear (window->archive->process); | ||||
6771 | if (fr_archive_extract_here (window->archive, | ||||
6772 | edata->skip_older, | ||||
6773 | edata->overwrite, | ||||
6774 | edata->junk_paths, | ||||
6775 | window->priv->password)) | ||||
6776 | { | ||||
6777 | fr_process_start (window->archive->process); | ||||
6778 | } | ||||
6779 | } | ||||
6780 | |||||
6781 | |||||
6782 | /* -- fr_window_archive_extract -- */ | ||||
6783 | |||||
6784 | |||||
6785 | typedef struct { | ||||
6786 | FrWindow *window; | ||||
6787 | ExtractData *edata; | ||||
6788 | GList *current_file; | ||||
6789 | gboolean extract_all; | ||||
6790 | } OverwriteData; | ||||
6791 | |||||
6792 | |||||
6793 | #define _FR_RESPONSE_OVERWRITE_YES_ALL100 100 | ||||
6794 | #define _FR_RESPONSE_OVERWRITE_YES101 101 | ||||
6795 | #define _FR_RESPONSE_OVERWRITE_NO102 102 | ||||
6796 | |||||
6797 | |||||
6798 | static void | ||||
6799 | _fr_window_archive_extract_from_edata (FrWindow *window, | ||||
6800 | ExtractData *edata) | ||||
6801 | { | ||||
6802 | window->priv->ask_to_open_destination_after_extraction = edata->ask_to_open_destination; | ||||
6803 | |||||
6804 | fr_process_clear (window->archive->process); | ||||
6805 | fr_archive_extract (window->archive, | ||||
6806 | edata->file_list, | ||||
6807 | edata->extract_to_dir, | ||||
6808 | edata->base_dir, | ||||
6809 | edata->skip_older, | ||||
6810 | edata->overwrite == FR_OVERWRITE_YES, | ||||
6811 | edata->junk_paths, | ||||
6812 | window->priv->password); | ||||
6813 | fr_process_start (window->archive->process); | ||||
6814 | } | ||||
6815 | |||||
6816 | |||||
6817 | static void _fr_window_ask_overwrite_dialog (OverwriteData *odata); | ||||
6818 | |||||
6819 | |||||
6820 | static void | ||||
6821 | overwrite_dialog_response_cb (CtkDialog *dialog, | ||||
6822 | int response_id, | ||||
6823 | gpointer user_data) | ||||
6824 | { | ||||
6825 | OverwriteData *odata = user_data; | ||||
6826 | gboolean do_not_extract = FALSE(0); | ||||
6827 | |||||
6828 | switch (response_id) { | ||||
6829 | case _FR_RESPONSE_OVERWRITE_YES_ALL100: | ||||
6830 | odata->edata->overwrite = FR_OVERWRITE_YES; | ||||
6831 | break; | ||||
6832 | |||||
6833 | case _FR_RESPONSE_OVERWRITE_YES101: | ||||
6834 | odata->current_file = odata->current_file->next; | ||||
6835 | break; | ||||
6836 | |||||
6837 | case _FR_RESPONSE_OVERWRITE_NO102: | ||||
6838 | { | ||||
6839 | /* remove the file from the list to extract */ | ||||
6840 | GList *next = odata->current_file->next; | ||||
6841 | odata->edata->file_list = g_list_remove_link (odata->edata->file_list, odata->current_file); | ||||
6842 | path_list_free (odata->current_file); | ||||
6843 | odata->current_file = next; | ||||
6844 | odata->extract_all = FALSE(0); | ||||
6845 | } | ||||
6846 | break; | ||||
6847 | |||||
6848 | case CTK_RESPONSE_DELETE_EVENT: | ||||
6849 | case CTK_RESPONSE_CANCEL: | ||||
6850 | do_not_extract = TRUE(!(0)); | ||||
6851 | break; | ||||
6852 | |||||
6853 | default: | ||||
6854 | break; | ||||
6855 | } | ||||
6856 | |||||
6857 | ctk_widget_destroy (CTK_WIDGET (dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_widget_get_type ()))))))); | ||||
6858 | |||||
6859 | if (do_not_extract) { | ||||
6860 | fr_window_stop_batch (odata->window); | ||||
6861 | g_free (odata); | ||||
6862 | return; | ||||
6863 | } | ||||
6864 | |||||
6865 | _fr_window_ask_overwrite_dialog (odata); | ||||
6866 | } | ||||
6867 | |||||
6868 | |||||
6869 | static void | ||||
6870 | _fr_window_ask_overwrite_dialog (OverwriteData *odata) | ||||
6871 | { | ||||
6872 | while ((odata->edata->overwrite == FR_OVERWRITE_ASK) && (odata->current_file != NULL((void*)0))) { | ||||
6873 | const char *base_name; | ||||
6874 | char *e_base_name; | ||||
6875 | char *dest_uri; | ||||
6876 | GFile *file; | ||||
6877 | GFileInfo *info; | ||||
6878 | GFileType file_type; | ||||
6879 | |||||
6880 | base_name = _g_path_get_base_name ((char *) odata->current_file->data, odata->edata->base_dir, odata->edata->junk_paths); | ||||
6881 | e_base_name = g_uri_escape_string (base_name, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH"!$&'()*+,;=" ":@" "/", TRUE(!(0))); | ||||
6882 | dest_uri = g_strdup_printf ("%s/%s", odata->edata->extract_to_dir, e_base_name); | ||||
6883 | file = g_file_new_for_uri (dest_uri); | ||||
6884 | info = g_file_query_info (file, | ||||
6885 | G_FILE_ATTRIBUTE_STANDARD_TYPE"standard::type" "," G_FILE_ATTRIBUTE_STANDARD_NAME"standard::name" "," G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME"standard::display-name", | ||||
6886 | G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, | ||||
6887 | NULL((void*)0), | ||||
6888 | NULL((void*)0)); | ||||
6889 | |||||
6890 | g_free (dest_uri); | ||||
6891 | g_free (e_base_name); | ||||
6892 | |||||
6893 | if (info == NULL((void*)0)) { | ||||
6894 | g_object_unref (file); | ||||
6895 | odata->current_file = odata->current_file->next; | ||||
6896 | continue; | ||||
6897 | } | ||||
6898 | |||||
6899 | file_type = g_file_info_get_file_type (info); | ||||
6900 | if ((file_type != G_FILE_TYPE_UNKNOWN) && (file_type != G_FILE_TYPE_DIRECTORY)) { | ||||
6901 | char *msg; | ||||
6902 | GFile *parent; | ||||
6903 | char *parent_name; | ||||
6904 | char *details; | ||||
6905 | CtkWidget *d; | ||||
6906 | |||||
6907 | msg = g_strdup_printf (_("Replace file \"%s\"?")gettext ("Replace file \"%s\"?"), g_file_info_get_display_name (info)); | ||||
6908 | parent = g_file_get_parent (file); | ||||
6909 | parent_name = g_file_get_parse_name (parent); | ||||
6910 | 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); | ||||
6911 | d = _ctk_message_dialog_new (CTK_WINDOW (odata->window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((odata->window)), ((ctk_window_get_type ())))))), | ||||
6912 | CTK_DIALOG_MODAL, | ||||
6913 | "dialog-question", | ||||
6914 | msg, | ||||
6915 | details, | ||||
6916 | CTK_STOCK_CANCEL((CtkStock)"ctk-cancel"), CTK_RESPONSE_CANCEL, | ||||
6917 | _("Replace _All")gettext ("Replace _All"), _FR_RESPONSE_OVERWRITE_YES_ALL100, | ||||
6918 | _("_Skip")gettext ("_Skip"), _FR_RESPONSE_OVERWRITE_NO102, | ||||
6919 | _("_Replace")gettext ("_Replace"), _FR_RESPONSE_OVERWRITE_YES101, | ||||
6920 | NULL((void*)0)); | ||||
6921 | 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); | ||||
6922 | g_signal_connect (d,g_signal_connect_data ((d), ("response"), (((GCallback) (overwrite_dialog_response_cb ))), (odata), ((void*)0), (GConnectFlags) 0) | ||||
6923 | "response",g_signal_connect_data ((d), ("response"), (((GCallback) (overwrite_dialog_response_cb ))), (odata), ((void*)0), (GConnectFlags) 0) | ||||
6924 | G_CALLBACK (overwrite_dialog_response_cb),g_signal_connect_data ((d), ("response"), (((GCallback) (overwrite_dialog_response_cb ))), (odata), ((void*)0), (GConnectFlags) 0) | ||||
6925 | odata)g_signal_connect_data ((d), ("response"), (((GCallback) (overwrite_dialog_response_cb ))), (odata), ((void*)0), (GConnectFlags) 0); | ||||
6926 | ctk_widget_show (d); | ||||
6927 | |||||
6928 | g_free (parent_name); | ||||
6929 | g_object_unref (parent); | ||||
6930 | g_object_unref (info); | ||||
6931 | g_object_unref (file); | ||||
6932 | |||||
6933 | return; | ||||
6934 | } | ||||
6935 | else | ||||
6936 | odata->current_file = odata->current_file->next; | ||||
6937 | |||||
6938 | g_object_unref (info); | ||||
6939 | g_object_unref (file); | ||||
6940 | } | ||||
6941 | |||||
6942 | if (odata->edata->file_list != NULL((void*)0)) { | ||||
6943 | /* speed optimization: passing NULL when extracting all the | ||||
6944 | * files is faster if the command supports the | ||||
6945 | * propCanExtractAll property. */ | ||||
6946 | if (odata->extract_all) { | ||||
6947 | path_list_free (odata->edata->file_list); | ||||
6948 | odata->edata->file_list = NULL((void*)0); | ||||
6949 | } | ||||
6950 | odata->edata->overwrite = FR_OVERWRITE_YES; | ||||
6951 | _fr_window_archive_extract_from_edata (odata->window, odata->edata); | ||||
6952 | } | ||||
6953 | else { | ||||
6954 | CtkWidget *d; | ||||
6955 | |||||
6956 | d = _ctk_message_dialog_new (CTK_WINDOW (odata->window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((odata->window)), ((ctk_window_get_type ())))))), | ||||
6957 | 0, | ||||
6958 | "dialog-warning", | ||||
6959 | _("Extraction not performed")gettext ("Extraction not performed"), | ||||
6960 | NULL((void*)0), | ||||
6961 | CTK_STOCK_OK((CtkStock)"ctk-ok"), CTK_RESPONSE_OK, | ||||
6962 | NULL((void*)0)); | ||||
6963 | ctk_dialog_set_default_response (CTK_DIALOG (d)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((d)), ((ctk_dialog_get_type ())))))), CTK_RESPONSE_OK); | ||||
6964 | 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")); | ||||
6965 | |||||
6966 | fr_window_stop_batch (odata->window); | ||||
6967 | } | ||||
6968 | g_free (odata); | ||||
6969 | } | ||||
6970 | |||||
6971 | |||||
6972 | void | ||||
6973 | fr_window_archive_extract (FrWindow *window, | ||||
6974 | GList *file_list, | ||||
6975 | const char *extract_to_dir, | ||||
6976 | const char *base_dir, | ||||
6977 | gboolean skip_older, | ||||
6978 | FrOverwrite overwrite, | ||||
6979 | gboolean junk_paths, | ||||
6980 | gboolean ask_to_open_destination) | ||||
6981 | { | ||||
6982 | ExtractData *edata; | ||||
6983 | gboolean do_not_extract = FALSE(0); | ||||
6984 | GError *error = NULL((void*)0); | ||||
6985 | |||||
6986 | edata = extract_data_new (file_list, | ||||
6987 | extract_to_dir, | ||||
6988 | base_dir, | ||||
6989 | skip_older, | ||||
6990 | overwrite, | ||||
6991 | junk_paths, | ||||
6992 | FALSE(0), | ||||
6993 | ask_to_open_destination); | ||||
6994 | |||||
6995 | fr_window_set_current_batch_action (window, | ||||
6996 | FR_BATCH_ACTION_EXTRACT, | ||||
6997 | edata, | ||||
6998 | (GFreeFunc) extract_data_free); | ||||
6999 | |||||
7000 | if (archive_is_encrypted (window, edata->file_list) && (window->priv->password == NULL((void*)0))) { | ||||
7001 | dlg_ask_password (window); | ||||
7002 | return; | ||||
7003 | } | ||||
7004 | |||||
7005 | if (! uri_is_dir (edata->extract_to_dir)) { | ||||
7006 | |||||
7007 | /* There is nothing to ask if the destination doesn't exist. */ | ||||
7008 | if (edata->overwrite == FR_OVERWRITE_ASK) | ||||
7009 | edata->overwrite = FR_OVERWRITE_YES; | ||||
7010 | |||||
7011 | if (! ForceDirectoryCreation) { | ||||
7012 | CtkWidget *d; | ||||
7013 | int r; | ||||
7014 | char *folder_name; | ||||
7015 | char *msg; | ||||
7016 | |||||
7017 | folder_name = g_filename_display_name (edata->extract_to_dir); | ||||
7018 | 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); | ||||
7019 | g_free (folder_name); | ||||
7020 | |||||
7021 | d = _ctk_message_dialog_new (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), | ||||
7022 | CTK_DIALOG_MODAL, | ||||
7023 | "dialog-question", | ||||
7024 | msg, | ||||
7025 | NULL((void*)0), | ||||
7026 | CTK_STOCK_CANCEL((CtkStock)"ctk-cancel"), CTK_RESPONSE_CANCEL, | ||||
7027 | _("Create _Folder")gettext ("Create _Folder"), CTK_RESPONSE_YES, | ||||
7028 | NULL((void*)0)); | ||||
7029 | |||||
7030 | ctk_dialog_set_default_response (CTK_DIALOG (d)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((d)), ((ctk_dialog_get_type ())))))), CTK_RESPONSE_YES); | ||||
7031 | r = ctk_dialog_run (CTK_DIALOG (d)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((d)), ((ctk_dialog_get_type ()))))))); | ||||
7032 | ctk_widget_destroy (CTK_WIDGET (d)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((d)), ((ctk_widget_get_type ()))))))); | ||||
7033 | |||||
7034 | g_free (msg); | ||||
7035 | |||||
7036 | if (r != CTK_RESPONSE_YES) | ||||
7037 | do_not_extract = TRUE(!(0)); | ||||
7038 | } | ||||
7039 | |||||
7040 | if (! do_not_extract && ! ensure_dir_exists (edata->extract_to_dir, 0755, &error)) { | ||||
7041 | CtkWidget *d; | ||||
7042 | char *details; | ||||
7043 | |||||
7044 | details = g_strdup_printf (_("Could not create the destination folder: %s.")gettext ("Could not create the destination folder: %s."), error->message); | ||||
7045 | d = _ctk_error_dialog_new (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), | ||||
7046 | 0, | ||||
7047 | NULL((void*)0), | ||||
7048 | _("Extraction not performed")gettext ("Extraction not performed"), | ||||
7049 | "%s", | ||||
7050 | details); | ||||
7051 | g_clear_error (&error); | ||||
7052 | fr_window_show_error_dialog (window, d, CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), details); | ||||
7053 | fr_window_stop_batch (window); | ||||
7054 | |||||
7055 | g_free (details); | ||||
7056 | |||||
7057 | return; | ||||
7058 | } | ||||
7059 | } | ||||
7060 | |||||
7061 | if (do_not_extract) { | ||||
7062 | CtkWidget *d; | ||||
7063 | |||||
7064 | d = _ctk_message_dialog_new (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), | ||||
7065 | 0, | ||||
7066 | "dialog-warning", | ||||
7067 | _("Extraction not performed")gettext ("Extraction not performed"), | ||||
7068 | NULL((void*)0), | ||||
7069 | CTK_STOCK_OK((CtkStock)"ctk-ok"), CTK_RESPONSE_OK, | ||||
7070 | NULL((void*)0)); | ||||
7071 | ctk_dialog_set_default_response (CTK_DIALOG (d)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((d)), ((ctk_dialog_get_type ())))))), CTK_RESPONSE_OK); | ||||
7072 | 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")); | ||||
7073 | fr_window_stop_batch (window); | ||||
7074 | |||||
7075 | return; | ||||
7076 | } | ||||
7077 | |||||
7078 | if (edata->overwrite == FR_OVERWRITE_ASK) { | ||||
7079 | OverwriteData *odata; | ||||
7080 | |||||
7081 | odata = g_new0 (OverwriteData, 1)((OverwriteData *) g_malloc0_n ((1), sizeof (OverwriteData))); | ||||
7082 | odata->window = window; | ||||
7083 | odata->edata = edata; | ||||
7084 | odata->extract_all = (edata->file_list == NULL((void*)0)) || (g_list_length (edata->file_list) == window->archive->command->files->len); | ||||
7085 | if (edata->file_list == NULL((void*)0)) | ||||
7086 | edata->file_list = fr_window_get_file_list (window); | ||||
7087 | odata->current_file = odata->edata->file_list; | ||||
7088 | _fr_window_ask_overwrite_dialog (odata); | ||||
7089 | } | ||||
7090 | else | ||||
7091 | _fr_window_archive_extract_from_edata (window, edata); | ||||
7092 | } | ||||
7093 | |||||
7094 | |||||
7095 | void | ||||
7096 | fr_window_archive_test (FrWindow *window) | ||||
7097 | { | ||||
7098 | fr_window_set_current_batch_action (window, | ||||
7099 | FR_BATCH_ACTION_TEST, | ||||
7100 | NULL((void*)0), | ||||
7101 | NULL((void*)0)); | ||||
7102 | fr_archive_test (window->archive, window->priv->password); | ||||
7103 | } | ||||
7104 | |||||
7105 | |||||
7106 | void | ||||
7107 | fr_window_set_password (FrWindow *window, | ||||
7108 | const char *password) | ||||
7109 | { | ||||
7110 | 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); | ||||
7111 | |||||
7112 | if (window->priv->password != NULL((void*)0)) { | ||||
7113 | g_free (window->priv->password); | ||||
7114 | window->priv->password = NULL((void*)0); | ||||
7115 | } | ||||
7116 | |||||
7117 | if ((password != NULL((void*)0)) && (password[0] != '\0')) | ||||
7118 | window->priv->password = g_strdup (password)g_strdup_inline (password); | ||||
7119 | } | ||||
7120 | |||||
7121 | void | ||||
7122 | fr_window_set_password_for_paste (FrWindow *window, | ||||
7123 | const char *password) | ||||
7124 | { | ||||
7125 | 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); | ||||
7126 | |||||
7127 | if (window->priv->password_for_paste != NULL((void*)0)) { | ||||
7128 | g_free (window->priv->password_for_paste); | ||||
7129 | window->priv->password_for_paste = NULL((void*)0); | ||||
7130 | } | ||||
7131 | |||||
7132 | if ((password != NULL((void*)0)) && (password[0] != '\0')) | ||||
7133 | window->priv->password_for_paste = g_strdup (password)g_strdup_inline (password); | ||||
7134 | } | ||||
7135 | |||||
7136 | const char * | ||||
7137 | fr_window_get_password (FrWindow *window) | ||||
7138 | { | ||||
7139 | 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); | ||||
7140 | |||||
7141 | return window->priv->password; | ||||
7142 | } | ||||
7143 | |||||
7144 | |||||
7145 | void | ||||
7146 | fr_window_set_encrypt_header (FrWindow *window, | ||||
7147 | gboolean encrypt_header) | ||||
7148 | { | ||||
7149 | 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); | ||||
7150 | |||||
7151 | window->priv->encrypt_header = encrypt_header; | ||||
7152 | } | ||||
7153 | |||||
7154 | |||||
7155 | gboolean | ||||
7156 | fr_window_get_encrypt_header (FrWindow *window) | ||||
7157 | { | ||||
7158 | return window->priv->encrypt_header; | ||||
7159 | } | ||||
7160 | |||||
7161 | |||||
7162 | void | ||||
7163 | fr_window_set_compression (FrWindow *window, | ||||
7164 | FrCompression compression) | ||||
7165 | { | ||||
7166 | 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); | ||||
7167 | |||||
7168 | window->priv->compression = compression; | ||||
7169 | } | ||||
7170 | |||||
7171 | |||||
7172 | FrCompression | ||||
7173 | fr_window_get_compression (FrWindow *window) | ||||
7174 | { | ||||
7175 | return window->priv->compression; | ||||
7176 | } | ||||
7177 | |||||
7178 | |||||
7179 | void | ||||
7180 | fr_window_set_volume_size (FrWindow *window, | ||||
7181 | guint volume_size) | ||||
7182 | { | ||||
7183 | 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); | ||||
7184 | |||||
7185 | window->priv->volume_size = volume_size; | ||||
7186 | } | ||||
7187 | |||||
7188 | |||||
7189 | guint | ||||
7190 | fr_window_get_volume_size (FrWindow *window) | ||||
7191 | { | ||||
7192 | return window->priv->volume_size; | ||||
7193 | } | ||||
7194 | |||||
7195 | |||||
7196 | void | ||||
7197 | fr_window_go_to_location (FrWindow *window, | ||||
7198 | const char *path, | ||||
7199 | gboolean force_update) | ||||
7200 | { | ||||
7201 | char *dir; | ||||
7202 | |||||
7203 | 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); | ||||
7204 | 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); | ||||
7205 | |||||
7206 | if (force_update) { | ||||
7207 | g_free (window->priv->last_location); | ||||
7208 | window->priv->last_location = NULL((void*)0); | ||||
7209 | } | ||||
7210 | |||||
7211 | if (path[strlen (path) - 1] != '/') | ||||
7212 | dir = g_strconcat (path, "/", NULL((void*)0)); | ||||
7213 | else | ||||
7214 | dir = g_strdup (path)g_strdup_inline (path); | ||||
7215 | |||||
7216 | if ((window->priv->last_location == NULL((void*)0)) || (strcmp (window->priv->last_location, dir) != 0)) { | ||||
7217 | g_free (window->priv->last_location); | ||||
7218 | window->priv->last_location = dir; | ||||
7219 | |||||
7220 | fr_window_history_add (window, dir); | ||||
7221 | fr_window_update_file_list (window, TRUE(!(0))); | ||||
7222 | fr_window_update_current_location (window); | ||||
7223 | } | ||||
7224 | else | ||||
7225 | g_free (dir); | ||||
7226 | } | ||||
7227 | |||||
7228 | |||||
7229 | const char * | ||||
7230 | fr_window_get_current_location (FrWindow *window) | ||||
7231 | { | ||||
7232 | if (window->priv->history_current == NULL((void*)0)) { | ||||
7233 | fr_window_history_add (window, "/"); | ||||
7234 | return window->priv->history_current->data; | ||||
7235 | } | ||||
7236 | else | ||||
7237 | return (const char*) window->priv->history_current->data; | ||||
7238 | } | ||||
7239 | |||||
7240 | |||||
7241 | void | ||||
7242 | fr_window_go_up_one_level (FrWindow *window) | ||||
7243 | { | ||||
7244 | char *parent_dir; | ||||
7245 | |||||
7246 | 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); | ||||
7247 | |||||
7248 | parent_dir = get_parent_dir (fr_window_get_current_location (window)); | ||||
7249 | fr_window_go_to_location (window, parent_dir, FALSE(0)); | ||||
7250 | g_free (parent_dir); | ||||
7251 | } | ||||
7252 | |||||
7253 | |||||
7254 | void | ||||
7255 | fr_window_go_back (FrWindow *window) | ||||
7256 | { | ||||
7257 | 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); | ||||
7258 | |||||
7259 | if (window->priv->history == NULL((void*)0)) | ||||
7260 | return; | ||||
7261 | if (window->priv->history_current == NULL((void*)0)) | ||||
7262 | return; | ||||
7263 | if (window->priv->history_current->next == NULL((void*)0)) | ||||
7264 | return; | ||||
7265 | window->priv->history_current = window->priv->history_current->next; | ||||
7266 | |||||
7267 | fr_window_go_to_location (window, window->priv->history_current->data, FALSE(0)); | ||||
7268 | } | ||||
7269 | |||||
7270 | |||||
7271 | void | ||||
7272 | fr_window_go_forward (FrWindow *window) | ||||
7273 | { | ||||
7274 | 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); | ||||
7275 | |||||
7276 | if (window->priv->history == NULL((void*)0)) | ||||
7277 | return; | ||||
7278 | if (window->priv->history_current == NULL((void*)0)) | ||||
7279 | return; | ||||
7280 | if (window->priv->history_current->prev == NULL((void*)0)) | ||||
7281 | return; | ||||
7282 | window->priv->history_current = window->priv->history_current->prev; | ||||
7283 | |||||
7284 | fr_window_go_to_location (window, window->priv->history_current->data, FALSE(0)); | ||||
7285 | } | ||||
7286 | |||||
7287 | |||||
7288 | void | ||||
7289 | fr_window_set_list_mode (FrWindow *window, | ||||
7290 | FrWindowListMode list_mode) | ||||
7291 | { | ||||
7292 | 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); | ||||
7293 | |||||
7294 | window->priv->list_mode = window->priv->last_list_mode = list_mode; | ||||
7295 | if (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT) { | ||||
7296 | fr_window_history_clear (window); | ||||
7297 | fr_window_history_add (window, "/"); | ||||
7298 | } | ||||
7299 | |||||
7300 | g_settings_set_enum (window->priv->settings_listing, PREF_LISTING_LIST_MODE"list-mode", window->priv->last_list_mode); | ||||
7301 | g_settings_set_boolean (window->priv->settings_listing, PREF_LISTING_SHOW_PATH"show-path", (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT)); | ||||
7302 | |||||
7303 | fr_window_update_file_list (window, TRUE(!(0))); | ||||
7304 | fr_window_update_dir_tree (window); | ||||
7305 | fr_window_update_current_location (window); | ||||
7306 | } | ||||
7307 | |||||
7308 | |||||
7309 | CtkTreeModel * | ||||
7310 | fr_window_get_list_store (FrWindow *window) | ||||
7311 | { | ||||
7312 | 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 ())))))); | ||||
7313 | } | ||||
7314 | |||||
7315 | |||||
7316 | void | ||||
7317 | fr_window_find (FrWindow *window) | ||||
7318 | { | ||||
7319 | window->priv->filter_mode = TRUE(!(0)); | ||||
7320 | ctk_widget_show (window->priv->filter_bar); | ||||
7321 | ctk_widget_grab_focus (window->priv->filter_entry); | ||||
7322 | } | ||||
7323 | |||||
7324 | |||||
7325 | void | ||||
7326 | fr_window_select_all (FrWindow *window) | ||||
7327 | { | ||||
7328 | 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 ())))))))); | ||||
7329 | } | ||||
7330 | |||||
7331 | |||||
7332 | void | ||||
7333 | fr_window_unselect_all (FrWindow *window) | ||||
7334 | { | ||||
7335 | 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 ())))))))); | ||||
7336 | } | ||||
7337 | |||||
7338 | |||||
7339 | void | ||||
7340 | fr_window_set_sort_type (FrWindow *window, | ||||
7341 | CtkSortType sort_type) | ||||
7342 | { | ||||
7343 | window->priv->sort_type = sort_type; | ||||
7344 | fr_window_update_list_order (window); | ||||
7345 | } | ||||
7346 | |||||
7347 | |||||
7348 | void | ||||
7349 | fr_window_stop (FrWindow *window) | ||||
7350 | { | ||||
7351 | if (! window->priv->stoppable) | ||||
7352 | return; | ||||
7353 | |||||
7354 | if (window->priv->activity_ref > 0) | ||||
7355 | fr_archive_stop (window->archive); | ||||
7356 | |||||
7357 | if (window->priv->convert_data.converting) | ||||
7358 | fr_window_convert_data_free (window, TRUE(!(0))); | ||||
7359 | } | ||||
7360 | |||||
7361 | |||||
7362 | /* -- start/stop activity mode -- */ | ||||
7363 | |||||
7364 | |||||
7365 | static int | ||||
7366 | activity_cb (gpointer data) | ||||
7367 | { | ||||
7368 | FrWindow *window = data; | ||||
7369 | |||||
7370 | if ((window->priv->pd_progress_bar != NULL((void*)0)) && window->priv->progress_pulse) | ||||
7371 | 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 ()))))))); | ||||
7372 | if (window->priv->progress_pulse) | ||||
7373 | 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 ()))))))); | ||||
7374 | |||||
7375 | return TRUE(!(0)); | ||||
7376 | } | ||||
7377 | |||||
7378 | |||||
7379 | void | ||||
7380 | fr_window_start_activity_mode (FrWindow *window) | ||||
7381 | { | ||||
7382 | 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); | ||||
7383 | |||||
7384 | if (window->priv->activity_ref++ > 0) | ||||
7385 | return; | ||||
7386 | |||||
7387 | window->priv->activity_timeout_handle = g_timeout_add (ACTIVITY_DELAY100, | ||||
7388 | activity_cb, | ||||
7389 | window); | ||||
7390 | fr_window_update_sensitivity (window); | ||||
7391 | } | ||||
7392 | |||||
7393 | |||||
7394 | void | ||||
7395 | fr_window_stop_activity_mode (FrWindow *window) | ||||
7396 | { | ||||
7397 | 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); | ||||
7398 | |||||
7399 | if (window->priv->activity_ref == 0) | ||||
7400 | return; | ||||
7401 | |||||
7402 | window->priv->activity_ref--; | ||||
7403 | |||||
7404 | if (window->priv->activity_ref > 0) | ||||
7405 | return; | ||||
7406 | |||||
7407 | if (window->priv->activity_timeout_handle == 0) | ||||
7408 | return; | ||||
7409 | |||||
7410 | g_source_remove (window->priv->activity_timeout_handle); | ||||
7411 | window->priv->activity_timeout_handle = 0; | ||||
7412 | |||||
7413 | if (! ctk_widget_get_realized (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))) | ||||
7414 | return; | ||||
7415 | |||||
7416 | if (window->priv->progress_dialog != NULL((void*)0)) | ||||
7417 | 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); | ||||
7418 | |||||
7419 | if (! window->priv->batch_mode) { | ||||
7420 | if (window->priv->progress_bar != NULL((void*)0)) | ||||
7421 | 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); | ||||
7422 | fr_window_update_sensitivity (window); | ||||
7423 | } | ||||
7424 | } | ||||
7425 | |||||
7426 | |||||
7427 | static gboolean | ||||
7428 | last_output_window__unrealize_cb (CtkWidget *widget, | ||||
7429 | gpointer data) | ||||
7430 | { | ||||
7431 | 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"); | ||||
7432 | return FALSE(0); | ||||
7433 | } | ||||
7434 | |||||
7435 | |||||
7436 | static void | ||||
7437 | fr_window_view_last_output_print(CtkTextBuffer *text_buffer, | ||||
7438 | CtkTextIter *iter, | ||||
7439 | GList *scan) | ||||
7440 | { | ||||
7441 | for (; scan; scan = scan->next) { | ||||
7442 | char *line = scan->data; | ||||
7443 | char *utf8_line; | ||||
7444 | gsize bytes_written; | ||||
7445 | |||||
7446 | utf8_line = g_locale_to_utf8 (line, -1, NULL((void*)0), &bytes_written, NULL((void*)0)); | ||||
7447 | ctk_text_buffer_insert_with_tags_by_name (text_buffer, | ||||
7448 | iter, | ||||
7449 | utf8_line, | ||||
7450 | bytes_written, | ||||
7451 | "monospace", NULL((void*)0)); | ||||
7452 | g_free (utf8_line); | ||||
7453 | ctk_text_buffer_insert (text_buffer, iter, "\n", 1); | ||||
7454 | } | ||||
7455 | } | ||||
7456 | |||||
7457 | void | ||||
7458 | fr_window_view_last_output (FrWindow *window, | ||||
7459 | const char *title) | ||||
7460 | { | ||||
7461 | CtkWidget *dialog; | ||||
7462 | CtkWidget *vbox; | ||||
7463 | CtkWidget *text_view; | ||||
7464 | CtkWidget *scrolled; | ||||
7465 | CtkTextBuffer *text_buffer; | ||||
7466 | CtkTextIter iter; | ||||
7467 | |||||
7468 | if (title == NULL((void*)0)) | ||||
7469 | title = _("Last Output")gettext ("Last Output"); | ||||
7470 | |||||
7471 | dialog = ctk_dialog_new (); | ||||
7472 | ctk_window_set_title (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), title); | ||||
7473 | 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 ()))))))); | ||||
7474 | ctk_window_set_destroy_with_parent (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), TRUE(!(0))); | ||||
7475 | 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); | ||||
7476 | |||||
7477 | ctk_dialog_set_default_response (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), CTK_RESPONSE_CLOSE); | ||||
7478 | ctk_window_set_resizable (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), TRUE(!(0))); | ||||
7479 | ctk_widget_set_size_request (dialog, 500, 300); | ||||
7480 | |||||
7481 | /* Add text */ | ||||
7482 | |||||
7483 | scrolled = ctk_scrolled_window_new (NULL((void*)0), NULL((void*)0)); | ||||
7484 | ctk_scrolled_window_set_policy (CTK_SCROLLED_WINDOW (scrolled)((((CtkScrolledWindow*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((scrolled)), ((ctk_scrolled_window_get_type ())))))), | ||||
7485 | CTK_POLICY_AUTOMATIC, | ||||
7486 | CTK_POLICY_AUTOMATIC); | ||||
7487 | ctk_scrolled_window_set_shadow_type (CTK_SCROLLED_WINDOW (scrolled)((((CtkScrolledWindow*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((scrolled)), ((ctk_scrolled_window_get_type ())))))), | ||||
7488 | CTK_SHADOW_ETCHED_IN); | ||||
7489 | |||||
7490 | text_buffer = ctk_text_buffer_new (NULL((void*)0)); | ||||
7491 | ctk_text_buffer_create_tag (text_buffer, "monospace", | ||||
7492 | "family", "monospace", NULL((void*)0)); | ||||
7493 | |||||
7494 | text_view = ctk_text_view_new_with_buffer (text_buffer); | ||||
7495 | g_object_unref (text_buffer); | ||||
7496 | 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)); | ||||
7497 | 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)); | ||||
7498 | |||||
7499 | /**/ | ||||
7500 | |||||
7501 | vbox = ctk_box_new (CTK_ORIENTATION_VERTICAL, 6); | ||||
7502 | ctk_container_set_border_width (CTK_CONTAINER (vbox)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((vbox)), ((ctk_container_get_type ())))))), 5); | ||||
7503 | |||||
7504 | ctk_container_add (CTK_CONTAINER (scrolled)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((scrolled)), ((ctk_container_get_type ())))))), text_view); | ||||
7505 | ctk_box_pack_start (CTK_BOX (vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((vbox)), ((ctk_box_get_type ())))))), scrolled, | ||||
7506 | TRUE(!(0)), TRUE(!(0)), 0); | ||||
7507 | |||||
7508 | ctk_widget_show_all (vbox); | ||||
7509 | 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 ())))))), | ||||
7510 | vbox, | ||||
7511 | TRUE(!(0)), TRUE(!(0)), 0); | ||||
7512 | |||||
7513 | /* signals */ | ||||
7514 | |||||
7515 | 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) | ||||
7516 | "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) | ||||
7517 | 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) | ||||
7518 | 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); | ||||
7519 | |||||
7520 | 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) | ||||
7521 | "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) | ||||
7522 | 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) | ||||
7523 | 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); | ||||
7524 | |||||
7525 | ctk_text_buffer_get_iter_at_offset (text_buffer, &iter, 0); | ||||
7526 | /* Show STDOUT of process */ | ||||
7527 | fr_window_view_last_output_print(text_buffer, &iter, window->archive->process->out.raw); | ||||
7528 | /* Show STDERR of process */ | ||||
7529 | fr_window_view_last_output_print(text_buffer, &iter, window->archive->process->err.raw); | ||||
7530 | |||||
7531 | /**/ | ||||
7532 | |||||
7533 | 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"); | ||||
7534 | } | ||||
7535 | |||||
7536 | |||||
7537 | /* -- fr_window_rename_selection -- */ | ||||
7538 | |||||
7539 | |||||
7540 | typedef struct { | ||||
7541 | char *path_to_rename; | ||||
7542 | char *old_name; | ||||
7543 | char *new_name; | ||||
7544 | char *current_dir; | ||||
7545 | gboolean is_dir; | ||||
7546 | gboolean dir_in_archive; | ||||
7547 | char *original_path; | ||||
7548 | } RenameData; | ||||
7549 | |||||
7550 | |||||
7551 | static RenameData* | ||||
7552 | rename_data_new (const char *path_to_rename, | ||||
7553 | const char *old_name, | ||||
7554 | const char *new_name, | ||||
7555 | const char *current_dir, | ||||
7556 | gboolean is_dir, | ||||
7557 | gboolean dir_in_archive, | ||||
7558 | const char *original_path) | ||||
7559 | { | ||||
7560 | RenameData *rdata; | ||||
7561 | |||||
7562 | rdata = g_new0 (RenameData, 1)((RenameData *) g_malloc0_n ((1), sizeof (RenameData))); | ||||
7563 | rdata->path_to_rename = g_strdup (path_to_rename)g_strdup_inline (path_to_rename); | ||||
7564 | if (old_name != NULL((void*)0)) | ||||
7565 | rdata->old_name = g_strdup (old_name)g_strdup_inline (old_name); | ||||
7566 | if (new_name != NULL((void*)0)) | ||||
7567 | rdata->new_name = g_strdup (new_name)g_strdup_inline (new_name); | ||||
7568 | if (current_dir != NULL((void*)0)) | ||||
7569 | rdata->current_dir = g_strdup (current_dir)g_strdup_inline (current_dir); | ||||
7570 | rdata->is_dir = is_dir; | ||||
7571 | rdata->dir_in_archive = dir_in_archive; | ||||
7572 | if (original_path != NULL((void*)0)) | ||||
7573 | rdata->original_path = g_strdup (original_path)g_strdup_inline (original_path); | ||||
7574 | |||||
7575 | return rdata; | ||||
7576 | } | ||||
7577 | |||||
7578 | |||||
7579 | static void | ||||
7580 | rename_data_free (RenameData *rdata) | ||||
7581 | { | ||||
7582 | 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); | ||||
7583 | |||||
7584 | g_free (rdata->path_to_rename); | ||||
7585 | g_free (rdata->old_name); | ||||
7586 | g_free (rdata->new_name); | ||||
7587 | g_free (rdata->current_dir); | ||||
7588 | g_free (rdata->original_path); | ||||
7589 | g_free (rdata); | ||||
7590 | } | ||||
7591 | |||||
7592 | |||||
7593 | static void | ||||
7594 | rename_selection (FrWindow *window, | ||||
7595 | const char *path_to_rename, | ||||
7596 | const char *old_name, | ||||
7597 | const char *new_name, | ||||
7598 | const char *current_dir, | ||||
7599 | gboolean is_dir, | ||||
7600 | gboolean dir_in_archive, | ||||
7601 | const char *original_path) | ||||
7602 | { | ||||
7603 | FrArchive *archive = window->archive; | ||||
7604 | RenameData *rdata; | ||||
7605 | char *tmp_dir; | ||||
7606 | GList *file_list; | ||||
7607 | gboolean added_dir; | ||||
7608 | char *new_dirname; | ||||
7609 | GList *new_file_list; | ||||
7610 | GList *scan; | ||||
7611 | |||||
7612 | rdata = rename_data_new (path_to_rename, | ||||
7613 | old_name, | ||||
7614 | new_name, | ||||
7615 | current_dir, | ||||
7616 | is_dir, | ||||
7617 | dir_in_archive, | ||||
7618 | original_path); | ||||
7619 | fr_window_set_current_batch_action (window, | ||||
7620 | FR_BATCH_ACTION_RENAME, | ||||
7621 | rdata, | ||||
7622 | (GFreeFunc) rename_data_free); | ||||
7623 | |||||
7624 | fr_process_clear (archive->process); | ||||
7625 | |||||
7626 | tmp_dir = get_temp_work_dir (NULL((void*)0)); | ||||
7627 | |||||
7628 | if (is_dir) | ||||
7629 | file_list = get_dir_list_from_path (window, rdata->path_to_rename); | ||||
7630 | else | ||||
7631 | file_list = g_list_append (NULL((void*)0), g_strdup (rdata->path_to_rename)g_strdup_inline (rdata->path_to_rename)); | ||||
7632 | |||||
7633 | fr_archive_extract_to_local (archive, | ||||
7634 | file_list, | ||||
7635 | tmp_dir, | ||||
7636 | NULL((void*)0), | ||||
7637 | FALSE(0), | ||||
7638 | TRUE(!(0)), | ||||
7639 | FALSE(0), | ||||
7640 | window->priv->password); | ||||
7641 | |||||
7642 | /* temporarily add the dir to rename to the list if it's stored in the | ||||
7643 | * archive, this way it will be removed from the archive... */ | ||||
7644 | added_dir = FALSE(0); | ||||
7645 | if (is_dir && dir_in_archive && ! g_list_find_custom (file_list, original_path, (GCompareFunc) strcmp)) { | ||||
7646 | file_list = g_list_prepend (file_list, g_strdup (original_path)g_strdup_inline (original_path)); | ||||
7647 | added_dir = TRUE(!(0)); | ||||
7648 | } | ||||
7649 | |||||
7650 | fr_archive_remove (archive, file_list, window->priv->compression); | ||||
7651 | fr_window_clipboard_remove_file_list (window, file_list); | ||||
7652 | |||||
7653 | /* ...and remove it from the list again */ | ||||
7654 | if (added_dir) { | ||||
7655 | GList *tmp; | ||||
7656 | |||||
7657 | tmp = file_list; | ||||
7658 | file_list = g_list_remove_link (file_list, tmp); | ||||
7659 | |||||
7660 | g_free (tmp->data); | ||||
7661 | g_list_free (tmp); | ||||
7662 | } | ||||
7663 | |||||
7664 | /* rename the files. */ | ||||
7665 | |||||
7666 | new_dirname = g_build_filename (rdata->current_dir + 1, rdata->new_name, "/", NULL((void*)0)); | ||||
7667 | new_file_list = NULL((void*)0); | ||||
7668 | if (rdata->is_dir) { | ||||
7669 | char *old_path; | ||||
7670 | char *new_path; | ||||
7671 | |||||
7672 | old_path = g_build_filename (tmp_dir, rdata->current_dir, rdata->old_name, NULL((void*)0)); | ||||
7673 | new_path = g_build_filename (tmp_dir, rdata->current_dir, rdata->new_name, NULL((void*)0)); | ||||
7674 | |||||
7675 | fr_process_begin_command (archive->process, "mv"); | ||||
7676 | fr_process_add_arg (archive->process, "-f"); | ||||
7677 | fr_process_add_arg (archive->process, old_path); | ||||
7678 | fr_process_add_arg (archive->process, new_path); | ||||
7679 | fr_process_end_command (archive->process); | ||||
7680 | |||||
7681 | g_free (old_path); | ||||
7682 | g_free (new_path); | ||||
7683 | } | ||||
7684 | |||||
7685 | for (scan = file_list; scan; scan = scan->next) { | ||||
7686 | const char *current_dir_relative = rdata->current_dir + 1; | ||||
7687 | const char *filename = (char*) scan->data; | ||||
7688 | char *old_path = NULL((void*)0), *common = NULL((void*)0), *new_path = NULL((void*)0); | ||||
7689 | char *new_filename; | ||||
7690 | |||||
7691 | old_path = g_build_filename (tmp_dir, filename, NULL((void*)0)); | ||||
7692 | |||||
7693 | if (strlen (filename) > (strlen (rdata->current_dir) + strlen (rdata->old_name))) | ||||
7694 | common = g_strdup (filename + strlen (rdata->current_dir) + strlen (rdata->old_name))g_strdup_inline (filename + strlen (rdata->current_dir) + strlen (rdata->old_name)); | ||||
7695 | new_path = g_build_filename (tmp_dir, rdata->current_dir, rdata->new_name, common, NULL((void*)0)); | ||||
7696 | |||||
7697 | if (! rdata->is_dir) { | ||||
7698 | fr_process_begin_command (archive->process, "mv"); | ||||
7699 | fr_process_add_arg (archive->process, "-f"); | ||||
7700 | fr_process_add_arg (archive->process, old_path); | ||||
7701 | fr_process_add_arg (archive->process, new_path); | ||||
7702 | fr_process_end_command (archive->process); | ||||
7703 | } | ||||
7704 | |||||
7705 | new_filename = g_build_filename (current_dir_relative, rdata->new_name, common, NULL((void*)0)); | ||||
7706 | new_file_list = g_list_prepend (new_file_list, new_filename); | ||||
7707 | |||||
7708 | g_free (old_path); | ||||
7709 | g_free (common); | ||||
7710 | g_free (new_path); | ||||
7711 | } | ||||
7712 | new_file_list = g_list_reverse (new_file_list); | ||||
7713 | |||||
7714 | /* FIXME: this is broken for tar archives. | ||||
7715 | if (is_dir && dir_in_archive && ! g_list_find_custom (new_file_list, new_dirname, (GCompareFunc) strcmp)) | ||||
7716 | new_file_list = g_list_prepend (new_file_list, g_build_filename (rdata->current_dir + 1, rdata->new_name, NULL)); | ||||
7717 | */ | ||||
7718 | |||||
7719 | fr_archive_add (archive, | ||||
7720 | new_file_list, | ||||
7721 | tmp_dir, | ||||
7722 | NULL((void*)0), | ||||
7723 | FALSE(0), | ||||
7724 | FALSE(0), | ||||
7725 | window->priv->password, | ||||
7726 | window->priv->encrypt_header, | ||||
7727 | window->priv->compression, | ||||
7728 | window->priv->volume_size); | ||||
7729 | |||||
7730 | g_free (new_dirname); | ||||
7731 | path_list_free (new_file_list); | ||||
7732 | path_list_free (file_list); | ||||
7733 | |||||
7734 | /* remove the tmp dir */ | ||||
7735 | |||||
7736 | fr_process_begin_command (archive->process, "rm"); | ||||
7737 | fr_process_set_working_dir (archive->process, g_get_tmp_dir ()); | ||||
7738 | fr_process_set_sticky (archive->process, TRUE(!(0))); | ||||
7739 | fr_process_add_arg (archive->process, "-rf"); | ||||
7740 | fr_process_add_arg (archive->process, tmp_dir); | ||||
7741 | fr_process_end_command (archive->process); | ||||
7742 | |||||
7743 | fr_process_start (archive->process); | ||||
7744 | |||||
7745 | g_free (tmp_dir); | ||||
7746 | } | ||||
7747 | |||||
7748 | |||||
7749 | static gboolean | ||||
7750 | valid_name (const char *new_name, | ||||
7751 | const char *old_name, | ||||
7752 | char **reason) | ||||
7753 | { | ||||
7754 | char *utf8_new_name; | ||||
7755 | gboolean retval = TRUE(!(0)); | ||||
7756 | |||||
7757 | new_name = eat_spaces (new_name); | ||||
7758 | utf8_new_name = g_filename_display_name (new_name); | ||||
7759 | |||||
7760 | if (*new_name == '\0') { | ||||
7761 | /* Translators: the name references to a filename. This message can appear when renaming a file. */ | ||||
7762 | *reason = g_strdup (_("New name is void, please type a name."))g_strdup_inline (gettext ("New name is void, please type a name." )); | ||||
7763 | retval = FALSE(0); | ||||
7764 | } | ||||
7765 | else if (strcmp (new_name, old_name) == 0) { | ||||
7766 | /* Translators: the name references to a filename. This message can appear when renaming a file. */ | ||||
7767 | *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." )); | ||||
7768 | retval = FALSE(0); | ||||
7769 | } | ||||
7770 | else if (strchrs (new_name, BAD_CHARS"/\\*")) { | ||||
7771 | /* Translators: the %s references to a filename. This message can appear when renaming a file. */ | ||||
7772 | *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"/\\*"); | ||||
7773 | retval = FALSE(0); | ||||
7774 | } | ||||
7775 | |||||
7776 | g_free (utf8_new_name); | ||||
7777 | |||||
7778 | return retval; | ||||
7779 | } | ||||
7780 | |||||
7781 | |||||
7782 | static gboolean | ||||
7783 | name_is_present (FrWindow *window, | ||||
7784 | const char *current_dir, | ||||
7785 | const char *new_name, | ||||
7786 | char **reason) | ||||
7787 | { | ||||
7788 | gboolean retval = FALSE(0); | ||||
7789 | guint i; | ||||
7790 | char *new_filename; | ||||
7791 | int new_filename_l; | ||||
7792 | |||||
7793 | *reason = NULL((void*)0); | ||||
7794 | |||||
7795 | new_filename = g_build_filename (current_dir, new_name, NULL((void*)0)); | ||||
7796 | new_filename_l = strlen (new_filename); | ||||
7797 | |||||
7798 | for (i = 0; i < window->archive->command->files->len; i++) { | ||||
7799 | FileData *fdata = g_ptr_array_index (window->archive->command->files, i)((window->archive->command->files)->pdata)[i]; | ||||
7800 | const char *filename = fdata->full_path; | ||||
7801 | |||||
7802 | if ((strncmp (filename, new_filename, new_filename_l) == 0) | ||||
7803 | && ((filename[new_filename_l] == '\0') | ||||
7804 | || (filename[new_filename_l] == G_DIR_SEPARATOR'/'))) { | ||||
7805 | char *utf8_name = g_filename_display_name (new_name); | ||||
7806 | |||||
7807 | if (filename[new_filename_l] == G_DIR_SEPARATOR'/') | ||||
7808 | *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.")); | ||||
7809 | else | ||||
7810 | *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.")); | ||||
7811 | |||||
7812 | retval = TRUE(!(0)); | ||||
7813 | break; | ||||
7814 | } | ||||
7815 | } | ||||
7816 | |||||
7817 | g_free (new_filename); | ||||
7818 | |||||
7819 | return retval; | ||||
7820 | } | ||||
7821 | |||||
7822 | |||||
7823 | void | ||||
7824 | fr_window_rename_selection (FrWindow *window, | ||||
7825 | gboolean from_sidebar) | ||||
7826 | { | ||||
7827 | char *path_to_rename; | ||||
7828 | char *parent_dir; | ||||
7829 | char *old_name; | ||||
7830 | gboolean renaming_dir = FALSE(0); | ||||
7831 | gboolean dir_in_archive = FALSE(0); | ||||
7832 | char *original_path = NULL((void*)0); | ||||
7833 | char *utf8_old_name; | ||||
7834 | char *utf8_new_name; | ||||
7835 | |||||
7836 | if (from_sidebar) { | ||||
7837 | path_to_rename = fr_window_get_selected_folder_in_tree_view (window); | ||||
7838 | if (path_to_rename == NULL((void*)0)) | ||||
7839 | return; | ||||
7840 | parent_dir = remove_level_from_path (path_to_rename); | ||||
7841 | old_name = g_strdup (file_name_from_path (path_to_rename))g_strdup_inline (file_name_from_path (path_to_rename)); | ||||
7842 | renaming_dir = TRUE(!(0)); | ||||
7843 | } | ||||
7844 | else { | ||||
7845 | FileData *selected_item; | ||||
7846 | |||||
7847 | selected_item = fr_window_get_selected_item_from_file_list (window); | ||||
7848 | if (selected_item == NULL((void*)0)) | ||||
7849 | return; | ||||
7850 | |||||
7851 | renaming_dir = file_data_is_dir (selected_item); | ||||
7852 | dir_in_archive = selected_item->dir; | ||||
7853 | original_path = g_strdup (selected_item->original_path)g_strdup_inline (selected_item->original_path); | ||||
7854 | |||||
7855 | if (renaming_dir && ! dir_in_archive) { | ||||
7856 | parent_dir = g_strdup (fr_window_get_current_location (window))g_strdup_inline (fr_window_get_current_location (window)); | ||||
7857 | old_name = g_strdup (selected_item->list_name)g_strdup_inline (selected_item->list_name); | ||||
7858 | path_to_rename = g_build_filename (parent_dir, old_name, NULL((void*)0)); | ||||
7859 | } | ||||
7860 | else { | ||||
7861 | if (renaming_dir) { | ||||
7862 | path_to_rename = remove_ending_separator (selected_item->full_path); | ||||
7863 | parent_dir = remove_level_from_path (path_to_rename); | ||||
7864 | } | ||||
7865 | else { | ||||
7866 | path_to_rename = g_strdup (selected_item->original_path)g_strdup_inline (selected_item->original_path); | ||||
7867 | parent_dir = remove_level_from_path (selected_item->full_path); | ||||
7868 | } | ||||
7869 | old_name = g_strdup (selected_item->name)g_strdup_inline (selected_item->name); | ||||
7870 | } | ||||
7871 | |||||
7872 | file_data_free (selected_item); | ||||
7873 | } | ||||
7874 | |||||
7875 | retry__rename_selection: | ||||
7876 | utf8_old_name = g_locale_to_utf8 (old_name, -1 ,0 ,0 ,0); | ||||
7877 | utf8_new_name = _ctk_request_dialog_run (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), | ||||
7878 | (CTK_DIALOG_DESTROY_WITH_PARENT | ||||
7879 | | CTK_DIALOG_MODAL), | ||||
7880 | _("Rename")gettext ("Rename"), | ||||
7881 | (renaming_dir ? _("_New folder name:")gettext ("_New folder name:") : _("_New file name:")gettext ("_New file name:")), | ||||
7882 | utf8_old_name, | ||||
7883 | 1024, | ||||
7884 | _("_Cancel")gettext ("_Cancel"), | ||||
7885 | _("_Rename")gettext ("_Rename")); | ||||
7886 | g_free (utf8_old_name); | ||||
7887 | |||||
7888 | if (utf8_new_name != NULL((void*)0)) { | ||||
7889 | char *new_name; | ||||
7890 | char *reason = NULL((void*)0); | ||||
7891 | |||||
7892 | new_name = g_filename_from_utf8 (utf8_new_name, -1, 0, 0, 0); | ||||
7893 | g_free (utf8_new_name); | ||||
7894 | |||||
7895 | if (! valid_name (new_name, old_name, &reason)) { | ||||
7896 | char *utf8_name = g_filename_display_name (new_name); | ||||
7897 | CtkWidget *dlg; | ||||
7898 | |||||
7899 | dlg = _ctk_error_dialog_new (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), | ||||
7900 | CTK_DIALOG_DESTROY_WITH_PARENT, | ||||
7901 | NULL((void*)0), | ||||
7902 | (renaming_dir ? _("Could not rename the folder")gettext ("Could not rename the folder") : _("Could not rename the file")gettext ("Could not rename the file")), | ||||
7903 | "%s", | ||||
7904 | reason); | ||||
7905 | ctk_dialog_run (CTK_DIALOG (dlg)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dlg)), ((ctk_dialog_get_type ()))))))); | ||||
7906 | ctk_widget_destroy (dlg); | ||||
7907 | |||||
7908 | g_free (reason); | ||||
7909 | g_free (utf8_name); | ||||
7910 | g_free (new_name); | ||||
7911 | |||||
7912 | goto retry__rename_selection; | ||||
7913 | } | ||||
7914 | |||||
7915 | if (name_is_present (window, parent_dir, new_name, &reason)) { | ||||
7916 | CtkWidget *dlg; | ||||
7917 | |||||
7918 | dlg = _ctk_message_dialog_new (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), | ||||
7919 | CTK_DIALOG_MODAL, | ||||
7920 | "dialog-question", | ||||
7921 | (renaming_dir ? _("Could not rename the folder")gettext ("Could not rename the folder") : _("Could not rename the file")gettext ("Could not rename the file")), | ||||
7922 | reason, | ||||
7923 | CTK_STOCK_CLOSE((CtkStock)"ctk-close"), CTK_RESPONSE_OK, | ||||
7924 | NULL((void*)0)); | ||||
7925 | ctk_dialog_run (CTK_DIALOG (dlg)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dlg)), ((ctk_dialog_get_type ()))))))); | ||||
7926 | ctk_widget_destroy (dlg); | ||||
7927 | g_free (reason); | ||||
7928 | g_free (new_name); | ||||
7929 | goto retry__rename_selection; | ||||
7930 | } | ||||
7931 | |||||
7932 | rename_selection (window, | ||||
7933 | path_to_rename, | ||||
7934 | old_name, | ||||
7935 | new_name, | ||||
7936 | parent_dir, | ||||
7937 | renaming_dir, | ||||
7938 | dir_in_archive, | ||||
7939 | original_path); | ||||
7940 | |||||
7941 | g_free (new_name); | ||||
7942 | } | ||||
7943 | |||||
7944 | g_free (old_name); | ||||
7945 | g_free (parent_dir); | ||||
7946 | g_free (path_to_rename); | ||||
7947 | g_free (original_path); | ||||
7948 | } | ||||
7949 | |||||
7950 | |||||
7951 | static void | ||||
7952 | fr_clipboard_get (CtkClipboard *clipboard, | ||||
7953 | CtkSelectionData *selection_data, | ||||
7954 | guint info, | ||||
7955 | gpointer user_data_or_owner) | ||||
7956 | { | ||||
7957 | FrWindow *window = user_data_or_owner; | ||||
7958 | char *data; | ||||
7959 | |||||
7960 | if (ctk_selection_data_get_target (selection_data) != FR_SPECIAL_URI_LIST(cdk_atom_intern_static_string ("application/grapa-uri-list") )) | ||||
7961 | return; | ||||
7962 | |||||
7963 | data = get_selection_data_from_clipboard_data (window, window->priv->copy_data); | ||||
7964 | ctk_selection_data_set (selection_data, | ||||
7965 | ctk_selection_data_get_target (selection_data), | ||||
7966 | 8, | ||||
7967 | (guchar *) data, | ||||
7968 | strlen (data)); | ||||
7969 | g_free (data); | ||||
7970 | } | ||||
7971 | |||||
7972 | |||||
7973 | static void | ||||
7974 | fr_clipboard_clear (CtkClipboard *clipboard, | ||||
7975 | gpointer user_data_or_owner) | ||||
7976 | { | ||||
7977 | FrWindow *window = user_data_or_owner; | ||||
7978 | |||||
7979 | if (window->priv->copy_data != NULL((void*)0)) { | ||||
7980 | fr_clipboard_data_unref (window->priv->copy_data); | ||||
7981 | window->priv->copy_data = NULL((void*)0); | ||||
7982 | } | ||||
7983 | } | ||||
7984 | |||||
7985 | |||||
7986 | GList * | ||||
7987 | fr_window_get_selection (FrWindow *window, | ||||
7988 | gboolean from_sidebar, | ||||
7989 | char **return_base_dir) | ||||
7990 | { | ||||
7991 | GList *files; | ||||
7992 | char *base_dir; | ||||
7993 | |||||
7994 | if (from_sidebar) { | ||||
7995 | char *selected_folder; | ||||
7996 | char *parent_folder; | ||||
7997 | |||||
7998 | files = fr_window_get_folder_tree_selection (window, TRUE(!(0)), NULL((void*)0)); | ||||
7999 | selected_folder = fr_window_get_selected_folder_in_tree_view (window); | ||||
8000 | parent_folder = remove_level_from_path (selected_folder); | ||||
8001 | if (parent_folder == NULL((void*)0)) | ||||
8002 | base_dir = g_strdup ("/")g_strdup_inline ("/"); | ||||
8003 | else if (parent_folder[strlen (parent_folder) - 1] == '/') | ||||
8004 | base_dir = g_strdup (parent_folder)g_strdup_inline (parent_folder); | ||||
8005 | else | ||||
8006 | base_dir = g_strconcat (parent_folder, "/", NULL((void*)0)); | ||||
8007 | g_free (selected_folder); | ||||
8008 | g_free (parent_folder); | ||||
8009 | } | ||||
8010 | else { | ||||
8011 | files = fr_window_get_file_list_selection (window, TRUE(!(0)), NULL((void*)0)); | ||||
8012 | base_dir = g_strdup (fr_window_get_current_location (window))g_strdup_inline (fr_window_get_current_location (window)); | ||||
8013 | } | ||||
8014 | |||||
8015 | if (return_base_dir) | ||||
8016 | *return_base_dir = base_dir; | ||||
8017 | else | ||||
8018 | g_free (base_dir); | ||||
8019 | |||||
8020 | return files; | ||||
8021 | } | ||||
8022 | |||||
8023 | |||||
8024 | static void | ||||
8025 | fr_window_copy_or_cut_selection (FrWindow *window, | ||||
8026 | FRClipboardOp op, | ||||
8027 | gboolean from_sidebar) | ||||
8028 | { | ||||
8029 | GList *files; | ||||
8030 | char *base_dir; | ||||
8031 | CtkClipboard *clipboard; | ||||
8032 | |||||
8033 | files = fr_window_get_selection (window, from_sidebar, &base_dir); | ||||
8034 | |||||
8035 | if (window->priv->copy_data != NULL((void*)0)) | ||||
8036 | fr_clipboard_data_unref (window->priv->copy_data); | ||||
8037 | window->priv->copy_data = fr_clipboard_data_new (); | ||||
8038 | window->priv->copy_data->files = files; | ||||
8039 | window->priv->copy_data->op = op; | ||||
8040 | window->priv->copy_data->base_dir = base_dir; | ||||
8041 | |||||
8042 | clipboard = ctk_clipboard_get (FR_CLIPBOARD(cdk_atom_intern_static_string ("_RNGRAMPA_SPECIAL_CLIPBOARD" ))); | ||||
8043 | ctk_clipboard_set_with_owner (clipboard, | ||||
8044 | clipboard_targets, | ||||
8045 | G_N_ELEMENTS (clipboard_targets)(sizeof (clipboard_targets) / sizeof ((clipboard_targets)[0]) ), | ||||
8046 | fr_clipboard_get, | ||||
8047 | fr_clipboard_clear, | ||||
8048 | G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (((GType) ((20) << (2))))))))); | ||||
8049 | |||||
8050 | fr_window_update_sensitivity (window); | ||||
8051 | } | ||||
8052 | |||||
8053 | |||||
8054 | void | ||||
8055 | fr_window_copy_selection (FrWindow *window, | ||||
8056 | gboolean from_sidebar) | ||||
8057 | { | ||||
8058 | fr_window_copy_or_cut_selection (window, FR_CLIPBOARD_OP_COPY, from_sidebar); | ||||
8059 | } | ||||
8060 | |||||
8061 | |||||
8062 | void | ||||
8063 | fr_window_cut_selection (FrWindow *window, | ||||
8064 | gboolean from_sidebar) | ||||
8065 | { | ||||
8066 | fr_window_copy_or_cut_selection (window, FR_CLIPBOARD_OP_CUT, from_sidebar); | ||||
8067 | } | ||||
8068 | |||||
8069 | |||||
8070 | static gboolean | ||||
8071 | always_fake_load (FrArchive *archive, | ||||
8072 | gpointer data) | ||||
8073 | { | ||||
8074 | return TRUE(!(0)); | ||||
8075 | } | ||||
8076 | |||||
8077 | |||||
8078 | static void | ||||
8079 | add_pasted_files (FrWindow *window, | ||||
8080 | FrClipboardData *data) | ||||
8081 | { | ||||
8082 | const char *current_dir_relative = data->current_dir + 1; | ||||
8083 | GList *scan; | ||||
8084 | GList *new_file_list = NULL((void*)0); | ||||
8085 | |||||
8086 | if (window->priv->password_for_paste != NULL((void*)0)) { | ||||
8087 | g_free (window->priv->password_for_paste); | ||||
8088 | window->priv->password_for_paste = NULL((void*)0); | ||||
8089 | } | ||||
8090 | |||||
8091 | fr_process_clear (window->archive->process); | ||||
8092 | for (scan = data->files; scan; scan = scan->next) { | ||||
8093 | const char *old_name = (char*) scan->data; | ||||
8094 | char *new_name = g_build_filename (current_dir_relative, old_name + strlen (data->base_dir) - 1, NULL((void*)0)); | ||||
8095 | |||||
8096 | /* skip folders */ | ||||
8097 | |||||
8098 | if ((strcmp (old_name, new_name) != 0) | ||||
8099 | && (old_name[strlen (old_name) - 1] != '/')) | ||||
8100 | { | ||||
8101 | fr_process_begin_command (window->archive->process, "mv"); | ||||
8102 | fr_process_set_working_dir (window->archive->process, data->tmp_dir); | ||||
8103 | fr_process_add_arg (window->archive->process, "-f"); | ||||
8104 | if (old_name[0] == '/') | ||||
8105 | old_name = old_name + 1; | ||||
8106 | fr_process_add_arg (window->archive->process, old_name); | ||||
8107 | fr_process_add_arg (window->archive->process, new_name); | ||||
8108 | fr_process_end_command (window->archive->process); | ||||
8109 | } | ||||
8110 | |||||
8111 | new_file_list = g_list_prepend (new_file_list, new_name); | ||||
8112 | } | ||||
8113 | |||||
8114 | fr_archive_add (window->archive, | ||||
8115 | new_file_list, | ||||
8116 | data->tmp_dir, | ||||
8117 | NULL((void*)0), | ||||
8118 | FALSE(0), | ||||
8119 | FALSE(0), | ||||
8120 | window->priv->password, | ||||
8121 | window->priv->encrypt_header, | ||||
8122 | window->priv->compression, | ||||
8123 | window->priv->volume_size); | ||||
8124 | |||||
8125 | path_list_free (new_file_list); | ||||
8126 | |||||
8127 | /* remove the tmp dir */ | ||||
8128 | |||||
8129 | fr_process_begin_command (window->archive->process, "rm"); | ||||
8130 | fr_process_set_working_dir (window->archive->process, g_get_tmp_dir ()); | ||||
8131 | fr_process_set_sticky (window->archive->process, TRUE(!(0))); | ||||
8132 | fr_process_add_arg (window->archive->process, "-rf"); | ||||
8133 | fr_process_add_arg (window->archive->process, data->tmp_dir); | ||||
8134 | fr_process_end_command (window->archive->process); | ||||
8135 | |||||
8136 | fr_process_start (window->archive->process); | ||||
8137 | } | ||||
8138 | |||||
8139 | |||||
8140 | static void | ||||
8141 | copy_from_archive_action_performed_cb (FrArchive *archive, | ||||
8142 | FrAction action, | ||||
8143 | FrProcError *error, | ||||
8144 | gpointer data) | ||||
8145 | { | ||||
8146 | FrWindow *window = data; | ||||
8147 | gboolean UNUSED_VARIABLE__attribute__ ((unused)) continue_batch = FALSE(0); | ||||
8148 | |||||
8149 | #ifdef CAFE_ENABLE_DEBUG | ||||
8150 | debug (DEBUG_INFO"fr-window.c", 8150, __FUNCTION__, "%s [DONE] (FR::Window)\n", get_action_name (action)); | ||||
8151 | #endif | ||||
8152 | |||||
8153 | fr_window_stop_activity_mode (window); | ||||
8154 | fr_window_pop_message (window); | ||||
8155 | close_progress_dialog (window, FALSE(0)); | ||||
8156 | |||||
8157 | if (error->type == FR_PROC_ERROR_ASK_PASSWORD) { | ||||
8158 | dlg_ask_password_for_paste_operation (window); | ||||
8159 | return; | ||||
8160 | } | ||||
8161 | |||||
8162 | (void) handle_errors (window, archive, action, error); | ||||
8163 | |||||
8164 | if (error->type != FR_PROC_ERROR_NONE) { | ||||
8165 | fr_clipboard_data_unref (window->priv->clipboard_data); | ||||
8166 | window->priv->clipboard_data = NULL((void*)0); | ||||
8167 | return; | ||||
8168 | } | ||||
8169 | |||||
8170 | switch (action) { | ||||
8171 | case FR_ACTION_LISTING_CONTENT: | ||||
8172 | fr_process_clear (window->priv->copy_from_archive->process); | ||||
8173 | fr_archive_extract_to_local (window->priv->copy_from_archive, | ||||
8174 | window->priv->clipboard_data->files, | ||||
8175 | window->priv->clipboard_data->tmp_dir, | ||||
8176 | NULL((void*)0), | ||||
8177 | FALSE(0), | ||||
8178 | TRUE(!(0)), | ||||
8179 | FALSE(0), | ||||
8180 | window->priv->clipboard_data->archive_password); | ||||
8181 | fr_process_start (window->priv->copy_from_archive->process); | ||||
8182 | break; | ||||
8183 | |||||
8184 | case FR_ACTION_EXTRACTING_FILES: | ||||
8185 | if (window->priv->clipboard_data->op == FR_CLIPBOARD_OP_CUT) { | ||||
8186 | fr_process_clear (window->priv->copy_from_archive->process); | ||||
8187 | fr_archive_remove (window->priv->copy_from_archive, | ||||
8188 | window->priv->clipboard_data->files, | ||||
8189 | window->priv->compression); | ||||
8190 | fr_process_start (window->priv->copy_from_archive->process); | ||||
8191 | } | ||||
8192 | else | ||||
8193 | add_pasted_files (window, window->priv->clipboard_data); | ||||
8194 | break; | ||||
8195 | |||||
8196 | case FR_ACTION_DELETING_FILES: | ||||
8197 | add_pasted_files (window, window->priv->clipboard_data); | ||||
8198 | break; | ||||
8199 | |||||
8200 | default: | ||||
8201 | break; | ||||
8202 | } | ||||
8203 | } | ||||
8204 | |||||
8205 | |||||
8206 | static void | ||||
8207 | fr_window_paste_from_clipboard_data (FrWindow *window, | ||||
8208 | FrClipboardData *data) | ||||
8209 | { | ||||
8210 | const char *current_dir_relative; | ||||
8211 | GHashTable *created_dirs; | ||||
8212 | GList *scan; | ||||
8213 | |||||
8214 | if (window->priv->password_for_paste != NULL((void*)0)) | ||||
8215 | fr_clipboard_data_set_password (data, window->priv->password_for_paste); | ||||
8216 | |||||
8217 | if (window->priv->clipboard_data != data) { | ||||
8218 | fr_clipboard_data_unref (window->priv->clipboard_data); | ||||
8219 | window->priv->clipboard_data = data; | ||||
8220 | } | ||||
8221 | |||||
8222 | fr_window_set_current_batch_action (window, | ||||
8223 | FR_BATCH_ACTION_PASTE, | ||||
8224 | fr_clipboard_data_ref (data), | ||||
8225 | (GFreeFunc) fr_clipboard_data_unref); | ||||
8226 | |||||
8227 | current_dir_relative = data->current_dir + 1; | ||||
8228 | |||||
8229 | data->tmp_dir = get_temp_work_dir (NULL((void*)0)); | ||||
8230 | created_dirs = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL((void*)0)); | ||||
8231 | for (scan = data->files; scan; scan = scan->next) { | ||||
8232 | const char *old_name = (char*) scan->data; | ||||
8233 | char *new_name = g_build_filename (current_dir_relative, old_name + strlen (data->base_dir) - 1, NULL((void*)0)); | ||||
8234 | char *dir = remove_level_from_path (new_name); | ||||
8235 | |||||
8236 | if ((dir != NULL((void*)0)) && (g_hash_table_lookup (created_dirs, dir) == NULL((void*)0))) { | ||||
8237 | char *dir_path; | ||||
8238 | |||||
8239 | dir_path = g_build_filename (data->tmp_dir, dir, NULL((void*)0)); | ||||
8240 | debug (DEBUG_INFO"fr-window.c", 8240, __FUNCTION__, "mktree %s\n", dir_path); | ||||
8241 | make_directory_tree_from_path (dir_path, 0700, NULL((void*)0)); | ||||
8242 | |||||
8243 | g_free (dir_path); | ||||
8244 | g_hash_table_replace (created_dirs, g_strdup (dir)g_strdup_inline (dir), "1"); | ||||
8245 | } | ||||
8246 | |||||
8247 | g_free (dir); | ||||
8248 | g_free (new_name); | ||||
8249 | } | ||||
8250 | g_hash_table_destroy (created_dirs); | ||||
8251 | |||||
8252 | /**/ | ||||
8253 | |||||
8254 | if (window->priv->copy_from_archive == NULL((void*)0)) { | ||||
8255 | window->priv->copy_from_archive = fr_archive_new (); | ||||
8256 | 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 ) | ||||
8257 | "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 ) | ||||
8258 | 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 ) | ||||
8259 | 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 ); | ||||
8260 | 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) | ||||
8261 | "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) | ||||
8262 | 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) | ||||
8263 | 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); | ||||
8264 | 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) | ||||
8265 | "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) | ||||
8266 | 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) | ||||
8267 | 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); | ||||
8268 | 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) | ||||
8269 | "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) | ||||
8270 | 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) | ||||
8271 | 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); | ||||
8272 | 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) | ||||
8273 | "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) | ||||
8274 | 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) | ||||
8275 | 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); | ||||
8276 | fr_archive_set_fake_load_func (window->priv->copy_from_archive, always_fake_load, NULL((void*)0)); | ||||
8277 | } | ||||
8278 | fr_archive_load_local (window->priv->copy_from_archive, | ||||
8279 | data->archive_filename, | ||||
8280 | data->archive_password); | ||||
8281 | } | ||||
8282 | |||||
8283 | |||||
8284 | static void | ||||
8285 | fr_window_paste_selection_to (FrWindow *window, | ||||
8286 | const char *current_dir) | ||||
8287 | { | ||||
8288 | CtkClipboard *clipboard; | ||||
8289 | CtkSelectionData *selection_data; | ||||
8290 | FrClipboardData *paste_data; | ||||
8291 | |||||
8292 | clipboard = ctk_clipboard_get (FR_CLIPBOARD(cdk_atom_intern_static_string ("_RNGRAMPA_SPECIAL_CLIPBOARD" ))); | ||||
8293 | selection_data = ctk_clipboard_wait_for_contents (clipboard, FR_SPECIAL_URI_LIST(cdk_atom_intern_static_string ("application/grapa-uri-list") )); | ||||
8294 | if (selection_data == NULL((void*)0)) | ||||
8295 | return; | ||||
8296 | |||||
8297 | paste_data = get_clipboard_data_from_selection_data (window, (char*) ctk_selection_data_get_data (selection_data)); | ||||
8298 | paste_data->current_dir = g_strdup (current_dir)g_strdup_inline (current_dir); | ||||
8299 | fr_window_paste_from_clipboard_data (window, paste_data); | ||||
8300 | |||||
8301 | ctk_selection_data_free (selection_data); | ||||
8302 | } | ||||
8303 | |||||
8304 | |||||
8305 | void | ||||
8306 | fr_window_paste_selection (FrWindow *window, | ||||
8307 | gboolean from_sidebar) | ||||
8308 | { | ||||
8309 | char *utf8_path, *utf8_old_path, *destination; | ||||
8310 | char *current_dir; | ||||
8311 | |||||
8312 | if (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT) | ||||
8313 | return; | ||||
8314 | |||||
8315 | /**/ | ||||
8316 | |||||
8317 | utf8_old_path = g_filename_to_utf8 (fr_window_get_current_location (window), -1, NULL((void*)0), NULL((void*)0), NULL((void*)0)); | ||||
8318 | utf8_path = _ctk_request_dialog_run (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), | ||||
8319 | (CTK_DIALOG_DESTROY_WITH_PARENT | ||||
8320 | | CTK_DIALOG_MODAL), | ||||
8321 | _("Paste Selection")gettext ("Paste Selection"), | ||||
8322 | _("_Destination folder:")gettext ("_Destination folder:"), | ||||
8323 | utf8_old_path, | ||||
8324 | 1024, | ||||
8325 | _("_Cancel")gettext ("_Cancel"), | ||||
8326 | _("_Paste")gettext ("_Paste")); | ||||
8327 | g_free (utf8_old_path); | ||||
8328 | if (utf8_path == NULL((void*)0)) | ||||
8329 | return; | ||||
8330 | |||||
8331 | destination = g_filename_from_utf8 (utf8_path, -1, NULL((void*)0), NULL((void*)0), NULL((void*)0)); | ||||
8332 | g_free (utf8_path); | ||||
8333 | |||||
8334 | if (destination[0] != '/') | ||||
8335 | current_dir = build_uri (fr_window_get_current_location (window), destination, NULL((void*)0)); | ||||
8336 | else | ||||
8337 | current_dir = g_strdup (destination)g_strdup_inline (destination); | ||||
8338 | g_free (destination); | ||||
8339 | |||||
8340 | fr_window_paste_selection_to (window, current_dir); | ||||
8341 | |||||
8342 | g_free (current_dir); | ||||
8343 | } | ||||
8344 | |||||
8345 | |||||
8346 | /* -- fr_window_open_files -- */ | ||||
8347 | |||||
8348 | |||||
8349 | void | ||||
8350 | fr_window_open_files_with_command (FrWindow *window, | ||||
8351 | GList *file_list, | ||||
8352 | char *command) | ||||
8353 | { | ||||
8354 | GAppInfo *app; | ||||
8355 | GError *error = NULL((void*)0); | ||||
8356 | |||||
8357 | app = g_app_info_create_from_commandline (command, NULL((void*)0), G_APP_INFO_CREATE_NONE, &error); | ||||
8358 | if (error != NULL((void*)0)) { | ||||
8359 | _ctk_error_dialog_run (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), | ||||
8360 | _("Could not perform the operation")gettext ("Could not perform the operation"), | ||||
8361 | "%s", | ||||
8362 | error->message); | ||||
8363 | g_clear_error (&error); | ||||
8364 | return; | ||||
8365 | } | ||||
8366 | |||||
8367 | fr_window_open_files_with_application (window, file_list, app); | ||||
8368 | } | ||||
8369 | |||||
8370 | |||||
8371 | void | ||||
8372 | fr_window_open_files_with_application (FrWindow *window, | ||||
8373 | GList *file_list, | ||||
8374 | GAppInfo *app) | ||||
8375 | { | ||||
8376 | GList *uris; | ||||
8377 | GList *scan; | ||||
8378 | CdkAppLaunchContext *context; | ||||
8379 | GError *error = NULL((void*)0); | ||||
8380 | |||||
8381 | if (window->priv->activity_ref > 0) | ||||
8382 | return; | ||||
8383 | |||||
8384 | g_assert (file_list != NULL)do { if (file_list != ((void*)0)) ; else g_assertion_message_expr (((gchar*) 0), "fr-window.c", 8384, ((const char*) (__func__ )), "file_list != NULL"); } while (0); | ||||
8385 | |||||
8386 | uris = NULL((void*)0); | ||||
8387 | for (scan = file_list; scan; scan = scan->next) | ||||
8388 | uris = g_list_prepend (uris, g_filename_to_uri (scan->data, NULL((void*)0), NULL((void*)0))); | ||||
8389 | |||||
8390 | 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 ())))))))); | ||||
8391 | 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 ())))))))); | ||||
8392 | cdk_app_launch_context_set_timestamp (context, 0); | ||||
8393 | |||||
8394 | 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)) { | ||||
8395 | _ctk_error_dialog_run (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), | ||||
8396 | _("Could not perform the operation")gettext ("Could not perform the operation"), | ||||
8397 | "%s", | ||||
8398 | error->message); | ||||
8399 | g_clear_error (&error); | ||||
8400 | } | ||||
8401 | |||||
8402 | g_object_unref (context); | ||||
8403 | path_list_free (uris); | ||||
8404 | } | ||||
8405 | |||||
8406 | |||||
8407 | typedef struct { | ||||
8408 | FrWindow *window; | ||||
8409 | GList *file_list; | ||||
8410 | gboolean ask_application; | ||||
8411 | CommandData *cdata; | ||||
8412 | } OpenFilesData; | ||||
8413 | |||||
8414 | |||||
8415 | static OpenFilesData* | ||||
8416 | open_files_data_new (FrWindow *window, | ||||
8417 | GList *file_list, | ||||
8418 | gboolean ask_application) | ||||
8419 | |||||
8420 | { | ||||
8421 | OpenFilesData *odata; | ||||
8422 | GList *scan; | ||||
8423 | |||||
8424 | odata = g_new0 (OpenFilesData, 1)((OpenFilesData *) g_malloc0_n ((1), sizeof (OpenFilesData))); | ||||
8425 | odata->window = window; | ||||
8426 | odata->file_list = path_list_dup (file_list); | ||||
8427 | odata->ask_application = ask_application; | ||||
8428 | odata->cdata = g_new0 (CommandData, 1)((CommandData *) g_malloc0_n ((1), sizeof (CommandData))); | ||||
8429 | odata->cdata->temp_dir = get_temp_work_dir (NULL((void*)0)); | ||||
8430 | odata->cdata->file_list = NULL((void*)0); | ||||
8431 | for (scan = file_list; scan; scan = scan->next) { | ||||
8432 | char *file = scan->data; | ||||
8433 | char *filename; | ||||
8434 | |||||
8435 | filename = g_strconcat (odata->cdata->temp_dir, | ||||
8436 | "/", | ||||
8437 | file, | ||||
8438 | NULL((void*)0)); | ||||
8439 | odata->cdata->file_list = g_list_prepend (odata->cdata->file_list, filename); | ||||
8440 | } | ||||
8441 | |||||
8442 | /* Add to CommandList so the cdata is released on exit. */ | ||||
8443 | CommandList = g_list_prepend (CommandList, odata->cdata); | ||||
8444 | |||||
8445 | return odata; | ||||
8446 | } | ||||
8447 | |||||
8448 | |||||
8449 | static void | ||||
8450 | open_files_data_free (OpenFilesData *odata) | ||||
8451 | { | ||||
8452 | 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); | ||||
8453 | |||||
8454 | path_list_free (odata->file_list); | ||||
8455 | g_free (odata); | ||||
8456 | } | ||||
8457 | |||||
8458 | |||||
8459 | void | ||||
8460 | fr_window_update_dialog_closed (FrWindow *window) | ||||
8461 | { | ||||
8462 | window->priv->update_dialog = NULL((void*)0); | ||||
8463 | } | ||||
8464 | |||||
8465 | |||||
8466 | gboolean | ||||
8467 | fr_window_update_files (FrWindow *window, | ||||
8468 | GList *file_list) | ||||
8469 | { | ||||
8470 | GList *scan; | ||||
8471 | |||||
8472 | if (window->priv->activity_ref > 0) | ||||
8473 | return FALSE(0); | ||||
8474 | |||||
8475 | if (window->archive->read_only) | ||||
8476 | return FALSE(0); | ||||
8477 | |||||
8478 | fr_process_clear (window->archive->process); | ||||
8479 | |||||
8480 | for (scan = file_list; scan; scan = scan->next) { | ||||
8481 | OpenFile *file = scan->data; | ||||
8482 | GList *local_file_list; | ||||
8483 | |||||
8484 | local_file_list = g_list_append (NULL((void*)0), file->path); | ||||
8485 | fr_archive_add (window->archive, | ||||
8486 | local_file_list, | ||||
8487 | file->temp_dir, | ||||
8488 | "/", | ||||
8489 | FALSE(0), | ||||
8490 | FALSE(0), | ||||
8491 | window->priv->password, | ||||
8492 | window->priv->encrypt_header, | ||||
8493 | window->priv->compression, | ||||
8494 | window->priv->volume_size); | ||||
8495 | g_list_free (local_file_list); | ||||
8496 | } | ||||
8497 | |||||
8498 | fr_process_start (window->archive->process); | ||||
8499 | |||||
8500 | return TRUE(!(0)); | ||||
8501 | } | ||||
8502 | |||||
8503 | |||||
8504 | static void | ||||
8505 | open_file_modified_cb (GFileMonitor *monitor, | ||||
8506 | GFile *monitor_file, | ||||
8507 | GFile *other_file, | ||||
8508 | GFileMonitorEvent event_type, | ||||
8509 | gpointer user_data) | ||||
8510 | { | ||||
8511 | FrWindow *window = user_data; | ||||
8512 | char *monitor_uri; | ||||
8513 | OpenFile *file; | ||||
8514 | GList *scan; | ||||
8515 | |||||
8516 | if ((event_type != G_FILE_MONITOR_EVENT_CHANGED) | ||||
8517 | && (event_type != G_FILE_MONITOR_EVENT_CREATED)) | ||||
8518 | { | ||||
8519 | return; | ||||
8520 | } | ||||
8521 | |||||
8522 | monitor_uri = g_file_get_uri (monitor_file); | ||||
8523 | file = NULL((void*)0); | ||||
8524 | for (scan = window->priv->open_files; scan; scan = scan->next) { | ||||
8525 | OpenFile *test = scan->data; | ||||
8526 | if (uricmp (test->extracted_uri, monitor_uri) == 0) { | ||||
8527 | file = test; | ||||
8528 | break; | ||||
8529 | } | ||||
8530 | } | ||||
8531 | g_free (monitor_uri); | ||||
8532 | |||||
8533 | 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); | ||||
8534 | |||||
8535 | if (window->priv->update_dialog == NULL((void*)0)) | ||||
8536 | window->priv->update_dialog = dlg_update (window); | ||||
8537 | dlg_update_add_file (window->priv->update_dialog, file); | ||||
8538 | } | ||||
8539 | |||||
8540 | |||||
8541 | static void | ||||
8542 | fr_window_monitor_open_file (FrWindow *window, | ||||
8543 | OpenFile *file) | ||||
8544 | { | ||||
8545 | GFile *f; | ||||
8546 | |||||
8547 | window->priv->open_files = g_list_prepend (window->priv->open_files, file); | ||||
8548 | f = g_file_new_for_uri (file->extracted_uri); | ||||
8549 | file->monitor = g_file_monitor_file (f, 0, NULL((void*)0), NULL((void*)0)); | ||||
8550 | g_signal_connect (file->monitor,g_signal_connect_data ((file->monitor), ("changed"), (((GCallback ) (open_file_modified_cb))), (window), ((void*)0), (GConnectFlags ) 0) | ||||
8551 | "changed",g_signal_connect_data ((file->monitor), ("changed"), (((GCallback ) (open_file_modified_cb))), (window), ((void*)0), (GConnectFlags ) 0) | ||||
8552 | G_CALLBACK (open_file_modified_cb),g_signal_connect_data ((file->monitor), ("changed"), (((GCallback ) (open_file_modified_cb))), (window), ((void*)0), (GConnectFlags ) 0) | ||||
8553 | window)g_signal_connect_data ((file->monitor), ("changed"), (((GCallback ) (open_file_modified_cb))), (window), ((void*)0), (GConnectFlags ) 0); | ||||
8554 | g_object_unref (f); | ||||
8555 | } | ||||
8556 | |||||
8557 | |||||
8558 | static void | ||||
8559 | monitor_extracted_files (OpenFilesData *odata) | ||||
8560 | { | ||||
8561 | FrWindow *window = odata->window; | ||||
8562 | GList *scan1, *scan2; | ||||
8563 | |||||
8564 | for (scan1 = odata->file_list, scan2 = odata->cdata->file_list; | ||||
8565 | scan1 && scan2; | ||||
8566 | scan1 = scan1->next, scan2 = scan2->next) | ||||
8567 | { | ||||
8568 | OpenFile *ofile; | ||||
8569 | const char *file = scan1->data; | ||||
8570 | const char *extracted_path = scan2->data; | ||||
8571 | |||||
8572 | ofile = open_file_new (file, extracted_path, odata->cdata->temp_dir); | ||||
8573 | if (ofile != NULL((void*)0)) | ||||
8574 | fr_window_monitor_open_file (window, ofile); | ||||
8575 | } | ||||
8576 | } | ||||
8577 | |||||
8578 | |||||
8579 | static gboolean | ||||
8580 | fr_window_open_extracted_files (OpenFilesData *odata) | ||||
8581 | { | ||||
8582 | GList *file_list = odata->cdata->file_list; | ||||
8583 | const char *first_file; | ||||
8584 | const char *first_mime_type; | ||||
8585 | GAppInfo *app; | ||||
8586 | GList *files_to_open = NULL((void*)0); | ||||
8587 | CdkAppLaunchContext *context; | ||||
8588 | gboolean result; | ||||
8589 | GError *error = NULL((void*)0); | ||||
8590 | |||||
8591 | 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); | ||||
8592 | |||||
8593 | first_file = (char*) file_list->data; | ||||
8594 | if (first_file == NULL((void*)0)) | ||||
8595 | return FALSE(0); | ||||
8596 | |||||
8597 | if (! odata->window->archive->read_only) | ||||
8598 | monitor_extracted_files (odata); | ||||
8599 | |||||
8600 | if (odata->ask_application) { | ||||
8601 | dlg_open_with (odata->window, file_list); | ||||
8602 | return FALSE(0); | ||||
8603 | } | ||||
8604 | |||||
8605 | first_mime_type = get_file_mime_type_for_path (first_file, FALSE(0)); | ||||
8606 | app = g_app_info_get_default_for_type (first_mime_type, FALSE(0)); | ||||
8607 | |||||
8608 | if (app == NULL((void*)0)) { | ||||
8609 | dlg_open_with (odata->window, file_list); | ||||
8610 | return FALSE(0); | ||||
8611 | } | ||||
8612 | |||||
8613 | files_to_open = g_list_append (files_to_open, g_filename_to_uri (first_file, NULL((void*)0), NULL((void*)0))); | ||||
8614 | |||||
8615 | if (g_app_info_supports_files (app)) { | ||||
8616 | GList *scan; | ||||
8617 | |||||
8618 | for (scan = file_list->next; scan; scan = scan->next) { | ||||
8619 | const char *path = scan->data; | ||||
8620 | const char *mime_type; | ||||
8621 | |||||
8622 | mime_type = get_file_mime_type_for_path (path, FALSE(0)); | ||||
8623 | if (mime_type == NULL((void*)0)) | ||||
8624 | continue; | ||||
8625 | |||||
8626 | if (strcmp (mime_type, first_mime_type) == 0) { | ||||
8627 | files_to_open = g_list_append (files_to_open, g_filename_to_uri (path, NULL((void*)0), NULL((void*)0))); | ||||
8628 | } | ||||
8629 | else { | ||||
8630 | GAppInfo *app2; | ||||
8631 | |||||
8632 | app2 = g_app_info_get_default_for_type (mime_type, FALSE(0)); | ||||
8633 | if (g_app_info_equal (app, app2)) | ||||
8634 | files_to_open = g_list_append (files_to_open, g_filename_to_uri (path, NULL((void*)0), NULL((void*)0))); | ||||
8635 | g_object_unref (app2); | ||||
8636 | } | ||||
8637 | } | ||||
8638 | } | ||||
8639 | |||||
8640 | 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 ())))))))); | ||||
8641 | 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 ())))))))); | ||||
8642 | cdk_app_launch_context_set_timestamp (context, 0); | ||||
8643 | 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); | ||||
8644 | if (! result) { | ||||
8645 | _ctk_error_dialog_run (CTK_WINDOW (odata->window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((odata->window)), ((ctk_window_get_type ())))))), | ||||
8646 | _("Could not perform the operation")gettext ("Could not perform the operation"), | ||||
8647 | "%s", | ||||
8648 | error->message); | ||||
8649 | g_clear_error (&error); | ||||
8650 | } | ||||
8651 | |||||
8652 | g_object_unref (context); | ||||
8653 | g_object_unref (app); | ||||
8654 | path_list_free (files_to_open); | ||||
8655 | |||||
8656 | return result; | ||||
8657 | } | ||||
8658 | |||||
8659 | |||||
8660 | static void | ||||
8661 | fr_window_open_files__extract_done_cb (FrArchive *archive, | ||||
8662 | FrAction action, | ||||
8663 | FrProcError *error, | ||||
8664 | gpointer callback_data) | ||||
8665 | { | ||||
8666 | OpenFilesData *odata = callback_data; | ||||
8667 | |||||
8668 | g_signal_handlers_disconnect_matched (G_OBJECT (archive)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((archive)), (((GType) ((20) << (2)))))))), | ||||
8669 | G_SIGNAL_MATCH_DATA, | ||||
8670 | 0, | ||||
8671 | 0, NULL((void*)0), | ||||
8672 | 0, | ||||
8673 | odata); | ||||
8674 | |||||
8675 | if (error->type == FR_PROC_ERROR_NONE) | ||||
8676 | fr_window_open_extracted_files (odata); | ||||
8677 | } | ||||
8678 | |||||
8679 | |||||
8680 | void | ||||
8681 | fr_window_open_files (FrWindow *window, | ||||
8682 | GList *file_list, | ||||
8683 | gboolean ask_application) | ||||
8684 | { | ||||
8685 | OpenFilesData *odata; | ||||
8686 | |||||
8687 | if (window->priv->activity_ref > 0) | ||||
8688 | return; | ||||
8689 | |||||
8690 | odata = open_files_data_new (window, file_list, ask_application); | ||||
8691 | fr_window_set_current_batch_action (window, | ||||
8692 | FR_BATCH_ACTION_OPEN_FILES, | ||||
8693 | odata, | ||||
8694 | (GFreeFunc) open_files_data_free); | ||||
8695 | |||||
8696 | 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) | ||||
8697 | "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) | ||||
8698 | 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) | ||||
8699 | 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); | ||||
8700 | |||||
8701 | fr_process_clear (window->archive->process); | ||||
8702 | fr_archive_extract_to_local (window->archive, | ||||
8703 | odata->file_list, | ||||
8704 | odata->cdata->temp_dir, | ||||
8705 | NULL((void*)0), | ||||
8706 | FALSE(0), | ||||
8707 | TRUE(!(0)), | ||||
8708 | FALSE(0), | ||||
8709 | window->priv->password); | ||||
8710 | fr_process_start (window->archive->process); | ||||
8711 | } | ||||
8712 | |||||
8713 | |||||
8714 | /**/ | ||||
8715 | |||||
8716 | |||||
8717 | static char* | ||||
8718 | get_default_dir (const char *dir) | ||||
8719 | { | ||||
8720 | if (! is_temp_dir (dir)) | ||||
8721 | return g_strdup (dir)g_strdup_inline (dir); | ||||
8722 | else | ||||
8723 | return NULL((void*)0); | ||||
8724 | } | ||||
8725 | |||||
8726 | |||||
8727 | void | ||||
8728 | fr_window_set_open_default_dir (FrWindow *window, | ||||
8729 | const char *default_dir) | ||||
8730 | { | ||||
8731 | 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); | ||||
8732 | 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); | ||||
8733 | |||||
8734 | if (window->priv->open_default_dir != NULL((void*)0)) | ||||
8735 | g_free (window->priv->open_default_dir); | ||||
8736 | window->priv->open_default_dir = get_default_dir (default_dir); | ||||
8737 | } | ||||
8738 | |||||
8739 | |||||
8740 | const char * | ||||
8741 | fr_window_get_open_default_dir (FrWindow *window) | ||||
8742 | { | ||||
8743 | if (window->priv->open_default_dir == NULL((void*)0)) | ||||
8744 | return get_home_uri (); | ||||
8745 | else | ||||
8746 | return window->priv->open_default_dir; | ||||
8747 | } | ||||
8748 | |||||
8749 | |||||
8750 | void | ||||
8751 | fr_window_set_add_default_dir (FrWindow *window, | ||||
8752 | const char *default_dir) | ||||
8753 | { | ||||
8754 | 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); | ||||
8755 | 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); | ||||
8756 | |||||
8757 | if (window->priv->add_default_dir != NULL((void*)0)) | ||||
8758 | g_free (window->priv->add_default_dir); | ||||
8759 | window->priv->add_default_dir = get_default_dir (default_dir); | ||||
8760 | } | ||||
8761 | |||||
8762 | |||||
8763 | const char * | ||||
8764 | fr_window_get_add_default_dir (FrWindow *window) | ||||
8765 | { | ||||
8766 | if (window->priv->add_default_dir == NULL((void*)0)) | ||||
8767 | return get_home_uri (); | ||||
8768 | else | ||||
8769 | return window->priv->add_default_dir; | ||||
8770 | } | ||||
8771 | |||||
8772 | |||||
8773 | void | ||||
8774 | fr_window_set_extract_default_dir (FrWindow *window, | ||||
8775 | const char *default_dir, | ||||
8776 | gboolean freeze) | ||||
8777 | { | ||||
8778 | 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); | ||||
8779 | 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); | ||||
8780 | |||||
8781 | /* do not change this dir while it's used by the non-interactive | ||||
8782 | * extraction operation. */ | ||||
8783 | if (window->priv->extract_interact_use_default_dir) | ||||
8784 | return; | ||||
8785 | |||||
8786 | window->priv->extract_interact_use_default_dir = freeze; | ||||
8787 | |||||
8788 | if (window->priv->extract_default_dir != NULL((void*)0)) | ||||
8789 | g_free (window->priv->extract_default_dir); | ||||
8790 | window->priv->extract_default_dir = get_default_dir (default_dir); | ||||
8791 | } | ||||
8792 | |||||
8793 | |||||
8794 | const char * | ||||
8795 | fr_window_get_extract_default_dir (FrWindow *window) | ||||
8796 | { | ||||
8797 | if (window->priv->extract_default_dir == NULL((void*)0)) | ||||
8798 | return get_home_uri (); | ||||
8799 | else | ||||
8800 | return window->priv->extract_default_dir; | ||||
8801 | } | ||||
8802 | |||||
8803 | |||||
8804 | void | ||||
8805 | fr_window_set_default_dir (FrWindow *window, | ||||
8806 | const char *default_dir, | ||||
8807 | gboolean freeze) | ||||
8808 | { | ||||
8809 | 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); | ||||
8810 | 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); | ||||
8811 | |||||
8812 | window->priv->freeze_default_dir = freeze; | ||||
8813 | |||||
8814 | fr_window_set_open_default_dir (window, default_dir); | ||||
8815 | fr_window_set_add_default_dir (window, default_dir); | ||||
8816 | fr_window_set_extract_default_dir (window, default_dir, FALSE(0)); | ||||
8817 | } | ||||
8818 | |||||
8819 | |||||
8820 | void | ||||
8821 | fr_window_update_columns_visibility (FrWindow *window) | ||||
8822 | { | ||||
8823 | 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 ())))))); | ||||
8824 | CtkTreeViewColumn *column; | ||||
8825 | |||||
8826 | column = ctk_tree_view_get_column (tree_view, 1); | ||||
8827 | ctk_tree_view_column_set_visible (column, g_settings_get_boolean (window->priv->settings_listing, PREF_LISTING_SHOW_SIZE"show-size")); | ||||
8828 | |||||
8829 | column = ctk_tree_view_get_column (tree_view, 2); | ||||
8830 | ctk_tree_view_column_set_visible (column, g_settings_get_boolean (window->priv->settings_listing, PREF_LISTING_SHOW_TYPE"show-type")); | ||||
8831 | |||||
8832 | column = ctk_tree_view_get_column (tree_view, 3); | ||||
8833 | ctk_tree_view_column_set_visible (column, g_settings_get_boolean (window->priv->settings_listing, PREF_LISTING_SHOW_TIME"show-time")); | ||||
8834 | |||||
8835 | column = ctk_tree_view_get_column (tree_view, 4); | ||||
8836 | ctk_tree_view_column_set_visible (column, g_settings_get_boolean (window->priv->settings_listing, PREF_LISTING_SHOW_PATH"show-path")); | ||||
8837 | } | ||||
8838 | |||||
8839 | |||||
8840 | void | ||||
8841 | fr_window_set_toolbar_visibility (FrWindow *window, | ||||
8842 | gboolean visible) | ||||
8843 | { | ||||
8844 | 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); | ||||
8845 | |||||
8846 | if (visible) | ||||
8847 | ctk_widget_show (window->priv->toolbar); | ||||
8848 | else | ||||
8849 | ctk_widget_hide (window->priv->toolbar); | ||||
8850 | |||||
8851 | set_active (window, "ViewToolbar", visible); | ||||
8852 | } | ||||
8853 | |||||
8854 | |||||
8855 | void | ||||
8856 | fr_window_set_statusbar_visibility (FrWindow *window, | ||||
8857 | gboolean visible) | ||||
8858 | { | ||||
8859 | 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); | ||||
8860 | |||||
8861 | if (visible) | ||||
8862 | ctk_widget_show (window->priv->statusbar); | ||||
8863 | else | ||||
8864 | ctk_widget_hide (window->priv->statusbar); | ||||
8865 | |||||
8866 | set_active (window, "ViewStatusbar", visible); | ||||
8867 | } | ||||
8868 | |||||
8869 | |||||
8870 | void | ||||
8871 | fr_window_set_folders_visibility (FrWindow *window, | ||||
8872 | gboolean value) | ||||
8873 | { | ||||
8874 | 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); | ||||
8875 | |||||
8876 | window->priv->view_folders = value; | ||||
8877 | fr_window_update_dir_tree (window); | ||||
8878 | |||||
8879 | set_active (window, "ViewFolders", window->priv->view_folders); | ||||
8880 | } | ||||
8881 | |||||
8882 | |||||
8883 | void | ||||
8884 | fr_window_use_progress_dialog (FrWindow *window, | ||||
8885 | gboolean value) | ||||
8886 | { | ||||
8887 | window->priv->use_progress_dialog = value; | ||||
8888 | } | ||||
8889 | |||||
8890 | |||||
8891 | /* -- batch mode procedures -- */ | ||||
8892 | |||||
8893 | |||||
8894 | static void fr_window_exec_current_batch_action (FrWindow *window); | ||||
8895 | |||||
8896 | |||||
8897 | static void | ||||
8898 | fr_window_exec_batch_action (FrWindow *window, | ||||
8899 | FRBatchAction *action) | ||||
8900 | { | ||||
8901 | ExtractData *edata; | ||||
8902 | RenameData *rdata; | ||||
8903 | OpenFilesData *odata; | ||||
8904 | SaveAsData *sdata; | ||||
8905 | |||||
8906 | switch (action->type) { | ||||
8907 | case FR_BATCH_ACTION_LOAD: | ||||
8908 | debug (DEBUG_INFO"fr-window.c", 8908, __FUNCTION__, "[BATCH] LOAD\n"); | ||||
8909 | |||||
8910 | if (! uri_exists ((char*) action->data)) | ||||
8911 | fr_window_archive_new (window, (char*) action->data); | ||||
8912 | else | ||||
8913 | fr_window_archive_open (window, (char*) action->data, CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ()))))))); | ||||
8914 | break; | ||||
8915 | |||||
8916 | case FR_BATCH_ACTION_ADD: | ||||
8917 | debug (DEBUG_INFO"fr-window.c", 8917, __FUNCTION__, "[BATCH] ADD\n"); | ||||
8918 | |||||
8919 | fr_window_archive_add_dropped_items (window, (GList*) action->data, FALSE(0)); | ||||
8920 | break; | ||||
8921 | |||||
8922 | case FR_BATCH_ACTION_OPEN: | ||||
8923 | debug (DEBUG_INFO"fr-window.c", 8923, __FUNCTION__, "[BATCH] OPEN\n"); | ||||
8924 | |||||
8925 | fr_window_push_message (window, _("Add files to an archive")gettext ("Add files to an archive")); | ||||
8926 | dlg_batch_add_files (window, (GList*) action->data); | ||||
8927 | break; | ||||
8928 | |||||
8929 | case FR_BATCH_ACTION_EXTRACT: | ||||
8930 | debug (DEBUG_INFO"fr-window.c", 8930, __FUNCTION__, "[BATCH] EXTRACT\n"); | ||||
8931 | |||||
8932 | edata = action->data; | ||||
8933 | fr_window_archive_extract (window, | ||||
8934 | edata->file_list, | ||||
8935 | edata->extract_to_dir, | ||||
8936 | edata->base_dir, | ||||
8937 | edata->skip_older, | ||||
8938 | edata->overwrite, | ||||
8939 | edata->junk_paths, | ||||
8940 | TRUE(!(0))); | ||||
8941 | break; | ||||
8942 | |||||
8943 | case FR_BATCH_ACTION_EXTRACT_HERE: | ||||
8944 | debug (DEBUG_INFO"fr-window.c", 8944, __FUNCTION__, "[BATCH] EXTRACT HERE\n"); | ||||
8945 | |||||
8946 | fr_window_archive_extract_here (window, | ||||
8947 | FALSE(0), | ||||
8948 | TRUE(!(0)), | ||||
8949 | FALSE(0)); | ||||
8950 | break; | ||||
8951 | |||||
8952 | case FR_BATCH_ACTION_EXTRACT_INTERACT: | ||||
8953 | debug (DEBUG_INFO"fr-window.c", 8953, __FUNCTION__, "[BATCH] EXTRACT_INTERACT\n"); | ||||
8954 | |||||
8955 | if (window->priv->extract_interact_use_default_dir | ||||
8956 | && (window->priv->extract_default_dir != NULL((void*)0))) | ||||
8957 | { | ||||
8958 | fr_window_archive_extract (window, | ||||
8959 | NULL((void*)0), | ||||
8960 | window->priv->extract_default_dir, | ||||
8961 | NULL((void*)0), | ||||
8962 | FALSE(0), | ||||
8963 | FR_OVERWRITE_ASK, | ||||
8964 | FALSE(0), | ||||
8965 | TRUE(!(0))); | ||||
8966 | } | ||||
8967 | else { | ||||
8968 | fr_window_push_message (window, _("Extract archive")gettext ("Extract archive")); | ||||
8969 | dlg_extract (NULL((void*)0), window); | ||||
8970 | } | ||||
8971 | break; | ||||
8972 | |||||
8973 | case FR_BATCH_ACTION_RENAME: | ||||
8974 | debug (DEBUG_INFO"fr-window.c", 8974, __FUNCTION__, "[BATCH] RENAME\n"); | ||||
8975 | |||||
8976 | rdata = action->data; | ||||
8977 | rename_selection (window, | ||||
8978 | rdata->path_to_rename, | ||||
8979 | rdata->old_name, | ||||
8980 | rdata->new_name, | ||||
8981 | rdata->current_dir, | ||||
8982 | rdata->is_dir, | ||||
8983 | rdata->dir_in_archive, | ||||
8984 | rdata->original_path); | ||||
8985 | break; | ||||
8986 | |||||
8987 | case FR_BATCH_ACTION_PASTE: | ||||
8988 | debug (DEBUG_INFO"fr-window.c", 8988, __FUNCTION__, "[BATCH] PASTE\n"); | ||||
8989 | |||||
8990 | fr_window_paste_from_clipboard_data (window, (FrClipboardData*) action->data); | ||||
8991 | break; | ||||
8992 | |||||
8993 | case FR_BATCH_ACTION_OPEN_FILES: | ||||
8994 | debug (DEBUG_INFO"fr-window.c", 8994, __FUNCTION__, "[BATCH] OPEN FILES\n"); | ||||
8995 | |||||
8996 | odata = action->data; | ||||
8997 | fr_window_open_files (window, odata->file_list, odata->ask_application); | ||||
8998 | break; | ||||
8999 | |||||
9000 | case FR_BATCH_ACTION_SAVE_AS: | ||||
9001 | debug (DEBUG_INFO"fr-window.c", 9001, __FUNCTION__, "[BATCH] SAVE_AS\n"); | ||||
9002 | |||||
9003 | sdata = action->data; | ||||
9004 | fr_window_archive_save_as (window, | ||||
9005 | sdata->uri, | ||||
9006 | sdata->password, | ||||
9007 | sdata->encrypt_header, | ||||
9008 | sdata->volume_size); | ||||
9009 | break; | ||||
9010 | |||||
9011 | case FR_BATCH_ACTION_TEST: | ||||
9012 | debug (DEBUG_INFO"fr-window.c", 9012, __FUNCTION__, "[BATCH] TEST\n"); | ||||
9013 | |||||
9014 | fr_window_archive_test (window); | ||||
9015 | break; | ||||
9016 | |||||
9017 | case FR_BATCH_ACTION_CLOSE: | ||||
9018 | debug (DEBUG_INFO"fr-window.c", 9018, __FUNCTION__, "[BATCH] CLOSE\n"); | ||||
9019 | |||||
9020 | fr_window_archive_close (window); | ||||
9021 | fr_window_exec_next_batch_action (window); | ||||
9022 | break; | ||||
9023 | |||||
9024 | case FR_BATCH_ACTION_QUIT: | ||||
9025 | debug (DEBUG_INFO"fr-window.c", 9025, __FUNCTION__, "[BATCH] QUIT\n"); | ||||
9026 | |||||
9027 | g_signal_emit (window, | ||||
9028 | fr_window_signals[READY], | ||||
9029 | 0, | ||||
9030 | NULL((void*)0)); | ||||
9031 | |||||
9032 | 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 ())))))))) | ||||
9033 | ctk_widget_destroy (window->priv->progress_dialog); | ||||
9034 | ctk_widget_destroy (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | ||||
9035 | break; | ||||
9036 | |||||
9037 | default: | ||||
9038 | break; | ||||
9039 | } | ||||
9040 | } | ||||
9041 | |||||
9042 | |||||
9043 | void | ||||
9044 | fr_window_reset_current_batch_action (FrWindow *window) | ||||
9045 | { | ||||
9046 | FRBatchAction *adata = &window->priv->current_batch_action; | ||||
9047 | |||||
9048 | if ((adata->data != NULL((void*)0)) && (adata->free_func != NULL((void*)0))) | ||||
9049 | (*adata->free_func) (adata->data); | ||||
9050 | adata->type = FR_BATCH_ACTION_NONE; | ||||
9051 | adata->data = NULL((void*)0); | ||||
9052 | adata->free_func = NULL((void*)0); | ||||
9053 | } | ||||
9054 | |||||
9055 | |||||
9056 | void | ||||
9057 | fr_window_set_current_batch_action (FrWindow *window, | ||||
9058 | FrBatchActionType action, | ||||
9059 | void *data, | ||||
9060 | GFreeFunc free_func) | ||||
9061 | { | ||||
9062 | FRBatchAction *adata = &window->priv->current_batch_action; | ||||
9063 | |||||
9064 | fr_window_reset_current_batch_action (window); | ||||
9065 | |||||
9066 | adata->type = action; | ||||
9067 | adata->data = data; | ||||
9068 | adata->free_func = free_func; | ||||
9069 | } | ||||
9070 | |||||
9071 | |||||
9072 | void | ||||
9073 | fr_window_restart_current_batch_action (FrWindow *window) | ||||
9074 | { | ||||
9075 | fr_window_exec_batch_action (window, &window->priv->current_batch_action); | ||||
9076 | } | ||||
9077 | |||||
9078 | |||||
9079 | void | ||||
9080 | fr_window_append_batch_action (FrWindow *window, | ||||
9081 | FrBatchActionType action, | ||||
9082 | void *data, | ||||
9083 | GFreeFunc free_func) | ||||
9084 | { | ||||
9085 | FRBatchAction *a_desc; | ||||
9086 | |||||
9087 | 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); | ||||
9088 | |||||
9089 | a_desc = g_new0 (FRBatchAction, 1)((FRBatchAction *) g_malloc0_n ((1), sizeof (FRBatchAction))); | ||||
9090 | a_desc->type = action; | ||||
9091 | a_desc->data = data; | ||||
9092 | a_desc->free_func = free_func; | ||||
9093 | |||||
9094 | window->priv->batch_action_list = g_list_append (window->priv->batch_action_list, a_desc); | ||||
9095 | } | ||||
9096 | |||||
9097 | |||||
9098 | static void | ||||
9099 | fr_window_exec_current_batch_action (FrWindow *window) | ||||
9100 | { | ||||
9101 | FRBatchAction *action; | ||||
9102 | |||||
9103 | if (window->priv->batch_action
| ||||
9104 | window->priv->batch_mode = FALSE(0); | ||||
9105 | return; | ||||
9106 | } | ||||
9107 | action = (FRBatchAction *) window->priv->batch_action->data; | ||||
9108 | fr_window_exec_batch_action (window, action); | ||||
9109 | } | ||||
9110 | |||||
9111 | |||||
9112 | static void | ||||
9113 | fr_window_exec_next_batch_action (FrWindow *window) | ||||
9114 | { | ||||
9115 | if (window->priv->batch_action != NULL((void*)0)) | ||||
9116 | window->priv->batch_action = g_list_next (window->priv->batch_action)((window->priv->batch_action) ? (((GList *)(window-> priv->batch_action))->next) : ((void*)0)); | ||||
9117 | else | ||||
9118 | window->priv->batch_action = window->priv->batch_action_list; | ||||
9119 | fr_window_exec_current_batch_action (window); | ||||
9120 | } | ||||
9121 | |||||
9122 | |||||
9123 | void | ||||
9124 | fr_window_start_batch (FrWindow *window) | ||||
9125 | { | ||||
9126 | 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); | ||||
| |||||
9127 | |||||
9128 | if (window->priv->batch_mode) | ||||
9129 | return; | ||||
9130 | |||||
9131 | if (window->priv->batch_action_list == NULL((void*)0)) | ||||
9132 | return; | ||||
9133 | |||||
9134 | if (window->priv->progress_dialog != NULL((void*)0)) | ||||
9135 | 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 ())))))), | ||||
9136 | window->priv->batch_title); | ||||
9137 | |||||
9138 | window->priv->batch_mode = TRUE(!(0)); | ||||
9139 | window->priv->batch_action = window->priv->batch_action_list; | ||||
9140 | window->archive->can_create_compressed_file = window->priv->batch_adding_one_file; | ||||
9141 | |||||
9142 | fr_window_exec_current_batch_action (window); | ||||
9143 | } | ||||
9144 | |||||
9145 | |||||
9146 | void | ||||
9147 | fr_window_stop_batch (FrWindow *window) | ||||
9148 | { | ||||
9149 | if (! window->priv->non_interactive) | ||||
9150 | return; | ||||
9151 | |||||
9152 | window->priv->extract_interact_use_default_dir = FALSE(0); | ||||
9153 | window->archive->can_create_compressed_file = FALSE(0); | ||||
9154 | |||||
9155 | if (window->priv->batch_mode) { | ||||
9156 | if (! window->priv->showing_error_dialog) { | ||||
9157 | ctk_widget_destroy (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); | ||||
9158 | return; | ||||
9159 | } | ||||
9160 | } | ||||
9161 | else { | ||||
9162 | ctk_window_present (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ()))))))); | ||||
9163 | fr_window_archive_close (window); | ||||
9164 | } | ||||
9165 | |||||
9166 | window->priv->batch_mode = FALSE(0); | ||||
9167 | } | ||||
9168 | |||||
9169 | |||||
9170 | void | ||||
9171 | fr_window_resume_batch (FrWindow *window) | ||||
9172 | { | ||||
9173 | fr_window_exec_current_batch_action (window); | ||||
9174 | } | ||||
9175 | |||||
9176 | |||||
9177 | gboolean | ||||
9178 | fr_window_is_batch_mode (FrWindow *window) | ||||
9179 | { | ||||
9180 | return window->priv->batch_mode; | ||||
9181 | } | ||||
9182 | |||||
9183 | |||||
9184 | void | ||||
9185 | fr_window_new_batch (FrWindow *window, | ||||
9186 | const char *title) | ||||
9187 | { | ||||
9188 | fr_window_free_batch_data (window); | ||||
9189 | window->priv->non_interactive = TRUE(!(0)); | ||||
9190 | g_free (window->priv->batch_title); | ||||
9191 | window->priv->batch_title = g_strdup (title)g_strdup_inline (title); | ||||
9192 | } | ||||
9193 | |||||
9194 | |||||
9195 | void | ||||
9196 | fr_window_set_batch__extract_here (FrWindow *window, | ||||
9197 | const char *filename) | ||||
9198 | { | ||||
9199 | 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); | ||||
9200 | 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); | ||||
9201 | |||||
9202 | fr_window_append_batch_action (window, | ||||
9203 | FR_BATCH_ACTION_LOAD, | ||||
9204 | g_strdup (filename)g_strdup_inline (filename), | ||||
9205 | (GFreeFunc) g_free); | ||||
9206 | fr_window_append_batch_action (window, | ||||
9207 | FR_BATCH_ACTION_EXTRACT_HERE, | ||||
9208 | extract_to_data_new (NULL((void*)0)), | ||||
9209 | (GFreeFunc) extract_data_free); | ||||
9210 | fr_window_append_batch_action (window, | ||||
9211 | FR_BATCH_ACTION_CLOSE, | ||||
9212 | NULL((void*)0), | ||||
9213 | NULL((void*)0)); | ||||
9214 | } | ||||
9215 | |||||
9216 | |||||
9217 | void | ||||
9218 | fr_window_set_batch__extract (FrWindow *window, | ||||
9219 | const char *filename, | ||||
9220 | const char *dest_dir) | ||||
9221 | { | ||||
9222 | 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); | ||||
9223 | 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); | ||||
9224 | |||||
9225 | enable_notifications = FALSE(0); | ||||
9226 | |||||
9227 | fr_window_append_batch_action (window, | ||||
9228 | FR_BATCH_ACTION_LOAD, | ||||
9229 | g_strdup (filename)g_strdup_inline (filename), | ||||
9230 | (GFreeFunc) g_free); | ||||
9231 | if (dest_dir != NULL((void*)0)) | ||||
9232 | fr_window_append_batch_action (window, | ||||
9233 | FR_BATCH_ACTION_EXTRACT, | ||||
9234 | extract_to_data_new (dest_dir), | ||||
9235 | (GFreeFunc) extract_data_free); | ||||
9236 | else | ||||
9237 | fr_window_append_batch_action (window, | ||||
9238 | FR_BATCH_ACTION_EXTRACT_INTERACT, | ||||
9239 | NULL((void*)0), | ||||
9240 | NULL((void*)0)); | ||||
9241 | fr_window_append_batch_action (window, | ||||
9242 | FR_BATCH_ACTION_CLOSE, | ||||
9243 | NULL((void*)0), | ||||
9244 | NULL((void*)0)); | ||||
9245 | } | ||||
9246 | |||||
9247 | |||||
9248 | void | ||||
9249 | fr_window_set_batch__add (FrWindow *window, | ||||
9250 | const char *archive, | ||||
9251 | GList *file_list) | ||||
9252 | { | ||||
9253 | window->priv->batch_adding_one_file = (file_list->next == NULL((void*)0)) && (uri_is_file (file_list->data)); | ||||
9254 | |||||
9255 | if (archive != NULL((void*)0)) | ||||
9256 | fr_window_append_batch_action (window, | ||||
9257 | FR_BATCH_ACTION_LOAD, | ||||
9258 | g_strdup (archive)g_strdup_inline (archive), | ||||
9259 | (GFreeFunc) g_free); | ||||
9260 | else | ||||
9261 | fr_window_append_batch_action (window, | ||||
9262 | FR_BATCH_ACTION_OPEN, | ||||
9263 | file_list, | ||||
9264 | NULL((void*)0)); | ||||
9265 | fr_window_append_batch_action (window, | ||||
9266 | FR_BATCH_ACTION_ADD, | ||||
9267 | file_list, | ||||
9268 | NULL((void*)0)); | ||||
9269 | fr_window_append_batch_action (window, | ||||
9270 | FR_BATCH_ACTION_CLOSE, | ||||
9271 | NULL((void*)0), | ||||
9272 | NULL((void*)0)); | ||||
9273 | } |