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