annotate src/utilops.c @ 67:f63ecca6c087

Fri Oct 13 05:22:43 2006 John Ellis <johne@verizon.net> * bar_sort.c, pan-view.c, preferences.c: Mark strings for translation, plus punctuation fix. * utilops.c: Change auto rename start number to default to 1. * configure.in (ALL_LINGUAS): Add be, ca, ko translations. * gqview.spec.in: Add Italian translation to RPM spec file, submitted by HappyCactus <happycactus@people.it>. * be.po: Add Belarusion translation, submitted by Pavel Piatruk <berserker@neolocation.com>. * ca.po: Add Catalan translation [merge from 2.0.2], submitted by catux.org <mecatxis@ya.com>. * de.po: Update German translation [merge from 2.0.2], submitted by Ronny Steiner <Post@SIRSteiner.de>. * fr.po: Update French translation, submitted by ?ric Lassauge <lassauge@users.sourceforge.net>. * it.po: Update Italian translation, submitted by Kostantino <ciclope10ATalice.it>. * ko.po: Add Korean translation (mostly menus), submitted by Hyun-Jin Moon <moonhyunjin@gmail.com>. * pt_BR.po: Update Brazilian Portuguese translation, submitted by Herval Ribeiro de Azev??do <heraze@gmail.com>. * sk.po: Update Slovak translation, submitted by Mgr. Peter Tuharsky <tuharsky@misbb.sk>. * zh_TW.po: Update Traditional Chinese translation, submitted by S.J. Luo <crystal@mickey.ee.nctu.edu.tw>
author gqview
date Fri, 13 Oct 2006 10:14:59 +0000
parents ebbff299ad0d
children 7425cb0aeb03
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
17 #include "cache_maint.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
18 #include "collect.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
19 #include "dupe.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
20 #include "filelist.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
21 #include "image.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
22 #include "img-view.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
23 #include "layout.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
24 #include "search.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
25 #include "ui_bookmark.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
26 #include "ui_fileops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
27 #include "ui_misc.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
28 #include "ui_tabcomp.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
29
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
30
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 * call these when names change, files move, deleted, etc.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
34 * so that any open windows are also updated
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
35 *--------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
36 */
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 void file_maint_renamed(const gchar *source, const gchar *dest)
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 cache_maint_moved(source, dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
41 collection_maint_renamed(source, dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
42
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
43 layout_maint_renamed(source, dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
44 view_window_maint_moved(source, dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
45 dupe_maint_renamed(source, dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
46 search_maint_renamed(source, dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
47 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
48
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
49 /* under most cases ignore_list should be NULL */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
50 void file_maint_removed(const gchar *path, GList *ignore_list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
51 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
52 layout_maint_removed(path, ignore_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
53 view_window_maint_removed(path, ignore_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
54 dupe_maint_removed(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
55 search_maint_removed(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
56
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
57 collection_maint_removed(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
58 cache_maint_removed(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
59 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
60
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
61 /* special case for correct main window behavior */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
62 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
63 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
64 cache_maint_moved(source, dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
65 collection_maint_renamed(source, dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
66
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
67 layout_maint_moved(source, dest, ignore_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
68 view_window_maint_moved(source, dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
69 dupe_maint_renamed(source, dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
70 search_maint_renamed(source, dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
71 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
72
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
73 void file_maint_copied(const gchar *source, const gchar *dest)
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 cache_maint_copied(source, 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
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 * The file manipulation dialogs
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
81 *--------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
82 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
83
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
84
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
85 enum {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
86 DIALOG_NEW_DIR,
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
87 DIALOG_COPY,
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
88 DIALOG_MOVE,
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
89 DIALOG_DELETE,
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
90 DIALOG_RENAME
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
91 };
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
92
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
93 typedef struct _FileDataMult FileDataMult;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
94 struct _FileDataMult
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
95 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
96 gint confirm_all;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
97 gint confirmed;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
98 gint skip;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
99 GList *source_list;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
100 GList *source_next;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
101 gchar *dest_base;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
102 gchar *source;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
103 gchar *dest;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
104 gint copy;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
105
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
106 gint rename;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
107 gint rename_auto;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
108 gint rename_all;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
109
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
110 GtkWidget *rename_box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
111 GtkWidget *rename_entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
112 GtkWidget *rename_auto_box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
113
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
114 GtkWidget *yes_all_button;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
115 };
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
116
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
117 typedef struct _FileDataSingle FileDataSingle;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
118 struct _FileDataSingle
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
119 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
120 gint confirmed;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
121 gchar *source;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
122 gchar *dest;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
123 gint copy;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
124
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
125 gint rename;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
126 gint rename_auto;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
127
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
128 GtkWidget *rename_box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
129 GtkWidget *rename_entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
130 GtkWidget *rename_auto_box;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
131 };
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
132
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
133 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
134 *--------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
135 * 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
136 *--------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
137 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
138
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
139 #define DIALOG_DEF_IMAGE_DIM_X 200
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
140 #define DIALOG_DEF_IMAGE_DIM_Y 150
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
141
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
142 static void generic_dialog_add_image(GenericDialog *gd, const gchar *path1, const gchar *header1,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
143 const gchar *path2, const gchar *header2,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
144 gint show_filename)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
145 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
146 ImageWindow *imd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
147 GtkWidget *hbox = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
148 GtkWidget *vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
149 GtkWidget *label = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
150
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
151 if (path2)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
152 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
153 hbox = pref_box_new(gd->vbox, TRUE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
154 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
155
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
156 /* image 1 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
157
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
158 vbox = gtk_vbox_new(FALSE, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
159 if (hbox)
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 GtkWidget *sep;
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 gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
164
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
165 sep = gtk_vseparator_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
166 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
167 gtk_widget_show(sep);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
168 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
169 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
170 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
171 gtk_box_pack_start(GTK_BOX(gd->vbox), vbox, TRUE, TRUE, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
172 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
173 gtk_widget_show(vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
174
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
175 if (header1)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
176 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
177 GtkWidget *head;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
178
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
179 head = pref_label_new(vbox, header1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
180 pref_label_bold(head, TRUE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
181 gtk_misc_set_alignment(GTK_MISC(head), 0.0, 0.5);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
182 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
183
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
184 imd = image_new(FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
185 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
186 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
187 image_change_path(imd, path1, 0.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
188 gtk_widget_show(imd->widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
189
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
190 if (show_filename)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
191 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
192 label = pref_label_new(vbox, (path1 == NULL) ? "" : filename_from_path(path1));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
193 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
194
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
195 /* 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
196 g_object_set_data(G_OBJECT(gd->dialog), "img_image", imd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
197 g_object_set_data(G_OBJECT(gd->dialog), "img_label", label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
198
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
199
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
200 /* image 2 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
201
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
202 if (hbox && path2)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
203 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
204 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
205
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
206 if (header2)
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 GtkWidget *head;
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 head = pref_label_new(vbox, header2);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
211 pref_label_bold(head, TRUE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
212 gtk_misc_set_alignment(GTK_MISC(head), 0.0, 0.5);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
215 imd = image_new(FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
216 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
217 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
218 image_change_path(imd, path2, 0.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
219 gtk_widget_show(imd->widget);
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 pref_label_new(vbox, filename_from_path(path2));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
222 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
223 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
224
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
225 static void generic_dialog_image_set(GenericDialog *gd, const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
226 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
227 ImageWindow *imd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
228 GtkWidget *label;
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 imd = g_object_get_data(G_OBJECT(gd->dialog), "img_image");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
231 label = g_object_get_data(G_OBJECT(gd->dialog), "img_label");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
232
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
233 if (!imd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
234
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
235 image_change_path(imd, path, 0.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
236 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
237 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
238
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 *--------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
241 * Wrappers to aid in setting additional dialog properties (unde mouse, etc.)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
242 *--------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
243 */
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 GenericDialog *file_util_gen_dlg(const gchar *title,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
246 const gchar *wmclass, const gchar *wmsubclass,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
247 GtkWidget *parent, gint auto_close,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
248 void (*cancel_cb)(GenericDialog *, gpointer), gpointer data)
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 GenericDialog *gd;
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 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
253 if (place_dialogs_under_mouse)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
254 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
255 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
256 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
257
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
258 return gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
259 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
260
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
261 FileDialog *file_util_file_dlg(const gchar *title,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
262 const gchar *wmclass, const gchar *wmsubclass,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
263 GtkWidget *parent,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
264 void (*cancel_cb)(FileDialog *, gpointer), gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
265 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
266 FileDialog *fd;
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 fd = file_dialog_new(title, wmclass, wmsubclass, parent, cancel_cb, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
269 if (place_dialogs_under_mouse)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
270 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
271 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
272 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
273
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
274 return fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
275 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
276
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
277 /* this warning dialog is copied from SLIK's ui_utildg.c,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
278 * because it does not have a mouse center option,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
279 * and we must center it before show, implement it here.
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 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
282 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
283 /* no op */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
284 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
285
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
286 GenericDialog *file_util_warning_dialog(const gchar *heading, const gchar *message,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
287 const gchar *icon_stock_id, GtkWidget *parent)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
288 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
289 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
290
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
291 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
292 generic_dialog_add_message(gd, icon_stock_id, heading, message);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
293 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
294 if (place_dialogs_under_mouse)
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 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
297 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
298 gtk_widget_show(gd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
299
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
300 return gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
301 }
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
302
42
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
303 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
304 {
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
305 gint n;
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
306
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
307 if (!name) return 0;
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
308
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
309 n = strlen(name);
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
310
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
311 if (filter_name_exists(name))
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
312 {
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
313 const gchar *ext;
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
314
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
315 ext = extension_from_path(name);
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
316 if (ext) n -= strlen(ext);
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
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
319 return n;
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
320 }
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
321
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
322
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
323 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
324 *--------------------------------------------------------------------------
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
325 * Move and Copy routines
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
326 *--------------------------------------------------------------------------
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
327 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
328
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
329 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
330 * Multi file move
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
331 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
332
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
333 static FileDataMult *file_data_multiple_new(GList *source_list, const gchar *dest, gint copy)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
334 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
335 FileDataMult *fdm = g_new0(FileDataMult, 1);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
336 fdm->confirm_all = FALSE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
337 fdm->confirmed = FALSE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
338 fdm->skip = FALSE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
339 fdm->source_list = source_list;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
340 fdm->source_next = fdm->source_list;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
341 fdm->dest_base = g_strdup(dest);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
342 fdm->source = NULL;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
343 fdm->dest = NULL;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
344 fdm->copy = copy;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
345 return fdm;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
346 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
347
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
348 static void file_data_multiple_free(FileDataMult *fdm)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
349 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
350 path_list_free(fdm->source_list);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
351 g_free(fdm->dest_base);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
352 g_free(fdm->dest);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
353 g_free(fdm);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
354 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
355
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
356 static void file_util_move_multiple(FileDataMult *fdm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
357
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
358 static void file_util_move_multiple_ok_cb(GenericDialog *gd, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
359 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
360 FileDataMult *fdm = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
361
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
362 fdm->confirmed = TRUE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
363
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
364 if (fdm->rename_auto)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
365 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
366 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
367
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
368 buf = unique_filename_simple(fdm->dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
369 if (buf)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
370 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
371 g_free(fdm->dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
372 fdm->dest = buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
373 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
374 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
375 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
376 /* unique failed? well, return to the overwrite prompt :( */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
377 fdm->confirmed = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
378 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
379 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
380 else if (fdm->rename)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
381 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
382 const gchar *name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
383
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
384 name = gtk_entry_get_text(GTK_ENTRY(fdm->rename_entry));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
385 if (strlen(name) == 0 ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
386 strcmp(name, filename_from_path(fdm->source)) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
387 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
388 fdm->confirmed = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
389 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
390 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
391 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
392 g_free(fdm->dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
393 fdm->dest = concat_dir_and_file(fdm->dest_base, name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
394 fdm->confirmed = !isname(fdm->dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
395 }
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
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
398 file_util_move_multiple(fdm);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
399 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
400
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
401 static void file_util_move_multiple_all_cb(GenericDialog *gd, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
402 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
403 FileDataMult *fdm = data;
9
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 fdm->confirm_all = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
406
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
407 if (fdm->rename_auto) fdm->rename_all = TRUE;
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 file_util_move_multiple(fdm);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
412 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
413 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
414 FileDataMult *fdm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
415
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
416 fdm->skip = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
417 fdm->confirmed = TRUE;
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 file_util_move_multiple(fdm);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
422 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
423 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
424 FileDataMult *fdm = data;
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 fdm->skip = TRUE;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
427 fdm->confirm_all = TRUE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
428 file_util_move_multiple(fdm);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
429 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
430
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
431 static void file_util_move_multiple_continue_cb(GenericDialog *gd, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
432 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
433 FileDataMult *fdm = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
434
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
435 fdm->confirmed = TRUE;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
436 file_util_move_multiple(fdm);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
437 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
438
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
439 static void file_util_move_multiple_cancel_cb(GenericDialog *gd, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
440 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
441 FileDataMult *fdm = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
442
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
443 file_data_multiple_free(fdm);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
444 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
445
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
446 /* rename option */
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 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
449 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
450 GenericDialog *gd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
451 FileDataMult *fdm;
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 fdm = gd->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->rename_auto = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
456 gtk_widget_set_sensitive(fdm->rename_box, !fdm->rename_auto);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
457 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
458
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
459 if (fdm->rename_auto)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
460 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
461 gchar *preview;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
462
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
463 preview = unique_filename_simple(fdm->dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
464 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
465 g_free(preview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
466 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
467
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
468 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
469 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
470
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
471 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
472 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
473 GenericDialog *gd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
474 FileDataMult *fdm;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
475
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
476 fdm = gd->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
477
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
478 fdm->rename = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
479 gtk_widget_set_sensitive(fdm->rename_entry, fdm->rename);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
480 gtk_widget_set_sensitive(fdm->yes_all_button, !fdm->rename);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
481
42
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
482 if (fdm->rename)
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
483 {
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
484 const gchar *name;
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
485
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
486 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
487
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
488 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
489 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
490 }
9
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
493 static GenericDialog *file_util_move_multiple_confirm_dialog(FileDataMult *fdm)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
494 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
495 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
496 GtkWidget *hbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
497
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
498 gd = file_util_gen_dlg(_("Overwrite file"), "GQview", "dlg_confirm",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
499 NULL, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
500 file_util_move_multiple_cancel_cb, fdm);
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 generic_dialog_add_message(gd, GTK_STOCK_DIALOG_QUESTION,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
503 _("Overwrite file?"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
504 _("Replace existing file with new file."));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
505 pref_spacer(gd->vbox, 0);
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 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
508 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
509 file_util_move_multiple_all_cb, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
510 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
511 generic_dialog_add_button(gd, GTK_STOCK_GO_FORWARD, _("_Skip"), file_util_move_multiple_skip_cb, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
512 generic_dialog_add_image(gd, fdm->dest, _("Existing file"), fdm->source, _("New file"), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
513
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
514 /* rename option */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
515
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
516 fdm->rename = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
517 fdm->rename_all = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
518 fdm->rename_auto = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
519
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
520 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
521
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
522 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
523 g_signal_connect(G_OBJECT(fdm->rename_auto_box), "clicked",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
524 G_CALLBACK(file_util_move_multiple_rename_auto_cb), gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
525 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
526 gtk_widget_show(fdm->rename_auto_box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
527
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
528 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
529
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
530 fdm->rename_box = gtk_check_button_new_with_label(_("Rename"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
531 g_signal_connect(G_OBJECT(fdm->rename_box), "clicked",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
532 G_CALLBACK(file_util_move_multiple_rename_cb), gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
533 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
534 gtk_widget_show(fdm->rename_box);
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 fdm->rename_entry = gtk_entry_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
537 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
538 gtk_widget_set_sensitive(fdm->rename_entry, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
539 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
540 gtk_widget_show(fdm->rename_entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
541
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
542 return gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
543 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
544
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
545 static void file_util_move_multiple(FileDataMult *fdm)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
546 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
547 while (fdm->dest || fdm->source_next)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
548 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
549 gint success = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
550 gint skip_file = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
551
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
552 if (!fdm->dest)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
553 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
554 GList *work = fdm->source_next;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
555 fdm->source = work->data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
556 fdm->dest = concat_dir_and_file(fdm->dest_base, filename_from_path(fdm->source));
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
557 fdm->source_next = work->next;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
558 fdm->confirmed = FALSE;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
559 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
560
3
gqview
parents: 1
diff changeset
561 if (fdm->dest && fdm->source && strcmp(fdm->dest, fdm->source) == 0)
gqview
parents: 1
diff changeset
562 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
563 if (!fdm->confirmed)
3
gqview
parents: 1
diff changeset
564 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
565 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
566 const gchar *title;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
567 gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
568
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
569 if (fdm->copy)
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 title = _("Source to copy matches destination");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
572 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
573 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
574 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
575 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
576 title = _("Source to move matches destination");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
577 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
578 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
579
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
580 gd = file_util_gen_dlg(title, "GQview", "dlg_confirm",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
581 NULL, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
582 file_util_move_multiple_cancel_cb, fdm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
583 generic_dialog_add_message(gd, GTK_STOCK_DIALOG_WARNING, title, text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
584 g_free(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
585 generic_dialog_add_button(gd, GTK_STOCK_GO_FORWARD, _("Co_ntinue"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
586 file_util_move_multiple_continue_cb, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
587
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
588 gtk_widget_show(gd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
589 return;
3
gqview
parents: 1
diff changeset
590 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
591 skip_file = TRUE;
3
gqview
parents: 1
diff changeset
592 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
593 else if (isfile(fdm->dest))
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
594 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
595 if (!fdm->confirmed && !fdm->confirm_all)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
596 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
597 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
598
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
599 gd = file_util_move_multiple_confirm_dialog(fdm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
600 gtk_widget_show(gd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
601 return;
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 if (fdm->skip) skip_file = TRUE;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
606 if (skip_file)
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 success = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
609 if (!fdm->confirm_all) fdm->skip = FALSE;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
610 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
611 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
612 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
613 gint try = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
614
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
615 if (fdm->confirm_all && fdm->rename_all && isfile(fdm->dest))
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
616 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
617 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
618 buf = unique_filename_simple(fdm->dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
619 if (buf)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
620 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
621 g_free(fdm->dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
622 fdm->dest = buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
623 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
624 else
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 try = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
627 }
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
628 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
629 if (try)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
630 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
631 if (fdm->copy)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
632 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
633 if (copy_file(fdm->source, fdm->dest))
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 success = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
636 file_maint_copied(fdm->source, fdm->dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
637 }
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
638 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
639 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
640 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
641 if (move_file(fdm->source, fdm->dest))
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
642 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
643 success = TRUE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
644 file_maint_moved(fdm->source, fdm->dest, fdm->source_list);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
645 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
646 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
647 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
648 }
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 if (!success)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
651 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
652 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
653 const gchar *title;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
654 gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
655
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
656 if (fdm->copy)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
657 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
658 title = _("Error copying file");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
659 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
660 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
661 else
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
662 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
663 title = _("Error moving file");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
664 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
665 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
666 gd = file_util_gen_dlg(title, "GQview", "dlg_confirm",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
667 NULL, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
668 file_util_move_multiple_cancel_cb, fdm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
669 generic_dialog_add_message(gd, GTK_STOCK_DIALOG_WARNING, title, text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
670 g_free(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
671
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
672 generic_dialog_add_button(gd, GTK_STOCK_GO_FORWARD, _("Co_ntinue"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
673 file_util_move_multiple_continue_cb, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
674 gtk_widget_show(gd->dialog);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
675 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
676
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
677 g_free(fdm->dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
678 fdm->dest = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
679
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
680 if (!success) return;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
681 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
682
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
683 file_data_multiple_free(fdm);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
684 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
685
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
686 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
687 * Single file move
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
688 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
689
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
690 static FileDataSingle *file_data_single_new(const gchar *source, const gchar *dest, gint copy)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
691 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
692 FileDataSingle *fds = g_new0(FileDataSingle, 1);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
693 fds->confirmed = FALSE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
694 fds->source = g_strdup(source);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
695 fds->dest = g_strdup(dest);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
696 fds->copy = copy;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
697 return fds;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
698 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
699
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
700 static void file_data_single_free(FileDataSingle *fds)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
701 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
702 g_free(fds->source);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
703 g_free(fds->dest);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
704 g_free(fds);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
705 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
706
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
707 static void file_util_move_single(FileDataSingle *fds);
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 static void file_util_move_single_ok_cb(GenericDialog *gd, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
710 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
711 FileDataSingle *fds = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
712
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
713 fds->confirmed = TRUE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
714
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
715 if (fds->rename_auto)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
716 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
717 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
718
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
719 buf = unique_filename_simple(fds->dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
720 if (buf)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
721 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
722 g_free(fds->dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
723 fds->dest = buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
724 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
725 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
726 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
727 /* unique failed? well, return to the overwrite prompt :( */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
728 fds->confirmed = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
729 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
730 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
731 else if (fds->rename)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
732 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
733 const gchar *name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
734
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
735 name = gtk_entry_get_text(GTK_ENTRY(fds->rename_entry));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
736 if (strlen(name) == 0 ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
737 strcmp(name, filename_from_path(fds->source)) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
738 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
739 fds->confirmed = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
740 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
741 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
742 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
743 gchar *base;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
744
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
745 base = remove_level_from_path(fds->dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
746 g_free(fds->dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
747 fds->dest = concat_dir_and_file(base, name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
748 fds->confirmed = !isname(fds->dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
749
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
750 g_free(base);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
751 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
752 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
753
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
754 file_util_move_single(fds);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
755 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
756
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
757 static void file_util_move_single_cancel_cb(GenericDialog *gd, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
758 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
759 FileDataSingle *fds = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
760
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
761 file_data_single_free(fds);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
762 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
763
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
764 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
765 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
766 GenericDialog *gd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
767 FileDataSingle *fds;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
768
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
769 fds = gd->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
770
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
771 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
772 gtk_widget_set_sensitive(fds->rename_box, !fds->rename_auto);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
773 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
774
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
775 if (fds->rename_auto)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
776 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
777 gchar *preview;
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 preview = unique_filename_simple(fds->dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
780 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
781 g_free(preview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
782 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
783 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
784
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
785 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
786 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
787 GenericDialog *gd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
788 FileDataSingle *fds;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
789
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
790 fds = gd->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
791
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
792 fds->rename = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
793 gtk_widget_set_sensitive(fds->rename_entry, fds->rename);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
794
42
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
795 if (fds->rename)
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
796 {
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
797 const gchar *name;
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
798
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
799 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
800
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
801 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
802 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
803 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
804 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
805
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
806 static void file_util_move_single(FileDataSingle *fds)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
807 {
3
gqview
parents: 1
diff changeset
808 if (fds->dest && fds->source && strcmp(fds->dest, fds->source) == 0)
gqview
parents: 1
diff changeset
809 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
810 file_util_warning_dialog(_("Source matches destination"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
811 _("Source and destination are the same, operation cancelled."),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
812 GTK_STOCK_DIALOG_INFO, NULL);
3
gqview
parents: 1
diff changeset
813 }
gqview
parents: 1
diff changeset
814 else if (isfile(fds->dest) && !fds->confirmed)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
815 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
816 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
817 GtkWidget *hbox;
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 gd = file_util_gen_dlg(_("Overwrite file"), "GQview", "dlg_confirm",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
820 NULL, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
821 file_util_move_single_cancel_cb, fds);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
822
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
823 generic_dialog_add_message(gd, GTK_STOCK_DIALOG_QUESTION,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
824 _("Overwrite file?"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
825 _("Replace existing file with new file."));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
826 pref_spacer(gd->vbox, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
827
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
828 generic_dialog_add_button(gd, GTK_STOCK_OK, _("_Overwrite"), file_util_move_single_ok_cb, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
829 generic_dialog_add_image(gd, fds->dest, _("Existing file"), fds->source, _("New file"), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
830
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
831 /* rename option */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
832
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
833 fds->rename = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
834 fds->rename_auto = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
835
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
836 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
837
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
838 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
839 g_signal_connect(G_OBJECT(fds->rename_auto_box), "clicked",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
840 G_CALLBACK(file_util_move_single_rename_auto_cb), gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
841 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
842 gtk_widget_show(fds->rename_auto_box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
843
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
844 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
845
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
846 fds->rename_box = gtk_check_button_new_with_label(_("Rename"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
847 g_signal_connect(G_OBJECT(fds->rename_box), "clicked",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
848 G_CALLBACK(file_util_move_single_rename_cb), gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
849 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
850 gtk_widget_show(fds->rename_box);
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 fds->rename_entry = gtk_entry_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
853 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
854 gtk_widget_set_sensitive(fds->rename_entry, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
855 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
856 gtk_widget_show(fds->rename_entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
857
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
858 gtk_widget_show(gd->dialog);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
859 return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
860 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
861 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
862 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
863 gint success = FALSE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
864 if (fds->copy)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
865 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
866 if (copy_file(fds->source, fds->dest))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
867 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
868 success = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
869 file_maint_copied(fds->source, fds->dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
870 }
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
871 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
872 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
873 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
874 if (move_file(fds->source, fds->dest))
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
875 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
876 success = TRUE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
877 file_maint_moved(fds->source, fds->dest, NULL);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
878 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
879 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
880 if (!success)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
881 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
882 gchar *title;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
883 gchar *text;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
884 if (fds->copy)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
885 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
886 title = _("Error copying file");
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
887 text = g_strdup_printf(_("Unable to copy file:\n%s\nto:\n%s"), fds->source, fds->dest);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
888 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
889 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
890 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
891 title = _("Error moving file");
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
892 text = g_strdup_printf(_("Unable to move file:\n%s\nto:\n%s"), fds->source, fds->dest);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
893 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
894 file_util_warning_dialog(title, text, GTK_STOCK_DIALOG_ERROR, NULL);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
895 g_free(text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
896 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
897 }
3
gqview
parents: 1
diff changeset
898
gqview
parents: 1
diff changeset
899 file_data_single_free(fds);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
900 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
901
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
902 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
903 * file move dialog
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
904 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
905
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
906 static void file_util_move_do(FileDialog *fd)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
907 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
908 file_dialog_sync_history(fd, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
909
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
910 if (fd->multiple_files)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
911 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
912 file_util_move_multiple(file_data_multiple_new(fd->source_list, fd->dest_path, fd->type));
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
913 fd->source_list = NULL;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
914 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
915 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
916 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
917 if (isdir(fd->dest_path))
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
918 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
919 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
920 gtk_entry_set_text(GTK_ENTRY(fd->entry), buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
921 g_free(buf);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
922 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
923 file_util_move_single(file_data_single_new(fd->source_path, fd->dest_path, fd->type));
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
924 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
925
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
926 file_dialog_close(fd);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
927 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
928
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
929 static void file_util_move_check(FileDialog *fd)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
930 {
42
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
931 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
932 {
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
933 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
934 }
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
935
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
936 if (fd->multiple_files && !isdir(fd->dest_path))
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
937 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
938 if (isfile(fd->dest_path))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
939 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
940 file_util_warning_dialog(_("Invalid destination"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
941 _("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
942 GTK_STOCK_DIALOG_INFO, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
943 }
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
944 else
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
945 file_util_warning_dialog(_("Invalid folder"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
946 _("Please select an existing folder."),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
947 GTK_STOCK_DIALOG_INFO, NULL);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
948 return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
949 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
950
42
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
951 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
952 {
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
953 if (fd->source_path)
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
954 {
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
955 gchar *base;
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
956 gchar *path;
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
957
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
958 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
959 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
960
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
961 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
962
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
963 g_free(path);
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
964 g_free(base);
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
965 }
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
966 return;
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
967 }
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
968
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
969 file_util_move_do(fd);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
970 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
971
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
972 static void file_util_move_cb(FileDialog *fd, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
973 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
974 file_util_move_check(fd);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
975 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
976
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
977 static void file_util_move_cancel_cb(FileDialog *fd, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
978 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
979 file_dialog_close(fd);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
980 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
981
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
982 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
983 const gchar *dest_path, gint copy, GtkWidget *parent)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
984 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
985 FileDialog *fd;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
986 GtkWidget *label;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
987 gchar *path = NULL;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
988 gint multiple;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
989 const gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
990 const gchar *title;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
991 const gchar *op_text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
992 const gchar *stock_id;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
993
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
994 if (!source_path && !source_list) return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
995
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
996 if (source_path)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
997 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
998 path = g_strdup(source_path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
999 multiple = FALSE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1000 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1001 else if (source_list->next)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1002 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1003 multiple = TRUE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1004 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1005 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1006 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1007 path = g_strdup(source_list->data);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1008 path_list_free(source_list);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1009 source_list = NULL;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1010 multiple = FALSE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1011 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1012
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1013 if (copy)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1014 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1015 title = _("Copy - GQview");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1016 op_text = _("_Copy");
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1017 if (path)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1018 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1019 text = _("Copy file");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1020 }
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1021 else
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1022 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1023 text = _("Copy multiple files");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1024 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1025 stock_id = GTK_STOCK_COPY;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1026 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1027 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1028 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1029 title = _("Move - GQview");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1030 op_text = _("_Move");
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1031 if (path)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1032 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1033 text = _("Move file");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1034 }
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1035 else
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1036 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1037 text = _("Move multiple files");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1038 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1039 stock_id = GTK_STOCK_OK;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1040 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1041
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1042 fd = file_util_file_dlg(title, "GQview", "dlg_copymove", parent,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1043 file_util_move_cancel_cb, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1044 generic_dialog_add_message(GENERIC_DIALOG(fd), NULL, text, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1045
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1046 if (path)
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 GtkWidget *box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1049
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1050 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
1051 pref_label_new(box, _("File name:"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1052 pref_label_new(box, filename_from_path(path));
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1055 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
1056 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1057 pref_spacer(GENERIC_DIALOG(fd)->vbox, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1058
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1059 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
1060
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1061 file_dialog_add_path_widgets(fd, NULL, dest_path, "move_copy", NULL, NULL);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1062
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1063 fd->type = copy;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1064 fd->source_path = path;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1065 fd->source_list = source_list;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1066 fd->multiple_files = multiple;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1067
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1068 gtk_widget_show(GENERIC_DIALOG(fd)->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1069 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1070
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1071 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
1072 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1073 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
1074 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1075
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1076 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
1077 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1078 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
1079 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1080
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1081 void file_util_move_simple(GList *list, const gchar *dest_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 if (!list) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1084 if (!dest_path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1085 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1086 path_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1087 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1088 }
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 if (!list->next)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1091 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1092 const gchar *source;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1093 gchar *dest;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1094
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1095 source = list->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1096 dest = concat_dir_and_file(dest_path, filename_from_path(source));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1097
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1098 file_util_move_single(file_data_single_new(source, dest, FALSE));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1099 g_free(dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1100 path_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1101 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1102 }
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 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
1105 }
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 void file_util_copy_simple(GList *list, const gchar *dest_path)
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 if (!list) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1110 if (!dest_path)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1111 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1112 path_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1113 return;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1116 if (!list->next)
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 const gchar *source;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1119 gchar *dest;
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 source = list->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1122 dest = concat_dir_and_file(dest_path, filename_from_path(source));
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 file_util_move_single(file_data_single_new(source, dest, TRUE));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1125 g_free(dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1126 path_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1127 return;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1128 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1129
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1130 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
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 /*
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 * Safe Delete
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1136 *--------------------------------------------------------------------------
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1139 static gint file_util_safe_number(gint64 free_space)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1140 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1141 gint n = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1142 gint64 total = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1143 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1144 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1145 gint sorted = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1146 gint warned = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1147
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1148 if (!filelist_read(safe_delete_path, &list, NULL)) return 0;
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 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1151 while (work)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1152 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1153 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1154 gint v;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1155
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1156 fd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1157 work = work->next;
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 v = (gint)strtol(fd->name, NULL, 10);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1160 if (v >= n) n = v + 1;
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 total += fd->size;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1163 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1164
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1165 while (list &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1166 (free_space < 0 || total + free_space > (gint64)safe_delete_size * 1048576) )
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 FileData *fd;
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 if (!sorted)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1171 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1172 list = filelist_sort(list, SORT_NAME, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1173 sorted = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1174 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1175
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1176 fd = list->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1177 list = g_list_remove(list, fd);
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 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
1180 if (!unlink_file(fd->path) && !warned)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1181 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1182 file_util_warning_dialog(_("Delete failed"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1183 _("Unable to remove old file from trash folder"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1184 GTK_STOCK_DIALOG_WARNING, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1185 warned = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1186 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1187 total -= fd->size;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1188 file_data_free(fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1189 }
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 filelist_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1192
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1193 return n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1194 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1195
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1196 void file_util_trash_clear(void)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1197 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1198 file_util_safe_number(-1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1199 }
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 static gchar *file_util_safe_dest(const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1202 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1203 gint n;
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 n = file_util_safe_number(filesize(path));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1206 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
1207 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1208
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1209 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
1210 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1211 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
1212 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1213
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1214 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
1215 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1216 GenericDialog **gd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1217
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1218 *gd = NULL;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1219 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1220
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1221 static gint file_util_unlink(const gchar *path)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1222 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1223 static GenericDialog *gd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1224 gchar *result = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1225 gint success = TRUE;
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 if (!isfile(path)) return FALSE;
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 if (!safe_delete_enable)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1230 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1231 return unlink_file(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1232 }
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 if (!isdir(safe_delete_path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1235 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1236 if (debug) printf("creating trash: %s\n", safe_delete_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1237 if (!safe_delete_path || !mkdir_utf8(safe_delete_path, 0755))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1238 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1239 result = _("Could not create folder");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1240 success = FALSE;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1244 if (success)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1245 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1246 gchar *dest;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1247
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1248 dest = file_util_safe_dest(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1249 if (dest)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1250 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1251 if (debug) printf("safe deleting %s to %s\n", path, dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1252 success = move_file(path, dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1253 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1254 else
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 success = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1257 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1258
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1259 if (!success && !access_file(path, W_OK))
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 result = _("Permission denied");
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 g_free(dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1264 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1265
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1266 if (result && !gd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1267 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1268 GtkWidget *button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1269 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1270
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1271 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
1272 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
1273 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1274
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1275 button = gtk_check_button_new_with_label(_("Turn off safe delete"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1276 g_signal_connect(G_OBJECT(button), "toggled",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1277 G_CALLBACK(file_util_safe_del_toggle_cb), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1278 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
1279 gtk_widget_show(button);
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 g_signal_connect(G_OBJECT(gd->dialog), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1282 G_CALLBACK(file_util_safe_del_close_cb), &gd);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1285 return success;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1286 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1287
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1288 static void box_append_safe_delete_status(GenericDialog *gd)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1289 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1290 GtkWidget *label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1291 gchar *buf;
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 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
1294 label = pref_label_new(gd->vbox, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1295 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1296
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1297 gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1298 gtk_widget_set_sensitive(label, FALSE);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1299 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1300
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1301 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1302 *--------------------------------------------------------------------------
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1303 * Delete routines
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1304 *--------------------------------------------------------------------------
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1305 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1306
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1307 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1308 * delete multiple files
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1309 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1310
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1311 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
1312 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
1313
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1314 static void file_util_delete_multiple_ok_cb(GenericDialog *gd, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1315 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1316 GList *source_list = data;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1317
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1318 while (source_list)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1319 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1320 gchar *path = source_list->data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1321
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1322 source_list = g_list_remove(source_list, path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1323
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1324 if (!file_util_unlink(path))
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1325 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1326 if (source_list)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1327 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1328 GenericDialog *d;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1329 gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1330
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1331 d = file_util_gen_dlg(_("Delete failed"), "GQview", "dlg_confirm",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1332 NULL, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1333 file_util_delete_multiple_cancel_cb, source_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1334
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1335 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
1336 generic_dialog_add_message(d, GTK_STOCK_DIALOG_WARNING, NULL, text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1337 g_free(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1338
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1339 generic_dialog_add_button(d, GTK_STOCK_GO_FORWARD, _("Co_ntinue"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1340 file_util_delete_multiple_ok_cb, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1341 gtk_widget_show(d->dialog);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1342 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1343 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1344 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1345 gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1346
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1347 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
1348 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
1349 g_free(text);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1350 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1351 g_free(path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1352 return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1353 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1354 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1355 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1356 file_maint_removed(path, source_list);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1357 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1358 g_free(path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1359 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1360 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1361
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1362 static void file_util_delete_multiple_cancel_cb(GenericDialog *gd, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1363 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1364 GList *source_list = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1365
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1366 path_list_free(source_list);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1367 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1368
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1369 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
1370 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1371 GtkWidget *button_back;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1372 GtkWidget *button_next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1373 GtkWidget *button_label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1374 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1375 GList *list_point;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1376 const gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1377 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1378
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1379 list = gd->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1380 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
1381 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
1382 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
1383 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
1384
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1385 if (!list || !button_label) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1386
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1387 if (list_point)
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 if (next)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1390 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1391 if (list_point->next) list_point = list_point->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1392 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1393 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1394 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1395 if (list_point->prev) list_point = list_point->prev;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1396 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1397 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1398 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1399 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1400 list_point = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1401 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1402
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1403 if (!list_point) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1404
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1405 path = list_point->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1406 buf = g_strdup_printf(_("File %d of %d"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1407 g_list_index(list, (gpointer)path) + 1,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1408 g_list_length(list));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1409 gtk_label_set_text(GTK_LABEL(button_label), buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1410 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1411
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1412 gtk_widget_set_sensitive(button_back, (list_point->prev != NULL) );
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1413 gtk_widget_set_sensitive(button_next, (list_point->next != NULL) );
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1414
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1415 generic_dialog_image_set(gd, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1416
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1417 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
1418 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1419
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1420 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
1421 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1422 GenericDialog *gd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1423
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1424 file_util_delete_multiple_review_skip(gd, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1425 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1426
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1427 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
1428 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1429 GenericDialog *gd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1430
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1431 file_util_delete_multiple_review_skip(gd, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1432 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1433
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1434 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
1435 gdouble x, gdouble y, guint state, gpointer data)
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 (button == 1)
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 file_util_delete_multiple_review_next(NULL, data);
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 else if (button == 2 || button == 3)
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 file_util_delete_multiple_review_back(NULL, data);
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 }
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 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
1448 gdouble x, gdouble y, guint state, gpointer data)
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 if (direction == GDK_SCROLL_UP)
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 file_util_delete_multiple_review_back(NULL, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1453 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1454 else if (direction == GDK_SCROLL_DOWN)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1455 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1456 file_util_delete_multiple_review_next(NULL, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1457 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1458 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1459
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1460 static void file_util_delete_multiple(GList *source_list, GtkWidget *parent)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1461 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1462 if (!confirm_delete)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1463 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1464 file_util_delete_multiple_ok_cb(NULL, source_list);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1465 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1466 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1467 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1468 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1469 GtkWidget *hbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1470 GtkWidget *button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1471 GtkWidget *label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1472 ImageWindow *imd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1473 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1474
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1475 gd = file_util_gen_dlg(_("Delete files - GQview"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1476 "GQview", "dlg_confirm", parent, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1477 file_util_delete_multiple_cancel_cb, source_list);
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 generic_dialog_add_message(gd, NULL, _("Delete multiple files"), NULL);
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 generic_dialog_add_image(gd, NULL, NULL, NULL, NULL, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1482 imd = g_object_get_data(G_OBJECT(gd->dialog), "img_image");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1483 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
1484 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
1485
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1486 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
1487
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1488 button = pref_button_new(hbox, GTK_STOCK_GO_BACK, NULL, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1489 G_CALLBACK(file_util_delete_multiple_review_back), gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1490 gtk_widget_set_sensitive(button, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1491 g_object_set_data(G_OBJECT(gd->dialog), "button_back", button);
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 button = pref_button_new(hbox, GTK_STOCK_GO_FORWARD, NULL, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1494 G_CALLBACK(file_util_delete_multiple_review_next), gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1495 g_object_set_data(G_OBJECT(gd->dialog), "button_next", button);
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 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
1498 label = pref_label_new(hbox, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1499 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1500 g_object_set_data(G_OBJECT(gd->dialog), "button_label", label);
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 box_append_safe_delete_status(gd);
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 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
1505
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1506 gtk_widget_show(gd->dialog);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1507 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1508 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1509
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1510 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1511 * delete single file
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1512 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1513
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1514 static void file_util_delete_ok_cb(GenericDialog *gd, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1515 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1516 gchar *path = data;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1517
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1518 if (!file_util_unlink(path))
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1519 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1520 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
1521 file_util_warning_dialog(_("File deletion failed"), text, GTK_STOCK_DIALOG_ERROR, NULL);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1522 g_free(text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1523 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1524 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1525 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1526 file_maint_removed(path, NULL);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1527 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1528
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1529 g_free(path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1530 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1531
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1532 static void file_util_delete_cancel_cb(GenericDialog *gd, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1533 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1534 gchar *path = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1535
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1536 g_free(path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1537 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1538
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1539 static void file_util_delete_single(const gchar *path, GtkWidget *parent)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1540 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1541 gchar *buf = g_strdup(path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1542
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1543 if (!confirm_delete)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1544 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1545 file_util_delete_ok_cb(NULL, buf);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1546 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1547 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1548 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1549 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1550 GtkWidget *table;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1551 gchar *base;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1552
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1553 gd = file_util_gen_dlg(_("Delete file - GQview"), "GQview", "dlg_confirm",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1554 parent, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1555 file_util_delete_cancel_cb, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1556
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1557 generic_dialog_add_message(gd, NULL, _("Delete file?"), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1558
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1559 table = pref_table_new(gd->vbox, 2, 2, FALSE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1560
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1561 pref_table_label(table, 0, 0, _("File name:"), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1562 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
1563
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1564 pref_table_label(table, 0, 1, _("Location:"), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1565
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1566 base = remove_level_from_path(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1567 pref_table_label(table, 1, 1, base, 0.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1568 g_free(base);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1569
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1570 generic_dialog_add_image(gd, path, NULL, NULL, NULL, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1571
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1572 box_append_safe_delete_status(gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1573
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1574 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
1575
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1576 gtk_widget_show(gd->dialog);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1577 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1578 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1579
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1580 void file_util_delete(const gchar *source_path, GList *source_list, GtkWidget *parent)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1581 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1582 if (!source_path && !source_list) return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1583
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1584 if (source_path)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1585 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1586 file_util_delete_single(source_path, parent);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1587 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1588 else if (!source_list->next)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1589 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1590 file_util_delete_single(source_list->data, parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1591 path_list_free(source_list);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1592 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1593 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1594 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1595 file_util_delete_multiple(source_list, parent);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1596 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1597 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1598
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1599 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1600 *--------------------------------------------------------------------------
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1601 * Rename routines
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1602 *--------------------------------------------------------------------------
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1603 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1604
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1605 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1606 * rename multiple files
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1607 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1608
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1609 enum {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1610 RENAME_COLUMN_PATH = 0,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1611 RENAME_COLUMN_NAME,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1612 RENAME_COLUMN_PREVIEW,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1613 RENAME_COLUMN_COUNT
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1614 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1615
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1616 typedef enum {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1617 RENAME_TYPE_MANUAL = 0,
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1618 RENAME_TYPE_FORMATTED,
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1619 RENAME_TYPE_AUTO
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1620 } RenameType;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1621
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1622 typedef struct _RenameDataMult RenameDataMult;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1623 struct _RenameDataMult
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1624 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1625 FileDialog *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1626
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1627 RenameType rename_type;
9
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 GtkWidget *listview;
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1630 GtkWidget *combo_type;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1631
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1632 GtkWidget *rename_box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1633 GtkWidget *rename_label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1634 GtkWidget *rename_entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1635
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1636 GtkWidget *auto_box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1637 GtkWidget *auto_entry_front;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1638 GtkWidget *auto_spin_start;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1639 GtkWidget *auto_spin_pad;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1640 GtkWidget *auto_entry_end;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1641
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1642 GtkWidget *format_box;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1643 GtkWidget *format_entry;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1644 GtkWidget *format_spin;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1645
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1646 ImageWindow *imd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1647
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1648 gint update_idle_id;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1649 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1650
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1651 static void file_util_rename_multiple(RenameDataMult *rd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1652
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1653 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
1654 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1655 RenameDataMult *rd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1656 GtkWidget *dialog;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1657
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1658 dialog = GENERIC_DIALOG(rd->fd)->dialog;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1659 if (!GTK_WIDGET_VISIBLE(dialog)) gtk_widget_show(dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1660
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1661 rd->fd->type = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1662 file_util_rename_multiple(rd);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1663 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1664
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1665 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
1666 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1667 RenameDataMult *rd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1668 GtkWidget *dialog;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1669
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1670 dialog = GENERIC_DIALOG(rd->fd)->dialog;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1671 if (!GTK_WIDGET_VISIBLE(dialog)) gtk_widget_show(dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1672 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1673
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1674 static gint file_util_rename_multiple_find_row(RenameDataMult *rd, const gchar *path, GtkTreeIter *iter)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1675 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1676 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1677 gint valid;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1678 gint row = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1679
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1680 store = gtk_tree_view_get_model(GTK_TREE_VIEW(rd->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1681 valid = gtk_tree_model_get_iter_first(store, iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1682 while (valid)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1683 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1684 gchar *path_n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1685 gint ret;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1686
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1687 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
1688 ret = (strcmp(path_n, path) == 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1689 g_free(path_n);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1690 if (ret) return row;
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 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1693 row++;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1696 return -1;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1697 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1698
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1699 static void file_util_rename_multiple(RenameDataMult *rd)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1700 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1701 FileDialog *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1702
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1703 fd = rd->fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1704
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1705 if (isfile(fd->dest_path) && !fd->type)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1706 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1707 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1708
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1709 gd = file_util_gen_dlg(_("Overwrite file"), "GQview", "dlg_confirm",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1710 NULL, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1711 file_util_rename_multiple_cancel_cb, rd);
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 generic_dialog_add_message(gd, GTK_STOCK_DIALOG_QUESTION,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1714 _("Overwrite file?"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1715 _("Replace existing file by renaming new file."));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1716 pref_spacer(gd->vbox, 0);
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 generic_dialog_add_button(gd, GTK_STOCK_OK, _("_Overwrite"), file_util_rename_multiple_ok_cb, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1719 generic_dialog_add_image(gd, fd->dest_path, _("Existing file"), fd->source_path, _("New file"), TRUE);
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 gtk_widget_hide(GENERIC_DIALOG(fd)->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1722
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1723 gtk_widget_show(gd->dialog);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1724 return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1725 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1726 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1727 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1728 if (!rename_file(fd->source_path, fd->dest_path))
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1729 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1730 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
1731 filename_from_path(fd->source_path),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1732 filename_from_path(fd->dest_path));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1733 file_util_warning_dialog(_("Error renaming file"), text, GTK_STOCK_DIALOG_ERROR, NULL);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1734 g_free(text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1735 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1736 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1737 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1738 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1739 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1740 GtkTreeIter next;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1741 gint row;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1742
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1743 file_maint_renamed(fd->source_path, fd->dest_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1744
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1745 store = gtk_tree_view_get_model(GTK_TREE_VIEW(rd->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1746 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
1747
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1748 if (row >= 0 &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1749 (gtk_tree_model_iter_nth_child(store, &next, NULL, row + 1) ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1750 (row > 0 && gtk_tree_model_iter_nth_child(store, &next, NULL, row - 1)) ) )
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1751 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1752 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1753
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1754 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(rd->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1755 gtk_tree_selection_select_iter(selection, &next);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1756 gtk_list_store_remove(GTK_LIST_STORE(store), &iter);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1757 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1758 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1759 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1760 if (debug) printf("closed by #%d\n", row);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1761
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1762 file_dialog_close(rd->fd);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1763 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1764 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1765 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1766 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1767
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1768 /* 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
1769 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
1770 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1771 gchar *new_name;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1772 gchar *parsed;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1773 const gchar *ext;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1774 gchar *middle;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1775 gchar *tmp;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1776 gchar *pad_start;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1777 gchar *pad_end;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1778 gint padding;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1779
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1780 if (!format || !name) return NULL;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1781
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1782 tmp = g_strdup(format);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1783 pad_start = strchr(tmp, '#');
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1784 if (pad_start)
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1785 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1786 pad_end = pad_start;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1787 padding = 0;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1788 while (*pad_end == '#')
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1789 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1790 pad_end++;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1791 padding++;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1792 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1793 *pad_start = '\0';
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1794
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1795 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
1796 g_free(tmp);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1797 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1798 else
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1799 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1800 parsed = tmp;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1801 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1802
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1803 ext = extension_from_path(name);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1804
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1805 middle = strchr(parsed, '*');
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1806 if (middle)
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1807 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1808 gchar *base;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1809
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1810 *middle = '\0';
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1811 middle++;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1812
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1813 base = remove_extension_from_path(name);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1814 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
1815 g_free(base);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1816 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1817 else
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1818 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1819 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
1820 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1821
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1822 g_free(parsed);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1823
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1824 return new_name;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1825 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1826
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1827 static void file_util_rename_multiple_auto(RenameDataMult *rd)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1828 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1829 const gchar *front;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1830 const gchar *end;
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1831 const gchar *format;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1832 gint start_n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1833 gint padding;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1834 gint n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1835 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1836 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1837 gint valid;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1838 gint success;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1839
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1840 front = gtk_entry_get_text(GTK_ENTRY(rd->auto_entry_front));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1841 end = gtk_entry_get_text(GTK_ENTRY(rd->auto_entry_end));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1842 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
1843
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1844 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
1845
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1846 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
1847 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1848 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
1849
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1850 if (!format ||
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1851 (strchr(format, '*') == NULL && strchr(format, '#') == NULL))
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1852 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1853 file_util_warning_dialog(_("Auto rename"),
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1854 _("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
1855 GTK_STOCK_DIALOG_WARNING, NULL);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1856 return;
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
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1859 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
1860 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1861 else
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 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
1864
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1865 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
1866 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
1867 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1868
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1869 store = gtk_tree_view_get_model(GTK_TREE_VIEW(rd->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1870
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1871 /* first check for name conflicts */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1872 success = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1873 n = start_n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1874 valid = gtk_tree_model_get_iter_first(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1875 while (valid && success)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1876 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1877 gchar *dest;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1878 gchar *base;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1879 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1880
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1881 gtk_tree_model_get(store, &iter, RENAME_COLUMN_PATH, &path, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1882 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
1883
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1884 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
1885 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1886 gchar *new_name;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1887
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1888 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
1889 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
1890 g_free(new_name);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1891 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1892 else
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1893 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1894 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
1895 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1896
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1897 if (isname(dest)) success = FALSE;
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1898
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1899 g_free(dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1900 g_free(base);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1901 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1902
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1903 n++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1904 valid = gtk_tree_model_iter_next(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1905 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1906
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1907 if (!success)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1908 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1909 file_util_warning_dialog(_("Auto rename"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1910 _("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
1911 GTK_STOCK_DIALOG_WARNING, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1912 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1913 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1914
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1915 /* 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
1916 if (gtk_tree_model_get_iter_first(store, &iter))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1917 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1918 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1919
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1920 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(rd->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1921 gtk_tree_selection_select_iter(selection, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1922 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1923
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1924 /* now do it for real */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1925 success = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1926 n = start_n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1927 while (success && gtk_tree_model_get_iter_first(store, &iter))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1928 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1929 gchar *dest;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1930 gchar *base;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1931 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1932
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1933 gtk_tree_model_get(store, &iter, RENAME_COLUMN_PATH, &path, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1934 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
1935
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1936 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
1937 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1938 gchar *new_name;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1939
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1940 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
1941 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
1942 g_free(new_name);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1943 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1944 else
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1945 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1946 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
1947 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1948
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1949 if (!rename_file(path, dest))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1950 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1951 success = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1952 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1953 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1954 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1955 file_maint_renamed(path, dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1956 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1957
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1958 g_free(dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1959 g_free(base);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1960 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1961
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1962 if (success)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1963 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1964 gtk_list_store_remove(GTK_LIST_STORE(store), &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1965 if (gtk_tree_model_get_iter_first(store, &iter))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1966 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1967 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1968
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1969 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(rd->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1970 gtk_tree_selection_select_iter(selection, &iter);
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 }
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 n++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1975 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1976
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1977 if (!success)
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 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1980
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1981 n--;
15
3263965d5f9e ##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents: 9
diff changeset
1982 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
1983
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1984 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
1985 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
1986 g_free(buf);
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 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1989 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1990
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1991 file_dialog_close(rd->fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1992 }
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 static void file_util_rename_multiple_cb(FileDialog *fd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1995 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1996 RenameDataMult *rd = data;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1997 gchar *base;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1998 const gchar *name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1999
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2000 if (rd->rename_type != RENAME_TYPE_MANUAL)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2001 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2002 file_util_rename_multiple_auto(rd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2003 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2004 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2005
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2006 name = gtk_entry_get_text(GTK_ENTRY(rd->rename_entry));
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2007 base = remove_level_from_path(fd->source_path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2008
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2009 g_free(fd->dest_path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2010 fd->dest_path = concat_dir_and_file(base, name);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2011 g_free(base);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2012
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2013 if (strlen(name) == 0 || strcmp(fd->source_path, fd->dest_path) == 0)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2014 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2015 return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2016 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2017
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2018 fd->type = FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2019 file_util_rename_multiple(rd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2020 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2021
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2022 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
2023 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2024 RenameDataMult *rd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2025
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2026 file_dialog_close(rd->fd);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2027 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2028
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2029 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
2030 gboolean path_currently_selected, gpointer data)
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 RenameDataMult *rd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2033 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2034 const gchar *name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2035 gchar *path = NULL;
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 if (path_currently_selected ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2038 !gtk_tree_model_get_iter(store, &iter, tpath)) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2039 gtk_tree_model_get(store, &iter, RENAME_COLUMN_PATH, &path, -1);
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 g_free(rd->fd->source_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2042 rd->fd->source_path = path;
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 name = filename_from_path(rd->fd->source_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2045 gtk_label_set_text(GTK_LABEL(rd->rename_label), name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2046 gtk_entry_set_text(GTK_ENTRY(rd->rename_entry), name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2047
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2048 image_change_path(rd->imd, rd->fd->source_path, 0.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2049
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2050 if (GTK_WIDGET_VISIBLE(rd->rename_box))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2051 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2052 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
2053 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
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 return TRUE;
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_preview_update(RenameDataMult *rd)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2060 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2061 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2062 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2063 const gchar *front;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2064 const gchar *end;
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2065 const gchar *format;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2066 gint valid;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2067 gint start_n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2068 gint padding;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2069 gint n;
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 front = gtk_entry_get_text(GTK_ENTRY(rd->auto_entry_front));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2072 end = gtk_entry_get_text(GTK_ENTRY(rd->auto_entry_end));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2073 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
2074
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2075 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
2076
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2077 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
2078 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2079 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
2080 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2081 else
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2082 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2083 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
2084 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2085
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2086 store = gtk_tree_view_get_model(GTK_TREE_VIEW(rd->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2087 n = start_n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2088 valid = gtk_tree_model_get_iter_first(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2089 while (valid)
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 gchar *dest;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2092
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2093 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
2094 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2095 gchar *path;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2096
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2097 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
2098 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
2099 g_free(path);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2100 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2101 else
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2102 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2103 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
2104 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2105 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
2106 g_free(dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2107
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2108 n++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2109 valid = gtk_tree_model_iter_next(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2110 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2111
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2112 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2113
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2114 static gboolean file_util_rename_multiple_idle_cb(gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2115 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2116 RenameDataMult *rd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2117
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2118 file_util_rename_multiple_preview_update(rd);
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 rd->update_idle_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2121 return FALSE;
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_order_cb(GtkTreeModel *treemodel, GtkTreePath *tpath,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2125 GtkTreeIter *iter, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2126 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2127 RenameDataMult *rd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2128
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2129 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
2130 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2131 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
2132 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2133 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2134
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2135 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
2136 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2137 RenameDataMult *rd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2138 file_util_rename_multiple_preview_update(rd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2139 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2140
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2141 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
2142 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2143 RenameDataMult *rd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2144 file_util_rename_multiple_preview_update(rd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2145 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2146
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2147 static void file_util_rename_multiple_auto_change(GtkWidget *widget, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2148 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2149 RenameDataMult *rd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2150 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2151
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2152 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
2153
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2154 switch (rd->rename_type)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2155 {
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2156 case RENAME_TYPE_FORMATTED:
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2157 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
2158 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
2159 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
2160 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
2161 break;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2162 case RENAME_TYPE_AUTO:
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2163 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
2164 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
2165 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
2166 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
2167 break;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2168 case RENAME_TYPE_MANUAL:
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2169 default:
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2170 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
2171 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
2172 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
2173 break;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2174 }
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 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
2177 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
2178 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2179
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2180 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
2181 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2182 GtkWidget *vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2183 GtkWidget *label;
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 vbox = gtk_vbox_new(FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2186 gtk_box_pack_start(GTK_BOX(box), vbox, expand, expand, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2187 gtk_widget_show(vbox);
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 label = gtk_label_new(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2190 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2191 gtk_widget_show(label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2192
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2193 return vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2194 }
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 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
2197 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2198 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2199 GtkCellRenderer *renderer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2200
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2201 column = gtk_tree_view_column_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2202 gtk_tree_view_column_set_title(column, text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2203 gtk_tree_view_column_set_min_width(column, 4);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2204 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
2205 renderer = gtk_cell_renderer_text_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2206 gtk_tree_view_column_pack_start(column, renderer, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2207 gtk_tree_view_column_add_attribute(column, renderer, "text", n);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2208 gtk_tree_view_append_column(GTK_TREE_VIEW(rd->listview), column);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2209
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2210 return column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2211 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2212
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2213 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
2214 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2215 RenameDataMult *rd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2216
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2217 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
2218
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2219 g_free(rd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2220 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2221
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2222 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
2223 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2224 RenameDataMult *rd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2225 GtkWidget *pane;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2226 GtkWidget *scrolled;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2227 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2228 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2229 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2230 GtkWidget *hbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2231 GtkWidget *vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2232 GtkWidget *box2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2233 GtkWidget *table;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2234 GtkWidget *combo;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2235 GList *work;
42
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
2236 const gchar *name;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2237
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2238 rd = g_new0(RenameDataMult, 1);
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 rd->fd = file_util_file_dlg(_("Rename - GQview"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2241 "GQview", "dlg_rename", parent,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2242 file_util_rename_multiple_close_cb, rd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2243 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
2244 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
2245
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2246 rd->fd->source_path = g_strdup(source_list->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2247 rd->fd->dest_path = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2248
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2249 rd->rename_type = RENAME_TYPE_MANUAL;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2250
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2251 rd->update_idle_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2252
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2253 vbox = GENERIC_DIALOG(rd->fd)->vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2254
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2255 pane = gtk_hpaned_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2256 gtk_box_pack_start(GTK_BOX(vbox), pane, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2257 gtk_widget_show(pane);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2258
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2259 scrolled = gtk_scrolled_window_new(NULL, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2260 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
2261 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scrolled),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2262 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2263 gtk_paned_pack1(GTK_PANED(pane), scrolled, TRUE, TRUE);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2264 gtk_widget_show(scrolled);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2265
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2266 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
2267 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
2268 g_object_unref(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2269
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2270 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(rd->listview), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2271 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
2272
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2273 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(rd->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2274 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
2275 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
2276
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2277 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
2278 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
2279 gtk_tree_view_column_set_visible(column, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2280
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2281 gtk_tree_view_set_reorderable(GTK_TREE_VIEW(rd->listview), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2282 g_signal_connect(G_OBJECT(store), "row_changed",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2283 G_CALLBACK(file_util_rename_multiple_preview_order_cb), rd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2284 gtk_widget_set_size_request(rd->listview, 250, 150);
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 gtk_container_add(GTK_CONTAINER(scrolled), rd->listview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2287 gtk_widget_show(rd->listview);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2288
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2289 work = source_list;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2290 while (work)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2291 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2292 gchar *path = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2293 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2294
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2295 gtk_list_store_append(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2296 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
2297
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2298 work = work->next;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2299 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2300
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2301 path_list_free(source_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2302
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2303 rd->imd = image_new(TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2304 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
2305 gtk_paned_pack2(GTK_PANED(pane), rd->imd->widget, FALSE, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2306 gtk_widget_show(rd->imd->widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2307
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2308 hbox = gtk_hbox_new(FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2309 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2310 gtk_widget_show(hbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2311
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2312 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
2313
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2314 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
2315 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
2316 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
2317
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2318 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
2319
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2320 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
2321 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
2322 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
2323 gtk_widget_show(rd->combo_type);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2324
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2325 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
2326 table = pref_table_new(rd->rename_box, 2, 2, FALSE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2327
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2328 pref_table_label(table, 0, 0, _("Original name:"), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2329 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
2330
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2331 pref_table_label(table, 0, 1, _("New name:"), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2332
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2333 rd->rename_entry = gtk_entry_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2334 gtk_table_attach(GTK_TABLE(table), rd->rename_entry, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, FALSE, 0, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2335 generic_dialog_attach_default(GENERIC_DIALOG(rd->fd), rd->rename_entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2336 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
2337
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
2338 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
2339 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
2340 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
2341 gtk_widget_show(rd->rename_entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2342
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2343 rd->auto_box = gtk_vbox_new(FALSE, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2344 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
2345 /* do not show it here */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2346
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2347 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
2348
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2349 box2 = furm_simple_vlabel(hbox, _("Begin text"), TRUE);
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 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
2352 g_signal_connect(G_OBJECT(rd->auto_entry_front), "changed",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2353 G_CALLBACK(file_util_rename_multiple_preview_entry_cb), rd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2354 gtk_box_pack_start(GTK_BOX(box2), combo, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2355 gtk_widget_show(combo);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2356
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2357 box2 = furm_simple_vlabel(hbox, _("Start #"), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2358
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2359 rd->auto_spin_start = pref_spin_new(box2, NULL, NULL,
67
f63ecca6c087 Fri Oct 13 05:22:43 2006 John Ellis <johne@verizon.net>
gqview
parents: 66
diff changeset
2360 1.0, 1000000.0, 1.0, 0, 0.0,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2361 G_CALLBACK(file_util_rename_multiple_preview_adj_cb), rd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2362
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2363 box2 = furm_simple_vlabel(hbox, _("End text"), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2364
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2365 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
2366 g_signal_connect(G_OBJECT(rd->auto_entry_end), "changed",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2367 G_CALLBACK(file_util_rename_multiple_preview_entry_cb), rd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2368 gtk_box_pack_start(GTK_BOX(box2), combo, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2369 gtk_widget_show(combo);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2370
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2371 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
2372 1.0, 8.0, 1.0, 0, 1.0,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2373 G_CALLBACK(file_util_rename_multiple_preview_adj_cb), rd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2374
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2375 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
2376 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
2377 /* do not show it here */
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2378
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2379 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
2380
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2381 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
2382
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2383 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
2384 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
2385 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
2386 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
2387 gtk_widget_show(combo);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2388
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2389 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
2390
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2391 rd->format_spin = pref_spin_new(box2, NULL, NULL,
67
f63ecca6c087 Fri Oct 13 05:22:43 2006 John Ellis <johne@verizon.net>
gqview
parents: 66
diff changeset
2392 1.0, 1000000.0, 1.0, 0, 0.0,
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
2393 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
2394
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2395 image_change_path(rd->imd, 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 g_signal_connect(G_OBJECT(GENERIC_DIALOG(rd->fd)->dialog), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2398 G_CALLBACK(file_util_rename_multiple_destroy_cb), rd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2399
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2400 gtk_widget_show(GENERIC_DIALOG(rd->fd)->dialog);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2401 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2402
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2403 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2404 * rename single file
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2405 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2406
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2407 static void file_util_rename_single(FileDataSingle *fds);
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 static void file_util_rename_single_ok_cb(GenericDialog *gd, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2410 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2411 FileDataSingle *fds = data;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2412 fds->confirmed = TRUE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2413 file_util_rename_single(fds);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2414 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2415
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2416 static void file_util_rename_single_cancel_cb(GenericDialog *gd, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2417 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2418 FileDataSingle *fds = data;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2419 file_data_single_free(fds);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2420 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2421
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2422 static void file_util_rename_single(FileDataSingle *fds)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2423 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2424 if (isfile(fds->dest) && !fds->confirmed)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2425 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2426 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2427
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2428 gd = file_util_gen_dlg(_("Overwrite file"), "GQview", "dlg_confirm",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2429 NULL, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2430 file_util_rename_single_cancel_cb, fds);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2431
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2432 generic_dialog_add_message(gd, GTK_STOCK_DIALOG_QUESTION,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2433 _("Overwrite file?"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2434 _("Replace existing file by renaming new file."));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2435 pref_spacer(gd->vbox, 0);
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 generic_dialog_add_button(gd, GTK_STOCK_OK, _("_Overwrite"), file_util_rename_single_ok_cb, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2438 generic_dialog_add_image(gd, fds->dest, _("Existing file"), fds->source, _("New file"), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2439
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2440 gtk_widget_show(gd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2441
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2442 return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2443 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2444 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2445 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2446 if (!rename_file(fds->source, fds->dest))
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2447 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2448 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
2449 file_util_warning_dialog(_("Error renaming file"), text, GTK_STOCK_DIALOG_ERROR, NULL);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2450 g_free(text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2451 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2452 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2453 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2454 file_maint_renamed(fds->source, fds->dest);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2455 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2456 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2457 file_data_single_free(fds);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2458 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2459
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2460 static void file_util_rename_single_cb(FileDialog *fd, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2461 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2462 const gchar *name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2463 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2464
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2465 name = gtk_entry_get_text(GTK_ENTRY(fd->entry));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2466 path = concat_dir_and_file(fd->dest_path, name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2467
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2468 if (strlen(name) == 0 || strcmp(fd->source_path, path) == 0)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2469 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2470 g_free(path);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2471 return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2472 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2473
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2474 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
2475
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2476 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2477 file_dialog_close(fd);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2478 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2479
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2480 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
2481 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2482 file_dialog_close(fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2483 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2484
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2485 static void file_util_rename_single_do(const gchar *source_path, GtkWidget *parent)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2486 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2487 FileDialog *fd;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2488 GtkWidget *table;
42
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
2489 const gchar *name;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2490
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2491 fd = file_util_file_dlg(_("Rename - GQview"), "GQview", "dlg_rename", parent,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2492 file_util_rename_single_close_cb, NULL);
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 generic_dialog_add_message(GENERIC_DIALOG(fd), NULL, _("Rename file"), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2495 generic_dialog_add_image(GENERIC_DIALOG(fd), source_path, NULL, NULL, NULL, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2496
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2497 file_dialog_add_button(fd, GTK_STOCK_OK, _("_Rename"), file_util_rename_single_cb, TRUE);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2498
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2499 fd->source_path = g_strdup(source_path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2500 fd->dest_path = remove_level_from_path(source_path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2501
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2502 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
2503
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2504 pref_table_label(table, 0, 0, _("Original name:"), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2505 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
2506
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2507 pref_table_label(table, 0, 1, _("New name:"), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2508
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2509 fd->entry = gtk_entry_new();
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2510 gtk_table_attach(GTK_TABLE(table), fd->entry, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, FALSE, 0, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2511 generic_dialog_attach_default(GENERIC_DIALOG(fd), fd->entry);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2512 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
2513
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
2514 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
2515 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
2516 gtk_editable_select_region(GTK_EDITABLE(fd->entry), 0, filename_base_length(name));
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2517 gtk_widget_show(fd->entry);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2518
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2519 gtk_widget_show(GENERIC_DIALOG(fd)->dialog);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2520 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2521
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2522 void file_util_rename(const gchar *source_path, GList *source_list, GtkWidget *parent)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2523 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2524 if (!source_path && !source_list) return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2525
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2526 if (source_path)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2527 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2528 file_util_rename_single_do(source_path, parent);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2529 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2530 else if (!source_list->next)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2531 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2532 file_util_rename_single_do(source_list->data, parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2533 path_list_free(source_list);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2534 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2535 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2536 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2537 file_util_rename_multiple_do(source_list, parent);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2538 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2539 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2540
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2541 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2542 *--------------------------------------------------------------------------
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2543 * Create directory routines
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2544 *--------------------------------------------------------------------------
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2545 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2546
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2547 static void file_util_create_dir_do(const gchar *base, const gchar *name)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2548 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2549 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2550
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2551 path = concat_dir_and_file(base, name);
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 if (isdir(path))
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2554 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2555 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
2556 file_util_warning_dialog(_("Folder exists"), text, GTK_STOCK_DIALOG_INFO, NULL);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2557 g_free(text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2558 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2559 else if (isname(path))
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2560 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2561 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
2562 file_util_warning_dialog(_("Could not create folder"), text, GTK_STOCK_DIALOG_INFO, NULL);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2563 g_free(text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2564 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2565 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2566 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2567 if (!mkdir_utf8(path, 0755))
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2568 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2569 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
2570 file_util_warning_dialog(_("Error creating folder"), text, GTK_STOCK_DIALOG_ERROR, NULL);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2571 g_free(text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2572 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2573 }
9
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 g_free(path);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2576 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2577
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2578 static void file_util_create_dir_cb(FileDialog *fd, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2579 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2580 const gchar *name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2581
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2582 name = gtk_entry_get_text(GTK_ENTRY(fd->entry));
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2583
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2584 if (strlen(name) == 0) return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2585
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2586 if (name[0] == '/')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2587 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2588 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2589 buf = remove_level_from_path(name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2590 file_util_create_dir_do(buf, filename_from_path(name));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2591 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2592 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2593 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2594 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2595 file_util_create_dir_do(fd->dest_path, name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2596 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2597
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2598 file_dialog_close(fd);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2599 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2600
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2601 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
2602 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2603 file_dialog_close(fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2604 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2605
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2606 void file_util_create_dir(const gchar *path, GtkWidget *parent)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2607 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2608 FileDialog *fd;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2609 gchar *text;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2610
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2611 if (!isdir(path)) return;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2612
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2613 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
2614 file_util_create_dir_close_cb, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2615
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2616 text = g_strdup_printf(_("Create folder in:\n%s\nnamed:"), path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2617 generic_dialog_add_message(GENERIC_DIALOG(fd), NULL, NULL, text);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2618 g_free(text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2619
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2620 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
2621
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2622 fd->dest_path = g_strdup(path);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2623
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2624 fd->entry = gtk_entry_new();
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2625 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
2626 generic_dialog_attach_default(GENERIC_DIALOG(fd), fd->entry);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2627 gtk_widget_grab_focus(fd->entry);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2628 gtk_widget_show(fd->entry);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2629
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2630 gtk_widget_show(GENERIC_DIALOG(fd)->dialog);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2631 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2632
44
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2633 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
2634 {
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2635 const gchar *old_name;
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2636 const gchar *new_name;
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2637
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2638 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
2639
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2640 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
2641 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
2642
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2643 if (isdir(new_path))
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2644 {
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2645 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
2646 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
2647 g_free(text);
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2648
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2649 return FALSE;
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2650 }
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2651
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2652 if (isname(new_path))
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2653 {
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2654 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
2655 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
2656 g_free(text);
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2657
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2658 return FALSE;
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2659 }
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2660
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2661 if (!rename_file(old_path, new_path))
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2662 {
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2663 gchar *text = g_strdup_printf(_("Failed to rename %s to %s."), old_name, new_name);
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2664 file_util_warning_dialog("Rename failed", text, GTK_STOCK_DIALOG_ERROR, parent);
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2665 g_free(text);
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2666
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2667 return FALSE;
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2668 }
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2669
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2670 return TRUE;
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2671 }
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2672