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