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