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