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