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