Mercurial > geeqie
annotate src/utilops.c @ 968:065a129fd42b
Simplify things related to ViewFileInfoList * and ViewFileInfoIcon * type casting:
- drop VFICON_INFO() and VFLIST_INFO() macros
- rename VFLIST_INFO_POINTER() and VFICON_INFO_POINTER() to shorter VFLIST() and VFICON().
- replace all related occurrences by shorter expressions.
For example:
VFICON_INFO(vf, columns) becomes VFICON(vf)->columns
VFLIST_INFO(vf, click_fd) becomes VFLIST(vf)->click_fd
author | zas_ |
---|---|
date | Sun, 17 Aug 2008 09:30:45 +0000 |
parents | 368643594bc8 |
children | c466b8fabcc3 |
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 | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
17 #include "cache.h" |
9 | 18 #include "cache_maint.h" |
19 #include "collect.h" | |
20 #include "dupe.h" | |
586 | 21 #include "filedata.h" |
22 #include "filefilter.h" | |
9 | 23 #include "image.h" |
24 #include "img-view.h" | |
25 #include "layout.h" | |
26 #include "search.h" | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
27 #include "thumb_standard.h" |
597 | 28 #include "trash.h" |
9 | 29 #include "ui_bookmark.h" |
30 #include "ui_fileops.h" | |
31 #include "ui_misc.h" | |
32 #include "ui_tabcomp.h" | |
140 | 33 #include "editors.h" |
9 | 34 |
924
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
35 static GdkPixbuf *file_util_get_error_icon(FileData *fd, GtkWidget *widget); |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
36 |
9 | 37 /* |
38 *-------------------------------------------------------------------------- | |
39 * Adds 1 or 2 images (if 2, side by side) to a GenericDialog | |
40 *-------------------------------------------------------------------------- | |
41 */ | |
42 | |
43 #define DIALOG_DEF_IMAGE_DIM_X 200 | |
44 #define DIALOG_DEF_IMAGE_DIM_Y 150 | |
45 | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
46 static void generic_dialog_add_image(GenericDialog *gd, GtkWidget *box, |
138 | 47 FileData *fd1, const gchar *header1, |
48 FileData *fd2, const gchar *header2, | |
9 | 49 gint show_filename) |
50 { | |
51 ImageWindow *imd; | |
52 GtkWidget *hbox = NULL; | |
53 GtkWidget *vbox; | |
54 GtkWidget *label = NULL; | |
55 | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
56 if (!box) box = gd->vbox; |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
57 |
138 | 58 if (fd2) |
9 | 59 { |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
60 hbox = pref_box_new(box, TRUE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE); |
9 | 61 } |
62 | |
63 /* image 1 */ | |
64 | |
65 vbox = gtk_vbox_new(FALSE, PREF_PAD_GAP); | |
66 if (hbox) | |
67 { | |
68 GtkWidget *sep; | |
69 | |
70 gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0); | |
71 | |
72 sep = gtk_vseparator_new(); | |
73 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0); | |
74 gtk_widget_show(sep); | |
75 } | |
76 else | |
77 { | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
78 gtk_box_pack_start(GTK_BOX(box), vbox, TRUE, TRUE, PREF_PAD_GAP); |
9 | 79 } |
80 gtk_widget_show(vbox); | |
81 | |
82 if (header1) | |
83 { | |
84 GtkWidget *head; | |
85 | |
86 head = pref_label_new(vbox, header1); | |
87 pref_label_bold(head, TRUE, FALSE); | |
88 gtk_misc_set_alignment(GTK_MISC(head), 0.0, 0.5); | |
89 } | |
90 | |
91 imd = image_new(FALSE); | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
92 g_object_set(G_OBJECT(imd->pr), "zoom_expand", FALSE, NULL); |
9 | 93 gtk_widget_set_size_request(imd->widget, DIALOG_DEF_IMAGE_DIM_X, DIALOG_DEF_IMAGE_DIM_Y); |
94 gtk_box_pack_start(GTK_BOX(vbox), imd->widget, TRUE, TRUE, 0); | |
138 | 95 image_change_fd(imd, fd1, 0.0); |
9 | 96 gtk_widget_show(imd->widget); |
97 | |
98 if (show_filename) | |
99 { | |
138 | 100 label = pref_label_new(vbox, (fd1 == NULL) ? "" : fd1->name); |
9 | 101 } |
102 | |
103 /* only the first image is stored (for use in gd_image_set) */ | |
104 g_object_set_data(G_OBJECT(gd->dialog), "img_image", imd); | |
105 g_object_set_data(G_OBJECT(gd->dialog), "img_label", label); | |
442 | 106 |
9 | 107 |
108 /* image 2 */ | |
109 | |
138 | 110 if (hbox && fd2) |
9 | 111 { |
112 vbox = pref_box_new(hbox, TRUE, GTK_ORIENTATION_VERTICAL, PREF_PAD_GAP); | |
113 | |
114 if (header2) | |
115 { | |
116 GtkWidget *head; | |
117 | |
118 head = pref_label_new(vbox, header2); | |
119 pref_label_bold(head, TRUE, FALSE); | |
120 gtk_misc_set_alignment(GTK_MISC(head), 0.0, 0.5); | |
121 } | |
122 | |
123 imd = image_new(FALSE); | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
124 g_object_set(G_OBJECT(imd->pr), "zoom_expand", FALSE, NULL); |
9 | 125 gtk_widget_set_size_request(imd->widget, DIALOG_DEF_IMAGE_DIM_X, DIALOG_DEF_IMAGE_DIM_Y); |
126 gtk_box_pack_start(GTK_BOX(vbox), imd->widget, TRUE, TRUE, 0); | |
138 | 127 image_change_fd(imd, fd2, 0.0); |
9 | 128 gtk_widget_show(imd->widget); |
129 | |
138 | 130 pref_label_new(vbox, fd2->name); |
9 | 131 } |
132 } | |
133 | |
138 | 134 static void generic_dialog_image_set(GenericDialog *gd, FileData *fd) |
9 | 135 { |
136 ImageWindow *imd; | |
137 GtkWidget *label; | |
442 | 138 |
9 | 139 imd = g_object_get_data(G_OBJECT(gd->dialog), "img_image"); |
140 label = g_object_get_data(G_OBJECT(gd->dialog), "img_label"); | |
141 | |
142 if (!imd) return; | |
143 | |
138 | 144 image_change_fd(imd, fd, 0.0); |
145 if (label) gtk_label_set_text(GTK_LABEL(label), fd->name); | |
9 | 146 } |
147 | |
148 /* | |
149 *-------------------------------------------------------------------------- | |
150 * Wrappers to aid in setting additional dialog properties (unde mouse, etc.) | |
151 *-------------------------------------------------------------------------- | |
152 */ | |
153 | |
154 GenericDialog *file_util_gen_dlg(const gchar *title, | |
155 const gchar *wmclass, const gchar *wmsubclass, | |
156 GtkWidget *parent, gint auto_close, | |
157 void (*cancel_cb)(GenericDialog *, gpointer), gpointer data) | |
158 { | |
159 GenericDialog *gd; | |
160 | |
161 gd = generic_dialog_new(title, wmclass, wmsubclass, parent, auto_close, cancel_cb, data); | |
318 | 162 if (options->place_dialogs_under_mouse) |
9 | 163 { |
164 gtk_window_set_position(GTK_WINDOW(gd->dialog), GTK_WIN_POS_MOUSE); | |
165 } | |
166 | |
167 return gd; | |
168 } | |
169 | |
170 FileDialog *file_util_file_dlg(const gchar *title, | |
171 const gchar *wmclass, const gchar *wmsubclass, | |
172 GtkWidget *parent, | |
173 void (*cancel_cb)(FileDialog *, gpointer), gpointer data) | |
174 { | |
138 | 175 FileDialog *fdlg; |
176 | |
177 fdlg = file_dialog_new(title, wmclass, wmsubclass, parent, cancel_cb, data); | |
318 | 178 if (options->place_dialogs_under_mouse) |
9 | 179 { |
138 | 180 gtk_window_set_position(GTK_WINDOW(GENERIC_DIALOG(fdlg)->dialog), GTK_WIN_POS_MOUSE); |
9 | 181 } |
182 | |
138 | 183 return fdlg; |
9 | 184 } |
185 | |
186 /* this warning dialog is copied from SLIK's ui_utildg.c, | |
187 * because it does not have a mouse center option, | |
188 * and we must center it before show, implement it here. | |
189 */ | |
190 static void file_util_warning_dialog_ok_cb(GenericDialog *gd, gpointer data) | |
191 { | |
192 /* no op */ | |
193 } | |
194 | |
195 GenericDialog *file_util_warning_dialog(const gchar *heading, const gchar *message, | |
196 const gchar *icon_stock_id, GtkWidget *parent) | |
197 { | |
198 GenericDialog *gd; | |
199 | |
254
9faf34f047b1
Make the wmclass value unique among the code by defining
zas_
parents:
223
diff
changeset
|
200 gd = file_util_gen_dlg(heading, GQ_WMCLASS, "warning", parent, TRUE, NULL, NULL); |
9 | 201 generic_dialog_add_message(gd, icon_stock_id, heading, message); |
202 generic_dialog_add_button(gd, GTK_STOCK_OK, NULL, file_util_warning_dialog_ok_cb, TRUE); | |
318 | 203 if (options->place_dialogs_under_mouse) |
9 | 204 { |
205 gtk_window_set_position(GTK_WINDOW(gd->dialog), GTK_WIN_POS_MOUSE); | |
206 } | |
207 gtk_widget_show(gd->dialog); | |
208 | |
209 return gd; | |
210 } | |
1 | 211 |
42
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
212 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
|
213 { |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
214 gint n; |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
215 |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
216 if (!name) return 0; |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
217 |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
218 n = strlen(name); |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
219 |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
220 if (filter_name_exists(name)) |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
221 { |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
222 const gchar *ext; |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
223 |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
224 ext = extension_from_path(name); |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
225 if (ext) n -= strlen(ext); |
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 |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
228 return n; |
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 |
606fcf461a68
Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents:
15
diff
changeset
|
231 |
753 | 232 |
140 | 233 |
753 | 234 typedef enum { |
235 UTILITY_TYPE_COPY, | |
236 UTILITY_TYPE_MOVE, | |
237 UTILITY_TYPE_RENAME, | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
238 UTILITY_TYPE_RENAME_FOLDER, |
753 | 239 UTILITY_TYPE_EDITOR, |
240 UTILITY_TYPE_FILTER, | |
241 UTILITY_TYPE_DELETE, | |
242 UTILITY_TYPE_DELETE_LINK, | |
901 | 243 UTILITY_TYPE_DELETE_FOLDER, |
244 UTILITY_TYPE_CREATE_FOLDER | |
753 | 245 } UtilityType; |
246 | |
247 typedef enum { | |
248 UTILITY_PHASE_START = 0, | |
249 UTILITY_PHASE_ENTERING, | |
250 UTILITY_PHASE_CHECKED, | |
251 UTILITY_PHASE_DONE, | |
252 UTILITY_PHASE_CANCEL | |
253 } UtilityPhase; | |
254 | |
255 enum { | |
256 UTILITY_RENAME = 0, | |
257 UTILITY_RENAME_AUTO, | |
258 UTILITY_RENAME_FORMATTED | |
259 }; | |
260 | |
261 typedef struct _UtilityDataMessages UtilityDataMessages; | |
262 struct _UtilityDataMessages { | |
263 gchar *title; | |
264 gchar *question; | |
265 gchar *desc_flist; | |
266 gchar *desc_source_fd; | |
267 gchar *fail; | |
268 }; | |
269 | |
270 typedef struct _UtilityData UtilityData; | |
271 | |
272 struct _UtilityData { | |
273 UtilityType type; | |
274 UtilityPhase phase; | |
275 | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
276 FileData *dir_fd; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
277 GList *content_list; |
753 | 278 GList *flist; |
279 | |
280 GtkWidget *parent; | |
281 GenericDialog *gd; | |
282 FileDialog *fdlg; | |
283 | |
284 gint update_idle_id; | |
285 | |
286 /* alternative dialog parts */ | |
287 GtkWidget *notebook; | |
288 | |
289 UtilityDataMessages messages; | |
290 | |
291 /* helper entries for various modes */ | |
292 GtkWidget *rename_entry; | |
293 GtkWidget *rename_label; | |
294 GtkWidget *auto_entry_front; | |
295 GtkWidget *auto_entry_end; | |
296 GtkWidget *auto_spin_start; | |
297 GtkWidget *auto_spin_pad; | |
298 GtkWidget *format_entry; | |
299 GtkWidget *format_spin; | |
300 | |
301 GtkWidget *listview; | |
302 | |
303 | |
304 gchar *dest_path; | |
305 | |
306 /* data for the operation itself, internal or external */ | |
755 | 307 gboolean external; /* TRUE for external command, FALSE for internal */ |
753 | 308 |
309 gint external_command; | |
310 gpointer resume_data; | |
311 }; | |
312 | |
313 enum { | |
314 UTILITY_COLUMN_FD = 0, | |
924
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
315 UTILITY_COLUMN_PIXBUF, |
753 | 316 UTILITY_COLUMN_PATH, |
317 UTILITY_COLUMN_NAME, | |
318 UTILITY_COLUMN_SIDECARS, | |
319 UTILITY_COLUMN_DEST_PATH, | |
320 UTILITY_COLUMN_DEST_NAME, | |
321 UTILITY_COLUMN_COUNT | |
322 }; | |
323 | |
324 #define UTILITY_LIST_MIN_WIDTH 250 | |
325 #define UTILITY_LIST_MIN_HEIGHT 150 | |
326 | |
327 /* thumbnail spec has a max depth of 4 (.thumb??/fail/appname/??.png) */ | |
328 #define UTILITY_DELETE_MAX_DEPTH 5 | |
329 | |
330 static UtilityData *file_util_data_new(UtilityType type) | |
136 | 331 { |
753 | 332 UtilityData *ud; |
333 | |
334 ud = g_new0(UtilityData, 1); | |
335 ud->type = type; | |
336 ud->phase = UTILITY_PHASE_START; | |
337 ud->update_idle_id = -1; | |
338 ud->external_command = -1; | |
339 return ud; | |
340 } | |
341 | |
342 static void file_util_data_free(UtilityData *ud) | |
343 { | |
344 if (!ud) return; | |
345 | |
346 if (ud->update_idle_id != -1) g_source_remove(ud->update_idle_id); | |
347 | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
348 file_data_unref(ud->dir_fd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
349 filelist_free(ud->content_list); |
753 | 350 filelist_free(ud->flist); |
351 | |
352 if (ud->gd) generic_dialog_close(ud->gd); | |
353 | |
354 g_free(ud->dest_path); | |
355 | |
356 g_free(ud); | |
357 } | |
358 | |
924
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
359 static GtkTreeViewColumn *file_util_dialog_add_list_column(GtkWidget *view, const gchar *text, gboolean image, gint n) |
753 | 360 { |
361 GtkTreeViewColumn *column; | |
362 GtkCellRenderer *renderer; | |
363 | |
364 column = gtk_tree_view_column_new(); | |
365 gtk_tree_view_column_set_title(column, text); | |
366 gtk_tree_view_column_set_min_width(column, 4); | |
924
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
367 if (image) |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
368 { |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
369 gtk_tree_view_column_set_min_width(column, 20); |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
370 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED); |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
371 renderer = gtk_cell_renderer_pixbuf_new(); |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
372 gtk_tree_view_column_pack_start(column, renderer, TRUE); |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
373 gtk_tree_view_column_add_attribute(column, renderer, "pixbuf", n); |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
374 } |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
375 else |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
376 { |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
377 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY); |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
378 renderer = gtk_cell_renderer_text_new(); |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
379 gtk_tree_view_column_pack_start(column, renderer, TRUE); |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
380 gtk_tree_view_column_add_attribute(column, renderer, "text", n); |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
381 } |
753 | 382 gtk_tree_view_append_column(GTK_TREE_VIEW(view), column); |
383 | |
384 return column; | |
385 } | |
386 | |
387 static void file_util_dialog_list_select(GtkWidget *view, gint n) | |
388 { | |
389 GtkTreeModel *store; | |
390 GtkTreeIter iter; | |
391 GtkTreeSelection *selection; | |
392 | |
393 store = gtk_tree_view_get_model(GTK_TREE_VIEW(view)); | |
394 if (gtk_tree_model_iter_nth_child(store, &iter, NULL, n)) | |
140 | 395 { |
753 | 396 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view)); |
397 gtk_tree_selection_select_iter(selection, &iter); | |
398 } | |
399 } | |
400 | |
401 static GtkWidget *file_util_dialog_add_list(GtkWidget *box, GList *list, gint full_paths) | |
402 { | |
403 GtkWidget *scrolled; | |
404 GtkWidget *view; | |
405 GtkListStore *store; | |
406 | |
407 scrolled = gtk_scrolled_window_new(NULL, NULL); | |
408 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN); | |
409 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), | |
410 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
411 gtk_box_pack_start(GTK_BOX(box), scrolled, TRUE, TRUE, 0); | |
412 gtk_widget_show(scrolled); | |
413 | |
924
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
414 store = gtk_list_store_new(UTILITY_COLUMN_COUNT, G_TYPE_POINTER, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); |
753 | 415 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); |
416 g_object_unref(store); | |
417 | |
418 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), TRUE); | |
419 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(view), FALSE); | |
420 | |
924
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
421 file_util_dialog_add_list_column(view, "", TRUE, UTILITY_COLUMN_PIXBUF); |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
422 |
753 | 423 if (full_paths) |
424 { | |
924
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
425 file_util_dialog_add_list_column(view, _("Location"), FALSE, UTILITY_COLUMN_PATH); |
140 | 426 } |
138 | 427 else |
428 { | |
924
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
429 file_util_dialog_add_list_column(view, _("Name"), FALSE, UTILITY_COLUMN_NAME); |
138 | 430 } |
431 | |
753 | 432 gtk_widget_set_size_request(view, UTILITY_LIST_MIN_WIDTH, UTILITY_LIST_MIN_HEIGHT); |
433 gtk_container_add(GTK_CONTAINER(scrolled), view); | |
434 gtk_widget_show(view); | |
136 | 435 |
140 | 436 while (list) |
437 { | |
438 FileData *fd = list->data; | |
753 | 439 GtkTreeIter iter; |
440 gchar *sidecars; | |
441 | |
442 sidecars = file_data_sc_list_to_string(fd); | |
443 | |
444 gtk_list_store_append(store, &iter); | |
757 | 445 gtk_list_store_set(store, &iter, |
446 UTILITY_COLUMN_FD, fd, | |
924
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
447 UTILITY_COLUMN_PIXBUF, file_util_get_error_icon(fd, view), |
757 | 448 UTILITY_COLUMN_PATH, fd->path, |
449 UTILITY_COLUMN_NAME, fd->name, | |
450 UTILITY_COLUMN_SIDECARS, sidecars, | |
451 UTILITY_COLUMN_DEST_PATH, fd->change ? fd->change->dest : "error", | |
452 UTILITY_COLUMN_DEST_NAME, fd->change ? filename_from_path(fd->change->dest) : "error", | |
453 -1); | |
753 | 454 g_free(sidecars); |
455 | |
140 | 456 list = list->next; |
457 } | |
753 | 458 |
459 return view; | |
460 } | |
461 | |
462 | |
897 | 463 static void file_util_perform_ci_internal(UtilityData *ud); |
753 | 464 void file_util_dialog_run(UtilityData *ud); |
465 static gint file_util_perform_ci_cb(gpointer resume_data, gint flags, GList *list, gpointer data); | |
466 | |
467 /* call file_util_perform_ci_internal or start_editor_from_filelist_full */ | |
468 | |
469 | |
470 static void file_util_resume_cb(GenericDialog *gd, gpointer data) | |
471 { | |
472 UtilityData *ud = data; | |
473 if (ud->external) | |
474 editor_resume(ud->resume_data); | |
475 else | |
476 file_util_perform_ci_internal(ud); | |
477 } | |
478 | |
479 static void file_util_abort_cb(GenericDialog *gd, gpointer data) | |
480 { | |
481 UtilityData *ud = data; | |
482 if (ud->external) | |
483 editor_skip(ud->resume_data); | |
484 else | |
485 file_util_perform_ci_cb(NULL, EDITOR_ERROR_SKIPPED, ud->flist, ud); | |
140 | 486 |
487 } | |
488 | |
489 | |
753 | 490 static gint file_util_perform_ci_cb(gpointer resume_data, gint flags, GList *list, gpointer data) |
1 | 491 { |
753 | 492 UtilityData *ud = data; |
493 ud->resume_data = resume_data; | |
497 | 494 |
140 | 495 gint ret = EDITOR_CB_CONTINUE; |
496 if ((flags & EDITOR_ERROR_MASK) && !(flags & EDITOR_ERROR_SKIPPED)) | |
497 { | |
757 | 498 GString *msg = g_string_new(editor_get_error_str(flags)); |
499 GenericDialog *d; | |
500 g_string_append(msg, "\n"); | |
501 g_string_append(msg, ud->messages.fail); | |
502 g_string_append(msg, "\n"); | |
503 while (list) | |
504 { | |
505 FileData *fd = list->data; | |
442 | 506 |
757 | 507 g_string_append(msg, fd->path); |
508 g_string_append(msg, "\n"); | |
509 list = list->next; | |
510 } | |
511 if (resume_data) | |
512 { | |
513 g_string_append(msg, _("\n Continue multiple file operation?")); | |
514 d = file_util_gen_dlg(ud->messages.fail, GQ_WMCLASS, "dlg_confirm", | |
515 NULL, TRUE, | |
516 file_util_abort_cb, ud); | |
140 | 517 |
757 | 518 generic_dialog_add_message(d, GTK_STOCK_DIALOG_WARNING, NULL, msg->str); |
140 | 519 |
757 | 520 generic_dialog_add_button(d, GTK_STOCK_GO_FORWARD, _("Co_ntinue"), |
521 file_util_resume_cb, TRUE); | |
522 gtk_widget_show(d->dialog); | |
523 ret = EDITOR_CB_SUSPEND; | |
524 } | |
525 else | |
526 { | |
527 file_util_warning_dialog(ud->messages.fail, msg->str, GTK_STOCK_DIALOG_ERROR, NULL); | |
528 } | |
529 g_string_free(msg, TRUE); | |
140 | 530 } |
442 | 531 |
532 | |
753 | 533 while (list) /* be careful, file_util_perform_ci_internal can pass ud->flist as list */ |
140 | 534 { |
753 | 535 FileData *fd = list->data; |
536 list = list->next; | |
537 | |
538 if (!(flags & EDITOR_ERROR_MASK)) /* files were successfully deleted, call the maint functions */ | |
761 | 539 { |
540 file_data_sc_apply_ci(fd); | |
541 } | |
753 | 542 |
543 ud->flist = g_list_remove(ud->flist, fd); | |
544 file_data_sc_free_ci(fd); | |
545 file_data_unref(fd); | |
140 | 546 } |
753 | 547 |
548 if (!resume_data) /* end of the list */ | |
549 { | |
550 ud->phase = UTILITY_PHASE_DONE; | |
551 file_util_dialog_run(ud); | |
552 } | |
553 | |
140 | 554 return ret; |
555 } | |
556 | |
143
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
140
diff
changeset
|
557 |
753 | 558 /* |
756 | 559 * Perform the operation described by FileDataChangeInfo on all files in the list |
753 | 560 * it is an alternative to start_editor_from_filelist_full, it should use similar interface |
561 */ | |
143
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
140
diff
changeset
|
562 |
1 | 563 |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
564 static void file_util_perform_ci_internal(UtilityData *ud) |
753 | 565 { |
566 | |
567 while (ud->flist) | |
1 | 568 { |
753 | 569 gint ret; |
570 | |
571 /* take a single entry each time, this allows better control over the operation */ | |
572 GList *single_entry = g_list_append(NULL, ud->flist->data); | |
573 gboolean last = !ud->flist->next; | |
757 | 574 gint status = EDITOR_ERROR_STATUS; |
575 | |
753 | 576 if (file_data_sc_perform_ci(single_entry->data)) |
757 | 577 status = 0; /* OK */ |
578 | |
579 ret = file_util_perform_ci_cb(GINT_TO_POINTER(!last), status, single_entry, ud); | |
753 | 580 g_list_free(single_entry); |
581 | |
582 if (ret == EDITOR_CB_SUSPEND || last) return; | |
583 | |
584 if (ret == EDITOR_CB_SKIP) | |
585 { | |
586 file_util_perform_ci_cb(NULL, EDITOR_ERROR_SKIPPED, ud->flist, ud); | |
587 } | |
588 | |
589 /* FIXME: convert the loop to idle call */ | |
590 | |
1 | 591 } |
592 } | |
593 | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
594 static void file_util_perform_ci_dir(UtilityData *ud, gboolean internal, gboolean ext_result) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
595 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
596 switch (ud->type) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
597 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
598 case UTILITY_TYPE_DELETE_LINK: |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
599 { |
897 | 600 if ((internal && file_data_sc_perform_ci(ud->dir_fd)) || |
601 (!internal && ext_result)) | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
602 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
603 file_data_sc_apply_ci(ud->dir_fd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
604 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
605 else |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
606 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
607 gchar *text; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
608 |
901 | 609 text = g_strdup_printf("%s:\n\n%s", ud->messages.fail, ud->dir_fd->path); |
610 file_util_warning_dialog(ud->messages.fail, text, GTK_STOCK_DIALOG_ERROR, NULL); | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
611 g_free(text); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
612 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
613 file_data_sc_free_ci(ud->dir_fd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
614 break; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
615 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
616 case UTILITY_TYPE_DELETE_FOLDER: |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
617 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
618 FileData *fail = NULL; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
619 GList *work; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
620 work = ud->content_list; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
621 while (work) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
622 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
623 FileData *fd; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
624 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
625 fd = work->data; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
626 work = work->next; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
627 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
628 if (!fail) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
629 { |
897 | 630 if ((internal && file_data_sc_perform_ci(fd)) || |
631 (!internal && ext_result)) | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
632 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
633 file_data_sc_apply_ci(fd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
634 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
635 else |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
636 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
637 if (internal) fail = file_data_ref(fd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
638 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
639 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
640 file_data_sc_free_ci(fd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
641 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
642 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
643 if (!fail) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
644 { |
897 | 645 if ((internal && file_data_sc_perform_ci(ud->dir_fd)) || |
646 (!internal && ext_result)) | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
647 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
648 file_data_sc_apply_ci(ud->dir_fd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
649 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
650 else |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
651 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
652 fail = file_data_ref(ud->dir_fd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
653 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
654 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
655 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
656 if (fail) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
657 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
658 gchar *text; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
659 GenericDialog *gd; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
660 |
901 | 661 text = g_strdup_printf("%s:\n\n%s", ud->messages.fail, ud->dir_fd->path); |
662 gd = file_util_warning_dialog(ud->messages.fail, text, GTK_STOCK_DIALOG_ERROR, NULL); | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
663 g_free(text); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
664 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
665 if (fail != ud->dir_fd) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
666 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
667 pref_spacer(gd->vbox, PREF_PAD_GROUP); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
668 text = g_strdup_printf(_("Removal of folder contents failed at this file:\n\n%s"), |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
669 fail->path); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
670 pref_label_new(gd->vbox, text); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
671 g_free(text); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
672 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
673 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
674 file_data_unref(fail); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
675 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
676 break; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
677 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
678 case UTILITY_TYPE_RENAME_FOLDER: |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
679 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
680 FileData *fail = NULL; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
681 GList *work; |
897 | 682 if ((internal && file_data_sc_perform_ci(ud->dir_fd)) || |
683 (!internal && ext_result)) | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
684 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
685 file_data_sc_apply_ci(ud->dir_fd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
686 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
687 else |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
688 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
689 fail = file_data_ref(ud->dir_fd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
690 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
691 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
692 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
693 work = ud->content_list; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
694 while (work) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
695 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
696 FileData *fd; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
697 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
698 fd = work->data; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
699 work = work->next; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
700 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
701 if (!fail) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
702 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
703 file_data_sc_apply_ci(fd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
704 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
705 file_data_sc_free_ci(fd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
706 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
707 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
708 if (fail) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
709 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
710 gchar *text; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
711 GenericDialog *gd; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
712 |
901 | 713 text = g_strdup_printf("%s:\n\n%s", ud->messages.fail, ud->dir_fd->path); |
714 gd = file_util_warning_dialog(ud->messages.fail, text, GTK_STOCK_DIALOG_ERROR, NULL); | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
715 g_free(text); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
716 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
717 file_data_unref(fail); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
718 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
719 break; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
720 } |
901 | 721 case UTILITY_TYPE_CREATE_FOLDER: |
722 { | |
723 if ((internal && mkdir_utf8(ud->dir_fd->path, 0755)) || | |
724 (!internal && ext_result)) | |
725 { | |
907 | 726 file_data_increment_version(ud->dir_fd); |
901 | 727 file_data_send_notification(ud->dir_fd, NOTIFY_TYPE_REREAD); |
728 } | |
729 else | |
730 { | |
731 gchar *text; | |
732 GenericDialog *gd; | |
733 | |
734 text = g_strdup_printf("%s:\n\n%s", ud->messages.fail, ud->dir_fd->path); | |
735 gd = file_util_warning_dialog(ud->messages.fail, text, GTK_STOCK_DIALOG_ERROR, NULL); | |
736 g_free(text); | |
737 } | |
738 | |
739 break; | |
740 } | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
741 default: |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
742 g_warning("unhandled operation"); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
743 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
744 ud->phase = UTILITY_PHASE_DONE; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
745 file_util_dialog_run(ud); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
746 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
747 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
748 static gint file_util_perform_ci_dir_cb(gpointer resume_data, gint flags, GList *list, gpointer data) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
749 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
750 UtilityData *ud = data; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
751 file_util_perform_ci_dir(ud, FALSE, !((flags & EDITOR_ERROR_MASK) && !(flags & EDITOR_ERROR_SKIPPED))); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
752 return EDITOR_CB_CONTINUE; /* does not matter, there was just single directory */ |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
753 } |
9 | 754 |
753 | 755 void file_util_perform_ci(UtilityData *ud) |
756 { | |
757 switch (ud->type) | |
758 { | |
759 case UTILITY_TYPE_COPY: | |
760 ud->external_command = CMD_COPY; | |
761 break; | |
762 case UTILITY_TYPE_MOVE: | |
763 ud->external_command = CMD_MOVE; | |
764 break; | |
765 case UTILITY_TYPE_RENAME: | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
766 case UTILITY_TYPE_RENAME_FOLDER: |
753 | 767 ud->external_command = CMD_RENAME; |
768 break; | |
769 case UTILITY_TYPE_DELETE: | |
770 case UTILITY_TYPE_DELETE_LINK: | |
771 case UTILITY_TYPE_DELETE_FOLDER: | |
772 ud->external_command = CMD_DELETE; | |
773 break; | |
901 | 774 case UTILITY_TYPE_CREATE_FOLDER: |
775 ud->external_command = CMD_FOLDER; | |
776 break; | |
753 | 777 case UTILITY_TYPE_FILTER: |
778 case UTILITY_TYPE_EDITOR: | |
779 g_assert(ud->external_command != -1); /* it should be already set */ | |
780 break; | |
781 } | |
9 | 782 |
766
7148e125bf23
Check for existing editor command using is_valid_editor_command().
zas_
parents:
761
diff
changeset
|
783 if (is_valid_editor_command(ud->external_command)) |
9 | 784 { |
753 | 785 gint flags; |
757 | 786 |
753 | 787 ud->external = TRUE; |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
788 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
789 if (ud->dir_fd) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
790 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
791 flags = start_editor_from_file_full(ud->external_command, ud->dir_fd, file_util_perform_ci_dir_cb, ud); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
792 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
793 else |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
794 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
795 flags = start_editor_from_filelist_full(ud->external_command, ud->flist, file_util_perform_ci_cb, ud); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
796 } |
757 | 797 |
798 if (flags) | |
9 | 799 { |
753 | 800 gchar *text = g_strdup_printf(_("%s\nUnable to start external command.\n"), editor_get_error_str(flags)); |
801 file_util_warning_dialog(ud->messages.fail, text, GTK_STOCK_DIALOG_ERROR, NULL); | |
802 g_free(text); | |
9 | 803 } |
804 } | |
805 else | |
806 { | |
753 | 807 ud->external = FALSE; |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
808 if (ud->dir_fd) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
809 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
810 file_util_perform_ci_dir(ud, TRUE, FALSE); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
811 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
812 else |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
813 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
814 file_util_perform_ci_internal(ud); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
815 } |
1 | 816 } |
817 } | |
818 | |
924
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
819 static GdkPixbuf *file_util_get_error_icon(FileData *fd, GtkWidget *widget) |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
820 { |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
821 static GdkPixbuf *pb_warning; |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
822 static GdkPixbuf *pb_error; |
932 | 823 static GdkPixbuf *pb_apply; |
924
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
824 gint error; |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
825 |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
826 if (!pb_warning) |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
827 { |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
828 pb_warning = gtk_widget_render_icon(widget, GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_MENU, NULL); |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
829 } |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
830 |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
831 if (!pb_error) |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
832 { |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
833 pb_error = gtk_widget_render_icon(widget, GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_MENU, NULL); |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
834 } |
932 | 835 |
836 if (!pb_apply) | |
837 { | |
838 pb_apply = gtk_widget_render_icon(widget, GTK_STOCK_APPLY, GTK_ICON_SIZE_MENU, NULL); | |
839 } | |
924
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
840 |
928 | 841 error = file_data_sc_verify_ci(fd); |
924
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
842 |
932 | 843 if (!error) return pb_apply; |
924
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
844 |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
845 if (error & CHANGE_ERROR_MASK) |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
846 { |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
847 return pb_error; |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
848 } |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
849 else |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
850 { |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
851 return pb_warning; |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
852 } |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
853 } |
914
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
854 |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
855 static void file_util_check_resume_cb(GenericDialog *gd, gpointer data) |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
856 { |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
857 UtilityData *ud = data; |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
858 ud->phase = UTILITY_PHASE_CHECKED; |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
859 file_util_dialog_run(ud); |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
860 } |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
861 |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
862 static void file_util_check_abort_cb(GenericDialog *gd, gpointer data) |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
863 { |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
864 UtilityData *ud = data; |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
865 ud->phase = UTILITY_PHASE_START; |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
866 file_util_dialog_run(ud); |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
867 } |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
868 |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
869 void file_util_check_ci(UtilityData *ud) |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
870 { |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
871 gint error = CHANGE_OK; |
928 | 872 gchar *desc = NULL; |
914
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
873 |
935 | 874 if (ud->type != UTILITY_TYPE_CREATE_FOLDER) |
914
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
875 { |
935 | 876 if (ud->dest_path && !isdir(ud->dest_path)) |
877 { | |
878 error = CHANGE_GENERIC_ERROR; | |
879 desc = g_strdup_printf(_("%s is not a directory"), ud->dest_path); | |
880 } | |
881 else if (ud->dir_fd) | |
882 { | |
883 error = file_data_sc_verify_ci(ud->dir_fd); | |
884 if (error) desc = file_data_get_error_string(error); | |
885 } | |
886 else | |
887 { | |
888 error = file_data_sc_verify_ci_list(ud->flist, &desc); | |
889 } | |
914
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
890 } |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
891 |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
892 if (!error) |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
893 { |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
894 ud->phase = UTILITY_PHASE_CHECKED; |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
895 file_util_dialog_run(ud); |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
896 return; |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
897 } |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
898 |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
899 if (!(error & CHANGE_ERROR_MASK)) |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
900 { |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
901 /* just a warning */ |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
902 GenericDialog *d; |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
903 |
937 | 904 d = file_util_gen_dlg(ud->messages.title, GQ_WMCLASS, "dlg_confirm", |
914
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
905 ud->parent, TRUE, |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
906 file_util_check_abort_cb, ud); |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
907 |
928 | 908 generic_dialog_add_message(d, GTK_STOCK_DIALOG_WARNING, _("Really continue?"), desc); |
914
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
909 |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
910 generic_dialog_add_button(d, GTK_STOCK_GO_FORWARD, _("Co_ntinue"), |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
911 file_util_check_resume_cb, TRUE); |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
912 gtk_widget_show(d->dialog); |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
913 } |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
914 else |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
915 { |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
916 /* fatal error */ |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
917 GenericDialog *d; |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
918 |
937 | 919 d = file_util_gen_dlg(ud->messages.title, GQ_WMCLASS, "dlg_confirm", |
914
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
920 ud->parent, TRUE, |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
921 file_util_check_abort_cb, ud); |
937 | 922 generic_dialog_add_message(d, GTK_STOCK_DIALOG_WARNING, _("This operation can't continue:"), desc); |
914
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
923 |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
924 gtk_widget_show(d->dialog); |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
925 } |
928 | 926 g_free(desc); |
914
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
927 } |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
928 |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
929 |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
930 |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
931 |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
932 |
757 | 933 static void file_util_cancel_cb(GenericDialog *gd, gpointer data) |
753 | 934 { |
935 UtilityData *ud = data; | |
936 | |
937 generic_dialog_close(gd); | |
1 | 938 |
753 | 939 ud->gd = NULL; |
940 | |
941 ud->phase = UTILITY_PHASE_CANCEL; | |
942 file_util_dialog_run(ud); | |
1 | 943 } |
944 | |
757 | 945 static void file_util_ok_cb(GenericDialog *gd, gpointer data) |
1 | 946 { |
753 | 947 UtilityData *ud = data; |
948 | |
949 generic_dialog_close(gd); | |
950 | |
951 ud->gd = NULL; | |
138 | 952 |
753 | 953 file_util_dialog_run(ud); |
1 | 954 } |
955 | |
757 | 956 static void file_util_fdlg_cancel_cb(FileDialog *fdlg, gpointer data) |
1 | 957 { |
753 | 958 UtilityData *ud = data; |
675 | 959 |
753 | 960 file_dialog_close(fdlg); |
9 | 961 |
753 | 962 ud->fdlg = NULL; |
963 | |
964 ud->phase = UTILITY_PHASE_CANCEL; | |
965 file_util_dialog_run(ud); | |
966 } | |
9 | 967 |
900 | 968 static void file_util_dest_folder_update_path(UtilityData *ud) |
753 | 969 { |
970 g_free(ud->dest_path); | |
900 | 971 ud->dest_path = g_strdup(gtk_entry_get_text(GTK_ENTRY(ud->fdlg->entry))); |
753 | 972 |
973 switch (ud->type) | |
1 | 974 { |
753 | 975 case UTILITY_TYPE_COPY: |
976 file_data_sc_update_ci_copy_list(ud->flist, ud->dest_path); | |
977 break; | |
978 case UTILITY_TYPE_MOVE: | |
979 file_data_sc_update_ci_move_list(ud->flist, ud->dest_path); | |
980 break; | |
981 case UTILITY_TYPE_FILTER: | |
982 case UTILITY_TYPE_EDITOR: | |
983 file_data_sc_update_ci_unspecified_list(ud->flist, ud->dest_path); | |
984 break; | |
901 | 985 case UTILITY_TYPE_CREATE_FOLDER: |
986 file_data_unref(ud->dir_fd); | |
987 ud->dir_fd = file_data_new_simple(ud->dest_path); | |
988 break; | |
753 | 989 case UTILITY_TYPE_DELETE: |
990 case UTILITY_TYPE_DELETE_LINK: | |
991 case UTILITY_TYPE_DELETE_FOLDER: | |
992 case UTILITY_TYPE_RENAME: | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
993 case UTILITY_TYPE_RENAME_FOLDER: |
753 | 994 g_warning("unhandled operation"); |
1 | 995 } |
996 } | |
997 | |
900 | 998 static void file_util_fdlg_ok_cb(FileDialog *fdlg, gpointer data) |
999 { | |
1000 UtilityData *ud = data; | |
1001 | |
1002 file_util_dest_folder_update_path(ud); | |
946 | 1003 if (isdir(ud->dest_path)) file_dialog_sync_history(fdlg, TRUE); |
900 | 1004 file_dialog_close(fdlg); |
1005 | |
1006 ud->fdlg = NULL; | |
1007 | |
1008 file_util_dialog_run(ud); | |
1009 } | |
1010 | |
1011 | |
1012 static void file_util_dest_folder_entry_cb(GtkWidget *entry, gpointer data) | |
1013 { | |
1014 UtilityData *ud = data; | |
1015 file_util_dest_folder_update_path(ud); | |
1016 } | |
1 | 1017 |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1018 /* 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
|
1019 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
|
1020 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1021 gchar *new_name; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1022 gchar *parsed; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1023 const gchar *ext; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1024 gchar *middle; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1025 gchar *tmp; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1026 gchar *pad_start; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1027 gchar *pad_end; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1028 gint padding; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1029 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1030 if (!format || !name) return NULL; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1031 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1032 tmp = g_strdup(format); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1033 pad_start = strchr(tmp, '#'); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1034 if (pad_start) |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1035 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1036 pad_end = pad_start; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1037 padding = 0; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1038 while (*pad_end == '#') |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1039 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1040 pad_end++; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1041 padding++; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1042 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1043 *pad_start = '\0'; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1044 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1045 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
|
1046 g_free(tmp); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1047 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1048 else |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1049 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1050 parsed = tmp; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1051 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1052 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1053 ext = extension_from_path(name); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1054 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1055 middle = strchr(parsed, '*'); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1056 if (middle) |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1057 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1058 gchar *base; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1059 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1060 *middle = '\0'; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1061 middle++; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1062 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1063 base = remove_extension_from_path(name); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1064 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
|
1065 g_free(base); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1066 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1067 else |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1068 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1069 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
|
1070 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1071 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1072 g_free(parsed); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1073 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1074 return new_name; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1075 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1076 |
9 | 1077 |
753 | 1078 static void file_util_rename_preview_update(UtilityData *ud) |
1 | 1079 { |
9 | 1080 GtkTreeModel *store; |
753 | 1081 GtkTreeSelection *selection; |
9 | 1082 GtkTreeIter iter; |
1083 const gchar *front; | |
1084 const gchar *end; | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1085 const gchar *format; |
9 | 1086 gint valid; |
1087 gint start_n; | |
1088 gint padding; | |
1089 gint n; | |
753 | 1090 gint mode; |
9 | 1091 |
753 | 1092 mode = gtk_notebook_get_current_page(GTK_NOTEBOOK(ud->notebook)); |
9 | 1093 |
753 | 1094 if (mode == UTILITY_RENAME) |
1095 { | |
1096 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(ud->listview)); | |
1097 if (gtk_tree_selection_get_selected(selection, &store, &iter)) | |
1098 { | |
1099 FileData *fd; | |
1100 const gchar *dest = gtk_entry_get_text(GTK_ENTRY(ud->rename_entry)); | |
1101 | |
1102 gtk_tree_model_get(store, &iter, UTILITY_COLUMN_FD, &fd, -1); | |
1103 file_data_sc_update_ci_rename(fd, dest); | |
1104 gtk_list_store_set(GTK_LIST_STORE(store), &iter, | |
924
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
1105 UTILITY_COLUMN_PIXBUF, file_util_get_error_icon(fd, ud->listview), |
753 | 1106 UTILITY_COLUMN_DEST_PATH, fd->change->dest, |
1107 UTILITY_COLUMN_DEST_NAME, filename_from_path(fd->change->dest), | |
1108 -1); | |
1109 } | |
1110 return; | |
1111 } | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1112 |
753 | 1113 |
1114 front = gtk_entry_get_text(GTK_ENTRY(ud->auto_entry_front)); | |
1115 end = gtk_entry_get_text(GTK_ENTRY(ud->auto_entry_end)); | |
1116 padding = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ud->auto_spin_pad)); | |
1117 | |
1118 format = gtk_entry_get_text(GTK_ENTRY(ud->format_entry)); | |
1119 | |
1120 if (mode == UTILITY_RENAME_FORMATTED) | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1121 { |
753 | 1122 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
|
1123 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1124 else |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1125 { |
753 | 1126 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
|
1127 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1128 |
753 | 1129 store = gtk_tree_view_get_model(GTK_TREE_VIEW(ud->listview)); |
9 | 1130 n = start_n; |
1131 valid = gtk_tree_model_get_iter_first(store, &iter); | |
1132 while (valid) | |
1133 { | |
1134 gchar *dest; | |
753 | 1135 FileData *fd; |
1136 gtk_tree_model_get(store, &iter, UTILITY_COLUMN_FD, &fd, -1); | |
9 | 1137 |
753 | 1138 if (mode == UTILITY_RENAME_FORMATTED) |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1139 { |
138 | 1140 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
|
1141 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1142 else |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1143 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1144 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
|
1145 } |
753 | 1146 |
1147 file_data_sc_update_ci_rename(fd, dest); | |
1148 gtk_list_store_set(GTK_LIST_STORE(store), &iter, | |
924
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
1149 UTILITY_COLUMN_PIXBUF, file_util_get_error_icon(fd, ud->listview), |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
1150 UTILITY_COLUMN_DEST_PATH, fd->change->dest, |
753 | 1151 UTILITY_COLUMN_DEST_NAME, filename_from_path(fd->change->dest), |
1152 -1); | |
9 | 1153 g_free(dest); |
1154 | |
1155 n++; | |
1156 valid = gtk_tree_model_iter_next(store, &iter); | |
1157 } | |
1158 | |
1 | 1159 } |
1160 | |
753 | 1161 static void file_util_rename_preview_entry_cb(GtkWidget *entry, gpointer data) |
9 | 1162 { |
753 | 1163 UtilityData *ud = data; |
1164 file_util_rename_preview_update(ud); | |
1165 } | |
9 | 1166 |
753 | 1167 static void file_util_rename_preview_adj_cb(GtkWidget *spin, gpointer data) |
1168 { | |
1169 UtilityData *ud = data; | |
1170 file_util_rename_preview_update(ud); | |
1171 } | |
9 | 1172 |
753 | 1173 static gboolean file_util_rename_idle_cb(gpointer data) |
1174 { | |
1175 UtilityData *ud = data; | |
1176 | |
1177 file_util_rename_preview_update(ud); | |
1178 | |
1179 ud->update_idle_id = -1; | |
9 | 1180 return FALSE; |
1181 } | |
1182 | |
753 | 1183 static void file_util_rename_preview_order_cb(GtkTreeModel *treemodel, GtkTreePath *tpath, |
9 | 1184 GtkTreeIter *iter, gpointer data) |
1185 { | |
753 | 1186 UtilityData *ud = data; |
9 | 1187 |
757 | 1188 if (ud->update_idle_id != -1) return; |
1189 | |
1190 ud->update_idle_id = g_idle_add(file_util_rename_idle_cb, ud); | |
9 | 1191 } |
1192 | |
753 | 1193 |
1194 static gboolean file_util_preview_cb(GtkTreeSelection *selection, GtkTreeModel *store, | |
1195 GtkTreePath *tpath, gboolean path_currently_selected, | |
1196 gpointer data) | |
9 | 1197 { |
753 | 1198 UtilityData *ud = data; |
1199 GtkTreeIter iter; | |
1200 FileData *fd = NULL; | |
1201 | |
1202 if (path_currently_selected || | |
1203 !gtk_tree_model_get_iter(store, &iter, tpath)) return TRUE; | |
1204 | |
1205 gtk_tree_model_get(store, &iter, UTILITY_COLUMN_FD, &fd, -1); | |
1206 generic_dialog_image_set(ud->gd, fd); | |
1207 | |
1208 if (ud->type == UTILITY_TYPE_RENAME) | |
1209 { | |
1210 const gchar *name = filename_from_path(fd->change->dest); | |
757 | 1211 |
753 | 1212 gtk_widget_grab_focus(ud->rename_entry); |
1213 gtk_label_set_text(GTK_LABEL(ud->rename_label), fd->name); | |
1214 g_signal_handlers_block_by_func(ud->rename_entry, G_CALLBACK(file_util_rename_preview_entry_cb), ud); | |
1215 gtk_entry_set_text(GTK_ENTRY(ud->rename_entry), name); | |
1216 gtk_editable_select_region(GTK_EDITABLE(ud->rename_entry), 0, filename_base_length(name)); | |
1217 g_signal_handlers_unblock_by_func(ud->rename_entry, G_CALLBACK(file_util_rename_preview_entry_cb), ud); | |
1218 } | |
1219 | |
1220 return TRUE; | |
9 | 1221 } |
1222 | |
753 | 1223 |
1224 | |
1225 static void box_append_safe_delete_status(GenericDialog *gd) | |
9 | 1226 { |
753 | 1227 GtkWidget *label; |
1228 gchar *buf; | |
1229 | |
1230 buf = file_util_safe_delete_status(); | |
1231 label = pref_label_new(gd->vbox, buf); | |
1232 g_free(buf); | |
1233 | |
1234 gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); | |
1235 gtk_widget_set_sensitive(label, FALSE); | |
9 | 1236 } |
1237 | |
753 | 1238 |
1239 static void file_util_dialog_init_simple_list(UtilityData *ud) | |
1 | 1240 { |
753 | 1241 GtkWidget *box; |
1242 GtkTreeSelection *selection; | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1243 gchar *dir_msg; |
757 | 1244 |
753 | 1245 ud->gd = file_util_gen_dlg(ud->messages.title, GQ_WMCLASS, "dlg_confirm", |
757 | 1246 ud->parent, FALSE, file_util_cancel_cb, ud); |
753 | 1247 generic_dialog_add_button(ud->gd, GTK_STOCK_DELETE, NULL, file_util_ok_cb, TRUE); |
1248 | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1249 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1250 if (ud->dir_fd) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1251 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1252 dir_msg = g_strdup_printf("%s\n\n%s\n", ud->messages.desc_source_fd, ud->dir_fd->path); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1253 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1254 else |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1255 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1256 dir_msg = g_strdup(""); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1257 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1258 |
753 | 1259 box = generic_dialog_add_message(ud->gd, GTK_STOCK_DIALOG_QUESTION, |
757 | 1260 ud->messages.question, |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1261 dir_msg); |
753 | 1262 |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1263 g_free(dir_msg); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1264 |
753 | 1265 box = pref_group_new(box, TRUE, ud->messages.desc_flist, GTK_ORIENTATION_HORIZONTAL); |
1266 | |
1267 ud->listview = file_util_dialog_add_list(box, ud->flist, FALSE); | |
924
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
1268 file_util_dialog_add_list_column(ud->listview, _("Sidecars"), FALSE, UTILITY_COLUMN_SIDECARS); |
9 | 1269 |
753 | 1270 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(ud->listview)); |
1271 gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE); | |
1272 gtk_tree_selection_set_select_function(selection, file_util_preview_cb, ud, NULL); | |
1273 | |
1274 generic_dialog_add_image(ud->gd, box, NULL, NULL, NULL, NULL, FALSE); | |
1275 | |
1276 box_append_safe_delete_status(ud->gd); | |
1277 | |
1278 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
|
1279 |
753 | 1280 file_util_dialog_list_select(ud->listview, 0); |
1281 } | |
1282 | |
1283 static void file_util_dialog_init_dest_folder(UtilityData *ud) | |
1284 { | |
1285 FileDialog *fdlg; | |
1286 GtkWidget *label; | |
1287 const gchar *stock_id; | |
1288 | |
1289 if (ud->type == UTILITY_TYPE_COPY) | |
9 | 1290 { |
753 | 1291 stock_id = GTK_STOCK_COPY; |
1292 } | |
1293 else | |
1294 { | |
1295 stock_id = GTK_STOCK_OK; | |
9 | 1296 } |
1297 | |
753 | 1298 fdlg = file_util_file_dlg(ud->messages.title, GQ_WMCLASS, "dlg_dest_folder", ud->parent, |
757 | 1299 file_util_fdlg_cancel_cb, ud); |
753 | 1300 |
1301 ud->fdlg = fdlg; | |
1302 | |
1303 generic_dialog_add_message(GENERIC_DIALOG(fdlg), NULL, ud->messages.question, NULL); | |
1304 | |
1305 label = pref_label_new(GENERIC_DIALOG(fdlg)->vbox, _("Choose the destination folder.")); | |
1306 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); | |
1307 pref_spacer(GENERIC_DIALOG(fdlg)->vbox, 0); | |
1308 | |
1309 file_dialog_add_button(fdlg, stock_id, ud->messages.title, file_util_fdlg_ok_cb, TRUE); | |
1310 | |
1311 file_dialog_add_path_widgets(fdlg, NULL, ud->dest_path, "move_copy", NULL, NULL); | |
1312 | |
1313 g_signal_connect(G_OBJECT(fdlg->entry), "changed", | |
1314 G_CALLBACK(file_util_dest_folder_entry_cb), ud); | |
1315 | |
1316 gtk_widget_show(GENERIC_DIALOG(fdlg)->dialog); | |
9 | 1317 } |
1318 | |
753 | 1319 |
9 | 1320 static GtkWidget *furm_simple_vlabel(GtkWidget *box, const gchar *text, gint expand) |
1321 { | |
1322 GtkWidget *vbox; | |
1323 GtkWidget *label; | |
1324 | |
1325 vbox = gtk_vbox_new(FALSE, 0); | |
1326 gtk_box_pack_start(GTK_BOX(box), vbox, expand, expand, 0); | |
1327 gtk_widget_show(vbox); | |
1328 | |
1329 label = gtk_label_new(text); | |
1330 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
1331 gtk_widget_show(label); | |
1332 | |
1333 return vbox; | |
1334 } | |
1335 | |
753 | 1336 |
1337 static void file_util_dialog_init_source_dest(UtilityData *ud) | |
9 | 1338 { |
753 | 1339 GtkTreeModel *store; |
9 | 1340 GtkTreeSelection *selection; |
753 | 1341 GtkWidget *box; |
9 | 1342 GtkWidget *hbox; |
1343 GtkWidget *box2; | |
1344 GtkWidget *table; | |
1345 GtkWidget *combo; | |
753 | 1346 GtkWidget *page; |
1 | 1347 |
753 | 1348 ud->gd = file_util_gen_dlg(ud->messages.title, GQ_WMCLASS, "dlg_confirm", |
757 | 1349 ud->parent, FALSE, file_util_cancel_cb, ud); |
138 | 1350 |
753 | 1351 box = generic_dialog_add_message(ud->gd, NULL, ud->messages.question, NULL); |
1352 generic_dialog_add_button(ud->gd, GTK_STOCK_OK, ud->messages.title, file_util_ok_cb, TRUE); | |
9 | 1353 |
753 | 1354 box = pref_group_new(box, TRUE, ud->messages.desc_flist, GTK_ORIENTATION_HORIZONTAL); |
9 | 1355 |
753 | 1356 ud->listview = file_util_dialog_add_list(box, ud->flist, FALSE); |
924
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
1357 file_util_dialog_add_list_column(ud->listview, _("Sidecars"), FALSE, UTILITY_COLUMN_SIDECARS); |
442 | 1358 |
924
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
1359 file_util_dialog_add_list_column(ud->listview, _("New name"), FALSE, UTILITY_COLUMN_DEST_NAME); |
1 | 1360 |
753 | 1361 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(ud->listview)); |
1362 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_SINGLE); | |
1363 gtk_tree_selection_set_select_function(selection, file_util_preview_cb, ud, NULL); | |
9 | 1364 |
1365 | |
753 | 1366 // column = file_util_rename_multiple_add_column(rd, _("Preview"), RENAME_COLUMN_PREVIEW); |
1367 // gtk_tree_view_column_set_visible(column, FALSE); | |
442 | 1368 |
753 | 1369 gtk_tree_view_set_reorderable(GTK_TREE_VIEW(ud->listview), TRUE); |
1370 | |
1371 store = gtk_tree_view_get_model(GTK_TREE_VIEW(ud->listview)); | |
9 | 1372 g_signal_connect(G_OBJECT(store), "row_changed", |
753 | 1373 G_CALLBACK(file_util_rename_preview_order_cb), ud); |
1374 gtk_widget_set_size_request(ud->listview, 300, 150); | |
1 | 1375 |
753 | 1376 generic_dialog_add_image(ud->gd, box, NULL, NULL, NULL, NULL, FALSE); |
9 | 1377 |
753 | 1378 // gtk_container_add(GTK_CONTAINER(scrolled), view); |
1379 gtk_widget_show(ud->gd->dialog); | |
9 | 1380 |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1381 |
753 | 1382 ud->notebook = gtk_notebook_new(); |
1383 | |
1384 gtk_box_pack_start(GTK_BOX(ud->gd->vbox), ud->notebook, FALSE, FALSE, 0); | |
1385 gtk_widget_show(ud->notebook); | |
1386 | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1387 |
753 | 1388 page = gtk_vbox_new(FALSE, PREF_PAD_GAP); |
1389 gtk_notebook_append_page(GTK_NOTEBOOK(ud->notebook), page, gtk_label_new(_("Manual rename"))); | |
1390 gtk_widget_show(page); | |
1391 | |
1392 table = pref_table_new(page, 2, 2, FALSE, FALSE); | |
9 | 1393 |
1394 pref_table_label(table, 0, 0, _("Original name:"), 1.0); | |
753 | 1395 ud->rename_label = pref_table_label(table, 1, 0, "", 0.0); |
9 | 1396 |
1397 pref_table_label(table, 0, 1, _("New name:"), 1.0); | |
1398 | |
753 | 1399 ud->rename_entry = gtk_entry_new(); |
1400 gtk_table_attach(GTK_TABLE(table), ud->rename_entry, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0); | |
1401 generic_dialog_attach_default(GENERIC_DIALOG(ud->gd), ud->rename_entry); | |
1402 gtk_widget_grab_focus(ud->rename_entry); | |
1403 | |
1404 g_signal_connect(G_OBJECT(ud->rename_entry), "changed", | |
1405 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
|
1406 |
753 | 1407 gtk_widget_show(ud->rename_entry); |
9 | 1408 |
753 | 1409 page = gtk_vbox_new(FALSE, PREF_PAD_GAP); |
1410 gtk_notebook_append_page(GTK_NOTEBOOK(ud->notebook), page, gtk_label_new(_("Auto rename"))); | |
1411 gtk_widget_show(page); | |
9 | 1412 |
753 | 1413 |
1414 hbox = pref_box_new(page, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_GAP); | |
9 | 1415 |
1416 box2 = furm_simple_vlabel(hbox, _("Begin text"), TRUE); | |
1417 | |
753 | 1418 combo = history_combo_new(&ud->auto_entry_front, "", "numerical_rename_prefix", -1); |
1419 g_signal_connect(G_OBJECT(ud->auto_entry_front), "changed", | |
1420 G_CALLBACK(file_util_rename_preview_entry_cb), ud); | |
9 | 1421 gtk_box_pack_start(GTK_BOX(box2), combo, TRUE, TRUE, 0); |
1422 gtk_widget_show(combo); | |
442 | 1423 |
9 | 1424 box2 = furm_simple_vlabel(hbox, _("Start #"), FALSE); |
1425 | |
753 | 1426 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
|
1427 0.0, 1000000.0, 1.0, 0, 1.0, |
753 | 1428 G_CALLBACK(file_util_rename_preview_adj_cb), ud); |
9 | 1429 |
1430 box2 = furm_simple_vlabel(hbox, _("End text"), TRUE); | |
1431 | |
753 | 1432 combo = history_combo_new(&ud->auto_entry_end, "", "numerical_rename_suffix", -1); |
1433 g_signal_connect(G_OBJECT(ud->auto_entry_end), "changed", | |
1434 G_CALLBACK(file_util_rename_preview_entry_cb), ud); | |
9 | 1435 gtk_box_pack_start(GTK_BOX(box2), combo, TRUE, TRUE, 0); |
1436 gtk_widget_show(combo); | |
1437 | |
753 | 1438 ud->auto_spin_pad = pref_spin_new(page, _("Padding:"), NULL, |
9 | 1439 1.0, 8.0, 1.0, 0, 1.0, |
753 | 1440 G_CALLBACK(file_util_rename_preview_adj_cb), ud); |
9 | 1441 |
753 | 1442 page = gtk_vbox_new(FALSE, PREF_PAD_GAP); |
1443 gtk_notebook_append_page(GTK_NOTEBOOK(ud->notebook), page, gtk_label_new(_("Formatted rename"))); | |
1444 gtk_widget_show(page); | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1445 |
753 | 1446 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
|
1447 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1448 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
|
1449 |
753 | 1450 combo = history_combo_new(&ud->format_entry, "", "auto_rename_format", -1); |
1451 g_signal_connect(G_OBJECT(ud->format_entry), "changed", | |
1452 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
|
1453 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
|
1454 gtk_widget_show(combo); |
442 | 1455 |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1456 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
|
1457 |
753 | 1458 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
|
1459 0.0, 1000000.0, 1.0, 0, 1.0, |
753 | 1460 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
|
1461 |
753 | 1462 // gtk_combo_box_set_active(GTK_COMBO_BOX(ud->combo_type), 0); /* callback will take care of the rest */ |
138 | 1463 |
753 | 1464 file_util_dialog_list_select(ud->listview, 0); |
1 | 1465 } |
1466 | |
9 | 1467 |
753 | 1468 void file_util_dialog_run(UtilityData *ud) |
1 | 1469 { |
753 | 1470 switch (ud->phase) |
1471 { | |
1472 case UTILITY_PHASE_START: | |
1473 /* create the dialogs */ | |
1474 switch (ud->type) | |
1475 { | |
1476 case UTILITY_TYPE_DELETE: | |
1477 case UTILITY_TYPE_DELETE_LINK: | |
1478 case UTILITY_TYPE_DELETE_FOLDER: | |
1479 case UTILITY_TYPE_EDITOR: | |
1480 file_util_dialog_init_simple_list(ud); | |
1481 break; | |
1482 case UTILITY_TYPE_RENAME: | |
1483 file_util_dialog_init_source_dest(ud); | |
1484 break; | |
1485 case UTILITY_TYPE_COPY: | |
1486 case UTILITY_TYPE_MOVE: | |
1487 case UTILITY_TYPE_FILTER: | |
901 | 1488 case UTILITY_TYPE_CREATE_FOLDER: |
753 | 1489 file_util_dialog_init_dest_folder(ud); |
1490 break; | |
934 | 1491 case UTILITY_TYPE_RENAME_FOLDER: |
1492 ud->phase = UTILITY_PHASE_CANCEL; /* FIXME - not handled for now */ | |
1493 file_util_dialog_run(ud); | |
1494 return; | |
753 | 1495 } |
1496 ud->phase = UTILITY_PHASE_ENTERING; | |
1497 break; | |
1498 case UTILITY_PHASE_ENTERING: | |
914
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
1499 file_util_check_ci(ud); |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
1500 break; |
753 | 1501 |
1502 ud->phase = UTILITY_PHASE_CHECKED; | |
1503 case UTILITY_PHASE_CHECKED: | |
1504 file_util_perform_ci(ud); | |
1505 break; | |
1506 case UTILITY_PHASE_CANCEL: | |
1507 case UTILITY_PHASE_DONE: | |
1508 file_data_sc_free_ci_list(ud->flist); | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1509 file_data_sc_free_ci_list(ud->content_list); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1510 if (ud->dir_fd) file_data_sc_free_ci(ud->dir_fd); |
753 | 1511 file_util_data_free(ud); |
1512 break; | |
1513 } | |
1 | 1514 } |
1515 | |
753 | 1516 |
1517 | |
1518 | |
757 | 1519 static void file_util_warn_op_in_progress(const gchar *title) |
1520 { | |
1521 file_util_warning_dialog(title, _("Another operation in progress.\n"), GTK_STOCK_DIALOG_ERROR, NULL); | |
1522 } | |
9 | 1523 |
849
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1524 static void file_util_disable_grouping_sc_list(GList *list) |
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1525 { |
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1526 GList *work = list; |
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1527 |
855 | 1528 while (work) |
849
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1529 { |
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1530 FileData *fd = work->data; |
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1531 work = work->next; |
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1532 |
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1533 if (fd->parent) file_data_disable_grouping(fd, TRUE); |
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1534 } |
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1535 |
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1536 } |
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1537 |
753 | 1538 static void file_util_delete_full(FileData *source_fd, GList *source_list, GtkWidget *parent, UtilityPhase phase) |
1539 { | |
1540 UtilityData *ud; | |
1541 GList *flist = filelist_copy(source_list); | |
1542 | |
1543 if (source_fd) | |
1544 flist = g_list_append(flist, file_data_ref(source_fd)); | |
9 | 1545 |
947
368643594bc8
abort file operations when the file list is empty
nadvornik
parents:
946
diff
changeset
|
1546 if (!flist) return; |
368643594bc8
abort file operations when the file list is empty
nadvornik
parents:
946
diff
changeset
|
1547 |
849
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1548 file_util_disable_grouping_sc_list(flist); |
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1549 |
753 | 1550 if (!file_data_sc_add_ci_delete_list(flist)) |
1551 { | |
757 | 1552 file_util_warn_op_in_progress(_("File deletion failed")); |
753 | 1553 filelist_free(flist); |
1 | 1554 return; |
1555 } | |
753 | 1556 |
1557 ud = file_util_data_new(UTILITY_TYPE_DELETE); | |
1558 | |
1559 ud->phase = phase; | |
138 | 1560 |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1561 ud->dir_fd = NULL; |
753 | 1562 ud->flist = flist; |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1563 ud->content_list = NULL; |
753 | 1564 ud->parent = parent; |
1565 | |
1566 ud->messages.title = _("Delete"); | |
1567 ud->messages.question = _("Delete files?"); | |
1568 ud->messages.desc_flist = _("This will delete the following files"); | |
1569 ud->messages.desc_source_fd = ""; | |
1570 ud->messages.fail = _("File deletion failed"); | |
1571 | |
1572 file_util_dialog_run(ud); | |
1 | 1573 } |
1574 | |
753 | 1575 static void file_util_move_full(FileData *source_fd, GList *source_list, const gchar *dest_path, GtkWidget *parent, UtilityPhase phase) |
1 | 1576 { |
753 | 1577 UtilityData *ud; |
1578 GList *flist = filelist_copy(source_list); | |
1579 | |
1580 if (source_fd) | |
1581 flist = g_list_append(flist, file_data_ref(source_fd)); | |
1582 | |
947
368643594bc8
abort file operations when the file list is empty
nadvornik
parents:
946
diff
changeset
|
1583 if (!flist) return; |
368643594bc8
abort file operations when the file list is empty
nadvornik
parents:
946
diff
changeset
|
1584 |
849
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1585 file_util_disable_grouping_sc_list(flist); |
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1586 |
753 | 1587 if (!file_data_sc_add_ci_move_list(flist, dest_path)) |
1588 { | |
757 | 1589 file_util_warn_op_in_progress(_("Move failed")); |
753 | 1590 filelist_free(flist); |
1591 return; | |
1592 } | |
1593 | |
1594 ud = file_util_data_new(UTILITY_TYPE_MOVE); | |
1595 | |
1596 ud->phase = phase; | |
1597 | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1598 ud->dir_fd = NULL; |
753 | 1599 ud->flist = flist; |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1600 ud->content_list = NULL; |
753 | 1601 ud->parent = parent; |
9 | 1602 |
900 | 1603 if (dest_path) ud->dest_path = g_strdup(dest_path); |
753 | 1604 |
1605 ud->messages.title = _("Move"); | |
1606 ud->messages.question = _("Move files?"); | |
1607 ud->messages.desc_flist = _("This will move the following files"); | |
1608 ud->messages.desc_source_fd = ""; | |
1609 ud->messages.fail = _("Move failed"); | |
138 | 1610 |
753 | 1611 file_util_dialog_run(ud); |
1612 } | |
1613 static void file_util_copy_full(FileData *source_fd, GList *source_list, const gchar *dest_path, GtkWidget *parent, UtilityPhase phase) | |
1614 { | |
1615 UtilityData *ud; | |
1616 GList *flist = filelist_copy(source_list); | |
1617 | |
1618 if (source_fd) | |
1619 flist = g_list_append(flist, file_data_ref(source_fd)); | |
1620 | |
947
368643594bc8
abort file operations when the file list is empty
nadvornik
parents:
946
diff
changeset
|
1621 if (!flist) return; |
368643594bc8
abort file operations when the file list is empty
nadvornik
parents:
946
diff
changeset
|
1622 |
849
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1623 file_util_disable_grouping_sc_list(flist); |
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1624 |
753 | 1625 if (!file_data_sc_add_ci_copy_list(flist, dest_path)) |
1 | 1626 { |
757 | 1627 file_util_warn_op_in_progress(_("Copy failed")); |
753 | 1628 filelist_free(flist); |
1 | 1629 return; |
1630 } | |
1631 | |
753 | 1632 ud = file_util_data_new(UTILITY_TYPE_COPY); |
1633 | |
1634 ud->phase = phase; | |
1635 | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1636 ud->dir_fd = NULL; |
753 | 1637 ud->flist = flist; |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1638 ud->content_list = NULL; |
753 | 1639 ud->parent = parent; |
9 | 1640 |
900 | 1641 if (dest_path) ud->dest_path = g_strdup(dest_path); |
753 | 1642 |
1643 ud->messages.title = _("Copy"); | |
1644 ud->messages.question = _("Copy files?"); | |
1645 ud->messages.desc_flist = _("This will copy the following files"); | |
1646 ud->messages.desc_source_fd = ""; | |
1647 ud->messages.fail = _("Copy failed"); | |
1 | 1648 |
753 | 1649 file_util_dialog_run(ud); |
9 | 1650 } |
1651 | |
753 | 1652 static void file_util_rename_full(FileData *source_fd, GList *source_list, const gchar *dest_path, GtkWidget *parent, UtilityPhase phase) |
1 | 1653 { |
753 | 1654 UtilityData *ud; |
1655 GList *flist = filelist_copy(source_list); | |
1656 | |
1657 if (source_fd) | |
1658 flist = g_list_append(flist, file_data_ref(source_fd)); | |
138 | 1659 |
947
368643594bc8
abort file operations when the file list is empty
nadvornik
parents:
946
diff
changeset
|
1660 if (!flist) return; |
368643594bc8
abort file operations when the file list is empty
nadvornik
parents:
946
diff
changeset
|
1661 |
849
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1662 file_util_disable_grouping_sc_list(flist); |
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1663 |
753 | 1664 if (!file_data_sc_add_ci_rename_list(flist, dest_path)) |
1665 { | |
757 | 1666 file_util_warn_op_in_progress(_("Rename failed")); |
753 | 1667 filelist_free(flist); |
1668 return; | |
1669 } | |
9 | 1670 |
753 | 1671 ud = file_util_data_new(UTILITY_TYPE_RENAME); |
138 | 1672 |
753 | 1673 ud->phase = phase; |
1 | 1674 |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1675 ud->dir_fd = NULL; |
753 | 1676 ud->flist = flist; |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1677 ud->content_list = NULL; |
753 | 1678 ud->parent = parent; |
1679 | |
1680 ud->messages.title = _("Rename"); | |
1681 ud->messages.question = _("Rename files?"); | |
1682 ud->messages.desc_flist = _("This will rename the following files"); | |
1683 ud->messages.desc_source_fd = ""; | |
1684 ud->messages.fail = _("Rename failed"); | |
138 | 1685 |
753 | 1686 file_util_dialog_run(ud); |
1 | 1687 } |
1688 | |
753 | 1689 static void file_util_start_editor_full(gint n, FileData *source_fd, GList *source_list, const gchar *dest_path, GtkWidget *parent, UtilityPhase phase) |
1690 { | |
1691 UtilityData *ud; | |
1692 GList *flist = filelist_copy(source_list); | |
1693 | |
1694 if (source_fd) | |
1695 flist = g_list_append(flist, file_data_ref(source_fd)); | |
1 | 1696 |
947
368643594bc8
abort file operations when the file list is empty
nadvornik
parents:
946
diff
changeset
|
1697 if (!flist) return; |
368643594bc8
abort file operations when the file list is empty
nadvornik
parents:
946
diff
changeset
|
1698 |
849
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1699 file_util_disable_grouping_sc_list(flist); |
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1700 |
753 | 1701 if (!file_data_sc_add_ci_unspecified_list(flist, dest_path)) |
1 | 1702 { |
757 | 1703 file_util_warn_op_in_progress(_("Can't run external editor")); |
753 | 1704 filelist_free(flist); |
1705 return; | |
1 | 1706 } |
9 | 1707 |
753 | 1708 if (editor_is_filter(n)) |
1709 ud = file_util_data_new(UTILITY_TYPE_FILTER); | |
1710 else | |
1711 ud = file_util_data_new(UTILITY_TYPE_EDITOR); | |
1712 | |
1713 | |
1714 /* ask for destination if we don't have it */ | |
1715 if (ud->type == UTILITY_TYPE_FILTER && dest_path == NULL) phase = UTILITY_PHASE_START; | |
1716 | |
1717 ud->phase = phase; | |
1718 | |
1719 ud->external_command = n; | |
1720 | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1721 ud->dir_fd = NULL; |
753 | 1722 ud->flist = flist; |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1723 ud->content_list = NULL; |
753 | 1724 ud->parent = parent; |
1725 | |
900 | 1726 if (dest_path) ud->dest_path = g_strdup(dest_path); |
753 | 1727 |
1728 ud->messages.title = _("Editor"); | |
1729 ud->messages.question = _("Run editor?"); | |
1730 ud->messages.desc_flist = _("This will copy the following files"); | |
1731 ud->messages.desc_source_fd = ""; | |
1732 ud->messages.fail = _("External command failed"); | |
1733 | |
1734 file_util_dialog_run(ud); | |
1 | 1735 } |
1736 | |
901 | 1737 static GList *file_util_delete_dir_remaining_folders(GList *dlist) |
1738 { | |
1739 GList *rlist = NULL; | |
1740 | |
1741 while (dlist) | |
1742 { | |
1743 FileData *fd; | |
1744 | |
1745 fd = dlist->data; | |
1746 dlist = dlist->next; | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1747 |
901 | 1748 if (!fd->name || |
1749 (strcmp(fd->name, THUMB_FOLDER_GLOBAL) != 0 && | |
1750 strcmp(fd->name, THUMB_FOLDER_LOCAL) != 0 && | |
1751 strcmp(fd->name, GQ_CACHE_LOCAL_METADATA) != 0) ) | |
1752 { | |
1753 rlist = g_list_prepend(rlist, fd); | |
1754 } | |
1755 } | |
1756 | |
1757 return g_list_reverse(rlist); | |
1758 } | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1759 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1760 static gboolean file_util_delete_dir_empty_path(UtilityData *ud, FileData *fd, gint level) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1761 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1762 GList *dlist; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1763 GList *flist; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1764 GList *work; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1765 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1766 gboolean ok = TRUE; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1767 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1768 DEBUG_1("deltree into: %s", fd->path); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1769 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1770 level++; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1771 if (level > UTILITY_DELETE_MAX_DEPTH) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1772 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1773 log_printf("folder recursion depth past %d, giving up\n", UTILITY_DELETE_MAX_DEPTH); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1774 // ud->fail_fd = fd |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1775 return 0; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1776 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1777 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1778 if (!filelist_read_lstat(fd, &flist, &dlist)) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1779 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1780 // ud->fail_fd = fd |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1781 return 0; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1782 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1783 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1784 if (ok) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1785 { |
921 | 1786 ok = file_data_sc_add_ci_delete(fd); |
1787 if (ok) | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1788 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1789 ud->content_list = g_list_prepend(ud->content_list, fd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1790 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1791 // ud->fail_fd = fd |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1792 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1793 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1794 work = dlist; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1795 while (work && ok) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1796 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1797 FileData *lfd; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1798 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1799 lfd = work->data; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1800 work = work->next; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1801 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1802 ok = file_util_delete_dir_empty_path(ud, lfd, level); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1803 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1804 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1805 work = flist; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1806 while (work && ok) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1807 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1808 FileData *lfd; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1809 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1810 lfd = work->data; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1811 work = work->next; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1812 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1813 DEBUG_1("deltree child: %s", lfd->path); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1814 |
921 | 1815 ok = file_data_sc_add_ci_delete(lfd); |
1816 if (ok) | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1817 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1818 ud->content_list = g_list_prepend(ud->content_list, lfd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1819 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1820 // ud->fail_fd = fd |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1821 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1822 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1823 filelist_free(dlist); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1824 filelist_free(flist); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1825 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1826 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1827 DEBUG_1("deltree done: %s", fd->path); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1828 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1829 return ok; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1830 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1831 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1832 static gboolean file_util_delete_dir_prepare(UtilityData *ud, GList *flist, GList *dlist) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1833 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1834 gboolean ok = TRUE; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1835 GList *work; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1836 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1837 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1838 work = dlist; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1839 while (work && ok) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1840 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1841 FileData *fd; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1842 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1843 fd = work->data; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1844 work = work->next; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1845 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1846 ok = file_util_delete_dir_empty_path(ud, fd, 0); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1847 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1848 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1849 work = flist; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1850 if (ok && file_data_sc_add_ci_delete_list(flist)) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1851 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1852 ud->content_list = g_list_concat(filelist_copy(flist), ud->content_list); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1853 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1854 else |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1855 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1856 ok = FALSE; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1857 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1858 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1859 if (ok) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1860 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1861 ok = file_data_sc_add_ci_delete(ud->dir_fd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1862 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1863 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1864 if (!ok) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1865 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1866 work = ud->content_list; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1867 while (work) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1868 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1869 FileData *fd; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1870 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1871 fd = work->data; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1872 work = work->next; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1873 file_data_sc_free_ci(fd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1874 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1875 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1876 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1877 return ok; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1878 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1879 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1880 static void file_util_delete_dir_full(FileData *fd, GtkWidget *parent, UtilityPhase phase) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1881 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1882 GList *dlist; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1883 GList *flist; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1884 GList *rlist; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1885 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1886 if (!isdir(fd->path)) return; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1887 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1888 if (islink(fd->path)) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1889 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1890 UtilityData *ud; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1891 ud = file_util_data_new(UTILITY_TYPE_DELETE_LINK); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1892 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1893 ud->phase = phase; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1894 ud->dir_fd = file_data_ref(fd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1895 ud->content_list = NULL; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1896 ud->flist = NULL; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1897 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1898 ud->parent = parent; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1899 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1900 ud->messages.title = _("Delete folder"); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1901 ud->messages.question = _("Delete symbolic link?"); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1902 ud->messages.desc_flist = ""; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1903 ud->messages.desc_source_fd = _("This will delete the symbolic link.\n" |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1904 "The folder this link points to will not be deleted."); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1905 ud->messages.fail = _("Link deletion failed"); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1906 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1907 file_util_dialog_run(ud); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1908 return; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1909 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1910 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1911 if (!access_file(fd->path, W_OK | X_OK)) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1912 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1913 gchar *text; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1914 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1915 text = g_strdup_printf(_("Unable to remove folder %s\n" |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1916 "Permissions do not allow writing to the folder."), fd->path); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1917 file_util_warning_dialog(_("Delete failed"), text, GTK_STOCK_DIALOG_ERROR, parent); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1918 g_free(text); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1919 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1920 return; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1921 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1922 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1923 if (!filelist_read_lstat(fd, &flist, &dlist)) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1924 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1925 gchar *text; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1926 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1927 text = g_strdup_printf(_("Unable to list contents of folder %s"), fd->path); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1928 file_util_warning_dialog(_("Delete failed"), text, GTK_STOCK_DIALOG_ERROR, parent); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1929 g_free(text); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1930 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1931 return; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1932 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1933 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1934 rlist = file_util_delete_dir_remaining_folders(dlist); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1935 if (rlist) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1936 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1937 GenericDialog *gd; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1938 GtkWidget *box; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1939 gchar *text; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1940 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1941 gd = file_util_gen_dlg(_("Folder contains subfolders"), GQ_WMCLASS, "dlg_warning", |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1942 parent, TRUE, NULL, NULL); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1943 generic_dialog_add_button(gd, GTK_STOCK_CLOSE, NULL, NULL, TRUE); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1944 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1945 text = g_strdup_printf(_("Unable to delete the folder:\n\n%s\n\n" |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1946 "This folder contains subfolders which must be moved before it can be deleted."), |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1947 fd->path); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1948 box = generic_dialog_add_message(gd, GTK_STOCK_DIALOG_WARNING, |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1949 _("Folder contains subfolders"), |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1950 text); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1951 g_free(text); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1952 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1953 box = pref_group_new(box, TRUE, _("Subfolders:"), GTK_ORIENTATION_VERTICAL); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1954 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1955 rlist = filelist_sort_path(rlist); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1956 file_util_dialog_add_list(box, rlist, FALSE); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1957 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1958 gtk_widget_show(gd->dialog); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1959 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1960 else |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1961 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1962 UtilityData *ud; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1963 ud = file_util_data_new(UTILITY_TYPE_DELETE_FOLDER); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1964 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1965 ud->phase = phase; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1966 ud->dir_fd = file_data_ref(fd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1967 ud->content_list = NULL; /* will be filled by file_util_delete_dir_prepare */ |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1968 ud->flist = flist = filelist_sort_path(flist); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1969 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1970 ud->parent = parent; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1971 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1972 ud->messages.title = _("Delete folder"); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1973 ud->messages.question = _("Delete folder?"); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1974 ud->messages.desc_flist = _("The folder contains these files:"); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1975 ud->messages.desc_source_fd = _("This will delete the folder.\n" |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1976 "The contents of this folder will also be deleted."); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1977 ud->messages.fail = _("File deletion failed"); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1978 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1979 if (!file_util_delete_dir_prepare(ud, flist, dlist)) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1980 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1981 gchar *text; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1982 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1983 text = g_strdup_printf(_("Unable to list contents of folder %s"), fd->path); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1984 file_util_warning_dialog(_("Delete failed"), text, GTK_STOCK_DIALOG_ERROR, parent); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1985 g_free(text); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1986 file_data_unref(ud->dir_fd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1987 file_util_data_free(ud); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1988 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1989 else |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1990 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1991 filelist_free(dlist); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1992 file_util_dialog_run(ud); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1993 return; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1994 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1995 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1996 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1997 g_list_free(rlist); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1998 filelist_free(dlist); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1999 filelist_free(flist); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2000 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2001 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2002 static gboolean file_util_rename_dir_scan(UtilityData *ud, FileData *fd) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2003 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2004 GList *dlist; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2005 GList *flist; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2006 GList *work; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2007 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2008 gboolean ok = TRUE; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2009 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2010 if (!filelist_read_lstat(fd, &flist, &dlist)) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2011 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2012 // ud->fail_fd = fd |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2013 return 0; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2014 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2015 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2016 ud->content_list = g_list_concat(flist, ud->content_list); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2017 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2018 work = dlist; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2019 while (work && ok) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2020 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2021 FileData *lfd; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2022 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2023 lfd = work->data; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2024 work = work->next; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2025 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2026 ud->content_list = g_list_prepend(ud->content_list, file_data_ref(lfd)); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2027 ok = file_util_rename_dir_scan(ud, lfd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2028 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2029 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2030 filelist_free(dlist); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2031 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2032 return ok; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2033 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2034 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2035 static gboolean file_util_rename_dir_prepare(UtilityData *ud, const char *new_path) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2036 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2037 gboolean ok; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2038 GList *work; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2039 gint orig_len = strlen(ud->dir_fd->path); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2040 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2041 ok = file_util_rename_dir_scan(ud, ud->dir_fd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2042 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2043 work = ud->content_list; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2044 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2045 while (ok && work) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2046 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2047 gchar *np; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2048 FileData *fd; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2049 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2050 fd = work->data; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2051 work = work->next; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2052 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2053 g_assert(strncmp(fd->path, ud->dir_fd->path, orig_len) == 0); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2054 |
921 | 2055 np = g_strconcat(new_path, fd->path + orig_len, NULL); |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2056 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2057 ok = file_data_sc_add_ci_rename(fd, np); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2058 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2059 DEBUG_1("Dir rename: %s -> %s", fd->path, np); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2060 g_free(np); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2061 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2062 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2063 if (ok) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2064 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2065 ok = file_data_sc_add_ci_rename(ud->dir_fd, new_path); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2066 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2067 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2068 if (!ok) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2069 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2070 work = ud->content_list; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2071 while (work) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2072 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2073 FileData *fd; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2074 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2075 fd = work->data; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2076 work = work->next; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2077 file_data_sc_free_ci(fd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2078 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2079 } |
921 | 2080 |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2081 return ok; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2082 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2083 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2084 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2085 static void file_util_rename_dir_full(FileData *fd, const char *new_path, GtkWidget *parent, UtilityPhase phase) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2086 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2087 UtilityData *ud; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2088 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2089 ud = file_util_data_new(UTILITY_TYPE_RENAME_FOLDER); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2090 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2091 ud->phase = phase; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2092 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2093 ud->dir_fd = file_data_ref(fd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2094 ud->flist = NULL; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2095 ud->content_list = NULL; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2096 ud->parent = parent; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2097 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2098 ud->messages.title = _("Rename"); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2099 ud->messages.question = _("Rename folder?"); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2100 ud->messages.desc_flist = _("The folder contains the following files"); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2101 ud->messages.desc_source_fd = ""; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2102 ud->messages.fail = _("Rename failed"); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2103 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2104 if (!file_util_rename_dir_prepare(ud, new_path)) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2105 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2106 file_util_warn_op_in_progress(ud->messages.fail); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2107 file_util_data_free(ud); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2108 return; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2109 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2110 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2111 // ud->flist = filelist_recursive(fd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2112 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2113 file_util_dialog_run(ud); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2114 } |
753 | 2115 |
901 | 2116 static void file_util_create_dir_full(FileData *fd, const char *dest_path, GtkWidget *parent, UtilityPhase phase) |
1 | 2117 { |
901 | 2118 UtilityData *ud; |
2119 | |
2120 ud = file_util_data_new(UTILITY_TYPE_CREATE_FOLDER); | |
2121 | |
2122 ud->phase = phase; | |
2123 | |
2124 ud->dir_fd = NULL; | |
2125 ud->flist = NULL; | |
2126 ud->content_list = NULL; | |
2127 ud->parent = parent; | |
2128 | |
2129 if (dest_path) | |
2130 { | |
2131 ud->dest_path = g_strdup(dest_path); | |
2132 } | |
2133 else | |
2134 { | |
2135 gchar *buf = g_build_filename(fd->path, _("New folder"), NULL); | |
2136 ud->dest_path = unique_filename(buf, NULL, " ", FALSE); | |
2137 g_free(buf); | |
2138 } | |
2139 | |
2140 ud->dir_fd = file_data_new_simple(ud->dest_path); | |
2141 | |
2142 ud->messages.title = _("Create Folder"); | |
2143 ud->messages.question = _("Create folder?"); | |
2144 ud->messages.desc_flist = ""; | |
2145 ud->messages.desc_source_fd = ""; | |
2146 ud->messages.fail = _("Can't create folder"); | |
2147 | |
2148 file_util_dialog_run(ud); | |
1 | 2149 } |
757 | 2150 |
9 | 2151 |
757 | 2152 /* full-featured entry points |
753 | 2153 */ |
1 | 2154 |
753 | 2155 void file_util_delete(FileData *source_fd, GList *source_list, GtkWidget *parent) |
2156 { | |
2157 file_util_delete_full(source_fd, source_list, parent, UTILITY_PHASE_START); | |
2158 } | |
9 | 2159 |
753 | 2160 void file_util_copy(FileData *source_fd, GList *source_list, const gchar *dest_path, GtkWidget *parent) |
2161 { | |
2162 file_util_copy_full(source_fd, source_list, dest_path, parent, UTILITY_PHASE_START); | |
2163 } | |
757 | 2164 |
753 | 2165 void file_util_move(FileData *source_fd, GList *source_list, const gchar *dest_path, GtkWidget *parent) |
2166 { | |
2167 file_util_move_full(source_fd, source_list, dest_path, parent, UTILITY_PHASE_START); | |
2168 } | |
757 | 2169 |
753 | 2170 void file_util_rename(FileData *source_fd, GList *source_list, GtkWidget *parent) |
2171 { | |
2172 file_util_rename_full(source_fd, source_list, NULL, parent, UTILITY_PHASE_START); | |
1 | 2173 } |
2174 | |
753 | 2175 /* these avoid the location entry dialog unless there is an error, list must be files only and |
2176 * dest_path must be a valid directory path | |
757 | 2177 */ |
753 | 2178 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
|
2179 { |
753 | 2180 file_util_move_full(NULL, list, dest_path, parent, UTILITY_PHASE_ENTERING); |
2181 } | |
757 | 2182 |
753 | 2183 void file_util_copy_simple(GList *list, const gchar *dest_path, GtkWidget *parent) |
2184 { | |
2185 file_util_copy_full(NULL, list, dest_path, parent, UTILITY_PHASE_ENTERING); | |
2186 } | |
757 | 2187 |
753 | 2188 void file_util_rename_simple(FileData *fd, const gchar *dest_path, GtkWidget *parent) |
2189 { | |
2190 file_util_rename_full(fd, NULL, dest_path, parent, UTILITY_PHASE_ENTERING); | |
2191 } | |
138 | 2192 |
44
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2193 |
753 | 2194 void file_util_start_editor_from_file(gint n, FileData *fd, GtkWidget *parent) |
2195 { | |
2196 file_util_start_editor_full(n, fd, NULL, NULL, parent, UTILITY_PHASE_ENTERING); | |
2197 } | |
2198 | |
2199 void file_util_start_editor_from_filelist(gint n, GList *list, GtkWidget *parent) | |
2200 { | |
2201 file_util_start_editor_full(n, NULL, list, NULL, parent, UTILITY_PHASE_ENTERING); | |
2202 } | |
44
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2203 |
753 | 2204 void file_util_start_filter_from_file(gint n, FileData *fd, const gchar *dest_path, GtkWidget *parent) |
2205 { | |
2206 file_util_start_editor_full(n, fd, NULL, dest_path, parent, UTILITY_PHASE_ENTERING); | |
2207 } | |
44
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2208 |
753 | 2209 void file_util_start_filter_from_filelist(gint n, GList *list, const gchar *dest_path, GtkWidget *parent) |
2210 { | |
2211 file_util_start_editor_full(n, NULL, list, dest_path, parent, UTILITY_PHASE_ENTERING); | |
2212 } | |
44
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2213 |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2214 void file_util_delete_dir(FileData *fd, GtkWidget *parent) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2215 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2216 file_util_delete_dir_full(fd, parent, UTILITY_PHASE_START); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2217 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2218 |
901 | 2219 void file_util_create_dir(FileData *dir_fd, GtkWidget *parent) |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2220 { |
901 | 2221 file_util_create_dir_full(dir_fd, NULL, parent, UTILITY_PHASE_ENTERING); |
2222 } | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2223 |
908 | 2224 void file_util_rename_dir(FileData *source_fd, const gchar *new_path, GtkWidget *parent) |
901 | 2225 { |
2226 file_util_rename_dir_full(source_fd, new_path, parent, UTILITY_PHASE_ENTERING); | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2227 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2228 |
753 | 2229 |
2230 void file_util_copy_path_to_clipboard(FileData *fd) | |
2231 { | |
2232 GtkClipboard *clipboard; | |
2233 | |
2234 if (!fd || !*fd->path) return; | |
2235 | |
2236 clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); | |
2237 gtk_clipboard_set_text(clipboard, g_shell_quote(fd->path), -1); | |
2238 } | |
2239 | |
2240 void file_util_copy_path_list_to_clipboard(GList *list) | |
2241 { | |
2242 GtkClipboard *clipboard; | |
2243 GList *work; | |
2244 GString *new; | |
2245 | |
2246 clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); | |
2247 | |
2248 new = g_string_new(""); | |
2249 work = list; | |
2250 while (work) { | |
2251 FileData *fd = work->data; | |
2252 work = work->next; | |
2253 | |
2254 if (!fd || !*fd->path) continue; | |
2255 | |
2256 g_string_append(new, g_shell_quote(fd->path)); | |
2257 if (work) g_string_append_c(new, ' '); | |
2258 } | |
2259 | |
2260 gtk_clipboard_set_text(clipboard, new->str, new->len); | |
2261 g_string_free(new, TRUE); | |
2262 } |