Mercurial > geeqie
annotate src/utilops.c @ 136:18c2a29e681c
more external commands
author | nadvornik |
---|---|
date | Mon, 20 Aug 2007 20:11:32 +0000 |
parents | 15c1925b3bfb |
children | 71e1ebee420e |
rev | line source |
---|---|
1 | 1 /* |
9 | 2 * GQview |
67
f63ecca6c087
Fri Oct 13 05:22:43 2006 John Ellis <johne@verizon.net>
gqview
parents:
66
diff
changeset
|
3 * (C) 2006 John Ellis |
1 | 4 * |
5 * Author: John Ellis | |
6 * | |
9 | 7 * This software is released under the GNU General Public License (GNU GPL). |
8 * Please read the included file COPYING for more information. | |
9 * This software comes with no warranty of any kind, use at your own risk! | |
1 | 10 */ |
11 | |
9 | 12 |
1 | 13 #include "gqview.h" |
9 | 14 #include "utilops.h" |
15 | |
16 | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
17 #include "cache.h" |
9 | 18 #include "cache_maint.h" |
19 #include "collect.h" | |
20 #include "dupe.h" | |
21 #include "filelist.h" | |
22 #include "image.h" | |
23 #include "img-view.h" | |
24 #include "layout.h" | |
25 #include "search.h" | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
26 #include "thumb_standard.h" |
9 | 27 #include "ui_bookmark.h" |
28 #include "ui_fileops.h" | |
29 #include "ui_misc.h" | |
30 #include "ui_tabcomp.h" | |
31 | |
32 | |
33 /* | |
34 *-------------------------------------------------------------------------- | |
35 * call these when names change, files move, deleted, etc. | |
36 * so that any open windows are also updated | |
37 *-------------------------------------------------------------------------- | |
38 */ | |
39 | |
40 void file_maint_renamed(const gchar *source, const gchar *dest) | |
41 { | |
42 cache_maint_moved(source, dest); | |
43 collection_maint_renamed(source, dest); | |
44 | |
45 layout_maint_renamed(source, dest); | |
46 view_window_maint_moved(source, dest); | |
47 dupe_maint_renamed(source, dest); | |
48 search_maint_renamed(source, dest); | |
49 } | |
50 | |
51 /* under most cases ignore_list should be NULL */ | |
52 void file_maint_removed(const gchar *path, GList *ignore_list) | |
53 { | |
54 layout_maint_removed(path, ignore_list); | |
55 view_window_maint_removed(path, ignore_list); | |
56 dupe_maint_removed(path); | |
57 search_maint_removed(path); | |
58 | |
59 collection_maint_removed(path); | |
60 cache_maint_removed(path); | |
61 } | |
62 | |
63 /* special case for correct main window behavior */ | |
64 void file_maint_moved(const gchar *source, const gchar *dest, GList *ignore_list) | |
65 { | |
66 cache_maint_moved(source, dest); | |
67 collection_maint_renamed(source, dest); | |
68 | |
69 layout_maint_moved(source, dest, ignore_list); | |
70 view_window_maint_moved(source, dest); | |
71 dupe_maint_renamed(source, dest); | |
72 search_maint_renamed(source, dest); | |
73 } | |
74 | |
75 void file_maint_copied(const gchar *source, const gchar *dest) | |
76 { | |
77 cache_maint_copied(source, dest); | |
78 } | |
79 | |
80 /* | |
81 *-------------------------------------------------------------------------- | |
82 * The file manipulation dialogs | |
83 *-------------------------------------------------------------------------- | |
84 */ | |
85 | |
1 | 86 |
87 enum { | |
88 DIALOG_NEW_DIR, | |
89 DIALOG_COPY, | |
90 DIALOG_MOVE, | |
91 DIALOG_DELETE, | |
92 DIALOG_RENAME | |
93 }; | |
94 | |
95 typedef struct _FileDataMult FileDataMult; | |
96 struct _FileDataMult | |
97 { | |
98 gint confirm_all; | |
99 gint confirmed; | |
100 gint skip; | |
101 GList *source_list; | |
102 GList *source_next; | |
103 gchar *dest_base; | |
104 gchar *source; | |
105 gchar *dest; | |
106 gint copy; | |
9 | 107 |
108 gint rename; | |
109 gint rename_auto; | |
110 gint rename_all; | |
111 | |
112 GtkWidget *rename_box; | |
113 GtkWidget *rename_entry; | |
114 GtkWidget *rename_auto_box; | |
115 | |
116 GtkWidget *yes_all_button; | |
1 | 117 }; |
118 | |
119 typedef struct _FileDataSingle FileDataSingle; | |
120 struct _FileDataSingle | |
121 { | |
122 gint confirmed; | |
123 gchar *source; | |
124 gchar *dest; | |
125 gint copy; | |
9 | 126 |
127 gint rename; | |
128 gint rename_auto; | |
129 | |
130 GtkWidget *rename_box; | |
131 GtkWidget *rename_entry; | |
132 GtkWidget *rename_auto_box; | |
1 | 133 }; |
134 | |
9 | 135 /* |
136 *-------------------------------------------------------------------------- | |
137 * Adds 1 or 2 images (if 2, side by side) to a GenericDialog | |
138 *-------------------------------------------------------------------------- | |
139 */ | |
140 | |
141 #define DIALOG_DEF_IMAGE_DIM_X 200 | |
142 #define DIALOG_DEF_IMAGE_DIM_Y 150 | |
143 | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
144 static void generic_dialog_add_image(GenericDialog *gd, GtkWidget *box, |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
145 const gchar *path1, const gchar *header1, |
9 | 146 const gchar *path2, const gchar *header2, |
147 gint show_filename) | |
148 { | |
149 ImageWindow *imd; | |
150 GtkWidget *hbox = NULL; | |
151 GtkWidget *vbox; | |
152 GtkWidget *label = NULL; | |
153 | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
154 if (!box) box = gd->vbox; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
155 |
9 | 156 if (path2) |
157 { | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
158 hbox = pref_box_new(box, TRUE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE); |
9 | 159 } |
160 | |
161 /* image 1 */ | |
162 | |
163 vbox = gtk_vbox_new(FALSE, PREF_PAD_GAP); | |
164 if (hbox) | |
165 { | |
166 GtkWidget *sep; | |
167 | |
168 gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0); | |
169 | |
170 sep = gtk_vseparator_new(); | |
171 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0); | |
172 gtk_widget_show(sep); | |
173 } | |
174 else | |
175 { | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
176 gtk_box_pack_start(GTK_BOX(box), vbox, TRUE, TRUE, PREF_PAD_GAP); |
9 | 177 } |
178 gtk_widget_show(vbox); | |
179 | |
180 if (header1) | |
181 { | |
182 GtkWidget *head; | |
183 | |
184 head = pref_label_new(vbox, header1); | |
185 pref_label_bold(head, TRUE, FALSE); | |
186 gtk_misc_set_alignment(GTK_MISC(head), 0.0, 0.5); | |
187 } | |
188 | |
189 imd = image_new(FALSE); | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
190 g_object_set(G_OBJECT(imd->pr), "zoom_expand", FALSE, NULL); |
9 | 191 gtk_widget_set_size_request(imd->widget, DIALOG_DEF_IMAGE_DIM_X, DIALOG_DEF_IMAGE_DIM_Y); |
192 gtk_box_pack_start(GTK_BOX(vbox), imd->widget, TRUE, TRUE, 0); | |
193 image_change_path(imd, path1, 0.0); | |
194 gtk_widget_show(imd->widget); | |
195 | |
196 if (show_filename) | |
197 { | |
198 label = pref_label_new(vbox, (path1 == NULL) ? "" : filename_from_path(path1)); | |
199 } | |
200 | |
201 /* only the first image is stored (for use in gd_image_set) */ | |
202 g_object_set_data(G_OBJECT(gd->dialog), "img_image", imd); | |
203 g_object_set_data(G_OBJECT(gd->dialog), "img_label", label); | |
204 | |
205 | |
206 /* image 2 */ | |
207 | |
208 if (hbox && path2) | |
209 { | |
210 vbox = pref_box_new(hbox, TRUE, GTK_ORIENTATION_VERTICAL, PREF_PAD_GAP); | |
211 | |
212 if (header2) | |
213 { | |
214 GtkWidget *head; | |
215 | |
216 head = pref_label_new(vbox, header2); | |
217 pref_label_bold(head, TRUE, FALSE); | |
218 gtk_misc_set_alignment(GTK_MISC(head), 0.0, 0.5); | |
219 } | |
220 | |
221 imd = image_new(FALSE); | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
222 g_object_set(G_OBJECT(imd->pr), "zoom_expand", FALSE, NULL); |
9 | 223 gtk_widget_set_size_request(imd->widget, DIALOG_DEF_IMAGE_DIM_X, DIALOG_DEF_IMAGE_DIM_Y); |
224 gtk_box_pack_start(GTK_BOX(vbox), imd->widget, TRUE, TRUE, 0); | |
225 image_change_path(imd, path2, 0.0); | |
226 gtk_widget_show(imd->widget); | |
227 | |
228 pref_label_new(vbox, filename_from_path(path2)); | |
229 } | |
230 } | |
231 | |
232 static void generic_dialog_image_set(GenericDialog *gd, const gchar *path) | |
233 { | |
234 ImageWindow *imd; | |
235 GtkWidget *label; | |
236 | |
237 imd = g_object_get_data(G_OBJECT(gd->dialog), "img_image"); | |
238 label = g_object_get_data(G_OBJECT(gd->dialog), "img_label"); | |
239 | |
240 if (!imd) return; | |
241 | |
242 image_change_path(imd, path, 0.0); | |
243 if (label) gtk_label_set_text(GTK_LABEL(label), filename_from_path(path)); | |
244 } | |
245 | |
246 /* | |
247 *-------------------------------------------------------------------------- | |
248 * Wrappers to aid in setting additional dialog properties (unde mouse, etc.) | |
249 *-------------------------------------------------------------------------- | |
250 */ | |
251 | |
252 GenericDialog *file_util_gen_dlg(const gchar *title, | |
253 const gchar *wmclass, const gchar *wmsubclass, | |
254 GtkWidget *parent, gint auto_close, | |
255 void (*cancel_cb)(GenericDialog *, gpointer), gpointer data) | |
256 { | |
257 GenericDialog *gd; | |
258 | |
259 gd = generic_dialog_new(title, wmclass, wmsubclass, parent, auto_close, cancel_cb, data); | |
260 if (place_dialogs_under_mouse) | |
261 { | |
262 gtk_window_set_position(GTK_WINDOW(gd->dialog), GTK_WIN_POS_MOUSE); | |
263 } | |
264 | |
265 return gd; | |
266 } | |
267 | |
268 FileDialog *file_util_file_dlg(const gchar *title, | |
269 const gchar *wmclass, const gchar *wmsubclass, | |
270 GtkWidget *parent, | |
271 void (*cancel_cb)(FileDialog *, gpointer), gpointer data) | |
272 { | |
273 FileDialog *fd; | |
274 | |
275 fd = file_dialog_new(title, wmclass, wmsubclass, parent, cancel_cb, data); | |
276 if (place_dialogs_under_mouse) | |
277 { | |
278 gtk_window_set_position(GTK_WINDOW(GENERIC_DIALOG(fd)->dialog), GTK_WIN_POS_MOUSE); | |
279 } | |
280 | |
281 return fd; | |
282 } | |
283 | |
284 /* this warning dialog is copied from SLIK's ui_utildg.c, | |
285 * because it does not have a mouse center option, | |
286 * and we must center it before show, implement it here. | |
287 */ | |
288 static void file_util_warning_dialog_ok_cb(GenericDialog *gd, gpointer data) | |
289 { | |
290 /* no op */ | |
291 } | |
292 | |
293 GenericDialog *file_util_warning_dialog(const gchar *heading, const gchar *message, | |
294 const gchar *icon_stock_id, GtkWidget *parent) | |
295 { | |
296 GenericDialog *gd; | |
297 | |
298 gd = file_util_gen_dlg(heading, "GQview", "warning", parent, TRUE, NULL, NULL); | |
299 generic_dialog_add_message(gd, icon_stock_id, heading, message); | |
300 generic_dialog_add_button(gd, GTK_STOCK_OK, NULL, file_util_warning_dialog_ok_cb, TRUE); | |
301 if (place_dialogs_under_mouse) | |
302 { | |
303 gtk_window_set_position(GTK_WINDOW(gd->dialog), GTK_WIN_POS_MOUSE); | |
304 } | |
305 gtk_widget_show(gd->dialog); | |
306 | |
307 return gd; | |
308 } | |
1 | 309 |
42
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
310 static gint filename_base_length(const gchar *name) |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
311 { |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
312 gint n; |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
313 |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
314 if (!name) return 0; |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
315 |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
316 n = strlen(name); |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
317 |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
318 if (filter_name_exists(name)) |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
319 { |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
320 const gchar *ext; |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
321 |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
322 ext = extension_from_path(name); |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
323 if (ext) n -= strlen(ext); |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
324 } |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
325 |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
326 return n; |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
327 } |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
328 |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
329 |
1 | 330 /* |
331 *-------------------------------------------------------------------------- | |
332 * Move and Copy routines | |
333 *-------------------------------------------------------------------------- | |
334 */ | |
335 | |
136 | 336 static gint copy_file_ext(const gchar *s, const gchar *t) |
337 { | |
338 if (editor_command[CMD_COPY]) | |
339 return start_editor_from_pair(CMD_COPY, s, t); | |
340 return copy_file(s, t); | |
341 } | |
342 | |
343 static gint move_file_ext(const gchar *s, const gchar *t) | |
344 { | |
345 if (editor_command[CMD_MOVE]) | |
346 return start_editor_from_pair(CMD_MOVE, s, t); | |
347 return move_file(s, t); | |
348 } | |
349 | |
350 static gint rename_file_ext(const gchar *s, const gchar *t) | |
351 { | |
352 if (editor_command[CMD_RENAME]) | |
353 return start_editor_from_pair(CMD_RENAME, s, t); | |
354 return rename_file(s, t); | |
355 } | |
356 | |
357 | |
1 | 358 /* |
359 * Multi file move | |
360 */ | |
361 | |
9 | 362 static FileDataMult *file_data_multiple_new(GList *source_list, const gchar *dest, gint copy) |
1 | 363 { |
364 FileDataMult *fdm = g_new0(FileDataMult, 1); | |
365 fdm->confirm_all = FALSE; | |
366 fdm->confirmed = FALSE; | |
367 fdm->skip = FALSE; | |
368 fdm->source_list = source_list; | |
369 fdm->source_next = fdm->source_list; | |
370 fdm->dest_base = g_strdup(dest); | |
371 fdm->source = NULL; | |
372 fdm->dest = NULL; | |
373 fdm->copy = copy; | |
374 return fdm; | |
375 } | |
376 | |
377 static void file_data_multiple_free(FileDataMult *fdm) | |
378 { | |
9 | 379 path_list_free(fdm->source_list); |
1 | 380 g_free(fdm->dest_base); |
381 g_free(fdm->dest); | |
382 g_free(fdm); | |
383 } | |
384 | |
9 | 385 static void file_util_move_multiple(FileDataMult *fdm); |
386 | |
387 static void file_util_move_multiple_ok_cb(GenericDialog *gd, gpointer data) | |
1 | 388 { |
389 FileDataMult *fdm = data; | |
9 | 390 |
1 | 391 fdm->confirmed = TRUE; |
9 | 392 |
393 if (fdm->rename_auto) | |
394 { | |
395 gchar *buf; | |
396 | |
397 buf = unique_filename_simple(fdm->dest); | |
398 if (buf) | |
399 { | |
400 g_free(fdm->dest); | |
401 fdm->dest = buf; | |
402 } | |
403 else | |
404 { | |
405 /* unique failed? well, return to the overwrite prompt :( */ | |
406 fdm->confirmed = FALSE; | |
407 } | |
408 } | |
409 else if (fdm->rename) | |
410 { | |
411 const gchar *name; | |
412 | |
413 name = gtk_entry_get_text(GTK_ENTRY(fdm->rename_entry)); | |
414 if (strlen(name) == 0 || | |
415 strcmp(name, filename_from_path(fdm->source)) == 0) | |
416 { | |
417 fdm->confirmed = FALSE; | |
418 } | |
419 else | |
420 { | |
421 g_free(fdm->dest); | |
422 fdm->dest = concat_dir_and_file(fdm->dest_base, name); | |
423 fdm->confirmed = !isname(fdm->dest); | |
424 } | |
425 } | |
426 | |
1 | 427 file_util_move_multiple(fdm); |
428 } | |
429 | |
9 | 430 static void file_util_move_multiple_all_cb(GenericDialog *gd, gpointer data) |
1 | 431 { |
432 FileDataMult *fdm = data; | |
9 | 433 |
434 fdm->confirm_all = TRUE; | |
435 | |
436 if (fdm->rename_auto) fdm->rename_all = TRUE; | |
437 | |
438 file_util_move_multiple(fdm); | |
439 } | |
440 | |
441 static void file_util_move_multiple_skip_cb(GenericDialog *gd, gpointer data) | |
442 { | |
443 FileDataMult *fdm = data; | |
444 | |
445 fdm->skip = TRUE; | |
446 fdm->confirmed = TRUE; | |
447 | |
448 file_util_move_multiple(fdm); | |
449 } | |
450 | |
451 static void file_util_move_multiple_skip_all_cb(GenericDialog *gd, gpointer data) | |
452 { | |
453 FileDataMult *fdm = data; | |
454 | |
455 fdm->skip = TRUE; | |
1 | 456 fdm->confirm_all = TRUE; |
457 file_util_move_multiple(fdm); | |
458 } | |
459 | |
9 | 460 static void file_util_move_multiple_continue_cb(GenericDialog *gd, gpointer data) |
1 | 461 { |
462 FileDataMult *fdm = data; | |
9 | 463 |
464 fdm->confirmed = TRUE; | |
1 | 465 file_util_move_multiple(fdm); |
466 } | |
467 | |
9 | 468 static void file_util_move_multiple_cancel_cb(GenericDialog *gd, gpointer data) |
1 | 469 { |
470 FileDataMult *fdm = data; | |
9 | 471 |
1 | 472 file_data_multiple_free(fdm); |
473 } | |
474 | |
9 | 475 /* rename option */ |
476 | |
477 static void file_util_move_multiple_rename_auto_cb(GtkWidget *widget, gpointer data) | |
478 { | |
479 GenericDialog *gd = data; | |
480 FileDataMult *fdm; | |
481 | |
482 fdm = gd->data; | |
483 | |
484 fdm->rename_auto = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); | |
485 gtk_widget_set_sensitive(fdm->rename_box, !fdm->rename_auto); | |
486 gtk_widget_set_sensitive(fdm->rename_entry, (!fdm->rename_auto && fdm->rename)); | |
487 | |
488 if (fdm->rename_auto) | |
489 { | |
490 gchar *preview; | |
491 | |
492 preview = unique_filename_simple(fdm->dest); | |
493 if (preview) gtk_entry_set_text(GTK_ENTRY(fdm->rename_entry), filename_from_path(preview)); | |
494 g_free(preview); | |
495 } | |
496 | |
497 gtk_widget_set_sensitive(fdm->yes_all_button, (fdm->rename_auto || !fdm->rename)); | |
498 } | |
499 | |
500 static void file_util_move_multiple_rename_cb(GtkWidget *widget, gpointer data) | |
501 { | |
502 GenericDialog *gd = data; | |
503 FileDataMult *fdm; | |
504 | |
505 fdm = gd->data; | |
506 | |
507 fdm->rename = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); | |
508 gtk_widget_set_sensitive(fdm->rename_entry, fdm->rename); | |
509 gtk_widget_set_sensitive(fdm->yes_all_button, !fdm->rename); | |
510 | |
42
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
511 if (fdm->rename) |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
512 { |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
513 const gchar *name; |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
514 |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
515 gtk_widget_grab_focus(fdm->rename_entry); |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
516 |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
517 name = gtk_entry_get_text(GTK_ENTRY(fdm->rename_entry)); |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
518 gtk_editable_select_region(GTK_EDITABLE(fdm->rename_entry), 0, filename_base_length(name)); |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
519 } |
9 | 520 } |
521 | |
522 static GenericDialog *file_util_move_multiple_confirm_dialog(FileDataMult *fdm) | |
523 { | |
524 GenericDialog *gd; | |
525 GtkWidget *hbox; | |
526 | |
527 gd = file_util_gen_dlg(_("Overwrite file"), "GQview", "dlg_confirm", | |
528 NULL, TRUE, | |
529 file_util_move_multiple_cancel_cb, fdm); | |
530 | |
531 generic_dialog_add_message(gd, GTK_STOCK_DIALOG_QUESTION, | |
532 _("Overwrite file?"), | |
533 _("Replace existing file with new file.")); | |
534 pref_spacer(gd->vbox, 0); | |
535 | |
536 generic_dialog_add_button(gd, GTK_STOCK_YES, _("_Overwrite"), file_util_move_multiple_ok_cb, TRUE); | |
537 fdm->yes_all_button = generic_dialog_add_button(gd, NULL, _("Overwrite _all"), | |
538 file_util_move_multiple_all_cb, FALSE); | |
539 generic_dialog_add_button(gd, GTK_STOCK_GOTO_LAST, _("S_kip all"), file_util_move_multiple_skip_all_cb, FALSE); | |
540 generic_dialog_add_button(gd, GTK_STOCK_GO_FORWARD, _("_Skip"), file_util_move_multiple_skip_cb, FALSE); | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
541 generic_dialog_add_image(gd, NULL, fdm->dest, _("Existing file"), fdm->source, _("New file"), TRUE); |
9 | 542 |
543 /* rename option */ | |
544 | |
545 fdm->rename = FALSE; | |
546 fdm->rename_all = FALSE; | |
547 fdm->rename_auto = FALSE; | |
548 | |
549 hbox = pref_box_new(gd->vbox, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_GAP); | |
550 | |
551 fdm->rename_auto_box = gtk_check_button_new_with_label(_("Auto rename")); | |
552 g_signal_connect(G_OBJECT(fdm->rename_auto_box), "clicked", | |
553 G_CALLBACK(file_util_move_multiple_rename_auto_cb), gd); | |
554 gtk_box_pack_start(GTK_BOX(hbox), fdm->rename_auto_box, FALSE, FALSE, 0); | |
555 gtk_widget_show(fdm->rename_auto_box); | |
556 | |
557 hbox = pref_box_new(gd->vbox, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_GAP); | |
558 | |
559 fdm->rename_box = gtk_check_button_new_with_label(_("Rename")); | |
560 g_signal_connect(G_OBJECT(fdm->rename_box), "clicked", | |
561 G_CALLBACK(file_util_move_multiple_rename_cb), gd); | |
562 gtk_box_pack_start(GTK_BOX(hbox), fdm->rename_box, FALSE, FALSE, 0); | |
563 gtk_widget_show(fdm->rename_box); | |
564 | |
565 fdm->rename_entry = gtk_entry_new(); | |
566 gtk_entry_set_text(GTK_ENTRY(fdm->rename_entry), filename_from_path(fdm->dest)); | |
567 gtk_widget_set_sensitive(fdm->rename_entry, FALSE); | |
568 gtk_box_pack_start(GTK_BOX(hbox), fdm->rename_entry, TRUE, TRUE, 0); | |
569 gtk_widget_show(fdm->rename_entry); | |
570 | |
571 return gd; | |
572 } | |
573 | |
1 | 574 static void file_util_move_multiple(FileDataMult *fdm) |
575 { | |
576 while (fdm->dest || fdm->source_next) | |
577 { | |
9 | 578 gint success = FALSE; |
579 gint skip_file = FALSE; | |
580 | |
1 | 581 if (!fdm->dest) |
582 { | |
583 GList *work = fdm->source_next; | |
584 fdm->source = work->data; | |
9 | 585 fdm->dest = concat_dir_and_file(fdm->dest_base, filename_from_path(fdm->source)); |
1 | 586 fdm->source_next = work->next; |
9 | 587 fdm->confirmed = FALSE; |
1 | 588 } |
589 | |
3 | 590 if (fdm->dest && fdm->source && strcmp(fdm->dest, fdm->source) == 0) |
591 { | |
9 | 592 if (!fdm->confirmed) |
3 | 593 { |
9 | 594 GenericDialog *gd; |
595 const gchar *title; | |
596 gchar *text; | |
597 | |
598 if (fdm->copy) | |
599 { | |
600 title = _("Source to copy matches destination"); | |
601 text = g_strdup_printf(_("Unable to copy file:\n%s\nto itself."), fdm->dest); | |
602 } | |
603 else | |
604 { | |
605 title = _("Source to move matches destination"); | |
606 text = g_strdup_printf(_("Unable to move file:\n%s\nto itself."), fdm->dest); | |
607 } | |
608 | |
609 gd = file_util_gen_dlg(title, "GQview", "dlg_confirm", | |
610 NULL, TRUE, | |
611 file_util_move_multiple_cancel_cb, fdm); | |
612 generic_dialog_add_message(gd, GTK_STOCK_DIALOG_WARNING, title, text); | |
613 g_free(text); | |
614 generic_dialog_add_button(gd, GTK_STOCK_GO_FORWARD, _("Co_ntinue"), | |
615 file_util_move_multiple_continue_cb, TRUE); | |
616 | |
617 gtk_widget_show(gd->dialog); | |
618 return; | |
3 | 619 } |
9 | 620 skip_file = TRUE; |
3 | 621 } |
9 | 622 else if (isfile(fdm->dest)) |
1 | 623 { |
9 | 624 if (!fdm->confirmed && !fdm->confirm_all) |
625 { | |
626 GenericDialog *gd; | |
627 | |
628 gd = file_util_move_multiple_confirm_dialog(fdm); | |
629 gtk_widget_show(gd->dialog); | |
630 return; | |
631 } | |
632 if (fdm->skip) skip_file = TRUE; | |
633 } | |
634 | |
635 if (skip_file) | |
636 { | |
637 success = TRUE; | |
638 if (!fdm->confirm_all) fdm->skip = FALSE; | |
1 | 639 } |
640 else | |
641 { | |
9 | 642 gint try = TRUE; |
643 | |
644 if (fdm->confirm_all && fdm->rename_all && isfile(fdm->dest)) | |
1 | 645 { |
9 | 646 gchar *buf; |
647 buf = unique_filename_simple(fdm->dest); | |
648 if (buf) | |
649 { | |
650 g_free(fdm->dest); | |
651 fdm->dest = buf; | |
652 } | |
653 else | |
654 { | |
655 try = FALSE; | |
656 } | |
1 | 657 } |
9 | 658 if (try) |
1 | 659 { |
660 if (fdm->copy) | |
661 { | |
136 | 662 if (copy_file_ext(fdm->source, fdm->dest)) |
9 | 663 { |
664 success = TRUE; | |
665 file_maint_copied(fdm->source, fdm->dest); | |
666 } | |
1 | 667 } |
668 else | |
669 { | |
136 | 670 if (move_file_ext(fdm->source, fdm->dest)) |
1 | 671 { |
672 success = TRUE; | |
9 | 673 file_maint_moved(fdm->source, fdm->dest, fdm->source_list); |
1 | 674 } |
675 } | |
676 } | |
9 | 677 } |
678 | |
679 if (!success) | |
680 { | |
681 GenericDialog *gd; | |
682 const gchar *title; | |
683 gchar *text; | |
684 | |
685 if (fdm->copy) | |
686 { | |
687 title = _("Error copying file"); | |
688 text = g_strdup_printf(_("Unable to copy file:\n%s\nto:\n%s\nduring multiple file copy."), fdm->source, fdm->dest); | |
689 } | |
690 else | |
1 | 691 { |
9 | 692 title = _("Error moving file"); |
693 text = g_strdup_printf(_("Unable to move file:\n%s\nto:\n%s\nduring multiple file move."), fdm->source, fdm->dest); | |
1 | 694 } |
9 | 695 gd = file_util_gen_dlg(title, "GQview", "dlg_confirm", |
696 NULL, TRUE, | |
697 file_util_move_multiple_cancel_cb, fdm); | |
698 generic_dialog_add_message(gd, GTK_STOCK_DIALOG_WARNING, title, text); | |
699 g_free(text); | |
700 | |
701 generic_dialog_add_button(gd, GTK_STOCK_GO_FORWARD, _("Co_ntinue"), | |
702 file_util_move_multiple_continue_cb, TRUE); | |
703 gtk_widget_show(gd->dialog); | |
1 | 704 } |
9 | 705 |
706 g_free(fdm->dest); | |
707 fdm->dest = NULL; | |
708 | |
709 if (!success) return; | |
1 | 710 } |
711 | |
712 file_data_multiple_free(fdm); | |
713 } | |
714 | |
715 /* | |
716 * Single file move | |
717 */ | |
718 | |
9 | 719 static FileDataSingle *file_data_single_new(const gchar *source, const gchar *dest, gint copy) |
1 | 720 { |
721 FileDataSingle *fds = g_new0(FileDataSingle, 1); | |
722 fds->confirmed = FALSE; | |
723 fds->source = g_strdup(source); | |
724 fds->dest = g_strdup(dest); | |
725 fds->copy = copy; | |
726 return fds; | |
727 } | |
728 | |
729 static void file_data_single_free(FileDataSingle *fds) | |
730 { | |
731 g_free(fds->source); | |
732 g_free(fds->dest); | |
733 g_free(fds); | |
734 } | |
735 | |
9 | 736 static void file_util_move_single(FileDataSingle *fds); |
737 | |
738 static void file_util_move_single_ok_cb(GenericDialog *gd, gpointer data) | |
1 | 739 { |
740 FileDataSingle *fds = data; | |
9 | 741 |
1 | 742 fds->confirmed = TRUE; |
9 | 743 |
744 if (fds->rename_auto) | |
745 { | |
746 gchar *buf; | |
747 | |
748 buf = unique_filename_simple(fds->dest); | |
749 if (buf) | |
750 { | |
751 g_free(fds->dest); | |
752 fds->dest = buf; | |
753 } | |
754 else | |
755 { | |
756 /* unique failed? well, return to the overwrite prompt :( */ | |
757 fds->confirmed = FALSE; | |
758 } | |
759 } | |
760 else if (fds->rename) | |
761 { | |
762 const gchar *name; | |
763 | |
764 name = gtk_entry_get_text(GTK_ENTRY(fds->rename_entry)); | |
765 if (strlen(name) == 0 || | |
766 strcmp(name, filename_from_path(fds->source)) == 0) | |
767 { | |
768 fds->confirmed = FALSE; | |
769 } | |
770 else | |
771 { | |
772 gchar *base; | |
773 | |
774 base = remove_level_from_path(fds->dest); | |
775 g_free(fds->dest); | |
776 fds->dest = concat_dir_and_file(base, name); | |
777 fds->confirmed = !isname(fds->dest); | |
778 | |
779 g_free(base); | |
780 } | |
781 } | |
782 | |
1 | 783 file_util_move_single(fds); |
784 } | |
785 | |
9 | 786 static void file_util_move_single_cancel_cb(GenericDialog *gd, gpointer data) |
1 | 787 { |
788 FileDataSingle *fds = data; | |
9 | 789 |
1 | 790 file_data_single_free(fds); |
791 } | |
792 | |
9 | 793 static void file_util_move_single_rename_auto_cb(GtkWidget *widget, gpointer data) |
794 { | |
795 GenericDialog *gd = data; | |
796 FileDataSingle *fds; | |
797 | |
798 fds = gd->data; | |
799 | |
800 fds->rename_auto = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); | |
801 gtk_widget_set_sensitive(fds->rename_box, !fds->rename_auto); | |
802 gtk_widget_set_sensitive(fds->rename_entry, (!fds->rename_auto && fds->rename)); | |
803 | |
804 if (fds->rename_auto) | |
805 { | |
806 gchar *preview; | |
807 | |
808 preview = unique_filename_simple(fds->dest); | |
809 if (preview) gtk_entry_set_text(GTK_ENTRY(fds->rename_entry), filename_from_path(preview)); | |
810 g_free(preview); | |
811 } | |
812 } | |
813 | |
814 static void file_util_move_single_rename_cb(GtkWidget *widget, gpointer data) | |
815 { | |
816 GenericDialog *gd = data; | |
817 FileDataSingle *fds; | |
818 | |
819 fds = gd->data; | |
820 | |
821 fds->rename = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); | |
822 gtk_widget_set_sensitive(fds->rename_entry, fds->rename); | |
823 | |
42
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
824 if (fds->rename) |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
825 { |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
826 const gchar *name; |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
827 |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
828 gtk_widget_grab_focus(fds->rename_entry); |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
829 |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
830 name = gtk_entry_get_text(GTK_ENTRY(fds->rename_entry)); |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
831 gtk_editable_select_region(GTK_EDITABLE(fds->rename_entry), 0, filename_base_length(name)); |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
832 } |
9 | 833 } |
834 | |
1 | 835 static void file_util_move_single(FileDataSingle *fds) |
836 { | |
3 | 837 if (fds->dest && fds->source && strcmp(fds->dest, fds->source) == 0) |
838 { | |
9 | 839 file_util_warning_dialog(_("Source matches destination"), |
840 _("Source and destination are the same, operation cancelled."), | |
841 GTK_STOCK_DIALOG_INFO, NULL); | |
3 | 842 } |
843 else if (isfile(fds->dest) && !fds->confirmed) | |
1 | 844 { |
9 | 845 GenericDialog *gd; |
846 GtkWidget *hbox; | |
847 | |
848 gd = file_util_gen_dlg(_("Overwrite file"), "GQview", "dlg_confirm", | |
849 NULL, TRUE, | |
850 file_util_move_single_cancel_cb, fds); | |
851 | |
852 generic_dialog_add_message(gd, GTK_STOCK_DIALOG_QUESTION, | |
853 _("Overwrite file?"), | |
854 _("Replace existing file with new file.")); | |
855 pref_spacer(gd->vbox, 0); | |
856 | |
857 generic_dialog_add_button(gd, GTK_STOCK_OK, _("_Overwrite"), file_util_move_single_ok_cb, TRUE); | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
858 generic_dialog_add_image(gd, NULL, fds->dest, _("Existing file"), fds->source, _("New file"), TRUE); |
9 | 859 |
860 /* rename option */ | |
861 | |
862 fds->rename = FALSE; | |
863 fds->rename_auto = FALSE; | |
864 | |
865 hbox = pref_box_new(gd->vbox, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_GAP); | |
866 | |
867 fds->rename_auto_box = gtk_check_button_new_with_label(_("Auto rename")); | |
868 g_signal_connect(G_OBJECT(fds->rename_auto_box), "clicked", | |
869 G_CALLBACK(file_util_move_single_rename_auto_cb), gd); | |
870 gtk_box_pack_start(GTK_BOX(hbox), fds->rename_auto_box, FALSE, FALSE, 0); | |
871 gtk_widget_show(fds->rename_auto_box); | |
872 | |
873 hbox = pref_box_new(gd->vbox, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_GAP); | |
874 | |
875 fds->rename_box = gtk_check_button_new_with_label(_("Rename")); | |
876 g_signal_connect(G_OBJECT(fds->rename_box), "clicked", | |
877 G_CALLBACK(file_util_move_single_rename_cb), gd); | |
878 gtk_box_pack_start(GTK_BOX(hbox), fds->rename_box, FALSE, FALSE, 0); | |
879 gtk_widget_show(fds->rename_box); | |
880 | |
881 fds->rename_entry = gtk_entry_new(); | |
882 gtk_entry_set_text(GTK_ENTRY(fds->rename_entry), filename_from_path(fds->dest)); | |
883 gtk_widget_set_sensitive(fds->rename_entry, FALSE); | |
884 gtk_box_pack_start(GTK_BOX(hbox), fds->rename_entry, TRUE, TRUE, 0); | |
885 gtk_widget_show(fds->rename_entry); | |
886 | |
887 gtk_widget_show(gd->dialog); | |
1 | 888 return; |
889 } | |
890 else | |
891 { | |
892 gint success = FALSE; | |
893 if (fds->copy) | |
894 { | |
136 | 895 if (copy_file_ext(fds->source, fds->dest)) |
9 | 896 { |
897 success = TRUE; | |
898 file_maint_copied(fds->source, fds->dest); | |
899 } | |
1 | 900 } |
901 else | |
902 { | |
136 | 903 if (move_file_ext(fds->source, fds->dest)) |
1 | 904 { |
905 success = TRUE; | |
9 | 906 file_maint_moved(fds->source, fds->dest, NULL); |
1 | 907 } |
908 } | |
909 if (!success) | |
910 { | |
911 gchar *title; | |
912 gchar *text; | |
913 if (fds->copy) | |
914 { | |
915 title = _("Error copying file"); | |
916 text = g_strdup_printf(_("Unable to copy file:\n%s\nto:\n%s"), fds->source, fds->dest); | |
917 } | |
918 else | |
919 { | |
920 title = _("Error moving file"); | |
921 text = g_strdup_printf(_("Unable to move file:\n%s\nto:\n%s"), fds->source, fds->dest); | |
922 } | |
9 | 923 file_util_warning_dialog(title, text, GTK_STOCK_DIALOG_ERROR, NULL); |
1 | 924 g_free(text); |
925 } | |
926 } | |
3 | 927 |
928 file_data_single_free(fds); | |
1 | 929 } |
930 | |
931 /* | |
932 * file move dialog | |
933 */ | |
934 | |
935 static void file_util_move_do(FileDialog *fd) | |
936 { | |
9 | 937 file_dialog_sync_history(fd, TRUE); |
938 | |
1 | 939 if (fd->multiple_files) |
940 { | |
941 file_util_move_multiple(file_data_multiple_new(fd->source_list, fd->dest_path, fd->type)); | |
942 fd->source_list = NULL; | |
943 } | |
944 else | |
945 { | |
946 if (isdir(fd->dest_path)) | |
947 { | |
9 | 948 gchar *buf = concat_dir_and_file(fd->dest_path, filename_from_path(fd->source_path)); |
949 gtk_entry_set_text(GTK_ENTRY(fd->entry), buf); | |
950 g_free(buf); | |
1 | 951 } |
952 file_util_move_single(file_data_single_new(fd->source_path, fd->dest_path, fd->type)); | |
953 } | |
954 | |
9 | 955 file_dialog_close(fd); |
1 | 956 } |
957 | |
958 static void file_util_move_check(FileDialog *fd) | |
959 { | |
42
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
960 if (fd->dest_path && strcmp(fd->dest_path, "~") == 0) |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
961 { |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
962 gtk_entry_set_text(GTK_ENTRY(fd->entry), homedir()); |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
963 } |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
964 |
1 | 965 if (fd->multiple_files && !isdir(fd->dest_path)) |
966 { | |
967 if (isfile(fd->dest_path)) | |
9 | 968 { |
969 file_util_warning_dialog(_("Invalid destination"), | |
970 _("When operating with multiple files, please select\na folder, not a file."), | |
971 GTK_STOCK_DIALOG_INFO, NULL); | |
972 } | |
1 | 973 else |
9 | 974 file_util_warning_dialog(_("Invalid folder"), |
975 _("Please select an existing folder."), | |
976 GTK_STOCK_DIALOG_INFO, NULL); | |
1 | 977 return; |
978 } | |
979 | |
42
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
980 if (!fd->dest_path || fd->dest_path[0] != '/') |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
981 { |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
982 if (fd->source_path) |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
983 { |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
984 gchar *base; |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
985 gchar *path; |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
986 |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
987 base = remove_level_from_path(fd->source_path); |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
988 path = concat_dir_and_file(base, fd->dest_path); |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
989 |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
990 gtk_entry_set_text(GTK_ENTRY(fd->entry), path); |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
991 |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
992 g_free(path); |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
993 g_free(base); |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
994 } |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
995 return; |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
996 } |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
997 |
1 | 998 file_util_move_do(fd); |
999 } | |
1000 | |
9 | 1001 static void file_util_move_cb(FileDialog *fd, gpointer data) |
1 | 1002 { |
1003 file_util_move_check(fd); | |
1004 } | |
1005 | |
9 | 1006 static void file_util_move_cancel_cb(FileDialog *fd, gpointer data) |
1 | 1007 { |
9 | 1008 file_dialog_close(fd); |
1 | 1009 } |
1010 | |
9 | 1011 static void real_file_util_move(const gchar *source_path, GList *source_list, |
1012 const gchar *dest_path, gint copy, GtkWidget *parent) | |
1 | 1013 { |
1014 FileDialog *fd; | |
9 | 1015 GtkWidget *label; |
1 | 1016 gchar *path = NULL; |
1017 gint multiple; | |
9 | 1018 const gchar *text; |
1019 const gchar *title; | |
1020 const gchar *op_text; | |
1021 const gchar *stock_id; | |
1 | 1022 |
1023 if (!source_path && !source_list) return; | |
1024 | |
1025 if (source_path) | |
1026 { | |
1027 path = g_strdup(source_path); | |
1028 multiple = FALSE; | |
1029 } | |
1030 else if (source_list->next) | |
1031 { | |
1032 multiple = TRUE; | |
1033 } | |
1034 else | |
1035 { | |
1036 path = g_strdup(source_list->data); | |
9 | 1037 path_list_free(source_list); |
1 | 1038 source_list = NULL; |
1039 multiple = FALSE; | |
1040 } | |
1041 | |
1042 if (copy) | |
1043 { | |
9 | 1044 title = _("Copy - GQview"); |
1045 op_text = _("_Copy"); | |
1 | 1046 if (path) |
9 | 1047 { |
1048 text = _("Copy file"); | |
1049 } | |
1 | 1050 else |
9 | 1051 { |
1052 text = _("Copy multiple files"); | |
1053 } | |
1054 stock_id = GTK_STOCK_COPY; | |
1 | 1055 } |
1056 else | |
1057 { | |
9 | 1058 title = _("Move - GQview"); |
1059 op_text = _("_Move"); | |
1 | 1060 if (path) |
9 | 1061 { |
1062 text = _("Move file"); | |
1063 } | |
1 | 1064 else |
9 | 1065 { |
1066 text = _("Move multiple files"); | |
1067 } | |
1068 stock_id = GTK_STOCK_OK; | |
1 | 1069 } |
1070 | |
9 | 1071 fd = file_util_file_dlg(title, "GQview", "dlg_copymove", parent, |
1072 file_util_move_cancel_cb, NULL); | |
1073 generic_dialog_add_message(GENERIC_DIALOG(fd), NULL, text, NULL); | |
1074 | |
1075 if (path) | |
1076 { | |
1077 GtkWidget *box; | |
1078 | |
1079 box = pref_box_new(GENERIC_DIALOG(fd)->vbox, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE); | |
1080 pref_label_new(box, _("File name:")); | |
1081 pref_label_new(box, filename_from_path(path)); | |
1082 } | |
1083 | |
1084 label = pref_label_new(GENERIC_DIALOG(fd)->vbox, _("Choose the destination folder.")); | |
1085 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); | |
1086 pref_spacer(GENERIC_DIALOG(fd)->vbox, 0); | |
1087 | |
1088 file_dialog_add_button(fd, stock_id, op_text, file_util_move_cb, TRUE); | |
1089 | |
1090 file_dialog_add_path_widgets(fd, NULL, dest_path, "move_copy", NULL, NULL); | |
1 | 1091 |
1092 fd->type = copy; | |
1093 fd->source_path = path; | |
1094 fd->source_list = source_list; | |
1095 fd->multiple_files = multiple; | |
1096 | |
9 | 1097 gtk_widget_show(GENERIC_DIALOG(fd)->dialog); |
1098 } | |
1099 | |
1100 void file_util_move(const gchar *source_path, GList *source_list, const gchar *dest_path, GtkWidget *parent) | |
1101 { | |
1102 real_file_util_move(source_path, source_list, dest_path, FALSE, parent); | |
1103 } | |
1104 | |
1105 void file_util_copy(const gchar *source_path, GList *source_list, const gchar *dest_path, GtkWidget *parent) | |
1106 { | |
1107 real_file_util_move(source_path, source_list, dest_path, TRUE, parent); | |
1108 } | |
1109 | |
1110 void file_util_move_simple(GList *list, const gchar *dest_path) | |
1111 { | |
1112 if (!list) return; | |
1113 if (!dest_path) | |
1114 { | |
1115 path_list_free(list); | |
1116 return; | |
1117 } | |
1118 | |
1119 if (!list->next) | |
1120 { | |
1121 const gchar *source; | |
1122 gchar *dest; | |
1123 | |
1124 source = list->data; | |
1125 dest = concat_dir_and_file(dest_path, filename_from_path(source)); | |
1126 | |
1127 file_util_move_single(file_data_single_new(source, dest, FALSE)); | |
1128 g_free(dest); | |
1129 path_list_free(list); | |
1130 return; | |
1131 } | |
1132 | |
1133 file_util_move_multiple(file_data_multiple_new(list, dest_path, FALSE)); | |
1134 } | |
1135 | |
1136 void file_util_copy_simple(GList *list, const gchar *dest_path) | |
1137 { | |
1138 if (!list) return; | |
1139 if (!dest_path) | |
1 | 1140 { |
9 | 1141 path_list_free(list); |
1142 return; | |
1143 } | |
1144 | |
1145 if (!list->next) | |
1146 { | |
1147 const gchar *source; | |
1148 gchar *dest; | |
1149 | |
1150 source = list->data; | |
1151 dest = concat_dir_and_file(dest_path, filename_from_path(source)); | |
1152 | |
1153 file_util_move_single(file_data_single_new(source, dest, TRUE)); | |
1154 g_free(dest); | |
1155 path_list_free(list); | |
1156 return; | |
1 | 1157 } |
9 | 1158 |
1159 file_util_move_multiple(file_data_multiple_new(list, dest_path, TRUE)); | |
1160 } | |
1161 | |
1162 /* | |
1163 *-------------------------------------------------------------------------- | |
1164 * Safe Delete | |
1165 *-------------------------------------------------------------------------- | |
1166 */ | |
1167 | |
1168 static gint file_util_safe_number(gint64 free_space) | |
1169 { | |
1170 gint n = 0; | |
1171 gint64 total = 0; | |
1172 GList *list; | |
1173 GList *work; | |
1174 gint sorted = FALSE; | |
1175 gint warned = FALSE; | |
1176 | |
1177 if (!filelist_read(safe_delete_path, &list, NULL)) return 0; | |
1178 | |
1179 work = list; | |
1180 while (work) | |
1 | 1181 { |
9 | 1182 FileData *fd; |
1183 gint v; | |
1184 | |
1185 fd = work->data; | |
1186 work = work->next; | |
1187 | |
1188 v = (gint)strtol(fd->name, NULL, 10); | |
1189 if (v >= n) n = v + 1; | |
1190 | |
1191 total += fd->size; | |
1 | 1192 } |
9 | 1193 |
1194 while (list && | |
1195 (free_space < 0 || total + free_space > (gint64)safe_delete_size * 1048576) ) | |
1196 { | |
1197 FileData *fd; | |
1198 | |
1199 if (!sorted) | |
1200 { | |
1201 list = filelist_sort(list, SORT_NAME, TRUE); | |
1202 sorted = TRUE; | |
1203 } | |
1204 | |
1205 fd = list->data; | |
1206 list = g_list_remove(list, fd); | |
1207 | |
1208 if (debug) printf("expunging from trash for space: %s\n", fd->name); | |
1209 if (!unlink_file(fd->path) && !warned) | |
1210 { | |
1211 file_util_warning_dialog(_("Delete failed"), | |
1212 _("Unable to remove old file from trash folder"), | |
1213 GTK_STOCK_DIALOG_WARNING, NULL); | |
1214 warned = TRUE; | |
1215 } | |
1216 total -= fd->size; | |
1217 file_data_free(fd); | |
1218 } | |
1219 | |
1220 filelist_free(list); | |
1221 | |
1222 return n; | |
1223 } | |
1224 | |
1225 void file_util_trash_clear(void) | |
1226 { | |
1227 file_util_safe_number(-1); | |
1228 } | |
1229 | |
1230 static gchar *file_util_safe_dest(const gchar *path) | |
1231 { | |
1232 gint n; | |
1233 | |
1234 n = file_util_safe_number(filesize(path)); | |
1235 return g_strdup_printf("%s/%06d_%s", safe_delete_path, n, filename_from_path(path)); | |
1236 } | |
1237 | |
1238 static void file_util_safe_del_toggle_cb(GtkWidget *button, gpointer data) | |
1239 { | |
1240 safe_delete_enable = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)); | |
1241 } | |
1242 | |
1243 static void file_util_safe_del_close_cb(GtkWidget *dialog, gpointer data) | |
1244 { | |
1245 GenericDialog **gd = data; | |
1246 | |
1247 *gd = NULL; | |
1 | 1248 } |
1249 | |
9 | 1250 static gint file_util_unlink(const gchar *path) |
1 | 1251 { |
9 | 1252 static GenericDialog *gd = NULL; |
1253 gchar *result = NULL; | |
1254 gint success = TRUE; | |
1255 | |
1256 if (!isfile(path)) return FALSE; | |
1257 | |
134
9009856628f7
started implementation of external commands; external Delete should work
nadvornik
parents:
115
diff
changeset
|
1258 |
9 | 1259 if (!safe_delete_enable) |
1260 { | |
1261 return unlink_file(path); | |
1262 } | |
1263 | |
1264 if (!isdir(safe_delete_path)) | |
1265 { | |
1266 if (debug) printf("creating trash: %s\n", safe_delete_path); | |
1267 if (!safe_delete_path || !mkdir_utf8(safe_delete_path, 0755)) | |
1268 { | |
1269 result = _("Could not create folder"); | |
1270 success = FALSE; | |
1271 } | |
1272 } | |
1273 | |
1274 if (success) | |
1275 { | |
1276 gchar *dest; | |
1277 | |
1278 dest = file_util_safe_dest(path); | |
1279 if (dest) | |
1280 { | |
1281 if (debug) printf("safe deleting %s to %s\n", path, dest); | |
1282 success = move_file(path, dest); | |
1283 } | |
1284 else | |
1285 { | |
1286 success = FALSE; | |
1287 } | |
1288 | |
1289 if (!success && !access_file(path, W_OK)) | |
1290 { | |
1291 result = _("Permission denied"); | |
1292 } | |
1293 g_free(dest); | |
1294 } | |
1295 | |
1296 if (result && !gd) | |
1297 { | |
1298 GtkWidget *button; | |
1299 gchar *buf; | |
1300 | |
1301 buf = g_strdup_printf(_("Unable to access or create the trash folder.\n\"%s\""), safe_delete_path); | |
1302 gd = file_util_warning_dialog(result, buf, GTK_STOCK_DIALOG_WARNING, NULL); | |
1303 g_free(buf); | |
1304 | |
1305 button = gtk_check_button_new_with_label(_("Turn off safe delete")); | |
1306 g_signal_connect(G_OBJECT(button), "toggled", | |
1307 G_CALLBACK(file_util_safe_del_toggle_cb), NULL); | |
1308 gtk_box_pack_start(GTK_BOX(gd->vbox), button, FALSE, FALSE, 0); | |
1309 gtk_widget_show(button); | |
1310 | |
1311 g_signal_connect(G_OBJECT(gd->dialog), "destroy", | |
1312 G_CALLBACK(file_util_safe_del_close_cb), &gd); | |
1313 } | |
1314 | |
1315 return success; | |
1 | 1316 } |
1317 | |
9 | 1318 static void box_append_safe_delete_status(GenericDialog *gd) |
1 | 1319 { |
9 | 1320 GtkWidget *label; |
1321 gchar *buf; | |
1322 | |
1323 buf = g_strdup_printf(_("Safe delete: %s"), (safe_delete_enable) ? _("on") : _("off")); | |
1324 label = pref_label_new(gd->vbox, buf); | |
1325 g_free(buf); | |
1326 | |
1327 gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); | |
1328 gtk_widget_set_sensitive(label, FALSE); | |
1 | 1329 } |
1330 | |
1331 /* | |
1332 *-------------------------------------------------------------------------- | |
1333 * Delete routines | |
1334 *-------------------------------------------------------------------------- | |
1335 */ | |
1336 | |
1337 /* | |
1338 * delete multiple files | |
1339 */ | |
1340 | |
9 | 1341 static void file_util_delete_multiple_ok_cb(GenericDialog *gd, gpointer data); |
1342 static void file_util_delete_multiple_cancel_cb(GenericDialog *gd, gpointer data); | |
1343 | |
1344 static void file_util_delete_multiple_ok_cb(GenericDialog *gd, gpointer data) | |
1 | 1345 { |
1346 GList *source_list = data; | |
1347 | |
135 | 1348 if (editor_command[CMD_DELETE]) |
1349 { | |
1350 if (!start_editor_from_path_list(CMD_DELETE, source_list)) | |
1351 { | |
1352 file_util_warning_dialog(_("File deletion failed"), _("Unable to delete files by external command\n"), GTK_STOCK_DIALOG_ERROR, NULL); | |
1353 } | |
1354 else | |
1355 { | |
1356 while (source_list) | |
1357 { | |
1358 gchar *path = source_list->data; | |
1359 source_list = g_list_remove(source_list, path); | |
1360 file_maint_removed(path, source_list); | |
1361 g_free(path); | |
1362 } | |
1363 } | |
1364 return; | |
1365 } | |
1366 | |
1367 | |
9 | 1368 while (source_list) |
1 | 1369 { |
1370 gchar *path = source_list->data; | |
9 | 1371 |
1 | 1372 source_list = g_list_remove(source_list, path); |
9 | 1373 |
1374 if (!file_util_unlink(path)) | |
1 | 1375 { |
1376 if (source_list) | |
1377 { | |
9 | 1378 GenericDialog *d; |
1379 gchar *text; | |
1380 | |
1381 d = file_util_gen_dlg(_("Delete failed"), "GQview", "dlg_confirm", | |
1382 NULL, TRUE, | |
1383 file_util_delete_multiple_cancel_cb, source_list); | |
1384 | |
1 | 1385 text = g_strdup_printf(_("Unable to delete file:\n %s\n Continue multiple delete operation?"), path); |
9 | 1386 generic_dialog_add_message(d, GTK_STOCK_DIALOG_WARNING, NULL, text); |
1387 g_free(text); | |
1388 | |
1389 generic_dialog_add_button(d, GTK_STOCK_GO_FORWARD, _("Co_ntinue"), | |
1390 file_util_delete_multiple_ok_cb, TRUE); | |
1391 gtk_widget_show(d->dialog); | |
1 | 1392 } |
1393 else | |
1394 { | |
9 | 1395 gchar *text; |
1396 | |
1 | 1397 text = g_strdup_printf(_("Unable to delete file:\n%s"), path); |
9 | 1398 file_util_warning_dialog(_("Delete failed"), text, GTK_STOCK_DIALOG_ERROR, NULL); |
1399 g_free(text); | |
1 | 1400 } |
1401 g_free(path); | |
1402 return; | |
1403 } | |
1404 else | |
1405 { | |
9 | 1406 file_maint_removed(path, source_list); |
1 | 1407 } |
1408 g_free(path); | |
1409 } | |
1410 } | |
1411 | |
9 | 1412 static void file_util_delete_multiple_cancel_cb(GenericDialog *gd, gpointer data) |
1 | 1413 { |
1414 GList *source_list = data; | |
9 | 1415 |
1416 path_list_free(source_list); | |
1 | 1417 } |
1418 | |
9 | 1419 static void file_util_delete_multiple_review_skip(GenericDialog *gd, gint next) |
1420 { | |
1421 GtkWidget *button_back; | |
1422 GtkWidget *button_next; | |
1423 GtkWidget *button_label; | |
1424 GList *list; | |
1425 GList *list_point; | |
1426 const gchar *path; | |
1427 gchar *buf; | |
1428 | |
1429 list = gd->data; | |
1430 button_back = g_object_get_data(G_OBJECT(gd->dialog), "button_back"); | |
1431 button_next = g_object_get_data(G_OBJECT(gd->dialog), "button_next"); | |
1432 button_label = g_object_get_data(G_OBJECT(gd->dialog), "button_label"); | |
1433 list_point = g_object_get_data(G_OBJECT(gd->dialog), "list_point"); | |
1434 | |
1435 if (!list || !button_label) return; | |
1436 | |
1437 if (list_point) | |
1438 { | |
1439 if (next) | |
1440 { | |
1441 if (list_point->next) list_point = list_point->next; | |
1442 } | |
1443 else | |
1444 { | |
1445 if (list_point->prev) list_point = list_point->prev; | |
1446 } | |
1447 } | |
1448 else | |
1449 { | |
1450 list_point = list; | |
1451 } | |
1452 | |
1453 if (!list_point) return; | |
1454 | |
1455 path = list_point->data; | |
1456 buf = g_strdup_printf(_("File %d of %d"), | |
1457 g_list_index(list, (gpointer)path) + 1, | |
1458 g_list_length(list)); | |
1459 gtk_label_set_text(GTK_LABEL(button_label), buf); | |
1460 g_free(buf); | |
1461 | |
1462 gtk_widget_set_sensitive(button_back, (list_point->prev != NULL) ); | |
1463 gtk_widget_set_sensitive(button_next, (list_point->next != NULL) ); | |
1464 | |
1465 generic_dialog_image_set(gd, path); | |
1466 | |
1467 g_object_set_data(G_OBJECT(gd->dialog), "list_point", list_point); | |
1468 } | |
1469 | |
1470 static void file_util_delete_multiple_review_back(GtkWidget *button, gpointer data) | |
1471 { | |
1472 GenericDialog *gd = data; | |
1473 | |
1474 file_util_delete_multiple_review_skip(gd, FALSE); | |
1475 } | |
1476 | |
1477 static void file_util_delete_multiple_review_next(GtkWidget *button, gpointer data) | |
1478 { | |
1479 GenericDialog *gd = data; | |
1480 | |
1481 file_util_delete_multiple_review_skip(gd, TRUE); | |
1482 } | |
1483 | |
1484 static void file_util_delete_multiple_review_button_cb(ImageWindow *imd, gint button, guint32 time, | |
1485 gdouble x, gdouble y, guint state, gpointer data) | |
1486 { | |
1487 if (button == 1) | |
1488 { | |
1489 file_util_delete_multiple_review_next(NULL, data); | |
1490 } | |
1491 else if (button == 2 || button == 3) | |
1492 { | |
1493 file_util_delete_multiple_review_back(NULL, data); | |
1494 } | |
1495 } | |
1496 | |
1497 static void file_util_delete_multiple_review_scroll_cb(ImageWindow *imd, GdkScrollDirection direction, guint32 time, | |
1498 gdouble x, gdouble y, guint state, gpointer data) | |
1499 { | |
1500 if (direction == GDK_SCROLL_UP) | |
1501 { | |
1502 file_util_delete_multiple_review_back(NULL, data); | |
1503 } | |
1504 else if (direction == GDK_SCROLL_DOWN) | |
1505 { | |
1506 file_util_delete_multiple_review_next(NULL, data); | |
1507 } | |
1508 } | |
1509 | |
1510 static void file_util_delete_multiple(GList *source_list, GtkWidget *parent) | |
1 | 1511 { |
1512 if (!confirm_delete) | |
1513 { | |
1514 file_util_delete_multiple_ok_cb(NULL, source_list); | |
1515 } | |
1516 else | |
1517 { | |
9 | 1518 GenericDialog *gd; |
1519 GtkWidget *hbox; | |
1520 GtkWidget *button; | |
1521 GtkWidget *label; | |
1522 ImageWindow *imd; | |
1523 gchar *buf; | |
1524 | |
1525 gd = file_util_gen_dlg(_("Delete files - GQview"), | |
1526 "GQview", "dlg_confirm", parent, TRUE, | |
1527 file_util_delete_multiple_cancel_cb, source_list); | |
1528 | |
1529 generic_dialog_add_message(gd, NULL, _("Delete multiple files"), NULL); | |
1530 | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1531 generic_dialog_add_image(gd, NULL, NULL, NULL, NULL, NULL, TRUE); |
9 | 1532 imd = g_object_get_data(G_OBJECT(gd->dialog), "img_image"); |
1533 image_set_button_func(imd, file_util_delete_multiple_review_button_cb, gd); | |
1534 image_set_scroll_func(imd, file_util_delete_multiple_review_scroll_cb, gd); | |
1535 | |
1536 hbox = pref_box_new(gd->vbox, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_BUTTON_GAP); | |
1537 | |
1538 button = pref_button_new(hbox, GTK_STOCK_GO_BACK, NULL, TRUE, | |
1539 G_CALLBACK(file_util_delete_multiple_review_back), gd); | |
1540 gtk_widget_set_sensitive(button, FALSE); | |
1541 g_object_set_data(G_OBJECT(gd->dialog), "button_back", button); | |
1542 | |
1543 button = pref_button_new(hbox, GTK_STOCK_GO_FORWARD, NULL, TRUE, | |
1544 G_CALLBACK(file_util_delete_multiple_review_next), gd); | |
1545 g_object_set_data(G_OBJECT(gd->dialog), "button_next", button); | |
1546 | |
1547 buf = g_strdup_printf(_("Review %d files"), g_list_length(source_list) ); | |
1548 label = pref_label_new(hbox, buf); | |
1549 g_free(buf); | |
1550 g_object_set_data(G_OBJECT(gd->dialog), "button_label", label); | |
1551 | |
1552 box_append_safe_delete_status(gd); | |
1553 | |
1554 generic_dialog_add_button(gd, GTK_STOCK_DELETE, NULL, file_util_delete_multiple_ok_cb, TRUE); | |
1555 | |
1556 gtk_widget_show(gd->dialog); | |
1 | 1557 } |
1558 } | |
1559 | |
1560 /* | |
1561 * delete single file | |
1562 */ | |
1563 | |
9 | 1564 static void file_util_delete_ok_cb(GenericDialog *gd, gpointer data) |
1 | 1565 { |
1566 gchar *path = data; | |
1567 | |
135 | 1568 if (editor_command[CMD_DELETE]) |
1569 { | |
1570 if (!start_editor_from_file(CMD_DELETE, path)) | |
1571 { | |
1572 gchar *text = g_strdup_printf(_("Unable to delete file by external command:\n%s"), path); | |
1573 file_util_warning_dialog(_("File deletion failed"), text, GTK_STOCK_DIALOG_ERROR, NULL); | |
1574 g_free(text); | |
1575 } | |
1576 else | |
1577 { | |
1578 file_maint_removed(path, NULL); | |
1579 } | |
1580 } | |
1581 else if (!file_util_unlink(path)) | |
1 | 1582 { |
1583 gchar *text = g_strdup_printf(_("Unable to delete file:\n%s"), path); | |
9 | 1584 file_util_warning_dialog(_("File deletion failed"), text, GTK_STOCK_DIALOG_ERROR, NULL); |
1 | 1585 g_free(text); |
1586 } | |
1587 else | |
1588 { | |
9 | 1589 file_maint_removed(path, NULL); |
1 | 1590 } |
1591 | |
1592 g_free(path); | |
1593 } | |
1594 | |
9 | 1595 static void file_util_delete_cancel_cb(GenericDialog *gd, gpointer data) |
1 | 1596 { |
1597 gchar *path = data; | |
9 | 1598 |
1 | 1599 g_free(path); |
1600 } | |
1601 | |
9 | 1602 static void file_util_delete_single(const gchar *path, GtkWidget *parent) |
1 | 1603 { |
1604 gchar *buf = g_strdup(path); | |
1605 | |
1606 if (!confirm_delete) | |
1607 { | |
1608 file_util_delete_ok_cb(NULL, buf); | |
1609 } | |
1610 else | |
1611 { | |
9 | 1612 GenericDialog *gd; |
1613 GtkWidget *table; | |
1614 gchar *base; | |
1615 | |
1616 gd = file_util_gen_dlg(_("Delete file - GQview"), "GQview", "dlg_confirm", | |
1617 parent, TRUE, | |
1618 file_util_delete_cancel_cb, buf); | |
1619 | |
1620 generic_dialog_add_message(gd, NULL, _("Delete file?"), NULL); | |
1621 | |
1622 table = pref_table_new(gd->vbox, 2, 2, FALSE, FALSE); | |
1623 | |
1624 pref_table_label(table, 0, 0, _("File name:"), 1.0); | |
1625 pref_table_label(table, 1, 0, filename_from_path(path), 0.0); | |
1626 | |
1627 pref_table_label(table, 0, 1, _("Location:"), 1.0); | |
1628 | |
1629 base = remove_level_from_path(path); | |
1630 pref_table_label(table, 1, 1, base, 0.0); | |
1631 g_free(base); | |
1632 | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1633 generic_dialog_add_image(gd, NULL, path, NULL, NULL, NULL, FALSE); |
9 | 1634 |
1635 box_append_safe_delete_status(gd); | |
1636 | |
1637 generic_dialog_add_button(gd, GTK_STOCK_DELETE, NULL, file_util_delete_ok_cb, TRUE); | |
1638 | |
1639 gtk_widget_show(gd->dialog); | |
1 | 1640 } |
1641 } | |
1642 | |
9 | 1643 void file_util_delete(const gchar *source_path, GList *source_list, GtkWidget *parent) |
1 | 1644 { |
1645 if (!source_path && !source_list) return; | |
1646 | |
1647 if (source_path) | |
1648 { | |
9 | 1649 file_util_delete_single(source_path, parent); |
1 | 1650 } |
1651 else if (!source_list->next) | |
1652 { | |
9 | 1653 file_util_delete_single(source_list->data, parent); |
1654 path_list_free(source_list); | |
1 | 1655 } |
1656 else | |
1657 { | |
9 | 1658 file_util_delete_multiple(source_list, parent); |
1 | 1659 } |
1660 } | |
1661 | |
1662 /* | |
1663 *-------------------------------------------------------------------------- | |
1664 * Rename routines | |
1665 *-------------------------------------------------------------------------- | |
1666 */ | |
1667 | |
1668 /* | |
1669 * rename multiple files | |
1670 */ | |
1671 | |
9 | 1672 enum { |
1673 RENAME_COLUMN_PATH = 0, | |
1674 RENAME_COLUMN_NAME, | |
1675 RENAME_COLUMN_PREVIEW, | |
1676 RENAME_COLUMN_COUNT | |
1677 }; | |
1678 | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1679 typedef enum { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1680 RENAME_TYPE_MANUAL = 0, |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1681 RENAME_TYPE_FORMATTED, |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1682 RENAME_TYPE_AUTO |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1683 } RenameType; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1684 |
9 | 1685 typedef struct _RenameDataMult RenameDataMult; |
1686 struct _RenameDataMult | |
1 | 1687 { |
9 | 1688 FileDialog *fd; |
1689 | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1690 RenameType rename_type; |
9 | 1691 |
1692 GtkWidget *listview; | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1693 GtkWidget *combo_type; |
9 | 1694 |
1695 GtkWidget *rename_box; | |
1696 GtkWidget *rename_label; | |
1697 GtkWidget *rename_entry; | |
1698 | |
1699 GtkWidget *auto_box; | |
1700 GtkWidget *auto_entry_front; | |
1701 GtkWidget *auto_spin_start; | |
1702 GtkWidget *auto_spin_pad; | |
1703 GtkWidget *auto_entry_end; | |
1704 | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1705 GtkWidget *format_box; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1706 GtkWidget *format_entry; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1707 GtkWidget *format_spin; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1708 |
9 | 1709 ImageWindow *imd; |
1710 | |
1711 gint update_idle_id; | |
1712 }; | |
1713 | |
1714 static void file_util_rename_multiple(RenameDataMult *rd); | |
1715 | |
1716 static void file_util_rename_multiple_ok_cb(GenericDialog *gd, gpointer data) | |
1717 { | |
1718 RenameDataMult *rd = data; | |
1719 GtkWidget *dialog; | |
1720 | |
1721 dialog = GENERIC_DIALOG(rd->fd)->dialog; | |
1722 if (!GTK_WIDGET_VISIBLE(dialog)) gtk_widget_show(dialog); | |
1723 | |
1724 rd->fd->type = TRUE; | |
1725 file_util_rename_multiple(rd); | |
1 | 1726 } |
1727 | |
9 | 1728 static void file_util_rename_multiple_cancel_cb(GenericDialog *gd, gpointer data) |
1729 { | |
1730 RenameDataMult *rd = data; | |
1731 GtkWidget *dialog; | |
1732 | |
1733 dialog = GENERIC_DIALOG(rd->fd)->dialog; | |
1734 if (!GTK_WIDGET_VISIBLE(dialog)) gtk_widget_show(dialog); | |
1735 } | |
1736 | |
1737 static gint file_util_rename_multiple_find_row(RenameDataMult *rd, const gchar *path, GtkTreeIter *iter) | |
1 | 1738 { |
9 | 1739 GtkTreeModel *store; |
1740 gint valid; | |
1741 gint row = 0; | |
1742 | |
1743 store = gtk_tree_view_get_model(GTK_TREE_VIEW(rd->listview)); | |
1744 valid = gtk_tree_model_get_iter_first(store, iter); | |
1745 while (valid) | |
1746 { | |
1747 gchar *path_n; | |
1748 gint ret; | |
1749 | |
1750 gtk_tree_model_get(GTK_TREE_MODEL(store), iter, RENAME_COLUMN_PATH, &path_n, -1); | |
1751 ret = (strcmp(path_n, path) == 0); | |
1752 g_free(path_n); | |
1753 if (ret) return row; | |
1754 | |
1755 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), iter); | |
1756 row++; | |
1757 } | |
1758 | |
1759 return -1; | |
1 | 1760 } |
1761 | |
9 | 1762 static void file_util_rename_multiple(RenameDataMult *rd) |
1 | 1763 { |
9 | 1764 FileDialog *fd; |
1765 | |
1766 fd = rd->fd; | |
1767 | |
1 | 1768 if (isfile(fd->dest_path) && !fd->type) |
1769 { | |
9 | 1770 GenericDialog *gd; |
1771 | |
1772 gd = file_util_gen_dlg(_("Overwrite file"), "GQview", "dlg_confirm", | |
1773 NULL, TRUE, | |
1774 file_util_rename_multiple_cancel_cb, rd); | |
1775 | |
1776 generic_dialog_add_message(gd, GTK_STOCK_DIALOG_QUESTION, | |
1777 _("Overwrite file?"), | |
1778 _("Replace existing file by renaming new file.")); | |
1779 pref_spacer(gd->vbox, 0); | |
1780 | |
1781 generic_dialog_add_button(gd, GTK_STOCK_OK, _("_Overwrite"), file_util_rename_multiple_ok_cb, TRUE); | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1782 generic_dialog_add_image(gd, NULL, |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1783 fd->dest_path, _("Existing file"), |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1784 fd->source_path, _("New file"), TRUE); |
9 | 1785 |
1786 gtk_widget_hide(GENERIC_DIALOG(fd)->dialog); | |
1787 | |
1788 gtk_widget_show(gd->dialog); | |
1 | 1789 return; |
1790 } | |
1791 else | |
1792 { | |
136 | 1793 if (!rename_file_ext(fd->source_path, fd->dest_path)) |
1 | 1794 { |
9 | 1795 gchar *text = g_strdup_printf(_("Unable to rename file:\n%s\n to:\n%s"), |
1796 filename_from_path(fd->source_path), | |
1797 filename_from_path(fd->dest_path)); | |
1798 file_util_warning_dialog(_("Error renaming file"), text, GTK_STOCK_DIALOG_ERROR, NULL); | |
1 | 1799 g_free(text); |
1800 } | |
1801 else | |
1802 { | |
9 | 1803 GtkTreeModel *store; |
1804 GtkTreeIter iter; | |
1805 GtkTreeIter next; | |
1 | 1806 gint row; |
9 | 1807 |
1808 file_maint_renamed(fd->source_path, fd->dest_path); | |
1809 | |
1810 store = gtk_tree_view_get_model(GTK_TREE_VIEW(rd->listview)); | |
1811 row = file_util_rename_multiple_find_row(rd, rd->fd->source_path, &iter); | |
1812 | |
1813 if (row >= 0 && | |
1814 (gtk_tree_model_iter_nth_child(store, &next, NULL, row + 1) || | |
1815 (row > 0 && gtk_tree_model_iter_nth_child(store, &next, NULL, row - 1)) ) ) | |
1 | 1816 { |
9 | 1817 GtkTreeSelection *selection; |
1818 | |
1819 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(rd->listview)); | |
1820 gtk_tree_selection_select_iter(selection, &next); | |
1821 gtk_list_store_remove(GTK_LIST_STORE(store), &iter); | |
1 | 1822 } |
1823 else | |
1824 { | |
9 | 1825 if (debug) printf("closed by #%d\n", row); |
1826 | |
1827 file_dialog_close(rd->fd); | |
1 | 1828 } |
1829 } | |
1830 } | |
1831 } | |
1832 | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1833 /* format: * = filename without extension, ## = number position, extension is kept */ |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1834 static gchar *file_util_rename_multiple_auto_format_name(const gchar *format, const gchar *name, gint n) |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1835 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1836 gchar *new_name; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1837 gchar *parsed; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1838 const gchar *ext; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1839 gchar *middle; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1840 gchar *tmp; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1841 gchar *pad_start; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1842 gchar *pad_end; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1843 gint padding; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1844 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1845 if (!format || !name) return NULL; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1846 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1847 tmp = g_strdup(format); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1848 pad_start = strchr(tmp, '#'); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1849 if (pad_start) |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1850 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1851 pad_end = pad_start; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1852 padding = 0; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1853 while (*pad_end == '#') |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1854 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1855 pad_end++; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1856 padding++; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1857 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1858 *pad_start = '\0'; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1859 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1860 parsed = g_strdup_printf("%s%0*d%s", tmp, padding, n, pad_end); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1861 g_free(tmp); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1862 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1863 else |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1864 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1865 parsed = tmp; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1866 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1867 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1868 ext = extension_from_path(name); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1869 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1870 middle = strchr(parsed, '*'); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1871 if (middle) |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1872 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1873 gchar *base; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1874 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1875 *middle = '\0'; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1876 middle++; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1877 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1878 base = remove_extension_from_path(name); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1879 new_name = g_strconcat(parsed, base, middle, ext, NULL); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1880 g_free(base); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1881 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1882 else |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1883 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1884 new_name = g_strconcat(parsed, ext, NULL); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1885 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1886 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1887 g_free(parsed); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1888 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1889 return new_name; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1890 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1891 |
9 | 1892 static void file_util_rename_multiple_auto(RenameDataMult *rd) |
1 | 1893 { |
9 | 1894 const gchar *front; |
1895 const gchar *end; | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1896 const gchar *format; |
9 | 1897 gint start_n; |
1898 gint padding; | |
1899 gint n; | |
1900 GtkTreeModel *store; | |
1901 GtkTreeIter iter; | |
1902 gint valid; | |
1903 gint success; | |
1904 | |
1905 front = gtk_entry_get_text(GTK_ENTRY(rd->auto_entry_front)); | |
1906 end = gtk_entry_get_text(GTK_ENTRY(rd->auto_entry_end)); | |
1907 padding = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(rd->auto_spin_pad)); | |
1908 | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1909 format = gtk_entry_get_text(GTK_ENTRY(rd->format_entry)); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1910 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1911 if (rd->rename_type == RENAME_TYPE_FORMATTED) |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1912 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1913 start_n = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(rd->format_spin)); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1914 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1915 if (!format || |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1916 (strchr(format, '*') == NULL && strchr(format, '#') == NULL)) |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1917 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1918 file_util_warning_dialog(_("Auto rename"), |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1919 _("Format must include at least one of the symbol characters '*' or '#'.\n"), |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1920 GTK_STOCK_DIALOG_WARNING, NULL); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1921 return; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1922 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1923 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1924 history_combo_append_history(rd->format_entry, NULL); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1925 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1926 else |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1927 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1928 start_n = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(rd->auto_spin_start)); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1929 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1930 history_combo_append_history(rd->auto_entry_front, NULL); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1931 history_combo_append_history(rd->auto_entry_end, NULL); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1932 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1933 |
9 | 1934 store = gtk_tree_view_get_model(GTK_TREE_VIEW(rd->listview)); |
1935 | |
1936 /* first check for name conflicts */ | |
1937 success = TRUE; | |
1938 n = start_n; | |
1939 valid = gtk_tree_model_get_iter_first(store, &iter); | |
1940 while (valid && success) | |
1941 { | |
1942 gchar *dest; | |
1943 gchar *base; | |
1944 gchar *path; | |
1945 | |
1946 gtk_tree_model_get(store, &iter, RENAME_COLUMN_PATH, &path, -1); | |
1947 base = remove_level_from_path(path); | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1948 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1949 if (rd->rename_type == RENAME_TYPE_FORMATTED) |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1950 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1951 gchar *new_name; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1952 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1953 new_name = file_util_rename_multiple_auto_format_name(format, filename_from_path(path), n); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1954 dest = g_strconcat(base, "/", new_name, NULL); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1955 g_free(new_name); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1956 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1957 else |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1958 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1959 dest = g_strdup_printf("%s/%s%0*d%s", base, front, padding, n, end); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1960 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1961 |
9 | 1962 if (isname(dest)) success = FALSE; |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1963 |
9 | 1964 g_free(dest); |
1965 g_free(base); | |
1966 g_free(path); | |
1967 | |
1968 n++; | |
1969 valid = gtk_tree_model_iter_next(store, &iter); | |
1970 } | |
1971 | |
1972 if (!success) | |
1973 { | |
1974 file_util_warning_dialog(_("Auto rename"), | |
1975 _("Can not auto rename with the selected\nnumber set, one or more files exist that\nmatch the resulting name list.\n"), | |
1976 GTK_STOCK_DIALOG_WARNING, NULL); | |
1977 return; | |
1978 } | |
1979 | |
1980 /* select the first iter, so that on fail the correct info is given to user */ | |
1981 if (gtk_tree_model_get_iter_first(store, &iter)) | |
1982 { | |
1983 GtkTreeSelection *selection; | |
1984 | |
1985 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(rd->listview)); | |
1986 gtk_tree_selection_select_iter(selection, &iter); | |
1987 } | |
1988 | |
1989 /* now do it for real */ | |
1990 success = TRUE; | |
1991 n = start_n; | |
1992 while (success && gtk_tree_model_get_iter_first(store, &iter)) | |
1993 { | |
1994 gchar *dest; | |
1995 gchar *base; | |
1996 gchar *path; | |
1997 | |
1998 gtk_tree_model_get(store, &iter, RENAME_COLUMN_PATH, &path, -1); | |
1999 base = remove_level_from_path(path); | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2000 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2001 if (rd->rename_type == RENAME_TYPE_FORMATTED) |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2002 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2003 gchar *new_name; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2004 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2005 new_name = file_util_rename_multiple_auto_format_name(format, filename_from_path(path), n); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2006 dest = g_strconcat(base, "/", new_name, NULL); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2007 g_free(new_name); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2008 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2009 else |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2010 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2011 dest = g_strdup_printf("%s/%s%0*d%s", base, front, padding, n, end); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2012 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2013 |
136 | 2014 if (!rename_file_ext(path, dest)) |
9 | 2015 { |
2016 success = FALSE; | |
2017 } | |
2018 else | |
2019 { | |
2020 file_maint_renamed(path, dest); | |
2021 } | |
2022 | |
2023 g_free(dest); | |
2024 g_free(base); | |
2025 g_free(path); | |
2026 | |
2027 if (success) | |
2028 { | |
2029 gtk_list_store_remove(GTK_LIST_STORE(store), &iter); | |
2030 if (gtk_tree_model_get_iter_first(store, &iter)) | |
2031 { | |
2032 GtkTreeSelection *selection; | |
2033 | |
2034 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(rd->listview)); | |
2035 gtk_tree_selection_select_iter(selection, &iter); | |
2036 } | |
2037 } | |
2038 | |
2039 n++; | |
2040 } | |
2041 | |
2042 if (!success) | |
2043 { | |
2044 gchar *buf; | |
2045 | |
2046 n--; | |
15
3263965d5f9e
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
2047 gtk_spin_button_set_value(GTK_SPIN_BUTTON(rd->auto_spin_start), (gdouble)n); |
9 | 2048 |
2049 buf = g_strdup_printf(_("Failed to rename\n%s\nThe number was %d."), filename_from_path(rd->fd->source_path), n); | |
2050 file_util_warning_dialog(_("Auto rename"), buf, GTK_STOCK_DIALOG_ERROR, NULL); | |
2051 g_free(buf); | |
2052 | |
2053 return; | |
2054 } | |
2055 | |
2056 file_dialog_close(rd->fd); | |
2057 } | |
2058 | |
2059 static void file_util_rename_multiple_cb(FileDialog *fd, gpointer data) | |
2060 { | |
2061 RenameDataMult *rd = data; | |
1 | 2062 gchar *base; |
9 | 2063 const gchar *name; |
2064 | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2065 if (rd->rename_type != RENAME_TYPE_MANUAL) |
9 | 2066 { |
2067 file_util_rename_multiple_auto(rd); | |
2068 return; | |
2069 } | |
2070 | |
2071 name = gtk_entry_get_text(GTK_ENTRY(rd->rename_entry)); | |
1 | 2072 base = remove_level_from_path(fd->source_path); |
9 | 2073 |
1 | 2074 g_free(fd->dest_path); |
9 | 2075 fd->dest_path = concat_dir_and_file(base, name); |
1 | 2076 g_free(base); |
2077 | |
2078 if (strlen(name) == 0 || strcmp(fd->source_path, fd->dest_path) == 0) | |
2079 { | |
2080 return; | |
2081 } | |
2082 | |
2083 fd->type = FALSE; | |
9 | 2084 file_util_rename_multiple(rd); |
2085 } | |
2086 | |
2087 static void file_util_rename_multiple_close_cb(FileDialog *fd, gpointer data) | |
2088 { | |
2089 RenameDataMult *rd = data; | |
2090 | |
2091 file_dialog_close(rd->fd); | |
1 | 2092 } |
2093 | |
9 | 2094 static gboolean file_util_rename_multiple_select_cb(GtkTreeSelection *selection, GtkTreeModel *store, GtkTreePath *tpath, |
2095 gboolean path_currently_selected, gpointer data) | |
2096 { | |
2097 RenameDataMult *rd = data; | |
2098 GtkTreeIter iter; | |
2099 const gchar *name; | |
2100 gchar *path = NULL; | |
2101 | |
2102 if (path_currently_selected || | |
2103 !gtk_tree_model_get_iter(store, &iter, tpath)) return TRUE; | |
2104 gtk_tree_model_get(store, &iter, RENAME_COLUMN_PATH, &path, -1); | |
2105 | |
2106 g_free(rd->fd->source_path); | |
2107 rd->fd->source_path = path; | |
2108 | |
2109 name = filename_from_path(rd->fd->source_path); | |
2110 gtk_label_set_text(GTK_LABEL(rd->rename_label), name); | |
2111 gtk_entry_set_text(GTK_ENTRY(rd->rename_entry), name); | |
2112 | |
2113 image_change_path(rd->imd, rd->fd->source_path, 0.0); | |
2114 | |
2115 if (GTK_WIDGET_VISIBLE(rd->rename_box)) | |
2116 { | |
2117 gtk_widget_grab_focus(rd->rename_entry); | |
42
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
2118 gtk_editable_select_region(GTK_EDITABLE(rd->rename_entry), 0, filename_base_length(name)); |
9 | 2119 } |
2120 | |
2121 return TRUE; | |
2122 } | |
2123 | |
2124 static void file_util_rename_multiple_preview_update(RenameDataMult *rd) | |
1 | 2125 { |
9 | 2126 GtkTreeModel *store; |
2127 GtkTreeIter iter; | |
2128 const gchar *front; | |
2129 const gchar *end; | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2130 const gchar *format; |
9 | 2131 gint valid; |
2132 gint start_n; | |
2133 gint padding; | |
2134 gint n; | |
2135 | |
2136 front = gtk_entry_get_text(GTK_ENTRY(rd->auto_entry_front)); | |
2137 end = gtk_entry_get_text(GTK_ENTRY(rd->auto_entry_end)); | |
2138 padding = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(rd->auto_spin_pad)); | |
2139 | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2140 format = gtk_entry_get_text(GTK_ENTRY(rd->format_entry)); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2141 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2142 if (rd->rename_type == RENAME_TYPE_FORMATTED) |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2143 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2144 start_n = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(rd->format_spin)); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2145 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2146 else |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2147 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2148 start_n = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(rd->auto_spin_start)); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2149 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2150 |
9 | 2151 store = gtk_tree_view_get_model(GTK_TREE_VIEW(rd->listview)); |
2152 n = start_n; | |
2153 valid = gtk_tree_model_get_iter_first(store, &iter); | |
2154 while (valid) | |
2155 { | |
2156 gchar *dest; | |
2157 | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2158 if (rd->rename_type == RENAME_TYPE_FORMATTED) |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2159 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2160 gchar *path; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2161 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2162 gtk_tree_model_get(store, &iter, RENAME_COLUMN_PATH, &path, -1); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2163 dest = file_util_rename_multiple_auto_format_name(format, filename_from_path(path), n); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2164 g_free(path); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2165 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2166 else |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2167 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2168 dest = g_strdup_printf("%s%0*d%s", front, padding, n, end); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2169 } |
9 | 2170 gtk_list_store_set(GTK_LIST_STORE(store), &iter, RENAME_COLUMN_PREVIEW, dest, -1); |
2171 g_free(dest); | |
2172 | |
2173 n++; | |
2174 valid = gtk_tree_model_iter_next(store, &iter); | |
2175 } | |
2176 | |
1 | 2177 } |
2178 | |
9 | 2179 static gboolean file_util_rename_multiple_idle_cb(gpointer data) |
2180 { | |
2181 RenameDataMult *rd = data; | |
2182 | |
2183 file_util_rename_multiple_preview_update(rd); | |
2184 | |
2185 rd->update_idle_id = -1; | |
2186 return FALSE; | |
2187 } | |
2188 | |
2189 static void file_util_rename_multiple_preview_order_cb(GtkTreeModel *treemodel, GtkTreePath *tpath, | |
2190 GtkTreeIter *iter, gpointer data) | |
2191 { | |
2192 RenameDataMult *rd = data; | |
2193 | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2194 if (rd->rename_type != RENAME_TYPE_MANUAL && rd->update_idle_id == -1) |
9 | 2195 { |
2196 rd->update_idle_id = g_idle_add(file_util_rename_multiple_idle_cb, rd); | |
2197 } | |
2198 } | |
2199 | |
2200 static void file_util_rename_multiple_preview_entry_cb(GtkWidget *entry, gpointer data) | |
2201 { | |
2202 RenameDataMult *rd = data; | |
2203 file_util_rename_multiple_preview_update(rd); | |
2204 } | |
2205 | |
2206 static void file_util_rename_multiple_preview_adj_cb(GtkWidget *spin, gpointer data) | |
2207 { | |
2208 RenameDataMult *rd = data; | |
2209 file_util_rename_multiple_preview_update(rd); | |
2210 } | |
2211 | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2212 static void file_util_rename_multiple_auto_change(GtkWidget *widget, gpointer data) |
1 | 2213 { |
9 | 2214 RenameDataMult *rd = data; |
2215 GtkTreeViewColumn *column; | |
2216 | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2217 rd->rename_type = gtk_combo_box_get_active(GTK_COMBO_BOX(rd->combo_type)); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2218 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2219 switch (rd->rename_type) |
9 | 2220 { |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2221 case RENAME_TYPE_FORMATTED: |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2222 if (GTK_WIDGET_VISIBLE(rd->rename_box)) gtk_widget_hide(rd->rename_box); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2223 if (GTK_WIDGET_VISIBLE(rd->auto_box)) gtk_widget_hide(rd->auto_box); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2224 if (!GTK_WIDGET_VISIBLE(rd->format_box)) gtk_widget_show(rd->format_box); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2225 file_util_rename_multiple_preview_update(rd); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2226 break; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2227 case RENAME_TYPE_AUTO: |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2228 if (GTK_WIDGET_VISIBLE(rd->format_box)) gtk_widget_hide(rd->format_box); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2229 if (GTK_WIDGET_VISIBLE(rd->rename_box)) gtk_widget_hide(rd->rename_box); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2230 if (!GTK_WIDGET_VISIBLE(rd->auto_box)) gtk_widget_show(rd->auto_box); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2231 file_util_rename_multiple_preview_update(rd); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2232 break; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2233 case RENAME_TYPE_MANUAL: |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2234 default: |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2235 if (GTK_WIDGET_VISIBLE(rd->format_box)) gtk_widget_hide(rd->format_box); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2236 if (GTK_WIDGET_VISIBLE(rd->auto_box)) gtk_widget_hide(rd->auto_box); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2237 if (!GTK_WIDGET_VISIBLE(rd->rename_box)) gtk_widget_show(rd->rename_box); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2238 break; |
9 | 2239 } |
2240 | |
2241 column = gtk_tree_view_get_column(GTK_TREE_VIEW(rd->listview), RENAME_COLUMN_PREVIEW - 1); | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2242 gtk_tree_view_column_set_visible(column, (rd->rename_type != RENAME_TYPE_MANUAL)); |
9 | 2243 } |
2244 | |
2245 static GtkWidget *furm_simple_vlabel(GtkWidget *box, const gchar *text, gint expand) | |
2246 { | |
2247 GtkWidget *vbox; | |
2248 GtkWidget *label; | |
2249 | |
2250 vbox = gtk_vbox_new(FALSE, 0); | |
2251 gtk_box_pack_start(GTK_BOX(box), vbox, expand, expand, 0); | |
2252 gtk_widget_show(vbox); | |
2253 | |
2254 label = gtk_label_new(text); | |
2255 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
2256 gtk_widget_show(label); | |
2257 | |
2258 return vbox; | |
2259 } | |
2260 | |
2261 static GtkTreeViewColumn *file_util_rename_multiple_add_column(RenameDataMult *rd, const gchar *text, gint n) | |
2262 { | |
2263 GtkTreeViewColumn *column; | |
2264 GtkCellRenderer *renderer; | |
2265 | |
2266 column = gtk_tree_view_column_new(); | |
2267 gtk_tree_view_column_set_title(column, text); | |
2268 gtk_tree_view_column_set_min_width(column, 4); | |
2269 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY); | |
2270 renderer = gtk_cell_renderer_text_new(); | |
2271 gtk_tree_view_column_pack_start(column, renderer, TRUE); | |
2272 gtk_tree_view_column_add_attribute(column, renderer, "text", n); | |
2273 gtk_tree_view_append_column(GTK_TREE_VIEW(rd->listview), column); | |
2274 | |
2275 return column; | |
2276 } | |
2277 | |
2278 static void file_util_rename_multiple_destroy_cb(GtkWidget *widget, gpointer data) | |
2279 { | |
2280 RenameDataMult *rd = data; | |
2281 | |
2282 if (rd->update_idle_id != -1) g_source_remove(rd->update_idle_id); | |
2283 | |
2284 g_free(rd); | |
2285 } | |
2286 | |
2287 static void file_util_rename_multiple_do(GList *source_list, GtkWidget *parent) | |
2288 { | |
2289 RenameDataMult *rd; | |
2290 GtkWidget *pane; | |
1 | 2291 GtkWidget *scrolled; |
9 | 2292 GtkListStore *store; |
2293 GtkTreeSelection *selection; | |
2294 GtkTreeViewColumn *column; | |
2295 GtkWidget *hbox; | |
2296 GtkWidget *vbox; | |
2297 GtkWidget *box2; | |
2298 GtkWidget *table; | |
2299 GtkWidget *combo; | |
1 | 2300 GList *work; |
42
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
2301 const gchar *name; |
1 | 2302 |
9 | 2303 rd = g_new0(RenameDataMult, 1); |
2304 | |
2305 rd->fd = file_util_file_dlg(_("Rename - GQview"), | |
2306 "GQview", "dlg_rename", parent, | |
2307 file_util_rename_multiple_close_cb, rd); | |
2308 generic_dialog_add_message(GENERIC_DIALOG(rd->fd), NULL, _("Rename multiple files"), NULL); | |
2309 file_dialog_add_button(rd->fd, GTK_STOCK_OK, _("_Rename"), file_util_rename_multiple_cb, TRUE); | |
2310 | |
2311 rd->fd->source_path = g_strdup(source_list->data); | |
2312 rd->fd->dest_path = NULL; | |
2313 | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2314 rd->rename_type = RENAME_TYPE_MANUAL; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2315 |
9 | 2316 rd->update_idle_id = -1; |
2317 | |
2318 vbox = GENERIC_DIALOG(rd->fd)->vbox; | |
2319 | |
2320 pane = gtk_hpaned_new(); | |
2321 gtk_box_pack_start(GTK_BOX(vbox), pane, TRUE, TRUE, 0); | |
2322 gtk_widget_show(pane); | |
2323 | |
1 | 2324 scrolled = gtk_scrolled_window_new(NULL, NULL); |
9 | 2325 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN); |
2326 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scrolled), | |
2327 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
2328 gtk_paned_pack1(GTK_PANED(pane), scrolled, TRUE, TRUE); | |
1 | 2329 gtk_widget_show(scrolled); |
2330 | |
9 | 2331 store = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); |
2332 rd->listview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); | |
2333 g_object_unref(store); | |
2334 | |
2335 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(rd->listview), TRUE); | |
2336 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(rd->listview), FALSE); | |
2337 | |
2338 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(rd->listview)); | |
2339 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_SINGLE); | |
2340 gtk_tree_selection_set_select_function(selection, file_util_rename_multiple_select_cb, rd, NULL); | |
2341 | |
2342 file_util_rename_multiple_add_column(rd, _("Original Name"), RENAME_COLUMN_NAME); | |
2343 column = file_util_rename_multiple_add_column(rd, _("Preview"), RENAME_COLUMN_PREVIEW); | |
2344 gtk_tree_view_column_set_visible(column, FALSE); | |
2345 | |
2346 gtk_tree_view_set_reorderable(GTK_TREE_VIEW(rd->listview), TRUE); | |
2347 g_signal_connect(G_OBJECT(store), "row_changed", | |
2348 G_CALLBACK(file_util_rename_multiple_preview_order_cb), rd); | |
2349 gtk_widget_set_size_request(rd->listview, 250, 150); | |
2350 | |
2351 gtk_container_add(GTK_CONTAINER(scrolled), rd->listview); | |
2352 gtk_widget_show(rd->listview); | |
1 | 2353 |
2354 work = source_list; | |
9 | 2355 while (work) |
1 | 2356 { |
9 | 2357 gchar *path = work->data; |
2358 GtkTreeIter iter; | |
2359 | |
2360 gtk_list_store_append(store, &iter); | |
2361 gtk_list_store_set(store, &iter, RENAME_COLUMN_PATH, path, RENAME_COLUMN_NAME, filename_from_path(path), -1); | |
2362 | |
1 | 2363 work = work->next; |
2364 } | |
2365 | |
9 | 2366 path_list_free(source_list); |
2367 | |
2368 rd->imd = image_new(TRUE); | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2369 g_object_set(G_OBJECT(rd->imd->pr), "zoom_expand", FALSE, NULL); |
9 | 2370 gtk_widget_set_size_request(rd->imd->widget, DIALOG_DEF_IMAGE_DIM_X, DIALOG_DEF_IMAGE_DIM_Y); |
2371 gtk_paned_pack2(GTK_PANED(pane), rd->imd->widget, FALSE, TRUE); | |
2372 gtk_widget_show(rd->imd->widget); | |
2373 | |
2374 hbox = gtk_hbox_new(FALSE, 0); | |
2375 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | |
2376 gtk_widget_show(hbox); | |
2377 | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2378 rd->combo_type = gtk_combo_box_new_text(); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2379 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2380 gtk_combo_box_append_text(GTK_COMBO_BOX(rd->combo_type), _("Manual rename")); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2381 gtk_combo_box_append_text(GTK_COMBO_BOX(rd->combo_type), _("Formatted rename")); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2382 gtk_combo_box_append_text(GTK_COMBO_BOX(rd->combo_type), _("Auto rename")); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2383 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2384 gtk_combo_box_set_active(GTK_COMBO_BOX(rd->combo_type), rd->rename_type); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2385 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2386 g_signal_connect(G_OBJECT(rd->combo_type), "changed", |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2387 G_CALLBACK(file_util_rename_multiple_auto_change), rd); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2388 gtk_box_pack_end(GTK_BOX(hbox), rd->combo_type, FALSE, FALSE, 0); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2389 gtk_widget_show(rd->combo_type); |
9 | 2390 |
2391 rd->rename_box = pref_box_new(vbox, FALSE, GTK_ORIENTATION_VERTICAL, 0); | |
2392 table = pref_table_new(rd->rename_box, 2, 2, FALSE, FALSE); | |
2393 | |
2394 pref_table_label(table, 0, 0, _("Original name:"), 1.0); | |
2395 rd->rename_label = pref_table_label(table, 1, 0, filename_from_path(rd->fd->source_path), 0.0); | |
2396 | |
2397 pref_table_label(table, 0, 1, _("New name:"), 1.0); | |
2398 | |
2399 rd->rename_entry = gtk_entry_new(); | |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
112
diff
changeset
|
2400 gtk_table_attach(GTK_TABLE(table), rd->rename_entry, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0); |
9 | 2401 generic_dialog_attach_default(GENERIC_DIALOG(rd->fd), rd->rename_entry); |
2402 gtk_widget_grab_focus(rd->rename_entry); | |
42
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
2403 |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
2404 name = filename_from_path(rd->fd->source_path); |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
2405 gtk_entry_set_text(GTK_ENTRY(rd->rename_entry), name); |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
2406 gtk_editable_select_region(GTK_EDITABLE(rd->rename_entry), 0, filename_base_length(name)); |
9 | 2407 gtk_widget_show(rd->rename_entry); |
2408 | |
2409 rd->auto_box = gtk_vbox_new(FALSE, PREF_PAD_GAP); | |
2410 gtk_box_pack_start(GTK_BOX(vbox), rd->auto_box, FALSE, FALSE, 0); | |
2411 /* do not show it here */ | |
2412 | |
2413 hbox = pref_box_new(rd->auto_box, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_GAP); | |
2414 | |
2415 box2 = furm_simple_vlabel(hbox, _("Begin text"), TRUE); | |
2416 | |
2417 combo = history_combo_new(&rd->auto_entry_front, "", "numerical_rename_prefix", -1); | |
2418 g_signal_connect(G_OBJECT(rd->auto_entry_front), "changed", | |
2419 G_CALLBACK(file_util_rename_multiple_preview_entry_cb), rd); | |
2420 gtk_box_pack_start(GTK_BOX(box2), combo, TRUE, TRUE, 0); | |
2421 gtk_widget_show(combo); | |
2422 | |
2423 box2 = furm_simple_vlabel(hbox, _("Start #"), FALSE); | |
2424 | |
2425 rd->auto_spin_start = pref_spin_new(box2, NULL, NULL, | |
80
a10fc0308c12
Thu Oct 19 07:42:38 2006 John Ellis <johne@verizon.net>
gqview
parents:
71
diff
changeset
|
2426 0.0, 1000000.0, 1.0, 0, 1.0, |
9 | 2427 G_CALLBACK(file_util_rename_multiple_preview_adj_cb), rd); |
2428 | |
2429 box2 = furm_simple_vlabel(hbox, _("End text"), TRUE); | |
2430 | |
2431 combo = history_combo_new(&rd->auto_entry_end, "", "numerical_rename_suffix", -1); | |
2432 g_signal_connect(G_OBJECT(rd->auto_entry_end), "changed", | |
2433 G_CALLBACK(file_util_rename_multiple_preview_entry_cb), rd); | |
2434 gtk_box_pack_start(GTK_BOX(box2), combo, TRUE, TRUE, 0); | |
2435 gtk_widget_show(combo); | |
2436 | |
2437 rd->auto_spin_pad = pref_spin_new(rd->auto_box, _("Padding:"), NULL, | |
2438 1.0, 8.0, 1.0, 0, 1.0, | |
2439 G_CALLBACK(file_util_rename_multiple_preview_adj_cb), rd); | |
2440 | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2441 rd->format_box = gtk_vbox_new(FALSE, PREF_PAD_GAP); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2442 gtk_box_pack_start(GTK_BOX(vbox), rd->format_box, FALSE, FALSE, 0); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2443 /* do not show it here */ |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2444 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2445 hbox = pref_box_new(rd->format_box, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_GAP); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2446 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2447 box2 = furm_simple_vlabel(hbox, _("Format (* = original name, ## = numbers)"), TRUE); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2448 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2449 combo = history_combo_new(&rd->format_entry, "", "auto_rename_format", -1); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2450 g_signal_connect(G_OBJECT(rd->format_entry), "changed", |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2451 G_CALLBACK(file_util_rename_multiple_preview_entry_cb), rd); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2452 gtk_box_pack_start(GTK_BOX(box2), combo, TRUE, TRUE, 0); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2453 gtk_widget_show(combo); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2454 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2455 box2 = furm_simple_vlabel(hbox, _("Start #"), FALSE); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2456 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2457 rd->format_spin = pref_spin_new(box2, NULL, NULL, |
80
a10fc0308c12
Thu Oct 19 07:42:38 2006 John Ellis <johne@verizon.net>
gqview
parents:
71
diff
changeset
|
2458 0.0, 1000000.0, 1.0, 0, 1.0, |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2459 G_CALLBACK(file_util_rename_multiple_preview_adj_cb), rd); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2460 |
9 | 2461 image_change_path(rd->imd, rd->fd->source_path, 0.0); |
2462 | |
2463 g_signal_connect(G_OBJECT(GENERIC_DIALOG(rd->fd)->dialog), "destroy", | |
2464 G_CALLBACK(file_util_rename_multiple_destroy_cb), rd); | |
2465 | |
2466 gtk_widget_show(GENERIC_DIALOG(rd->fd)->dialog); | |
1 | 2467 } |
2468 | |
2469 /* | |
2470 * rename single file | |
2471 */ | |
2472 | |
9 | 2473 static void file_util_rename_single(FileDataSingle *fds); |
2474 | |
2475 static void file_util_rename_single_ok_cb(GenericDialog *gd, gpointer data) | |
1 | 2476 { |
2477 FileDataSingle *fds = data; | |
2478 fds->confirmed = TRUE; | |
2479 file_util_rename_single(fds); | |
2480 } | |
2481 | |
9 | 2482 static void file_util_rename_single_cancel_cb(GenericDialog *gd, gpointer data) |
1 | 2483 { |
2484 FileDataSingle *fds = data; | |
2485 file_data_single_free(fds); | |
2486 } | |
2487 | |
2488 static void file_util_rename_single(FileDataSingle *fds) | |
2489 { | |
2490 if (isfile(fds->dest) && !fds->confirmed) | |
2491 { | |
9 | 2492 GenericDialog *gd; |
2493 | |
2494 gd = file_util_gen_dlg(_("Overwrite file"), "GQview", "dlg_confirm", | |
2495 NULL, TRUE, | |
2496 file_util_rename_single_cancel_cb, fds); | |
2497 | |
2498 generic_dialog_add_message(gd, GTK_STOCK_DIALOG_QUESTION, | |
2499 _("Overwrite file?"), | |
2500 _("Replace existing file by renaming new file.")); | |
2501 pref_spacer(gd->vbox, 0); | |
2502 | |
2503 generic_dialog_add_button(gd, GTK_STOCK_OK, _("_Overwrite"), file_util_rename_single_ok_cb, TRUE); | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2504 generic_dialog_add_image(gd, NULL, |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2505 fds->dest, _("Existing file"), |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2506 fds->source, _("New file"), TRUE); |
9 | 2507 |
2508 gtk_widget_show(gd->dialog); | |
2509 | |
1 | 2510 return; |
2511 } | |
2512 else | |
2513 { | |
136 | 2514 if (!rename_file_ext(fds->source, fds->dest)) |
1 | 2515 { |
2516 gchar *text = g_strdup_printf(_("Unable to rename file:\n%s\nto:\n%s"), filename_from_path(fds->source), filename_from_path(fds->dest)); | |
9 | 2517 file_util_warning_dialog(_("Error renaming file"), text, GTK_STOCK_DIALOG_ERROR, NULL); |
1 | 2518 g_free(text); |
2519 } | |
2520 else | |
2521 { | |
9 | 2522 file_maint_renamed(fds->source, fds->dest); |
1 | 2523 } |
2524 } | |
2525 file_data_single_free(fds); | |
2526 } | |
2527 | |
9 | 2528 static void file_util_rename_single_cb(FileDialog *fd, gpointer data) |
1 | 2529 { |
9 | 2530 const gchar *name; |
2531 gchar *path; | |
2532 | |
2533 name = gtk_entry_get_text(GTK_ENTRY(fd->entry)); | |
2534 path = concat_dir_and_file(fd->dest_path, name); | |
2535 | |
2536 if (strlen(name) == 0 || strcmp(fd->source_path, path) == 0) | |
1 | 2537 { |
9 | 2538 g_free(path); |
1 | 2539 return; |
2540 } | |
2541 | |
9 | 2542 file_util_rename_single(file_data_single_new(fd->source_path, path, fd->type)); |
2543 | |
2544 g_free(path); | |
2545 file_dialog_close(fd); | |
1 | 2546 } |
2547 | |
9 | 2548 static void file_util_rename_single_close_cb(FileDialog *fd, gpointer data) |
2549 { | |
2550 file_dialog_close(fd); | |
2551 } | |
2552 | |
2553 static void file_util_rename_single_do(const gchar *source_path, GtkWidget *parent) | |
1 | 2554 { |
2555 FileDialog *fd; | |
9 | 2556 GtkWidget *table; |
42
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
2557 const gchar *name; |
9 | 2558 |
2559 fd = file_util_file_dlg(_("Rename - GQview"), "GQview", "dlg_rename", parent, | |
2560 file_util_rename_single_close_cb, NULL); | |
2561 | |
2562 generic_dialog_add_message(GENERIC_DIALOG(fd), NULL, _("Rename file"), NULL); | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2563 generic_dialog_add_image(GENERIC_DIALOG(fd), NULL, source_path, NULL, NULL, NULL, FALSE); |
9 | 2564 |
2565 file_dialog_add_button(fd, GTK_STOCK_OK, _("_Rename"), file_util_rename_single_cb, TRUE); | |
1 | 2566 |
2567 fd->source_path = g_strdup(source_path); | |
2568 fd->dest_path = remove_level_from_path(source_path); | |
2569 | |
9 | 2570 table = pref_table_new(GENERIC_DIALOG(fd)->vbox, 2, 2, FALSE, FALSE); |
2571 | |
2572 pref_table_label(table, 0, 0, _("Original name:"), 1.0); | |
2573 pref_table_label(table, 1, 0, filename_from_path(fd->source_path), 0.0); | |
2574 | |
2575 pref_table_label(table, 0, 1, _("New name:"), 1.0); | |
2576 | |
1 | 2577 fd->entry = gtk_entry_new(); |
115
53b2bfdcff69
Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents:
112
diff
changeset
|
2578 gtk_table_attach(GTK_TABLE(table), fd->entry, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0); |
9 | 2579 generic_dialog_attach_default(GENERIC_DIALOG(fd), fd->entry); |
1 | 2580 gtk_widget_grab_focus(fd->entry); |
42
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
2581 |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
2582 name = filename_from_path(fd->source_path); |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
2583 gtk_entry_set_text(GTK_ENTRY(fd->entry), name); |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
2584 gtk_editable_select_region(GTK_EDITABLE(fd->entry), 0, filename_base_length(name)); |
1 | 2585 gtk_widget_show(fd->entry); |
9 | 2586 |
2587 gtk_widget_show(GENERIC_DIALOG(fd)->dialog); | |
1 | 2588 } |
2589 | |
9 | 2590 void file_util_rename(const gchar *source_path, GList *source_list, GtkWidget *parent) |
1 | 2591 { |
2592 if (!source_path && !source_list) return; | |
2593 | |
2594 if (source_path) | |
2595 { | |
9 | 2596 file_util_rename_single_do(source_path, parent); |
1 | 2597 } |
2598 else if (!source_list->next) | |
2599 { | |
9 | 2600 file_util_rename_single_do(source_list->data, parent); |
2601 path_list_free(source_list); | |
1 | 2602 } |
2603 else | |
2604 { | |
9 | 2605 file_util_rename_multiple_do(source_list, parent); |
1 | 2606 } |
2607 } | |
2608 | |
2609 /* | |
2610 *-------------------------------------------------------------------------- | |
2611 * Create directory routines | |
2612 *-------------------------------------------------------------------------- | |
2613 */ | |
2614 | |
9 | 2615 static void file_util_create_dir_do(const gchar *base, const gchar *name) |
1 | 2616 { |
9 | 2617 gchar *path; |
2618 | |
2619 path = concat_dir_and_file(base, name); | |
2620 | |
2621 if (isdir(path)) | |
1 | 2622 { |
9 | 2623 gchar *text = g_strdup_printf(_("The folder:\n%s\nalready exists."), name); |
2624 file_util_warning_dialog(_("Folder exists"), text, GTK_STOCK_DIALOG_INFO, NULL); | |
1 | 2625 g_free(text); |
2626 } | |
9 | 2627 else if (isname(path)) |
1 | 2628 { |
9 | 2629 gchar *text = g_strdup_printf(_("The path:\n%s\nalready exists as a file."), name); |
2630 file_util_warning_dialog(_("Could not create folder"), text, GTK_STOCK_DIALOG_INFO, NULL); | |
1 | 2631 g_free(text); |
2632 } | |
2633 else | |
2634 { | |
9 | 2635 if (!mkdir_utf8(path, 0755)) |
1 | 2636 { |
9 | 2637 gchar *text = g_strdup_printf(_("Unable to create folder:\n%s"), name); |
2638 file_util_warning_dialog(_("Error creating folder"), text, GTK_STOCK_DIALOG_ERROR, NULL); | |
1 | 2639 g_free(text); |
2640 } | |
2641 } | |
9 | 2642 |
2643 g_free(path); | |
1 | 2644 } |
2645 | |
9 | 2646 static void file_util_create_dir_cb(FileDialog *fd, gpointer data) |
1 | 2647 { |
9 | 2648 const gchar *name; |
2649 | |
2650 name = gtk_entry_get_text(GTK_ENTRY(fd->entry)); | |
1 | 2651 |
2652 if (strlen(name) == 0) return; | |
2653 | |
9 | 2654 if (name[0] == '/') |
2655 { | |
2656 gchar *buf; | |
2657 buf = remove_level_from_path(name); | |
2658 file_util_create_dir_do(buf, filename_from_path(name)); | |
2659 g_free(buf); | |
2660 } | |
2661 else | |
2662 { | |
2663 file_util_create_dir_do(fd->dest_path, name); | |
2664 } | |
2665 | |
2666 file_dialog_close(fd); | |
1 | 2667 } |
2668 | |
9 | 2669 static void file_util_create_dir_close_cb(FileDialog *fd, gpointer data) |
2670 { | |
2671 file_dialog_close(fd); | |
2672 } | |
2673 | |
2674 void file_util_create_dir(const gchar *path, GtkWidget *parent) | |
1 | 2675 { |
2676 FileDialog *fd; | |
2677 gchar *text; | |
2678 | |
2679 if (!isdir(path)) return; | |
9 | 2680 |
2681 fd = file_util_file_dlg(_("New folder - GQview"), "GQview", "dlg_newdir", parent, | |
2682 file_util_create_dir_close_cb, NULL); | |
2683 | |
2684 text = g_strdup_printf(_("Create folder in:\n%s\nnamed:"), path); | |
2685 generic_dialog_add_message(GENERIC_DIALOG(fd), NULL, NULL, text); | |
1 | 2686 g_free(text); |
2687 | |
9 | 2688 file_dialog_add_button(fd, GTK_STOCK_OK, NULL, file_util_create_dir_cb, TRUE); |
2689 | |
2690 fd->dest_path = g_strdup(path); | |
1 | 2691 |
2692 fd->entry = gtk_entry_new(); | |
9 | 2693 gtk_box_pack_start(GTK_BOX(GENERIC_DIALOG(fd)->vbox), fd->entry, FALSE, FALSE, 0); |
2694 generic_dialog_attach_default(GENERIC_DIALOG(fd), fd->entry); | |
1 | 2695 gtk_widget_grab_focus(fd->entry); |
2696 gtk_widget_show(fd->entry); | |
9 | 2697 |
2698 gtk_widget_show(GENERIC_DIALOG(fd)->dialog); | |
1 | 2699 } |
2700 | |
44
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2701 gint file_util_rename_dir(const gchar *old_path, const gchar *new_path, GtkWidget *parent) |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2702 { |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2703 const gchar *old_name; |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2704 const gchar *new_name; |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2705 |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2706 if (!old_path || !new_path || !isdir(old_path)) return FALSE; |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2707 |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2708 old_name = filename_from_path(old_path); |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2709 new_name = filename_from_path(new_path); |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2710 |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2711 if (isdir(new_path)) |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2712 { |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2713 gchar *text = g_strdup_printf(_("The folder:\n%s\nalready exists."), new_name); |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2714 file_util_warning_dialog(_("Folder exists"), text, GTK_STOCK_DIALOG_INFO, parent); |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2715 g_free(text); |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2716 |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2717 return FALSE; |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2718 } |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2719 |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2720 if (isname(new_path)) |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2721 { |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2722 gchar *text = g_strdup_printf(_("The path:\n%s\nalready exists as a file."), new_name); |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2723 file_util_warning_dialog(_("Rename failed"), text, GTK_STOCK_DIALOG_INFO,parent); |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2724 g_free(text); |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2725 |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2726 return FALSE; |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2727 } |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2728 |
136 | 2729 if (!rename_file_ext(old_path, new_path)) |
44
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2730 { |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2731 gchar *text = g_strdup_printf(_("Failed to rename %s to %s."), old_name, new_name); |
71
7425cb0aeb03
Sat Oct 14 05:18:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
67
diff
changeset
|
2732 file_util_warning_dialog(_("Rename failed"), text, GTK_STOCK_DIALOG_ERROR, parent); |
44
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2733 g_free(text); |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2734 |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2735 return FALSE; |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2736 } |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2737 |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2738 return TRUE; |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2739 } |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2740 |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2741 /* |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2742 *-------------------------------------------------------------------------- |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2743 * Delete directory routines |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2744 *-------------------------------------------------------------------------- |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2745 */ |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2746 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2747 /* The plan is to eventually make all of utilops.c |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2748 * use UtilityData and UtilityType. |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2749 * And clean up the above mess someday. |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2750 */ |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2751 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2752 typedef enum { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2753 UTILITY_TYPE_NONE = 0, |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2754 UTILITY_TYPE_COPY, |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2755 UTILITY_TYPE_MOVE, |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2756 UTILITY_TYPE_RENAME, |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2757 UTILITY_TYPE_DELETE, |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2758 UTILITY_TYPE_DELETE_LINK, |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2759 UTILITY_TYPE_DELETE_FOLDER |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2760 } UtilityType; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2761 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2762 typedef struct _UtilityData UtilityData; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2763 struct _UtilityData { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2764 UtilityType type; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2765 gchar *source_path; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2766 GList *dlist; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2767 GList *flist; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2768 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2769 GenericDialog *gd; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2770 }; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2771 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2772 #define UTILITY_LIST_MIN_WIDTH 250 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2773 #define UTILITY_LIST_MIN_HEIGHT 150 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2774 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2775 /* thumbnail spec has a max depth of 4 (.thumb??/fail/appname/??.png) */ |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2776 #define UTILITY_DELETE_MAX_DEPTH 5 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2777 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2778 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2779 static void file_util_data_free(UtilityData *ud) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2780 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2781 if (!ud) return; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2782 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2783 g_free(ud->source_path); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2784 path_list_free(ud->dlist); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2785 path_list_free(ud->flist); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2786 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2787 if (ud->gd) generic_dialog_close(ud->gd); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2788 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2789 g_free(ud); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2790 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2791 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2792 static GtkTreeViewColumn *file_util_dialog_add_list_column(GtkWidget *view, const gchar *text, gint n) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2793 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2794 GtkTreeViewColumn *column; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2795 GtkCellRenderer *renderer; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2796 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2797 column = gtk_tree_view_column_new(); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2798 gtk_tree_view_column_set_title(column, text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2799 gtk_tree_view_column_set_min_width(column, 4); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2800 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2801 renderer = gtk_cell_renderer_text_new(); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2802 gtk_tree_view_column_pack_start(column, renderer, TRUE); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2803 gtk_tree_view_column_add_attribute(column, renderer, "text", n); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2804 gtk_tree_view_append_column(GTK_TREE_VIEW(view), column); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2805 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2806 return column; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2807 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2808 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2809 static GtkWidget *file_util_dialog_add_list(GtkWidget *box, GList *list, gint full_paths) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2810 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2811 GtkWidget *scrolled; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2812 GtkWidget *view; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2813 GtkListStore *store; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2814 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2815 scrolled = gtk_scrolled_window_new(NULL, NULL); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2816 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2817 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scrolled), |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2818 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2819 gtk_box_pack_start(GTK_BOX(box), scrolled, TRUE, TRUE, 0); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2820 gtk_widget_show(scrolled); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2821 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2822 store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2823 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2824 g_object_unref(store); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2825 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2826 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), TRUE); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2827 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(view), FALSE); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2828 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2829 if (full_paths) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2830 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2831 file_util_dialog_add_list_column(view, _("Location"), 0); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2832 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2833 else |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2834 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2835 file_util_dialog_add_list_column(view, _("Name"), 1); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2836 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2837 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2838 gtk_widget_set_size_request(view, UTILITY_LIST_MIN_WIDTH, UTILITY_LIST_MIN_HEIGHT); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2839 gtk_container_add(GTK_CONTAINER(scrolled), view); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2840 gtk_widget_show(view); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2841 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2842 while (list) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2843 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2844 gchar *path = list->data; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2845 GtkTreeIter iter; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2846 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2847 gtk_list_store_append(store, &iter); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2848 gtk_list_store_set(store, &iter, 0, path, |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2849 1, filename_from_path(path), -1); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2850 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2851 list = list->next; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2852 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2853 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2854 return view; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2855 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2856 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2857 static gboolean file_util_delete_dir_preview_cb(GtkTreeSelection *selection, GtkTreeModel *store, |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2858 GtkTreePath *tpath, gboolean path_currently_selected, |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2859 gpointer data) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2860 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2861 UtilityData *ud = data; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2862 GtkTreeIter iter; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2863 gchar *path = NULL; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2864 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2865 if (path_currently_selected || |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2866 !gtk_tree_model_get_iter(store, &iter, tpath)) return TRUE; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2867 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2868 gtk_tree_model_get(store, &iter, 0, &path, -1); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2869 generic_dialog_image_set(ud->gd, path); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2870 g_free(path); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2871 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2872 return TRUE; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2873 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2874 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2875 static void file_util_delete_dir_cancel_cb(GenericDialog *gd, gpointer data) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2876 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2877 UtilityData *ud = data; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2878 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2879 ud->gd = NULL; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2880 file_util_data_free(ud); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2881 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2882 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2883 static gchar *file_util_delete_dir_empty_path(const gchar *path, gint real_content, gint level) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2884 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2885 GList *dlist = NULL; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2886 GList *flist = NULL; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2887 GList *work; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2888 gchar *fail = NULL; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2889 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2890 if (debug) printf("deltree into: %s\n", path); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2891 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2892 level++; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2893 if (level > UTILITY_DELETE_MAX_DEPTH) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2894 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2895 printf("folder recursion depth past %d, giving up\n", UTILITY_DELETE_MAX_DEPTH); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2896 return g_strdup(path); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2897 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2898 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2899 if (!path_list_lstat(path, &flist, &dlist)) return g_strdup(path); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2900 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2901 work = dlist; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2902 while (work && !fail) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2903 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2904 gchar *name; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2905 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2906 name = work->data; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2907 work = work->next; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2908 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2909 fail = file_util_delete_dir_empty_path(name, real_content, level); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2910 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2911 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2912 work = flist; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2913 while (work && !fail) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2914 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2915 gchar *name; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2916 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2917 name = work->data; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2918 work = work->next; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2919 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2920 if (debug) printf("deltree child: %s\n", name); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2921 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2922 if (real_content && !islink(name)) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2923 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2924 if (!file_util_unlink(name)) fail = g_strdup(name); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2925 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2926 else |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2927 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2928 if (!unlink_file(name)) fail = g_strdup(name); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2929 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2930 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2931 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2932 path_list_free(dlist); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2933 path_list_free(flist); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2934 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2935 if (!fail && !rmdir_utf8(path)) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2936 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2937 fail = g_strdup(path); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2938 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2939 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2940 if (debug) printf("deltree done: %s\n", path); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2941 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2942 return fail; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2943 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2944 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2945 static void file_util_delete_dir_ok_cb(GenericDialog *gd, gpointer data) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2946 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2947 UtilityData *ud = data; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2948 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2949 ud->gd = NULL; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2950 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2951 if (ud->type == UTILITY_TYPE_DELETE_LINK) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2952 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2953 if (!unlink_file(ud->source_path)) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2954 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2955 gchar *text; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2956 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2957 text = g_strdup_printf("Unable to remove symbolic link:\n %s", ud->source_path); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2958 file_util_warning_dialog(_("Delete failed"), text, |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2959 GTK_STOCK_DIALOG_ERROR, NULL); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2960 g_free(text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2961 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2962 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2963 else |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2964 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2965 gchar *fail = NULL; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2966 GList *work; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2967 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2968 work = ud->dlist; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2969 while (work && !fail) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2970 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2971 gchar *path; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2972 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2973 path = work->data; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2974 work = work->next; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2975 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2976 fail = file_util_delete_dir_empty_path(path, FALSE, 0); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2977 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2978 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2979 work = ud->flist; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2980 while (work && !fail) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2981 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2982 gchar *path; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2983 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2984 path = work->data; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2985 work = work->next; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2986 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2987 if (debug) printf("deltree unlink: %s\n", path); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2988 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2989 if (islink(path)) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2990 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2991 if (!unlink_file(path)) fail = g_strdup(path); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2992 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2993 else |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2994 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2995 if (!file_util_unlink(path)) fail = g_strdup(path); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2996 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2997 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2998 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2999 if (!fail) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3000 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3001 if (!rmdir_utf8(ud->source_path)) fail = g_strdup(ud->source_path); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3002 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3003 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3004 if (fail) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3005 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3006 gchar *text; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3007 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3008 text = g_strdup_printf(_("Unable to delete folder:\n\n%s"), ud->source_path); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3009 gd = file_util_warning_dialog(_("Delete failed"), text, GTK_STOCK_DIALOG_ERROR, NULL); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3010 g_free(text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3011 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3012 if (strcmp(fail, ud->source_path) != 0) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3013 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3014 pref_spacer(gd->vbox, PREF_PAD_GROUP); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3015 text = g_strdup_printf(_("Removal of folder contents failed at this file:\n\n%s"), |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3016 fail); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3017 pref_label_new(gd->vbox, text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3018 g_free(text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3019 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3020 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3021 g_free(fail); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3022 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3023 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3024 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3025 file_util_data_free(ud); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3026 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3027 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3028 static GList *file_util_delete_dir_remaining_folders(GList *dlist) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3029 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3030 GList *rlist = NULL; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3031 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3032 while (dlist) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3033 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3034 gchar *path; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3035 const gchar *name; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3036 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3037 path = dlist->data; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3038 dlist = dlist->next; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3039 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3040 name = filename_from_path(path); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3041 if (!name || |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3042 (strcmp(name, THUMB_FOLDER_GLOBAL) != 0 && |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3043 strcmp(name, THUMB_FOLDER_LOCAL) != 0 && |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3044 strcmp(name, GQVIEW_CACHE_LOCAL_METADATA) != 0) ) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3045 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3046 rlist = g_list_prepend(rlist, path); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3047 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3048 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3049 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3050 return g_list_reverse(rlist); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3051 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3052 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3053 void file_util_delete_dir(const gchar *path, GtkWidget *parent) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3054 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3055 GList *dlist = NULL; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3056 GList *flist = NULL; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3057 GList *rlist; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3058 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3059 if (!isdir(path)) return; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3060 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3061 if (islink(path)) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3062 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3063 UtilityData *ud; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3064 gchar *text; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3065 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3066 ud = g_new0(UtilityData, 1); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3067 ud->type = UTILITY_TYPE_DELETE_LINK; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3068 ud->source_path = g_strdup(path); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3069 ud->dlist = NULL; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3070 ud->flist = NULL; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3071 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3072 ud->gd = file_util_gen_dlg(_("Delete folder"), "GQview", "dlg_confirm", |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3073 parent, TRUE, |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3074 file_util_delete_dir_cancel_cb, ud); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3075 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3076 text = g_strdup_printf(_("This will delete the symbolic link:\n\n%s\n\n" |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3077 "The folder this link points to will not be deleted."), |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3078 path); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3079 generic_dialog_add_message(ud->gd, GTK_STOCK_DIALOG_QUESTION, |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3080 _("Delete symbolic link to folder?"), |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3081 text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3082 g_free(text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3083 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3084 generic_dialog_add_button(ud->gd, GTK_STOCK_DELETE, NULL, file_util_delete_dir_ok_cb, TRUE); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3085 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3086 gtk_widget_show(ud->gd->dialog); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3087 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3088 return; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3089 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3090 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3091 if (!access_file(path, W_OK | X_OK)) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3092 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3093 gchar *text; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3094 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3095 text = g_strdup_printf(_("Unable to remove folder %s\n" |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3096 "Permissions do not allow writing to the folder."), path); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3097 file_util_warning_dialog(_("Delete failed"), text, GTK_STOCK_DIALOG_ERROR, parent); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3098 g_free(text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3099 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3100 return; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3101 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3102 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3103 if (!path_list_lstat(path, &flist, &dlist)) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3104 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3105 gchar *text; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3106 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3107 text = g_strdup_printf(_("Unable to list contents of folder %s"), path); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3108 file_util_warning_dialog(_("Delete failed"), text, GTK_STOCK_DIALOG_ERROR, parent); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3109 g_free(text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3110 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3111 return; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3112 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3113 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3114 rlist = file_util_delete_dir_remaining_folders(dlist); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3115 if (rlist) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3116 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3117 GenericDialog *gd; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3118 GtkWidget *box; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3119 gchar *text; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3120 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3121 gd = file_util_gen_dlg(_("Folder contains subfolders"), "GQview", "dlg_warning", |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3122 parent, TRUE, NULL, NULL); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3123 generic_dialog_add_button(gd, GTK_STOCK_CLOSE, NULL, NULL, TRUE); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3124 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3125 text = g_strdup_printf(_("Unable to delete the folder:\n\n%s\n\n" |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3126 "This folder contains subfolders which must be moved before it can be deleted."), |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3127 path); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3128 box = generic_dialog_add_message(gd, GTK_STOCK_DIALOG_WARNING, |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3129 _("Folder contains subfolders"), |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3130 text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3131 g_free(text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3132 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3133 box = pref_group_new(box, TRUE, _("Subfolders:"), GTK_ORIENTATION_VERTICAL); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3134 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3135 rlist = path_list_sort(rlist); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3136 file_util_dialog_add_list(box, rlist, FALSE); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3137 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3138 gtk_widget_show(gd->dialog); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3139 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3140 else |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3141 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3142 UtilityData *ud; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3143 GtkWidget *box; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3144 GtkWidget *view; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3145 GtkTreeSelection *selection; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3146 gchar *text; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3147 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3148 ud = g_new0(UtilityData, 1); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3149 ud->type = UTILITY_TYPE_DELETE_FOLDER; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3150 ud->source_path = g_strdup(path); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3151 ud->dlist = dlist; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3152 dlist = NULL; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3153 ud->flist = path_list_sort(flist); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3154 flist = NULL; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3155 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3156 ud->gd = file_util_gen_dlg(_("Delete folder"), "GQview", "dlg_confirm", |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3157 parent, TRUE, file_util_delete_dir_cancel_cb, ud); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3158 generic_dialog_add_button(ud->gd, GTK_STOCK_DELETE, NULL, file_util_delete_dir_ok_cb, TRUE); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3159 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3160 text = g_strdup_printf(_("This will delete the folder:\n\n%s\n\n" |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3161 "The contents of this folder will also be deleted."), |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3162 path); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3163 box = generic_dialog_add_message(ud->gd, GTK_STOCK_DIALOG_QUESTION, |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3164 _("Delete folder?"), |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3165 text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3166 g_free(text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3167 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3168 box = pref_group_new(box, TRUE, _("Contents:"), GTK_ORIENTATION_HORIZONTAL); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3169 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3170 view = file_util_dialog_add_list(box, ud->flist, FALSE); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3171 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view)); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3172 gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3173 gtk_tree_selection_set_select_function(selection, file_util_delete_dir_preview_cb, ud, NULL); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3174 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3175 generic_dialog_add_image(ud->gd, box, NULL, NULL, NULL, NULL, FALSE); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3176 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3177 box_append_safe_delete_status(ud->gd); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3178 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3179 gtk_widget_show(ud->gd->dialog); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3180 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3181 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3182 g_list_free(rlist); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3183 path_list_free(dlist); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3184 path_list_free(flist); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3185 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3186 |