annotate src/utilops.c @ 440:3d16af3b133a

rm as external delete command is too dangerous, even for testing
author nadvornik
date Sun, 20 Apr 2008 09:53:37 +0000
parents 15c6b94545a2
children 4b2d7f9af171
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
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
4 *
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
5 * Author: John Ellis
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
6 *
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
7 * 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
8 * Please read the included file COPYING for more information.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
9 * This software comes with no warranty of any kind, use at your own risk!
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
10 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
11
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
12
281
9995c5fb202a gqview.h -> main.h
zas_
parents: 254
diff changeset
13 #include "main.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
14 #include "utilops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
15
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"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
21 #include "filelist.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
22 #include "image.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
23 #include "img-view.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
24 #include "layout.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
25 #include "search.h"
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
26 #include "thumb_standard.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
27 #include "ui_bookmark.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
28 #include "ui_fileops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
29 #include "ui_misc.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
30 #include "ui_tabcomp.h"
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
31 #include "editors.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
32
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
33 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
34 *--------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
35 * call these when names change, files move, deleted, etc.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
36 * so that any open windows are also updated
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
37 *--------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
38 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
39
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
40
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
41 void file_maint_renamed(FileData *fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
42 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
43 cache_maint_moved(fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
44 collection_maint_renamed(fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
45
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
46 layout_maint_renamed(fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
47 view_window_maint_moved(fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
48 dupe_maint_renamed(fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
49 search_maint_renamed(fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
50 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
51
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
52 /* under most cases ignore_list should be NULL */
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
53 void file_maint_removed(FileData *fd, GList *ignore_list)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
54 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
55 layout_maint_removed(fd, ignore_list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
56 view_window_maint_removed(fd, ignore_list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
57 dupe_maint_removed(fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
58 search_maint_removed(fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
59
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
60 collection_maint_removed(fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
61 cache_maint_removed(fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
62 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
63
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
64 /* special case for correct main window behavior */
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
65 void file_maint_moved(FileData *fd, GList *ignore_list)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
66 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
67 cache_maint_moved(fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
68 collection_maint_renamed(fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
69
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
70 layout_maint_moved(fd, ignore_list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
71 view_window_maint_moved(fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
72 dupe_maint_renamed(fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
73 search_maint_renamed(fd);
9
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
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
76 void file_maint_copied(FileData *fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
77 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
78 cache_maint_copied(fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
79 }
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 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
82 *--------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
83 * The file manipulation dialogs
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 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
86
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
87
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
88 enum {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
89 DIALOG_NEW_DIR,
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
90 DIALOG_COPY,
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
91 DIALOG_MOVE,
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
92 DIALOG_DELETE,
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
93 DIALOG_RENAME
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
94 };
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
95
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
96 typedef struct _FileDataMult FileDataMult;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
97 struct _FileDataMult
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
98 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
99 gint confirm_all;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
100 gint confirmed;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
101 gint skip;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
102 GList *source_list;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
103 GList *source_next;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
104 gchar *dest_base;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
105 FileData *source_fd;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
106 gchar *dest;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
107 gint copy;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
108
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
109 gint rename;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
110 gint rename_auto;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
111 gint rename_all;
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 GtkWidget *rename_box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
114 GtkWidget *rename_entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
115 GtkWidget *rename_auto_box;
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 GtkWidget *yes_all_button;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
118 };
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
119
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
120 typedef struct _FileDataSingle FileDataSingle;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
121 struct _FileDataSingle
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
122 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
123 gint confirmed;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
124 FileData *source_fd;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
125 gchar *dest;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
126 gint copy;
9
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 gint rename;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
129 gint rename_auto;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
130
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
131 GtkWidget *rename_box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
132 GtkWidget *rename_entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
133 GtkWidget *rename_auto_box;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
134 };
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
135
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 * 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
139 *--------------------------------------------------------------------------
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
142 #define DIALOG_DEF_IMAGE_DIM_X 200
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
143 #define DIALOG_DEF_IMAGE_DIM_Y 150
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
144
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
145 static void generic_dialog_add_image(GenericDialog *gd, GtkWidget *box,
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
146 FileData *fd1, const gchar *header1,
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
147 FileData *fd2, const gchar *header2,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
148 gint show_filename)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
149 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
150 ImageWindow *imd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
151 GtkWidget *hbox = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
152 GtkWidget *vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
153 GtkWidget *label = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
154
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
155 if (!box) box = gd->vbox;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
156
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
157 if (fd2)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
158 {
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
159 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
160 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
161
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
162 /* image 1 */
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 vbox = gtk_vbox_new(FALSE, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
165 if (hbox)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
166 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
167 GtkWidget *sep;
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_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
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 sep = gtk_vseparator_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
172 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
173 gtk_widget_show(sep);
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
176 {
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
177 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
178 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
179 gtk_widget_show(vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
180
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
181 if (header1)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
182 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
183 GtkWidget *head;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
184
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
185 head = pref_label_new(vbox, header1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
186 pref_label_bold(head, TRUE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
187 gtk_misc_set_alignment(GTK_MISC(head), 0.0, 0.5);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
188 }
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 imd = image_new(FALSE);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
191 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
192 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
193 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
194 image_change_fd(imd, fd1, 0.0);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
195 gtk_widget_show(imd->widget);
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 if (show_filename)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
198 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
199 label = pref_label_new(vbox, (fd1 == NULL) ? "" : fd1->name);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
200 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
201
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
202 /* 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
203 g_object_set_data(G_OBJECT(gd->dialog), "img_image", imd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
204 g_object_set_data(G_OBJECT(gd->dialog), "img_label", label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
205
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
206
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
207 /* image 2 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
208
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
209 if (hbox && fd2)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
210 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
211 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
212
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
213 if (header2)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
214 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
215 GtkWidget *head;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
216
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
217 head = pref_label_new(vbox, header2);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
218 pref_label_bold(head, TRUE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
219 gtk_misc_set_alignment(GTK_MISC(head), 0.0, 0.5);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
220 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
221
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
222 imd = image_new(FALSE);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
223 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
224 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
225 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
226 image_change_fd(imd, fd2, 0.0);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
227 gtk_widget_show(imd->widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
228
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
229 pref_label_new(vbox, fd2->name);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
230 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
231 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
232
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
233 static void generic_dialog_image_set(GenericDialog *gd, FileData *fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
234 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
235 ImageWindow *imd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
236 GtkWidget *label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
237
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
238 imd = g_object_get_data(G_OBJECT(gd->dialog), "img_image");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
239 label = g_object_get_data(G_OBJECT(gd->dialog), "img_label");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
240
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
241 if (!imd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
242
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
243 image_change_fd(imd, fd, 0.0);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
244 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
245 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
246
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
247 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
248 *--------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
249 * Wrappers to aid in setting additional dialog properties (unde mouse, etc.)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
250 *--------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
251 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
252
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
253 GenericDialog *file_util_gen_dlg(const gchar *title,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
254 const gchar *wmclass, const gchar *wmsubclass,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
255 GtkWidget *parent, gint auto_close,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
256 void (*cancel_cb)(GenericDialog *, gpointer), gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
257 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
258 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
259
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
260 gd = generic_dialog_new(title, wmclass, wmsubclass, parent, auto_close, cancel_cb, data);
318
b16b9b8979e5 Add a new struct ConfOptions to handle options.
zas_
parents: 288
diff changeset
261 if (options->place_dialogs_under_mouse)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
262 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
263 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
264 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
265
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
266 return gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
267 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
268
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
269 FileDialog *file_util_file_dlg(const gchar *title,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
270 const gchar *wmclass, const gchar *wmsubclass,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
271 GtkWidget *parent,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
272 void (*cancel_cb)(FileDialog *, gpointer), gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
273 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
274 FileDialog *fdlg;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
275
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
276 fdlg = file_dialog_new(title, wmclass, wmsubclass, parent, cancel_cb, data);
318
b16b9b8979e5 Add a new struct ConfOptions to handle options.
zas_
parents: 288
diff changeset
277 if (options->place_dialogs_under_mouse)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
278 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
279 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
280 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
281
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
282 return fdlg;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
283 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
284
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
285 /* this warning dialog is copied from SLIK's ui_utildg.c,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
286 * because it does not have a mouse center option,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
287 * and we must center it before show, implement it here.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
288 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
289 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
290 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
291 /* no op */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
292 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
293
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
294 GenericDialog *file_util_warning_dialog(const gchar *heading, const gchar *message,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
295 const gchar *icon_stock_id, GtkWidget *parent)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
296 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
297 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
298
254
9faf34f047b1 Make the wmclass value unique among the code by defining
zas_
parents: 223
diff changeset
299 gd = file_util_gen_dlg(heading, GQ_WMCLASS, "warning", parent, TRUE, NULL, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
300 generic_dialog_add_message(gd, icon_stock_id, heading, message);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
301 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
302 if (options->place_dialogs_under_mouse)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
303 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
304 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
305 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
306 gtk_widget_show(gd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
307
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
308 return gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
309 }
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
310
42
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
311 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
312 {
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
313 gint n;
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
314
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
315 if (!name) return 0;
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
316
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
317 n = strlen(name);
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
318
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
319 if (filter_name_exists(name))
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
320 {
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
321 const gchar *ext;
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
322
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
323 ext = extension_from_path(name);
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
324 if (ext) n -= strlen(ext);
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
325 }
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
326
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
327 return n;
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
328 }
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
329
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
330
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
331 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
332 *--------------------------------------------------------------------------
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
333 * Move and Copy routines
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
334 *--------------------------------------------------------------------------
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
335 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
336
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
337 static gint copy_file_ext_cb(gpointer ed, gint flags, GList *list, gpointer data)
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
338 {
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
339 if ((flags & EDITOR_ERROR_MASK) && !(flags & EDITOR_ERROR_SKIPPED))
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
340 {
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
341 FileData *fd = list->data;
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
342 gchar *title = _("Error copying file");
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
343 gchar *text = g_strdup_printf(_("%s\nUnable to copy file:\n%s\nto:\n%s"), editor_get_error_str(flags), fd->name, fd->change->dest);
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
344 file_util_warning_dialog(title, text, GTK_STOCK_DIALOG_ERROR, NULL);
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
345 g_free(text);
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
346 }
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
347 while (list)
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
348 {
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
349 FileData *fd = list->data;
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
350 if (!(flags & EDITOR_ERROR_MASK))
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
351 file_maint_copied(fd);
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
352 file_data_change_info_free(NULL, fd);
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
353 list = list->next;
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
354 }
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
355 return EDITOR_CB_CONTINUE;
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
356 }
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
357
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
358
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
359 gint copy_file_ext(FileData *fd)
136
18c2a29e681c more external commands
nadvornik
parents: 135
diff changeset
360 {
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
361 gint ok;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
362 g_assert(fd->change);
318
b16b9b8979e5 Add a new struct ConfOptions to handle options.
zas_
parents: 288
diff changeset
363 if (options->editor_command[CMD_COPY])
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
364 {
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
365 ok = !start_editor_from_file_full(CMD_COPY, fd, copy_file_ext_cb, NULL);
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
366 if (ok) return ok; /* that's all for now, let's continue in callback */
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
367 }
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
368 else
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
369 ok = copy_file(fd->change->source, fd->change->dest);
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
370
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
371 if (ok)
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
372 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
373 file_maint_copied(fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
374 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
375
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
376 file_data_change_info_free(NULL, fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
377
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
378 return ok;
136
18c2a29e681c more external commands
nadvornik
parents: 135
diff changeset
379 }
18c2a29e681c more external commands
nadvornik
parents: 135
diff changeset
380
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
381 static gint move_file_ext_cb(gpointer ed, gint flags, GList *list, gpointer data)
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
382 {
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
383 if ((flags & EDITOR_ERROR_MASK) && !(flags & EDITOR_ERROR_SKIPPED))
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
384 {
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
385 FileData *fd = list->data;
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
386 gchar *title = _("Error moving file");
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
387 gchar *text = g_strdup_printf(_("%s\nUnable to move file:\n%s\nto:\n%s"), editor_get_error_str(flags), fd->name, fd->change->dest);
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
388 file_util_warning_dialog(title, text, GTK_STOCK_DIALOG_ERROR, NULL);
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
389 g_free(text);
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
390 }
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
391 while (list)
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
392 {
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
393 FileData *fd = list->data;
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
394 if (!(flags & EDITOR_ERROR_MASK))
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
395 {
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
396 file_data_do_change(fd);
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
397 file_maint_moved(fd, NULL);
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
398 }
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
399 file_data_change_info_free(NULL, fd);
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
400 list = list->next;
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
401 }
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
402 return EDITOR_CB_CONTINUE;
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
403
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
404 }
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
405
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
406
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
407 gint move_file_ext(FileData *fd)
136
18c2a29e681c more external commands
nadvornik
parents: 135
diff changeset
408 {
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
409 gint ok;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
410 g_assert(fd->change);
318
b16b9b8979e5 Add a new struct ConfOptions to handle options.
zas_
parents: 288
diff changeset
411 if (options->editor_command[CMD_MOVE])
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
412 {
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
413 ok = !start_editor_from_file_full(CMD_MOVE, fd, move_file_ext_cb, NULL);
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
414 if (ok) return ok; /* that's all for now, let's continue in callback */
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
415 }
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
416 else
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
417 ok = move_file(fd->change->source, fd->change->dest);
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
418
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
419 if (ok)
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
420 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
421 file_data_do_change(fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
422 file_maint_moved(fd, NULL);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
423 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
424
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
425 file_data_change_info_free(NULL, fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
426
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
427 return ok;
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
428 }
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
429
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
430 static gint rename_file_ext_cb(gpointer ed, gint flags, GList *list, gpointer data)
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
431 {
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
432 if ((flags & EDITOR_ERROR_MASK) && !(flags & EDITOR_ERROR_SKIPPED))
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
433 {
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
434 FileData *fd = list->data;
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
435 gchar *title = _("Error renaming file");
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
436 gchar *text = g_strdup_printf(_("%s\nUnable to rename file:\n%s\nto:\n%s"), editor_get_error_str(flags), fd->name, fd->change->dest);
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
437 file_util_warning_dialog(title, text, GTK_STOCK_DIALOG_ERROR, NULL);
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
438 g_free(text);
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
439 }
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
440 while (list)
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
441 {
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
442 FileData *fd = list->data;
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
443 if (!(flags & EDITOR_ERROR_MASK))
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
444 {
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
445 file_data_do_change(fd);
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
446 file_maint_renamed(fd);
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
447 }
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
448 file_data_change_info_free(NULL, fd);
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
449 list = list->next;
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
450 }
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
451 return EDITOR_CB_CONTINUE;
136
18c2a29e681c more external commands
nadvornik
parents: 135
diff changeset
452 }
18c2a29e681c more external commands
nadvornik
parents: 135
diff changeset
453
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
454 gint rename_file_ext(FileData *fd)
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 gint ok;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
457 g_assert(fd->change);
318
b16b9b8979e5 Add a new struct ConfOptions to handle options.
zas_
parents: 288
diff changeset
458 if (options->editor_command[CMD_RENAME])
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
459 {
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
460 ok = !start_editor_from_file_full(CMD_RENAME, fd, rename_file_ext_cb, NULL);
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
461 if (ok) return ok; /* that's all for now, let's continue in callback */
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
462 }
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
463 else
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
464 ok = rename_file(fd->change->source, fd->change->dest);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
465
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
466 if (ok)
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
467 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
468 file_data_do_change(fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
469 file_maint_renamed(fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
470 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
471
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
472 file_data_change_info_free(NULL, fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
473
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
474 return ok;
136
18c2a29e681c more external commands
nadvornik
parents: 135
diff changeset
475 }
18c2a29e681c more external commands
nadvornik
parents: 135
diff changeset
476
18c2a29e681c more external commands
nadvornik
parents: 135
diff changeset
477
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
478 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
479 * Multi file move
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
480 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
481
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
482 static FileDataMult *file_data_multiple_new(GList *source_list, const gchar *dest, gint copy)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
483 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
484 FileDataMult *fdm = g_new0(FileDataMult, 1);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
485 fdm->confirm_all = FALSE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
486 fdm->confirmed = FALSE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
487 fdm->skip = FALSE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
488 fdm->source_list = source_list;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
489 fdm->source_next = fdm->source_list;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
490 fdm->dest_base = g_strdup(dest);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
491 fdm->source_fd = NULL;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
492 fdm->dest = NULL;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
493 fdm->copy = copy;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
494 return fdm;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
495 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
496
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
497 static void file_data_multiple_free(FileDataMult *fdm)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
498 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
499 filelist_free(fdm->source_list);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
500 g_free(fdm->dest_base);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
501 g_free(fdm->dest);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
502 g_free(fdm);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
503 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
504
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
505 static void file_util_move_multiple(FileDataMult *fdm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
506
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
507 static void file_util_move_multiple_ok_cb(GenericDialog *gd, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
508 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
509 FileDataMult *fdm = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
510
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
511 fdm->confirmed = TRUE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
512
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
513 if (fdm->rename_auto)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
514 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
515 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
516
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
517 buf = unique_filename_simple(fdm->dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
518 if (buf)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
519 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
520 g_free(fdm->dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
521 fdm->dest = buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
522 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
523 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
524 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
525 /* unique failed? well, return to the overwrite prompt :( */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
526 fdm->confirmed = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
527 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
528 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
529 else if (fdm->rename)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
530 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
531 const gchar *name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
532
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
533 name = gtk_entry_get_text(GTK_ENTRY(fdm->rename_entry));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
534 if (strlen(name) == 0 ||
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
535 strcmp(name, fdm->source_fd->name) == 0)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
536 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
537 fdm->confirmed = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
538 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
539 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
540 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
541 g_free(fdm->dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
542 fdm->dest = concat_dir_and_file(fdm->dest_base, name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
543 fdm->confirmed = !isname(fdm->dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
544 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
545 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
546
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
547 file_util_move_multiple(fdm);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
548 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
549
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
550 static void file_util_move_multiple_all_cb(GenericDialog *gd, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
551 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
552 FileDataMult *fdm = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
553
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
554 fdm->confirm_all = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
555
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
556 if (fdm->rename_auto) fdm->rename_all = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
557
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
558 file_util_move_multiple(fdm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
559 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
560
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
561 static void file_util_move_multiple_skip_cb(GenericDialog *gd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
562 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
563 FileDataMult *fdm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
564
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
565 fdm->skip = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
566 fdm->confirmed = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
567
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
568 file_util_move_multiple(fdm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
569 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
570
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
571 static void file_util_move_multiple_skip_all_cb(GenericDialog *gd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
572 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
573 FileDataMult *fdm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
574
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
575 fdm->skip = TRUE;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
576 fdm->confirm_all = TRUE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
577 file_util_move_multiple(fdm);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
578 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
579
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
580 static void file_util_move_multiple_continue_cb(GenericDialog *gd, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
581 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
582 FileDataMult *fdm = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
583
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
584 fdm->confirmed = TRUE;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
585 file_util_move_multiple(fdm);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
586 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
587
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
588 static void file_util_move_multiple_cancel_cb(GenericDialog *gd, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
589 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
590 FileDataMult *fdm = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
591
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
592 file_data_multiple_free(fdm);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
593 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
594
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
595 /* rename option */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
596
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
597 static void file_util_move_multiple_rename_auto_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
598 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
599 GenericDialog *gd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
600 FileDataMult *fdm;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
601
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
602 fdm = gd->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
603
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
604 fdm->rename_auto = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
605 gtk_widget_set_sensitive(fdm->rename_box, !fdm->rename_auto);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
606 gtk_widget_set_sensitive(fdm->rename_entry, (!fdm->rename_auto && fdm->rename));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
607
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
608 if (fdm->rename_auto)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
609 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
610 gchar *preview;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
611
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
612 preview = unique_filename_simple(fdm->dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
613 if (preview) gtk_entry_set_text(GTK_ENTRY(fdm->rename_entry), filename_from_path(preview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
614 g_free(preview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
615 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
616
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
617 gtk_widget_set_sensitive(fdm->yes_all_button, (fdm->rename_auto || !fdm->rename));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
618 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
619
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
620 static void file_util_move_multiple_rename_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
621 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
622 GenericDialog *gd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
623 FileDataMult *fdm;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
624
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
625 fdm = gd->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
626
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
627 fdm->rename = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
628 gtk_widget_set_sensitive(fdm->rename_entry, fdm->rename);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
629 gtk_widget_set_sensitive(fdm->yes_all_button, !fdm->rename);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
630
42
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
631 if (fdm->rename)
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
632 {
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
633 const gchar *name;
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
634
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
635 gtk_widget_grab_focus(fdm->rename_entry);
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
636
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
637 name = gtk_entry_get_text(GTK_ENTRY(fdm->rename_entry));
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
638 gtk_editable_select_region(GTK_EDITABLE(fdm->rename_entry), 0, filename_base_length(name));
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
639 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
640 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
641
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
642 static GenericDialog *file_util_move_multiple_confirm_dialog(FileDataMult *fdm)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
643 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
644 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
645 GtkWidget *hbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
646
254
9faf34f047b1 Make the wmclass value unique among the code by defining
zas_
parents: 223
diff changeset
647 gd = file_util_gen_dlg(_("Overwrite file"), GQ_WMCLASS, "dlg_confirm",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
648 NULL, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
649 file_util_move_multiple_cancel_cb, fdm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
650
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
651 generic_dialog_add_message(gd, GTK_STOCK_DIALOG_QUESTION,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
652 _("Overwrite file?"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
653 _("Replace existing file with new file."));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
654 pref_spacer(gd->vbox, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
655
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
656 generic_dialog_add_button(gd, GTK_STOCK_YES, _("_Overwrite"), file_util_move_multiple_ok_cb, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
657 fdm->yes_all_button = generic_dialog_add_button(gd, NULL, _("Overwrite _all"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
658 file_util_move_multiple_all_cb, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
659 generic_dialog_add_button(gd, GTK_STOCK_GOTO_LAST, _("S_kip all"), file_util_move_multiple_skip_all_cb, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
660 generic_dialog_add_button(gd, GTK_STOCK_GO_FORWARD, _("_Skip"), file_util_move_multiple_skip_cb, FALSE);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
661 generic_dialog_add_image(gd, NULL, file_data_new_simple(fdm->dest), _("Existing file"), fdm->source_fd, _("New file"), TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
662
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
663 /* rename option */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
664
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
665 fdm->rename = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
666 fdm->rename_all = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
667 fdm->rename_auto = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
668
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
669 hbox = pref_box_new(gd->vbox, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
670
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
671 fdm->rename_auto_box = gtk_check_button_new_with_label(_("Auto rename"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
672 g_signal_connect(G_OBJECT(fdm->rename_auto_box), "clicked",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
673 G_CALLBACK(file_util_move_multiple_rename_auto_cb), gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
674 gtk_box_pack_start(GTK_BOX(hbox), fdm->rename_auto_box, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
675 gtk_widget_show(fdm->rename_auto_box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
676
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
677 hbox = pref_box_new(gd->vbox, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
678
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
679 fdm->rename_box = gtk_check_button_new_with_label(_("Rename"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
680 g_signal_connect(G_OBJECT(fdm->rename_box), "clicked",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
681 G_CALLBACK(file_util_move_multiple_rename_cb), gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
682 gtk_box_pack_start(GTK_BOX(hbox), fdm->rename_box, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
683 gtk_widget_show(fdm->rename_box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
684
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
685 fdm->rename_entry = gtk_entry_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
686 gtk_entry_set_text(GTK_ENTRY(fdm->rename_entry), filename_from_path(fdm->dest));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
687 gtk_widget_set_sensitive(fdm->rename_entry, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
688 gtk_box_pack_start(GTK_BOX(hbox), fdm->rename_entry, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
689 gtk_widget_show(fdm->rename_entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
690
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
691 return gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
692 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
693
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
694 static void file_util_move_multiple(FileDataMult *fdm)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
695 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
696 while (fdm->dest || fdm->source_next)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
697 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
698 gint success = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
699 gint skip_file = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
700
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
701 if (!fdm->dest)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
702 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
703 GList *work = fdm->source_next;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
704 fdm->source_fd = work->data;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
705 fdm->dest = concat_dir_and_file(fdm->dest_base, fdm->source_fd->name);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
706 fdm->source_next = work->next;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
707 fdm->confirmed = FALSE;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
708 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
709
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
710 if (fdm->dest && fdm->source_fd && strcmp(fdm->dest, fdm->source_fd->name) == 0)
3
gqview
parents: 1
diff changeset
711 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
712 if (!fdm->confirmed)
3
gqview
parents: 1
diff changeset
713 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
714 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
715 const gchar *title;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
716 gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
717
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
718 if (fdm->copy)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
719 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
720 title = _("Source to copy matches destination");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
721 text = g_strdup_printf(_("Unable to copy file:\n%s\nto itself."), fdm->dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
722 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
723 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
724 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
725 title = _("Source to move matches destination");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
726 text = g_strdup_printf(_("Unable to move file:\n%s\nto itself."), fdm->dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
727 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
728
254
9faf34f047b1 Make the wmclass value unique among the code by defining
zas_
parents: 223
diff changeset
729 gd = file_util_gen_dlg(title, GQ_WMCLASS, "dlg_confirm",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
730 NULL, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
731 file_util_move_multiple_cancel_cb, fdm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
732 generic_dialog_add_message(gd, GTK_STOCK_DIALOG_WARNING, title, text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
733 g_free(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
734 generic_dialog_add_button(gd, GTK_STOCK_GO_FORWARD, _("Co_ntinue"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
735 file_util_move_multiple_continue_cb, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
736
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
737 gtk_widget_show(gd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
738 return;
3
gqview
parents: 1
diff changeset
739 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
740 skip_file = TRUE;
3
gqview
parents: 1
diff changeset
741 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
742 else if (isfile(fdm->dest))
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
743 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
744 if (!fdm->confirmed && !fdm->confirm_all)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
745 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
746 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
747
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
748 gd = file_util_move_multiple_confirm_dialog(fdm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
749 gtk_widget_show(gd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
750 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
751 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
752 if (fdm->skip) skip_file = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
753 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
754
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
755 if (skip_file)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
756 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
757 success = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
758 if (!fdm->confirm_all) fdm->skip = FALSE;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
759 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
760 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
761 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
762 gint try = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
763
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
764 if (fdm->confirm_all && fdm->rename_all && isfile(fdm->dest))
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
765 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
766 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
767 buf = unique_filename_simple(fdm->dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
768 if (buf)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
769 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
770 g_free(fdm->dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
771 fdm->dest = buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
772 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
773 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
774 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
775 try = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
776 }
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
777 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
778 if (try)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
779 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
780 if (fdm->copy)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
781 {
143
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
782 if (file_data_add_change_info(fdm->source_fd, FILEDATA_CHANGE_COPY, fdm->source_fd->path, fdm->dest) &&
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
783 copy_file_ext(fdm->source_fd))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
784 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
785 success = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
786 }
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
787 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
788 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
789 {
143
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
790 if (file_data_add_change_info(fdm->source_fd, FILEDATA_CHANGE_MOVE, fdm->source_fd->path, fdm->dest) &&
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
791 move_file_ext(fdm->source_fd))
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
792 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
793 success = TRUE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
794 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
795 }
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
796
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
797 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
798 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
799 if (!success)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
800 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
801 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
802 const gchar *title;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
803 gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
804
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
805 if (fdm->copy)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
806 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
807 title = _("Error copying file");
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
808 text = g_strdup_printf(_("Unable to copy file:\n%s\nto:\n%s\nduring multiple file copy."), fdm->source_fd->path, fdm->dest);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
809 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
810 else
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
811 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
812 title = _("Error moving file");
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
813 text = g_strdup_printf(_("Unable to move file:\n%s\nto:\n%s\nduring multiple file move."), fdm->source_fd->path, fdm->dest);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
814 }
254
9faf34f047b1 Make the wmclass value unique among the code by defining
zas_
parents: 223
diff changeset
815 gd = file_util_gen_dlg(title, GQ_WMCLASS, "dlg_confirm",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
816 NULL, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
817 file_util_move_multiple_cancel_cb, fdm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
818 generic_dialog_add_message(gd, GTK_STOCK_DIALOG_WARNING, title, text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
819 g_free(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
820
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
821 generic_dialog_add_button(gd, GTK_STOCK_GO_FORWARD, _("Co_ntinue"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
822 file_util_move_multiple_continue_cb, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
823 gtk_widget_show(gd->dialog);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
824 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
825
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
826 g_free(fdm->dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
827 fdm->dest = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
828
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
829 if (!success) return;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
830 }
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
831 /*
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
832 if (fdm->source_list)
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
833 file_util_do_move_list(fdm->source_list, fdm->copy);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
834 else
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
835 {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
836 GList *list = g_list_append(NULL, file_data_ref(fdm->source_fd));
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
837 file_util_do_move_list(list, fdm->copy);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
838 filelist_free(list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
839 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
840 */
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
841 file_data_multiple_free(fdm);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
842 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
843
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
844 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
845 * Single file move
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
846 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
847
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
848 static FileDataSingle *file_data_single_new(FileData *source_fd, const gchar *dest, gint copy)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
849 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
850 FileDataSingle *fds = g_new0(FileDataSingle, 1);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
851 fds->confirmed = FALSE;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
852 fds->source_fd = file_data_ref(source_fd);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
853 fds->dest = g_strdup(dest);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
854 fds->copy = copy;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
855 return fds;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
856 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
857
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
858 static void file_data_single_free(FileDataSingle *fds)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
859 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
860 file_data_unref(fds->source_fd);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
861 g_free(fds->dest);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
862 g_free(fds);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
863 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
864
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
865 static void file_util_move_single(FileDataSingle *fds);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
866
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
867 static void file_util_move_single_ok_cb(GenericDialog *gd, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
868 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
869 FileDataSingle *fds = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
870
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
871 fds->confirmed = TRUE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
872
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
873 if (fds->rename_auto)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
874 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
875 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
876
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
877 buf = unique_filename_simple(fds->dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
878 if (buf)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
879 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
880 g_free(fds->dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
881 fds->dest = buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
882 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
883 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
884 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
885 /* unique failed? well, return to the overwrite prompt :( */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
886 fds->confirmed = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
887 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
888 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
889 else if (fds->rename)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
890 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
891 const gchar *name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
892
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
893 name = gtk_entry_get_text(GTK_ENTRY(fds->rename_entry));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
894 if (strlen(name) == 0 ||
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
895 strcmp(name, fds->source_fd->name) == 0)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
896 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
897 fds->confirmed = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
898 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
899 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
900 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
901 gchar *base;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
902
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
903 base = remove_level_from_path(fds->dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
904 g_free(fds->dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
905 fds->dest = concat_dir_and_file(base, name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
906 fds->confirmed = !isname(fds->dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
907
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
908 g_free(base);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
909 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
910 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
911
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
912 file_util_move_single(fds);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
913 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
914
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
915 static void file_util_move_single_cancel_cb(GenericDialog *gd, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
916 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
917 FileDataSingle *fds = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
918
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
919 file_data_single_free(fds);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
920 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
921
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
922 static void file_util_move_single_rename_auto_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
923 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
924 GenericDialog *gd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
925 FileDataSingle *fds;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
926
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
927 fds = gd->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
928
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
929 fds->rename_auto = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
930 gtk_widget_set_sensitive(fds->rename_box, !fds->rename_auto);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
931 gtk_widget_set_sensitive(fds->rename_entry, (!fds->rename_auto && fds->rename));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
932
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
933 if (fds->rename_auto)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
934 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
935 gchar *preview;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
936
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
937 preview = unique_filename_simple(fds->dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
938 if (preview) gtk_entry_set_text(GTK_ENTRY(fds->rename_entry), filename_from_path(preview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
939 g_free(preview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
940 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
941 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
942
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
943 static void file_util_move_single_rename_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
944 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
945 GenericDialog *gd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
946 FileDataSingle *fds;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
947
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
948 fds = gd->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
949
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
950 fds->rename = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
951 gtk_widget_set_sensitive(fds->rename_entry, fds->rename);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
952
42
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
953 if (fds->rename)
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
954 {
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
955 const gchar *name;
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
956
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
957 gtk_widget_grab_focus(fds->rename_entry);
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
958
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
959 name = gtk_entry_get_text(GTK_ENTRY(fds->rename_entry));
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
960 gtk_editable_select_region(GTK_EDITABLE(fds->rename_entry), 0, filename_base_length(name));
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
961 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
962 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
963
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
964 static void file_util_move_single(FileDataSingle *fds)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
965 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
966 if (fds->dest && fds->source_fd && strcmp(fds->dest, fds->source_fd->name) == 0)
3
gqview
parents: 1
diff changeset
967 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
968 file_util_warning_dialog(_("Source matches destination"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
969 _("Source and destination are the same, operation cancelled."),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
970 GTK_STOCK_DIALOG_INFO, NULL);
3
gqview
parents: 1
diff changeset
971 }
gqview
parents: 1
diff changeset
972 else if (isfile(fds->dest) && !fds->confirmed)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
973 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
974 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
975 GtkWidget *hbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
976
254
9faf34f047b1 Make the wmclass value unique among the code by defining
zas_
parents: 223
diff changeset
977 gd = file_util_gen_dlg(_("Overwrite file"), GQ_WMCLASS, "dlg_confirm",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
978 NULL, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
979 file_util_move_single_cancel_cb, fds);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
980
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
981 generic_dialog_add_message(gd, GTK_STOCK_DIALOG_QUESTION,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
982 _("Overwrite file?"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
983 _("Replace existing file with new file."));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
984 pref_spacer(gd->vbox, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
985
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
986 generic_dialog_add_button(gd, GTK_STOCK_OK, _("_Overwrite"), file_util_move_single_ok_cb, TRUE);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
987 generic_dialog_add_image(gd, NULL, file_data_new_simple(fds->dest), _("Existing file"), fds->source_fd, _("New file"), TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
988
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
989 /* rename option */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
990
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
991 fds->rename = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
992 fds->rename_auto = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
993
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
994 hbox = pref_box_new(gd->vbox, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
995
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
996 fds->rename_auto_box = gtk_check_button_new_with_label(_("Auto rename"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
997 g_signal_connect(G_OBJECT(fds->rename_auto_box), "clicked",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
998 G_CALLBACK(file_util_move_single_rename_auto_cb), gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
999 gtk_box_pack_start(GTK_BOX(hbox), fds->rename_auto_box, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1000 gtk_widget_show(fds->rename_auto_box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1001
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1002 hbox = pref_box_new(gd->vbox, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1003
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1004 fds->rename_box = gtk_check_button_new_with_label(_("Rename"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1005 g_signal_connect(G_OBJECT(fds->rename_box), "clicked",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1006 G_CALLBACK(file_util_move_single_rename_cb), gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1007 gtk_box_pack_start(GTK_BOX(hbox), fds->rename_box, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1008 gtk_widget_show(fds->rename_box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1009
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1010 fds->rename_entry = gtk_entry_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1011 gtk_entry_set_text(GTK_ENTRY(fds->rename_entry), filename_from_path(fds->dest));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1012 gtk_widget_set_sensitive(fds->rename_entry, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1013 gtk_box_pack_start(GTK_BOX(hbox), fds->rename_entry, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1014 gtk_widget_show(fds->rename_entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1015
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1016 gtk_widget_show(gd->dialog);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1017 return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1018 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1019 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1020 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1021 gint success = FALSE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1022 if (fds->copy)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1023 {
143
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1024 if (file_data_add_change_info(fds->source_fd, FILEDATA_CHANGE_COPY, fds->source_fd->path, fds->dest) &&
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1025 copy_file_ext(fds->source_fd))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1026 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1027 success = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1028 }
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1029 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1030 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1031 {
143
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1032 if (file_data_add_change_info(fds->source_fd, FILEDATA_CHANGE_MOVE, fds->source_fd->path, fds->dest) &&
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1033 move_file_ext(fds->source_fd))
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1034 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1035 success = TRUE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1036 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1037 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1038 if (!success)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1039 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1040 gchar *title;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1041 gchar *text;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1042 if (fds->copy)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1043 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1044 title = _("Error copying file");
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1045 text = g_strdup_printf(_("Unable to copy file:\n%s\nto:\n%s"), fds->source_fd->name, fds->dest);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1046 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1047 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1048 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1049 title = _("Error moving file");
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1050 text = g_strdup_printf(_("Unable to move file:\n%s\nto:\n%s"), fds->source_fd->name, fds->dest);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1051 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1052 file_util_warning_dialog(title, text, GTK_STOCK_DIALOG_ERROR, NULL);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1053 g_free(text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1054 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1055 }
3
gqview
parents: 1
diff changeset
1056
gqview
parents: 1
diff changeset
1057 file_data_single_free(fds);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1058 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1059
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1060 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1061 * file move dialog
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1062 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1063
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1064 static void file_util_move_do(FileDialog *fdlg)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1065 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1066 file_dialog_sync_history(fdlg, TRUE);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1067
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1068 if (fdlg->multiple_files)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1069 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1070 file_util_move_multiple(file_data_multiple_new(fdlg->source_list, fdlg->dest_path, fdlg->type));
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1071 fdlg->source_list = NULL;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1072 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1073 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1074 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1075 if (isdir(fdlg->dest_path))
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1076 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1077 gchar *buf = concat_dir_and_file(fdlg->dest_path, fdlg->source_fd->name);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1078 gtk_entry_set_text(GTK_ENTRY(fdlg->entry), buf);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1079 g_free(buf);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1080 }
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1081 file_util_move_single(file_data_single_new(fdlg->source_fd, fdlg->dest_path, fdlg->type));
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1082 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1083
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1084 file_dialog_close(fdlg);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1085 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1086
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1087 static void file_util_move_check(FileDialog *fdlg)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1088 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1089 if (fdlg->dest_path && strcmp(fdlg->dest_path, "~") == 0)
42
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
1090 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1091 gtk_entry_set_text(GTK_ENTRY(fdlg->entry), homedir());
42
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
1092 }
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
1093
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1094 if (fdlg->multiple_files && !isdir(fdlg->dest_path))
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1095 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1096 if (isfile(fdlg->dest_path))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1097 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1098 file_util_warning_dialog(_("Invalid destination"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1099 _("When operating with multiple files, please select\na folder, not a file."),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1100 GTK_STOCK_DIALOG_INFO, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1101 }
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1102 else
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1103 file_util_warning_dialog(_("Invalid folder"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1104 _("Please select an existing folder."),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1105 GTK_STOCK_DIALOG_INFO, NULL);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1106 return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1107 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1108
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1109 if (!fdlg->dest_path || fdlg->dest_path[0] != '/')
42
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
1110 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1111 if (fdlg->source_fd)
42
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
1112 {
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
1113 gchar *base;
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
1114 gchar *path;
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
1115
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1116 base = remove_level_from_path(fdlg->source_fd->path);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1117 path = concat_dir_and_file(base, fdlg->dest_path);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1118
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1119 gtk_entry_set_text(GTK_ENTRY(fdlg->entry), path);
42
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
1120
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
1121 g_free(path);
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
1122 g_free(base);
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
1123 }
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
1124 return;
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
1125 }
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
1126
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1127 file_util_move_do(fdlg);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1128 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1129
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1130 static void file_util_move_cb(FileDialog *fdlg, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1131 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1132 file_util_move_check(fdlg);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1133 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1134
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1135 static void file_util_move_cancel_cb(FileDialog *fdlg, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1136 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1137 file_dialog_close(fdlg);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1138 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1139
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1140 static void real_file_util_move(FileData *source_fd, GList *source_list,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1141 const gchar *dest_path, gint copy, GtkWidget *parent)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1142 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1143 FileDialog *fdlg;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1144 GtkWidget *label;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1145 FileData *fd = NULL;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1146 gint multiple;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1147 const gchar *text;
288
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 283
diff changeset
1148 gchar *title;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1149 const gchar *op_text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1150 const gchar *stock_id;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1151
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1152 if (!source_fd && !source_list) return;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1153
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1154 if (source_fd)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1155 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1156 fd = file_data_ref(source_fd);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1157 multiple = FALSE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1158 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1159 else if (source_list->next)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1160 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1161 multiple = TRUE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1162 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1163 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1164 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1165 fd = file_data_ref(source_list->data);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1166 filelist_free(source_list);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1167 source_list = NULL;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1168 multiple = FALSE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1169 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1170
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1171 if (copy)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1172 {
288
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 283
diff changeset
1173 title = g_strdup_printf("%s -%s", _("Copy"), GQ_APPNAME);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1174 op_text = _("_Copy");
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1175 if (fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1176 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1177 text = _("Copy file");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1178 }
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1179 else
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1180 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1181 text = _("Copy multiple files");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1182 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1183 stock_id = GTK_STOCK_COPY;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1184 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1185 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1186 {
288
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 283
diff changeset
1187 title = g_strdup_printf("%s -%s", _("Move"), GQ_APPNAME);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1188 op_text = _("_Move");
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1189 if (fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1190 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1191 text = _("Move file");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1192 }
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1193 else
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1194 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1195 text = _("Move multiple files");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1196 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1197 stock_id = GTK_STOCK_OK;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1198 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1199
254
9faf34f047b1 Make the wmclass value unique among the code by defining
zas_
parents: 223
diff changeset
1200 fdlg = file_util_file_dlg(title, GQ_WMCLASS, "dlg_copymove", parent,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1201 file_util_move_cancel_cb, NULL);
288
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 283
diff changeset
1202 g_free(title);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1203 generic_dialog_add_message(GENERIC_DIALOG(fdlg), NULL, text, NULL);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1204
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1205 if (fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1206 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1207 GtkWidget *box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1208
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1209 box = pref_box_new(GENERIC_DIALOG(fdlg)->vbox, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1210 pref_label_new(box, _("File name:"));
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1211 pref_label_new(box, fd->name);
9
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
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1214 label = pref_label_new(GENERIC_DIALOG(fdlg)->vbox, _("Choose the destination folder."));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1215 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1216 pref_spacer(GENERIC_DIALOG(fdlg)->vbox, 0);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1217
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1218 file_dialog_add_button(fdlg, stock_id, op_text, file_util_move_cb, TRUE);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1219
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1220 file_dialog_add_path_widgets(fdlg, NULL, dest_path, "move_copy", NULL, NULL);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1221
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1222 fdlg->type = copy;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1223 fdlg->source_fd = fd;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1224 fdlg->source_list = source_list;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1225 fdlg->multiple_files = multiple;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1226
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1227 gtk_widget_show(GENERIC_DIALOG(fdlg)->dialog);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1228 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1229
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1230 void file_util_move(FileData *source_fd, GList *source_list, const gchar *dest_path, GtkWidget *parent)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1231 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1232 real_file_util_move(source_fd, source_list, dest_path, FALSE, parent);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1233 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1234
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1235 void file_util_copy(FileData *source_fd, GList *source_list, const gchar *dest_path, GtkWidget *parent)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1236 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1237 real_file_util_move(source_fd, source_list, dest_path, TRUE, parent);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1238 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1239
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1240 void file_util_move_simple(GList *list, const gchar *dest_path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1241 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1242 if (!list) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1243 if (!dest_path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1244 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1245 filelist_free(list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1246 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1247 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1248
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1249 if (!list->next)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1250 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1251 FileData *source_fd;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1252 gchar *dest;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1253
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1254 source_fd = list->data;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1255 dest = concat_dir_and_file(dest_path, source_fd->name);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1256
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1257 file_util_move_single(file_data_single_new(source_fd, dest, FALSE));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1258 g_free(dest);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1259 filelist_free(list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1260 return;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1263 file_util_move_multiple(file_data_multiple_new(list, dest_path, FALSE));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1264 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1265
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1266 void file_util_copy_simple(GList *list, const gchar *dest_path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1267 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1268 if (!list) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1269 if (!dest_path)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1270 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1271 filelist_free(list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1272 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1273 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1274
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1275 if (!list->next)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1276 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1277 FileData *source_fd;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1278 gchar *dest;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1279
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1280 source_fd = list->data;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1281 dest = concat_dir_and_file(dest_path, source_fd->name);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1282
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1283 file_util_move_single(file_data_single_new(source_fd, dest, TRUE));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1284 g_free(dest);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1285 filelist_free(list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1286 return;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1287 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1288
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1289 file_util_move_multiple(file_data_multiple_new(list, dest_path, TRUE));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1290 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1291
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1292 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1293 *--------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1294 * Safe Delete
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1295 *--------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1296 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1297
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1298 static gint file_util_safe_number(gint64 free_space)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1299 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1300 gint n = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1301 gint64 total = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1302 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1303 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1304 gint sorted = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1305 gint warned = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1306
341
15c6b94545a2 Move safe_delete* and in place rename options to file_ops
zas_
parents: 318
diff changeset
1307 if (!filelist_read(options->file_ops.safe_delete_path, &list, NULL)) return 0;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1308
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1309 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1310 while (work)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1311 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1312 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1313 gint v;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1314
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1315 fd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1316 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1317
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1318 v = (gint)strtol(fd->name, NULL, 10);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1319 if (v >= n) n = v + 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1320
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1321 total += fd->size;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1322 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1323
341
15c6b94545a2 Move safe_delete* and in place rename options to file_ops
zas_
parents: 318
diff changeset
1324 while (options->file_ops.safe_delete_folder_maxsize > 0 && list &&
15c6b94545a2 Move safe_delete* and in place rename options to file_ops
zas_
parents: 318
diff changeset
1325 (free_space < 0 || total + free_space > (gint64)options->file_ops.safe_delete_folder_maxsize * 1048576) )
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1326 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1327 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1328
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1329 if (!sorted)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1330 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1331 list = filelist_sort(list, SORT_NAME, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1332 sorted = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1333 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1334
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1335 fd = list->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1336 list = g_list_remove(list, fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1337
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1338 if (debug) printf("expunging from trash for space: %s\n", fd->name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1339 if (!unlink_file(fd->path) && !warned)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1340 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1341 file_util_warning_dialog(_("Delete failed"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1342 _("Unable to remove old file from trash folder"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1343 GTK_STOCK_DIALOG_WARNING, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1344 warned = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1345 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1346 total -= fd->size;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1347 file_data_unref(fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1348 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1349
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1350 filelist_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1351
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1352 return n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1353 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1354
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1355 void file_util_trash_clear(void)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1356 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1357 file_util_safe_number(-1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1358 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1359
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1360 static gchar *file_util_safe_dest(const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1361 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1362 gint n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1363
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1364 n = file_util_safe_number(filesize(path));
341
15c6b94545a2 Move safe_delete* and in place rename options to file_ops
zas_
parents: 318
diff changeset
1365 return g_strdup_printf("%s/%06d_%s", options->file_ops.safe_delete_path, n, filename_from_path(path));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1366 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1367
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1368 static void file_util_safe_del_toggle_cb(GtkWidget *button, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1369 {
341
15c6b94545a2 Move safe_delete* and in place rename options to file_ops
zas_
parents: 318
diff changeset
1370 options->file_ops.safe_delete_enable = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1371 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1372
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1373 static void file_util_safe_del_close_cb(GtkWidget *dialog, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1374 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1375 GenericDialog **gd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1376
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1377 *gd = NULL;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1378 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1379
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1380 static gint file_util_unlink(FileData *fd)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1381 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1382 static GenericDialog *gd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1383 gchar *result = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1384 gint success = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1385
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1386 if (!isfile(fd->path)) return FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1387
134
9009856628f7 started implementation of external commands; external Delete should work
nadvornik
parents: 115
diff changeset
1388
341
15c6b94545a2 Move safe_delete* and in place rename options to file_ops
zas_
parents: 318
diff changeset
1389 if (!options->file_ops.safe_delete_enable)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1390 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1391 return unlink_file(fd->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1392 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1393
341
15c6b94545a2 Move safe_delete* and in place rename options to file_ops
zas_
parents: 318
diff changeset
1394 if (!isdir(options->file_ops.safe_delete_path))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1395 {
341
15c6b94545a2 Move safe_delete* and in place rename options to file_ops
zas_
parents: 318
diff changeset
1396 if (debug) printf("creating trash: %s\n", options->file_ops.safe_delete_path);
15c6b94545a2 Move safe_delete* and in place rename options to file_ops
zas_
parents: 318
diff changeset
1397 if (!options->file_ops.safe_delete_path || !mkdir_utf8(options->file_ops.safe_delete_path, 0755))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1398 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1399 result = _("Could not create folder");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1400 success = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1401 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1402 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1403
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1404 if (success)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1405 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1406 gchar *dest;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1407
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1408 dest = file_util_safe_dest(fd->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1409 if (dest)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1410 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1411 if (debug) printf("safe deleting %s to %s\n", fd->path, dest);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1412 success = move_file(fd->path, dest);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1413 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1414 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1415 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1416 success = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1417 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1418
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1419 if (!success && !access_file(fd->path, W_OK))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1420 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1421 result = _("Permission denied");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1422 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1423 g_free(dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1424 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1425
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1426 if (result && !gd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1427 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1428 GtkWidget *button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1429 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1430
341
15c6b94545a2 Move safe_delete* and in place rename options to file_ops
zas_
parents: 318
diff changeset
1431 buf = g_strdup_printf(_("Unable to access or create the trash folder.\n\"%s\""), options->file_ops.safe_delete_path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1432 gd = file_util_warning_dialog(result, buf, GTK_STOCK_DIALOG_WARNING, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1433 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1434
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1435 button = gtk_check_button_new_with_label(_("Turn off safe delete"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1436 g_signal_connect(G_OBJECT(button), "toggled",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1437 G_CALLBACK(file_util_safe_del_toggle_cb), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1438 gtk_box_pack_start(GTK_BOX(gd->vbox), button, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1439 gtk_widget_show(button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1440
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1441 g_signal_connect(G_OBJECT(gd->dialog), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1442 G_CALLBACK(file_util_safe_del_close_cb), &gd);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1445 return success;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1446 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1447
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1448 static void box_append_safe_delete_status(GenericDialog *gd)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1449 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1450 GtkWidget *label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1451 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1452
318
b16b9b8979e5 Add a new struct ConfOptions to handle options.
zas_
parents: 288
diff changeset
1453 if (options->editor_command[CMD_DELETE])
223
73efc1ba150f Setting no limit size to trash directory is now possible using zero as value.
zas_
parents: 196
diff changeset
1454 {
73efc1ba150f Setting no limit size to trash directory is now possible using zero as value.
zas_
parents: 196
diff changeset
1455 buf = g_strdup(_("Deletion by external command"));
73efc1ba150f Setting no limit size to trash directory is now possible using zero as value.
zas_
parents: 196
diff changeset
1456 }
73efc1ba150f Setting no limit size to trash directory is now possible using zero as value.
zas_
parents: 196
diff changeset
1457 else
73efc1ba150f Setting no limit size to trash directory is now possible using zero as value.
zas_
parents: 196
diff changeset
1458 {
341
15c6b94545a2 Move safe_delete* and in place rename options to file_ops
zas_
parents: 318
diff changeset
1459 if (options->file_ops.safe_delete_enable)
223
73efc1ba150f Setting no limit size to trash directory is now possible using zero as value.
zas_
parents: 196
diff changeset
1460 {
73efc1ba150f Setting no limit size to trash directory is now possible using zero as value.
zas_
parents: 196
diff changeset
1461 gchar *buf2;
341
15c6b94545a2 Move safe_delete* and in place rename options to file_ops
zas_
parents: 318
diff changeset
1462 if (options->file_ops.safe_delete_folder_maxsize > 0)
15c6b94545a2 Move safe_delete* and in place rename options to file_ops
zas_
parents: 318
diff changeset
1463 buf2 = g_strdup_printf(_(" (max. %d MB)"), options->file_ops.safe_delete_folder_maxsize);
223
73efc1ba150f Setting no limit size to trash directory is now possible using zero as value.
zas_
parents: 196
diff changeset
1464 else
73efc1ba150f Setting no limit size to trash directory is now possible using zero as value.
zas_
parents: 196
diff changeset
1465 buf2 = g_strdup("");
73efc1ba150f Setting no limit size to trash directory is now possible using zero as value.
zas_
parents: 196
diff changeset
1466
341
15c6b94545a2 Move safe_delete* and in place rename options to file_ops
zas_
parents: 318
diff changeset
1467 buf = g_strdup_printf(_("Safe delete: %s%s\nTrash: %s"), _("on"), buf2, options->file_ops.safe_delete_path);
223
73efc1ba150f Setting no limit size to trash directory is now possible using zero as value.
zas_
parents: 196
diff changeset
1468 g_free(buf2);
73efc1ba150f Setting no limit size to trash directory is now possible using zero as value.
zas_
parents: 196
diff changeset
1469 }
73efc1ba150f Setting no limit size to trash directory is now possible using zero as value.
zas_
parents: 196
diff changeset
1470 else
73efc1ba150f Setting no limit size to trash directory is now possible using zero as value.
zas_
parents: 196
diff changeset
1471 {
73efc1ba150f Setting no limit size to trash directory is now possible using zero as value.
zas_
parents: 196
diff changeset
1472 buf = g_strdup_printf(_("Safe delete: %s"), _("off"));
73efc1ba150f Setting no limit size to trash directory is now possible using zero as value.
zas_
parents: 196
diff changeset
1473 }
73efc1ba150f Setting no limit size to trash directory is now possible using zero as value.
zas_
parents: 196
diff changeset
1474 }
73efc1ba150f Setting no limit size to trash directory is now possible using zero as value.
zas_
parents: 196
diff changeset
1475
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1476 label = pref_label_new(gd->vbox, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1477 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1478
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1479 gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1480 gtk_widget_set_sensitive(label, FALSE);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1481 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1482
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1483 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1484 *--------------------------------------------------------------------------
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1485 * Delete routines
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1486 *--------------------------------------------------------------------------
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1487 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1488
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1489 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1490 * delete multiple files
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1491 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1492
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1493 static void file_util_delete_multiple_ok_cb(GenericDialog *gd, gpointer data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1494 static void file_util_delete_multiple_cancel_cb(GenericDialog *gd, gpointer data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1495
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1496 static void file_util_delete_ext_ok_cb(GenericDialog *gd, gpointer data)
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1497 {
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1498 editor_resume(data);
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1499 }
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1500
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1501 static void file_util_delete_ext_cancel_cb(GenericDialog *gd, gpointer data)
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1502 {
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1503 editor_skip(data);
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1504 }
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1505
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1506
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1507 static gint file_util_delete_ext_cb(gpointer resume_data, gint flags, GList *list, gpointer data)
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1508 {
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1509 gint ret = EDITOR_CB_CONTINUE;
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1510 if ((flags & EDITOR_ERROR_MASK) && !(flags & EDITOR_ERROR_SKIPPED))
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1511 {
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1512 GString *msg = g_string_new(editor_get_error_str(flags));
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1513 g_string_append(msg,_("\nUnable to delete file by external command:\n"));
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1514 GenericDialog *d;
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1515 while (list)
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1516 {
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1517 FileData *fd = list->data;
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1518
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1519 g_string_append(msg, fd->path);
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1520 g_string_append(msg, "\n");
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1521 list = list->next;
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1522 }
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1523 if (resume_data)
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1524 {
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1525 g_string_append(msg, _("\n Continue multiple delete operation?"));
254
9faf34f047b1 Make the wmclass value unique among the code by defining
zas_
parents: 223
diff changeset
1526 d = file_util_gen_dlg(_("Delete failed"), GQ_WMCLASS, "dlg_confirm",
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1527 NULL, TRUE,
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1528 file_util_delete_ext_cancel_cb, resume_data);
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1529
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1530 generic_dialog_add_message(d, GTK_STOCK_DIALOG_WARNING, NULL, msg->str);
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1531
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1532 generic_dialog_add_button(d, GTK_STOCK_GO_FORWARD, _("Co_ntinue"),
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1533 file_util_delete_ext_ok_cb, TRUE);
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1534 gtk_widget_show(d->dialog);
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1535 ret = EDITOR_CB_SUSPEND;
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1536 }
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1537 else
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1538 {
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1539 file_util_warning_dialog(_("Delete failed"), msg->str, GTK_STOCK_DIALOG_ERROR, NULL);
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1540 }
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1541 g_string_free(msg, TRUE);
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1542 }
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1543
143
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1544
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1545 {
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1546 while (list)
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1547 {
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1548 FileData *fd = list->data;
143
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1549 if (flags & EDITOR_ERROR_MASK)
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1550 /* an error occured -> no change -> delete change info */
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1551 file_data_change_info_free(NULL, fd);
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1552 else
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1553 /* files were successfully deleted, call the maint functions and keep the change info forever */
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1554 file_maint_removed(fd, list);
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1555 list = list->next;
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1556 }
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1557 }
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1558 return ret;
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1559 }
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1560
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1561 static void file_util_delete_multiple_ok_cb(GenericDialog *gd, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1562 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1563 GList *source_list = data;
143
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1564 GList *work = source_list;
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1565 gboolean ok = TRUE;
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1566
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1567 while (work)
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1568 {
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1569 FileData *fd = work->data;
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1570 if (fd->change) ok = FALSE; /* another operation in progress */
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1571 work = work->next;
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1572 }
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1573
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1574 if (!ok)
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1575 {
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1576 file_util_warning_dialog(_("File deletion failed"), _("Another operation in progress.\n"), GTK_STOCK_DIALOG_ERROR, NULL);
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1577 filelist_free(source_list);
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1578 return;
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1579 }
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1580
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1581
318
b16b9b8979e5 Add a new struct ConfOptions to handle options.
zas_
parents: 288
diff changeset
1582 if (options->editor_command[CMD_DELETE])
135
15c1925b3bfb improved external delete command
nadvornik
parents: 134
diff changeset
1583 {
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1584 gint flags;
143
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1585 work = source_list;
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1586 while (work)
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1587 {
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1588 FileData *fd = work->data;
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1589 file_data_add_change_info(fd, FILEDATA_CHANGE_DELETE, NULL, NULL);
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1590 work = work->next;
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1591 }
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1592
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1593 if ((flags = start_editor_from_filelist_full(CMD_DELETE, source_list, file_util_delete_ext_cb, NULL)))
135
15c1925b3bfb improved external delete command
nadvornik
parents: 134
diff changeset
1594 {
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1595 gchar *text = g_strdup_printf(_("%s\nUnable to delete files by external command.\n"), editor_get_error_str(flags));
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1596 file_util_warning_dialog(_("File deletion failed"), text, GTK_STOCK_DIALOG_ERROR, NULL);
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1597 g_free(text);
135
15c1925b3bfb improved external delete command
nadvornik
parents: 134
diff changeset
1598 }
143
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1599
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1600 filelist_free(source_list);
135
15c1925b3bfb improved external delete command
nadvornik
parents: 134
diff changeset
1601 return;
15c1925b3bfb improved external delete command
nadvornik
parents: 134
diff changeset
1602 }
15c1925b3bfb improved external delete command
nadvornik
parents: 134
diff changeset
1603
15c1925b3bfb improved external delete command
nadvornik
parents: 134
diff changeset
1604
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1605 while (source_list)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1606 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1607 FileData *fd = source_list->data;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1608
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1609 source_list = g_list_remove(source_list, fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1610
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1611 if (!file_util_unlink(fd))
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1612 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1613 if (source_list)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1614 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1615 GenericDialog *d;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1616 gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1617
254
9faf34f047b1 Make the wmclass value unique among the code by defining
zas_
parents: 223
diff changeset
1618 d = file_util_gen_dlg(_("Delete failed"), GQ_WMCLASS, "dlg_confirm",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1619 NULL, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1620 file_util_delete_multiple_cancel_cb, source_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1621
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1622 text = g_strdup_printf(_("Unable to delete file:\n %s\n Continue multiple delete operation?"), fd->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1623 generic_dialog_add_message(d, GTK_STOCK_DIALOG_WARNING, NULL, text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1624 g_free(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1625
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1626 generic_dialog_add_button(d, GTK_STOCK_GO_FORWARD, _("Co_ntinue"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1627 file_util_delete_multiple_ok_cb, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1628 gtk_widget_show(d->dialog);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1629 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1630 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1631 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1632 gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1633
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1634 text = g_strdup_printf(_("Unable to delete file:\n%s"), fd->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1635 file_util_warning_dialog(_("Delete failed"), text, GTK_STOCK_DIALOG_ERROR, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1636 g_free(text);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1637 }
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1638 file_data_unref(fd);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1639 return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1640 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1641 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1642 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1643 file_maint_removed(fd, source_list);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1644 }
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1645 file_data_unref(fd);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1646 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1647 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1648
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1649 static void file_util_delete_multiple_cancel_cb(GenericDialog *gd, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1650 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1651 GList *source_list = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1652
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1653 filelist_free(source_list);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1654 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1655
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1656 static void file_util_delete_multiple_review_skip(GenericDialog *gd, gint next)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1657 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1658 GtkWidget *button_back;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1659 GtkWidget *button_next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1660 GtkWidget *button_label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1661 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1662 GList *list_point;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1663 FileData *fd;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1664 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1665
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1666 list = gd->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1667 button_back = g_object_get_data(G_OBJECT(gd->dialog), "button_back");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1668 button_next = g_object_get_data(G_OBJECT(gd->dialog), "button_next");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1669 button_label = g_object_get_data(G_OBJECT(gd->dialog), "button_label");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1670 list_point = g_object_get_data(G_OBJECT(gd->dialog), "list_point");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1671
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1672 if (!list || !button_label) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1673
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1674 if (list_point)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1675 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1676 if (next)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1677 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1678 if (list_point->next) list_point = list_point->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1679 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1680 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1681 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1682 if (list_point->prev) list_point = list_point->prev;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1683 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1684 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1685 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1686 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1687 list_point = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1688 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1689
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1690 if (!list_point) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1691
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1692 fd = list_point->data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1693 buf = g_strdup_printf(_("File %d of %d"),
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1694 g_list_index(list, (gpointer)fd) + 1,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1695 g_list_length(list));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1696 gtk_label_set_text(GTK_LABEL(button_label), buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1697 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1698
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1699 gtk_widget_set_sensitive(button_back, (list_point->prev != NULL) );
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1700 gtk_widget_set_sensitive(button_next, (list_point->next != NULL) );
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1701
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1702 generic_dialog_image_set(gd, fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1703
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1704 g_object_set_data(G_OBJECT(gd->dialog), "list_point", list_point);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1705 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1706
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1707 static void file_util_delete_multiple_review_back(GtkWidget *button, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1708 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1709 GenericDialog *gd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1710
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1711 file_util_delete_multiple_review_skip(gd, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1712 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1713
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1714 static void file_util_delete_multiple_review_next(GtkWidget *button, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1715 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1716 GenericDialog *gd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1717
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1718 file_util_delete_multiple_review_skip(gd, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1719 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1720
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1721 static void file_util_delete_multiple_review_button_cb(ImageWindow *imd, gint button, guint32 time,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1722 gdouble x, gdouble y, guint state, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1723 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1724 if (button == 1)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1725 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1726 file_util_delete_multiple_review_next(NULL, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1727 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1728 else if (button == 2 || button == 3)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1729 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1730 file_util_delete_multiple_review_back(NULL, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1731 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1732 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1733
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1734 static void file_util_delete_multiple_review_scroll_cb(ImageWindow *imd, GdkScrollDirection direction, guint32 time,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1735 gdouble x, gdouble y, guint state, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1736 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1737 if (direction == GDK_SCROLL_UP)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1738 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1739 file_util_delete_multiple_review_back(NULL, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1740 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1741 else if (direction == GDK_SCROLL_DOWN)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1742 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1743 file_util_delete_multiple_review_next(NULL, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1744 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1745 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1746
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1747 static void file_util_delete_multiple(GList *source_list, GtkWidget *parent)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1748 {
341
15c6b94545a2 Move safe_delete* and in place rename options to file_ops
zas_
parents: 318
diff changeset
1749 if (!options->file_ops.confirm_delete)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1750 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1751 file_util_delete_multiple_ok_cb(NULL, source_list);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1752 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1753 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1754 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1755 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1756 GtkWidget *hbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1757 GtkWidget *button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1758 GtkWidget *label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1759 ImageWindow *imd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1760 gchar *buf;
288
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 283
diff changeset
1761 gchar *title = g_strdup_printf("%s -%s", _("Delete files"), GQ_APPNAME);
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 283
diff changeset
1762
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 283
diff changeset
1763 gd = file_util_gen_dlg(title, GQ_WMCLASS, "dlg_confirm", parent, TRUE,
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 283
diff changeset
1764 file_util_delete_multiple_cancel_cb, source_list);
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 283
diff changeset
1765 g_free(title);
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 283
diff changeset
1766
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1767 generic_dialog_add_message(gd, NULL, _("Delete multiple files"), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1768
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1769 generic_dialog_add_image(gd, NULL, NULL, NULL, NULL, NULL, TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1770 imd = g_object_get_data(G_OBJECT(gd->dialog), "img_image");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1771 image_set_button_func(imd, file_util_delete_multiple_review_button_cb, gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1772 image_set_scroll_func(imd, file_util_delete_multiple_review_scroll_cb, gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1773
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1774 hbox = pref_box_new(gd->vbox, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_BUTTON_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1775
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1776 button = pref_button_new(hbox, GTK_STOCK_GO_BACK, NULL, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1777 G_CALLBACK(file_util_delete_multiple_review_back), gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1778 gtk_widget_set_sensitive(button, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1779 g_object_set_data(G_OBJECT(gd->dialog), "button_back", button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1780
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1781 button = pref_button_new(hbox, GTK_STOCK_GO_FORWARD, NULL, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1782 G_CALLBACK(file_util_delete_multiple_review_next), gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1783 g_object_set_data(G_OBJECT(gd->dialog), "button_next", button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1784
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1785 buf = g_strdup_printf(_("Review %d files"), g_list_length(source_list) );
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1786 label = pref_label_new(hbox, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1787 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1788 g_object_set_data(G_OBJECT(gd->dialog), "button_label", label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1789
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1790 box_append_safe_delete_status(gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1791
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1792 generic_dialog_add_button(gd, GTK_STOCK_DELETE, NULL, file_util_delete_multiple_ok_cb, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1793
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1794 gtk_widget_show(gd->dialog);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1795 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1796 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1797
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1798 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1799 * delete single file
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1800 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1801
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1802 static void file_util_delete_ok_cb(GenericDialog *gd, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1803 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1804 FileData *fd = data;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1805
143
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1806 if (!file_data_add_change_info(fd, FILEDATA_CHANGE_DELETE, NULL, NULL))
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1807 {
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1808 file_util_warning_dialog(_("File deletion failed"), _("Another operation in progress.\n"), GTK_STOCK_DIALOG_ERROR, NULL);
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1809 file_data_unref(fd);
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1810 return;
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1811 }
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1812
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1813
318
b16b9b8979e5 Add a new struct ConfOptions to handle options.
zas_
parents: 288
diff changeset
1814 if (options->editor_command[CMD_DELETE])
135
15c1925b3bfb improved external delete command
nadvornik
parents: 134
diff changeset
1815 {
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1816 gint flags;
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1817 if ((flags = start_editor_from_file_full(CMD_DELETE, fd, file_util_delete_ext_cb, NULL)))
135
15c1925b3bfb improved external delete command
nadvornik
parents: 134
diff changeset
1818 {
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
1819 gchar *text = g_strdup_printf(_("%s\nUnable to delete file by external command:\n%s"), editor_get_error_str(flags), fd->path);
135
15c1925b3bfb improved external delete command
nadvornik
parents: 134
diff changeset
1820 file_util_warning_dialog(_("File deletion failed"), text, GTK_STOCK_DIALOG_ERROR, NULL);
15c1925b3bfb improved external delete command
nadvornik
parents: 134
diff changeset
1821 g_free(text);
143
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1822 file_data_change_info_free(NULL, fd);
135
15c1925b3bfb improved external delete command
nadvornik
parents: 134
diff changeset
1823 }
15c1925b3bfb improved external delete command
nadvornik
parents: 134
diff changeset
1824 }
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1825 else if (!file_util_unlink(fd))
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1826 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1827 gchar *text = g_strdup_printf(_("Unable to delete file:\n%s"), fd->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1828 file_util_warning_dialog(_("File deletion failed"), text, GTK_STOCK_DIALOG_ERROR, NULL);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1829 g_free(text);
143
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
1830 file_data_change_info_free(NULL, fd);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1831 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1832 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1833 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1834 file_maint_removed(fd, NULL);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1835 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1836
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1837 file_data_unref(fd);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1838 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1839
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1840 static void file_util_delete_cancel_cb(GenericDialog *gd, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1841 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1842 FileData *fd = data;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1843
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1844 file_data_unref(fd);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1845 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1846
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1847 static void file_util_delete_single(FileData *fd, GtkWidget *parent)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1848 {
341
15c6b94545a2 Move safe_delete* and in place rename options to file_ops
zas_
parents: 318
diff changeset
1849 if (!options->file_ops.confirm_delete)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1850 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1851 file_util_delete_ok_cb(NULL, file_data_ref(fd));
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1852 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1853 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1854 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1855 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1856 GtkWidget *table;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1857 gchar *base;
288
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 283
diff changeset
1858 gchar *title = g_strdup_printf("%s -%s", _("Delete file"), GQ_APPNAME);
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 283
diff changeset
1859
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 283
diff changeset
1860 gd = file_util_gen_dlg(title, GQ_WMCLASS, "dlg_confirm", parent, TRUE,
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 283
diff changeset
1861 file_util_delete_cancel_cb, file_data_ref(fd));
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 283
diff changeset
1862 g_free(title);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1863
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1864 generic_dialog_add_message(gd, NULL, _("Delete file?"), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1865
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1866 table = pref_table_new(gd->vbox, 2, 2, FALSE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1867
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1868 pref_table_label(table, 0, 0, _("File name:"), 1.0);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1869 pref_table_label(table, 1, 0, fd->name, 0.0);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1870
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1871 pref_table_label(table, 0, 1, _("Location:"), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1872
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1873 base = remove_level_from_path(fd->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1874 pref_table_label(table, 1, 1, base, 0.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1875 g_free(base);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1876
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1877 generic_dialog_add_image(gd, NULL, fd, NULL, NULL, NULL, FALSE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1878
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1879 box_append_safe_delete_status(gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1880
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1881 generic_dialog_add_button(gd, GTK_STOCK_DELETE, NULL, file_util_delete_ok_cb, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1882
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1883 gtk_widget_show(gd->dialog);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1884 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1885 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1886
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1887 void file_util_delete(FileData *source_fd, GList *source_list, GtkWidget *parent)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1888 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1889 if (!source_fd && !source_list) return;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1890
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1891 if (source_fd)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1892 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1893 file_util_delete_single(source_fd, parent);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1894 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1895 else if (!source_list->next)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1896 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1897 file_util_delete_single(source_list->data, parent);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1898 filelist_free(source_list);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1899 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1900 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1901 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1902 file_util_delete_multiple(source_list, parent);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1903 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1904 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1905
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1906 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1907 *--------------------------------------------------------------------------
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1908 * Rename routines
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1909 *--------------------------------------------------------------------------
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1910 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1911
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1912 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1913 * rename multiple files
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1914 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1915
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1916 enum {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1917 RENAME_COLUMN_FD = 0,
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1918 RENAME_COLUMN_PATH,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1919 RENAME_COLUMN_NAME,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1920 RENAME_COLUMN_PREVIEW,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1921 RENAME_COLUMN_COUNT
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1922 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1923
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1924 typedef enum {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1925 RENAME_TYPE_MANUAL = 0,
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1926 RENAME_TYPE_FORMATTED,
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1927 RENAME_TYPE_AUTO
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1928 } RenameType;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1929
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1930 typedef struct _RenameDataMult RenameDataMult;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1931 struct _RenameDataMult
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1932 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1933 FileDialog *fdlg;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1934
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1935 RenameType rename_type;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1936
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1937 GtkWidget *listview;
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1938 GtkWidget *combo_type;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1939
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1940 GtkWidget *rename_box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1941 GtkWidget *rename_label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1942 GtkWidget *rename_entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1943
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1944 GtkWidget *auto_box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1945 GtkWidget *auto_entry_front;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1946 GtkWidget *auto_spin_start;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1947 GtkWidget *auto_spin_pad;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1948 GtkWidget *auto_entry_end;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1949
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1950 GtkWidget *format_box;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1951 GtkWidget *format_entry;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1952 GtkWidget *format_spin;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1953
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1954 ImageWindow *imd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1955
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1956 gint update_idle_id;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1957 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1958
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1959 static void file_util_rename_multiple(RenameDataMult *rd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1960
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1961 static void file_util_rename_multiple_ok_cb(GenericDialog *gd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1962 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1963 RenameDataMult *rd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1964 GtkWidget *dialog;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1965
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1966 dialog = GENERIC_DIALOG(rd->fdlg)->dialog;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1967 if (!GTK_WIDGET_VISIBLE(dialog)) gtk_widget_show(dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1968
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1969 rd->fdlg->type = TRUE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1970 file_util_rename_multiple(rd);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1971 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1972
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1973 static void file_util_rename_multiple_cancel_cb(GenericDialog *gd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1974 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1975 RenameDataMult *rd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1976 GtkWidget *dialog;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1977
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1978 dialog = GENERIC_DIALOG(rd->fdlg)->dialog;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1979 if (!GTK_WIDGET_VISIBLE(dialog)) gtk_widget_show(dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1980 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1981
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1982 static gint file_util_rename_multiple_find_row(RenameDataMult *rd, FileData *fd, GtkTreeIter *iter)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1983 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1984 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1985 gint valid;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1986 gint row = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1987
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1988 store = gtk_tree_view_get_model(GTK_TREE_VIEW(rd->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1989 valid = gtk_tree_model_get_iter_first(store, iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1990 while (valid)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1991 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1992 FileData *fd_n;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1993 gint ret;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1994
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1995 gtk_tree_model_get(GTK_TREE_MODEL(store), iter, RENAME_COLUMN_FD, &fd_n, -1);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1996 ret = (fd_n == fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1997 // file_data_unref(fd_n);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1998 if (ret) return row;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1999
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2000 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2001 row++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2002 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2003
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2004 return -1;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2005 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2006
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2007 static void file_util_rename_multiple(RenameDataMult *rd)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2008 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2009 FileDialog *fdlg;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2010
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2011 fdlg = rd->fdlg;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2012
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2013 if (isfile(fdlg->dest_path) && !fdlg->type)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2014 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2015 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2016
254
9faf34f047b1 Make the wmclass value unique among the code by defining
zas_
parents: 223
diff changeset
2017 gd = file_util_gen_dlg(_("Overwrite file"), GQ_WMCLASS, "dlg_confirm",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2018 NULL, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2019 file_util_rename_multiple_cancel_cb, rd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2020
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2021 generic_dialog_add_message(gd, GTK_STOCK_DIALOG_QUESTION,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2022 _("Overwrite file?"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2023 _("Replace existing file by renaming new file."));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2024 pref_spacer(gd->vbox, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2025
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2026 generic_dialog_add_button(gd, GTK_STOCK_OK, _("_Overwrite"), file_util_rename_multiple_ok_cb, TRUE);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
2027 generic_dialog_add_image(gd, NULL,
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2028 file_data_new_simple(fdlg->dest_path), _("Existing file"),
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2029 fdlg->source_fd, _("New file"), TRUE);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2030
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2031 gtk_widget_hide(GENERIC_DIALOG(fdlg)->dialog);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2032
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2033 gtk_widget_show(gd->dialog);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2034 return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2035 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2036 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2037 {
143
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
2038 if (!file_data_add_change_info(fdlg->source_fd, FILEDATA_CHANGE_RENAME, fdlg->source_fd->path, fdlg->dest_path) ||
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
2039 !rename_file_ext(fdlg->source_fd))
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2040 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2041 gchar *text = g_strdup_printf(_("Unable to rename file:\n%s\n to:\n%s"),
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2042 fdlg->source_fd->name,
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2043 filename_from_path(fdlg->dest_path));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2044 file_util_warning_dialog(_("Error renaming file"), text, GTK_STOCK_DIALOG_ERROR, NULL);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2045 g_free(text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2046 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2047 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2048 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2049 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2050 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2051 GtkTreeIter next;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2052 gint row;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2053
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2054 store = gtk_tree_view_get_model(GTK_TREE_VIEW(rd->listview));
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2055 row = file_util_rename_multiple_find_row(rd, rd->fdlg->source_fd, &iter);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2056
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2057 if (row >= 0 &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2058 (gtk_tree_model_iter_nth_child(store, &next, NULL, row + 1) ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2059 (row > 0 && gtk_tree_model_iter_nth_child(store, &next, NULL, row - 1)) ) )
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2060 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2061 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2062
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2063 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(rd->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2064 gtk_tree_selection_select_iter(selection, &next);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2065 gtk_list_store_remove(GTK_LIST_STORE(store), &iter);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2066 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2067 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2068 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2069 if (debug) printf("closed by #%d\n", row);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2070
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2071 file_dialog_close(rd->fdlg);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2072 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2073 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2074 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2075 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2076
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2077 /* 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
2078 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
2079 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2080 gchar *new_name;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2081 gchar *parsed;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2082 const gchar *ext;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2083 gchar *middle;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2084 gchar *tmp;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2085 gchar *pad_start;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2086 gchar *pad_end;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2087 gint padding;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2088
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2089 if (!format || !name) return NULL;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2090
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2091 tmp = g_strdup(format);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2092 pad_start = strchr(tmp, '#');
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2093 if (pad_start)
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2094 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2095 pad_end = pad_start;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2096 padding = 0;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2097 while (*pad_end == '#')
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2098 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2099 pad_end++;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2100 padding++;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2101 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2102 *pad_start = '\0';
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2103
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2104 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
2105 g_free(tmp);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2106 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2107 else
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2108 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2109 parsed = tmp;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2110 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2111
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2112 ext = extension_from_path(name);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2113
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2114 middle = strchr(parsed, '*');
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2115 if (middle)
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2116 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2117 gchar *base;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2118
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2119 *middle = '\0';
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2120 middle++;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2121
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2122 base = remove_extension_from_path(name);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2123 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
2124 g_free(base);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2125 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2126 else
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2127 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2128 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
2129 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2130
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2131 g_free(parsed);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2132
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2133 return new_name;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2134 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2135
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2136 static void file_util_rename_multiple_auto(RenameDataMult *rd)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2137 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2138 const gchar *front;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2139 const gchar *end;
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2140 const gchar *format;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2141 gint start_n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2142 gint padding;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2143 gint n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2144 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2145 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2146 gint valid;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2147 gint success;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2148
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2149 front = gtk_entry_get_text(GTK_ENTRY(rd->auto_entry_front));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2150 end = gtk_entry_get_text(GTK_ENTRY(rd->auto_entry_end));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2151 padding = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(rd->auto_spin_pad));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2152
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2153 format = gtk_entry_get_text(GTK_ENTRY(rd->format_entry));
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2154
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2155 if (rd->rename_type == RENAME_TYPE_FORMATTED)
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2156 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2157 start_n = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(rd->format_spin));
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2158
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2159 if (!format ||
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2160 (strchr(format, '*') == NULL && strchr(format, '#') == NULL))
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2161 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2162 file_util_warning_dialog(_("Auto rename"),
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2163 _("Format must include at least one of the symbol characters '*' or '#'.\n"),
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2164 GTK_STOCK_DIALOG_WARNING, NULL);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2165 return;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2166 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2167
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2168 history_combo_append_history(rd->format_entry, NULL);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2169 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2170 else
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2171 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2172 start_n = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(rd->auto_spin_start));
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2173
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2174 history_combo_append_history(rd->auto_entry_front, NULL);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2175 history_combo_append_history(rd->auto_entry_end, NULL);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2176 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2177
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2178 store = gtk_tree_view_get_model(GTK_TREE_VIEW(rd->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2179
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2180 /* first check for name conflicts */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2181 success = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2182 n = start_n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2183 valid = gtk_tree_model_get_iter_first(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2184 while (valid && success)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2185 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2186 gchar *dest;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2187 gchar *base;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2188 FileData *fd;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2189
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2190 gtk_tree_model_get(store, &iter, RENAME_COLUMN_FD, &fd, -1);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2191 base = remove_level_from_path(fd->path);
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2192
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2193 if (rd->rename_type == RENAME_TYPE_FORMATTED)
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2194 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2195 gchar *new_name;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2196
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2197 new_name = 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
2198 dest = g_strconcat(base, "/", new_name, NULL);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2199 g_free(new_name);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2200 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2201 else
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2202 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2203 dest = g_strdup_printf("%s/%s%0*d%s", base, front, padding, n, end);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2204 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2205
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2206 if (isname(dest)) success = FALSE;
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2207
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2208 g_free(dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2209 g_free(base);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2210 // file_data_unref(fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2211
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2212 n++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2213 valid = gtk_tree_model_iter_next(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2214 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2215
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2216 if (!success)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2217 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2218 file_util_warning_dialog(_("Auto rename"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2219 _("Can not auto rename with the selected\nnumber set, one or more files exist that\nmatch the resulting name list.\n"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2220 GTK_STOCK_DIALOG_WARNING, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2221 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2222 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2223
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2224 /* select the first iter, so that on fail the correct info is given to user */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2225 if (gtk_tree_model_get_iter_first(store, &iter))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2226 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2227 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2228
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2229 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(rd->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2230 gtk_tree_selection_select_iter(selection, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2231 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2232
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2233 /* now do it for real */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2234 success = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2235 n = start_n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2236 while (success && gtk_tree_model_get_iter_first(store, &iter))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2237 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2238 gchar *dest;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2239 gchar *base;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2240 FileData *fd;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2241
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2242 gtk_tree_model_get(store, &iter, RENAME_COLUMN_FD, &fd, -1);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2243 base = remove_level_from_path(fd->path);
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2244
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2245 if (rd->rename_type == RENAME_TYPE_FORMATTED)
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2246 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2247 gchar *new_name;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2248
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2249 new_name = 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
2250 dest = g_strconcat(base, "/", new_name, NULL);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2251 g_free(new_name);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2252 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2253 else
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2254 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2255 dest = g_strdup_printf("%s/%s%0*d%s", base, front, padding, n, end);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2256 }
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2257
143
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
2258 if (!file_data_add_change_info(fd, FILEDATA_CHANGE_RENAME, fd->path, dest) ||
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
2259 !rename_file_ext(fd))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2260 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2261 success = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2262 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2263
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2264 g_free(dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2265 g_free(base);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2266 // file_data_unref(fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2267
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2268 if (success)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2269 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2270 gtk_list_store_remove(GTK_LIST_STORE(store), &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2271 if (gtk_tree_model_get_iter_first(store, &iter))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2272 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2273 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2274
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2275 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(rd->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2276 gtk_tree_selection_select_iter(selection, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2277 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2278 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2279
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2280 n++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2281 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2282
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2283 if (!success)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2284 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2285 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2286
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2287 n--;
15
3263965d5f9e ##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents: 9
diff changeset
2288 gtk_spin_button_set_value(GTK_SPIN_BUTTON(rd->auto_spin_start), (gdouble)n);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2289
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2290 buf = g_strdup_printf(_("Failed to rename\n%s\nThe number was %d."), rd->fdlg->source_fd->name, n);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2291 file_util_warning_dialog(_("Auto rename"), buf, GTK_STOCK_DIALOG_ERROR, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2292 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2293
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2294 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2295 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2296
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2297 file_dialog_close(rd->fdlg);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2298 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2299
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2300 static void file_util_rename_multiple_cb(FileDialog *fdlg, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2301 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2302 RenameDataMult *rd = data;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2303 gchar *base;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2304 const gchar *name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2305
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2306 if (rd->rename_type != RENAME_TYPE_MANUAL)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2307 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2308 file_util_rename_multiple_auto(rd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2309 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2310 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2311
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2312 name = gtk_entry_get_text(GTK_ENTRY(rd->rename_entry));
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2313 base = remove_level_from_path(fdlg->source_fd->path);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2314
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2315 g_free(fdlg->dest_path);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2316 fdlg->dest_path = concat_dir_and_file(base, name);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2317 g_free(base);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2318
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2319 if (strlen(name) == 0 || strcmp(fdlg->source_fd->path, fdlg->dest_path) == 0)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2320 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2321 return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2322 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2323
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2324 fdlg->type = FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2325 file_util_rename_multiple(rd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2326 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2327
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2328 static void file_util_rename_multiple_close_cb(FileDialog *fdlg, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2329 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2330 RenameDataMult *rd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2331
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2332 file_dialog_close(rd->fdlg);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2333 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2334
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2335 static gboolean file_util_rename_multiple_select_cb(GtkTreeSelection *selection, GtkTreeModel *store, GtkTreePath *tpath,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2336 gboolean path_currently_selected, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2337 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2338 RenameDataMult *rd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2339 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2340 const gchar *name;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2341 FileData *fd = NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2342
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2343 if (path_currently_selected ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2344 !gtk_tree_model_get_iter(store, &iter, tpath)) return TRUE;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2345 gtk_tree_model_get(store, &iter, RENAME_COLUMN_FD, &fd, -1);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2346
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2347 file_data_unref(rd->fdlg->source_fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2348 rd->fdlg->source_fd = file_data_ref(fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2349
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2350 name = rd->fdlg->source_fd->name;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2351 gtk_label_set_text(GTK_LABEL(rd->rename_label), name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2352 gtk_entry_set_text(GTK_ENTRY(rd->rename_entry), name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2353
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2354 image_change_fd(rd->imd, rd->fdlg->source_fd, 0.0);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2355
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2356 if (GTK_WIDGET_VISIBLE(rd->rename_box))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2357 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2358 gtk_widget_grab_focus(rd->rename_entry);
42
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
2359 gtk_editable_select_region(GTK_EDITABLE(rd->rename_entry), 0, filename_base_length(name));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2360 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2361
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2362 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2363 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2364
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2365 static void file_util_rename_multiple_preview_update(RenameDataMult *rd)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2366 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2367 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2368 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2369 const gchar *front;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2370 const gchar *end;
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2371 const gchar *format;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2372 gint valid;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2373 gint start_n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2374 gint padding;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2375 gint n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2376
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2377 front = gtk_entry_get_text(GTK_ENTRY(rd->auto_entry_front));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2378 end = gtk_entry_get_text(GTK_ENTRY(rd->auto_entry_end));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2379 padding = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(rd->auto_spin_pad));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2380
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2381 format = gtk_entry_get_text(GTK_ENTRY(rd->format_entry));
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2382
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2383 if (rd->rename_type == RENAME_TYPE_FORMATTED)
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2384 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2385 start_n = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(rd->format_spin));
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2386 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2387 else
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2388 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2389 start_n = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(rd->auto_spin_start));
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2390 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2391
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2392 store = gtk_tree_view_get_model(GTK_TREE_VIEW(rd->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2393 n = start_n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2394 valid = gtk_tree_model_get_iter_first(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2395 while (valid)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2396 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2397 gchar *dest;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2398
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2399 if (rd->rename_type == RENAME_TYPE_FORMATTED)
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2400 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2401 FileData *fd;
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2402
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2403 gtk_tree_model_get(store, &iter, RENAME_COLUMN_FD, &fd, -1);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2404 dest = file_util_rename_multiple_auto_format_name(format, fd->name, n);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2405 // file_data_unref(fd);
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2406 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2407 else
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2408 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2409 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
2410 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2411 gtk_list_store_set(GTK_LIST_STORE(store), &iter, RENAME_COLUMN_PREVIEW, dest, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2412 g_free(dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2413
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2414 n++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2415 valid = gtk_tree_model_iter_next(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2416 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2417
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2418 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2419
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2420 static gboolean file_util_rename_multiple_idle_cb(gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2421 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2422 RenameDataMult *rd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2423
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2424 file_util_rename_multiple_preview_update(rd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2425
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2426 rd->update_idle_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2427 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2428 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2429
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2430 static void file_util_rename_multiple_preview_order_cb(GtkTreeModel *treemodel, GtkTreePath *tpath,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2431 GtkTreeIter *iter, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2432 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2433 RenameDataMult *rd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2434
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2435 if (rd->rename_type != RENAME_TYPE_MANUAL && rd->update_idle_id == -1)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2436 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2437 rd->update_idle_id = g_idle_add(file_util_rename_multiple_idle_cb, rd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2438 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2439 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2440
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2441 static void file_util_rename_multiple_preview_entry_cb(GtkWidget *entry, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2442 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2443 RenameDataMult *rd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2444 file_util_rename_multiple_preview_update(rd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2445 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2446
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2447 static void file_util_rename_multiple_preview_adj_cb(GtkWidget *spin, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2448 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2449 RenameDataMult *rd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2450 file_util_rename_multiple_preview_update(rd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2451 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2452
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2453 static void file_util_rename_multiple_auto_change(GtkWidget *widget, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2454 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2455 RenameDataMult *rd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2456 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2457
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2458 rd->rename_type = gtk_combo_box_get_active(GTK_COMBO_BOX(rd->combo_type));
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2459
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2460 switch (rd->rename_type)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2461 {
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2462 case RENAME_TYPE_FORMATTED:
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2463 if (GTK_WIDGET_VISIBLE(rd->rename_box)) gtk_widget_hide(rd->rename_box);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2464 if (GTK_WIDGET_VISIBLE(rd->auto_box)) gtk_widget_hide(rd->auto_box);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2465 if (!GTK_WIDGET_VISIBLE(rd->format_box)) gtk_widget_show(rd->format_box);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2466 file_util_rename_multiple_preview_update(rd);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2467 break;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2468 case RENAME_TYPE_AUTO:
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2469 if (GTK_WIDGET_VISIBLE(rd->format_box)) gtk_widget_hide(rd->format_box);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2470 if (GTK_WIDGET_VISIBLE(rd->rename_box)) gtk_widget_hide(rd->rename_box);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2471 if (!GTK_WIDGET_VISIBLE(rd->auto_box)) gtk_widget_show(rd->auto_box);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2472 file_util_rename_multiple_preview_update(rd);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2473 break;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2474 case RENAME_TYPE_MANUAL:
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2475 default:
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2476 if (GTK_WIDGET_VISIBLE(rd->format_box)) gtk_widget_hide(rd->format_box);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2477 if (GTK_WIDGET_VISIBLE(rd->auto_box)) gtk_widget_hide(rd->auto_box);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2478 if (!GTK_WIDGET_VISIBLE(rd->rename_box)) gtk_widget_show(rd->rename_box);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2479 break;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2480 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2481
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2482 column = gtk_tree_view_get_column(GTK_TREE_VIEW(rd->listview), RENAME_COLUMN_PREVIEW - 1);
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2483 gtk_tree_view_column_set_visible(column, (rd->rename_type != RENAME_TYPE_MANUAL));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2484 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2485
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2486 static GtkWidget *furm_simple_vlabel(GtkWidget *box, const gchar *text, gint expand)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2487 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2488 GtkWidget *vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2489 GtkWidget *label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2490
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2491 vbox = gtk_vbox_new(FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2492 gtk_box_pack_start(GTK_BOX(box), vbox, expand, expand, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2493 gtk_widget_show(vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2494
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2495 label = gtk_label_new(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2496 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2497 gtk_widget_show(label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2498
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2499 return vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2500 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2501
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2502 static GtkTreeViewColumn *file_util_rename_multiple_add_column(RenameDataMult *rd, const gchar *text, gint n)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2503 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2504 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2505 GtkCellRenderer *renderer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2506
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2507 column = gtk_tree_view_column_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2508 gtk_tree_view_column_set_title(column, text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2509 gtk_tree_view_column_set_min_width(column, 4);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2510 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2511 renderer = gtk_cell_renderer_text_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2512 gtk_tree_view_column_pack_start(column, renderer, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2513 gtk_tree_view_column_add_attribute(column, renderer, "text", n);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2514 gtk_tree_view_append_column(GTK_TREE_VIEW(rd->listview), column);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2515
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2516 return column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2517 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2518
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2519 static void file_util_rename_multiple_destroy_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2520 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2521 RenameDataMult *rd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2522
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2523 if (rd->update_idle_id != -1) g_source_remove(rd->update_idle_id);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2524
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2525 g_free(rd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2526 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2527
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2528 static void file_util_rename_multiple_do(GList *source_list, GtkWidget *parent)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2529 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2530 RenameDataMult *rd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2531 GtkWidget *pane;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2532 GtkWidget *scrolled;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2533 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2534 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2535 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2536 GtkWidget *hbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2537 GtkWidget *vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2538 GtkWidget *box2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2539 GtkWidget *table;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2540 GtkWidget *combo;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2541 GList *work;
42
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
2542 const gchar *name;
288
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 283
diff changeset
2543 gchar *title;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2544
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2545 rd = g_new0(RenameDataMult, 1);
288
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 283
diff changeset
2546
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 283
diff changeset
2547 title = g_strdup_printf("%s -%s", _("Rename"), GQ_APPNAME);
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 283
diff changeset
2548 rd->fdlg = file_util_file_dlg(title, GQ_WMCLASS, "dlg_rename", parent,
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 283
diff changeset
2549 file_util_rename_multiple_close_cb, rd);
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 283
diff changeset
2550 g_free(title);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2551 generic_dialog_add_message(GENERIC_DIALOG(rd->fdlg), NULL, _("Rename multiple files"), NULL);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2552 file_dialog_add_button(rd->fdlg, GTK_STOCK_OK, _("_Rename"), file_util_rename_multiple_cb, TRUE);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2553
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2554 rd->fdlg->source_fd = file_data_ref(source_list->data);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2555 rd->fdlg->dest_path = NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2556
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2557 rd->rename_type = RENAME_TYPE_MANUAL;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2558
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2559 rd->update_idle_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2560
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2561 vbox = GENERIC_DIALOG(rd->fdlg)->vbox;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2562
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2563 pane = gtk_hpaned_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2564 gtk_box_pack_start(GTK_BOX(vbox), pane, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2565 gtk_widget_show(pane);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2566
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2567 scrolled = gtk_scrolled_window_new(NULL, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2568 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2569 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scrolled),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2570 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2571 gtk_paned_pack1(GTK_PANED(pane), scrolled, TRUE, TRUE);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2572 gtk_widget_show(scrolled);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2573
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2574 store = gtk_list_store_new(4, G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2575 rd->listview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2576 g_object_unref(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2577
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2578 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(rd->listview), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2579 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(rd->listview), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2580
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2581 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(rd->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2582 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_SINGLE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2583 gtk_tree_selection_set_select_function(selection, file_util_rename_multiple_select_cb, rd, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2584
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2585 file_util_rename_multiple_add_column(rd, _("Original Name"), RENAME_COLUMN_NAME);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2586 column = file_util_rename_multiple_add_column(rd, _("Preview"), RENAME_COLUMN_PREVIEW);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2587 gtk_tree_view_column_set_visible(column, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2588
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2589 gtk_tree_view_set_reorderable(GTK_TREE_VIEW(rd->listview), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2590 g_signal_connect(G_OBJECT(store), "row_changed",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2591 G_CALLBACK(file_util_rename_multiple_preview_order_cb), rd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2592 gtk_widget_set_size_request(rd->listview, 250, 150);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2593
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2594 gtk_container_add(GTK_CONTAINER(scrolled), rd->listview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2595 gtk_widget_show(rd->listview);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2596
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2597 work = source_list;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2598 while (work)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2599 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2600 FileData *fd = work->data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2601 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2602
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2603 gtk_list_store_append(store, &iter);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2604 gtk_list_store_set(store, &iter, RENAME_COLUMN_FD, fd, RENAME_COLUMN_PATH, fd->path, RENAME_COLUMN_NAME, fd->name, -1);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2605
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2606 work = work->next;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2607 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2608
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2609 filelist_free(source_list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2610
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2611 rd->imd = image_new(TRUE);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
2612 g_object_set(G_OBJECT(rd->imd->pr), "zoom_expand", FALSE, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2613 gtk_widget_set_size_request(rd->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
2614 gtk_paned_pack2(GTK_PANED(pane), rd->imd->widget, FALSE, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2615 gtk_widget_show(rd->imd->widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2616
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2617 hbox = gtk_hbox_new(FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2618 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2619 gtk_widget_show(hbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2620
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2621 rd->combo_type = gtk_combo_box_new_text();
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2622
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2623 gtk_combo_box_append_text(GTK_COMBO_BOX(rd->combo_type), _("Manual rename"));
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2624 gtk_combo_box_append_text(GTK_COMBO_BOX(rd->combo_type), _("Formatted rename"));
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2625 gtk_combo_box_append_text(GTK_COMBO_BOX(rd->combo_type), _("Auto rename"));
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2626
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2627 gtk_combo_box_set_active(GTK_COMBO_BOX(rd->combo_type), rd->rename_type);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2628
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2629 g_signal_connect(G_OBJECT(rd->combo_type), "changed",
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2630 G_CALLBACK(file_util_rename_multiple_auto_change), rd);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2631 gtk_box_pack_end(GTK_BOX(hbox), rd->combo_type, FALSE, FALSE, 0);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2632 gtk_widget_show(rd->combo_type);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2633
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2634 rd->rename_box = pref_box_new(vbox, FALSE, GTK_ORIENTATION_VERTICAL, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2635 table = pref_table_new(rd->rename_box, 2, 2, FALSE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2636
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2637 pref_table_label(table, 0, 0, _("Original name:"), 1.0);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2638 rd->rename_label = pref_table_label(table, 1, 0, rd->fdlg->source_fd->name, 0.0);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2639
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2640 pref_table_label(table, 0, 1, _("New name:"), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2641
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2642 rd->rename_entry = gtk_entry_new();
115
53b2bfdcff69 Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
gqview
parents: 112
diff changeset
2643 gtk_table_attach(GTK_TABLE(table), rd->rename_entry, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2644 generic_dialog_attach_default(GENERIC_DIALOG(rd->fdlg), rd->rename_entry);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2645 gtk_widget_grab_focus(rd->rename_entry);
42
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
2646
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2647 name = rd->fdlg->source_fd->name;
42
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
2648 gtk_entry_set_text(GTK_ENTRY(rd->rename_entry), name);
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
2649 gtk_editable_select_region(GTK_EDITABLE(rd->rename_entry), 0, filename_base_length(name));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2650 gtk_widget_show(rd->rename_entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2651
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2652 rd->auto_box = gtk_vbox_new(FALSE, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2653 gtk_box_pack_start(GTK_BOX(vbox), rd->auto_box, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2654 /* do not show it here */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2655
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2656 hbox = pref_box_new(rd->auto_box, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2657
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2658 box2 = furm_simple_vlabel(hbox, _("Begin text"), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2659
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2660 combo = history_combo_new(&rd->auto_entry_front, "", "numerical_rename_prefix", -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2661 g_signal_connect(G_OBJECT(rd->auto_entry_front), "changed",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2662 G_CALLBACK(file_util_rename_multiple_preview_entry_cb), rd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2663 gtk_box_pack_start(GTK_BOX(box2), combo, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2664 gtk_widget_show(combo);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2665
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2666 box2 = furm_simple_vlabel(hbox, _("Start #"), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2667
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2668 rd->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
2669 0.0, 1000000.0, 1.0, 0, 1.0,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2670 G_CALLBACK(file_util_rename_multiple_preview_adj_cb), rd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2671
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2672 box2 = furm_simple_vlabel(hbox, _("End text"), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2673
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2674 combo = history_combo_new(&rd->auto_entry_end, "", "numerical_rename_suffix", -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2675 g_signal_connect(G_OBJECT(rd->auto_entry_end), "changed",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2676 G_CALLBACK(file_util_rename_multiple_preview_entry_cb), rd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2677 gtk_box_pack_start(GTK_BOX(box2), combo, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2678 gtk_widget_show(combo);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2679
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2680 rd->auto_spin_pad = pref_spin_new(rd->auto_box, _("Padding:"), NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2681 1.0, 8.0, 1.0, 0, 1.0,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2682 G_CALLBACK(file_util_rename_multiple_preview_adj_cb), rd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2683
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2684 rd->format_box = gtk_vbox_new(FALSE, PREF_PAD_GAP);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2685 gtk_box_pack_start(GTK_BOX(vbox), rd->format_box, FALSE, FALSE, 0);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2686 /* do not show it here */
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2687
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2688 hbox = pref_box_new(rd->format_box, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_GAP);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2689
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2690 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
2691
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2692 combo = history_combo_new(&rd->format_entry, "", "auto_rename_format", -1);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2693 g_signal_connect(G_OBJECT(rd->format_entry), "changed",
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2694 G_CALLBACK(file_util_rename_multiple_preview_entry_cb), rd);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2695 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
2696 gtk_widget_show(combo);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2697
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2698 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
2699
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2700 rd->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
2701 0.0, 1000000.0, 1.0, 0, 1.0,
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2702 G_CALLBACK(file_util_rename_multiple_preview_adj_cb), rd);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2703
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2704 image_change_fd(rd->imd, rd->fdlg->source_fd, 0.0);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2705
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2706 g_signal_connect(G_OBJECT(GENERIC_DIALOG(rd->fdlg)->dialog), "destroy",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2707 G_CALLBACK(file_util_rename_multiple_destroy_cb), rd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2708
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2709 gtk_widget_show(GENERIC_DIALOG(rd->fdlg)->dialog);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2710 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2711
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2712 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2713 * rename single file
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2714 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2715
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2716 static void file_util_rename_single(FileDataSingle *fds);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2717
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2718 static void file_util_rename_single_ok_cb(GenericDialog *gd, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2719 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2720 FileDataSingle *fds = data;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2721 fds->confirmed = TRUE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2722 file_util_rename_single(fds);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2723 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2724
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2725 static void file_util_rename_single_cancel_cb(GenericDialog *gd, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2726 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2727 FileDataSingle *fds = data;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2728 file_data_single_free(fds);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2729 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2730
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2731 static void file_util_rename_single(FileDataSingle *fds)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2732 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2733 if (isfile(fds->dest) && !fds->confirmed)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2734 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2735 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2736
254
9faf34f047b1 Make the wmclass value unique among the code by defining
zas_
parents: 223
diff changeset
2737 gd = file_util_gen_dlg(_("Overwrite file"), GQ_WMCLASS, "dlg_confirm",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2738 NULL, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2739 file_util_rename_single_cancel_cb, fds);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2740
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2741 generic_dialog_add_message(gd, GTK_STOCK_DIALOG_QUESTION,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2742 _("Overwrite file?"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2743 _("Replace existing file by renaming new file."));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2744 pref_spacer(gd->vbox, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2745
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2746 generic_dialog_add_button(gd, GTK_STOCK_OK, _("_Overwrite"), file_util_rename_single_ok_cb, TRUE);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
2747 generic_dialog_add_image(gd, NULL,
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2748 file_data_new_simple(fds->dest), _("Existing file"),
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2749 fds->source_fd, _("New file"), TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2750
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2751 gtk_widget_show(gd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2752
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2753 return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2754 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2755 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2756 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2757 /*
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2758 GList *list = g_list_append(NULL, file_data_ref(fds->source_fd));
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2759 file_util_do_move_list(list, FALSE, TRUE);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2760 filelist_free(list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2761 */
143
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
2762 if (!file_data_add_change_info(fds->source_fd, FILEDATA_CHANGE_RENAME, fds->source_fd->path, fds->dest) ||
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
2763 !rename_file_ext(fds->source_fd))
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2764 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2765 gchar *text = g_strdup_printf(_("Unable to rename file:\n%s\nto:\n%s"), fds->source_fd->name, filename_from_path(fds->dest));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2766 file_util_warning_dialog(_("Error renaming file"), text, GTK_STOCK_DIALOG_ERROR, NULL);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2767 g_free(text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2768 }
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2769
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2770 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2771 file_data_single_free(fds);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2772 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2773
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2774 static void file_util_rename_single_cb(FileDialog *fdlg, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2775 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2776 const gchar *name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2777 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2778
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2779 name = gtk_entry_get_text(GTK_ENTRY(fdlg->entry));
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2780 path = concat_dir_and_file(fdlg->dest_path, name);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2781
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2782 if (strlen(name) == 0 || strcmp(fdlg->source_fd->path, path) == 0)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2783 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2784 g_free(path);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2785 return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2786 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2787
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2788 file_util_rename_single(file_data_single_new(fdlg->source_fd, path, fdlg->type));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2789
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2790 g_free(path);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2791 file_dialog_close(fdlg);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2792 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2793
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2794 static void file_util_rename_single_close_cb(FileDialog *fdlg, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2795 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2796 file_dialog_close(fdlg);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2797 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2798
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2799 static void file_util_rename_single_do(FileData *source_fd, GtkWidget *parent)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2800 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2801 FileDialog *fdlg;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2802 GtkWidget *table;
42
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
2803 const gchar *name;
288
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 283
diff changeset
2804 gchar *title;
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 283
diff changeset
2805
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 283
diff changeset
2806 title = g_strdup_printf("%s -%s", _("Rename"), GQ_APPNAME);
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 283
diff changeset
2807 fdlg = file_util_file_dlg(title, GQ_WMCLASS, "dlg_rename", parent,
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 283
diff changeset
2808 file_util_rename_single_close_cb, NULL);
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 283
diff changeset
2809 g_free(title);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2810
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2811 generic_dialog_add_message(GENERIC_DIALOG(fdlg), NULL, _("Rename file"), NULL);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2812 generic_dialog_add_image(GENERIC_DIALOG(fdlg), NULL, source_fd, NULL, NULL, NULL, FALSE);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2813
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2814 file_dialog_add_button(fdlg, GTK_STOCK_OK, _("_Rename"), file_util_rename_single_cb, TRUE);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2815
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2816 fdlg->source_fd = file_data_ref(source_fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2817 fdlg->dest_path = remove_level_from_path(source_fd->path);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2818
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2819 table = pref_table_new(GENERIC_DIALOG(fdlg)->vbox, 2, 2, FALSE, FALSE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2820
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2821 pref_table_label(table, 0, 0, _("Original name:"), 1.0);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2822 pref_table_label(table, 1, 0, fdlg->source_fd->name, 0.0);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2823
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2824 pref_table_label(table, 0, 1, _("New name:"), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2825
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2826 fdlg->entry = gtk_entry_new();
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2827 gtk_table_attach(GTK_TABLE(table), fdlg->entry, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2828 generic_dialog_attach_default(GENERIC_DIALOG(fdlg), fdlg->entry);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2829 gtk_widget_grab_focus(fdlg->entry);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2830
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2831 name = fdlg->source_fd->name;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2832 gtk_entry_set_text(GTK_ENTRY(fdlg->entry), name);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2833 gtk_editable_select_region(GTK_EDITABLE(fdlg->entry), 0, filename_base_length(name));
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2834 gtk_widget_show(fdlg->entry);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2835
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2836 gtk_widget_show(GENERIC_DIALOG(fdlg)->dialog);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2837 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2838
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2839 void file_util_rename(FileData *source_fd, GList *source_list, GtkWidget *parent)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2840 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2841 if (!source_fd && !source_list) return;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2842
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2843 if (source_fd)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2844 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2845 file_util_rename_single_do(source_fd, parent);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2846 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2847 else if (!source_list->next)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2848 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2849 file_util_rename_single_do(source_list->data, parent);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2850 filelist_free(source_list);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2851 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2852 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2853 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2854 file_util_rename_multiple_do(source_list, parent);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2855 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2856 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2857
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2858 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2859 *--------------------------------------------------------------------------
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2860 * Create directory routines
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2861 *--------------------------------------------------------------------------
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2862 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2863
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2864 static void file_util_create_dir_do(const gchar *base, const gchar *name)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2865 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2866 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2867
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2868 path = concat_dir_and_file(base, name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2869
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2870 if (isdir(path))
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2871 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2872 gchar *text = g_strdup_printf(_("The folder:\n%s\nalready exists."), name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2873 file_util_warning_dialog(_("Folder exists"), text, GTK_STOCK_DIALOG_INFO, NULL);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2874 g_free(text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2875 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2876 else if (isname(path))
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2877 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2878 gchar *text = g_strdup_printf(_("The path:\n%s\nalready exists as a file."), name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2879 file_util_warning_dialog(_("Could not create folder"), text, GTK_STOCK_DIALOG_INFO, NULL);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2880 g_free(text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2881 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2882 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2883 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2884 if (!mkdir_utf8(path, 0755))
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2885 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2886 gchar *text = g_strdup_printf(_("Unable to create folder:\n%s"), name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2887 file_util_warning_dialog(_("Error creating folder"), text, GTK_STOCK_DIALOG_ERROR, NULL);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2888 g_free(text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2889 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2890 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2891
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2892 g_free(path);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2893 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2894
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2895 static void file_util_create_dir_cb(FileDialog *fdlg, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2896 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2897 const gchar *name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2898
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2899 name = gtk_entry_get_text(GTK_ENTRY(fdlg->entry));
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2900
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2901 if (strlen(name) == 0) return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2902
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2903 if (name[0] == '/')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2904 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2905 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2906 buf = remove_level_from_path(name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2907 file_util_create_dir_do(buf, filename_from_path(name));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2908 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2909 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2910 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2911 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2912 file_util_create_dir_do(fdlg->dest_path, name);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2913 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2914
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2915 file_dialog_close(fdlg);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2916 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2917
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2918 static void file_util_create_dir_close_cb(FileDialog *fdlg, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2919 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2920 file_dialog_close(fdlg);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2921 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2922
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2923 void file_util_create_dir(const gchar *path, GtkWidget *parent)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2924 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2925 FileDialog *fdlg;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2926 gchar *text;
288
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 283
diff changeset
2927 gchar *title;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2928
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2929 if (!isdir(path)) return;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2930
288
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 283
diff changeset
2931 title = g_strdup_printf("%s -%s", _("New folder"), GQ_APPNAME);
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 283
diff changeset
2932 fdlg = file_util_file_dlg(title, GQ_WMCLASS, "dlg_newdir", parent,
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 283
diff changeset
2933 file_util_create_dir_close_cb, NULL);
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 283
diff changeset
2934 g_free(title);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2935
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2936 text = g_strdup_printf(_("Create folder in:\n%s\nnamed:"), path);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2937 generic_dialog_add_message(GENERIC_DIALOG(fdlg), NULL, NULL, text);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2938 g_free(text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2939
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2940 file_dialog_add_button(fdlg, GTK_STOCK_OK, NULL, file_util_create_dir_cb, TRUE);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2941
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2942 fdlg->dest_path = g_strdup(path);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2943
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2944 fdlg->entry = gtk_entry_new();
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2945 gtk_box_pack_start(GTK_BOX(GENERIC_DIALOG(fdlg)->vbox), fdlg->entry, FALSE, FALSE, 0);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2946 generic_dialog_attach_default(GENERIC_DIALOG(fdlg), fdlg->entry);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2947 gtk_widget_grab_focus(fdlg->entry);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2948 gtk_widget_show(fdlg->entry);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2949
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2950 gtk_widget_show(GENERIC_DIALOG(fdlg)->dialog);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2951 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2952
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2953 gint file_util_rename_dir(FileData *old_fd, const gchar *new_path, GtkWidget *parent)
44
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2954 {
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2955 const gchar *old_name;
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2956 const gchar *new_name;
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2957
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2958 if (!old_fd || !new_path || !isdir(old_fd->path)) return FALSE;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2959
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2960 old_name = old_fd->name;
44
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2961 new_name = filename_from_path(new_path);
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2962
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2963 if (isdir(new_path))
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2964 {
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2965 gchar *text = g_strdup_printf(_("The folder:\n%s\nalready exists."), new_name);
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2966 file_util_warning_dialog(_("Folder exists"), text, GTK_STOCK_DIALOG_INFO, parent);
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2967 g_free(text);
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2968
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2969 return FALSE;
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2970 }
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2971
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2972 if (isname(new_path))
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2973 {
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2974 gchar *text = g_strdup_printf(_("The path:\n%s\nalready exists as a file."), new_name);
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2975 file_util_warning_dialog(_("Rename failed"), text, GTK_STOCK_DIALOG_INFO,parent);
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2976 g_free(text);
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2977
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2978 return FALSE;
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2979 }
143
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
2980 if (!file_data_add_change_info(old_fd, FILEDATA_CHANGE_RENAME, old_fd->path, new_path) ||
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
2981 !rename_file_ext(old_fd))
44
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2982 {
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2983 gchar *text = g_strdup_printf(_("Failed to rename %s to %s."), old_name, new_name);
71
7425cb0aeb03 Sat Oct 14 05:18:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 67
diff changeset
2984 file_util_warning_dialog(_("Rename failed"), text, GTK_STOCK_DIALOG_ERROR, parent);
44
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2985 g_free(text);
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2986
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2987 return FALSE;
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2988 }
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2989
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2990 return TRUE;
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2991 }
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2992
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
2993 /*
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
2994 *--------------------------------------------------------------------------
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
2995 * Delete directory routines
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
2996 *--------------------------------------------------------------------------
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
2997 */
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
2998
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
2999 /* The plan is to eventually make all of utilops.c
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3000 * use UtilityData and UtilityType.
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3001 * And clean up the above mess someday.
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3002 */
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3003
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3004 typedef enum {
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3005 UTILITY_TYPE_NONE = 0,
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3006 UTILITY_TYPE_COPY,
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3007 UTILITY_TYPE_MOVE,
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3008 UTILITY_TYPE_RENAME,
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3009 UTILITY_TYPE_DELETE,
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3010 UTILITY_TYPE_DELETE_LINK,
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3011 UTILITY_TYPE_DELETE_FOLDER
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3012 } UtilityType;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3013
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3014 typedef struct _UtilityData UtilityData;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3015 struct _UtilityData {
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3016 UtilityType type;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3017 FileData *source_fd;
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3018 GList *dlist;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3019 GList *flist;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3020
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3021 GenericDialog *gd;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3022 };
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3023
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3024 enum {
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3025 UTILITY_COLUMN_FD = 0,
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3026 UTILITY_COLUMN_PATH,
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3027 UTILITY_COLUMN_NAME,
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3028 UTILITY_COLUMN_COUNT
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3029 };
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3030
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3031
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3032 #define UTILITY_LIST_MIN_WIDTH 250
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3033 #define UTILITY_LIST_MIN_HEIGHT 150
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3034
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3035 /* thumbnail spec has a max depth of 4 (.thumb??/fail/appname/??.png) */
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3036 #define UTILITY_DELETE_MAX_DEPTH 5
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3037
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3038
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3039 static void file_util_data_free(UtilityData *ud)
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3040 {
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3041 if (!ud) return;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3042
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3043 file_data_unref(ud->source_fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3044 filelist_free(ud->dlist);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3045 filelist_free(ud->flist);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3046
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3047 if (ud->gd) generic_dialog_close(ud->gd);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3048
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3049 g_free(ud);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3050 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3051
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3052 static GtkTreeViewColumn *file_util_dialog_add_list_column(GtkWidget *view, const gchar *text, gint n)
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3053 {
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3054 GtkTreeViewColumn *column;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3055 GtkCellRenderer *renderer;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3056
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3057 column = gtk_tree_view_column_new();
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3058 gtk_tree_view_column_set_title(column, text);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3059 gtk_tree_view_column_set_min_width(column, 4);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3060 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3061 renderer = gtk_cell_renderer_text_new();
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3062 gtk_tree_view_column_pack_start(column, renderer, TRUE);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3063 gtk_tree_view_column_add_attribute(column, renderer, "text", n);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3064 gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3065
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3066 return column;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3067 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3068
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3069 static GtkWidget *file_util_dialog_add_list(GtkWidget *box, GList *list, gint full_paths)
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3070 {
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3071 GtkWidget *scrolled;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3072 GtkWidget *view;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3073 GtkListStore *store;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3074
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3075 scrolled = gtk_scrolled_window_new(NULL, NULL);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3076 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3077 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scrolled),
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3078 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3079 gtk_box_pack_start(GTK_BOX(box), scrolled, TRUE, TRUE, 0);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3080 gtk_widget_show(scrolled);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3081
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3082 store = gtk_list_store_new(UTILITY_COLUMN_COUNT, G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_STRING);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3083 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3084 g_object_unref(store);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3085
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3086 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), TRUE);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3087 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(view), FALSE);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3088
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3089 if (full_paths)
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3090 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3091 file_util_dialog_add_list_column(view, _("Location"), UTILITY_COLUMN_PATH);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3092 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3093 else
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3094 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3095 file_util_dialog_add_list_column(view, _("Name"), UTILITY_COLUMN_NAME);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3096 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3097
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3098 gtk_widget_set_size_request(view, UTILITY_LIST_MIN_WIDTH, UTILITY_LIST_MIN_HEIGHT);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3099 gtk_container_add(GTK_CONTAINER(scrolled), view);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3100 gtk_widget_show(view);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3101
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3102 while (list)
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3103 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3104 FileData *fd = list->data;
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3105 GtkTreeIter iter;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3106
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3107 gtk_list_store_append(store, &iter);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3108 gtk_list_store_set(store, &iter, UTILITY_COLUMN_FD, fd,
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3109 UTILITY_COLUMN_PATH, fd->path,
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3110 UTILITY_COLUMN_NAME, fd->name, -1);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3111
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3112 list = list->next;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3113 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3114
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3115 return view;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3116 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3117
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3118 static gboolean file_util_delete_dir_preview_cb(GtkTreeSelection *selection, GtkTreeModel *store,
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3119 GtkTreePath *tpath, gboolean path_currently_selected,
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3120 gpointer data)
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3121 {
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3122 UtilityData *ud = data;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3123 GtkTreeIter iter;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3124 FileData *fd = NULL;
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3125
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3126 if (path_currently_selected ||
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3127 !gtk_tree_model_get_iter(store, &iter, tpath)) return TRUE;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3128
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3129 gtk_tree_model_get(store, &iter, UTILITY_COLUMN_FD, &fd, -1);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3130 generic_dialog_image_set(ud->gd, fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3131 // file_data_unref(fd);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3132
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3133 return TRUE;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3134 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3135
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3136 static void file_util_delete_dir_cancel_cb(GenericDialog *gd, gpointer data)
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3137 {
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3138 UtilityData *ud = data;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3139
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3140 ud->gd = NULL;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3141 file_util_data_free(ud);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3142 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3143
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3144 FileData *file_util_delete_dir_empty_path(FileData *fd, gint real_content, gint level)
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3145 {
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3146 GList *dlist = NULL;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3147 GList *flist = NULL;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3148 GList *work;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3149 FileData *fail = NULL;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3150
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3151 if (debug) printf("deltree into: %s\n", fd->path);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3152
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3153 level++;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3154 if (level > UTILITY_DELETE_MAX_DEPTH)
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3155 {
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3156 printf("folder recursion depth past %d, giving up\n", UTILITY_DELETE_MAX_DEPTH);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3157 return file_data_ref(fd);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3158 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3159
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3160 if (!filelist_read_lstat(fd->path, &flist, &dlist)) file_data_ref(fd);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3161
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3162 work = dlist;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3163 while (work && !fail)
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3164 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3165 FileData *lfd;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3166
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3167 lfd = work->data;
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3168 work = work->next;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3169
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3170 fail = file_util_delete_dir_empty_path(lfd, real_content, level);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3171 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3172
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3173 work = flist;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3174 while (work && !fail)
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3175 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3176 FileData *lfd;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3177
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3178 lfd = work->data;
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3179 work = work->next;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3180
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3181 if (debug) printf("deltree child: %s\n", lfd->path);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3182
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3183 if (real_content && !islink(lfd->path))
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3184 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3185 if (!file_util_unlink(lfd)) fail = file_data_ref(lfd);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3186 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3187 else
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3188 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3189 if (!unlink_file(lfd->path)) fail = file_data_ref(lfd);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3190 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3191 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3192
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3193 filelist_free(dlist);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3194 filelist_free(flist);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3195
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3196 if (!fail && !rmdir_utf8(fd->path))
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3197 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3198 fail = file_data_ref(fd);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3199 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3200
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3201 if (debug) printf("deltree done: %s\n", fd->path);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3202
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3203 return fail;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3204 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3205
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3206 static void file_util_delete_dir_ok_cb(GenericDialog *gd, gpointer data)
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3207 {
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3208 UtilityData *ud = data;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3209
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3210 ud->gd = NULL;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3211
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3212 if (ud->type == UTILITY_TYPE_DELETE_LINK)
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3213 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3214 if (!unlink_file(ud->source_fd->path))
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3215 {
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3216 gchar *text;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3217
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3218 text = g_strdup_printf("Unable to remove symbolic link:\n %s", ud->source_fd->path);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3219 file_util_warning_dialog(_("Delete failed"), text,
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3220 GTK_STOCK_DIALOG_ERROR, NULL);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3221 g_free(text);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3222 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3223 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3224 else
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3225 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3226 FileData *fail = NULL;
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3227 GList *work;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3228
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3229 work = ud->dlist;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3230 while (work && !fail)
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3231 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3232 FileData *fd;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3233
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3234 fd = work->data;
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3235 work = work->next;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3236
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3237 fail = file_util_delete_dir_empty_path(fd, FALSE, 0);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3238 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3239
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3240 work = ud->flist;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3241 while (work && !fail)
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3242 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3243 FileData *fd;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3244
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3245 fd = work->data;
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3246 work = work->next;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3247
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3248 if (debug) printf("deltree unlink: %s\n", fd->path);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3249
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3250 if (islink(fd->path))
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3251 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3252 if (!unlink_file(fd->path)) fail = file_data_ref(fd);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3253 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3254 else
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3255 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3256 if (!file_util_unlink(fd)) fail = file_data_ref(fd);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3257 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3258 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3259
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3260 if (!fail)
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3261 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3262 if (!rmdir_utf8(ud->source_fd->path)) fail = file_data_ref(ud->source_fd);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3263 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3264
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3265 if (fail)
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3266 {
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3267 gchar *text;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3268
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3269 text = g_strdup_printf(_("Unable to delete folder:\n\n%s"), ud->source_fd->path);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3270 gd = file_util_warning_dialog(_("Delete failed"), text, GTK_STOCK_DIALOG_ERROR, NULL);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3271 g_free(text);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3272
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3273 if (fail != ud->source_fd)
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3274 {
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3275 pref_spacer(gd->vbox, PREF_PAD_GROUP);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3276 text = g_strdup_printf(_("Removal of folder contents failed at this file:\n\n%s"),
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3277 fail->path);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3278 pref_label_new(gd->vbox, text);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3279 g_free(text);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3280 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3281
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3282 file_data_unref(fail);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3283 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3284 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3285
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3286 file_util_data_free(ud);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3287 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3288
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3289 static GList *file_util_delete_dir_remaining_folders(GList *dlist)
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3290 {
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3291 GList *rlist = NULL;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3292
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3293 while (dlist)
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3294 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3295 FileData *fd;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3296
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3297 fd = dlist->data;
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3298 dlist = dlist->next;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3299
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3300 if (!fd->name ||
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3301 (strcmp(fd->name, THUMB_FOLDER_GLOBAL) != 0 &&
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3302 strcmp(fd->name, THUMB_FOLDER_LOCAL) != 0 &&
283
e213fb025621 GQVIEW_* -> GQ_*
zas_
parents: 281
diff changeset
3303 strcmp(fd->name, GQ_CACHE_LOCAL_METADATA) != 0) )
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3304 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3305 rlist = g_list_prepend(rlist, fd);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3306 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3307 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3308
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3309 return g_list_reverse(rlist);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3310 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3311
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3312 void file_util_delete_dir(FileData *fd, GtkWidget *parent)
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3313 {
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3314 GList *dlist = NULL;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3315 GList *flist = NULL;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3316 GList *rlist;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3317
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3318 if (!isdir(fd->path)) return;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3319
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3320 if (islink(fd->path))
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3321 {
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3322 UtilityData *ud;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3323 gchar *text;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3324
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3325 ud = g_new0(UtilityData, 1);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3326 ud->type = UTILITY_TYPE_DELETE_LINK;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3327 ud->source_fd = file_data_ref(fd);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3328 ud->dlist = NULL;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3329 ud->flist = NULL;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3330
254
9faf34f047b1 Make the wmclass value unique among the code by defining
zas_
parents: 223
diff changeset
3331 ud->gd = file_util_gen_dlg(_("Delete folder"), GQ_WMCLASS, "dlg_confirm",
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3332 parent, TRUE,
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3333 file_util_delete_dir_cancel_cb, ud);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3334
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3335 text = g_strdup_printf(_("This will delete the symbolic link:\n\n%s\n\n"
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3336 "The folder this link points to will not be deleted."),
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3337 fd->path);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3338 generic_dialog_add_message(ud->gd, GTK_STOCK_DIALOG_QUESTION,
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3339 _("Delete symbolic link to folder?"),
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3340 text);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3341 g_free(text);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3342
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3343 generic_dialog_add_button(ud->gd, GTK_STOCK_DELETE, NULL, file_util_delete_dir_ok_cb, TRUE);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3344
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3345 gtk_widget_show(ud->gd->dialog);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3346
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3347 return;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3348 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3349
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3350 if (!access_file(fd->path, W_OK | X_OK))
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3351 {
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3352 gchar *text;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3353
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3354 text = g_strdup_printf(_("Unable to remove folder %s\n"
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3355 "Permissions do not allow writing to the folder."), fd->path);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3356 file_util_warning_dialog(_("Delete failed"), text, GTK_STOCK_DIALOG_ERROR, parent);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3357 g_free(text);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3358
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3359 return;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3360 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3361
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3362 if (!filelist_read_lstat(fd->path, &flist, &dlist))
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3363 {
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3364 gchar *text;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3365
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3366 text = g_strdup_printf(_("Unable to list contents of folder %s"), fd->path);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3367 file_util_warning_dialog(_("Delete failed"), text, GTK_STOCK_DIALOG_ERROR, parent);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3368 g_free(text);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3369
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3370 return;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3371 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3372
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3373 rlist = file_util_delete_dir_remaining_folders(dlist);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3374 if (rlist)
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3375 {
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3376 GenericDialog *gd;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3377 GtkWidget *box;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3378 gchar *text;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3379
254
9faf34f047b1 Make the wmclass value unique among the code by defining
zas_
parents: 223
diff changeset
3380 gd = file_util_gen_dlg(_("Folder contains subfolders"), GQ_WMCLASS, "dlg_warning",
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3381 parent, TRUE, NULL, NULL);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3382 generic_dialog_add_button(gd, GTK_STOCK_CLOSE, NULL, NULL, TRUE);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3383
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3384 text = g_strdup_printf(_("Unable to delete the folder:\n\n%s\n\n"
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3385 "This folder contains subfolders which must be moved before it can be deleted."),
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3386 fd->path);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3387 box = generic_dialog_add_message(gd, GTK_STOCK_DIALOG_WARNING,
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3388 _("Folder contains subfolders"),
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3389 text);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3390 g_free(text);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3391
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3392 box = pref_group_new(box, TRUE, _("Subfolders:"), GTK_ORIENTATION_VERTICAL);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3393
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3394 rlist = filelist_sort_path(rlist);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3395 file_util_dialog_add_list(box, rlist, FALSE);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3396
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3397 gtk_widget_show(gd->dialog);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3398 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3399 else
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3400 {
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3401 UtilityData *ud;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3402 GtkWidget *box;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3403 GtkWidget *view;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3404 GtkTreeSelection *selection;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3405 gchar *text;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3406
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3407 ud = g_new0(UtilityData, 1);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3408 ud->type = UTILITY_TYPE_DELETE_FOLDER;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3409 ud->source_fd = file_data_ref(fd);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3410 ud->dlist = dlist;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3411 dlist = NULL;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3412 ud->flist = filelist_sort_path(flist);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3413 flist = NULL;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3414
254
9faf34f047b1 Make the wmclass value unique among the code by defining
zas_
parents: 223
diff changeset
3415 ud->gd = file_util_gen_dlg(_("Delete folder"), GQ_WMCLASS, "dlg_confirm",
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3416 parent, TRUE, file_util_delete_dir_cancel_cb, ud);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3417 generic_dialog_add_button(ud->gd, GTK_STOCK_DELETE, NULL, file_util_delete_dir_ok_cb, TRUE);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3418
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3419 text = g_strdup_printf(_("This will delete the folder:\n\n%s\n\n"
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3420 "The contents of this folder will also be deleted."),
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3421 fd->path);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3422 box = generic_dialog_add_message(ud->gd, GTK_STOCK_DIALOG_QUESTION,
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3423 _("Delete folder?"),
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3424 text);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3425 g_free(text);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3426
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3427 box = pref_group_new(box, TRUE, _("Contents:"), GTK_ORIENTATION_HORIZONTAL);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3428
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3429 view = file_util_dialog_add_list(box, ud->flist, FALSE);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3430 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3431 gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3432 gtk_tree_selection_set_select_function(selection, file_util_delete_dir_preview_cb, ud, NULL);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3433
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3434 generic_dialog_add_image(ud->gd, box, NULL, NULL, NULL, NULL, FALSE);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3435
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3436 box_append_safe_delete_status(ud->gd);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3437
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3438 gtk_widget_show(ud->gd->dialog);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3439 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3440
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3441 g_list_free(rlist);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3442 filelist_free(dlist);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
3443 filelist_free(flist);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3444 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
3445