annotate src/utilops.c @ 1669:daab013a0dcf

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