annotate src/utilops.c @ 136:18c2a29e681c

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