Mercurial > geeqie
annotate src/utilops.c @ 1224:ebfd305d902e
improved sidecar writting
private metadata can be saved in xmp format
author | nadvornik |
---|---|
date | Fri, 26 Dec 2008 14:12:36 +0000 |
parents | 584eae03d747 |
children | ca8ccf0c3e81 |
rev | line source |
---|---|
1 | 1 /* |
196 | 2 * Geeqie |
67
f63ecca6c087
Fri Oct 13 05:22:43 2006 John Ellis <johne@verizon.net>
gqview
parents:
66
diff
changeset
|
3 * (C) 2006 John Ellis |
475 | 4 * Copyright (C) 2008 The Geeqie Team |
1 | 5 * |
6 * Author: John Ellis | |
7 * | |
9 | 8 * This software is released under the GNU General Public License (GNU GPL). |
9 * Please read the included file COPYING for more information. | |
10 * This software comes with no warranty of any kind, use at your own risk! | |
1 | 11 */ |
12 | |
9 | 13 |
281 | 14 #include "main.h" |
9 | 15 #include "utilops.h" |
16 | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
17 #include "cache.h" |
9 | 18 #include "cache_maint.h" |
19 #include "collect.h" | |
20 #include "dupe.h" | |
586 | 21 #include "filedata.h" |
22 #include "filefilter.h" | |
9 | 23 #include "image.h" |
24 #include "img-view.h" | |
25 #include "layout.h" | |
26 #include "search.h" | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
27 #include "thumb_standard.h" |
597 | 28 #include "trash.h" |
9 | 29 #include "ui_bookmark.h" |
30 #include "ui_fileops.h" | |
31 #include "ui_misc.h" | |
32 #include "ui_tabcomp.h" | |
140 | 33 #include "editors.h" |
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, | |
9 | 50 gint show_filename) |
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, |
9 | 157 GtkWidget *parent, gint auto_close, |
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 |
315 gint external_command; | |
316 gpointer resume_data; | |
317 }; | |
318 | |
319 enum { | |
320 UTILITY_COLUMN_FD = 0, | |
924
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
321 UTILITY_COLUMN_PIXBUF, |
753 | 322 UTILITY_COLUMN_PATH, |
323 UTILITY_COLUMN_NAME, | |
324 UTILITY_COLUMN_SIDECARS, | |
325 UTILITY_COLUMN_DEST_PATH, | |
326 UTILITY_COLUMN_DEST_NAME, | |
327 UTILITY_COLUMN_COUNT | |
328 }; | |
329 | |
330 #define UTILITY_LIST_MIN_WIDTH 250 | |
331 #define UTILITY_LIST_MIN_HEIGHT 150 | |
332 | |
333 /* thumbnail spec has a max depth of 4 (.thumb??/fail/appname/??.png) */ | |
334 #define UTILITY_DELETE_MAX_DEPTH 5 | |
335 | |
336 static UtilityData *file_util_data_new(UtilityType type) | |
136 | 337 { |
753 | 338 UtilityData *ud; |
339 | |
340 ud = g_new0(UtilityData, 1); | |
341 ud->type = type; | |
342 ud->phase = UTILITY_PHASE_START; | |
343 ud->update_idle_id = -1; | |
1221 | 344 ud->perform_idle_id = -1; |
753 | 345 ud->external_command = -1; |
346 return ud; | |
347 } | |
348 | |
349 static void file_util_data_free(UtilityData *ud) | |
350 { | |
351 if (!ud) return; | |
352 | |
353 if (ud->update_idle_id != -1) g_source_remove(ud->update_idle_id); | |
1221 | 354 if (ud->perform_idle_id != -1) g_source_remove(ud->perform_idle_id); |
753 | 355 |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
356 file_data_unref(ud->dir_fd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
357 filelist_free(ud->content_list); |
753 | 358 filelist_free(ud->flist); |
359 | |
360 if (ud->gd) generic_dialog_close(ud->gd); | |
361 | |
362 g_free(ud->dest_path); | |
363 | |
364 g_free(ud); | |
365 } | |
366 | |
924
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
367 static GtkTreeViewColumn *file_util_dialog_add_list_column(GtkWidget *view, const gchar *text, gboolean image, gint n) |
753 | 368 { |
369 GtkTreeViewColumn *column; | |
370 GtkCellRenderer *renderer; | |
371 | |
372 column = gtk_tree_view_column_new(); | |
373 gtk_tree_view_column_set_title(column, text); | |
374 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
|
375 if (image) |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
376 { |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
377 gtk_tree_view_column_set_min_width(column, 20); |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
378 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
|
379 renderer = gtk_cell_renderer_pixbuf_new(); |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
380 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
|
381 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
|
382 } |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
383 else |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
384 { |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
385 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
|
386 renderer = gtk_cell_renderer_text_new(); |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
387 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
|
388 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
|
389 } |
753 | 390 gtk_tree_view_append_column(GTK_TREE_VIEW(view), column); |
391 | |
392 return column; | |
393 } | |
394 | |
395 static void file_util_dialog_list_select(GtkWidget *view, gint n) | |
396 { | |
397 GtkTreeModel *store; | |
398 GtkTreeIter iter; | |
399 GtkTreeSelection *selection; | |
400 | |
401 store = gtk_tree_view_get_model(GTK_TREE_VIEW(view)); | |
402 if (gtk_tree_model_iter_nth_child(store, &iter, NULL, n)) | |
140 | 403 { |
753 | 404 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view)); |
405 gtk_tree_selection_select_iter(selection, &iter); | |
406 } | |
407 } | |
408 | |
1211 | 409 static GtkWidget *file_util_dialog_add_list(GtkWidget *box, GList *list, gint full_paths, gboolean with_sidecars) |
753 | 410 { |
411 GtkWidget *scrolled; | |
412 GtkWidget *view; | |
413 GtkListStore *store; | |
414 | |
415 scrolled = gtk_scrolled_window_new(NULL, NULL); | |
416 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN); | |
417 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), | |
418 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
419 gtk_box_pack_start(GTK_BOX(box), scrolled, TRUE, TRUE, 0); | |
420 gtk_widget_show(scrolled); | |
421 | |
924
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
422 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 | 423 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); |
424 g_object_unref(store); | |
425 | |
426 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), TRUE); | |
427 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(view), FALSE); | |
428 | |
924
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
429 file_util_dialog_add_list_column(view, "", TRUE, UTILITY_COLUMN_PIXBUF); |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
430 |
753 | 431 if (full_paths) |
432 { | |
924
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
433 file_util_dialog_add_list_column(view, _("Location"), FALSE, UTILITY_COLUMN_PATH); |
140 | 434 } |
138 | 435 else |
436 { | |
924
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
437 file_util_dialog_add_list_column(view, _("Name"), FALSE, UTILITY_COLUMN_NAME); |
138 | 438 } |
439 | |
753 | 440 gtk_widget_set_size_request(view, UTILITY_LIST_MIN_WIDTH, UTILITY_LIST_MIN_HEIGHT); |
441 gtk_container_add(GTK_CONTAINER(scrolled), view); | |
442 gtk_widget_show(view); | |
136 | 443 |
140 | 444 while (list) |
445 { | |
446 FileData *fd = list->data; | |
753 | 447 GtkTreeIter iter; |
448 gchar *sidecars; | |
449 | |
1211 | 450 sidecars = with_sidecars ? file_data_sc_list_to_string(fd) : NULL; |
1224 | 451 GdkPixbuf *icon = file_util_get_error_icon(fd, view); |
753 | 452 gtk_list_store_append(store, &iter); |
757 | 453 gtk_list_store_set(store, &iter, |
454 UTILITY_COLUMN_FD, fd, | |
1224 | 455 UTILITY_COLUMN_PIXBUF, icon, |
757 | 456 UTILITY_COLUMN_PATH, fd->path, |
457 UTILITY_COLUMN_NAME, fd->name, | |
458 UTILITY_COLUMN_SIDECARS, sidecars, | |
459 UTILITY_COLUMN_DEST_PATH, fd->change ? fd->change->dest : "error", | |
460 UTILITY_COLUMN_DEST_NAME, fd->change ? filename_from_path(fd->change->dest) : "error", | |
461 -1); | |
753 | 462 g_free(sidecars); |
463 | |
140 | 464 list = list->next; |
465 } | |
753 | 466 |
467 return view; | |
468 } | |
469 | |
470 | |
1221 | 471 static gboolean file_util_perform_ci_internal(gpointer data); |
753 | 472 void file_util_dialog_run(UtilityData *ud); |
473 static gint file_util_perform_ci_cb(gpointer resume_data, gint flags, GList *list, gpointer data); | |
474 | |
475 /* call file_util_perform_ci_internal or start_editor_from_filelist_full */ | |
476 | |
477 | |
478 static void file_util_resume_cb(GenericDialog *gd, gpointer data) | |
479 { | |
480 UtilityData *ud = data; | |
481 if (ud->external) | |
482 editor_resume(ud->resume_data); | |
483 else | |
484 file_util_perform_ci_internal(ud); | |
485 } | |
486 | |
487 static void file_util_abort_cb(GenericDialog *gd, gpointer data) | |
488 { | |
489 UtilityData *ud = data; | |
490 if (ud->external) | |
491 editor_skip(ud->resume_data); | |
492 else | |
493 file_util_perform_ci_cb(NULL, EDITOR_ERROR_SKIPPED, ud->flist, ud); | |
140 | 494 |
495 } | |
496 | |
497 | |
753 | 498 static gint file_util_perform_ci_cb(gpointer resume_data, gint flags, GList *list, gpointer data) |
1 | 499 { |
753 | 500 UtilityData *ud = data; |
501 ud->resume_data = resume_data; | |
497 | 502 |
140 | 503 gint ret = EDITOR_CB_CONTINUE; |
504 if ((flags & EDITOR_ERROR_MASK) && !(flags & EDITOR_ERROR_SKIPPED)) | |
505 { | |
757 | 506 GString *msg = g_string_new(editor_get_error_str(flags)); |
507 GenericDialog *d; | |
508 g_string_append(msg, "\n"); | |
509 g_string_append(msg, ud->messages.fail); | |
510 g_string_append(msg, "\n"); | |
511 while (list) | |
512 { | |
513 FileData *fd = list->data; | |
442 | 514 |
757 | 515 g_string_append(msg, fd->path); |
516 g_string_append(msg, "\n"); | |
517 list = list->next; | |
518 } | |
519 if (resume_data) | |
520 { | |
521 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
|
522 d = file_util_gen_dlg(ud->messages.fail, "dlg_confirm", |
757 | 523 NULL, TRUE, |
524 file_util_abort_cb, ud); | |
140 | 525 |
757 | 526 generic_dialog_add_message(d, GTK_STOCK_DIALOG_WARNING, NULL, msg->str); |
140 | 527 |
757 | 528 generic_dialog_add_button(d, GTK_STOCK_GO_FORWARD, _("Co_ntinue"), |
529 file_util_resume_cb, TRUE); | |
530 gtk_widget_show(d->dialog); | |
531 ret = EDITOR_CB_SUSPEND; | |
532 } | |
533 else | |
534 { | |
535 file_util_warning_dialog(ud->messages.fail, msg->str, GTK_STOCK_DIALOG_ERROR, NULL); | |
536 } | |
537 g_string_free(msg, TRUE); | |
140 | 538 } |
442 | 539 |
540 | |
753 | 541 while (list) /* be careful, file_util_perform_ci_internal can pass ud->flist as list */ |
140 | 542 { |
753 | 543 FileData *fd = list->data; |
995 | 544 list = list->next; |
753 | 545 |
546 if (!(flags & EDITOR_ERROR_MASK)) /* files were successfully deleted, call the maint functions */ | |
761 | 547 { |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
548 if (ud->with_sidecars) |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
549 file_data_sc_apply_ci(fd); |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
550 else |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
551 file_data_apply_ci(fd); |
761 | 552 } |
753 | 553 |
554 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
|
555 |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
556 /* FIXME: put it here for now */ |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
557 if (ud->type == UTILITY_TYPE_WRITE_METADATA) |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
558 { |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
559 metadata_write_queue_remove(fd); |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
560 } |
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 if (ud->with_sidecars) |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
563 file_data_sc_free_ci(fd); |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
564 else |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
565 file_data_free_ci(fd); |
753 | 566 file_data_unref(fd); |
140 | 567 } |
753 | 568 |
569 if (!resume_data) /* end of the list */ | |
570 { | |
571 ud->phase = UTILITY_PHASE_DONE; | |
572 file_util_dialog_run(ud); | |
573 } | |
574 | |
140 | 575 return ret; |
576 } | |
577 | |
143
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
140
diff
changeset
|
578 |
753 | 579 /* |
756 | 580 * Perform the operation described by FileDataChangeInfo on all files in the list |
753 | 581 * it is an alternative to start_editor_from_filelist_full, it should use similar interface |
995 | 582 */ |
143
0d1bf3ac6cd8
improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents:
140
diff
changeset
|
583 |
1 | 584 |
1221 | 585 static gboolean file_util_perform_ci_internal(gpointer data) |
753 | 586 { |
1221 | 587 UtilityData *ud = data; |
588 | |
589 /* this is removed when ud is destroyed */ | |
590 if (ud->perform_idle_id == -1) ud->perform_idle_id = g_idle_add(file_util_perform_ci_internal, ud); | |
591 | |
592 g_assert(ud->flist); | |
753 | 593 |
1221 | 594 if (ud->flist) |
1 | 595 { |
753 | 596 gint ret; |
597 | |
598 /* take a single entry each time, this allows better control over the operation */ | |
599 GList *single_entry = g_list_append(NULL, ud->flist->data); | |
600 gboolean last = !ud->flist->next; | |
757 | 601 gint status = EDITOR_ERROR_STATUS; |
602 | |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
603 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
|
604 : file_data_perform_ci(single_entry->data)) |
757 | 605 status = 0; /* OK */ |
606 | |
607 ret = file_util_perform_ci_cb(GINT_TO_POINTER(!last), status, single_entry, ud); | |
753 | 608 g_list_free(single_entry); |
609 | |
1221 | 610 if (ret == EDITOR_CB_SUSPEND || last) return FALSE; |
753 | 611 |
612 if (ret == EDITOR_CB_SKIP) | |
613 { | |
614 file_util_perform_ci_cb(NULL, EDITOR_ERROR_SKIPPED, ud->flist, ud); | |
1221 | 615 return FALSE; |
753 | 616 } |
1 | 617 } |
1221 | 618 |
619 return TRUE; | |
1 | 620 } |
621 | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
622 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
|
623 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
624 switch (ud->type) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
625 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
626 case UTILITY_TYPE_DELETE_LINK: |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
627 { |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
628 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
|
629 if ((internal && file_data_perform_ci(ud->dir_fd)) || |
897 | 630 (!internal && ext_result)) |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
631 { |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
632 file_data_apply_ci(ud->dir_fd); |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
633 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
634 else |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
635 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
636 gchar *text; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
637 |
901 | 638 text = g_strdup_printf("%s:\n\n%s", ud->messages.fail, ud->dir_fd->path); |
639 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
|
640 g_free(text); |
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 file_data_free_ci(ud->dir_fd); |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
643 break; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
644 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
645 case UTILITY_TYPE_DELETE_FOLDER: |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
646 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
647 FileData *fail = NULL; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
648 GList *work; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
649 work = ud->content_list; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
650 while (work) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
651 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
652 FileData *fd; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
653 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
654 fd = work->data; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
655 work = work->next; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
656 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
657 if (!fail) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
658 { |
897 | 659 if ((internal && file_data_sc_perform_ci(fd)) || |
660 (!internal && ext_result)) | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
661 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
662 file_data_sc_apply_ci(fd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
663 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
664 else |
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 if (internal) fail = file_data_ref(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 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
669 file_data_sc_free_ci(fd); |
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 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
672 if (!fail) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
673 { |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
674 g_assert(ud->dir_fd->sidecar_files == NULL); // directories should not have sidecars |
897 | 675 if ((internal && file_data_sc_perform_ci(ud->dir_fd)) || |
676 (!internal && ext_result)) | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
677 { |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
678 file_data_apply_ci(ud->dir_fd); |
896
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 else |
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 fail = file_data_ref(ud->dir_fd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
683 } |
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 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
688 gchar *text; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
689 GenericDialog *gd; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
690 |
901 | 691 text = g_strdup_printf("%s:\n\n%s", ud->messages.fail, ud->dir_fd->path); |
692 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
|
693 g_free(text); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
694 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
695 if (fail != ud->dir_fd) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
696 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
697 pref_spacer(gd->vbox, PREF_PAD_GROUP); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
698 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
|
699 fail->path); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
700 pref_label_new(gd->vbox, text); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
701 g_free(text); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
702 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
703 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
704 file_data_unref(fail); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
705 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
706 break; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
707 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
708 case UTILITY_TYPE_RENAME_FOLDER: |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
709 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
710 FileData *fail = NULL; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
711 GList *work; |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
712 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
|
713 |
897 | 714 if ((internal && file_data_sc_perform_ci(ud->dir_fd)) || |
715 (!internal && ext_result)) | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
716 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
717 file_data_sc_apply_ci(ud->dir_fd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
718 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
719 else |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
720 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
721 fail = file_data_ref(ud->dir_fd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
722 } |
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 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
725 work = ud->content_list; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
726 while (work) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
727 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
728 FileData *fd; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
729 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
730 fd = work->data; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
731 work = work->next; |
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 if (!fail) |
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 file_data_sc_apply_ci(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 file_data_sc_free_ci(fd); |
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 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
740 if (fail) |
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 gchar *text; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
743 GenericDialog *gd; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
744 |
901 | 745 text = g_strdup_printf("%s:\n\n%s", ud->messages.fail, ud->dir_fd->path); |
746 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
|
747 g_free(text); |
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_unref(fail); |
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 break; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
752 } |
901 | 753 case UTILITY_TYPE_CREATE_FOLDER: |
754 { | |
755 if ((internal && mkdir_utf8(ud->dir_fd->path, 0755)) || | |
756 (!internal && ext_result)) | |
757 { | |
974
c466b8fabcc3
update the FileData structure when a new folder is created
nadvornik
parents:
947
diff
changeset
|
758 file_data_check_changed_files(ud->dir_fd); /* this will update the FileData and send notification */ |
901 | 759 } |
760 else | |
761 { | |
762 gchar *text; | |
763 GenericDialog *gd; | |
764 | |
765 text = g_strdup_printf("%s:\n\n%s", ud->messages.fail, ud->dir_fd->path); | |
766 gd = file_util_warning_dialog(ud->messages.fail, text, GTK_STOCK_DIALOG_ERROR, NULL); | |
767 g_free(text); | |
768 } | |
769 | |
770 break; | |
771 } | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
772 default: |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
773 g_warning("unhandled operation"); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
774 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
775 ud->phase = UTILITY_PHASE_DONE; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
776 file_util_dialog_run(ud); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
777 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
778 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
779 static gint file_util_perform_ci_dir_cb(gpointer resume_data, gint flags, GList *list, gpointer data) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
780 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
781 UtilityData *ud = data; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
782 file_util_perform_ci_dir(ud, FALSE, !((flags & EDITOR_ERROR_MASK) && !(flags & EDITOR_ERROR_SKIPPED))); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
783 return EDITOR_CB_CONTINUE; /* does not matter, there was just single directory */ |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
784 } |
9 | 785 |
753 | 786 void file_util_perform_ci(UtilityData *ud) |
787 { | |
788 switch (ud->type) | |
789 { | |
790 case UTILITY_TYPE_COPY: | |
791 ud->external_command = CMD_COPY; | |
792 break; | |
793 case UTILITY_TYPE_MOVE: | |
794 ud->external_command = CMD_MOVE; | |
795 break; | |
796 case UTILITY_TYPE_RENAME: | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
797 case UTILITY_TYPE_RENAME_FOLDER: |
753 | 798 ud->external_command = CMD_RENAME; |
799 break; | |
800 case UTILITY_TYPE_DELETE: | |
801 case UTILITY_TYPE_DELETE_LINK: | |
802 case UTILITY_TYPE_DELETE_FOLDER: | |
803 ud->external_command = CMD_DELETE; | |
804 break; | |
901 | 805 case UTILITY_TYPE_CREATE_FOLDER: |
806 ud->external_command = CMD_FOLDER; | |
807 break; | |
753 | 808 case UTILITY_TYPE_FILTER: |
809 case UTILITY_TYPE_EDITOR: | |
810 g_assert(ud->external_command != -1); /* it should be already set */ | |
811 break; | |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
812 case UTILITY_TYPE_WRITE_METADATA: |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
813 ud->external_command = -1; |
753 | 814 } |
9 | 815 |
766
7148e125bf23
Check for existing editor command using is_valid_editor_command().
zas_
parents:
761
diff
changeset
|
816 if (is_valid_editor_command(ud->external_command)) |
9 | 817 { |
753 | 818 gint flags; |
757 | 819 |
753 | 820 ud->external = TRUE; |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
821 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
822 if (ud->dir_fd) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
823 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
824 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
|
825 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
826 else |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
827 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
828 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
|
829 } |
757 | 830 |
831 if (flags) | |
9 | 832 { |
753 | 833 gchar *text = g_strdup_printf(_("%s\nUnable to start external command.\n"), editor_get_error_str(flags)); |
834 file_util_warning_dialog(ud->messages.fail, text, GTK_STOCK_DIALOG_ERROR, NULL); | |
835 g_free(text); | |
9 | 836 } |
837 } | |
838 else | |
839 { | |
753 | 840 ud->external = FALSE; |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
841 if (ud->dir_fd) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
842 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
843 file_util_perform_ci_dir(ud, TRUE, FALSE); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
844 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
845 else |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
846 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
847 file_util_perform_ci_internal(ud); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
848 } |
1 | 849 } |
850 } | |
851 | |
924
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
852 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
|
853 { |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
854 static GdkPixbuf *pb_warning; |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
855 static GdkPixbuf *pb_error; |
932 | 856 static GdkPixbuf *pb_apply; |
924
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
857 gint error; |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
858 |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
859 if (!pb_warning) |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
860 { |
995 | 861 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
|
862 } |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
863 |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
864 if (!pb_error) |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
865 { |
995 | 866 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
|
867 } |
932 | 868 |
869 if (!pb_apply) | |
870 { | |
995 | 871 pb_apply = gtk_widget_render_icon(widget, GTK_STOCK_APPLY, GTK_ICON_SIZE_MENU, NULL); |
932 | 872 } |
924
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
873 |
928 | 874 error = file_data_sc_verify_ci(fd); |
924
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
875 |
932 | 876 if (!error) return pb_apply; |
924
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
877 |
995 | 878 if (error & CHANGE_ERROR_MASK) |
924
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
879 { |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
880 return pb_error; |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
881 } |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
882 else |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
883 { |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
884 return pb_warning; |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
885 } |
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
886 } |
914
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
887 |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
888 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
|
889 { |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
890 UtilityData *ud = data; |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
891 ud->phase = UTILITY_PHASE_CHECKED; |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
892 file_util_dialog_run(ud); |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
893 } |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
894 |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
895 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
|
896 { |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
897 UtilityData *ud = data; |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
898 ud->phase = UTILITY_PHASE_START; |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
899 file_util_dialog_run(ud); |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
900 } |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
901 |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
902 void file_util_check_ci(UtilityData *ud) |
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 gint error = CHANGE_OK; |
928 | 905 gchar *desc = NULL; |
914
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
906 |
935 | 907 if (ud->type != UTILITY_TYPE_CREATE_FOLDER) |
914
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
908 { |
935 | 909 if (ud->dest_path && !isdir(ud->dest_path)) |
910 { | |
911 error = CHANGE_GENERIC_ERROR; | |
912 desc = g_strdup_printf(_("%s is not a directory"), ud->dest_path); | |
913 } | |
914 else if (ud->dir_fd) | |
915 { | |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
916 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
|
917 error = file_data_verify_ci(ud->dir_fd); |
935 | 918 if (error) desc = file_data_get_error_string(error); |
919 } | |
920 else | |
921 { | |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
922 error = file_data_verify_ci_list(ud->flist, &desc, ud->with_sidecars); |
935 | 923 } |
914
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
924 } |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
925 |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
926 if (!error) |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
927 { |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
928 ud->phase = UTILITY_PHASE_CHECKED; |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
929 file_util_dialog_run(ud); |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
930 return; |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
931 } |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
932 |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
933 if (!(error & CHANGE_ERROR_MASK)) |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
934 { |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
935 /* just a warning */ |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
936 GenericDialog *d; |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
937 |
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
|
938 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
|
939 ud->parent, TRUE, |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
940 file_util_check_abort_cb, ud); |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
941 |
928 | 942 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
|
943 |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
944 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
|
945 file_util_check_resume_cb, TRUE); |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
946 gtk_widget_show(d->dialog); |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
947 } |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
948 else |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
949 { |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
950 /* fatal error */ |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
951 GenericDialog *d; |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
952 |
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
|
953 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
|
954 ud->parent, TRUE, |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
955 file_util_check_abort_cb, ud); |
937 | 956 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
|
957 |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
958 gtk_widget_show(d->dialog); |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
959 } |
928 | 960 g_free(desc); |
914
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 |
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 |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
965 |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
966 |
757 | 967 static void file_util_cancel_cb(GenericDialog *gd, gpointer data) |
753 | 968 { |
969 UtilityData *ud = data; | |
970 | |
971 generic_dialog_close(gd); | |
1 | 972 |
753 | 973 ud->gd = NULL; |
974 | |
975 ud->phase = UTILITY_PHASE_CANCEL; | |
976 file_util_dialog_run(ud); | |
1 | 977 } |
978 | |
757 | 979 static void file_util_ok_cb(GenericDialog *gd, gpointer data) |
1 | 980 { |
753 | 981 UtilityData *ud = data; |
982 | |
983 generic_dialog_close(gd); | |
984 | |
985 ud->gd = NULL; | |
138 | 986 |
753 | 987 file_util_dialog_run(ud); |
1 | 988 } |
989 | |
757 | 990 static void file_util_fdlg_cancel_cb(FileDialog *fdlg, gpointer data) |
1 | 991 { |
753 | 992 UtilityData *ud = data; |
675 | 993 |
753 | 994 file_dialog_close(fdlg); |
9 | 995 |
753 | 996 ud->fdlg = NULL; |
997 | |
998 ud->phase = UTILITY_PHASE_CANCEL; | |
999 file_util_dialog_run(ud); | |
1000 } | |
9 | 1001 |
900 | 1002 static void file_util_dest_folder_update_path(UtilityData *ud) |
753 | 1003 { |
1004 g_free(ud->dest_path); | |
900 | 1005 ud->dest_path = g_strdup(gtk_entry_get_text(GTK_ENTRY(ud->fdlg->entry))); |
753 | 1006 |
1007 switch (ud->type) | |
1 | 1008 { |
753 | 1009 case UTILITY_TYPE_COPY: |
1010 file_data_sc_update_ci_copy_list(ud->flist, ud->dest_path); | |
1011 case UTILITY_TYPE_MOVE: | |
1012 file_data_sc_update_ci_move_list(ud->flist, ud->dest_path); | |
1013 break; | |
1014 case UTILITY_TYPE_FILTER: | |
1015 case UTILITY_TYPE_EDITOR: | |
1016 file_data_sc_update_ci_unspecified_list(ud->flist, ud->dest_path); | |
1017 break; | |
901 | 1018 case UTILITY_TYPE_CREATE_FOLDER: |
1019 file_data_unref(ud->dir_fd); | |
1020 ud->dir_fd = file_data_new_simple(ud->dest_path); | |
1021 break; | |
753 | 1022 case UTILITY_TYPE_DELETE: |
1023 case UTILITY_TYPE_DELETE_LINK: | |
1024 case UTILITY_TYPE_DELETE_FOLDER: | |
1025 case UTILITY_TYPE_RENAME: | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1026 case UTILITY_TYPE_RENAME_FOLDER: |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1027 case UTILITY_TYPE_WRITE_METADATA: |
753 | 1028 g_warning("unhandled operation"); |
1 | 1029 } |
1030 } | |
1031 | |
900 | 1032 static void file_util_fdlg_ok_cb(FileDialog *fdlg, gpointer data) |
1033 { | |
1034 UtilityData *ud = data; | |
1035 | |
1036 file_util_dest_folder_update_path(ud); | |
946 | 1037 if (isdir(ud->dest_path)) file_dialog_sync_history(fdlg, TRUE); |
900 | 1038 file_dialog_close(fdlg); |
1039 | |
1040 ud->fdlg = NULL; | |
1041 | |
1042 file_util_dialog_run(ud); | |
1043 } | |
1044 | |
1045 | |
1046 static void file_util_dest_folder_entry_cb(GtkWidget *entry, gpointer data) | |
1047 { | |
1048 UtilityData *ud = data; | |
1049 file_util_dest_folder_update_path(ud); | |
1050 } | |
1 | 1051 |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1052 /* 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
|
1053 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
|
1054 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1055 gchar *new_name; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1056 gchar *parsed; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1057 const gchar *ext; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1058 gchar *middle; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1059 gchar *tmp; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1060 gchar *pad_start; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1061 gchar *pad_end; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1062 gint padding; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1063 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1064 if (!format || !name) return NULL; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1065 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1066 tmp = g_strdup(format); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1067 pad_start = strchr(tmp, '#'); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1068 if (pad_start) |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1069 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1070 pad_end = pad_start; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1071 padding = 0; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1072 while (*pad_end == '#') |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1073 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1074 pad_end++; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1075 padding++; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1076 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1077 *pad_start = '\0'; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1078 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1079 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
|
1080 g_free(tmp); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1081 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1082 else |
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 parsed = tmp; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1085 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1086 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1087 ext = extension_from_path(name); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1088 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1089 middle = strchr(parsed, '*'); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1090 if (middle) |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1091 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1092 gchar *base; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1093 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1094 *middle = '\0'; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1095 middle++; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1096 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1097 base = remove_extension_from_path(name); |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1098 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
|
1099 g_free(base); |
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 else |
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 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
|
1104 } |
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 g_free(parsed); |
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 return new_name; |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1109 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1110 |
9 | 1111 |
753 | 1112 static void file_util_rename_preview_update(UtilityData *ud) |
1 | 1113 { |
9 | 1114 GtkTreeModel *store; |
753 | 1115 GtkTreeSelection *selection; |
9 | 1116 GtkTreeIter iter; |
1117 const gchar *front; | |
1118 const gchar *end; | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1119 const gchar *format; |
9 | 1120 gint valid; |
1121 gint start_n; | |
1122 gint padding; | |
1123 gint n; | |
753 | 1124 gint mode; |
9 | 1125 |
753 | 1126 mode = gtk_notebook_get_current_page(GTK_NOTEBOOK(ud->notebook)); |
9 | 1127 |
753 | 1128 if (mode == UTILITY_RENAME) |
1129 { | |
1130 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(ud->listview)); | |
1131 if (gtk_tree_selection_get_selected(selection, &store, &iter)) | |
1132 { | |
1133 FileData *fd; | |
1134 const gchar *dest = gtk_entry_get_text(GTK_ENTRY(ud->rename_entry)); | |
1135 | |
1136 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
|
1137 g_assert(ud->with_sidecars); /* sidecars must be renamed too, it would break the pairing otherwise */ |
753 | 1138 file_data_sc_update_ci_rename(fd, dest); |
995 | 1139 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
|
1140 UTILITY_COLUMN_PIXBUF, file_util_get_error_icon(fd, ud->listview), |
995 | 1141 UTILITY_COLUMN_DEST_PATH, fd->change->dest, |
1142 UTILITY_COLUMN_DEST_NAME, filename_from_path(fd->change->dest), | |
753 | 1143 -1); |
1144 } | |
1145 return; | |
1146 } | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1147 |
753 | 1148 |
1149 front = gtk_entry_get_text(GTK_ENTRY(ud->auto_entry_front)); | |
1150 end = gtk_entry_get_text(GTK_ENTRY(ud->auto_entry_end)); | |
1151 padding = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ud->auto_spin_pad)); | |
1152 | |
1153 format = gtk_entry_get_text(GTK_ENTRY(ud->format_entry)); | |
1154 | |
1155 if (mode == UTILITY_RENAME_FORMATTED) | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1156 { |
753 | 1157 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
|
1158 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1159 else |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1160 { |
753 | 1161 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
|
1162 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1163 |
753 | 1164 store = gtk_tree_view_get_model(GTK_TREE_VIEW(ud->listview)); |
9 | 1165 n = start_n; |
1166 valid = gtk_tree_model_get_iter_first(store, &iter); | |
1167 while (valid) | |
1168 { | |
1169 gchar *dest; | |
753 | 1170 FileData *fd; |
1171 gtk_tree_model_get(store, &iter, UTILITY_COLUMN_FD, &fd, -1); | |
9 | 1172 |
753 | 1173 if (mode == UTILITY_RENAME_FORMATTED) |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1174 { |
138 | 1175 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
|
1176 } |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1177 else |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1178 { |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1179 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
|
1180 } |
753 | 1181 |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1182 g_assert(ud->with_sidecars); /* sidecars must be renamed too, it would break the pairing otherwise */ |
753 | 1183 file_data_sc_update_ci_rename(fd, dest); |
995 | 1184 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
|
1185 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
|
1186 UTILITY_COLUMN_DEST_PATH, fd->change->dest, |
753 | 1187 UTILITY_COLUMN_DEST_NAME, filename_from_path(fd->change->dest), |
1188 -1); | |
9 | 1189 g_free(dest); |
1190 | |
1191 n++; | |
1192 valid = gtk_tree_model_iter_next(store, &iter); | |
1193 } | |
1194 | |
1 | 1195 } |
1196 | |
753 | 1197 static void file_util_rename_preview_entry_cb(GtkWidget *entry, gpointer data) |
9 | 1198 { |
753 | 1199 UtilityData *ud = data; |
1200 file_util_rename_preview_update(ud); | |
1201 } | |
9 | 1202 |
753 | 1203 static void file_util_rename_preview_adj_cb(GtkWidget *spin, gpointer data) |
1204 { | |
1205 UtilityData *ud = data; | |
1206 file_util_rename_preview_update(ud); | |
1207 } | |
9 | 1208 |
753 | 1209 static gboolean file_util_rename_idle_cb(gpointer data) |
1210 { | |
1211 UtilityData *ud = data; | |
1212 | |
1213 file_util_rename_preview_update(ud); | |
1214 | |
1215 ud->update_idle_id = -1; | |
9 | 1216 return FALSE; |
1217 } | |
1218 | |
753 | 1219 static void file_util_rename_preview_order_cb(GtkTreeModel *treemodel, GtkTreePath *tpath, |
9 | 1220 GtkTreeIter *iter, gpointer data) |
1221 { | |
753 | 1222 UtilityData *ud = data; |
9 | 1223 |
757 | 1224 if (ud->update_idle_id != -1) return; |
1225 | |
1226 ud->update_idle_id = g_idle_add(file_util_rename_idle_cb, ud); | |
9 | 1227 } |
1228 | |
753 | 1229 |
1230 static gboolean file_util_preview_cb(GtkTreeSelection *selection, GtkTreeModel *store, | |
1231 GtkTreePath *tpath, gboolean path_currently_selected, | |
1232 gpointer data) | |
9 | 1233 { |
753 | 1234 UtilityData *ud = data; |
1235 GtkTreeIter iter; | |
1236 FileData *fd = NULL; | |
1237 | |
1238 if (path_currently_selected || | |
1239 !gtk_tree_model_get_iter(store, &iter, tpath)) return TRUE; | |
1240 | |
1241 gtk_tree_model_get(store, &iter, UTILITY_COLUMN_FD, &fd, -1); | |
1242 generic_dialog_image_set(ud->gd, fd); | |
1243 | |
1244 if (ud->type == UTILITY_TYPE_RENAME) | |
1245 { | |
1246 const gchar *name = filename_from_path(fd->change->dest); | |
757 | 1247 |
753 | 1248 gtk_widget_grab_focus(ud->rename_entry); |
1249 gtk_label_set_text(GTK_LABEL(ud->rename_label), fd->name); | |
1250 g_signal_handlers_block_by_func(ud->rename_entry, G_CALLBACK(file_util_rename_preview_entry_cb), ud); | |
1251 gtk_entry_set_text(GTK_ENTRY(ud->rename_entry), name); | |
1252 gtk_editable_select_region(GTK_EDITABLE(ud->rename_entry), 0, filename_base_length(name)); | |
1253 g_signal_handlers_unblock_by_func(ud->rename_entry, G_CALLBACK(file_util_rename_preview_entry_cb), ud); | |
1254 } | |
1255 | |
1256 return TRUE; | |
9 | 1257 } |
1258 | |
753 | 1259 |
1260 | |
1261 static void box_append_safe_delete_status(GenericDialog *gd) | |
9 | 1262 { |
753 | 1263 GtkWidget *label; |
1264 gchar *buf; | |
1265 | |
1266 buf = file_util_safe_delete_status(); | |
1267 label = pref_label_new(gd->vbox, buf); | |
1268 g_free(buf); | |
1269 | |
1270 gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5); | |
1271 gtk_widget_set_sensitive(label, FALSE); | |
9 | 1272 } |
1273 | |
753 | 1274 |
1275 static void file_util_dialog_init_simple_list(UtilityData *ud) | |
1 | 1276 { |
753 | 1277 GtkWidget *box; |
1278 GtkTreeSelection *selection; | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1279 gchar *dir_msg; |
757 | 1280 |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1281 const gchar *stock_id; |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1282 |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1283 if (ud->type == UTILITY_TYPE_DELETE || |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1284 ud->type == UTILITY_TYPE_DELETE_LINK || |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1285 ud->type == UTILITY_TYPE_DELETE_FOLDER) |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1286 { |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1287 stock_id = GTK_STOCK_DELETE; |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1288 } |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1289 else |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1290 { |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1291 stock_id = GTK_STOCK_OK; |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1292 } |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1293 |
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
|
1294 ud->gd = file_util_gen_dlg(ud->messages.title, "dlg_confirm", |
757 | 1295 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
|
1296 generic_dialog_add_button(ud->gd, stock_id, NULL, file_util_ok_cb, TRUE); |
753 | 1297 |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1298 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1299 if (ud->dir_fd) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1300 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1301 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
|
1302 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1303 else |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1304 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1305 dir_msg = g_strdup(""); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1306 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1307 |
753 | 1308 box = generic_dialog_add_message(ud->gd, GTK_STOCK_DIALOG_QUESTION, |
757 | 1309 ud->messages.question, |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1310 dir_msg); |
753 | 1311 |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1312 g_free(dir_msg); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1313 |
753 | 1314 box = pref_group_new(box, TRUE, ud->messages.desc_flist, GTK_ORIENTATION_HORIZONTAL); |
1315 | |
1211 | 1316 ud->listview = file_util_dialog_add_list(box, ud->flist, FALSE, ud->with_sidecars); |
1317 if (ud->with_sidecars) file_util_dialog_add_list_column(ud->listview, _("Sidecars"), FALSE, UTILITY_COLUMN_SIDECARS); | |
9 | 1318 |
1224 | 1319 if (ud->type == UTILITY_TYPE_WRITE_METADATA) file_util_dialog_add_list_column(ud->listview, _("Write to file"), FALSE, UTILITY_COLUMN_DEST_NAME); |
1320 | |
753 | 1321 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(ud->listview)); |
1322 gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE); | |
1323 gtk_tree_selection_set_select_function(selection, file_util_preview_cb, ud, NULL); | |
1324 | |
1325 generic_dialog_add_image(ud->gd, box, NULL, NULL, NULL, NULL, FALSE); | |
1326 | |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1327 if (ud->type == UTILITY_TYPE_DELETE || |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1328 ud->type == UTILITY_TYPE_DELETE_LINK || |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1329 ud->type == UTILITY_TYPE_DELETE_FOLDER) |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1330 box_append_safe_delete_status(ud->gd); |
753 | 1331 |
1332 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
|
1333 |
753 | 1334 file_util_dialog_list_select(ud->listview, 0); |
1335 } | |
1336 | |
1337 static void file_util_dialog_init_dest_folder(UtilityData *ud) | |
1338 { | |
1339 FileDialog *fdlg; | |
1340 GtkWidget *label; | |
1341 const gchar *stock_id; | |
1342 | |
995 | 1343 if (ud->type == UTILITY_TYPE_COPY) |
9 | 1344 { |
753 | 1345 stock_id = GTK_STOCK_COPY; |
1346 } | |
1347 else | |
1348 { | |
1349 stock_id = GTK_STOCK_OK; | |
9 | 1350 } |
1351 | |
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
|
1352 fdlg = file_util_file_dlg(ud->messages.title, "dlg_dest_folder", ud->parent, |
757 | 1353 file_util_fdlg_cancel_cb, ud); |
753 | 1354 |
1355 ud->fdlg = fdlg; | |
1356 | |
1357 generic_dialog_add_message(GENERIC_DIALOG(fdlg), NULL, ud->messages.question, NULL); | |
1358 | |
1359 label = pref_label_new(GENERIC_DIALOG(fdlg)->vbox, _("Choose the destination folder.")); | |
1360 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); | |
1361 pref_spacer(GENERIC_DIALOG(fdlg)->vbox, 0); | |
1362 | |
1363 file_dialog_add_button(fdlg, stock_id, ud->messages.title, file_util_fdlg_ok_cb, TRUE); | |
1364 | |
1365 file_dialog_add_path_widgets(fdlg, NULL, ud->dest_path, "move_copy", NULL, NULL); | |
1366 | |
1367 g_signal_connect(G_OBJECT(fdlg->entry), "changed", | |
1368 G_CALLBACK(file_util_dest_folder_entry_cb), ud); | |
1369 | |
1370 gtk_widget_show(GENERIC_DIALOG(fdlg)->dialog); | |
9 | 1371 } |
1372 | |
753 | 1373 |
9 | 1374 static GtkWidget *furm_simple_vlabel(GtkWidget *box, const gchar *text, gint expand) |
1375 { | |
1376 GtkWidget *vbox; | |
1377 GtkWidget *label; | |
1378 | |
1379 vbox = gtk_vbox_new(FALSE, 0); | |
1380 gtk_box_pack_start(GTK_BOX(box), vbox, expand, expand, 0); | |
1381 gtk_widget_show(vbox); | |
1382 | |
1383 label = gtk_label_new(text); | |
1384 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
1385 gtk_widget_show(label); | |
1386 | |
1387 return vbox; | |
1388 } | |
1389 | |
753 | 1390 |
1391 static void file_util_dialog_init_source_dest(UtilityData *ud) | |
9 | 1392 { |
753 | 1393 GtkTreeModel *store; |
9 | 1394 GtkTreeSelection *selection; |
753 | 1395 GtkWidget *box; |
9 | 1396 GtkWidget *hbox; |
1397 GtkWidget *box2; | |
1398 GtkWidget *table; | |
1399 GtkWidget *combo; | |
753 | 1400 GtkWidget *page; |
1 | 1401 |
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
|
1402 ud->gd = file_util_gen_dlg(ud->messages.title, "dlg_confirm", |
757 | 1403 ud->parent, FALSE, file_util_cancel_cb, ud); |
138 | 1404 |
753 | 1405 box = generic_dialog_add_message(ud->gd, NULL, ud->messages.question, NULL); |
1406 generic_dialog_add_button(ud->gd, GTK_STOCK_OK, ud->messages.title, file_util_ok_cb, TRUE); | |
9 | 1407 |
753 | 1408 box = pref_group_new(box, TRUE, ud->messages.desc_flist, GTK_ORIENTATION_HORIZONTAL); |
9 | 1409 |
1211 | 1410 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
|
1411 file_util_dialog_add_list_column(ud->listview, _("Sidecars"), FALSE, UTILITY_COLUMN_SIDECARS); |
442 | 1412 |
924
96a1f535ce89
indicate check warnings and errors in delete and rename dialogs
nadvornik
parents:
921
diff
changeset
|
1413 file_util_dialog_add_list_column(ud->listview, _("New name"), FALSE, UTILITY_COLUMN_DEST_NAME); |
1 | 1414 |
753 | 1415 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(ud->listview)); |
1416 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_SINGLE); | |
1417 gtk_tree_selection_set_select_function(selection, file_util_preview_cb, ud, NULL); | |
9 | 1418 |
1419 | |
753 | 1420 // column = file_util_rename_multiple_add_column(rd, _("Preview"), RENAME_COLUMN_PREVIEW); |
1421 // gtk_tree_view_column_set_visible(column, FALSE); | |
442 | 1422 |
753 | 1423 gtk_tree_view_set_reorderable(GTK_TREE_VIEW(ud->listview), TRUE); |
1424 | |
1425 store = gtk_tree_view_get_model(GTK_TREE_VIEW(ud->listview)); | |
9 | 1426 g_signal_connect(G_OBJECT(store), "row_changed", |
753 | 1427 G_CALLBACK(file_util_rename_preview_order_cb), ud); |
1428 gtk_widget_set_size_request(ud->listview, 300, 150); | |
1 | 1429 |
753 | 1430 generic_dialog_add_image(ud->gd, box, NULL, NULL, NULL, NULL, FALSE); |
9 | 1431 |
753 | 1432 // gtk_container_add(GTK_CONTAINER(scrolled), view); |
1433 gtk_widget_show(ud->gd->dialog); | |
9 | 1434 |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1435 |
753 | 1436 ud->notebook = gtk_notebook_new(); |
1437 | |
1438 gtk_box_pack_start(GTK_BOX(ud->gd->vbox), ud->notebook, FALSE, FALSE, 0); | |
1439 gtk_widget_show(ud->notebook); | |
1440 | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1441 |
753 | 1442 page = gtk_vbox_new(FALSE, PREF_PAD_GAP); |
1443 gtk_notebook_append_page(GTK_NOTEBOOK(ud->notebook), page, gtk_label_new(_("Manual rename"))); | |
1444 gtk_widget_show(page); | |
1445 | |
1446 table = pref_table_new(page, 2, 2, FALSE, FALSE); | |
9 | 1447 |
1448 pref_table_label(table, 0, 0, _("Original name:"), 1.0); | |
753 | 1449 ud->rename_label = pref_table_label(table, 1, 0, "", 0.0); |
9 | 1450 |
1451 pref_table_label(table, 0, 1, _("New name:"), 1.0); | |
1452 | |
753 | 1453 ud->rename_entry = gtk_entry_new(); |
1454 gtk_table_attach(GTK_TABLE(table), ud->rename_entry, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0); | |
1455 generic_dialog_attach_default(GENERIC_DIALOG(ud->gd), ud->rename_entry); | |
1456 gtk_widget_grab_focus(ud->rename_entry); | |
1457 | |
1458 g_signal_connect(G_OBJECT(ud->rename_entry), "changed", | |
1459 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
|
1460 |
753 | 1461 gtk_widget_show(ud->rename_entry); |
9 | 1462 |
753 | 1463 page = gtk_vbox_new(FALSE, PREF_PAD_GAP); |
1464 gtk_notebook_append_page(GTK_NOTEBOOK(ud->notebook), page, gtk_label_new(_("Auto rename"))); | |
1465 gtk_widget_show(page); | |
9 | 1466 |
753 | 1467 |
1468 hbox = pref_box_new(page, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_GAP); | |
9 | 1469 |
1470 box2 = furm_simple_vlabel(hbox, _("Begin text"), TRUE); | |
1471 | |
753 | 1472 combo = history_combo_new(&ud->auto_entry_front, "", "numerical_rename_prefix", -1); |
1473 g_signal_connect(G_OBJECT(ud->auto_entry_front), "changed", | |
1474 G_CALLBACK(file_util_rename_preview_entry_cb), ud); | |
9 | 1475 gtk_box_pack_start(GTK_BOX(box2), combo, TRUE, TRUE, 0); |
1476 gtk_widget_show(combo); | |
442 | 1477 |
9 | 1478 box2 = furm_simple_vlabel(hbox, _("Start #"), FALSE); |
1479 | |
753 | 1480 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
|
1481 0.0, 1000000.0, 1.0, 0, 1.0, |
753 | 1482 G_CALLBACK(file_util_rename_preview_adj_cb), ud); |
9 | 1483 |
1484 box2 = furm_simple_vlabel(hbox, _("End text"), TRUE); | |
1485 | |
753 | 1486 combo = history_combo_new(&ud->auto_entry_end, "", "numerical_rename_suffix", -1); |
1487 g_signal_connect(G_OBJECT(ud->auto_entry_end), "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); | |
1491 | |
753 | 1492 ud->auto_spin_pad = pref_spin_new(page, _("Padding:"), NULL, |
9 | 1493 1.0, 8.0, 1.0, 0, 1.0, |
753 | 1494 G_CALLBACK(file_util_rename_preview_adj_cb), ud); |
9 | 1495 |
753 | 1496 page = gtk_vbox_new(FALSE, PREF_PAD_GAP); |
1497 gtk_notebook_append_page(GTK_NOTEBOOK(ud->notebook), page, gtk_label_new(_("Formatted rename"))); | |
1498 gtk_widget_show(page); | |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1499 |
753 | 1500 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
|
1501 |
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1502 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
|
1503 |
753 | 1504 combo = history_combo_new(&ud->format_entry, "", "auto_rename_format", -1); |
1505 g_signal_connect(G_OBJECT(ud->format_entry), "changed", | |
1506 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
|
1507 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
|
1508 gtk_widget_show(combo); |
442 | 1509 |
66
ebbff299ad0d
Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents:
44
diff
changeset
|
1510 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
|
1511 |
753 | 1512 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
|
1513 0.0, 1000000.0, 1.0, 0, 1.0, |
753 | 1514 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
|
1515 |
753 | 1516 // gtk_combo_box_set_active(GTK_COMBO_BOX(ud->combo_type), 0); /* callback will take care of the rest */ |
138 | 1517 |
753 | 1518 file_util_dialog_list_select(ud->listview, 0); |
1 | 1519 } |
1520 | |
9 | 1521 |
753 | 1522 void file_util_dialog_run(UtilityData *ud) |
1 | 1523 { |
753 | 1524 switch (ud->phase) |
1525 { | |
1526 case UTILITY_PHASE_START: | |
1527 /* create the dialogs */ | |
1528 switch (ud->type) | |
1529 { | |
1530 case UTILITY_TYPE_DELETE: | |
1531 case UTILITY_TYPE_DELETE_LINK: | |
1532 case UTILITY_TYPE_DELETE_FOLDER: | |
1533 case UTILITY_TYPE_EDITOR: | |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1534 case UTILITY_TYPE_WRITE_METADATA: |
753 | 1535 file_util_dialog_init_simple_list(ud); |
1536 break; | |
1537 case UTILITY_TYPE_RENAME: | |
1538 file_util_dialog_init_source_dest(ud); | |
1539 break; | |
1540 case UTILITY_TYPE_COPY: | |
1541 case UTILITY_TYPE_MOVE: | |
1542 case UTILITY_TYPE_FILTER: | |
901 | 1543 case UTILITY_TYPE_CREATE_FOLDER: |
753 | 1544 file_util_dialog_init_dest_folder(ud); |
1545 break; | |
934 | 1546 case UTILITY_TYPE_RENAME_FOLDER: |
1547 ud->phase = UTILITY_PHASE_CANCEL; /* FIXME - not handled for now */ | |
1548 file_util_dialog_run(ud); | |
1549 return; | |
753 | 1550 } |
1551 ud->phase = UTILITY_PHASE_ENTERING; | |
1552 break; | |
1553 case UTILITY_PHASE_ENTERING: | |
914
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
1554 file_util_check_ci(ud); |
9427c91951e8
basic infrastructure for early error and dangerous operations checking
nadvornik
parents:
908
diff
changeset
|
1555 break; |
753 | 1556 |
1557 ud->phase = UTILITY_PHASE_CHECKED; | |
1558 case UTILITY_PHASE_CHECKED: | |
1559 file_util_perform_ci(ud); | |
1560 break; | |
1561 case UTILITY_PHASE_CANCEL: | |
1562 case UTILITY_PHASE_DONE: | |
1211 | 1563 |
1564 /* FIXME: put it here for now */ | |
1565 if (ud->type == UTILITY_TYPE_WRITE_METADATA) | |
1566 { | |
1567 metadata_write_queue_remove_list(ud->flist); | |
1568 } | |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1569 if (ud->with_sidecars) |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1570 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
|
1571 else |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1572 file_data_free_ci_list(ud->flist); |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1573 |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1574 /* directory content is always handled including sidecars */ |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1575 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
|
1576 |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1577 if (ud->dir_fd) file_data_free_ci(ud->dir_fd); |
753 | 1578 file_util_data_free(ud); |
1579 break; | |
1580 } | |
1 | 1581 } |
1582 | |
753 | 1583 |
1584 | |
1585 | |
757 | 1586 static void file_util_warn_op_in_progress(const gchar *title) |
1587 { | |
1588 file_util_warning_dialog(title, _("Another operation in progress.\n"), GTK_STOCK_DIALOG_ERROR, NULL); | |
1589 } | |
9 | 1590 |
849
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1591 static void file_util_disable_grouping_sc_list(GList *list) |
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1592 { |
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1593 GList *work = list; |
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1594 |
855 | 1595 while (work) |
849
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1596 { |
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1597 FileData *fd = work->data; |
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1598 work = work->next; |
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1599 |
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1600 if (fd->parent) file_data_disable_grouping(fd, TRUE); |
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1601 } |
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1602 |
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1603 } |
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1604 |
753 | 1605 static void file_util_delete_full(FileData *source_fd, GList *source_list, GtkWidget *parent, UtilityPhase phase) |
1606 { | |
1607 UtilityData *ud; | |
1608 GList *flist = filelist_copy(source_list); | |
1609 | |
1610 if (source_fd) | |
1611 flist = g_list_append(flist, file_data_ref(source_fd)); | |
9 | 1612 |
947
368643594bc8
abort file operations when the file list is empty
nadvornik
parents:
946
diff
changeset
|
1613 if (!flist) return; |
368643594bc8
abort file operations when the file list is empty
nadvornik
parents:
946
diff
changeset
|
1614 |
849
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1615 file_util_disable_grouping_sc_list(flist); |
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1616 |
753 | 1617 if (!file_data_sc_add_ci_delete_list(flist)) |
1618 { | |
757 | 1619 file_util_warn_op_in_progress(_("File deletion failed")); |
753 | 1620 filelist_free(flist); |
1 | 1621 return; |
1622 } | |
753 | 1623 |
1624 ud = file_util_data_new(UTILITY_TYPE_DELETE); | |
1625 | |
1626 ud->phase = phase; | |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1627 |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1628 ud->with_sidecars = TRUE; |
138 | 1629 |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1630 ud->dir_fd = NULL; |
753 | 1631 ud->flist = flist; |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1632 ud->content_list = NULL; |
753 | 1633 ud->parent = parent; |
1634 | |
1635 ud->messages.title = _("Delete"); | |
1636 ud->messages.question = _("Delete files?"); | |
1637 ud->messages.desc_flist = _("This will delete the following files"); | |
1638 ud->messages.desc_source_fd = ""; | |
1639 ud->messages.fail = _("File deletion failed"); | |
1640 | |
1641 file_util_dialog_run(ud); | |
1 | 1642 } |
1643 | |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1644 static void file_util_write_metadata_full(FileData *source_fd, GList *source_list, GtkWidget *parent, UtilityPhase phase) |
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 UtilityData *ud; |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1647 GList *flist = filelist_copy(source_list); |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1648 |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1649 if (source_fd) |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1650 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
|
1651 |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1652 if (!flist) return; |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1653 |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1654 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
|
1655 { |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1656 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
|
1657 filelist_free(flist); |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1658 return; |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1659 } |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1660 |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1661 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
|
1662 |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1663 ud->phase = phase; |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1664 |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1665 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
|
1666 |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1667 ud->dir_fd = NULL; |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1668 ud->flist = flist; |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1669 ud->content_list = NULL; |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1670 ud->parent = parent; |
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 ud->messages.title = _("Write metadata"); |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1673 ud->messages.question = _("Write metadata?"); |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1674 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
|
1675 ud->messages.desc_source_fd = ""; |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1676 ud->messages.fail = _("Metadata writting failed"); |
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 file_util_dialog_run(ud); |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1679 } |
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 |
753 | 1682 static void file_util_move_full(FileData *source_fd, GList *source_list, const gchar *dest_path, GtkWidget *parent, UtilityPhase phase) |
1 | 1683 { |
753 | 1684 UtilityData *ud; |
1685 GList *flist = filelist_copy(source_list); | |
1686 | |
1687 if (source_fd) | |
1688 flist = g_list_append(flist, file_data_ref(source_fd)); | |
1689 | |
947
368643594bc8
abort file operations when the file list is empty
nadvornik
parents:
946
diff
changeset
|
1690 if (!flist) return; |
368643594bc8
abort file operations when the file list is empty
nadvornik
parents:
946
diff
changeset
|
1691 |
849
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1692 file_util_disable_grouping_sc_list(flist); |
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1693 |
753 | 1694 if (!file_data_sc_add_ci_move_list(flist, dest_path)) |
1695 { | |
757 | 1696 file_util_warn_op_in_progress(_("Move failed")); |
753 | 1697 filelist_free(flist); |
1698 return; | |
1699 } | |
1700 | |
1701 ud = file_util_data_new(UTILITY_TYPE_MOVE); | |
1702 | |
1703 ud->phase = phase; | |
1704 | |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1705 ud->with_sidecars = TRUE; |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1706 |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1707 ud->dir_fd = NULL; |
753 | 1708 ud->flist = flist; |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1709 ud->content_list = NULL; |
753 | 1710 ud->parent = parent; |
9 | 1711 |
900 | 1712 if (dest_path) ud->dest_path = g_strdup(dest_path); |
753 | 1713 |
1714 ud->messages.title = _("Move"); | |
1715 ud->messages.question = _("Move files?"); | |
1716 ud->messages.desc_flist = _("This will move the following files"); | |
1717 ud->messages.desc_source_fd = ""; | |
1718 ud->messages.fail = _("Move failed"); | |
138 | 1719 |
753 | 1720 file_util_dialog_run(ud); |
1721 } | |
1722 static void file_util_copy_full(FileData *source_fd, GList *source_list, const gchar *dest_path, GtkWidget *parent, UtilityPhase phase) | |
1723 { | |
1724 UtilityData *ud; | |
1725 GList *flist = filelist_copy(source_list); | |
1726 | |
1727 if (source_fd) | |
1728 flist = g_list_append(flist, file_data_ref(source_fd)); | |
1729 | |
947
368643594bc8
abort file operations when the file list is empty
nadvornik
parents:
946
diff
changeset
|
1730 if (!flist) return; |
368643594bc8
abort file operations when the file list is empty
nadvornik
parents:
946
diff
changeset
|
1731 |
849
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1732 file_util_disable_grouping_sc_list(flist); |
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1733 |
753 | 1734 if (!file_data_sc_add_ci_copy_list(flist, dest_path)) |
1 | 1735 { |
757 | 1736 file_util_warn_op_in_progress(_("Copy failed")); |
753 | 1737 filelist_free(flist); |
1 | 1738 return; |
1739 } | |
1740 | |
753 | 1741 ud = file_util_data_new(UTILITY_TYPE_COPY); |
1742 | |
1743 ud->phase = phase; | |
1744 | |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1745 ud->with_sidecars = TRUE; |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1746 |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1747 ud->dir_fd = NULL; |
753 | 1748 ud->flist = flist; |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1749 ud->content_list = NULL; |
753 | 1750 ud->parent = parent; |
9 | 1751 |
900 | 1752 if (dest_path) ud->dest_path = g_strdup(dest_path); |
753 | 1753 |
1754 ud->messages.title = _("Copy"); | |
1755 ud->messages.question = _("Copy files?"); | |
1756 ud->messages.desc_flist = _("This will copy the following files"); | |
1757 ud->messages.desc_source_fd = ""; | |
1758 ud->messages.fail = _("Copy failed"); | |
1 | 1759 |
753 | 1760 file_util_dialog_run(ud); |
9 | 1761 } |
1762 | |
753 | 1763 static void file_util_rename_full(FileData *source_fd, GList *source_list, const gchar *dest_path, GtkWidget *parent, UtilityPhase phase) |
1 | 1764 { |
753 | 1765 UtilityData *ud; |
1766 GList *flist = filelist_copy(source_list); | |
1767 | |
1768 if (source_fd) | |
1769 flist = g_list_append(flist, file_data_ref(source_fd)); | |
138 | 1770 |
947
368643594bc8
abort file operations when the file list is empty
nadvornik
parents:
946
diff
changeset
|
1771 if (!flist) return; |
368643594bc8
abort file operations when the file list is empty
nadvornik
parents:
946
diff
changeset
|
1772 |
849
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1773 file_util_disable_grouping_sc_list(flist); |
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1774 |
753 | 1775 if (!file_data_sc_add_ci_rename_list(flist, dest_path)) |
1776 { | |
757 | 1777 file_util_warn_op_in_progress(_("Rename failed")); |
753 | 1778 filelist_free(flist); |
1779 return; | |
1780 } | |
9 | 1781 |
753 | 1782 ud = file_util_data_new(UTILITY_TYPE_RENAME); |
138 | 1783 |
753 | 1784 ud->phase = phase; |
1 | 1785 |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1786 ud->with_sidecars = TRUE; |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1787 |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1788 ud->dir_fd = NULL; |
753 | 1789 ud->flist = flist; |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1790 ud->content_list = NULL; |
753 | 1791 ud->parent = parent; |
1792 | |
1793 ud->messages.title = _("Rename"); | |
1794 ud->messages.question = _("Rename files?"); | |
1795 ud->messages.desc_flist = _("This will rename the following files"); | |
1796 ud->messages.desc_source_fd = ""; | |
1797 ud->messages.fail = _("Rename failed"); | |
138 | 1798 |
753 | 1799 file_util_dialog_run(ud); |
1 | 1800 } |
1801 | |
753 | 1802 static void file_util_start_editor_full(gint n, FileData *source_fd, GList *source_list, const gchar *dest_path, GtkWidget *parent, UtilityPhase phase) |
1803 { | |
1804 UtilityData *ud; | |
1805 GList *flist = filelist_copy(source_list); | |
1806 | |
1807 if (source_fd) | |
1808 flist = g_list_append(flist, file_data_ref(source_fd)); | |
1 | 1809 |
947
368643594bc8
abort file operations when the file list is empty
nadvornik
parents:
946
diff
changeset
|
1810 if (!flist) return; |
368643594bc8
abort file operations when the file list is empty
nadvornik
parents:
946
diff
changeset
|
1811 |
849
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1812 file_util_disable_grouping_sc_list(flist); |
db68d673448f
added possibility to disable grouping of selected files
nadvornik
parents:
800
diff
changeset
|
1813 |
753 | 1814 if (!file_data_sc_add_ci_unspecified_list(flist, dest_path)) |
1 | 1815 { |
757 | 1816 file_util_warn_op_in_progress(_("Can't run external editor")); |
753 | 1817 filelist_free(flist); |
1818 return; | |
1 | 1819 } |
9 | 1820 |
753 | 1821 if (editor_is_filter(n)) |
1822 ud = file_util_data_new(UTILITY_TYPE_FILTER); | |
1823 else | |
1824 ud = file_util_data_new(UTILITY_TYPE_EDITOR); | |
1825 | |
1826 | |
1827 /* ask for destination if we don't have it */ | |
1828 if (ud->type == UTILITY_TYPE_FILTER && dest_path == NULL) phase = UTILITY_PHASE_START; | |
1829 | |
1830 ud->phase = phase; | |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1831 |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
1832 ud->with_sidecars = TRUE; |
753 | 1833 |
1834 ud->external_command = n; | |
1835 | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1836 ud->dir_fd = NULL; |
753 | 1837 ud->flist = flist; |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1838 ud->content_list = NULL; |
753 | 1839 ud->parent = parent; |
1840 | |
900 | 1841 if (dest_path) ud->dest_path = g_strdup(dest_path); |
753 | 1842 |
1843 ud->messages.title = _("Editor"); | |
1844 ud->messages.question = _("Run editor?"); | |
1845 ud->messages.desc_flist = _("This will copy the following files"); | |
1846 ud->messages.desc_source_fd = ""; | |
1847 ud->messages.fail = _("External command failed"); | |
1848 | |
1849 file_util_dialog_run(ud); | |
1 | 1850 } |
1851 | |
901 | 1852 static GList *file_util_delete_dir_remaining_folders(GList *dlist) |
1853 { | |
1854 GList *rlist = NULL; | |
1855 | |
1856 while (dlist) | |
1857 { | |
1858 FileData *fd; | |
1859 | |
1860 fd = dlist->data; | |
1861 dlist = dlist->next; | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1862 |
901 | 1863 if (!fd->name || |
1864 (strcmp(fd->name, THUMB_FOLDER_GLOBAL) != 0 && | |
1865 strcmp(fd->name, THUMB_FOLDER_LOCAL) != 0 && | |
1866 strcmp(fd->name, GQ_CACHE_LOCAL_METADATA) != 0) ) | |
1867 { | |
1868 rlist = g_list_prepend(rlist, fd); | |
1869 } | |
1870 } | |
1871 | |
1872 return g_list_reverse(rlist); | |
1873 } | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1874 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1875 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
|
1876 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1877 GList *dlist; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1878 GList *flist; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1879 GList *work; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1880 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1881 gboolean ok = TRUE; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1882 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1883 DEBUG_1("deltree into: %s", fd->path); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1884 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1885 level++; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1886 if (level > UTILITY_DELETE_MAX_DEPTH) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1887 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1888 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
|
1889 // ud->fail_fd = fd |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1890 return 0; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1891 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1892 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1893 if (!filelist_read_lstat(fd, &flist, &dlist)) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1894 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1895 // ud->fail_fd = fd |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1896 return 0; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1897 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1898 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1899 if (ok) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1900 { |
921 | 1901 ok = file_data_sc_add_ci_delete(fd); |
1902 if (ok) | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1903 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1904 ud->content_list = g_list_prepend(ud->content_list, fd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1905 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1906 // ud->fail_fd = fd |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1907 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1908 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1909 work = dlist; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1910 while (work && ok) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1911 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1912 FileData *lfd; |
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 lfd = work->data; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1915 work = work->next; |
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 ok = file_util_delete_dir_empty_path(ud, lfd, level); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1918 } |
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 work = flist; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1921 while (work && ok) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1922 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1923 FileData *lfd; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1924 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1925 lfd = work->data; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1926 work = work->next; |
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 DEBUG_1("deltree child: %s", lfd->path); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1929 |
921 | 1930 ok = file_data_sc_add_ci_delete(lfd); |
1931 if (ok) | |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1932 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1933 ud->content_list = g_list_prepend(ud->content_list, lfd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1934 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1935 // ud->fail_fd = fd |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1936 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1937 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1938 filelist_free(dlist); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1939 filelist_free(flist); |
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 DEBUG_1("deltree done: %s", fd->path); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1943 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1944 return ok; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1945 } |
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 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
|
1948 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1949 gboolean ok = TRUE; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1950 GList *work; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1951 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1952 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1953 work = dlist; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1954 while (work && ok) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1955 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1956 FileData *fd; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1957 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1958 fd = work->data; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1959 work = work->next; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1960 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1961 ok = file_util_delete_dir_empty_path(ud, fd, 0); |
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 work = flist; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1965 if (ok && file_data_sc_add_ci_delete_list(flist)) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1966 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1967 ud->content_list = g_list_concat(filelist_copy(flist), ud->content_list); |
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 else |
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 ok = FALSE; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1972 } |
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 if (ok) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1975 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1976 ok = file_data_sc_add_ci_delete(ud->dir_fd); |
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 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1979 if (!ok) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1980 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1981 work = ud->content_list; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1982 while (work) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1983 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1984 FileData *fd; |
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 fd = work->data; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1987 work = work->next; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1988 file_data_sc_free_ci(fd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1989 } |
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 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1992 return ok; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1993 } |
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 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
|
1996 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1997 GList *dlist; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1998 GList *flist; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
1999 GList *rlist; |
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 (!isdir(fd->path)) return; |
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 if (islink(fd->path)) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2004 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2005 UtilityData *ud; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2006 ud = file_util_data_new(UTILITY_TYPE_DELETE_LINK); |
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 ud->phase = phase; |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
2009 ud->with_sidecars = TRUE; |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2010 ud->dir_fd = file_data_ref(fd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2011 ud->content_list = NULL; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2012 ud->flist = NULL; |
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 ud->parent = parent; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2015 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2016 ud->messages.title = _("Delete folder"); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2017 ud->messages.question = _("Delete symbolic link?"); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2018 ud->messages.desc_flist = ""; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2019 ud->messages.desc_source_fd = _("This will delete the symbolic link.\n" |
995 | 2020 "The folder this link points to will not be deleted."); |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2021 ud->messages.fail = _("Link deletion failed"); |
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 file_util_dialog_run(ud); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2024 return; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2025 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2026 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2027 if (!access_file(fd->path, W_OK | X_OK)) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2028 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2029 gchar *text; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2030 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2031 text = g_strdup_printf(_("Unable to remove folder %s\n" |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2032 "Permissions do not allow writing to the folder."), fd->path); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2033 file_util_warning_dialog(_("Delete failed"), text, GTK_STOCK_DIALOG_ERROR, parent); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2034 g_free(text); |
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 return; |
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 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2039 if (!filelist_read_lstat(fd, &flist, &dlist)) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2040 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2041 gchar *text; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2042 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2043 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
|
2044 file_util_warning_dialog(_("Delete failed"), text, GTK_STOCK_DIALOG_ERROR, parent); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2045 g_free(text); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2046 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2047 return; |
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 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2050 rlist = file_util_delete_dir_remaining_folders(dlist); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2051 if (rlist) |
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 GenericDialog *gd; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2054 GtkWidget *box; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2055 gchar *text; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2056 |
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
|
2057 gd = file_util_gen_dlg(_("Folder contains subfolders"), "dlg_warning", |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2058 parent, TRUE, NULL, NULL); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2059 generic_dialog_add_button(gd, GTK_STOCK_CLOSE, NULL, NULL, TRUE); |
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 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
|
2062 "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
|
2063 fd->path); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2064 box = generic_dialog_add_message(gd, GTK_STOCK_DIALOG_WARNING, |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2065 _("Folder contains subfolders"), |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2066 text); |
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 box = pref_group_new(box, TRUE, _("Subfolders:"), GTK_ORIENTATION_VERTICAL); |
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 rlist = filelist_sort_path(rlist); |
1211 | 2072 file_util_dialog_add_list(box, rlist, FALSE, FALSE); |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2073 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2074 gtk_widget_show(gd->dialog); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2075 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2076 else |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2077 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2078 UtilityData *ud; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2079 ud = file_util_data_new(UTILITY_TYPE_DELETE_FOLDER); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2080 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2081 ud->phase = phase; |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
2082 ud->with_sidecars = TRUE; |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2083 ud->dir_fd = file_data_ref(fd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2084 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
|
2085 ud->flist = flist = filelist_sort_path(flist); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2086 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2087 ud->parent = parent; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2088 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2089 ud->messages.title = _("Delete folder"); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2090 ud->messages.question = _("Delete folder?"); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2091 ud->messages.desc_flist = _("The folder contains these files:"); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2092 ud->messages.desc_source_fd = _("This will delete the folder.\n" |
995 | 2093 "The contents of this folder will also be deleted."); |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2094 ud->messages.fail = _("File deletion failed"); |
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 if (!file_util_delete_dir_prepare(ud, flist, dlist)) |
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 gchar *text; |
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 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
|
2101 file_util_warning_dialog(_("Delete failed"), text, GTK_STOCK_DIALOG_ERROR, parent); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2102 g_free(text); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2103 file_data_unref(ud->dir_fd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2104 file_util_data_free(ud); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2105 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2106 else |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2107 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2108 filelist_free(dlist); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2109 file_util_dialog_run(ud); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2110 return; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2111 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2112 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2113 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2114 g_list_free(rlist); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2115 filelist_free(dlist); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2116 filelist_free(flist); |
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 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2119 static gboolean file_util_rename_dir_scan(UtilityData *ud, FileData *fd) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2120 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2121 GList *dlist; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2122 GList *flist; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2123 GList *work; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2124 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2125 gboolean ok = TRUE; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2126 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2127 if (!filelist_read_lstat(fd, &flist, &dlist)) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2128 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2129 // ud->fail_fd = fd |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2130 return 0; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2131 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2132 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2133 ud->content_list = g_list_concat(flist, ud->content_list); |
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 work = dlist; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2136 while (work && ok) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2137 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2138 FileData *lfd; |
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 lfd = work->data; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2141 work = work->next; |
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 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
|
2144 ok = file_util_rename_dir_scan(ud, lfd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2145 } |
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 filelist_free(dlist); |
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 return ok; |
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 |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
2152 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
|
2153 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2154 gboolean ok; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2155 GList *work; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2156 gint orig_len = strlen(ud->dir_fd->path); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2157 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2158 ok = file_util_rename_dir_scan(ud, ud->dir_fd); |
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 work = ud->content_list; |
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 while (ok && work) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2163 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2164 gchar *np; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2165 FileData *fd; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2166 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2167 fd = work->data; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2168 work = work->next; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2169 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2170 g_assert(strncmp(fd->path, ud->dir_fd->path, orig_len) == 0); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2171 |
921 | 2172 np = g_strconcat(new_path, fd->path + orig_len, NULL); |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2173 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2174 ok = file_data_sc_add_ci_rename(fd, np); |
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 DEBUG_1("Dir rename: %s -> %s", fd->path, np); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2177 g_free(np); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2178 } |
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 if (ok) |
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 ok = file_data_sc_add_ci_rename(ud->dir_fd, new_path); |
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 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2185 if (!ok) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2186 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2187 work = ud->content_list; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2188 while (work) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2189 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2190 FileData *fd; |
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 fd = work->data; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2193 work = work->next; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2194 file_data_sc_free_ci(fd); |
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 } |
921 | 2197 |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2198 return ok; |
995 | 2199 } |
896
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 |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
2202 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
|
2203 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2204 UtilityData *ud; |
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 ud = file_util_data_new(UTILITY_TYPE_RENAME_FOLDER); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2207 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2208 ud->phase = phase; |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
2209 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
|
2210 and the content must be handled including sidecars */ |
896
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 ud->dir_fd = file_data_ref(fd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2213 ud->flist = NULL; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2214 ud->content_list = NULL; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2215 ud->parent = parent; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2216 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2217 ud->messages.title = _("Rename"); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2218 ud->messages.question = _("Rename folder?"); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2219 ud->messages.desc_flist = _("The folder contains the following files"); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2220 ud->messages.desc_source_fd = ""; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2221 ud->messages.fail = _("Rename failed"); |
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 if (!file_util_rename_dir_prepare(ud, new_path)) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2224 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2225 file_util_warn_op_in_progress(ud->messages.fail); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2226 file_util_data_free(ud); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2227 return; |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2228 } |
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->flist = filelist_recursive(fd); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2231 |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2232 file_util_dialog_run(ud); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2233 } |
753 | 2234 |
1000
4fe8f9656107
For the sake of consistency, use glib basic types everywhere.
zas_
parents:
995
diff
changeset
|
2235 static void file_util_create_dir_full(FileData *fd, const gchar *dest_path, GtkWidget *parent, UtilityPhase phase) |
1 | 2236 { |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
2237 UtilityData *ud; |
901 | 2238 |
2239 ud = file_util_data_new(UTILITY_TYPE_CREATE_FOLDER); | |
2240 | |
2241 ud->phase = phase; | |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
2242 ud->with_sidecars = TRUE; |
901 | 2243 |
2244 ud->dir_fd = NULL; | |
2245 ud->flist = NULL; | |
2246 ud->content_list = NULL; | |
2247 ud->parent = parent; | |
2248 | |
995 | 2249 if (dest_path) |
901 | 2250 { |
2251 ud->dest_path = g_strdup(dest_path); | |
2252 } | |
2253 else | |
2254 { | |
2255 gchar *buf = g_build_filename(fd->path, _("New folder"), NULL); | |
2256 ud->dest_path = unique_filename(buf, NULL, " ", FALSE); | |
2257 g_free(buf); | |
2258 } | |
2259 | |
2260 ud->dir_fd = file_data_new_simple(ud->dest_path); | |
2261 | |
2262 ud->messages.title = _("Create Folder"); | |
2263 ud->messages.question = _("Create folder?"); | |
2264 ud->messages.desc_flist = ""; | |
2265 ud->messages.desc_source_fd = ""; | |
2266 ud->messages.fail = _("Can't create folder"); | |
2267 | |
2268 file_util_dialog_run(ud); | |
1 | 2269 } |
757 | 2270 |
9 | 2271 |
757 | 2272 /* full-featured entry points |
753 | 2273 */ |
1 | 2274 |
753 | 2275 void file_util_delete(FileData *source_fd, GList *source_list, GtkWidget *parent) |
2276 { | |
1054 | 2277 file_util_delete_full(source_fd, source_list, parent, options->file_ops.confirm_delete ? UTILITY_PHASE_START : UTILITY_PHASE_ENTERING); |
753 | 2278 } |
9 | 2279 |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
2280 void file_util_write_metadata(FileData *source_fd, GList *source_list, GtkWidget *parent) |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
2281 { |
1211 | 2282 file_util_write_metadata_full(source_fd, source_list, parent, |
2283 (options->metadata.save_in_image_file && options->metadata.confirm_write) ? UTILITY_PHASE_START : UTILITY_PHASE_ENTERING); | |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
2284 } |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1175
diff
changeset
|
2285 |
753 | 2286 void file_util_copy(FileData *source_fd, GList *source_list, const gchar *dest_path, GtkWidget *parent) |
2287 { | |
2288 file_util_copy_full(source_fd, source_list, dest_path, parent, UTILITY_PHASE_START); | |
2289 } | |
757 | 2290 |
753 | 2291 void file_util_move(FileData *source_fd, GList *source_list, const gchar *dest_path, GtkWidget *parent) |
2292 { | |
2293 file_util_move_full(source_fd, source_list, dest_path, parent, UTILITY_PHASE_START); | |
2294 } | |
757 | 2295 |
753 | 2296 void file_util_rename(FileData *source_fd, GList *source_list, GtkWidget *parent) |
2297 { | |
2298 file_util_rename_full(source_fd, source_list, NULL, parent, UTILITY_PHASE_START); | |
1 | 2299 } |
2300 | |
753 | 2301 /* these avoid the location entry dialog unless there is an error, list must be files only and |
2302 * dest_path must be a valid directory path | |
757 | 2303 */ |
753 | 2304 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
|
2305 { |
753 | 2306 file_util_move_full(NULL, list, dest_path, parent, UTILITY_PHASE_ENTERING); |
2307 } | |
757 | 2308 |
753 | 2309 void file_util_copy_simple(GList *list, const gchar *dest_path, GtkWidget *parent) |
2310 { | |
2311 file_util_copy_full(NULL, list, dest_path, parent, UTILITY_PHASE_ENTERING); | |
2312 } | |
757 | 2313 |
753 | 2314 void file_util_rename_simple(FileData *fd, const gchar *dest_path, GtkWidget *parent) |
2315 { | |
2316 file_util_rename_full(fd, NULL, dest_path, parent, UTILITY_PHASE_ENTERING); | |
2317 } | |
138 | 2318 |
44
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2319 |
753 | 2320 void file_util_start_editor_from_file(gint n, FileData *fd, GtkWidget *parent) |
2321 { | |
2322 file_util_start_editor_full(n, fd, NULL, NULL, parent, UTILITY_PHASE_ENTERING); | |
2323 } | |
2324 | |
2325 void file_util_start_editor_from_filelist(gint n, GList *list, GtkWidget *parent) | |
2326 { | |
2327 file_util_start_editor_full(n, NULL, list, NULL, parent, UTILITY_PHASE_ENTERING); | |
2328 } | |
44
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2329 |
753 | 2330 void file_util_start_filter_from_file(gint n, FileData *fd, const gchar *dest_path, GtkWidget *parent) |
2331 { | |
2332 file_util_start_editor_full(n, fd, NULL, dest_path, parent, UTILITY_PHASE_ENTERING); | |
2333 } | |
44
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2334 |
753 | 2335 void file_util_start_filter_from_filelist(gint n, GList *list, const gchar *dest_path, GtkWidget *parent) |
2336 { | |
2337 file_util_start_editor_full(n, NULL, list, dest_path, parent, UTILITY_PHASE_ENTERING); | |
2338 } | |
44
458e396d3f35
Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents:
42
diff
changeset
|
2339 |
896
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2340 void file_util_delete_dir(FileData *fd, GtkWidget *parent) |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2341 { |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2342 file_util_delete_dir_full(fd, parent, UTILITY_PHASE_START); |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2343 } |
cf21dc928122
implemented directory rename and delete operations
nadvornik
parents:
855
diff
changeset
|
2344 |
901 | 2345 void file_util_create_dir(FileData *dir_fd, GtkWidget *parent) |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2346 { |
901 | 2347 file_util_create_dir_full(dir_fd, NULL, parent, UTILITY_PHASE_ENTERING); |
2348 } | |
112
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2349 |
908 | 2350 void file_util_rename_dir(FileData *source_fd, const gchar *new_path, GtkWidget *parent) |
901 | 2351 { |
2352 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
|
2353 } |
b15d4c18168f
Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents:
80
diff
changeset
|
2354 |
753 | 2355 |
2356 void file_util_copy_path_to_clipboard(FileData *fd) | |
2357 { | |
2358 GtkClipboard *clipboard; | |
2359 | |
2360 if (!fd || !*fd->path) return; | |
2361 | |
2362 clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); | |
2363 gtk_clipboard_set_text(clipboard, g_shell_quote(fd->path), -1); | |
2364 } | |
2365 | |
2366 void file_util_copy_path_list_to_clipboard(GList *list) | |
2367 { | |
2368 GtkClipboard *clipboard; | |
2369 GList *work; | |
2370 GString *new; | |
2371 | |
2372 clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); | |
2373 | |
2374 new = g_string_new(""); | |
2375 work = list; | |
2376 while (work) { | |
2377 FileData *fd = work->data; | |
2378 work = work->next; | |
2379 | |
2380 if (!fd || !*fd->path) continue; | |
2381 | |
2382 g_string_append(new, g_shell_quote(fd->path)); | |
2383 if (work) g_string_append_c(new, ' '); | |
2384 } | |
2385 | |
2386 gtk_clipboard_set_text(clipboard, new->str, new->len); | |
2387 g_string_free(new, TRUE); | |
2388 } | |
1055
1646720364cf
Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents:
1054
diff
changeset
|
2389 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ |