Mercurial > geeqie
annotate src/utilops.c @ 772:f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
changes made by external editors more precisely
author | nadvornik |
---|---|
date | Sat, 31 May 2008 19:44:41 +0000 |
parents | 7148e125bf23 |
children | 44128da39e13 |
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 * Adds 1 or 2 images (if 2, side by side) to a GenericDialog | |
39 *-------------------------------------------------------------------------- | |
40 */ | |
41 | |
42 #define DIALOG_DEF_IMAGE_DIM_X 200 | |
43 #define DIALOG_DEF_IMAGE_DIM_Y 150 | |
44 | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
45 static void generic_dialog_add_image(GenericDialog *gd, GtkWidget *box, |
138 | 46 FileData *fd1, const gchar *header1, |
47 FileData *fd2, const gchar *header2, | |
9 | 48 gint show_filename) |
49 { | |
50 ImageWindow *imd; | |
51 GtkWidget *hbox = NULL; | |
52 GtkWidget *vbox; | |
53 GtkWidget *label = NULL; | |
54 | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
55 if (!box) box = gd->vbox; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
56 |
138 | 57 if (fd2) |
9 | 58 { |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
59 hbox = pref_box_new(box, TRUE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE); |
9 | 60 } |
61 | |
62 /* image 1 */ | |
63 | |
64 vbox = gtk_vbox_new(FALSE, PREF_PAD_GAP); | |
65 if (hbox) | |
66 { | |
67 GtkWidget *sep; | |
68 | |
69 gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0); | |
70 | |
71 sep = gtk_vseparator_new(); | |
72 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0); | |
73 gtk_widget_show(sep); | |
74 } | |
75 else | |
76 { | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
77 gtk_box_pack_start(GTK_BOX(box), vbox, TRUE, TRUE, PREF_PAD_GAP); |
9 | 78 } |
79 gtk_widget_show(vbox); | |
80 | |
81 if (header1) | |
82 { | |
83 GtkWidget *head; | |
84 | |
85 head = pref_label_new(vbox, header1); | |
86 pref_label_bold(head, TRUE, FALSE); | |
87 gtk_misc_set_alignment(GTK_MISC(head), 0.0, 0.5); | |
88 } | |
89 | |
90 imd = image_new(FALSE); | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
91 g_object_set(G_OBJECT(imd->pr), "zoom_expand", FALSE, NULL); |
9 | 92 gtk_widget_set_size_request(imd->widget, DIALOG_DEF_IMAGE_DIM_X, DIALOG_DEF_IMAGE_DIM_Y); |
93 gtk_box_pack_start(GTK_BOX(vbox), imd->widget, TRUE, TRUE, 0); | |
138 | 94 image_change_fd(imd, fd1, 0.0); |
9 | 95 gtk_widget_show(imd->widget); |
96 | |
97 if (show_filename) | |
98 { | |
138 | 99 label = pref_label_new(vbox, (fd1 == NULL) ? "" : fd1->name); |
9 | 100 } |
101 | |
102 /* only the first image is stored (for use in gd_image_set) */ | |
103 g_object_set_data(G_OBJECT(gd->dialog), "img_image", imd); | |
104 g_object_set_data(G_OBJECT(gd->dialog), "img_label", label); | |
442 | 105 |
9 | 106 |
107 /* image 2 */ | |
108 | |
138 | 109 if (hbox && fd2) |
9 | 110 { |
111 vbox = pref_box_new(hbox, TRUE, GTK_ORIENTATION_VERTICAL, PREF_PAD_GAP); | |
112 | |
113 if (header2) | |
114 { | |
115 GtkWidget *head; | |
116 | |
117 head = pref_label_new(vbox, header2); | |
118 pref_label_bold(head, TRUE, FALSE); | |
119 gtk_misc_set_alignment(GTK_MISC(head), 0.0, 0.5); | |
120 } | |
121 | |
122 imd = image_new(FALSE); | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
123 g_object_set(G_OBJECT(imd->pr), "zoom_expand", FALSE, NULL); |
9 | 124 gtk_widget_set_size_request(imd->widget, DIALOG_DEF_IMAGE_DIM_X, DIALOG_DEF_IMAGE_DIM_Y); |
125 gtk_box_pack_start(GTK_BOX(vbox), imd->widget, TRUE, TRUE, 0); | |
138 | 126 image_change_fd(imd, fd2, 0.0); |
9 | 127 gtk_widget_show(imd->widget); |
128 | |
138 | 129 pref_label_new(vbox, fd2->name); |
9 | 130 } |
131 } | |
132 | |
138 | 133 static void generic_dialog_image_set(GenericDialog *gd, FileData *fd) |
9 | 134 { |
135 ImageWindow *imd; | |
136 GtkWidget *label; | |
442 | 137 |
9 | 138 imd = g_object_get_data(G_OBJECT(gd->dialog), "img_image"); |
139 label = g_object_get_data(G_OBJECT(gd->dialog), "img_label"); | |
140 | |
141 if (!imd) return; | |
142 | |
138 | 143 image_change_fd(imd, fd, 0.0); |
144 if (label) gtk_label_set_text(GTK_LABEL(label), fd->name); | |
9 | 145 } |
146 | |
147 /* | |
148 *-------------------------------------------------------------------------- | |
149 * Wrappers to aid in setting additional dialog properties (unde mouse, etc.) | |
150 *-------------------------------------------------------------------------- | |
151 */ | |
152 | |
153 GenericDialog *file_util_gen_dlg(const gchar *title, | |
154 const gchar *wmclass, const gchar *wmsubclass, | |
155 GtkWidget *parent, gint auto_close, | |
156 void (*cancel_cb)(GenericDialog *, gpointer), gpointer data) | |
157 { | |
158 GenericDialog *gd; | |
159 | |
160 gd = generic_dialog_new(title, wmclass, wmsubclass, parent, auto_close, cancel_cb, data); | |
318 | 161 if (options->place_dialogs_under_mouse) |
9 | 162 { |
163 gtk_window_set_position(GTK_WINDOW(gd->dialog), GTK_WIN_POS_MOUSE); | |
164 } | |
165 | |
166 return gd; | |
167 } | |
168 | |
169 FileDialog *file_util_file_dlg(const gchar *title, | |
170 const gchar *wmclass, const gchar *wmsubclass, | |
171 GtkWidget *parent, | |
172 void (*cancel_cb)(FileDialog *, gpointer), gpointer data) | |
173 { | |
138 | 174 FileDialog *fdlg; |
175 | |
176 fdlg = file_dialog_new(title, wmclass, wmsubclass, parent, cancel_cb, data); | |
318 | 177 if (options->place_dialogs_under_mouse) |
9 | 178 { |
138 | 179 gtk_window_set_position(GTK_WINDOW(GENERIC_DIALOG(fdlg)->dialog), GTK_WIN_POS_MOUSE); |
9 | 180 } |
181 | |
138 | 182 return fdlg; |
9 | 183 } |
184 | |
185 /* this warning dialog is copied from SLIK's ui_utildg.c, | |
186 * because it does not have a mouse center option, | |
187 * and we must center it before show, implement it here. | |
188 */ | |
189 static void file_util_warning_dialog_ok_cb(GenericDialog *gd, gpointer data) | |
190 { | |
191 /* no op */ | |
192 } | |
193 | |
194 GenericDialog *file_util_warning_dialog(const gchar *heading, const gchar *message, | |
195 const gchar *icon_stock_id, GtkWidget *parent) | |
196 { | |
197 GenericDialog *gd; | |
198 | |
254
9faf34f047b1
Make the wmclass value unique among the code by defining
zas_
parents:
223
diff
changeset
|
199 gd = file_util_gen_dlg(heading, GQ_WMCLASS, "warning", parent, TRUE, NULL, NULL); |
9 | 200 generic_dialog_add_message(gd, icon_stock_id, heading, message); |
201 generic_dialog_add_button(gd, GTK_STOCK_OK, NULL, file_util_warning_dialog_ok_cb, TRUE); | |
318 | 202 if (options->place_dialogs_under_mouse) |
9 | 203 { |
204 gtk_window_set_position(GTK_WINDOW(gd->dialog), GTK_WIN_POS_MOUSE); | |
205 } | |
206 gtk_widget_show(gd->dialog); | |
207 | |
208 return gd; | |
209 } | |
1 | 210 |
42
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
211 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
|
212 { |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
213 gint n; |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
214 |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
215 if (!name) return 0; |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
216 |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
217 n = strlen(name); |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
218 |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
219 if (filter_name_exists(name)) |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
220 { |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
221 const gchar *ext; |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
222 |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
223 ext = extension_from_path(name); |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
224 if (ext) n -= strlen(ext); |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
225 } |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
226 |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
227 return n; |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
228 } |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
229 |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
230 |
753 | 231 |
1 | 232 /* |
233 *-------------------------------------------------------------------------- | |
753 | 234 * call these when names change, files move, deleted, etc. |
235 * so that any open windows are also updated | |
1 | 236 *-------------------------------------------------------------------------- |
237 */ | |
238 | |
753 | 239 /* FIXME this is a temporary solution */ |
240 void file_data_notify_ci(FileData *fd) | |
140 | 241 { |
753 | 242 FileDataChangeType type = fd->change->type; |
243 switch (type) | |
140 | 244 { |
753 | 245 case FILEDATA_CHANGE_MOVE: |
246 cache_maint_moved(fd); | |
247 collection_maint_renamed(fd); | |
248 | |
249 layout_maint_moved(fd, NULL); | |
250 view_window_maint_moved(fd); | |
251 dupe_maint_renamed(fd); | |
252 search_maint_renamed(fd); | |
253 break; | |
254 case FILEDATA_CHANGE_COPY: | |
255 cache_maint_copied(fd); | |
256 break; | |
257 case FILEDATA_CHANGE_RENAME: | |
258 cache_maint_moved(fd); | |
259 collection_maint_renamed(fd); | |
260 | |
261 layout_maint_renamed(fd); | |
262 view_window_maint_moved(fd); | |
263 dupe_maint_renamed(fd); | |
264 search_maint_renamed(fd); | |
758 | 265 break; |
753 | 266 case FILEDATA_CHANGE_DELETE: |
267 layout_maint_removed(fd, NULL); | |
268 view_window_maint_removed(fd, NULL); | |
269 dupe_maint_removed(fd); | |
270 search_maint_removed(fd); | |
271 | |
272 collection_maint_removed(fd); | |
273 cache_maint_removed(fd); | |
274 break; | |
275 case FILEDATA_CHANGE_UNSPECIFIED: | |
276 /* FIXME */ | |
277 break; | |
140 | 278 } |
753 | 279 } |
280 | |
281 void file_data_sc_notify_ci(FileData *fd) | |
282 { | |
283 GList *work; | |
284 if (fd->parent) fd = fd->parent; | |
285 | |
286 file_data_notify_ci(fd); | |
287 | |
288 work = fd->sidecar_files; | |
289 while (work) | |
140 | 290 { |
753 | 291 FileData *sfd = work->data; |
292 file_data_notify_ci(sfd); | |
293 work = work->next; | |
140 | 294 } |
295 } | |
296 | |
297 | |
753 | 298 typedef enum { |
299 UTILITY_TYPE_COPY, | |
300 UTILITY_TYPE_MOVE, | |
301 UTILITY_TYPE_RENAME, | |
302 UTILITY_TYPE_EDITOR, | |
303 UTILITY_TYPE_FILTER, | |
304 UTILITY_TYPE_DELETE, | |
305 UTILITY_TYPE_DELETE_LINK, | |
306 UTILITY_TYPE_DELETE_FOLDER | |
307 } UtilityType; | |
308 | |
309 typedef enum { | |
310 UTILITY_PHASE_START = 0, | |
311 UTILITY_PHASE_ENTERING, | |
312 UTILITY_PHASE_CHECKED, | |
313 UTILITY_PHASE_DONE, | |
314 UTILITY_PHASE_CANCEL | |
315 } UtilityPhase; | |
316 | |
317 enum { | |
318 UTILITY_RENAME = 0, | |
319 UTILITY_RENAME_AUTO, | |
320 UTILITY_RENAME_FORMATTED | |
321 }; | |
322 | |
323 typedef struct _UtilityDataMessages UtilityDataMessages; | |
324 struct _UtilityDataMessages { | |
325 gchar *title; | |
326 gchar *question; | |
327 gchar *desc_flist; | |
328 gchar *desc_dlist; | |
329 gchar *desc_source_fd; | |
330 gchar *fail; | |
331 }; | |
332 | |
333 typedef struct _UtilityData UtilityData; | |
334 | |
335 struct _UtilityData { | |
336 UtilityType type; | |
337 UtilityPhase phase; | |
338 | |
339 FileData *source_fd; | |
340 GList *dlist; | |
341 GList *flist; | |
342 | |
343 GtkWidget *parent; | |
344 GenericDialog *gd; | |
345 FileDialog *fdlg; | |
346 | |
347 gint update_idle_id; | |
348 | |
349 /* alternative dialog parts */ | |
350 GtkWidget *notebook; | |
351 | |
352 UtilityDataMessages messages; | |
353 | |
354 /* helper entries for various modes */ | |
355 GtkWidget *rename_entry; | |
356 GtkWidget *rename_label; | |
357 GtkWidget *auto_entry_front; | |
358 GtkWidget *auto_entry_end; | |
359 GtkWidget *auto_spin_start; | |
360 GtkWidget *auto_spin_pad; | |
361 GtkWidget *format_entry; | |
362 GtkWidget *format_spin; | |
363 | |
364 GtkWidget *listview; | |
365 | |
366 | |
367 gchar *dest_path; | |
368 | |
369 /* data for the operation itself, internal or external */ | |
755 | 370 gboolean external; /* TRUE for external command, FALSE for internal */ |
753 | 371 |
372 gint external_command; | |
373 gpointer resume_data; | |
374 }; | |
375 | |
376 enum { | |
377 UTILITY_COLUMN_FD = 0, | |
378 UTILITY_COLUMN_PATH, | |
379 UTILITY_COLUMN_NAME, | |
380 UTILITY_COLUMN_SIDECARS, | |
381 UTILITY_COLUMN_DEST_PATH, | |
382 UTILITY_COLUMN_DEST_NAME, | |
383 UTILITY_COLUMN_COUNT | |
384 }; | |
385 | |
386 #define UTILITY_LIST_MIN_WIDTH 250 | |
387 #define UTILITY_LIST_MIN_HEIGHT 150 | |
388 | |
389 /* thumbnail spec has a max depth of 4 (.thumb??/fail/appname/??.png) */ | |
390 #define UTILITY_DELETE_MAX_DEPTH 5 | |
391 | |
392 static UtilityData *file_util_data_new(UtilityType type) | |
136 | 393 { |
753 | 394 UtilityData *ud; |
395 | |
396 ud = g_new0(UtilityData, 1); | |
397 ud->type = type; | |
398 ud->phase = UTILITY_PHASE_START; | |
399 ud->update_idle_id = -1; | |
400 ud->external_command = -1; | |
401 return ud; | |
402 } | |
403 | |
404 static void file_util_data_free(UtilityData *ud) | |
405 { | |
406 if (!ud) return; | |
407 | |
408 if (ud->update_idle_id != -1) g_source_remove(ud->update_idle_id); | |
409 | |
410 file_data_unref(ud->source_fd); | |
411 filelist_free(ud->dlist); | |
412 filelist_free(ud->flist); | |
413 | |
414 if (ud->gd) generic_dialog_close(ud->gd); | |
415 | |
416 g_free(ud->dest_path); | |
417 | |
418 g_free(ud); | |
419 } | |
420 | |
421 static GtkTreeViewColumn *file_util_dialog_add_list_column(GtkWidget *view, const gchar *text, gint n) | |
422 { | |
423 GtkTreeViewColumn *column; | |
424 GtkCellRenderer *renderer; | |
425 | |
426 column = gtk_tree_view_column_new(); | |
427 gtk_tree_view_column_set_title(column, text); | |
428 gtk_tree_view_column_set_min_width(column, 4); | |
429 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY); | |
430 renderer = gtk_cell_renderer_text_new(); | |
431 gtk_tree_view_column_pack_start(column, renderer, TRUE); | |
432 gtk_tree_view_column_add_attribute(column, renderer, "text", n); | |
433 gtk_tree_view_append_column(GTK_TREE_VIEW(view), column); | |
434 | |
435 return column; | |
436 } | |
437 | |
438 static void file_util_dialog_list_select(GtkWidget *view, gint n) | |
439 { | |
440 GtkTreeModel *store; | |
441 GtkTreeIter iter; | |
442 GtkTreeSelection *selection; | |
443 | |
444 store = gtk_tree_view_get_model(GTK_TREE_VIEW(view)); | |
445 if (gtk_tree_model_iter_nth_child(store, &iter, NULL, n)) | |
140 | 446 { |
753 | 447 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view)); |
448 gtk_tree_selection_select_iter(selection, &iter); | |
449 } | |
450 } | |
451 | |
452 static GtkWidget *file_util_dialog_add_list(GtkWidget *box, GList *list, gint full_paths) | |
453 { | |
454 GtkWidget *scrolled; | |
455 GtkWidget *view; | |
456 GtkListStore *store; | |
457 | |
458 scrolled = gtk_scrolled_window_new(NULL, NULL); | |
459 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN); | |
460 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), | |
461 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
462 gtk_box_pack_start(GTK_BOX(box), scrolled, TRUE, TRUE, 0); | |
463 gtk_widget_show(scrolled); | |
464 | |
465 store = gtk_list_store_new(UTILITY_COLUMN_COUNT, G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); | |
466 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); | |
467 g_object_unref(store); | |
468 | |
469 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), TRUE); | |
470 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(view), FALSE); | |
471 | |
472 if (full_paths) | |
473 { | |
474 file_util_dialog_add_list_column(view, _("Location"), UTILITY_COLUMN_PATH); | |
140 | 475 } |
138 | 476 else |
477 { | |
753 | 478 file_util_dialog_add_list_column(view, _("Name"), UTILITY_COLUMN_NAME); |
138 | 479 } |
480 | |
753 | 481 gtk_widget_set_size_request(view, UTILITY_LIST_MIN_WIDTH, UTILITY_LIST_MIN_HEIGHT); |
482 gtk_container_add(GTK_CONTAINER(scrolled), view); | |
483 gtk_widget_show(view); | |
136 | 484 |
140 | 485 while (list) |
486 { | |
487 FileData *fd = list->data; | |
753 | 488 GtkTreeIter iter; |
489 gchar *sidecars; | |
490 | |
491 sidecars = file_data_sc_list_to_string(fd); | |
492 | |
493 gtk_list_store_append(store, &iter); | |
757 | 494 gtk_list_store_set(store, &iter, |
495 UTILITY_COLUMN_FD, fd, | |
496 UTILITY_COLUMN_PATH, fd->path, | |
497 UTILITY_COLUMN_NAME, fd->name, | |
498 UTILITY_COLUMN_SIDECARS, sidecars, | |
499 UTILITY_COLUMN_DEST_PATH, fd->change ? fd->change->dest : "error", | |
500 UTILITY_COLUMN_DEST_NAME, fd->change ? filename_from_path(fd->change->dest) : "error", | |
501 -1); | |
753 | 502 g_free(sidecars); |
503 | |
140 | 504 list = list->next; |
505 } | |
753 | 506 |
507 return view; | |
508 } | |
509 | |
510 // FIXME | |
511 static void file_util_delete_dir_ok_cb(GenericDialog *gd, gpointer data); | |
512 | |
513 void file_util_perform_ci_internal(UtilityData *ud); | |
514 void file_util_dialog_run(UtilityData *ud); | |
515 static gint file_util_perform_ci_cb(gpointer resume_data, gint flags, GList *list, gpointer data); | |
516 | |
517 /* call file_util_perform_ci_internal or start_editor_from_filelist_full */ | |
518 | |
519 | |
520 static void file_util_resume_cb(GenericDialog *gd, gpointer data) | |
521 { | |
522 UtilityData *ud = data; | |
523 if (ud->external) | |
524 editor_resume(ud->resume_data); | |
525 else | |
526 file_util_perform_ci_internal(ud); | |
527 } | |
528 | |
529 static void file_util_abort_cb(GenericDialog *gd, gpointer data) | |
530 { | |
531 UtilityData *ud = data; | |
532 if (ud->external) | |
533 editor_skip(ud->resume_data); | |
534 else | |
535 file_util_perform_ci_cb(NULL, EDITOR_ERROR_SKIPPED, ud->flist, ud); | |
140 | 536 |
537 } | |
538 | |
539 | |
753 | 540 static gint file_util_perform_ci_cb(gpointer resume_data, gint flags, GList *list, gpointer data) |
1 | 541 { |
753 | 542 UtilityData *ud = data; |
543 ud->resume_data = resume_data; | |
497 | 544 |
140 | 545 gint ret = EDITOR_CB_CONTINUE; |
546 if ((flags & EDITOR_ERROR_MASK) && !(flags & EDITOR_ERROR_SKIPPED)) | |
547 { | |
757 | 548 GString *msg = g_string_new(editor_get_error_str(flags)); |
549 GenericDialog *d; | |
550 g_string_append(msg, "\n"); | |
551 g_string_append(msg, ud->messages.fail); | |
552 g_string_append(msg, "\n"); | |
553 while (list) | |
554 { | |
555 FileData *fd = list->data; | |
442 | 556 |
757 | 557 g_string_append(msg, fd->path); |
558 g_string_append(msg, "\n"); | |
559 list = list->next; | |
560 } | |
561 if (resume_data) | |
562 { | |
563 g_string_append(msg, _("\n Continue multiple file operation?")); | |
564 d = file_util_gen_dlg(ud->messages.fail, GQ_WMCLASS, "dlg_confirm", | |
565 NULL, TRUE, | |
566 file_util_abort_cb, ud); | |
140 | 567 |
757 | 568 generic_dialog_add_message(d, GTK_STOCK_DIALOG_WARNING, NULL, msg->str); |
140 | 569 |
757 | 570 generic_dialog_add_button(d, GTK_STOCK_GO_FORWARD, _("Co_ntinue"), |
571 file_util_resume_cb, TRUE); | |
572 gtk_widget_show(d->dialog); | |
573 ret = EDITOR_CB_SUSPEND; | |
574 } | |
575 else | |
576 { | |
577 file_util_warning_dialog(ud->messages.fail, msg->str, GTK_STOCK_DIALOG_ERROR, NULL); | |
578 } | |
579 g_string_free(msg, TRUE); | |
140 | 580 } |
442 | 581 |
582 | |
753 | 583 while (list) /* be careful, file_util_perform_ci_internal can pass ud->flist as list */ |
140 | 584 { |
753 | 585 FileData *fd = list->data; |
586 list = list->next; | |
587 | |
588 if (!(flags & EDITOR_ERROR_MASK)) /* files were successfully deleted, call the maint functions */ | |
761 | 589 { |
590 file_data_sc_apply_ci(fd); | |
753 | 591 file_data_sc_notify_ci(fd); |
761 | 592 } |
753 | 593 |
594 ud->flist = g_list_remove(ud->flist, fd); | |
595 file_data_sc_free_ci(fd); | |
596 file_data_unref(fd); | |
140 | 597 } |
753 | 598 |
599 if (!resume_data) /* end of the list */ | |
600 { | |
601 ud->phase = UTILITY_PHASE_DONE; | |
602 file_util_dialog_run(ud); | |
603 } | |
604 | |
140 | 605 return ret; |
606 } | |
607 | |
143
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
140
diff
changeset
|
608 |
753 | 609 /* |
756 | 610 * Perform the operation described by FileDataChangeInfo on all files in the list |
753 | 611 * it is an alternative to start_editor_from_filelist_full, it should use similar interface |
612 */ | |
143
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
140
diff
changeset
|
613 |
1 | 614 |
753 | 615 void file_util_perform_ci_internal(UtilityData *ud) |
616 { | |
617 | |
618 while (ud->flist) | |
1 | 619 { |
753 | 620 gint ret; |
621 | |
622 /* take a single entry each time, this allows better control over the operation */ | |
623 GList *single_entry = g_list_append(NULL, ud->flist->data); | |
624 gboolean last = !ud->flist->next; | |
757 | 625 gint status = EDITOR_ERROR_STATUS; |
626 | |
753 | 627 if (file_data_sc_perform_ci(single_entry->data)) |
757 | 628 status = 0; /* OK */ |
629 | |
630 ret = file_util_perform_ci_cb(GINT_TO_POINTER(!last), status, single_entry, ud); | |
753 | 631 g_list_free(single_entry); |
632 | |
633 if (ret == EDITOR_CB_SUSPEND || last) return; | |
634 | |
635 if (ret == EDITOR_CB_SKIP) | |
636 { | |
637 file_util_perform_ci_cb(NULL, EDITOR_ERROR_SKIPPED, ud->flist, ud); | |
638 } | |
639 | |
640 /* FIXME: convert the loop to idle call */ | |
641 | |
1 | 642 } |
643 } | |
644 | |
9 | 645 |
753 | 646 void file_util_perform_ci(UtilityData *ud) |
647 { | |
648 switch (ud->type) | |
649 { | |
650 case UTILITY_TYPE_COPY: | |
651 ud->external_command = CMD_COPY; | |
652 break; | |
653 case UTILITY_TYPE_MOVE: | |
654 ud->external_command = CMD_MOVE; | |
655 break; | |
656 case UTILITY_TYPE_RENAME: | |
657 ud->external_command = CMD_RENAME; | |
658 break; | |
659 case UTILITY_TYPE_DELETE: | |
660 case UTILITY_TYPE_DELETE_LINK: | |
661 case UTILITY_TYPE_DELETE_FOLDER: | |
662 ud->external_command = CMD_DELETE; | |
663 break; | |
664 case UTILITY_TYPE_FILTER: | |
665 case UTILITY_TYPE_EDITOR: | |
666 g_assert(ud->external_command != -1); /* it should be already set */ | |
667 break; | |
668 } | |
9 | 669 |
766
7148e125bf23
Check for existing editor command using is_valid_editor_command().
zas_
parents:
761
diff
changeset
|
670 if (is_valid_editor_command(ud->external_command)) |
9 | 671 { |
753 | 672 gint flags; |
757 | 673 |
753 | 674 ud->external = TRUE; |
757 | 675 flags = start_editor_from_filelist_full(ud->external_command, ud->flist, file_util_perform_ci_cb, ud); |
676 | |
677 if (flags) | |
9 | 678 { |
753 | 679 gchar *text = g_strdup_printf(_("%s\nUnable to start external command.\n"), editor_get_error_str(flags)); |
680 file_util_warning_dialog(ud->messages.fail, text, GTK_STOCK_DIALOG_ERROR, NULL); | |
681 g_free(text); | |
9 | 682 } |
683 } | |
684 else | |
685 { | |
753 | 686 ud->external = FALSE; |
687 file_util_perform_ci_internal(ud); | |
1 | 688 } |
689 } | |
690 | |
757 | 691 static void file_util_cancel_cb(GenericDialog *gd, gpointer data) |
753 | 692 { |
693 UtilityData *ud = data; | |
694 | |
695 generic_dialog_close(gd); | |
1 | 696 |
753 | 697 ud->gd = NULL; |
698 | |
699 ud->phase = UTILITY_PHASE_CANCEL; | |
700 file_util_dialog_run(ud); | |
1 | 701 } |
702 | |
757 | 703 static void file_util_ok_cb(GenericDialog *gd, gpointer data) |
1 | 704 { |
753 | 705 UtilityData *ud = data; |
706 | |
707 generic_dialog_close(gd); | |
708 | |
709 ud->gd = NULL; | |
138 | 710 |
753 | 711 file_util_dialog_run(ud); |
1 | 712 } |
713 | |
757 | 714 static void file_util_fdlg_cancel_cb(FileDialog *fdlg, gpointer data) |
1 | 715 { |
753 | 716 UtilityData *ud = data; |
675 | 717 |
753 | 718 file_dialog_close(fdlg); |
9 | 719 |
753 | 720 ud->fdlg = NULL; |
721 | |
722 ud->phase = UTILITY_PHASE_CANCEL; | |
723 file_util_dialog_run(ud); | |
724 } | |
9 | 725 |
757 | 726 static void file_util_fdlg_ok_cb(FileDialog *fdlg, gpointer data) |
753 | 727 { |
728 UtilityData *ud = data; | |
729 | |
730 file_dialog_close(fdlg); | |
731 | |
732 ud->fdlg = NULL; | |
9 | 733 |
753 | 734 file_util_dialog_run(ud); |
1 | 735 } |
736 | |
753 | 737 |
738 static void file_util_dest_folder_entry_cb(GtkWidget *entry, gpointer data) | |
1 | 739 { |
753 | 740 UtilityData *ud = data; |
741 | |
742 g_free(ud->dest_path); | |
743 ud->dest_path = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry))); | |
744 | |
745 switch (ud->type) | |
1 | 746 { |
753 | 747 case UTILITY_TYPE_COPY: |
748 file_data_sc_update_ci_copy_list(ud->flist, ud->dest_path); | |
749 break; | |
750 case UTILITY_TYPE_MOVE: | |
751 file_data_sc_update_ci_move_list(ud->flist, ud->dest_path); | |
752 break; | |
753 case UTILITY_TYPE_FILTER: | |
754 case UTILITY_TYPE_EDITOR: | |
755 file_data_sc_update_ci_unspecified_list(ud->flist, ud->dest_path); | |
756 break; | |
757 case UTILITY_TYPE_DELETE: | |
758 case UTILITY_TYPE_DELETE_LINK: | |
759 case UTILITY_TYPE_DELETE_FOLDER: | |
760 case UTILITY_TYPE_RENAME: | |
761 g_warning("unhandled operation"); | |
1 | 762 } |
763 } | |
764 | |
765 | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
766 /* 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
|
767 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
|
768 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
769 gchar *new_name; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
770 gchar *parsed; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
771 const gchar *ext; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
772 gchar *middle; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
773 gchar *tmp; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
774 gchar *pad_start; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
775 gchar *pad_end; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
776 gint padding; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
777 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
778 if (!format || !name) return NULL; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
779 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
780 tmp = g_strdup(format); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
781 pad_start = strchr(tmp, '#'); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
782 if (pad_start) |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
783 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
784 pad_end = pad_start; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
785 padding = 0; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
786 while (*pad_end == '#') |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
787 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
788 pad_end++; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
789 padding++; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
790 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
791 *pad_start = '\0'; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
792 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
793 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
|
794 g_free(tmp); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
795 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
796 else |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
797 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
798 parsed = tmp; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
799 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
800 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
801 ext = extension_from_path(name); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
802 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
803 middle = strchr(parsed, '*'); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
804 if (middle) |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
805 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
806 gchar *base; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
807 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
808 *middle = '\0'; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
809 middle++; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
810 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
811 base = remove_extension_from_path(name); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
812 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
|
813 g_free(base); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
814 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
815 else |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
816 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
817 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
|
818 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
819 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
820 g_free(parsed); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
821 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
822 return new_name; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
823 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
824 |
9 | 825 |
753 | 826 static void file_util_rename_preview_update(UtilityData *ud) |
1 | 827 { |
9 | 828 GtkTreeModel *store; |
753 | 829 GtkTreeSelection *selection; |
9 | 830 GtkTreeIter iter; |
831 const gchar *front; | |
832 const gchar *end; | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
833 const gchar *format; |
9 | 834 gint valid; |
835 gint start_n; | |
836 gint padding; | |
837 gint n; | |
753 | 838 gint mode; |
9 | 839 |
753 | 840 mode = gtk_notebook_get_current_page(GTK_NOTEBOOK(ud->notebook)); |
9 | 841 |
753 | 842 if (mode == UTILITY_RENAME) |
843 { | |
844 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(ud->listview)); | |
845 if (gtk_tree_selection_get_selected(selection, &store, &iter)) | |
846 { | |
847 FileData *fd; | |
848 const gchar *dest = gtk_entry_get_text(GTK_ENTRY(ud->rename_entry)); | |
849 | |
850 gtk_tree_model_get(store, &iter, UTILITY_COLUMN_FD, &fd, -1); | |
851 file_data_sc_update_ci_rename(fd, dest); | |
852 gtk_list_store_set(GTK_LIST_STORE(store), &iter, | |
853 UTILITY_COLUMN_DEST_PATH, fd->change->dest, | |
854 UTILITY_COLUMN_DEST_NAME, filename_from_path(fd->change->dest), | |
855 -1); | |
856 } | |
857 return; | |
858 } | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
859 |
753 | 860 |
861 front = gtk_entry_get_text(GTK_ENTRY(ud->auto_entry_front)); | |
862 end = gtk_entry_get_text(GTK_ENTRY(ud->auto_entry_end)); | |
863 padding = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ud->auto_spin_pad)); | |
864 | |
865 format = gtk_entry_get_text(GTK_ENTRY(ud->format_entry)); | |
866 | |
867 if (mode == UTILITY_RENAME_FORMATTED) | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
868 { |
753 | 869 start_n = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ud->format_spin)); |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
870 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
871 else |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
872 { |
753 | 873 start_n = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ud->auto_spin_start)); |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
874 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
875 |
753 | 876 store = gtk_tree_view_get_model(GTK_TREE_VIEW(ud->listview)); |
9 | 877 n = start_n; |
878 valid = gtk_tree_model_get_iter_first(store, &iter); | |
879 while (valid) | |
880 { | |
881 gchar *dest; | |
753 | 882 FileData *fd; |
883 gtk_tree_model_get(store, &iter, UTILITY_COLUMN_FD, &fd, -1); | |
9 | 884 |
753 | 885 if (mode == UTILITY_RENAME_FORMATTED) |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
886 { |
138 | 887 dest = file_util_rename_multiple_auto_format_name(format, fd->name, n); |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
888 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
889 else |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
890 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
891 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
|
892 } |
753 | 893 |
894 file_data_sc_update_ci_rename(fd, dest); | |
895 gtk_list_store_set(GTK_LIST_STORE(store), &iter, | |
896 UTILITY_COLUMN_DEST_PATH, fd->change->dest, | |
897 UTILITY_COLUMN_DEST_NAME, filename_from_path(fd->change->dest), | |
898 -1); | |
9 | 899 g_free(dest); |
900 | |
901 n++; | |
902 valid = gtk_tree_model_iter_next(store, &iter); | |
903 } | |
904 | |
1 | 905 } |
906 | |
753 | 907 static void file_util_rename_preview_entry_cb(GtkWidget *entry, gpointer data) |
9 | 908 { |
753 | 909 UtilityData *ud = data; |
910 file_util_rename_preview_update(ud); | |
911 } | |
9 | 912 |
753 | 913 static void file_util_rename_preview_adj_cb(GtkWidget *spin, gpointer data) |
914 { | |
915 UtilityData *ud = data; | |
916 file_util_rename_preview_update(ud); | |
917 } | |
9 | 918 |
753 | 919 static gboolean file_util_rename_idle_cb(gpointer data) |
920 { | |
921 UtilityData *ud = data; | |
922 | |
923 file_util_rename_preview_update(ud); | |
924 | |
925 ud->update_idle_id = -1; | |
9 | 926 return FALSE; |
927 } | |
928 | |
753 | 929 static void file_util_rename_preview_order_cb(GtkTreeModel *treemodel, GtkTreePath *tpath, |
9 | 930 GtkTreeIter *iter, gpointer data) |
931 { | |
753 | 932 UtilityData *ud = data; |
9 | 933 |
757 | 934 if (ud->update_idle_id != -1) return; |
935 | |
936 ud->update_idle_id = g_idle_add(file_util_rename_idle_cb, ud); | |
9 | 937 } |
938 | |
753 | 939 |
940 static gboolean file_util_preview_cb(GtkTreeSelection *selection, GtkTreeModel *store, | |
941 GtkTreePath *tpath, gboolean path_currently_selected, | |
942 gpointer data) | |
9 | 943 { |
753 | 944 UtilityData *ud = data; |
945 GtkTreeIter iter; | |
946 FileData *fd = NULL; | |
947 | |
948 if (path_currently_selected || | |
949 !gtk_tree_model_get_iter(store, &iter, tpath)) return TRUE; | |
950 | |
951 gtk_tree_model_get(store, &iter, UTILITY_COLUMN_FD, &fd, -1); | |
952 generic_dialog_image_set(ud->gd, fd); | |
953 | |
954 if (ud->type == UTILITY_TYPE_RENAME) | |
955 { | |
956 const gchar *name = filename_from_path(fd->change->dest); | |
757 | 957 |
753 | 958 gtk_widget_grab_focus(ud->rename_entry); |
959 gtk_label_set_text(GTK_LABEL(ud->rename_label), fd->name); | |
960 g_signal_handlers_block_by_func(ud->rename_entry, G_CALLBACK(file_util_rename_preview_entry_cb), ud); | |
961 gtk_entry_set_text(GTK_ENTRY(ud->rename_entry), name); | |
962 gtk_editable_select_region(GTK_EDITABLE(ud->rename_entry), 0, filename_base_length(name)); | |
963 g_signal_handlers_unblock_by_func(ud->rename_entry, G_CALLBACK(file_util_rename_preview_entry_cb), ud); | |
964 } | |
965 | |
966 return TRUE; | |
9 | 967 } |
968 | |
753 | 969 |
970 | |
971 static void box_append_safe_delete_status(GenericDialog *gd) | |
9 | 972 { |
753 | 973 GtkWidget *label; |
974 gchar *buf; | |
975 | |
976 buf = file_util_safe_delete_status(); | |
977 label = pref_label_new(gd->vbox, buf); | |
978 g_free(buf); | |
979 | |
980 gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); | |
981 gtk_widget_set_sensitive(label, FALSE); | |
9 | 982 } |
983 | |
753 | 984 |
985 static void file_util_dialog_init_simple_list(UtilityData *ud) | |
1 | 986 { |
753 | 987 GtkWidget *box; |
988 GtkTreeSelection *selection; | |
757 | 989 |
753 | 990 ud->gd = file_util_gen_dlg(ud->messages.title, GQ_WMCLASS, "dlg_confirm", |
757 | 991 ud->parent, FALSE, file_util_cancel_cb, ud); |
753 | 992 generic_dialog_add_button(ud->gd, GTK_STOCK_DELETE, NULL, file_util_ok_cb, TRUE); |
993 | |
994 box = generic_dialog_add_message(ud->gd, GTK_STOCK_DIALOG_QUESTION, | |
757 | 995 ud->messages.question, |
996 ud->messages.desc_flist); | |
753 | 997 |
998 box = pref_group_new(box, TRUE, ud->messages.desc_flist, GTK_ORIENTATION_HORIZONTAL); | |
999 | |
1000 ud->listview = file_util_dialog_add_list(box, ud->flist, FALSE); | |
1001 file_util_dialog_add_list_column(ud->listview, _("Sidecars"), UTILITY_COLUMN_SIDECARS); | |
9 | 1002 |
753 | 1003 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(ud->listview)); |
1004 gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE); | |
1005 gtk_tree_selection_set_select_function(selection, file_util_preview_cb, ud, NULL); | |
1006 | |
1007 generic_dialog_add_image(ud->gd, box, NULL, NULL, NULL, NULL, FALSE); | |
1008 | |
1009 box_append_safe_delete_status(ud->gd); | |
1010 | |
1011 gtk_widget_show(ud->gd->dialog); | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1012 |
753 | 1013 file_util_dialog_list_select(ud->listview, 0); |
1014 } | |
1015 | |
1016 static void file_util_dialog_init_dest_folder(UtilityData *ud) | |
1017 { | |
1018 FileDialog *fdlg; | |
1019 GtkWidget *label; | |
1020 const gchar *stock_id; | |
1021 | |
1022 if (ud->type == UTILITY_TYPE_COPY) | |
9 | 1023 { |
753 | 1024 stock_id = GTK_STOCK_COPY; |
1025 } | |
1026 else | |
1027 { | |
1028 stock_id = GTK_STOCK_OK; | |
9 | 1029 } |
1030 | |
753 | 1031 fdlg = file_util_file_dlg(ud->messages.title, GQ_WMCLASS, "dlg_dest_folder", ud->parent, |
757 | 1032 file_util_fdlg_cancel_cb, ud); |
753 | 1033 |
1034 ud->fdlg = fdlg; | |
1035 | |
1036 generic_dialog_add_message(GENERIC_DIALOG(fdlg), NULL, ud->messages.question, NULL); | |
1037 | |
1038 label = pref_label_new(GENERIC_DIALOG(fdlg)->vbox, _("Choose the destination folder.")); | |
1039 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); | |
1040 pref_spacer(GENERIC_DIALOG(fdlg)->vbox, 0); | |
1041 | |
1042 file_dialog_add_button(fdlg, stock_id, ud->messages.title, file_util_fdlg_ok_cb, TRUE); | |
1043 | |
1044 file_dialog_add_path_widgets(fdlg, NULL, ud->dest_path, "move_copy", NULL, NULL); | |
1045 | |
1046 g_signal_connect(G_OBJECT(fdlg->entry), "changed", | |
1047 G_CALLBACK(file_util_dest_folder_entry_cb), ud); | |
1048 | |
1049 gtk_widget_show(GENERIC_DIALOG(fdlg)->dialog); | |
9 | 1050 } |
1051 | |
753 | 1052 |
9 | 1053 static GtkWidget *furm_simple_vlabel(GtkWidget *box, const gchar *text, gint expand) |
1054 { | |
1055 GtkWidget *vbox; | |
1056 GtkWidget *label; | |
1057 | |
1058 vbox = gtk_vbox_new(FALSE, 0); | |
1059 gtk_box_pack_start(GTK_BOX(box), vbox, expand, expand, 0); | |
1060 gtk_widget_show(vbox); | |
1061 | |
1062 label = gtk_label_new(text); | |
1063 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
1064 gtk_widget_show(label); | |
1065 | |
1066 return vbox; | |
1067 } | |
1068 | |
753 | 1069 |
1070 static void file_util_dialog_init_source_dest(UtilityData *ud) | |
9 | 1071 { |
753 | 1072 GtkTreeModel *store; |
9 | 1073 GtkTreeSelection *selection; |
753 | 1074 GtkWidget *box; |
9 | 1075 GtkWidget *hbox; |
1076 GtkWidget *box2; | |
1077 GtkWidget *table; | |
1078 GtkWidget *combo; | |
753 | 1079 GtkWidget *page; |
1 | 1080 |
753 | 1081 ud->gd = file_util_gen_dlg(ud->messages.title, GQ_WMCLASS, "dlg_confirm", |
757 | 1082 ud->parent, FALSE, file_util_cancel_cb, ud); |
138 | 1083 |
753 | 1084 box = generic_dialog_add_message(ud->gd, NULL, ud->messages.question, NULL); |
1085 generic_dialog_add_button(ud->gd, GTK_STOCK_OK, ud->messages.title, file_util_ok_cb, TRUE); | |
9 | 1086 |
753 | 1087 box = pref_group_new(box, TRUE, ud->messages.desc_flist, GTK_ORIENTATION_HORIZONTAL); |
9 | 1088 |
753 | 1089 ud->listview = file_util_dialog_add_list(box, ud->flist, FALSE); |
1090 file_util_dialog_add_list_column(ud->listview, _("Sidecars"), UTILITY_COLUMN_SIDECARS); | |
442 | 1091 |
753 | 1092 file_util_dialog_add_list_column(ud->listview, _("New name"), UTILITY_COLUMN_DEST_NAME); |
1 | 1093 |
753 | 1094 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(ud->listview)); |
1095 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_SINGLE); | |
1096 gtk_tree_selection_set_select_function(selection, file_util_preview_cb, ud, NULL); | |
9 | 1097 |
1098 | |
753 | 1099 // column = file_util_rename_multiple_add_column(rd, _("Preview"), RENAME_COLUMN_PREVIEW); |
1100 // gtk_tree_view_column_set_visible(column, FALSE); | |
442 | 1101 |
753 | 1102 gtk_tree_view_set_reorderable(GTK_TREE_VIEW(ud->listview), TRUE); |
1103 | |
1104 store = gtk_tree_view_get_model(GTK_TREE_VIEW(ud->listview)); | |
9 | 1105 g_signal_connect(G_OBJECT(store), "row_changed", |
753 | 1106 G_CALLBACK(file_util_rename_preview_order_cb), ud); |
1107 gtk_widget_set_size_request(ud->listview, 300, 150); | |
1 | 1108 |
753 | 1109 generic_dialog_add_image(ud->gd, box, NULL, NULL, NULL, NULL, FALSE); |
9 | 1110 |
753 | 1111 // gtk_container_add(GTK_CONTAINER(scrolled), view); |
1112 gtk_widget_show(ud->gd->dialog); | |
9 | 1113 |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1114 |
753 | 1115 ud->notebook = gtk_notebook_new(); |
1116 | |
1117 gtk_box_pack_start(GTK_BOX(ud->gd->vbox), ud->notebook, FALSE, FALSE, 0); | |
1118 gtk_widget_show(ud->notebook); | |
1119 | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1120 |
753 | 1121 page = gtk_vbox_new(FALSE, PREF_PAD_GAP); |
1122 gtk_notebook_append_page(GTK_NOTEBOOK(ud->notebook), page, gtk_label_new(_("Manual rename"))); | |
1123 gtk_widget_show(page); | |
1124 | |
1125 table = pref_table_new(page, 2, 2, FALSE, FALSE); | |
9 | 1126 |
1127 pref_table_label(table, 0, 0, _("Original name:"), 1.0); | |
753 | 1128 ud->rename_label = pref_table_label(table, 1, 0, "", 0.0); |
9 | 1129 |
1130 pref_table_label(table, 0, 1, _("New name:"), 1.0); | |
1131 | |
753 | 1132 ud->rename_entry = gtk_entry_new(); |
1133 gtk_table_attach(GTK_TABLE(table), ud->rename_entry, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0); | |
1134 generic_dialog_attach_default(GENERIC_DIALOG(ud->gd), ud->rename_entry); | |
1135 gtk_widget_grab_focus(ud->rename_entry); | |
1136 | |
1137 g_signal_connect(G_OBJECT(ud->rename_entry), "changed", | |
1138 G_CALLBACK(file_util_rename_preview_entry_cb), ud); | |
42
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
1139 |
753 | 1140 gtk_widget_show(ud->rename_entry); |
9 | 1141 |
753 | 1142 page = gtk_vbox_new(FALSE, PREF_PAD_GAP); |
1143 gtk_notebook_append_page(GTK_NOTEBOOK(ud->notebook), page, gtk_label_new(_("Auto rename"))); | |
1144 gtk_widget_show(page); | |
9 | 1145 |
753 | 1146 |
1147 hbox = pref_box_new(page, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_GAP); | |
9 | 1148 |
1149 box2 = furm_simple_vlabel(hbox, _("Begin text"), TRUE); | |
1150 | |
753 | 1151 combo = history_combo_new(&ud->auto_entry_front, "", "numerical_rename_prefix", -1); |
1152 g_signal_connect(G_OBJECT(ud->auto_entry_front), "changed", | |
1153 G_CALLBACK(file_util_rename_preview_entry_cb), ud); | |
9 | 1154 gtk_box_pack_start(GTK_BOX(box2), combo, TRUE, TRUE, 0); |
1155 gtk_widget_show(combo); | |
442 | 1156 |
9 | 1157 box2 = furm_simple_vlabel(hbox, _("Start #"), FALSE); |
1158 | |
753 | 1159 ud->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
|
1160 0.0, 1000000.0, 1.0, 0, 1.0, |
753 | 1161 G_CALLBACK(file_util_rename_preview_adj_cb), ud); |
9 | 1162 |
1163 box2 = furm_simple_vlabel(hbox, _("End text"), TRUE); | |
1164 | |
753 | 1165 combo = history_combo_new(&ud->auto_entry_end, "", "numerical_rename_suffix", -1); |
1166 g_signal_connect(G_OBJECT(ud->auto_entry_end), "changed", | |
1167 G_CALLBACK(file_util_rename_preview_entry_cb), ud); | |
9 | 1168 gtk_box_pack_start(GTK_BOX(box2), combo, TRUE, TRUE, 0); |
1169 gtk_widget_show(combo); | |
1170 | |
753 | 1171 ud->auto_spin_pad = pref_spin_new(page, _("Padding:"), NULL, |
9 | 1172 1.0, 8.0, 1.0, 0, 1.0, |
753 | 1173 G_CALLBACK(file_util_rename_preview_adj_cb), ud); |
9 | 1174 |
753 | 1175 page = gtk_vbox_new(FALSE, PREF_PAD_GAP); |
1176 gtk_notebook_append_page(GTK_NOTEBOOK(ud->notebook), page, gtk_label_new(_("Formatted rename"))); | |
1177 gtk_widget_show(page); | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1178 |
753 | 1179 hbox = pref_box_new(page, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_GAP); |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1180 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1181 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
|
1182 |
753 | 1183 combo = history_combo_new(&ud->format_entry, "", "auto_rename_format", -1); |
1184 g_signal_connect(G_OBJECT(ud->format_entry), "changed", | |
1185 G_CALLBACK(file_util_rename_preview_entry_cb), ud); | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1186 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
|
1187 gtk_widget_show(combo); |
442 | 1188 |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1189 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
|
1190 |
753 | 1191 ud->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
|
1192 0.0, 1000000.0, 1.0, 0, 1.0, |
753 | 1193 G_CALLBACK(file_util_rename_preview_adj_cb), ud); |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1194 |
753 | 1195 // gtk_combo_box_set_active(GTK_COMBO_BOX(ud->combo_type), 0); /* callback will take care of the rest */ |
138 | 1196 |
753 | 1197 file_util_dialog_list_select(ud->listview, 0); |
1 | 1198 } |
1199 | |
9 | 1200 |
753 | 1201 void file_util_dialog_run(UtilityData *ud) |
1 | 1202 { |
753 | 1203 switch (ud->phase) |
1204 { | |
1205 case UTILITY_PHASE_START: | |
1206 /* create the dialogs */ | |
1207 switch (ud->type) | |
1208 { | |
1209 case UTILITY_TYPE_DELETE: | |
1210 case UTILITY_TYPE_DELETE_LINK: | |
1211 case UTILITY_TYPE_DELETE_FOLDER: | |
1212 case UTILITY_TYPE_EDITOR: | |
1213 file_util_dialog_init_simple_list(ud); | |
1214 break; | |
1215 case UTILITY_TYPE_RENAME: | |
1216 file_util_dialog_init_source_dest(ud); | |
1217 break; | |
1218 case UTILITY_TYPE_COPY: | |
1219 case UTILITY_TYPE_MOVE: | |
1220 case UTILITY_TYPE_FILTER: | |
1221 file_util_dialog_init_dest_folder(ud); | |
1222 break; | |
1223 } | |
1224 ud->phase = UTILITY_PHASE_ENTERING; | |
1225 break; | |
1226 case UTILITY_PHASE_ENTERING: | |
1227 /* FIXME use file_data_sc_check_ci_dest to detect problems and eventually go back to PHASE_START | |
1228 or to PHASE_CANCEL */ | |
1229 | |
1230 ud->phase = UTILITY_PHASE_CHECKED; | |
1231 case UTILITY_PHASE_CHECKED: | |
1232 file_util_perform_ci(ud); | |
1233 break; | |
1234 case UTILITY_PHASE_CANCEL: | |
1235 case UTILITY_PHASE_DONE: | |
1236 file_data_sc_free_ci_list(ud->flist); | |
1237 file_data_sc_free_ci_list(ud->dlist); | |
1238 if (ud->source_fd) file_data_sc_free_ci(ud->source_fd); | |
1239 file_util_data_free(ud); | |
1240 break; | |
1241 } | |
1 | 1242 } |
1243 | |
753 | 1244 |
1245 | |
1246 | |
1247 static gint file_util_unlink(FileData *fd) | |
1 | 1248 { |
1249 } | |
1250 | |
757 | 1251 static void file_util_warn_op_in_progress(const gchar *title) |
1252 { | |
1253 file_util_warning_dialog(title, _("Another operation in progress.\n"), GTK_STOCK_DIALOG_ERROR, NULL); | |
1254 } | |
9 | 1255 |
753 | 1256 static void file_util_delete_full(FileData *source_fd, GList *source_list, GtkWidget *parent, UtilityPhase phase) |
1257 { | |
1258 UtilityData *ud; | |
1259 GList *flist = filelist_copy(source_list); | |
1260 | |
1261 if (source_fd) | |
1262 flist = g_list_append(flist, file_data_ref(source_fd)); | |
9 | 1263 |
753 | 1264 if (!file_data_sc_add_ci_delete_list(flist)) |
1265 { | |
757 | 1266 file_util_warn_op_in_progress(_("File deletion failed")); |
753 | 1267 filelist_free(flist); |
1 | 1268 return; |
1269 } | |
753 | 1270 |
1271 ud = file_util_data_new(UTILITY_TYPE_DELETE); | |
1272 | |
1273 ud->phase = phase; | |
138 | 1274 |
753 | 1275 ud->source_fd = NULL; |
1276 ud->flist = flist; | |
1277 ud->dlist = NULL; | |
1278 ud->parent = parent; | |
1279 | |
1280 ud->messages.title = _("Delete"); | |
1281 ud->messages.question = _("Delete files?"); | |
1282 ud->messages.desc_flist = _("This will delete the following files"); | |
1283 ud->messages.desc_dlist = ""; | |
1284 ud->messages.desc_source_fd = ""; | |
1285 ud->messages.fail = _("File deletion failed"); | |
1286 | |
1287 file_util_dialog_run(ud); | |
1 | 1288 } |
1289 | |
753 | 1290 static void file_util_move_full(FileData *source_fd, GList *source_list, const gchar *dest_path, GtkWidget *parent, UtilityPhase phase) |
1 | 1291 { |
753 | 1292 UtilityData *ud; |
1293 GList *flist = filelist_copy(source_list); | |
1294 | |
1295 if (source_fd) | |
1296 flist = g_list_append(flist, file_data_ref(source_fd)); | |
1297 | |
1298 if (!file_data_sc_add_ci_move_list(flist, dest_path)) | |
1299 { | |
757 | 1300 file_util_warn_op_in_progress(_("Move failed")); |
753 | 1301 filelist_free(flist); |
1302 return; | |
1303 } | |
1304 | |
1305 ud = file_util_data_new(UTILITY_TYPE_MOVE); | |
1306 | |
1307 ud->phase = phase; | |
1308 | |
1309 ud->source_fd = NULL; | |
1310 ud->flist = flist; | |
1311 ud->dlist = NULL; | |
1312 ud->parent = parent; | |
9 | 1313 |
753 | 1314 ud->dest_path = g_strdup(dest_path ? dest_path : ""); |
1315 | |
1316 ud->messages.title = _("Move"); | |
1317 ud->messages.question = _("Move files?"); | |
1318 ud->messages.desc_flist = _("This will move the following files"); | |
1319 ud->messages.desc_dlist = ""; | |
1320 ud->messages.desc_source_fd = ""; | |
1321 ud->messages.fail = _("Move failed"); | |
138 | 1322 |
753 | 1323 file_util_dialog_run(ud); |
1324 } | |
1325 static void file_util_copy_full(FileData *source_fd, GList *source_list, const gchar *dest_path, GtkWidget *parent, UtilityPhase phase) | |
1326 { | |
1327 UtilityData *ud; | |
1328 GList *flist = filelist_copy(source_list); | |
1329 | |
1330 if (source_fd) | |
1331 flist = g_list_append(flist, file_data_ref(source_fd)); | |
1332 | |
1333 if (!file_data_sc_add_ci_copy_list(flist, dest_path)) | |
1 | 1334 { |
757 | 1335 file_util_warn_op_in_progress(_("Copy failed")); |
753 | 1336 filelist_free(flist); |
1 | 1337 return; |
1338 } | |
1339 | |
753 | 1340 ud = file_util_data_new(UTILITY_TYPE_COPY); |
1341 | |
1342 ud->phase = phase; | |
1343 | |
1344 ud->source_fd = NULL; | |
1345 ud->flist = flist; | |
1346 ud->dlist = NULL; | |
1347 ud->parent = parent; | |
9 | 1348 |
753 | 1349 ud->dest_path = g_strdup(dest_path ? dest_path : ""); |
1350 | |
1351 ud->messages.title = _("Copy"); | |
1352 ud->messages.question = _("Copy files?"); | |
1353 ud->messages.desc_flist = _("This will copy the following files"); | |
1354 ud->messages.desc_dlist = ""; | |
1355 ud->messages.desc_source_fd = ""; | |
1356 ud->messages.fail = _("Copy failed"); | |
1 | 1357 |
753 | 1358 file_util_dialog_run(ud); |
9 | 1359 } |
1360 | |
753 | 1361 static void file_util_rename_full(FileData *source_fd, GList *source_list, const gchar *dest_path, GtkWidget *parent, UtilityPhase phase) |
1 | 1362 { |
753 | 1363 UtilityData *ud; |
1364 GList *flist = filelist_copy(source_list); | |
1365 | |
1366 if (source_fd) | |
1367 flist = g_list_append(flist, file_data_ref(source_fd)); | |
138 | 1368 |
753 | 1369 if (!file_data_sc_add_ci_rename_list(flist, dest_path)) |
1370 { | |
757 | 1371 file_util_warn_op_in_progress(_("Rename failed")); |
753 | 1372 filelist_free(flist); |
1373 return; | |
1374 } | |
9 | 1375 |
753 | 1376 ud = file_util_data_new(UTILITY_TYPE_RENAME); |
138 | 1377 |
753 | 1378 ud->phase = phase; |
1 | 1379 |
753 | 1380 ud->source_fd = NULL; |
1381 ud->flist = flist; | |
1382 ud->dlist = NULL; | |
1383 ud->parent = parent; | |
1384 | |
1385 ud->messages.title = _("Rename"); | |
1386 ud->messages.question = _("Rename files?"); | |
1387 ud->messages.desc_flist = _("This will rename the following files"); | |
1388 ud->messages.desc_dlist = ""; | |
1389 ud->messages.desc_source_fd = ""; | |
1390 ud->messages.fail = _("Rename failed"); | |
138 | 1391 |
753 | 1392 file_util_dialog_run(ud); |
1 | 1393 } |
1394 | |
753 | 1395 static void file_util_start_editor_full(gint n, FileData *source_fd, GList *source_list, const gchar *dest_path, GtkWidget *parent, UtilityPhase phase) |
1396 { | |
1397 UtilityData *ud; | |
1398 GList *flist = filelist_copy(source_list); | |
1399 | |
1400 if (source_fd) | |
1401 flist = g_list_append(flist, file_data_ref(source_fd)); | |
1 | 1402 |
753 | 1403 if (!file_data_sc_add_ci_unspecified_list(flist, dest_path)) |
1 | 1404 { |
757 | 1405 file_util_warn_op_in_progress(_("Can't run external editor")); |
753 | 1406 filelist_free(flist); |
1407 return; | |
1 | 1408 } |
9 | 1409 |
753 | 1410 if (editor_is_filter(n)) |
1411 ud = file_util_data_new(UTILITY_TYPE_FILTER); | |
1412 else | |
1413 ud = file_util_data_new(UTILITY_TYPE_EDITOR); | |
1414 | |
1415 | |
1416 /* ask for destination if we don't have it */ | |
1417 if (ud->type == UTILITY_TYPE_FILTER && dest_path == NULL) phase = UTILITY_PHASE_START; | |
1418 | |
1419 ud->phase = phase; | |
1420 | |
1421 ud->external_command = n; | |
1422 | |
1423 ud->source_fd = NULL; | |
1424 ud->flist = flist; | |
1425 ud->dlist = NULL; | |
1426 ud->parent = parent; | |
1427 | |
1428 ud->dest_path = g_strdup(dest_path ? dest_path : ""); | |
1429 | |
1430 ud->messages.title = _("Editor"); | |
1431 ud->messages.question = _("Run editor?"); | |
1432 ud->messages.desc_flist = _("This will copy the following files"); | |
1433 ud->messages.desc_dlist = ""; | |
1434 ud->messages.desc_source_fd = ""; | |
1435 ud->messages.fail = _("External command failed"); | |
1436 | |
1437 file_util_dialog_run(ud); | |
1 | 1438 } |
1439 | |
753 | 1440 |
1441 /* FIXME: */ | |
1442 void file_util_create_dir(const gchar *path, GtkWidget *parent) | |
1 | 1443 { |
1444 } | |
757 | 1445 |
753 | 1446 gint file_util_rename_dir(FileData *source_fd, const gchar *new_path, GtkWidget *parent) |
9 | 1447 { |
1448 } | |
1449 | |
757 | 1450 /* full-featured entry points |
753 | 1451 */ |
1 | 1452 |
753 | 1453 void file_util_delete(FileData *source_fd, GList *source_list, GtkWidget *parent) |
1454 { | |
1455 file_util_delete_full(source_fd, source_list, parent, UTILITY_PHASE_START); | |
1456 } | |
9 | 1457 |
753 | 1458 void file_util_copy(FileData *source_fd, GList *source_list, const gchar *dest_path, GtkWidget *parent) |
1459 { | |
1460 file_util_copy_full(source_fd, source_list, dest_path, parent, UTILITY_PHASE_START); | |
1461 } | |
757 | 1462 |
753 | 1463 void file_util_move(FileData *source_fd, GList *source_list, const gchar *dest_path, GtkWidget *parent) |
1464 { | |
1465 file_util_move_full(source_fd, source_list, dest_path, parent, UTILITY_PHASE_START); | |
1466 } | |
757 | 1467 |
753 | 1468 void file_util_rename(FileData *source_fd, GList *source_list, GtkWidget *parent) |
1469 { | |
1470 file_util_rename_full(source_fd, source_list, NULL, parent, UTILITY_PHASE_START); | |
1 | 1471 } |
1472 | |
753 | 1473 /* these avoid the location entry dialog unless there is an error, list must be files only and |
1474 * dest_path must be a valid directory path | |
757 | 1475 */ |
753 | 1476 void file_util_move_simple(GList *list, const gchar *dest_path, GtkWidget *parent) |
44
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
1477 { |
753 | 1478 file_util_move_full(NULL, list, dest_path, parent, UTILITY_PHASE_ENTERING); |
1479 } | |
757 | 1480 |
753 | 1481 void file_util_copy_simple(GList *list, const gchar *dest_path, GtkWidget *parent) |
1482 { | |
1483 file_util_copy_full(NULL, list, dest_path, parent, UTILITY_PHASE_ENTERING); | |
1484 } | |
757 | 1485 |
753 | 1486 void file_util_rename_simple(FileData *fd, const gchar *dest_path, GtkWidget *parent) |
1487 { | |
1488 file_util_rename_full(fd, NULL, dest_path, parent, UTILITY_PHASE_ENTERING); | |
1489 } | |
138 | 1490 |
44
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
1491 |
753 | 1492 void file_util_start_editor_from_file(gint n, FileData *fd, GtkWidget *parent) |
1493 { | |
1494 file_util_start_editor_full(n, fd, NULL, NULL, parent, UTILITY_PHASE_ENTERING); | |
1495 } | |
1496 | |
1497 void file_util_start_editor_from_filelist(gint n, GList *list, GtkWidget *parent) | |
1498 { | |
1499 file_util_start_editor_full(n, NULL, list, NULL, parent, UTILITY_PHASE_ENTERING); | |
1500 } | |
44
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
1501 |
753 | 1502 void file_util_start_filter_from_file(gint n, FileData *fd, const gchar *dest_path, GtkWidget *parent) |
1503 { | |
1504 file_util_start_editor_full(n, fd, NULL, dest_path, parent, UTILITY_PHASE_ENTERING); | |
1505 } | |
44
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
1506 |
753 | 1507 void file_util_start_filter_from_filelist(gint n, GList *list, const gchar *dest_path, GtkWidget *parent) |
1508 { | |
1509 file_util_start_editor_full(n, NULL, list, dest_path, parent, UTILITY_PHASE_ENTERING); | |
1510 } | |
44
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
1511 |
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
1512 |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1513 /* |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1514 *-------------------------------------------------------------------------- |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1515 * Delete directory routines |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1516 *-------------------------------------------------------------------------- |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1517 */ |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1518 |
753 | 1519 // FIXME |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1520 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1521 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1522 |
138 | 1523 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
|
1524 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1525 GList *dlist = NULL; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1526 GList *flist = NULL; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1527 GList *work; |
138 | 1528 FileData *fail = NULL; |
1529 | |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
497
diff
changeset
|
1530 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
|
1531 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1532 level++; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1533 if (level > UTILITY_DELETE_MAX_DEPTH) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1534 { |
673
fbebf5cf4a55
Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents:
671
diff
changeset
|
1535 log_printf("folder recursion depth past %d, giving up\n", UTILITY_DELETE_MAX_DEPTH); |
138 | 1536 return file_data_ref(fd); |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1537 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1538 |
138 | 1539 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
|
1540 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1541 work = dlist; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1542 while (work && !fail) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1543 { |
138 | 1544 FileData *lfd; |
1545 | |
1546 lfd = work->data; | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1547 work = work->next; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1548 |
138 | 1549 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
|
1550 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1551 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1552 work = flist; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1553 while (work && !fail) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1554 { |
138 | 1555 FileData *lfd; |
1556 | |
1557 lfd = work->data; | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1558 work = work->next; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1559 |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
497
diff
changeset
|
1560 DEBUG_1("deltree child: %s", lfd->path); |
138 | 1561 |
1562 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
|
1563 { |
138 | 1564 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
|
1565 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1566 else |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1567 { |
138 | 1568 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
|
1569 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1570 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1571 |
138 | 1572 filelist_free(dlist); |
1573 filelist_free(flist); | |
1574 | |
1575 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
|
1576 { |
138 | 1577 fail = file_data_ref(fd); |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1578 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1579 |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
497
diff
changeset
|
1580 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
|
1581 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1582 return fail; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1583 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1584 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1585 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
|
1586 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1587 UtilityData *ud = data; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1588 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1589 ud->gd = NULL; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1590 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1591 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
|
1592 { |
138 | 1593 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
|
1594 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1595 gchar *text; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1596 |
138 | 1597 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
|
1598 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
|
1599 GTK_STOCK_DIALOG_ERROR, NULL); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1600 g_free(text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1601 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1602 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1603 else |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1604 { |
138 | 1605 FileData *fail = NULL; |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1606 GList *work; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1607 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1608 work = ud->dlist; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1609 while (work && !fail) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1610 { |
138 | 1611 FileData *fd; |
1612 | |
1613 fd = work->data; | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1614 work = work->next; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1615 |
138 | 1616 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
|
1617 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1618 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1619 work = ud->flist; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1620 while (work && !fail) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1621 { |
138 | 1622 FileData *fd; |
1623 | |
1624 fd = work->data; | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1625 work = work->next; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1626 |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
497
diff
changeset
|
1627 DEBUG_1("deltree unlink: %s", fd->path); |
138 | 1628 |
1629 if (islink(fd->path)) | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1630 { |
138 | 1631 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
|
1632 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1633 else |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1634 { |
138 | 1635 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
|
1636 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1637 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1638 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1639 if (!fail) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1640 { |
138 | 1641 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
|
1642 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1643 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1644 if (fail) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1645 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1646 gchar *text; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1647 |
138 | 1648 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
|
1649 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
|
1650 g_free(text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1651 |
138 | 1652 if (fail != ud->source_fd) |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1653 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1654 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
|
1655 text = g_strdup_printf(_("Removal of folder contents failed at this file:\n\n%s"), |
138 | 1656 fail->path); |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1657 pref_label_new(gd->vbox, text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1658 g_free(text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1659 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1660 |
138 | 1661 file_data_unref(fail); |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1662 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1663 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1664 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1665 file_util_data_free(ud); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1666 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1667 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1668 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
|
1669 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1670 GList *rlist = NULL; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1671 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1672 while (dlist) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1673 { |
138 | 1674 FileData *fd; |
1675 | |
1676 fd = dlist->data; | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1677 dlist = dlist->next; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1678 |
138 | 1679 if (!fd->name || |
1680 (strcmp(fd->name, THUMB_FOLDER_GLOBAL) != 0 && | |
1681 strcmp(fd->name, THUMB_FOLDER_LOCAL) != 0 && | |
283 | 1682 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
|
1683 { |
138 | 1684 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
|
1685 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1686 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1687 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1688 return g_list_reverse(rlist); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1689 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1690 |
138 | 1691 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
|
1692 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1693 GList *dlist = NULL; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1694 GList *flist = NULL; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1695 GList *rlist; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1696 |
138 | 1697 if (!isdir(fd->path)) return; |
1698 | |
1699 if (islink(fd->path)) | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1700 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1701 UtilityData *ud; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1702 gchar *text; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1703 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1704 ud = g_new0(UtilityData, 1); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1705 ud->type = UTILITY_TYPE_DELETE_LINK; |
138 | 1706 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
|
1707 ud->dlist = NULL; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1708 ud->flist = NULL; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1709 |
254
9faf34f047b1
Make the wmclass value unique among the code by defining
zas_
parents:
223
diff
changeset
|
1710 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
|
1711 parent, TRUE, |
757 | 1712 file_util_cancel_cb, ud); |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1713 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1714 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
|
1715 "The folder this link points to will not be deleted."), |
757 | 1716 fd->path); |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1717 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
|
1718 _("Delete symbolic link to folder?"), |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1719 text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1720 g_free(text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1721 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1722 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
|
1723 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1724 gtk_widget_show(ud->gd->dialog); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1725 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1726 return; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1727 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1728 |
138 | 1729 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
|
1730 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1731 gchar *text; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1732 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1733 text = g_strdup_printf(_("Unable to remove folder %s\n" |
138 | 1734 "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
|
1735 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
|
1736 g_free(text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1737 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1738 return; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1739 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1740 |
138 | 1741 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
|
1742 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1743 gchar *text; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1744 |
138 | 1745 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
|
1746 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
|
1747 g_free(text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1748 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1749 return; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1750 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1751 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1752 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
|
1753 if (rlist) |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1754 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1755 GenericDialog *gd; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1756 GtkWidget *box; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1757 gchar *text; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1758 |
254
9faf34f047b1
Make the wmclass value unique among the code by defining
zas_
parents:
223
diff
changeset
|
1759 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
|
1760 parent, TRUE, NULL, NULL); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1761 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
|
1762 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1763 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
|
1764 "This folder contains subfolders which must be moved before it can be deleted."), |
138 | 1765 fd->path); |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1766 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
|
1767 _("Folder contains subfolders"), |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1768 text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1769 g_free(text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1770 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1771 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
|
1772 |
138 | 1773 rlist = filelist_sort_path(rlist); |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1774 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
|
1775 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1776 gtk_widget_show(gd->dialog); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1777 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1778 else |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1779 { |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1780 UtilityData *ud; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1781 GtkWidget *box; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1782 GtkWidget *view; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1783 GtkTreeSelection *selection; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1784 gchar *text; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1785 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1786 ud = g_new0(UtilityData, 1); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1787 ud->type = UTILITY_TYPE_DELETE_FOLDER; |
138 | 1788 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
|
1789 ud->dlist = dlist; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1790 dlist = NULL; |
138 | 1791 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
|
1792 flist = NULL; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1793 |
254
9faf34f047b1
Make the wmclass value unique among the code by defining
zas_
parents:
223
diff
changeset
|
1794 ud->gd = file_util_gen_dlg(_("Delete folder"), GQ_WMCLASS, "dlg_confirm", |
753 | 1795 parent, TRUE, file_util_cancel_cb, ud); |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1796 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
|
1797 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1798 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
|
1799 "The contents of this folder will also be deleted."), |
138 | 1800 fd->path); |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1801 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
|
1802 _("Delete folder?"), |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1803 text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1804 g_free(text); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1805 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1806 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
|
1807 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1808 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
|
1809 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
|
1810 gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE); |
753 | 1811 gtk_tree_selection_set_select_function(selection, file_util_preview_cb, ud, NULL); |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1812 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1813 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
|
1814 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1815 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
|
1816 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1817 gtk_widget_show(ud->gd->dialog); |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1818 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1819 |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1820 g_list_free(rlist); |
138 | 1821 filelist_free(dlist); |
1822 filelist_free(flist); | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
1823 } |
753 | 1824 |
1825 | |
1826 void file_util_copy_path_to_clipboard(FileData *fd) | |
1827 { | |
1828 GtkClipboard *clipboard; | |
1829 | |
1830 if (!fd || !*fd->path) return; | |
1831 | |
1832 clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); | |
1833 gtk_clipboard_set_text(clipboard, g_shell_quote(fd->path), -1); | |
1834 } | |
1835 | |
1836 void file_util_copy_path_list_to_clipboard(GList *list) | |
1837 { | |
1838 GtkClipboard *clipboard; | |
1839 GList *work; | |
1840 GString *new; | |
1841 | |
1842 clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); | |
1843 | |
1844 new = g_string_new(""); | |
1845 work = list; | |
1846 while (work) { | |
1847 FileData *fd = work->data; | |
1848 work = work->next; | |
1849 | |
1850 if (!fd || !*fd->path) continue; | |
1851 | |
1852 g_string_append(new, g_shell_quote(fd->path)); | |
1853 if (work) g_string_append_c(new, ' '); | |
1854 } | |
1855 | |
1856 gtk_clipboard_set_text(clipboard, new->str, new->len); | |
1857 g_string_free(new, TRUE); | |
1858 } |