Mercurial > geeqie
annotate src/utilops.c @ 730:2d8a8e892b5e
Use a struct to handle editor's properties.
author | zas_ |
---|---|
date | Thu, 22 May 2008 08:49:52 +0000 |
parents | a1dcef8cd1ae |
children | 477f48ba28d8 |
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); |
730 | 366 if (options->editor[CMD_COPY].command) |
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); |
730 | 414 if (options->editor[CMD_MOVE].command) |
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); |
730 | 461 if (options->editor[CMD_RENAME].command) |
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 | |
726 | 1112 if (!fdlg->dest_path || fdlg->dest_path[0] != G_DIR_SEPARATOR) |
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 |
730 | 1456 if (options->editor[CMD_DELETE].command) |
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 |
730 | 1686 if (options->editor[CMD_DELETE].command) |
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); |
723 | 2068 dest = g_build_filename(base, new_name, NULL); |
66
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 { |
723 | 2073 gchar *new_name; |
2074 | |
2075 new_name = g_strdup_printf("%s%0*d%s", front, padding, n, end); | |
2076 dest = g_build_filename(base, new_name, NULL); | |
2077 g_free(new_name); | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2078 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2079 |
9 | 2080 if (isname(dest)) success = FALSE; |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2081 |
9 | 2082 g_free(dest); |
2083 g_free(base); | |
138 | 2084 // file_data_unref(fd); |
9 | 2085 |
2086 n++; | |
2087 valid = gtk_tree_model_iter_next(store, &iter); | |
2088 } | |
2089 | |
2090 if (!success) | |
2091 { | |
2092 file_util_warning_dialog(_("Auto rename"), | |
2093 _("Can not auto rename with the selected\nnumber set, one or more files exist that\nmatch the resulting name list.\n"), | |
2094 GTK_STOCK_DIALOG_WARNING, NULL); | |
2095 return; | |
2096 } | |
2097 | |
2098 /* select the first iter, so that on fail the correct info is given to user */ | |
2099 if (gtk_tree_model_get_iter_first(store, &iter)) | |
2100 { | |
2101 GtkTreeSelection *selection; | |
2102 | |
2103 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(rd->listview)); | |
2104 gtk_tree_selection_select_iter(selection, &iter); | |
2105 } | |
2106 | |
2107 /* now do it for real */ | |
2108 success = TRUE; | |
2109 n = start_n; | |
2110 while (success && gtk_tree_model_get_iter_first(store, &iter)) | |
2111 { | |
2112 gchar *dest; | |
2113 gchar *base; | |
138 | 2114 FileData *fd; |
2115 | |
2116 gtk_tree_model_get(store, &iter, RENAME_COLUMN_FD, &fd, -1); | |
2117 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
|
2118 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2119 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
|
2120 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2121 gchar *new_name; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2122 |
138 | 2123 new_name = file_util_rename_multiple_auto_format_name(format, fd->name, n); |
723 | 2124 dest = g_build_filename(base, new_name, NULL); |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2125 g_free(new_name); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2126 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2127 else |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2128 { |
723 | 2129 gchar *new_name; |
2130 | |
2131 new_name = g_strdup_printf("%s%0*d%s", front, padding, n, end); | |
2132 dest = g_build_filename(base, new_name, NULL); | |
2133 g_free(new_name); | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2134 } |
442 | 2135 |
143
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
140
diff
changeset
|
2136 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
|
2137 !rename_file_ext(fd)) |
9 | 2138 { |
2139 success = FALSE; | |
2140 } | |
2141 | |
2142 g_free(dest); | |
2143 g_free(base); | |
138 | 2144 // file_data_unref(fd); |
9 | 2145 |
2146 if (success) | |
2147 { | |
2148 gtk_list_store_remove(GTK_LIST_STORE(store), &iter); | |
2149 if (gtk_tree_model_get_iter_first(store, &iter)) | |
2150 { | |
2151 GtkTreeSelection *selection; | |
2152 | |
2153 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(rd->listview)); | |
2154 gtk_tree_selection_select_iter(selection, &iter); | |
2155 } | |
2156 } | |
2157 | |
2158 n++; | |
2159 } | |
2160 | |
2161 if (!success) | |
2162 { | |
2163 gchar *buf; | |
2164 | |
2165 n--; | |
15
3263965d5f9e
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
2166 gtk_spin_button_set_value(GTK_SPIN_BUTTON(rd->auto_spin_start), (gdouble)n); |
9 | 2167 |
138 | 2168 buf = g_strdup_printf(_("Failed to rename\n%s\nThe number was %d."), rd->fdlg->source_fd->name, n); |
9 | 2169 file_util_warning_dialog(_("Auto rename"), buf, GTK_STOCK_DIALOG_ERROR, NULL); |
2170 g_free(buf); | |
2171 | |
2172 return; | |
2173 } | |
2174 | |
138 | 2175 file_dialog_close(rd->fdlg); |
9 | 2176 } |
2177 | |
138 | 2178 static void file_util_rename_multiple_cb(FileDialog *fdlg, gpointer data) |
9 | 2179 { |
2180 RenameDataMult *rd = data; | |
1 | 2181 gchar *base; |
9 | 2182 const gchar *name; |
2183 | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2184 if (rd->rename_type != RENAME_TYPE_MANUAL) |
9 | 2185 { |
2186 file_util_rename_multiple_auto(rd); | |
2187 return; | |
2188 } | |
2189 | |
2190 name = gtk_entry_get_text(GTK_ENTRY(rd->rename_entry)); | |
138 | 2191 base = remove_level_from_path(fdlg->source_fd->path); |
2192 | |
2193 g_free(fdlg->dest_path); | |
702
e07895754e65
Drop concat_dir_and_file() and use g_build_filename() instead.
zas_
parents:
675
diff
changeset
|
2194 fdlg->dest_path = g_build_filename(base, name, NULL); |
1 | 2195 g_free(base); |
2196 | |
138 | 2197 if (strlen(name) == 0 || strcmp(fdlg->source_fd->path, fdlg->dest_path) == 0) |
1 | 2198 { |
2199 return; | |
2200 } | |
2201 | |
138 | 2202 fdlg->type = FALSE; |
9 | 2203 file_util_rename_multiple(rd); |
2204 } | |
2205 | |
138 | 2206 static void file_util_rename_multiple_close_cb(FileDialog *fdlg, gpointer data) |
9 | 2207 { |
2208 RenameDataMult *rd = data; | |
2209 | |
138 | 2210 file_dialog_close(rd->fdlg); |
1 | 2211 } |
2212 | |
9 | 2213 static gboolean file_util_rename_multiple_select_cb(GtkTreeSelection *selection, GtkTreeModel *store, GtkTreePath *tpath, |
2214 gboolean path_currently_selected, gpointer data) | |
2215 { | |
2216 RenameDataMult *rd = data; | |
2217 GtkTreeIter iter; | |
2218 const gchar *name; | |
138 | 2219 FileData *fd = NULL; |
9 | 2220 |
2221 if (path_currently_selected || | |
2222 !gtk_tree_model_get_iter(store, &iter, tpath)) return TRUE; | |
138 | 2223 gtk_tree_model_get(store, &iter, RENAME_COLUMN_FD, &fd, -1); |
2224 | |
2225 file_data_unref(rd->fdlg->source_fd); | |
2226 rd->fdlg->source_fd = file_data_ref(fd); | |
2227 | |
2228 name = rd->fdlg->source_fd->name; | |
9 | 2229 gtk_label_set_text(GTK_LABEL(rd->rename_label), name); |
2230 gtk_entry_set_text(GTK_ENTRY(rd->rename_entry), name); | |
2231 | |
138 | 2232 image_change_fd(rd->imd, rd->fdlg->source_fd, 0.0); |
9 | 2233 |
2234 if (GTK_WIDGET_VISIBLE(rd->rename_box)) | |
2235 { | |
2236 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
|
2237 gtk_editable_select_region(GTK_EDITABLE(rd->rename_entry), 0, filename_base_length(name)); |
9 | 2238 } |
2239 | |
2240 return TRUE; | |
2241 } | |
2242 | |
2243 static void file_util_rename_multiple_preview_update(RenameDataMult *rd) | |
1 | 2244 { |
9 | 2245 GtkTreeModel *store; |
2246 GtkTreeIter iter; | |
2247 const gchar *front; | |
2248 const gchar *end; | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2249 const gchar *format; |
9 | 2250 gint valid; |
2251 gint start_n; | |
2252 gint padding; | |
2253 gint n; | |
2254 | |
2255 front = gtk_entry_get_text(GTK_ENTRY(rd->auto_entry_front)); | |
2256 end = gtk_entry_get_text(GTK_ENTRY(rd->auto_entry_end)); | |
2257 padding = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(rd->auto_spin_pad)); | |
2258 | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2259 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
|
2260 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2261 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
|
2262 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2263 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
|
2264 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2265 else |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2266 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2267 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
|
2268 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2269 |
9 | 2270 store = gtk_tree_view_get_model(GTK_TREE_VIEW(rd->listview)); |
2271 n = start_n; | |
2272 valid = gtk_tree_model_get_iter_first(store, &iter); | |
2273 while (valid) | |
2274 { | |
2275 gchar *dest; | |
2276 | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2277 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
|
2278 { |
138 | 2279 FileData *fd; |
442 | 2280 |
138 | 2281 gtk_tree_model_get(store, &iter, RENAME_COLUMN_FD, &fd, -1); |
2282 dest = file_util_rename_multiple_auto_format_name(format, fd->name, n); | |
2283 // file_data_unref(fd); | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2284 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2285 else |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2286 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2287 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
|
2288 } |
9 | 2289 gtk_list_store_set(GTK_LIST_STORE(store), &iter, RENAME_COLUMN_PREVIEW, dest, -1); |
2290 g_free(dest); | |
2291 | |
2292 n++; | |
2293 valid = gtk_tree_model_iter_next(store, &iter); | |
2294 } | |
2295 | |
1 | 2296 } |
2297 | |
9 | 2298 static gboolean file_util_rename_multiple_idle_cb(gpointer data) |
2299 { | |
2300 RenameDataMult *rd = data; | |
2301 | |
2302 file_util_rename_multiple_preview_update(rd); | |
2303 | |
2304 rd->update_idle_id = -1; | |
2305 return FALSE; | |
2306 } | |
2307 | |
2308 static void file_util_rename_multiple_preview_order_cb(GtkTreeModel *treemodel, GtkTreePath *tpath, | |
2309 GtkTreeIter *iter, gpointer data) | |
2310 { | |
2311 RenameDataMult *rd = data; | |
2312 | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2313 if (rd->rename_type != RENAME_TYPE_MANUAL && rd->update_idle_id == -1) |
9 | 2314 { |
2315 rd->update_idle_id = g_idle_add(file_util_rename_multiple_idle_cb, rd); | |
2316 } | |
2317 } | |
2318 | |
2319 static void file_util_rename_multiple_preview_entry_cb(GtkWidget *entry, gpointer data) | |
2320 { | |
2321 RenameDataMult *rd = data; | |
2322 file_util_rename_multiple_preview_update(rd); | |
2323 } | |
2324 | |
2325 static void file_util_rename_multiple_preview_adj_cb(GtkWidget *spin, gpointer data) | |
2326 { | |
2327 RenameDataMult *rd = data; | |
2328 file_util_rename_multiple_preview_update(rd); | |
2329 } | |
2330 | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2331 static void file_util_rename_multiple_auto_change(GtkWidget *widget, gpointer data) |
1 | 2332 { |
9 | 2333 RenameDataMult *rd = data; |
2334 GtkTreeViewColumn *column; | |
2335 | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2336 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
|
2337 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2338 switch (rd->rename_type) |
9 | 2339 { |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2340 case RENAME_TYPE_FORMATTED: |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2341 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
|
2342 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
|
2343 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
|
2344 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
|
2345 break; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2346 case RENAME_TYPE_AUTO: |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2347 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
|
2348 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
|
2349 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
|
2350 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
|
2351 break; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2352 case RENAME_TYPE_MANUAL: |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2353 default: |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2354 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
|
2355 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
|
2356 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
|
2357 break; |
9 | 2358 } |
2359 | |
2360 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
|
2361 gtk_tree_view_column_set_visible(column, (rd->rename_type != RENAME_TYPE_MANUAL)); |
9 | 2362 } |
2363 | |
2364 static GtkWidget *furm_simple_vlabel(GtkWidget *box, const gchar *text, gint expand) | |
2365 { | |
2366 GtkWidget *vbox; | |
2367 GtkWidget *label; | |
2368 | |
2369 vbox = gtk_vbox_new(FALSE, 0); | |
2370 gtk_box_pack_start(GTK_BOX(box), vbox, expand, expand, 0); | |
2371 gtk_widget_show(vbox); | |
2372 | |
2373 label = gtk_label_new(text); | |
2374 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
2375 gtk_widget_show(label); | |
2376 | |
2377 return vbox; | |
2378 } | |
2379 | |
2380 static GtkTreeViewColumn *file_util_rename_multiple_add_column(RenameDataMult *rd, const gchar *text, gint n) | |
2381 { | |
2382 GtkTreeViewColumn *column; | |
2383 GtkCellRenderer *renderer; | |
2384 | |
2385 column = gtk_tree_view_column_new(); | |
442 | 2386 gtk_tree_view_column_set_title(column, text); |
2387 gtk_tree_view_column_set_min_width(column, 4); | |
2388 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY); | |
2389 renderer = gtk_cell_renderer_text_new(); | |
2390 gtk_tree_view_column_pack_start(column, renderer, TRUE); | |
2391 gtk_tree_view_column_add_attribute(column, renderer, "text", n); | |
2392 gtk_tree_view_append_column(GTK_TREE_VIEW(rd->listview), column); | |
9 | 2393 |
2394 return column; | |
2395 } | |
2396 | |
2397 static void file_util_rename_multiple_destroy_cb(GtkWidget *widget, gpointer data) | |
2398 { | |
2399 RenameDataMult *rd = data; | |
2400 | |
2401 if (rd->update_idle_id != -1) g_source_remove(rd->update_idle_id); | |
2402 | |
2403 g_free(rd); | |
2404 } | |
2405 | |
2406 static void file_util_rename_multiple_do(GList *source_list, GtkWidget *parent) | |
2407 { | |
2408 RenameDataMult *rd; | |
2409 GtkWidget *pane; | |
1 | 2410 GtkWidget *scrolled; |
9 | 2411 GtkListStore *store; |
2412 GtkTreeSelection *selection; | |
2413 GtkTreeViewColumn *column; | |
2414 GtkWidget *hbox; | |
2415 GtkWidget *vbox; | |
2416 GtkWidget *box2; | |
2417 GtkWidget *table; | |
2418 GtkWidget *combo; | |
1 | 2419 GList *work; |
42
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
2420 const gchar *name; |
1 | 2421 |
9 | 2422 rd = g_new0(RenameDataMult, 1); |
442 | 2423 |
675 | 2424 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
|
2425 file_util_rename_multiple_close_cb, rd); |
138 | 2426 generic_dialog_add_message(GENERIC_DIALOG(rd->fdlg), NULL, _("Rename multiple files"), NULL); |
2427 file_dialog_add_button(rd->fdlg, GTK_STOCK_OK, _("_Rename"), file_util_rename_multiple_cb, TRUE); | |
2428 | |
2429 rd->fdlg->source_fd = file_data_ref(source_list->data); | |
2430 rd->fdlg->dest_path = NULL; | |
9 | 2431 |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2432 rd->rename_type = RENAME_TYPE_MANUAL; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2433 |
9 | 2434 rd->update_idle_id = -1; |
2435 | |
138 | 2436 vbox = GENERIC_DIALOG(rd->fdlg)->vbox; |
9 | 2437 |
2438 pane = gtk_hpaned_new(); | |
2439 gtk_box_pack_start(GTK_BOX(vbox), pane, TRUE, TRUE, 0); | |
2440 gtk_widget_show(pane); | |
442 | 2441 |
1 | 2442 scrolled = gtk_scrolled_window_new(NULL, NULL); |
9 | 2443 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
|
2444 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), |
9 | 2445 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); |
2446 gtk_paned_pack1(GTK_PANED(pane), scrolled, TRUE, TRUE); | |
1 | 2447 gtk_widget_show(scrolled); |
2448 | |
138 | 2449 store = gtk_list_store_new(4, G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); |
9 | 2450 rd->listview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); |
2451 g_object_unref(store); | |
2452 | |
2453 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(rd->listview), TRUE); | |
2454 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(rd->listview), FALSE); | |
2455 | |
2456 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(rd->listview)); | |
2457 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_SINGLE); | |
2458 gtk_tree_selection_set_select_function(selection, file_util_rename_multiple_select_cb, rd, NULL); | |
2459 | |
2460 file_util_rename_multiple_add_column(rd, _("Original Name"), RENAME_COLUMN_NAME); | |
2461 column = file_util_rename_multiple_add_column(rd, _("Preview"), RENAME_COLUMN_PREVIEW); | |
2462 gtk_tree_view_column_set_visible(column, FALSE); | |
442 | 2463 |
9 | 2464 gtk_tree_view_set_reorderable(GTK_TREE_VIEW(rd->listview), TRUE); |
2465 g_signal_connect(G_OBJECT(store), "row_changed", | |
2466 G_CALLBACK(file_util_rename_multiple_preview_order_cb), rd); | |
2467 gtk_widget_set_size_request(rd->listview, 250, 150); | |
2468 | |
2469 gtk_container_add(GTK_CONTAINER(scrolled), rd->listview); | |
2470 gtk_widget_show(rd->listview); | |
1 | 2471 |
2472 work = source_list; | |
9 | 2473 while (work) |
1 | 2474 { |
138 | 2475 FileData *fd = work->data; |
9 | 2476 GtkTreeIter iter; |
2477 | |
2478 gtk_list_store_append(store, &iter); | |
138 | 2479 gtk_list_store_set(store, &iter, RENAME_COLUMN_FD, fd, RENAME_COLUMN_PATH, fd->path, RENAME_COLUMN_NAME, fd->name, -1); |
9 | 2480 |
1 | 2481 work = work->next; |
2482 } | |
2483 | |
138 | 2484 filelist_free(source_list); |
9 | 2485 |
2486 rd->imd = image_new(TRUE); | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2487 g_object_set(G_OBJECT(rd->imd->pr), "zoom_expand", FALSE, NULL); |
9 | 2488 gtk_widget_set_size_request(rd->imd->widget, DIALOG_DEF_IMAGE_DIM_X, DIALOG_DEF_IMAGE_DIM_Y); |
2489 gtk_paned_pack2(GTK_PANED(pane), rd->imd->widget, FALSE, TRUE); | |
2490 gtk_widget_show(rd->imd->widget); | |
2491 | |
2492 hbox = gtk_hbox_new(FALSE, 0); | |
2493 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | |
2494 gtk_widget_show(hbox); | |
2495 | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2496 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
|
2497 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2498 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
|
2499 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
|
2500 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
|
2501 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2502 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
|
2503 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2504 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
|
2505 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
|
2506 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
|
2507 gtk_widget_show(rd->combo_type); |
9 | 2508 |
2509 rd->rename_box = pref_box_new(vbox, FALSE, GTK_ORIENTATION_VERTICAL, 0); | |
2510 table = pref_table_new(rd->rename_box, 2, 2, FALSE, FALSE); | |
2511 | |
2512 pref_table_label(table, 0, 0, _("Original name:"), 1.0); | |
138 | 2513 rd->rename_label = pref_table_label(table, 1, 0, rd->fdlg->source_fd->name, 0.0); |
9 | 2514 |
2515 pref_table_label(table, 0, 1, _("New name:"), 1.0); | |
2516 | |
2517 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
|
2518 gtk_table_attach(GTK_TABLE(table), rd->rename_entry, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0); |
138 | 2519 generic_dialog_attach_default(GENERIC_DIALOG(rd->fdlg), rd->rename_entry); |
9 | 2520 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
|
2521 |
138 | 2522 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
|
2523 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
|
2524 gtk_editable_select_region(GTK_EDITABLE(rd->rename_entry), 0, filename_base_length(name)); |
9 | 2525 gtk_widget_show(rd->rename_entry); |
2526 | |
2527 rd->auto_box = gtk_vbox_new(FALSE, PREF_PAD_GAP); | |
2528 gtk_box_pack_start(GTK_BOX(vbox), rd->auto_box, FALSE, FALSE, 0); | |
2529 /* do not show it here */ | |
2530 | |
2531 hbox = pref_box_new(rd->auto_box, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_GAP); | |
2532 | |
2533 box2 = furm_simple_vlabel(hbox, _("Begin text"), TRUE); | |
2534 | |
2535 combo = history_combo_new(&rd->auto_entry_front, "", "numerical_rename_prefix", -1); | |
2536 g_signal_connect(G_OBJECT(rd->auto_entry_front), "changed", | |
2537 G_CALLBACK(file_util_rename_multiple_preview_entry_cb), rd); | |
2538 gtk_box_pack_start(GTK_BOX(box2), combo, TRUE, TRUE, 0); | |
2539 gtk_widget_show(combo); | |
442 | 2540 |
9 | 2541 box2 = furm_simple_vlabel(hbox, _("Start #"), FALSE); |
2542 | |
2543 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
|
2544 0.0, 1000000.0, 1.0, 0, 1.0, |
9 | 2545 G_CALLBACK(file_util_rename_multiple_preview_adj_cb), rd); |
2546 | |
2547 box2 = furm_simple_vlabel(hbox, _("End text"), TRUE); | |
2548 | |
2549 combo = history_combo_new(&rd->auto_entry_end, "", "numerical_rename_suffix", -1); | |
2550 g_signal_connect(G_OBJECT(rd->auto_entry_end), "changed", | |
2551 G_CALLBACK(file_util_rename_multiple_preview_entry_cb), rd); | |
2552 gtk_box_pack_start(GTK_BOX(box2), combo, TRUE, TRUE, 0); | |
2553 gtk_widget_show(combo); | |
2554 | |
2555 rd->auto_spin_pad = pref_spin_new(rd->auto_box, _("Padding:"), NULL, | |
2556 1.0, 8.0, 1.0, 0, 1.0, | |
2557 G_CALLBACK(file_util_rename_multiple_preview_adj_cb), rd); | |
2558 | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2559 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
|
2560 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
|
2561 /* do not show it here */ |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2562 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2563 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
|
2564 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2565 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
|
2566 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2567 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
|
2568 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
|
2569 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
|
2570 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
|
2571 gtk_widget_show(combo); |
442 | 2572 |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2573 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
|
2574 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
2575 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
|
2576 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
|
2577 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
|
2578 |
138 | 2579 image_change_fd(rd->imd, rd->fdlg->source_fd, 0.0); |
2580 | |
2581 g_signal_connect(G_OBJECT(GENERIC_DIALOG(rd->fdlg)->dialog), "destroy", | |
9 | 2582 G_CALLBACK(file_util_rename_multiple_destroy_cb), rd); |
2583 | |
138 | 2584 gtk_widget_show(GENERIC_DIALOG(rd->fdlg)->dialog); |
1 | 2585 } |
2586 | |
2587 /* | |
2588 * rename single file | |
2589 */ | |
2590 | |
9 | 2591 static void file_util_rename_single(FileDataSingle *fds); |
2592 | |
2593 static void file_util_rename_single_ok_cb(GenericDialog *gd, gpointer data) | |
1 | 2594 { |
2595 FileDataSingle *fds = data; | |
2596 fds->confirmed = TRUE; | |
2597 file_util_rename_single(fds); | |
2598 } | |
2599 | |
9 | 2600 static void file_util_rename_single_cancel_cb(GenericDialog *gd, gpointer data) |
1 | 2601 { |
2602 FileDataSingle *fds = data; | |
2603 file_data_single_free(fds); | |
2604 } | |
2605 | |
2606 static void file_util_rename_single(FileDataSingle *fds) | |
2607 { | |
2608 if (isfile(fds->dest) && !fds->confirmed) | |
2609 { | |
9 | 2610 GenericDialog *gd; |
2611 | |
254
9faf34f047b1
Make the wmclass value unique among the code by defining
zas_
parents:
223
diff
changeset
|
2612 gd = file_util_gen_dlg(_("Overwrite file"), GQ_WMCLASS, "dlg_confirm", |
9 | 2613 NULL, TRUE, |
2614 file_util_rename_single_cancel_cb, fds); | |
2615 | |
2616 generic_dialog_add_message(gd, GTK_STOCK_DIALOG_QUESTION, | |
2617 _("Overwrite file?"), | |
2618 _("Replace existing file by renaming new file.")); | |
2619 pref_spacer(gd->vbox, 0); | |
2620 | |
2621 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
|
2622 generic_dialog_add_image(gd, NULL, |
138 | 2623 file_data_new_simple(fds->dest), _("Existing file"), |
2624 fds->source_fd, _("New file"), TRUE); | |
9 | 2625 |
2626 gtk_widget_show(gd->dialog); | |
2627 | |
1 | 2628 return; |
2629 } | |
2630 else | |
2631 { | |
138 | 2632 /* |
2633 GList *list = g_list_append(NULL, file_data_ref(fds->source_fd)); | |
2634 file_util_do_move_list(list, FALSE, TRUE); | |
2635 filelist_free(list); | |
2636 */ | |
143
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
140
diff
changeset
|
2637 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
|
2638 !rename_file_ext(fds->source_fd)) |
1 | 2639 { |
138 | 2640 gchar *text = g_strdup_printf(_("Unable to rename file:\n%s\nto:\n%s"), fds->source_fd->name, filename_from_path(fds->dest)); |
9 | 2641 file_util_warning_dialog(_("Error renaming file"), text, GTK_STOCK_DIALOG_ERROR, NULL); |
1 | 2642 g_free(text); |
2643 } | |
138 | 2644 |
1 | 2645 } |
2646 file_data_single_free(fds); | |
2647 } | |
2648 | |
138 | 2649 static void file_util_rename_single_cb(FileDialog *fdlg, gpointer data) |
1 | 2650 { |
9 | 2651 const gchar *name; |
2652 gchar *path; | |
2653 | |
138 | 2654 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
|
2655 path = g_build_filename(fdlg->dest_path, name, NULL); |
138 | 2656 |
2657 if (strlen(name) == 0 || strcmp(fdlg->source_fd->path, path) == 0) | |
1 | 2658 { |
9 | 2659 g_free(path); |
1 | 2660 return; |
2661 } | |
2662 | |
138 | 2663 file_util_rename_single(file_data_single_new(fdlg->source_fd, path, fdlg->type)); |
9 | 2664 |
2665 g_free(path); | |
138 | 2666 file_dialog_close(fdlg); |
1 | 2667 } |
2668 | |
138 | 2669 static void file_util_rename_single_close_cb(FileDialog *fdlg, gpointer data) |
9 | 2670 { |
138 | 2671 file_dialog_close(fdlg); |
9 | 2672 } |
2673 | |
138 | 2674 static void file_util_rename_single_do(FileData *source_fd, GtkWidget *parent) |
1 | 2675 { |
138 | 2676 FileDialog *fdlg; |
9 | 2677 GtkWidget *table; |
42
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
2678 const gchar *name; |
675 | 2679 |
2680 fdlg = file_util_file_dlg(_("Rename"), GQ_WMCLASS, "dlg_rename", parent, | |
442 | 2681 file_util_rename_single_close_cb, NULL); |
9 | 2682 |
138 | 2683 generic_dialog_add_message(GENERIC_DIALOG(fdlg), NULL, _("Rename file"), NULL); |
2684 generic_dialog_add_image(GENERIC_DIALOG(fdlg), NULL, source_fd, NULL, NULL, NULL, FALSE); | |
2685 | |
2686 file_dialog_add_button(fdlg, GTK_STOCK_OK, _("_Rename"), file_util_rename_single_cb, TRUE); | |
2687 | |
2688 fdlg->source_fd = file_data_ref(source_fd); | |
2689 fdlg->dest_path = remove_level_from_path(source_fd->path); | |
2690 | |
2691 table = pref_table_new(GENERIC_DIALOG(fdlg)->vbox, 2, 2, FALSE, FALSE); | |
9 | 2692 |
2693 pref_table_label(table, 0, 0, _("Original name:"), 1.0); | |
138 | 2694 pref_table_label(table, 1, 0, fdlg->source_fd->name, 0.0); |
9 | 2695 |
2696 pref_table_label(table, 0, 1, _("New name:"), 1.0); | |
2697 | |
138 | 2698 fdlg->entry = gtk_entry_new(); |
2699 gtk_table_attach(GTK_TABLE(table), fdlg->entry, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0); | |
2700 generic_dialog_attach_default(GENERIC_DIALOG(fdlg), fdlg->entry); | |
2701 gtk_widget_grab_focus(fdlg->entry); | |
2702 | |
2703 name = fdlg->source_fd->name; | |
2704 gtk_entry_set_text(GTK_ENTRY(fdlg->entry), name); | |
2705 gtk_editable_select_region(GTK_EDITABLE(fdlg->entry), 0, filename_base_length(name)); | |
2706 gtk_widget_show(fdlg->entry); | |
2707 | |
2708 gtk_widget_show(GENERIC_DIALOG(fdlg)->dialog); | |
1 | 2709 } |
2710 | |
138 | 2711 void file_util_rename(FileData *source_fd, GList *source_list, GtkWidget *parent) |
1 | 2712 { |
138 | 2713 if (!source_fd && !source_list) return; |
2714 | |
2715 if (source_fd) | |
1 | 2716 { |
138 | 2717 file_util_rename_single_do(source_fd, parent); |
1 | 2718 } |
2719 else if (!source_list->next) | |
2720 { | |
9 | 2721 file_util_rename_single_do(source_list->data, parent); |
138 | 2722 filelist_free(source_list); |
1 | 2723 } |
2724 else | |
2725 { | |
9 | 2726 file_util_rename_multiple_do(source_list, parent); |
1 | 2727 } |
2728 } | |
2729 | |
2730 /* | |
2731 *-------------------------------------------------------------------------- | |
2732 * Create directory routines | |
2733 *-------------------------------------------------------------------------- | |
2734 */ | |
2735 | |
9 | 2736 static void file_util_create_dir_do(const gchar *base, const gchar *name) |
1 | 2737 { |
9 | 2738 gchar *path; |
2739 | |
702
e07895754e65
Drop concat_dir_and_file() and use g_build_filename() instead.
zas_
parents:
675
diff
changeset
|
2740 path = g_build_filename(base, name, NULL); |
9 | 2741 |
2742 if (isdir(path)) | |
1 | 2743 { |
9 | 2744 gchar *text = g_strdup_printf(_("The folder:\n%s\nalready exists."), name); |
2745 file_util_warning_dialog(_("Folder exists"), text, GTK_STOCK_DIALOG_INFO, NULL); | |
1 | 2746 g_free(text); |
2747 } | |
9 | 2748 else if (isname(path)) |
1 | 2749 { |
9 | 2750 gchar *text = g_strdup_printf(_("The path:\n%s\nalready exists as a file."), name); |
2751 file_util_warning_dialog(_("Could not create folder"), text, GTK_STOCK_DIALOG_INFO, NULL); | |
1 | 2752 g_free(text); |
2753 } | |
2754 else | |
2755 { | |
9 | 2756 if (!mkdir_utf8(path, 0755)) |
1 | 2757 { |
9 | 2758 gchar *text = g_strdup_printf(_("Unable to create folder:\n%s"), name); |
2759 file_util_warning_dialog(_("Error creating folder"), text, GTK_STOCK_DIALOG_ERROR, NULL); | |
1 | 2760 g_free(text); |
2761 } | |
2762 } | |
9 | 2763 |
2764 g_free(path); | |
1 | 2765 } |
2766 | |
138 | 2767 static void file_util_create_dir_cb(FileDialog *fdlg, gpointer data) |
1 | 2768 { |
9 | 2769 const gchar *name; |
2770 | |
138 | 2771 name = gtk_entry_get_text(GTK_ENTRY(fdlg->entry)); |
1 | 2772 |
2773 if (strlen(name) == 0) return; | |
2774 | |
726 | 2775 if (name[0] == G_DIR_SEPARATOR) |
9 | 2776 { |
2777 gchar *buf; | |
2778 buf = remove_level_from_path(name); | |
2779 file_util_create_dir_do(buf, filename_from_path(name)); | |
2780 g_free(buf); | |
2781 } | |
2782 else | |
2783 { | |
138 | 2784 file_util_create_dir_do(fdlg->dest_path, name); |
9 | 2785 } |
2786 | |
138 | 2787 file_dialog_close(fdlg); |
1 | 2788 } |
2789 | |
138 | 2790 static void file_util_create_dir_close_cb(FileDialog *fdlg, gpointer data) |
9 | 2791 { |
138 | 2792 file_dialog_close(fdlg); |
9 | 2793 } |
2794 | |
2795 void file_util_create_dir(const gchar *path, GtkWidget *parent) | |
1 | 2796 { |
138 | 2797 FileDialog *fdlg; |
1 | 2798 gchar *text; |
2799 | |
2800 if (!isdir(path)) return; | |
9 | 2801 |
675 | 2802 fdlg = file_util_file_dlg(_("New folder"), GQ_WMCLASS, "dlg_newdir", parent, |
442 | 2803 file_util_create_dir_close_cb, NULL); |
9 | 2804 |
2805 text = g_strdup_printf(_("Create folder in:\n%s\nnamed:"), path); | |
138 | 2806 generic_dialog_add_message(GENERIC_DIALOG(fdlg), NULL, NULL, text); |
1 | 2807 g_free(text); |
2808 | |
138 | 2809 file_dialog_add_button(fdlg, GTK_STOCK_OK, NULL, file_util_create_dir_cb, TRUE); |
2810 | |
2811 fdlg->dest_path = g_strdup(path); | |
2812 | |
2813 fdlg->entry = gtk_entry_new(); | |
2814 gtk_box_pack_start(GTK_BOX(GENERIC_DIALOG(fdlg)->vbox), fdlg->entry, FALSE, FALSE, 0); | |
2815 generic_dialog_attach_default(GENERIC_DIALOG(fdlg), fdlg->entry); | |
2816 gtk_widget_grab_focus(fdlg->entry); | |
2817 gtk_widget_show(fdlg->entry); | |
2818 | |
2819 gtk_widget_show(GENERIC_DIALOG(fdlg)->dialog); | |
1 | 2820 } |
2821 | |
138 | 2822 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
|
2823 { |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2824 const gchar *old_name; |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2825 const gchar *new_name; |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2826 |
138 | 2827 if (!old_fd || !new_path || !isdir(old_fd->path)) return FALSE; |
2828 | |
2829 old_name = old_fd->name; | |
44
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2830 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
|
2831 |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2832 if (isdir(new_path)) |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2833 { |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2834 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
|
2835 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
|
2836 g_free(text); |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2837 |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2838 return FALSE; |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2839 } |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2840 |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2841 if (isname(new_path)) |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2842 { |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2843 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
|
2844 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
|
2845 g_free(text); |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2846 |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2847 return FALSE; |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2848 } |
143
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
140
diff
changeset
|
2849 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
|
2850 !rename_file_ext(old_fd)) |
44
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2851 { |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2852 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
|
2853 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
|
2854 g_free(text); |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2855 |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2856 return FALSE; |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2857 } |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2858 |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2859 return TRUE; |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2860 } |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2861 |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2862 /* |
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 * Delete directory routines |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2865 *-------------------------------------------------------------------------- |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2866 */ |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2867 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2868 /* 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
|
2869 * use UtilityData and UtilityType. |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2870 * 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
|
2871 */ |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2872 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2873 typedef enum { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2874 UTILITY_TYPE_NONE = 0, |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2875 UTILITY_TYPE_COPY, |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2876 UTILITY_TYPE_MOVE, |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2877 UTILITY_TYPE_RENAME, |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2878 UTILITY_TYPE_DELETE, |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2879 UTILITY_TYPE_DELETE_LINK, |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2880 UTILITY_TYPE_DELETE_FOLDER |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2881 } UtilityType; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2882 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2883 typedef struct _UtilityData UtilityData; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2884 struct _UtilityData { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2885 UtilityType type; |
138 | 2886 FileData *source_fd; |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2887 GList *dlist; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2888 GList *flist; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2889 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2890 GenericDialog *gd; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2891 }; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2892 |
138 | 2893 enum { |
2894 UTILITY_COLUMN_FD = 0, | |
2895 UTILITY_COLUMN_PATH, | |
2896 UTILITY_COLUMN_NAME, | |
2897 UTILITY_COLUMN_COUNT | |
2898 }; | |
2899 | |
2900 | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2901 #define UTILITY_LIST_MIN_WIDTH 250 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2902 #define UTILITY_LIST_MIN_HEIGHT 150 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2903 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2904 /* 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
|
2905 #define UTILITY_DELETE_MAX_DEPTH 5 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2906 |
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 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
|
2909 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2910 if (!ud) return; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2911 |
138 | 2912 file_data_unref(ud->source_fd); |
2913 filelist_free(ud->dlist); | |
2914 filelist_free(ud->flist); | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2915 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2916 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
|
2917 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2918 g_free(ud); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2919 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2920 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2921 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
|
2922 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2923 GtkTreeViewColumn *column; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2924 GtkCellRenderer *renderer; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2925 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2926 column = gtk_tree_view_column_new(); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2927 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
|
2928 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
|
2929 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
|
2930 renderer = gtk_cell_renderer_text_new(); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2931 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
|
2932 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
|
2933 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
|
2934 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2935 return column; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2936 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2937 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2938 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
|
2939 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2940 GtkWidget *scrolled; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2941 GtkWidget *view; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2942 GtkListStore *store; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2943 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2944 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
|
2945 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
|
2946 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
|
2947 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2948 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
|
2949 gtk_widget_show(scrolled); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2950 |
138 | 2951 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
|
2952 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
|
2953 g_object_unref(store); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2954 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2955 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
|
2956 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
|
2957 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2958 if (full_paths) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2959 { |
138 | 2960 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
|
2961 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2962 else |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2963 { |
138 | 2964 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
|
2965 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2966 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2967 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
|
2968 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
|
2969 gtk_widget_show(view); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2970 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2971 while (list) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2972 { |
138 | 2973 FileData *fd = list->data; |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2974 GtkTreeIter iter; |
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 gtk_list_store_append(store, &iter); |
138 | 2977 gtk_list_store_set(store, &iter, UTILITY_COLUMN_FD, fd, |
2978 UTILITY_COLUMN_PATH, fd->path, | |
2979 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
|
2980 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2981 list = list->next; |
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 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2984 return view; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2985 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2986 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2987 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
|
2988 GtkTreePath *tpath, gboolean path_currently_selected, |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2989 gpointer data) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2990 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2991 UtilityData *ud = data; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2992 GtkTreeIter iter; |
138 | 2993 FileData *fd = NULL; |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2994 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2995 if (path_currently_selected || |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2996 !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
|
2997 |
138 | 2998 gtk_tree_model_get(store, &iter, UTILITY_COLUMN_FD, &fd, -1); |
2999 generic_dialog_image_set(ud->gd, fd); | |
3000 // file_data_unref(fd); | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3001 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3002 return TRUE; |
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 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3005 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
|
3006 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3007 UtilityData *ud = data; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3008 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3009 ud->gd = NULL; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3010 file_util_data_free(ud); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3011 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3012 |
138 | 3013 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
|
3014 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3015 GList *dlist = NULL; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3016 GList *flist = NULL; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3017 GList *work; |
138 | 3018 FileData *fail = NULL; |
3019 | |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
497
diff
changeset
|
3020 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
|
3021 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3022 level++; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3023 if (level > UTILITY_DELETE_MAX_DEPTH) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3024 { |
673
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
671
diff
changeset
|
3025 log_printf("folder recursion depth past %d, giving up\n", UTILITY_DELETE_MAX_DEPTH); |
138 | 3026 return file_data_ref(fd); |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3027 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3028 |
138 | 3029 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
|
3030 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3031 work = dlist; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3032 while (work && !fail) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3033 { |
138 | 3034 FileData *lfd; |
3035 | |
3036 lfd = work->data; | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3037 work = work->next; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3038 |
138 | 3039 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
|
3040 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3041 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3042 work = flist; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3043 while (work && !fail) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3044 { |
138 | 3045 FileData *lfd; |
3046 | |
3047 lfd = work->data; | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3048 work = work->next; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3049 |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
497
diff
changeset
|
3050 DEBUG_1("deltree child: %s", lfd->path); |
138 | 3051 |
3052 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
|
3053 { |
138 | 3054 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
|
3055 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3056 else |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3057 { |
138 | 3058 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
|
3059 } |
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 |
138 | 3062 filelist_free(dlist); |
3063 filelist_free(flist); | |
3064 | |
3065 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
|
3066 { |
138 | 3067 fail = file_data_ref(fd); |
112
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 |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
497
diff
changeset
|
3070 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
|
3071 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3072 return fail; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3073 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3074 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3075 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
|
3076 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3077 UtilityData *ud = data; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3078 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3079 ud->gd = NULL; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3080 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3081 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
|
3082 { |
138 | 3083 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
|
3084 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3085 gchar *text; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3086 |
138 | 3087 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
|
3088 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
|
3089 GTK_STOCK_DIALOG_ERROR, NULL); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3090 g_free(text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3091 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3092 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3093 else |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3094 { |
138 | 3095 FileData *fail = NULL; |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3096 GList *work; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3097 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3098 work = ud->dlist; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3099 while (work && !fail) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3100 { |
138 | 3101 FileData *fd; |
3102 | |
3103 fd = work->data; | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3104 work = work->next; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3105 |
138 | 3106 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
|
3107 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3108 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3109 work = ud->flist; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3110 while (work && !fail) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3111 { |
138 | 3112 FileData *fd; |
3113 | |
3114 fd = work->data; | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3115 work = work->next; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3116 |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
497
diff
changeset
|
3117 DEBUG_1("deltree unlink: %s", fd->path); |
138 | 3118 |
3119 if (islink(fd->path)) | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3120 { |
138 | 3121 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
|
3122 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3123 else |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3124 { |
138 | 3125 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
|
3126 } |
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 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3129 if (!fail) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3130 { |
138 | 3131 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
|
3132 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3133 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3134 if (fail) |
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 gchar *text; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3137 |
138 | 3138 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
|
3139 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
|
3140 g_free(text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3141 |
138 | 3142 if (fail != ud->source_fd) |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3143 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3144 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
|
3145 text = g_strdup_printf(_("Removal of folder contents failed at this file:\n\n%s"), |
138 | 3146 fail->path); |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3147 pref_label_new(gd->vbox, text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3148 g_free(text); |
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 |
138 | 3151 file_data_unref(fail); |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3152 } |
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 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3155 file_util_data_free(ud); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3156 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3157 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3158 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
|
3159 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3160 GList *rlist = NULL; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3161 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3162 while (dlist) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3163 { |
138 | 3164 FileData *fd; |
3165 | |
3166 fd = dlist->data; | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3167 dlist = dlist->next; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3168 |
138 | 3169 if (!fd->name || |
3170 (strcmp(fd->name, THUMB_FOLDER_GLOBAL) != 0 && | |
3171 strcmp(fd->name, THUMB_FOLDER_LOCAL) != 0 && | |
283 | 3172 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
|
3173 { |
138 | 3174 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
|
3175 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3176 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3177 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3178 return g_list_reverse(rlist); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3179 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3180 |
138 | 3181 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
|
3182 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3183 GList *dlist = NULL; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3184 GList *flist = NULL; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3185 GList *rlist; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3186 |
138 | 3187 if (!isdir(fd->path)) return; |
3188 | |
3189 if (islink(fd->path)) | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3190 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3191 UtilityData *ud; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3192 gchar *text; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3193 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3194 ud = g_new0(UtilityData, 1); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3195 ud->type = UTILITY_TYPE_DELETE_LINK; |
138 | 3196 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
|
3197 ud->dlist = NULL; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3198 ud->flist = NULL; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3199 |
254
9faf34f047b1
Make the wmclass value unique among the code by defining
zas_
parents:
223
diff
changeset
|
3200 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
|
3201 parent, TRUE, |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3202 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
|
3203 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3204 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
|
3205 "The folder this link points to will not be deleted."), |
138 | 3206 fd->path); |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3207 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
|
3208 _("Delete symbolic link to folder?"), |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3209 text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3210 g_free(text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3211 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3212 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
|
3213 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3214 gtk_widget_show(ud->gd->dialog); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3215 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3216 return; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3217 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3218 |
138 | 3219 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
|
3220 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3221 gchar *text; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3222 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3223 text = g_strdup_printf(_("Unable to remove folder %s\n" |
138 | 3224 "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
|
3225 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
|
3226 g_free(text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3227 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3228 return; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3229 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3230 |
138 | 3231 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
|
3232 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3233 gchar *text; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3234 |
138 | 3235 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
|
3236 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
|
3237 g_free(text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3238 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3239 return; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3240 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3241 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3242 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
|
3243 if (rlist) |
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 GenericDialog *gd; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3246 GtkWidget *box; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3247 gchar *text; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3248 |
254
9faf34f047b1
Make the wmclass value unique among the code by defining
zas_
parents:
223
diff
changeset
|
3249 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
|
3250 parent, TRUE, NULL, NULL); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3251 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
|
3252 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3253 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
|
3254 "This folder contains subfolders which must be moved before it can be deleted."), |
138 | 3255 fd->path); |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3256 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
|
3257 _("Folder contains subfolders"), |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3258 text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3259 g_free(text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3260 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3261 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
|
3262 |
138 | 3263 rlist = filelist_sort_path(rlist); |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3264 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
|
3265 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3266 gtk_widget_show(gd->dialog); |
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 else |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3269 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3270 UtilityData *ud; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3271 GtkWidget *box; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3272 GtkWidget *view; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3273 GtkTreeSelection *selection; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3274 gchar *text; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3275 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3276 ud = g_new0(UtilityData, 1); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3277 ud->type = UTILITY_TYPE_DELETE_FOLDER; |
138 | 3278 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
|
3279 ud->dlist = dlist; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3280 dlist = NULL; |
138 | 3281 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
|
3282 flist = NULL; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3283 |
254
9faf34f047b1
Make the wmclass value unique among the code by defining
zas_
parents:
223
diff
changeset
|
3284 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
|
3285 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
|
3286 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
|
3287 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3288 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
|
3289 "The contents of this folder will also be deleted."), |
138 | 3290 fd->path); |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3291 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
|
3292 _("Delete folder?"), |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3293 text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3294 g_free(text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3295 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3296 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
|
3297 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3298 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
|
3299 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
|
3300 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
|
3301 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
|
3302 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3303 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
|
3304 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3305 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
|
3306 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3307 gtk_widget_show(ud->gd->dialog); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3308 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3309 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3310 g_list_free(rlist); |
138 | 3311 filelist_free(dlist); |
3312 filelist_free(flist); | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
3313 } |