annotate src/utilops.c @ 702:e07895754e65

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