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