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