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