annotate src/utilops.c @ 1:b3e0e515fabf

Initial revision
author gqview
date Mon, 03 Apr 2000 18:24:05 +0000
parents
children c0e337a01cb7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2 * GQview image viewer
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
3 * (C)1999 John Ellis
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 *
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
7 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
8
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
9 #include "gqview.h"
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
10
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
11 enum {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
12 DIALOG_NEW_DIR,
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
13 DIALOG_COPY,
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
14 DIALOG_MOVE,
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
15 DIALOG_DELETE,
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
16 DIALOG_RENAME
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
17 };
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
18
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
19 typedef struct _FileDataMult FileDataMult;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
20 struct _FileDataMult
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
21 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
22 gint confirm_all;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
23 gint confirmed;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
24 gint skip;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
25 GList *source_list;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
26 GList *source_next;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
27 gchar *dest_base;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
28 gchar *source;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
29 gchar *dest;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
30 gint copy;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
31 };
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
32
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
33 typedef struct _FileDataSingle FileDataSingle;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
34 struct _FileDataSingle
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
35 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
36 gint confirmed;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
37 gchar *source;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
38 gchar *dest;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
39 gint copy;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
40 };
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
41
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
42 static FileDataMult *file_data_multiple_new(GList *source_list, gchar *dest, gint copy);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
43 static void file_data_multiple_free(FileDataMult *fdm);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
44 static void file_util_move_multiple(FileDataMult *fdm);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
45 static void file_util_move_multiple_ok_cb(GtkWidget *widget, gpointer data);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
46 static void file_util_move_multiple_all_cb(GtkWidget *widget, gpointer data);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
47 static void file_util_move_multiple_skip_cb(GtkWidget *widget, gpointer data);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
48 static void file_util_move_multiple_cancel_cb(GtkWidget *widget, gpointer data);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
49 static void file_util_move_multiple(FileDataMult *fdm);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
50
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
51 static FileDataSingle *file_data_single_new(gchar *source, gchar *dest, gint copy);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
52 static void file_data_single_free(FileDataSingle *fds);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
53 static void file_util_move_single_ok_cb(GtkWidget *widget, gpointer data);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
54 static void file_util_move_single(FileDataSingle *fds);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
55 static void file_util_move_single_cancel_cb(GtkWidget *widget, gpointer data);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
56 static void file_util_move_do(FileDialog *fd);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
57 static void file_util_move_check(FileDialog *fd);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
58 static void file_util_move_cb(GtkWidget *widget, gpointer data);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
59 static void file_util_move_enter_cb(gchar *path, gpointer data);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
60 static void file_util_move_completion_sync_cb(gchar *path, gpointer data);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
61 static void real_file_util_move(gchar *source_path, GList *source_list, gchar *dest_path, gint copy);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
62
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
63 static void file_util_delete_multiple_ok_cb(GtkWidget *w, gpointer data);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
64 static void file_util_delete_multiple_cancel_cb(GtkWidget *w, gpointer data);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
65 static void file_util_delete_multiple(GList *source_list);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
66 static void file_util_delete_ok_cb(GtkWidget *w, gpointer data);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
67 static void file_util_delete_cancel_cb(GtkWidget *w, gpointer data);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
68 static void file_util_delete_single(gchar *path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
69
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
70 static void file_util_rename_multiple_ok_cb(GtkWidget *w, gpointer data);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
71 static void file_util_rename_multiple_cancel_cb(GtkWidget *w, gpointer data);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
72 static void file_util_rename_multiple(FileDialog *fd);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
73 static void file_util_rename_multiple_cb(GtkWidget *w, gpointer data);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
74 static void file_util_rename_multiple_select_cb(GtkWidget *clist,
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
75 gint row, gint column, GdkEventButton *bevent, gpointer data);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
76 static void file_util_rename_multiple_do(GList *source_list);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
77
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
78 static void file_util_rename_single_ok_cb(GtkWidget *w, gpointer data);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
79 static void file_util_rename_single_cancel_cb(GtkWidget *w, gpointer data);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
80 static void file_util_rename_single(FileDataSingle *fds);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
81 static void file_util_rename_single_cb(GtkWidget *w, gpointer data);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
82 static void file_util_rename_single_do(gchar *source_path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
83
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
84 static void file_util_create_dir_do(gchar *source, gchar *path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
85 static void file_util_create_dir_cb(GtkWidget *w, gpointer data);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
86
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
87 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
88 *--------------------------------------------------------------------------
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
89 * Move and Copy routines
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
90 *--------------------------------------------------------------------------
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
91 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
92
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
93 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
94 * Multi file move
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
95 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
96
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
97 static FileDataMult *file_data_multiple_new(GList *source_list, gchar *dest, gint copy)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
98 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
99 FileDataMult *fdm = g_new0(FileDataMult, 1);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
100 fdm->confirm_all = FALSE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
101 fdm->confirmed = FALSE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
102 fdm->skip = FALSE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
103 fdm->source_list = source_list;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
104 fdm->source_next = fdm->source_list;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
105 fdm->dest_base = g_strdup(dest);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
106 fdm->source = NULL;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
107 fdm->dest = NULL;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
108 fdm->copy = copy;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
109 return fdm;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
110 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
111
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
112 static void file_data_multiple_free(FileDataMult *fdm)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
113 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
114 free_selected_list(fdm->source_list);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
115 g_free(fdm->dest_base);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
116 g_free(fdm->dest);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
117 g_free(fdm);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
118 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
119
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
120 static void file_util_move_multiple_ok_cb(GtkWidget *widget, gpointer data)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
121 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
122 FileDataMult *fdm = data;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
123 fdm->confirmed = TRUE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
124 file_util_move_multiple(fdm);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
125 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
126
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
127 static void file_util_move_multiple_all_cb(GtkWidget *widget, gpointer data)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
128 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
129 FileDataMult *fdm = data;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
130 fdm->confirm_all = TRUE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
131 file_util_move_multiple(fdm);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
132 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
133
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
134 static void file_util_move_multiple_skip_cb(GtkWidget *widget, gpointer data)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
135 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
136 FileDataMult *fdm = data;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
137 fdm->skip = TRUE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
138 file_util_move_multiple(fdm);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
139 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
140
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
141 static void file_util_move_multiple_cancel_cb(GtkWidget *widget, gpointer data)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
142 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
143 FileDataMult *fdm = data;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
144 file_data_multiple_free(fdm);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
145 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
146
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
147 static void file_util_move_multiple(FileDataMult *fdm)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
148 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
149 while (fdm->dest || fdm->source_next)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
150 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
151 if (!fdm->dest)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
152 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
153 GList *work = fdm->source_next;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
154 fdm->source = work->data;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
155 fdm->dest = g_strconcat(fdm->dest_base, "/", filename_from_path(fdm->source), NULL);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
156 fdm->source_next = work->next;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
157 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
158
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
159 if (isfile(fdm->dest) && !fdm->confirmed && !fdm->confirm_all && !fdm->skip)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
160 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
161 ConfirmDialog *cd;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
162 gchar *text = g_strdup_printf(_("Overwrite file:\n %s\n with:\b %s"), fdm->dest, fdm->source);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
163 cd = confirm_dialog_new(_("Overwrite file"), text, file_util_move_multiple_cancel_cb, fdm);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
164 confirm_dialog_add(cd, _("Skip"), file_util_move_multiple_skip_cb);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
165 confirm_dialog_add(cd, _("Yes to all"), file_util_move_multiple_all_cb);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
166 confirm_dialog_add(cd, _("Yes"), file_util_move_multiple_ok_cb);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
167 g_free(text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
168 return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
169 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
170 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
171 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
172 gint success = FALSE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
173 if (fdm->skip)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
174 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
175 success = TRUE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
176 fdm->skip = FALSE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
177 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
178 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
179 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
180 if (fdm->copy)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
181 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
182 success = copy_file(fdm->source, fdm->dest);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
183 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
184 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
185 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
186 if (move_file(fdm->source, fdm->dest))
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
187 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
188 success = TRUE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
189 file_is_gone(fdm->source, fdm->source_list);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
190 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
191 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
192 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
193 if (!success)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
194 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
195 ConfirmDialog *cd;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
196 gchar *title;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
197 gchar *text;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
198 if (fdm->copy)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
199 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
200 title = _("Error copying file");
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
201 text = g_strdup_printf(_("Unable to copy file:\n%sto:\n%s\n during multiple file copy."), fdm->source, fdm->dest);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
202 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
203 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
204 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
205 title = _("Error moving file");
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
206 text = g_strdup_printf(_("Unable to move file:\n%sto:\n%s\n during multiple file move."), fdm->source, fdm->dest);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
207 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
208 cd = confirm_dialog_new(title, text, file_util_move_multiple_cancel_cb, fdm);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
209 confirm_dialog_add(cd, _("Continue"), file_util_move_multiple_skip_cb);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
210 g_free(text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
211 return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
212 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
213 fdm->confirmed = FALSE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
214 g_free(fdm->dest);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
215 fdm->dest = NULL;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
216 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
217 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
218
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
219 file_data_multiple_free(fdm);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
220 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
221
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
222 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
223 * Single file move
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
224 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
225
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
226 static FileDataSingle *file_data_single_new(gchar *source, gchar *dest, gint copy)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
227 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
228 FileDataSingle *fds = g_new0(FileDataSingle, 1);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
229 fds->confirmed = FALSE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
230 fds->source = g_strdup(source);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
231 fds->dest = g_strdup(dest);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
232 fds->copy = copy;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
233 return fds;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
234 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
235
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
236 static void file_data_single_free(FileDataSingle *fds)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
237 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
238 g_free(fds->source);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
239 g_free(fds->dest);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
240 g_free(fds);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
241 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
242
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
243 static void file_util_move_single_ok_cb(GtkWidget *widget, gpointer data)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
244 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
245 FileDataSingle *fds = data;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
246 fds->confirmed = TRUE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
247 file_util_move_single(fds);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
248 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
249
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
250 static void file_util_move_single_cancel_cb(GtkWidget *widget, gpointer data)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
251 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
252 FileDataSingle *fds = data;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
253 file_data_single_free(fds);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
254 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
255
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
256 static void file_util_move_single(FileDataSingle *fds)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
257 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
258 if (isfile(fds->dest) && !fds->confirmed)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
259 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
260 ConfirmDialog *cd;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
261 gchar *text = g_strdup_printf(_("Overwrite file:\n%s\n with:\n%s"), fds->dest, fds->source);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
262 cd = confirm_dialog_new(_("Overwrite file"), text, file_util_move_single_cancel_cb, fds);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
263 confirm_dialog_add(cd, _("Overwrite"), file_util_move_single_ok_cb);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
264 g_free(text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
265 return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
266 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
267 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
268 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
269 gint success = FALSE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
270 if (fds->copy)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
271 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
272 success = copy_file(fds->source, fds->dest);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
273 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
274 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
275 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
276 if (move_file(fds->source, fds->dest))
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
277 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
278 success = TRUE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
279 file_is_gone(fds->source, NULL);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
280 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
281 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
282 if (!success)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
283 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
284 gchar *title;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
285 gchar *text;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
286 if (fds->copy)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
287 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
288 title = _("Error copying file");
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
289 text = g_strdup_printf(_("Unable to copy file:\n%s\nto:\n%s"), fds->source, fds->dest);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
290 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
291 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
292 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
293 title = _("Error moving file");
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
294 text = g_strdup_printf(_("Unable to move file:\n%s\nto:\n%s"), fds->source, fds->dest);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
295 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
296 warning_dialog(title, text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
297 g_free(text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
298 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
299 file_data_single_free(fds);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
300 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
301 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
302
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
303 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
304 * file move dialog
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
305 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
306
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
307 static void file_util_move_do(FileDialog *fd)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
308 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
309 tab_completion_append_to_history(fd->entry, fd->dest_path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
310 if (fd->multiple_files)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
311 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
312 file_util_move_multiple(file_data_multiple_new(fd->source_list, fd->dest_path, fd->type));
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
313 fd->source_list = NULL;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
314 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
315 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
316 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
317 if (isdir(fd->dest_path))
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
318 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
319 gchar *buf = g_strconcat(fd->dest_path, "/", filename_from_path(fd->source_path), NULL);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
320 g_free(fd->dest_path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
321 fd->dest_path = buf;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
322 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
323 file_util_move_single(file_data_single_new(fd->source_path, fd->dest_path, fd->type));
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
324 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
325
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
326 generic_dialog_close(NULL, fd);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
327 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
328
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
329 static void file_util_move_check(FileDialog *fd)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
330 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
331 g_free(fd->dest_path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
332 fd->dest_path = remove_trailing_slash(gtk_entry_get_text(GTK_ENTRY(fd->entry)));
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
333
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
334 if (fd->multiple_files && !isdir(fd->dest_path))
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
335 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
336 if (isfile(fd->dest_path))
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
337 warning_dialog(_("Invalid destination"), _("When operating with multiple files, please select\n a directory, not file."));
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
338 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
339 warning_dialog(_("Invalid directory"), _("Please select an existing directory"));
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
340 return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
341 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
342
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
343 file_util_move_do(fd);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
344 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
345
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
346 static void file_util_move_cb(GtkWidget *widget, gpointer data)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
347 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
348 FileDialog *fd = data;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
349 file_util_move_check(fd);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
350 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
351
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
352 static void file_util_move_enter_cb(gchar *path, gpointer data)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
353 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
354 FileDialog *fd = data;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
355 file_util_move_check(fd);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
356 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
357
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
358 static void file_util_move_completion_sync_cb(gchar *path, gpointer data)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
359 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
360 FileDialog *fd = data;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
361 destination_widget_sync_to_entry(fd->entry);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
362 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
363
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
364 static void real_file_util_move(gchar *source_path, GList *source_list, gchar *dest_path, gint copy)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
365 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
366 FileDialog *fd;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
367 gchar *path = NULL;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
368 gint multiple;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
369 gchar *text;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
370 gchar *title;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
371 gchar *op_text;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
372 GtkWidget *tabcomp;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
373 GtkWidget *dest;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
374 gchar *last_path;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
375
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
376 if (!source_path && !source_list) return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
377
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
378 if (source_path)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
379 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
380 path = g_strdup(source_path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
381 multiple = FALSE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
382 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
383 else if (source_list->next)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
384 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
385 multiple = TRUE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
386 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
387 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
388 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
389 path = g_strdup(source_list->data);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
390 free_selected_list(source_list);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
391 source_list = NULL;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
392 multiple = FALSE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
393 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
394
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
395 if (copy)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
396 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
397 title = _("GQview - copy");
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
398 op_text = _("Copy");
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
399 if (path)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
400 text = g_strdup_printf(_("Copy file:\n%s\nto:"), path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
401 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
402 text = g_strdup_printf(_("Copy multiple files from:\n%s\nto:"), dest_path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
403 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
404 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
405 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
406 title = _("GQview - move");
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
407 op_text = _("Move");
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
408 if (path)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
409 text = g_strdup_printf(_("Move file:\n%s\nto:"), path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
410 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
411 text = g_strdup_printf(_("Move multiple files from:\n%s\nto:"), dest_path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
412 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
413
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
414 fd = generic_dialog_new(title, text, op_text, _("Cancel"),
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
415 file_util_move_cb, generic_dialog_close);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
416
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
417 g_free(text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
418
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
419 fd->type = copy;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
420 fd->source_path = path;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
421 fd->source_list = source_list;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
422 fd->multiple_files = multiple;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
423
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
424 tabcomp = tab_completion_new_with_history(&fd->entry, fd->dialog, dest_path,
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
425 "move_copy", 32, file_util_move_enter_cb, fd);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
426 last_path = tab_completion_set_to_last_history(fd->entry);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
427 if (last_path)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
428 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
429 fd->dest_path = g_strdup(last_path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
430 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
431 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
432 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
433 fd->dest_path = g_strdup(dest_path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
434 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
435
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
436 /* tabcomp = tab_completion_new(&fd->entry, fd->dialog, fd->dest_path, file_util_move_enter_cb, fd);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
437 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
438 gtk_box_pack_start(GTK_BOX(fd->vbox), tabcomp, FALSE, FALSE, 0);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
439 gtk_widget_show(tabcomp);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
440
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
441 gtk_widget_grab_focus(fd->entry);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
442
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
443 dest = destination_widget_new(fd->dest_path, fd->entry);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
444
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
445 tab_completion_add_tab_func(fd->entry, file_util_move_completion_sync_cb, fd);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
446
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
447 gtk_box_pack_start(GTK_BOX(fd->vbox), dest, TRUE, TRUE, 0);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
448 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
449
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
450 void file_util_move(gchar *source_path, GList *source_list, gchar *dest_path)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
451 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
452 real_file_util_move(source_path, source_list, dest_path, FALSE);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
453 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
454
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
455 void file_util_copy(gchar *source_path, GList *source_list, gchar *dest_path)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
456 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
457 real_file_util_move(source_path, source_list, dest_path, TRUE);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
458 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
459
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
460 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
461 *--------------------------------------------------------------------------
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
462 * Delete routines
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
463 *--------------------------------------------------------------------------
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
464 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
465
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
466 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
467 * delete multiple files
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
468 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
469
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
470 static void file_util_delete_multiple_ok_cb(GtkWidget *w, gpointer data)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
471 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
472 GList *source_list = data;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
473
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
474 while(source_list)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
475 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
476 gchar *path = source_list->data;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
477 source_list = g_list_remove(source_list, path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
478 if (unlink (path) < 0)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
479 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
480 ConfirmDialog *cd;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
481 gchar *text;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
482 if (source_list)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
483 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
484 text = g_strdup_printf(_("Unable to delete file:\n %s\n Continue multiple delete operation?"), path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
485 cd = confirm_dialog_new(_("Delete failed"), text, file_util_delete_multiple_cancel_cb, source_list);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
486 confirm_dialog_add(cd, _("Continue"), file_util_delete_multiple_ok_cb);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
487 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
488 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
489 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
490 text = g_strdup_printf(_("Unable to delete file:\n%s"), path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
491 warning_dialog(_("Delete failed"), text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
492 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
493 g_free(text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
494 g_free(path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
495 return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
496 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
497 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
498 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
499 file_is_gone(path, source_list);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
500 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
501 g_free(path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
502 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
503 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
504
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
505 static void file_util_delete_multiple_cancel_cb(GtkWidget *w, gpointer data)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
506 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
507 GList *source_list = data;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
508 free_selected_list(source_list);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
509 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
510
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
511 static void file_util_delete_multiple(GList *source_list)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
512 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
513 if (!confirm_delete)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
514 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
515 file_util_delete_multiple_ok_cb(NULL, source_list);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
516 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
517 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
518 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
519 ConfirmDialog *cd;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
520 cd = confirm_dialog_new(_("Delete files"), _("About to delete multiple files..."), file_util_delete_multiple_cancel_cb, source_list);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
521 confirm_dialog_add(cd, _("Delete"), file_util_delete_multiple_ok_cb);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
522 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
523 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
524
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
525 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
526 * delete single file
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
527 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
528
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
529 static void file_util_delete_ok_cb(GtkWidget *w, gpointer data)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
530 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
531 gchar *path = data;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
532
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
533 if (unlink (path) < 0)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
534 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
535 gchar *text = g_strdup_printf(_("Unable to delete file:\n%s"), path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
536 warning_dialog(_("File deletion failed"), text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
537 g_free(text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
538 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
539 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
540 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
541 file_is_gone(path, NULL);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
542 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
543
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
544 g_free(path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
545 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
546
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
547 static void file_util_delete_cancel_cb(GtkWidget *w, gpointer data)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
548 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
549 gchar *path = data;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
550 g_free(path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
551 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
552
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
553 static void file_util_delete_single(gchar *path)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
554 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
555 gchar *buf = g_strdup(path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
556
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
557 if (!confirm_delete)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
558 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
559 file_util_delete_ok_cb(NULL, buf);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
560 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
561 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
562 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
563 ConfirmDialog *cd;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
564 gchar *text = g_strdup_printf(_("About to delete the file:\n %s"), buf);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
565 cd = confirm_dialog_new(_("Delete file"), text, file_util_delete_cancel_cb, buf);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
566 confirm_dialog_add(cd, _("Delete"), file_util_delete_ok_cb);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
567 g_free(text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
568 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
569 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
570
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
571 void file_util_delete(gchar *source_path, GList *source_list)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
572 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
573 if (!source_path && !source_list) return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
574
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
575 if (source_path)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
576 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
577 file_util_delete_single(source_path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
578 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
579 else if (!source_list->next)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
580 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
581 file_util_delete_single(source_list->data);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
582 free_selected_list(source_list);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
583 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
584 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
585 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
586 file_util_delete_multiple(source_list);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
587 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
588 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
589
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
590 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
591 *--------------------------------------------------------------------------
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
592 * Rename routines
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
593 *--------------------------------------------------------------------------
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
594 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
595
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
596 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
597 * rename multiple files
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
598 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
599
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
600 static void file_util_rename_multiple_ok_cb(GtkWidget *w, gpointer data)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
601 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
602 FileDialog *fd = data;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
603 if (!GTK_WIDGET_VISIBLE(fd->dialog)) gtk_widget_show(fd->dialog);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
604 fd->type = TRUE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
605 file_util_rename_multiple(fd);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
606 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
607
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
608 static void file_util_rename_multiple_cancel_cb(GtkWidget *w, gpointer data)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
609 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
610 FileDialog *fd = data;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
611 if (!GTK_WIDGET_VISIBLE(fd->dialog)) gtk_widget_show(fd->dialog);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
612 return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
613 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
614
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
615 static void file_util_rename_multiple(FileDialog *fd)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
616 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
617 if (isfile(fd->dest_path) && !fd->type)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
618 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
619 ConfirmDialog *cd;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
620 gchar *text = g_strdup_printf(_("Overwrite file:\n%s\nby renaming:\n%s"), fd->dest_path, fd->source_path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
621 cd = confirm_dialog_new(_("Overwrite file"), text, file_util_rename_multiple_cancel_cb, fd);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
622 confirm_dialog_add(cd, _("Overwrite"), file_util_rename_multiple_ok_cb);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
623 g_free(text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
624 gtk_widget_hide(fd->dialog);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
625 return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
626 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
627 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
628 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
629 if (rename (fd->source_path, fd->dest_path) < 0)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
630 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
631 gchar *text = g_strdup_printf(_("Unable to rename file:\n%s\n to:\n%s"), filename_from_path(fd->source_path), filename_from_path(fd->dest_path));
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
632 warning_dialog(_("Error renaming file"), text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
633 g_free(text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
634 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
635 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
636 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
637 gint row;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
638 gint n;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
639 GtkWidget *clist;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
640 gchar *path;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
641
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
642 file_is_renamed(fd->source_path, fd->dest_path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
643
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
644 clist = gtk_object_get_user_data(GTK_OBJECT(fd->entry));
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
645 path = gtk_object_get_user_data(GTK_OBJECT(clist));
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
646 row = gtk_clist_find_row_from_data(GTK_CLIST(clist), path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
647
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
648 n = g_list_length(GTK_CLIST(clist)->row_list);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
649 if (debug) printf("r=%d n=%d\n", row, n);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
650 if (n - 1 > row)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
651 n = row;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
652 else if (n > 1)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
653 n = row - 1;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
654 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
655 n = -1;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
656
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
657 if (n >= 0)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
658 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
659 gtk_object_set_user_data(GTK_OBJECT(clist), NULL);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
660 gtk_clist_remove(GTK_CLIST(clist), row);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
661 gtk_clist_select_row(GTK_CLIST(clist), n, -1);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
662 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
663 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
664 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
665 if (debug) printf("closed by #%d\n", n);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
666 generic_dialog_close(NULL, fd);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
667 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
668 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
669 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
670 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
671
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
672 static void file_util_rename_multiple_cb(GtkWidget *w, gpointer data)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
673 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
674 FileDialog *fd = data;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
675 gchar *base;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
676 gchar *name;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
677
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
678 name = gtk_entry_get_text(GTK_ENTRY(fd->entry));
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
679 base = remove_level_from_path(fd->source_path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
680 g_free(fd->dest_path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
681 fd->dest_path = g_strconcat(base, "/", name, NULL);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
682 g_free(base);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
683
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
684 if (strlen(name) == 0 || strcmp(fd->source_path, fd->dest_path) == 0)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
685 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
686 return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
687 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
688
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
689 fd->type = FALSE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
690 file_util_rename_multiple(fd);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
691 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
692
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
693 static void file_util_rename_multiple_select_cb(GtkWidget *clist,
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
694 gint row, gint column, GdkEventButton *bevent, gpointer data)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
695 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
696 FileDialog *fd = data;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
697 GtkWidget *label;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
698 gchar *name;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
699 gchar *path;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
700
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
701 label = gtk_object_get_user_data(GTK_OBJECT(fd->dialog));
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
702 path = gtk_clist_get_row_data(GTK_CLIST(clist), row);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
703 g_free(fd->source_path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
704 fd->source_path = g_strdup(path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
705 gtk_object_set_user_data(GTK_OBJECT(clist), path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
706 name = filename_from_path(fd->source_path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
707
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
708 gtk_label_set(GTK_LABEL(label), name);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
709 gtk_entry_set_text(GTK_ENTRY(fd->entry), name);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
710
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
711 gtk_widget_grab_focus(fd->entry);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
712 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
713
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
714 static void file_util_rename_multiple_do(GList *source_list)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
715 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
716 FileDialog *fd;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
717 GtkWidget *scrolled;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
718 GtkWidget *clist;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
719 GtkWidget *label;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
720 GList *work;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
721
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
722 fd = generic_dialog_new(_("GQview - rename"), _("Rename multiple files:"), _("Rename"), _("Cancel"),
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
723 file_util_rename_multiple_cb, generic_dialog_close);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
724
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
725 fd->source_path = g_strdup(source_list->data);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
726 fd->dest_path = NULL;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
727
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
728 scrolled = gtk_scrolled_window_new(NULL, NULL);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
729 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
730 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
731 gtk_box_pack_start(GTK_BOX(fd->vbox), scrolled, TRUE, TRUE, 0);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
732 gtk_widget_show(scrolled);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
733
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
734 clist=gtk_clist_new (1);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
735 gtk_clist_set_column_auto_resize(GTK_CLIST(clist), 0, TRUE);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
736 gtk_signal_connect (GTK_OBJECT (clist), "select_row",(GtkSignalFunc) file_util_rename_multiple_select_cb, fd);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
737 gtk_widget_set_usize(clist, 250, 150);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
738 gtk_container_add (GTK_CONTAINER (scrolled), clist);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
739 gtk_widget_show (clist);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
740
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
741 gtk_object_set_user_data(GTK_OBJECT(clist), source_list->data);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
742
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
743 work = source_list;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
744 while(work)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
745 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
746 gint row;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
747 gchar *buf[2];
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
748 buf[0] = filename_from_path(work->data);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
749 buf[1] = NULL;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
750 row = gtk_clist_append(GTK_CLIST(clist), buf);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
751 gtk_clist_set_row_data_full(GTK_CLIST(clist), row,
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
752 work->data, (GtkDestroyNotify) g_free);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
753 work = work->next;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
754 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
755
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
756 g_list_free(source_list);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
757
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
758 label = gtk_label_new(_("Rename:"));
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
759 gtk_box_pack_start(GTK_BOX(fd->vbox), label, FALSE, FALSE, 0);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
760 gtk_widget_show(label);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
761
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
762 label = gtk_label_new(filename_from_path(fd->source_path));
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
763 gtk_box_pack_start(GTK_BOX(fd->vbox), label, FALSE, FALSE, 0);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
764 gtk_widget_show(label);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
765 gtk_object_set_user_data(GTK_OBJECT(fd->dialog), label);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
766
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
767 label = gtk_label_new(_("to:"));
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
768 gtk_box_pack_start(GTK_BOX(fd->vbox), label, FALSE, FALSE, 0);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
769 gtk_widget_show(label);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
770
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
771 fd->entry = gtk_entry_new();
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
772 gtk_entry_set_text(GTK_ENTRY(fd->entry), filename_from_path(fd->source_path));
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
773 gtk_box_pack_start(GTK_BOX(fd->vbox), fd->entry, FALSE, FALSE, 0);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
774 gtk_widget_grab_focus(fd->entry);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
775 gtk_widget_show(fd->entry);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
776
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
777 gtk_object_set_user_data(GTK_OBJECT(fd->entry), clist);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
778 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
779
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
780 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
781 * rename single file
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
782 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
783
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
784 static void file_util_rename_single_ok_cb(GtkWidget *w, gpointer data)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
785 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
786 FileDataSingle *fds = data;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
787 fds->confirmed = TRUE;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
788 file_util_rename_single(fds);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
789 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
790
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
791 static void file_util_rename_single_cancel_cb(GtkWidget *w, gpointer data)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
792 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
793 FileDataSingle *fds = data;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
794 file_data_single_free(fds);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
795 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
796
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
797 static void file_util_rename_single(FileDataSingle *fds)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
798 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
799 if (isfile(fds->dest) && !fds->confirmed)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
800 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
801 ConfirmDialog *cd;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
802 gchar *text = g_strdup_printf(_("Overwrite file:\n%s\nwith:\n%s"), fds->dest,fds->source);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
803 cd = confirm_dialog_new(_("Overwrite file"), text, file_util_rename_single_cancel_cb, fds);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
804 confirm_dialog_add(cd, _("Overwrite"), file_util_rename_single_ok_cb);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
805 g_free(text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
806 return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
807 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
808 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
809 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
810 if (rename (fds->source, fds->dest) < 0)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
811 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
812 gchar *text = g_strdup_printf(_("Unable to rename file:\n%s\nto:\n%s"), filename_from_path(fds->source), filename_from_path(fds->dest));
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
813 warning_dialog(_("Error renaming file"), text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
814 g_free(text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
815 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
816 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
817 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
818 file_is_renamed(fds->source, fds->dest);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
819 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
820 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
821 file_data_single_free(fds);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
822 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
823
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
824 static void file_util_rename_single_cb(GtkWidget *w, gpointer data)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
825 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
826 FileDialog *fd = data;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
827 gchar *name = gtk_entry_get_text(GTK_ENTRY(fd->entry));
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
828 gchar *buf = g_strconcat(fd->dest_path, "/", name, NULL);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
829
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
830 if (strlen(name) == 0 || strcmp(fd->source_path, buf) == 0)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
831 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
832 g_free(buf);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
833 return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
834 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
835
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
836 g_free(fd->dest_path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
837 fd->dest_path = buf;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
838
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
839 file_util_rename_single(file_data_single_new(fd->source_path, fd->dest_path, fd->type));
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
840
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
841 generic_dialog_close(NULL, fd);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
842 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
843
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
844 static void file_util_rename_single_do(gchar *source_path)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
845 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
846 FileDialog *fd;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
847 gchar *text;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
848 gchar *name = filename_from_path(source_path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
849
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
850 text = g_strdup_printf(_("Rename file:\n%s\nto:"), name);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
851 fd = generic_dialog_new(_("GQview - rename"), text, _("Rename"), _("Cancel"),
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
852 file_util_rename_single_cb, generic_dialog_close);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
853 g_free(text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
854
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
855 fd->source_path = g_strdup(source_path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
856 fd->dest_path = remove_level_from_path(source_path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
857
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
858 fd->entry = gtk_entry_new();
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
859 gtk_entry_set_text(GTK_ENTRY(fd->entry), name);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
860 gtk_box_pack_start(GTK_BOX(fd->vbox), fd->entry, FALSE, FALSE, 0);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
861 gtk_widget_grab_focus(fd->entry);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
862 gtk_widget_show(fd->entry);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
863 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
864
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
865 void file_util_rename(gchar *source_path, GList *source_list)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
866 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
867 if (!source_path && !source_list) return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
868
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
869 if (source_path)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
870 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
871 file_util_rename_single_do(source_path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
872 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
873 else if (!source_list->next)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
874 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
875 file_util_rename_single_do(source_list->data);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
876 free_selected_list(source_list);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
877 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
878 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
879 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
880 file_util_rename_multiple_do(source_list);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
881 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
882 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
883
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
884 /*
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
885 *--------------------------------------------------------------------------
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
886 * Create directory routines
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
887 *--------------------------------------------------------------------------
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
888 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
889
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
890 static void file_util_create_dir_do(gchar *source, gchar *path)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
891 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
892 if (isfile(path))
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
893 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
894 gchar *text = g_strdup_printf(_("The path:\n%s\nalready exists as a file."), filename_from_path(path));
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
895 warning_dialog(_("Could not create directory"), text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
896 g_free(text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
897 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
898 else if (isdir(path))
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
899 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
900 gchar *text = g_strdup_printf(_("The directory:\n%s\nalready exists."), filename_from_path(path));
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
901 warning_dialog(_("Directory exists"), text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
902 g_free(text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
903 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
904 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
905 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
906 if (mkdir (path, 0755) < 0)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
907 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
908 gchar *text = g_strdup_printf(_("Unable to create directory:\n%s"), filename_from_path(path));
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
909 warning_dialog(_("Error creating directory"), text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
910 g_free(text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
911 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
912 else
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
913 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
914 if (strcmp(source, current_path) == 0)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
915 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
916 gchar *buf = g_strdup(current_path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
917 filelist_change_to(buf);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
918 g_free(buf);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
919 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
920 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
921 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
922 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
923
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
924 static void file_util_create_dir_cb(GtkWidget *w, gpointer data)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
925 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
926 FileDialog *fd = data;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
927 gchar *name = gtk_entry_get_text(GTK_ENTRY(fd->entry));
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
928
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
929 if (strlen(name) == 0) return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
930
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
931 g_free(fd->dest_path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
932 fd->dest_path = g_strconcat(fd->source_path, "/", name, NULL);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
933
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
934 file_util_create_dir_do(fd->source_path, fd->dest_path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
935
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
936 generic_dialog_close(NULL, fd);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
937 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
938
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
939 void file_util_create_dir(gchar *path)
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
940 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
941 FileDialog *fd;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
942 gchar *text;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
943 gchar *name;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
944
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
945 if (!isdir(path)) return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
946 name = filename_from_path(path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
947
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
948 text = g_strdup_printf(_("Create directory in:\n%s\nnamed:"), path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
949 fd = generic_dialog_new(_("GQview - new directory"), text, _("Create"), _("Cancel"),
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
950 file_util_create_dir_cb, generic_dialog_close);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
951 g_free(text);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
952
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
953 fd->source_path = g_strdup(path);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
954 fd->dest_path = NULL;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
955
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
956 fd->entry = gtk_entry_new();
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
957 gtk_box_pack_start(GTK_BOX(fd->vbox), fd->entry, FALSE, FALSE, 0);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
958 gtk_widget_grab_focus(fd->entry);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
959 gtk_widget_show(fd->entry);
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
960 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
961