annotate src/utilops.c @ 1160:2562e0bc89a1

Mark keyboard keys with a span and make them look like a key through css style.
author zas_
date Wed, 19 Nov 2008 22:42:20 +0000
parents 1646720364cf
children 0bea79d87065
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
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
17 #include "cache.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
18 #include "cache_maint.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
19 #include "collect.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
20 #include "dupe.h"
586
905688aa2317 split filelist.c to filefilter.c and filedata.c
nadvornik
parents: 513
diff changeset
21 #include "filedata.h"
905688aa2317 split filelist.c to filefilter.c and filedata.c
nadvornik
parents: 513
diff changeset
22 #include "filefilter.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
23 #include "image.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
24 #include "img-view.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
25 #include "layout.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
26 #include "search.h"
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
27 #include "thumb_standard.h"
597
5da092a6a92a moved safe delete functions to separate file
nadvornik
parents: 596
diff changeset
28 #include "trash.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
29 #include "ui_bookmark.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
30 #include "ui_fileops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
31 #include "ui_misc.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
32 #include "ui_tabcomp.h"
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
33 #include "editors.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
34
924
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
35 static GdkPixbuf *file_util_get_error_icon(FileData *fd, GtkWidget *widget);
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
36
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
37 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
38 *--------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
39 * 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
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
43 #define DIALOG_DEF_IMAGE_DIM_X 200
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
44 #define DIALOG_DEF_IMAGE_DIM_Y 150
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
45
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
46 static void generic_dialog_add_image(GenericDialog *gd, GtkWidget *box,
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
47 FileData *fd1, const gchar *header1,
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
48 FileData *fd2, const gchar *header2,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
49 gint show_filename)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
50 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
51 ImageWindow *imd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
52 GtkWidget *hbox = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
53 GtkWidget *vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
54 GtkWidget *label = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
55
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
56 if (!box) box = gd->vbox;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
57
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
58 if (fd2)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
59 {
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
60 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
61 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
62
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
63 /* image 1 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
64
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
65 vbox = gtk_vbox_new(FALSE, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
66 if (hbox)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
67 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
68 GtkWidget *sep;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
69
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
70 gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
71
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
72 sep = gtk_vseparator_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
73 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
74 gtk_widget_show(sep);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
75 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
76 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
77 {
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
78 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
79 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
80 gtk_widget_show(vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
81
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
82 if (header1)
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 GtkWidget *head;
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 head = pref_label_new(vbox, header1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
87 pref_label_bold(head, TRUE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
88 gtk_misc_set_alignment(GTK_MISC(head), 0.0, 0.5);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
89 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
90
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
91 imd = image_new(FALSE);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
92 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
93 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
94 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
95 image_change_fd(imd, fd1, 0.0);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
96 gtk_widget_show(imd->widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
97
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
98 if (show_filename)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
99 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
100 label = pref_label_new(vbox, (fd1 == NULL) ? "" : fd1->name);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
101 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
102
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
103 /* 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
104 g_object_set_data(G_OBJECT(gd->dialog), "img_image", imd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
105 g_object_set_data(G_OBJECT(gd->dialog), "img_label", label);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 341
diff changeset
106
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
107
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
108 /* image 2 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
109
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
110 if (hbox && fd2)
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 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
113
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
114 if (header2)
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 *head;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
117
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
118 head = pref_label_new(vbox, header2);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
119 pref_label_bold(head, TRUE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
120 gtk_misc_set_alignment(GTK_MISC(head), 0.0, 0.5);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
121 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
122
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
123 imd = image_new(FALSE);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
124 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
125 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
126 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
127 image_change_fd(imd, fd2, 0.0);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
128 gtk_widget_show(imd->widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
129
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
130 pref_label_new(vbox, fd2->name);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
131 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
132 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
133
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
134 static void generic_dialog_image_set(GenericDialog *gd, FileData *fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
135 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
136 ImageWindow *imd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
137 GtkWidget *label;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 341
diff changeset
138
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
139 imd = g_object_get_data(G_OBJECT(gd->dialog), "img_image");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
140 label = g_object_get_data(G_OBJECT(gd->dialog), "img_label");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
141
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
142 if (!imd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
143
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
144 image_change_fd(imd, fd, 0.0);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
145 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
146 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
147
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
148 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
149 *--------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
150 * Wrappers to aid in setting additional dialog properties (unde mouse, etc.)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
151 *--------------------------------------------------------------------------
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
154 GenericDialog *file_util_gen_dlg(const gchar *title,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
155 const gchar *wmclass, const gchar *wmsubclass,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
156 GtkWidget *parent, gint auto_close,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
157 void (*cancel_cb)(GenericDialog *, gpointer), gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
158 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
159 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
160
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
161 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
162 if (options->place_dialogs_under_mouse)
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 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
165 }
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 return gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
168 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
169
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
170 FileDialog *file_util_file_dlg(const gchar *title,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
171 const gchar *wmclass, const gchar *wmsubclass,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
172 GtkWidget *parent,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
173 void (*cancel_cb)(FileDialog *, gpointer), gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
174 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
175 FileDialog *fdlg;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
176
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
177 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
178 if (options->place_dialogs_under_mouse)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
179 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
180 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
181 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
182
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
183 return fdlg;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
184 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
185
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
186 /* this warning dialog is copied from SLIK's ui_utildg.c,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
187 * because it does not have a mouse center option,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
188 * and we must center it before show, implement it here.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
189 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
190 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
191 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
192 /* no op */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
193 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
194
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
195 GenericDialog *file_util_warning_dialog(const gchar *heading, const gchar *message,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
196 const gchar *icon_stock_id, GtkWidget *parent)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
197 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
198 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
199
254
9faf34f047b1 Make the wmclass value unique among the code by defining
zas_
parents: 223
diff changeset
200 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
201 generic_dialog_add_message(gd, icon_stock_id, heading, message);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
202 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
203 if (options->place_dialogs_under_mouse)
9
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 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
206 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
207 gtk_widget_show(gd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
208
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
209 return gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
210 }
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
211
42
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
212 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
213 {
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
214 gint n;
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
215
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
216 if (!name) return 0;
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
217
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
218 n = strlen(name);
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
219
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
220 if (filter_name_exists(name))
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
221 {
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
222 const gchar *ext;
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
223
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
224 ext = extension_from_path(name);
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
225 if (ext) n -= strlen(ext);
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
226 }
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
227
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
228 return n;
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
229 }
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
230
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
231
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
232
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
233
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
234 typedef enum {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
235 UTILITY_TYPE_COPY,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
236 UTILITY_TYPE_MOVE,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
237 UTILITY_TYPE_RENAME,
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
238 UTILITY_TYPE_RENAME_FOLDER,
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
239 UTILITY_TYPE_EDITOR,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
240 UTILITY_TYPE_FILTER,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
241 UTILITY_TYPE_DELETE,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
242 UTILITY_TYPE_DELETE_LINK,
901
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
243 UTILITY_TYPE_DELETE_FOLDER,
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
244 UTILITY_TYPE_CREATE_FOLDER
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
245 } UtilityType;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
246
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
247 typedef enum {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
248 UTILITY_PHASE_START = 0,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
249 UTILITY_PHASE_ENTERING,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
250 UTILITY_PHASE_CHECKED,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
251 UTILITY_PHASE_DONE,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
252 UTILITY_PHASE_CANCEL
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
253 } UtilityPhase;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
254
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
255 enum {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
256 UTILITY_RENAME = 0,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
257 UTILITY_RENAME_AUTO,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
258 UTILITY_RENAME_FORMATTED
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
259 };
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
260
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
261 typedef struct _UtilityDataMessages UtilityDataMessages;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
262 struct _UtilityDataMessages {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
263 gchar *title;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
264 gchar *question;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
265 gchar *desc_flist;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
266 gchar *desc_source_fd;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
267 gchar *fail;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
268 };
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
269
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
270 typedef struct _UtilityData UtilityData;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
271
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
272 struct _UtilityData {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
273 UtilityType type;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
274 UtilityPhase phase;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
275
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
276 FileData *dir_fd;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
277 GList *content_list;
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
278 GList *flist;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
279
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
280 GtkWidget *parent;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
281 GenericDialog *gd;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
282 FileDialog *fdlg;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
283
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
284 gint update_idle_id;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
285
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
286 /* alternative dialog parts */
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
287 GtkWidget *notebook;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
288
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
289 UtilityDataMessages messages;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
290
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
291 /* helper entries for various modes */
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
292 GtkWidget *rename_entry;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
293 GtkWidget *rename_label;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
294 GtkWidget *auto_entry_front;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
295 GtkWidget *auto_entry_end;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
296 GtkWidget *auto_spin_start;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
297 GtkWidget *auto_spin_pad;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
298 GtkWidget *format_entry;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
299 GtkWidget *format_spin;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
300
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
301 GtkWidget *listview;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
302
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
303
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
304 gchar *dest_path;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
305
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
306 /* data for the operation itself, internal or external */
755
be382bffd11f Typo fix.
zas_
parents: 753
diff changeset
307 gboolean external; /* TRUE for external command, FALSE for internal */
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
308
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
309 gint external_command;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
310 gpointer resume_data;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
311 };
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
312
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
313 enum {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
314 UTILITY_COLUMN_FD = 0,
924
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
315 UTILITY_COLUMN_PIXBUF,
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
316 UTILITY_COLUMN_PATH,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
317 UTILITY_COLUMN_NAME,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
318 UTILITY_COLUMN_SIDECARS,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
319 UTILITY_COLUMN_DEST_PATH,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
320 UTILITY_COLUMN_DEST_NAME,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
321 UTILITY_COLUMN_COUNT
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
322 };
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
323
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
324 #define UTILITY_LIST_MIN_WIDTH 250
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
325 #define UTILITY_LIST_MIN_HEIGHT 150
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
326
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
327 /* thumbnail spec has a max depth of 4 (.thumb??/fail/appname/??.png) */
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
328 #define UTILITY_DELETE_MAX_DEPTH 5
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
329
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
330 static UtilityData *file_util_data_new(UtilityType type)
136
18c2a29e681c more external commands
nadvornik
parents: 135
diff changeset
331 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
332 UtilityData *ud;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
333
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
334 ud = g_new0(UtilityData, 1);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
335 ud->type = type;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
336 ud->phase = UTILITY_PHASE_START;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
337 ud->update_idle_id = -1;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
338 ud->external_command = -1;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
339 return ud;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
340 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
341
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
342 static void file_util_data_free(UtilityData *ud)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
343 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
344 if (!ud) return;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
345
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
346 if (ud->update_idle_id != -1) g_source_remove(ud->update_idle_id);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
347
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
348 file_data_unref(ud->dir_fd);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
349 filelist_free(ud->content_list);
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
350 filelist_free(ud->flist);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
351
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
352 if (ud->gd) generic_dialog_close(ud->gd);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
353
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
354 g_free(ud->dest_path);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
355
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
356 g_free(ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
357 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
358
924
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
359 static GtkTreeViewColumn *file_util_dialog_add_list_column(GtkWidget *view, const gchar *text, gboolean image, gint n)
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
360 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
361 GtkTreeViewColumn *column;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
362 GtkCellRenderer *renderer;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
363
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
364 column = gtk_tree_view_column_new();
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
365 gtk_tree_view_column_set_title(column, text);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
366 gtk_tree_view_column_set_min_width(column, 4);
924
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
367 if (image)
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
368 {
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
369 gtk_tree_view_column_set_min_width(column, 20);
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
370 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
371 renderer = gtk_cell_renderer_pixbuf_new();
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
372 gtk_tree_view_column_pack_start(column, renderer, TRUE);
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
373 gtk_tree_view_column_add_attribute(column, renderer, "pixbuf", n);
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
374 }
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
375 else
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
376 {
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
377 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
378 renderer = gtk_cell_renderer_text_new();
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
379 gtk_tree_view_column_pack_start(column, renderer, TRUE);
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
380 gtk_tree_view_column_add_attribute(column, renderer, "text", n);
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
381 }
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
382 gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
383
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
384 return column;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
385 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
386
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
387 static void file_util_dialog_list_select(GtkWidget *view, gint n)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
388 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
389 GtkTreeModel *store;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
390 GtkTreeIter iter;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
391 GtkTreeSelection *selection;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
392
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
393 store = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
394 if (gtk_tree_model_iter_nth_child(store, &iter, NULL, n))
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
395 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
396 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
397 gtk_tree_selection_select_iter(selection, &iter);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
398 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
399 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
400
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
401 static GtkWidget *file_util_dialog_add_list(GtkWidget *box, GList *list, gint full_paths)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
402 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
403 GtkWidget *scrolled;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
404 GtkWidget *view;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
405 GtkListStore *store;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
406
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
407 scrolled = gtk_scrolled_window_new(NULL, NULL);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
408 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
409 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
410 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
411 gtk_box_pack_start(GTK_BOX(box), scrolled, TRUE, TRUE, 0);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
412 gtk_widget_show(scrolled);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
413
924
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
414 store = gtk_list_store_new(UTILITY_COLUMN_COUNT, G_TYPE_POINTER, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
415 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
416 g_object_unref(store);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
417
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
418 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), TRUE);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
419 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(view), FALSE);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
420
924
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
421 file_util_dialog_add_list_column(view, "", TRUE, UTILITY_COLUMN_PIXBUF);
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
422
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
423 if (full_paths)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
424 {
924
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
425 file_util_dialog_add_list_column(view, _("Location"), FALSE, UTILITY_COLUMN_PATH);
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
426 }
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
427 else
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
428 {
924
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
429 file_util_dialog_add_list_column(view, _("Name"), FALSE, UTILITY_COLUMN_NAME);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
430 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
431
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
432 gtk_widget_set_size_request(view, UTILITY_LIST_MIN_WIDTH, UTILITY_LIST_MIN_HEIGHT);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
433 gtk_container_add(GTK_CONTAINER(scrolled), view);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
434 gtk_widget_show(view);
136
18c2a29e681c more external commands
nadvornik
parents: 135
diff changeset
435
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
436 while (list)
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
437 {
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
438 FileData *fd = list->data;
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
439 GtkTreeIter iter;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
440 gchar *sidecars;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
441
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
442 sidecars = file_data_sc_list_to_string(fd);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
443
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
444 gtk_list_store_append(store, &iter);
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
445 gtk_list_store_set(store, &iter,
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
446 UTILITY_COLUMN_FD, fd,
924
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
447 UTILITY_COLUMN_PIXBUF, file_util_get_error_icon(fd, view),
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
448 UTILITY_COLUMN_PATH, fd->path,
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
449 UTILITY_COLUMN_NAME, fd->name,
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
450 UTILITY_COLUMN_SIDECARS, sidecars,
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
451 UTILITY_COLUMN_DEST_PATH, fd->change ? fd->change->dest : "error",
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
452 UTILITY_COLUMN_DEST_NAME, fd->change ? filename_from_path(fd->change->dest) : "error",
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
453 -1);
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
454 g_free(sidecars);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
455
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
456 list = list->next;
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
457 }
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
458
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
459 return view;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
460 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
461
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
462
897
6c676d3eef5b fixed previous checkin
nadvornik
parents: 896
diff changeset
463 static void file_util_perform_ci_internal(UtilityData *ud);
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
464 void file_util_dialog_run(UtilityData *ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
465 static gint file_util_perform_ci_cb(gpointer resume_data, gint flags, GList *list, gpointer data);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
466
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
467 /* call file_util_perform_ci_internal or start_editor_from_filelist_full */
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
468
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
469
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
470 static void file_util_resume_cb(GenericDialog *gd, gpointer data)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
471 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
472 UtilityData *ud = data;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
473 if (ud->external)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
474 editor_resume(ud->resume_data);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
475 else
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
476 file_util_perform_ci_internal(ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
477 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
478
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
479 static void file_util_abort_cb(GenericDialog *gd, gpointer data)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
480 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
481 UtilityData *ud = data;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
482 if (ud->external)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
483 editor_skip(ud->resume_data);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
484 else
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
485 file_util_perform_ci_cb(NULL, EDITOR_ERROR_SKIPPED, ud->flist, ud);
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
486
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
487 }
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
488
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
489
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
490 static gint file_util_perform_ci_cb(gpointer resume_data, gint flags, GList *list, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
491 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
492 UtilityData *ud = data;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
493 ud->resume_data = resume_data;
497
a33badd85f16 Allow the copy of file paths to clipboard.
zas_
parents: 495
diff changeset
494
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
495 gint ret = EDITOR_CB_CONTINUE;
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
496 if ((flags & EDITOR_ERROR_MASK) && !(flags & EDITOR_ERROR_SKIPPED))
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
497 {
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
498 GString *msg = g_string_new(editor_get_error_str(flags));
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
499 GenericDialog *d;
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
500 g_string_append(msg, "\n");
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
501 g_string_append(msg, ud->messages.fail);
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
502 g_string_append(msg, "\n");
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
503 while (list)
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
504 {
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
505 FileData *fd = list->data;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 341
diff changeset
506
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
507 g_string_append(msg, fd->path);
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
508 g_string_append(msg, "\n");
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
509 list = list->next;
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
510 }
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
511 if (resume_data)
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
512 {
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
513 g_string_append(msg, _("\n Continue multiple file operation?"));
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
514 d = file_util_gen_dlg(ud->messages.fail, GQ_WMCLASS, "dlg_confirm",
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
515 NULL, TRUE,
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
516 file_util_abort_cb, ud);
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
517
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
518 generic_dialog_add_message(d, GTK_STOCK_DIALOG_WARNING, NULL, msg->str);
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
519
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
520 generic_dialog_add_button(d, GTK_STOCK_GO_FORWARD, _("Co_ntinue"),
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
521 file_util_resume_cb, TRUE);
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
522 gtk_widget_show(d->dialog);
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
523 ret = EDITOR_CB_SUSPEND;
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
524 }
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
525 else
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
526 {
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
527 file_util_warning_dialog(ud->messages.fail, msg->str, GTK_STOCK_DIALOG_ERROR, NULL);
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
528 }
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
529 g_string_free(msg, TRUE);
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
530 }
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 341
diff changeset
531
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 341
diff changeset
532
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
533 while (list) /* be careful, file_util_perform_ci_internal can pass ud->flist as list */
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
534 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
535 FileData *fd = list->data;
995
6ca2c5fd7b13 Whitespaces cleanup.
zas_
parents: 974
diff changeset
536 list = list->next;
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
537
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
538 if (!(flags & EDITOR_ERROR_MASK)) /* files were successfully deleted, call the maint functions */
761
a2dda8e61e0f another fix in notification
nadvornik
parents: 758
diff changeset
539 {
a2dda8e61e0f another fix in notification
nadvornik
parents: 758
diff changeset
540 file_data_sc_apply_ci(fd);
a2dda8e61e0f another fix in notification
nadvornik
parents: 758
diff changeset
541 }
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
542
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
543 ud->flist = g_list_remove(ud->flist, fd);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
544 file_data_sc_free_ci(fd);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
545 file_data_unref(fd);
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
546 }
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
547
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
548 if (!resume_data) /* end of the list */
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
549 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
550 ud->phase = UTILITY_PHASE_DONE;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
551 file_util_dialog_run(ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
552 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
553
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
554 return ret;
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
555 }
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
556
143
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
557
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
558 /*
756
573121c002c3 Typo fix.
zas_
parents: 755
diff changeset
559 * Perform the operation described by FileDataChangeInfo on all files in the list
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
560 * it is an alternative to start_editor_from_filelist_full, it should use similar interface
995
6ca2c5fd7b13 Whitespaces cleanup.
zas_
parents: 974
diff changeset
561 */
143
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
562
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
563
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
564 static void file_util_perform_ci_internal(UtilityData *ud)
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
565 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
566
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
567 while (ud->flist)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
568 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
569 gint ret;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
570
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
571 /* take a single entry each time, this allows better control over the operation */
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
572 GList *single_entry = g_list_append(NULL, ud->flist->data);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
573 gboolean last = !ud->flist->next;
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
574 gint status = EDITOR_ERROR_STATUS;
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
575
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
576 if (file_data_sc_perform_ci(single_entry->data))
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
577 status = 0; /* OK */
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
578
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
579 ret = file_util_perform_ci_cb(GINT_TO_POINTER(!last), status, single_entry, ud);
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
580 g_list_free(single_entry);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
581
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
582 if (ret == EDITOR_CB_SUSPEND || last) return;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
583
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
584 if (ret == EDITOR_CB_SKIP)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
585 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
586 file_util_perform_ci_cb(NULL, EDITOR_ERROR_SKIPPED, ud->flist, ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
587 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
588
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
589 /* FIXME: convert the loop to idle call */
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
590
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
591 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
592 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
593
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
594 static void file_util_perform_ci_dir(UtilityData *ud, gboolean internal, gboolean ext_result)
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
595 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
596 switch (ud->type)
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
597 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
598 case UTILITY_TYPE_DELETE_LINK:
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
599 {
897
6c676d3eef5b fixed previous checkin
nadvornik
parents: 896
diff changeset
600 if ((internal && file_data_sc_perform_ci(ud->dir_fd)) ||
6c676d3eef5b fixed previous checkin
nadvornik
parents: 896
diff changeset
601 (!internal && ext_result))
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
602 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
603 file_data_sc_apply_ci(ud->dir_fd);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
604 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
605 else
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
606 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
607 gchar *text;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
608
901
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
609 text = g_strdup_printf("%s:\n\n%s", ud->messages.fail, ud->dir_fd->path);
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
610 file_util_warning_dialog(ud->messages.fail, text, GTK_STOCK_DIALOG_ERROR, NULL);
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
611 g_free(text);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
612 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
613 file_data_sc_free_ci(ud->dir_fd);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
614 break;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
615 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
616 case UTILITY_TYPE_DELETE_FOLDER:
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
617 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
618 FileData *fail = NULL;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
619 GList *work;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
620 work = ud->content_list;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
621 while (work)
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
622 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
623 FileData *fd;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
624
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
625 fd = work->data;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
626 work = work->next;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
627
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
628 if (!fail)
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
629 {
897
6c676d3eef5b fixed previous checkin
nadvornik
parents: 896
diff changeset
630 if ((internal && file_data_sc_perform_ci(fd)) ||
6c676d3eef5b fixed previous checkin
nadvornik
parents: 896
diff changeset
631 (!internal && ext_result))
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
632 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
633 file_data_sc_apply_ci(fd);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
634 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
635 else
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
636 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
637 if (internal) fail = file_data_ref(fd);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
638 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
639 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
640 file_data_sc_free_ci(fd);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
641 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
642
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
643 if (!fail)
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
644 {
897
6c676d3eef5b fixed previous checkin
nadvornik
parents: 896
diff changeset
645 if ((internal && file_data_sc_perform_ci(ud->dir_fd)) ||
6c676d3eef5b fixed previous checkin
nadvornik
parents: 896
diff changeset
646 (!internal && ext_result))
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
647 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
648 file_data_sc_apply_ci(ud->dir_fd);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
649 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
650 else
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
651 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
652 fail = file_data_ref(ud->dir_fd);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
653 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
654 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
655
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
656 if (fail)
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
657 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
658 gchar *text;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
659 GenericDialog *gd;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
660
901
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
661 text = g_strdup_printf("%s:\n\n%s", ud->messages.fail, ud->dir_fd->path);
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
662 gd = file_util_warning_dialog(ud->messages.fail, text, GTK_STOCK_DIALOG_ERROR, NULL);
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
663 g_free(text);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
664
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
665 if (fail != ud->dir_fd)
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
666 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
667 pref_spacer(gd->vbox, PREF_PAD_GROUP);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
668 text = g_strdup_printf(_("Removal of folder contents failed at this file:\n\n%s"),
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
669 fail->path);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
670 pref_label_new(gd->vbox, text);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
671 g_free(text);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
672 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
673
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
674 file_data_unref(fail);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
675 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
676 break;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
677 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
678 case UTILITY_TYPE_RENAME_FOLDER:
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
679 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
680 FileData *fail = NULL;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
681 GList *work;
897
6c676d3eef5b fixed previous checkin
nadvornik
parents: 896
diff changeset
682 if ((internal && file_data_sc_perform_ci(ud->dir_fd)) ||
6c676d3eef5b fixed previous checkin
nadvornik
parents: 896
diff changeset
683 (!internal && ext_result))
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
684 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
685 file_data_sc_apply_ci(ud->dir_fd);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
686 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
687 else
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
688 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
689 fail = file_data_ref(ud->dir_fd);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
690 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
691
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
692
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
693 work = ud->content_list;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
694 while (work)
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
695 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
696 FileData *fd;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
697
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
698 fd = work->data;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
699 work = work->next;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
700
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
701 if (!fail)
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
702 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
703 file_data_sc_apply_ci(fd);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
704 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
705 file_data_sc_free_ci(fd);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
706 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
707
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
708 if (fail)
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
709 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
710 gchar *text;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
711 GenericDialog *gd;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
712
901
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
713 text = g_strdup_printf("%s:\n\n%s", ud->messages.fail, ud->dir_fd->path);
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
714 gd = file_util_warning_dialog(ud->messages.fail, text, GTK_STOCK_DIALOG_ERROR, NULL);
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
715 g_free(text);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
716
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
717 file_data_unref(fail);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
718 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
719 break;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
720 }
901
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
721 case UTILITY_TYPE_CREATE_FOLDER:
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
722 {
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
723 if ((internal && mkdir_utf8(ud->dir_fd->path, 0755)) ||
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
724 (!internal && ext_result))
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
725 {
974
c466b8fabcc3 update the FileData structure when a new folder is created
nadvornik
parents: 947
diff changeset
726 file_data_check_changed_files(ud->dir_fd); /* this will update the FileData and send notification */
901
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
727 }
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
728 else
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
729 {
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
730 gchar *text;
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
731 GenericDialog *gd;
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
732
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
733 text = g_strdup_printf("%s:\n\n%s", ud->messages.fail, ud->dir_fd->path);
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
734 gd = file_util_warning_dialog(ud->messages.fail, text, GTK_STOCK_DIALOG_ERROR, NULL);
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
735 g_free(text);
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
736 }
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
737
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
738 break;
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
739 }
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
740 default:
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
741 g_warning("unhandled operation");
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
742 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
743 ud->phase = UTILITY_PHASE_DONE;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
744 file_util_dialog_run(ud);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
745 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
746
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
747 static gint file_util_perform_ci_dir_cb(gpointer resume_data, gint flags, GList *list, gpointer data)
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
748 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
749 UtilityData *ud = data;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
750 file_util_perform_ci_dir(ud, FALSE, !((flags & EDITOR_ERROR_MASK) && !(flags & EDITOR_ERROR_SKIPPED)));
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
751 return EDITOR_CB_CONTINUE; /* does not matter, there was just single directory */
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
752 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
753
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
754 void file_util_perform_ci(UtilityData *ud)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
755 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
756 switch (ud->type)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
757 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
758 case UTILITY_TYPE_COPY:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
759 ud->external_command = CMD_COPY;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
760 break;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
761 case UTILITY_TYPE_MOVE:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
762 ud->external_command = CMD_MOVE;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
763 break;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
764 case UTILITY_TYPE_RENAME:
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
765 case UTILITY_TYPE_RENAME_FOLDER:
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
766 ud->external_command = CMD_RENAME;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
767 break;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
768 case UTILITY_TYPE_DELETE:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
769 case UTILITY_TYPE_DELETE_LINK:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
770 case UTILITY_TYPE_DELETE_FOLDER:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
771 ud->external_command = CMD_DELETE;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
772 break;
901
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
773 case UTILITY_TYPE_CREATE_FOLDER:
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
774 ud->external_command = CMD_FOLDER;
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
775 break;
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
776 case UTILITY_TYPE_FILTER:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
777 case UTILITY_TYPE_EDITOR:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
778 g_assert(ud->external_command != -1); /* it should be already set */
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
779 break;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
780 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
781
766
7148e125bf23 Check for existing editor command using is_valid_editor_command().
zas_
parents: 761
diff changeset
782 if (is_valid_editor_command(ud->external_command))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
783 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
784 gint flags;
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
785
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
786 ud->external = TRUE;
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
787
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
788 if (ud->dir_fd)
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
789 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
790 flags = start_editor_from_file_full(ud->external_command, ud->dir_fd, file_util_perform_ci_dir_cb, ud);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
791 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
792 else
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
793 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
794 flags = start_editor_from_filelist_full(ud->external_command, ud->flist, file_util_perform_ci_cb, ud);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
795 }
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
796
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
797 if (flags)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
798 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
799 gchar *text = g_strdup_printf(_("%s\nUnable to start external command.\n"), editor_get_error_str(flags));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
800 file_util_warning_dialog(ud->messages.fail, text, GTK_STOCK_DIALOG_ERROR, NULL);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
801 g_free(text);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
802 }
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
805 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
806 ud->external = FALSE;
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
807 if (ud->dir_fd)
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
808 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
809 file_util_perform_ci_dir(ud, TRUE, FALSE);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
810 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
811 else
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
812 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
813 file_util_perform_ci_internal(ud);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
814 }
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
815 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
816 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
817
924
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
818 static GdkPixbuf *file_util_get_error_icon(FileData *fd, GtkWidget *widget)
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
819 {
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
820 static GdkPixbuf *pb_warning;
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
821 static GdkPixbuf *pb_error;
932
988eff509920 added icon for changes without warnings
nadvornik
parents: 931
diff changeset
822 static GdkPixbuf *pb_apply;
924
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
823 gint error;
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
824
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
825 if (!pb_warning)
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
826 {
995
6ca2c5fd7b13 Whitespaces cleanup.
zas_
parents: 974
diff changeset
827 pb_warning = gtk_widget_render_icon(widget, GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_MENU, NULL);
924
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
828 }
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
829
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
830 if (!pb_error)
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
831 {
995
6ca2c5fd7b13 Whitespaces cleanup.
zas_
parents: 974
diff changeset
832 pb_error = gtk_widget_render_icon(widget, GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_MENU, NULL);
924
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
833 }
932
988eff509920 added icon for changes without warnings
nadvornik
parents: 931
diff changeset
834
988eff509920 added icon for changes without warnings
nadvornik
parents: 931
diff changeset
835 if (!pb_apply)
988eff509920 added icon for changes without warnings
nadvornik
parents: 931
diff changeset
836 {
995
6ca2c5fd7b13 Whitespaces cleanup.
zas_
parents: 974
diff changeset
837 pb_apply = gtk_widget_render_icon(widget, GTK_STOCK_APPLY, GTK_ICON_SIZE_MENU, NULL);
932
988eff509920 added icon for changes without warnings
nadvornik
parents: 931
diff changeset
838 }
924
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
839
928
6a42ab7051f2 improved error reporting
nadvornik
parents: 924
diff changeset
840 error = file_data_sc_verify_ci(fd);
924
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
841
932
988eff509920 added icon for changes without warnings
nadvornik
parents: 931
diff changeset
842 if (!error) return pb_apply;
924
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
843
995
6ca2c5fd7b13 Whitespaces cleanup.
zas_
parents: 974
diff changeset
844 if (error & CHANGE_ERROR_MASK)
924
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
845 {
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
846 return pb_error;
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
847 }
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
848 else
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
849 {
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
850 return pb_warning;
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
851 }
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
852 }
914
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
853
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
854 static void file_util_check_resume_cb(GenericDialog *gd, gpointer data)
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
855 {
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
856 UtilityData *ud = data;
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
857 ud->phase = UTILITY_PHASE_CHECKED;
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
858 file_util_dialog_run(ud);
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
859 }
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
860
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
861 static void file_util_check_abort_cb(GenericDialog *gd, gpointer data)
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
862 {
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
863 UtilityData *ud = data;
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
864 ud->phase = UTILITY_PHASE_START;
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
865 file_util_dialog_run(ud);
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
866 }
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
867
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
868 void file_util_check_ci(UtilityData *ud)
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
869 {
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
870 gint error = CHANGE_OK;
928
6a42ab7051f2 improved error reporting
nadvornik
parents: 924
diff changeset
871 gchar *desc = NULL;
914
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
872
935
ae641f36159d fixed new folder command
nadvornik
parents: 934
diff changeset
873 if (ud->type != UTILITY_TYPE_CREATE_FOLDER)
914
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
874 {
935
ae641f36159d fixed new folder command
nadvornik
parents: 934
diff changeset
875 if (ud->dest_path && !isdir(ud->dest_path))
ae641f36159d fixed new folder command
nadvornik
parents: 934
diff changeset
876 {
ae641f36159d fixed new folder command
nadvornik
parents: 934
diff changeset
877 error = CHANGE_GENERIC_ERROR;
ae641f36159d fixed new folder command
nadvornik
parents: 934
diff changeset
878 desc = g_strdup_printf(_("%s is not a directory"), ud->dest_path);
ae641f36159d fixed new folder command
nadvornik
parents: 934
diff changeset
879 }
ae641f36159d fixed new folder command
nadvornik
parents: 934
diff changeset
880 else if (ud->dir_fd)
ae641f36159d fixed new folder command
nadvornik
parents: 934
diff changeset
881 {
ae641f36159d fixed new folder command
nadvornik
parents: 934
diff changeset
882 error = file_data_sc_verify_ci(ud->dir_fd);
ae641f36159d fixed new folder command
nadvornik
parents: 934
diff changeset
883 if (error) desc = file_data_get_error_string(error);
ae641f36159d fixed new folder command
nadvornik
parents: 934
diff changeset
884 }
ae641f36159d fixed new folder command
nadvornik
parents: 934
diff changeset
885 else
ae641f36159d fixed new folder command
nadvornik
parents: 934
diff changeset
886 {
ae641f36159d fixed new folder command
nadvornik
parents: 934
diff changeset
887 error = file_data_sc_verify_ci_list(ud->flist, &desc);
ae641f36159d fixed new folder command
nadvornik
parents: 934
diff changeset
888 }
914
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
889 }
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
890
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
891 if (!error)
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
892 {
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
893 ud->phase = UTILITY_PHASE_CHECKED;
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
894 file_util_dialog_run(ud);
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
895 return;
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
896 }
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
897
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
898 if (!(error & CHANGE_ERROR_MASK))
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
899 {
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
900 /* just a warning */
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
901 GenericDialog *d;
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
902
937
ed7ff10c0656 string cleanup
nadvornik
parents: 936
diff changeset
903 d = file_util_gen_dlg(ud->messages.title, GQ_WMCLASS, "dlg_confirm",
914
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
904 ud->parent, TRUE,
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
905 file_util_check_abort_cb, ud);
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
906
928
6a42ab7051f2 improved error reporting
nadvornik
parents: 924
diff changeset
907 generic_dialog_add_message(d, GTK_STOCK_DIALOG_WARNING, _("Really continue?"), desc);
914
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
908
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
909 generic_dialog_add_button(d, GTK_STOCK_GO_FORWARD, _("Co_ntinue"),
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
910 file_util_check_resume_cb, TRUE);
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
911 gtk_widget_show(d->dialog);
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
912 }
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
913 else
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
914 {
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
915 /* fatal error */
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
916 GenericDialog *d;
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
917
937
ed7ff10c0656 string cleanup
nadvornik
parents: 936
diff changeset
918 d = file_util_gen_dlg(ud->messages.title, GQ_WMCLASS, "dlg_confirm",
914
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
919 ud->parent, TRUE,
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
920 file_util_check_abort_cb, ud);
937
ed7ff10c0656 string cleanup
nadvornik
parents: 936
diff changeset
921 generic_dialog_add_message(d, GTK_STOCK_DIALOG_WARNING, _("This operation can't continue:"), desc);
914
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
922
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
923 gtk_widget_show(d->dialog);
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
924 }
928
6a42ab7051f2 improved error reporting
nadvornik
parents: 924
diff changeset
925 g_free(desc);
914
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
926 }
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
927
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
928
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
929
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
930
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
931
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
932 static void file_util_cancel_cb(GenericDialog *gd, gpointer data)
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
933 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
934 UtilityData *ud = data;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
935
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
936 generic_dialog_close(gd);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
937
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
938 ud->gd = NULL;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
939
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
940 ud->phase = UTILITY_PHASE_CANCEL;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
941 file_util_dialog_run(ud);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
942 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
943
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
944 static void file_util_ok_cb(GenericDialog *gd, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
945 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
946 UtilityData *ud = data;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
947
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
948 generic_dialog_close(gd);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
949
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
950 ud->gd = NULL;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
951
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
952 file_util_dialog_run(ud);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
953 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
954
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
955 static void file_util_fdlg_cancel_cb(FileDialog *fdlg, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
956 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
957 UtilityData *ud = data;
675
cca86176bf81 Fix redundant application name in window titles.
zas_
parents: 673
diff changeset
958
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
959 file_dialog_close(fdlg);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
960
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
961 ud->fdlg = NULL;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
962
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
963 ud->phase = UTILITY_PHASE_CANCEL;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
964 file_util_dialog_run(ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
965 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
966
900
dc13766d1eeb fixed file copy/move dialog
nadvornik
parents: 897
diff changeset
967 static void file_util_dest_folder_update_path(UtilityData *ud)
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
968 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
969 g_free(ud->dest_path);
900
dc13766d1eeb fixed file copy/move dialog
nadvornik
parents: 897
diff changeset
970 ud->dest_path = g_strdup(gtk_entry_get_text(GTK_ENTRY(ud->fdlg->entry)));
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
971
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
972 switch (ud->type)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
973 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
974 case UTILITY_TYPE_COPY:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
975 file_data_sc_update_ci_copy_list(ud->flist, ud->dest_path);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
976 break;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
977 case UTILITY_TYPE_MOVE:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
978 file_data_sc_update_ci_move_list(ud->flist, ud->dest_path);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
979 break;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
980 case UTILITY_TYPE_FILTER:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
981 case UTILITY_TYPE_EDITOR:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
982 file_data_sc_update_ci_unspecified_list(ud->flist, ud->dest_path);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
983 break;
901
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
984 case UTILITY_TYPE_CREATE_FOLDER:
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
985 file_data_unref(ud->dir_fd);
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
986 ud->dir_fd = file_data_new_simple(ud->dest_path);
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
987 break;
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
988 case UTILITY_TYPE_DELETE:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
989 case UTILITY_TYPE_DELETE_LINK:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
990 case UTILITY_TYPE_DELETE_FOLDER:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
991 case UTILITY_TYPE_RENAME:
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
992 case UTILITY_TYPE_RENAME_FOLDER:
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
993 g_warning("unhandled operation");
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
994 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
995 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
996
900
dc13766d1eeb fixed file copy/move dialog
nadvornik
parents: 897
diff changeset
997 static void file_util_fdlg_ok_cb(FileDialog *fdlg, gpointer data)
dc13766d1eeb fixed file copy/move dialog
nadvornik
parents: 897
diff changeset
998 {
dc13766d1eeb fixed file copy/move dialog
nadvornik
parents: 897
diff changeset
999 UtilityData *ud = data;
dc13766d1eeb fixed file copy/move dialog
nadvornik
parents: 897
diff changeset
1000
dc13766d1eeb fixed file copy/move dialog
nadvornik
parents: 897
diff changeset
1001 file_util_dest_folder_update_path(ud);
946
1d6e01950e85 remember path entered in file dialog
nadvornik
parents: 937
diff changeset
1002 if (isdir(ud->dest_path)) file_dialog_sync_history(fdlg, TRUE);
900
dc13766d1eeb fixed file copy/move dialog
nadvornik
parents: 897
diff changeset
1003 file_dialog_close(fdlg);
dc13766d1eeb fixed file copy/move dialog
nadvornik
parents: 897
diff changeset
1004
dc13766d1eeb fixed file copy/move dialog
nadvornik
parents: 897
diff changeset
1005 ud->fdlg = NULL;
dc13766d1eeb fixed file copy/move dialog
nadvornik
parents: 897
diff changeset
1006
dc13766d1eeb fixed file copy/move dialog
nadvornik
parents: 897
diff changeset
1007 file_util_dialog_run(ud);
dc13766d1eeb fixed file copy/move dialog
nadvornik
parents: 897
diff changeset
1008 }
dc13766d1eeb fixed file copy/move dialog
nadvornik
parents: 897
diff changeset
1009
dc13766d1eeb fixed file copy/move dialog
nadvornik
parents: 897
diff changeset
1010
dc13766d1eeb fixed file copy/move dialog
nadvornik
parents: 897
diff changeset
1011 static void file_util_dest_folder_entry_cb(GtkWidget *entry, gpointer data)
dc13766d1eeb fixed file copy/move dialog
nadvornik
parents: 897
diff changeset
1012 {
dc13766d1eeb fixed file copy/move dialog
nadvornik
parents: 897
diff changeset
1013 UtilityData *ud = data;
dc13766d1eeb fixed file copy/move dialog
nadvornik
parents: 897
diff changeset
1014 file_util_dest_folder_update_path(ud);
dc13766d1eeb fixed file copy/move dialog
nadvornik
parents: 897
diff changeset
1015 }
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1016
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1017 /* 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
1018 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
1019 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1020 gchar *new_name;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1021 gchar *parsed;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1022 const gchar *ext;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1023 gchar *middle;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1024 gchar *tmp;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1025 gchar *pad_start;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1026 gchar *pad_end;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1027 gint padding;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1028
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1029 if (!format || !name) return NULL;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1030
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1031 tmp = g_strdup(format);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1032 pad_start = strchr(tmp, '#');
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1033 if (pad_start)
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1034 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1035 pad_end = pad_start;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1036 padding = 0;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1037 while (*pad_end == '#')
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1038 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1039 pad_end++;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1040 padding++;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1041 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1042 *pad_start = '\0';
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1043
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1044 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
1045 g_free(tmp);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1046 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1047 else
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1048 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1049 parsed = tmp;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1050 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1051
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1052 ext = extension_from_path(name);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1053
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1054 middle = strchr(parsed, '*');
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1055 if (middle)
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1056 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1057 gchar *base;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1058
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1059 *middle = '\0';
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1060 middle++;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1061
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1062 base = remove_extension_from_path(name);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1063 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
1064 g_free(base);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1065 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1066 else
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1067 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1068 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
1069 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1070
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1071 g_free(parsed);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1072
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1073 return new_name;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1074 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1075
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1076
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1077 static void file_util_rename_preview_update(UtilityData *ud)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1078 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1079 GtkTreeModel *store;
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1080 GtkTreeSelection *selection;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1081 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1082 const gchar *front;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1083 const gchar *end;
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1084 const gchar *format;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1085 gint valid;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1086 gint start_n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1087 gint padding;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1088 gint n;
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1089 gint mode;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1090
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1091 mode = gtk_notebook_get_current_page(GTK_NOTEBOOK(ud->notebook));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1092
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1093 if (mode == UTILITY_RENAME)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1094 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1095 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(ud->listview));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1096 if (gtk_tree_selection_get_selected(selection, &store, &iter))
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1097 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1098 FileData *fd;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1099 const gchar *dest = gtk_entry_get_text(GTK_ENTRY(ud->rename_entry));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1100
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1101 gtk_tree_model_get(store, &iter, UTILITY_COLUMN_FD, &fd, -1);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1102 file_data_sc_update_ci_rename(fd, dest);
995
6ca2c5fd7b13 Whitespaces cleanup.
zas_
parents: 974
diff changeset
1103 gtk_list_store_set(GTK_LIST_STORE(store), &iter,
924
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
1104 UTILITY_COLUMN_PIXBUF, file_util_get_error_icon(fd, ud->listview),
995
6ca2c5fd7b13 Whitespaces cleanup.
zas_
parents: 974
diff changeset
1105 UTILITY_COLUMN_DEST_PATH, fd->change->dest,
6ca2c5fd7b13 Whitespaces cleanup.
zas_
parents: 974
diff changeset
1106 UTILITY_COLUMN_DEST_NAME, filename_from_path(fd->change->dest),
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1107 -1);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1108 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1109 return;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1110 }
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1111
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1112
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1113 front = gtk_entry_get_text(GTK_ENTRY(ud->auto_entry_front));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1114 end = gtk_entry_get_text(GTK_ENTRY(ud->auto_entry_end));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1115 padding = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ud->auto_spin_pad));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1116
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1117 format = gtk_entry_get_text(GTK_ENTRY(ud->format_entry));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1118
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1119 if (mode == UTILITY_RENAME_FORMATTED)
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1120 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1121 start_n = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ud->format_spin));
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1122 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1123 else
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1124 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1125 start_n = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ud->auto_spin_start));
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1126 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1127
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1128 store = gtk_tree_view_get_model(GTK_TREE_VIEW(ud->listview));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1129 n = start_n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1130 valid = gtk_tree_model_get_iter_first(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1131 while (valid)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1132 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1133 gchar *dest;
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1134 FileData *fd;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1135 gtk_tree_model_get(store, &iter, UTILITY_COLUMN_FD, &fd, -1);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1136
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1137 if (mode == UTILITY_RENAME_FORMATTED)
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1138 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1139 dest = 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
1140 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1141 else
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1142 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1143 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
1144 }
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1145
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1146 file_data_sc_update_ci_rename(fd, dest);
995
6ca2c5fd7b13 Whitespaces cleanup.
zas_
parents: 974
diff changeset
1147 gtk_list_store_set(GTK_LIST_STORE(store), &iter,
924
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
1148 UTILITY_COLUMN_PIXBUF, file_util_get_error_icon(fd, ud->listview),
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
1149 UTILITY_COLUMN_DEST_PATH, fd->change->dest,
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1150 UTILITY_COLUMN_DEST_NAME, filename_from_path(fd->change->dest),
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1151 -1);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1152 g_free(dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1153
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1154 n++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1155 valid = gtk_tree_model_iter_next(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1156 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1157
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1158 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1159
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1160 static void file_util_rename_preview_entry_cb(GtkWidget *entry, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1161 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1162 UtilityData *ud = data;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1163 file_util_rename_preview_update(ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1164 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1165
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1166 static void file_util_rename_preview_adj_cb(GtkWidget *spin, gpointer data)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1167 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1168 UtilityData *ud = data;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1169 file_util_rename_preview_update(ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1170 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1171
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1172 static gboolean file_util_rename_idle_cb(gpointer data)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1173 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1174 UtilityData *ud = data;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1175
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1176 file_util_rename_preview_update(ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1177
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1178 ud->update_idle_id = -1;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1179 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1180 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1181
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1182 static void file_util_rename_preview_order_cb(GtkTreeModel *treemodel, GtkTreePath *tpath,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1183 GtkTreeIter *iter, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1184 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1185 UtilityData *ud = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1186
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
1187 if (ud->update_idle_id != -1) return;
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
1188
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
1189 ud->update_idle_id = g_idle_add(file_util_rename_idle_cb, ud);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1190 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1191
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1192
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1193 static gboolean file_util_preview_cb(GtkTreeSelection *selection, GtkTreeModel *store,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1194 GtkTreePath *tpath, gboolean path_currently_selected,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1195 gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1196 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1197 UtilityData *ud = data;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1198 GtkTreeIter iter;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1199 FileData *fd = NULL;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1200
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1201 if (path_currently_selected ||
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1202 !gtk_tree_model_get_iter(store, &iter, tpath)) return TRUE;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1203
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1204 gtk_tree_model_get(store, &iter, UTILITY_COLUMN_FD, &fd, -1);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1205 generic_dialog_image_set(ud->gd, fd);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1206
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1207 if (ud->type == UTILITY_TYPE_RENAME)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1208 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1209 const gchar *name = filename_from_path(fd->change->dest);
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
1210
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1211 gtk_widget_grab_focus(ud->rename_entry);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1212 gtk_label_set_text(GTK_LABEL(ud->rename_label), fd->name);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1213 g_signal_handlers_block_by_func(ud->rename_entry, G_CALLBACK(file_util_rename_preview_entry_cb), ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1214 gtk_entry_set_text(GTK_ENTRY(ud->rename_entry), name);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1215 gtk_editable_select_region(GTK_EDITABLE(ud->rename_entry), 0, filename_base_length(name));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1216 g_signal_handlers_unblock_by_func(ud->rename_entry, G_CALLBACK(file_util_rename_preview_entry_cb), ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1217 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1218
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1219 return TRUE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1220 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1221
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1222
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1223
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1224 static void box_append_safe_delete_status(GenericDialog *gd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1225 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1226 GtkWidget *label;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1227 gchar *buf;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1228
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1229 buf = file_util_safe_delete_status();
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1230 label = pref_label_new(gd->vbox, buf);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1231 g_free(buf);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1232
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1233 gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1234 gtk_widget_set_sensitive(label, FALSE);
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
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1237
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1238 static void file_util_dialog_init_simple_list(UtilityData *ud)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1239 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1240 GtkWidget *box;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1241 GtkTreeSelection *selection;
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1242 gchar *dir_msg;
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
1243
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1244 ud->gd = file_util_gen_dlg(ud->messages.title, GQ_WMCLASS, "dlg_confirm",
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
1245 ud->parent, FALSE, file_util_cancel_cb, ud);
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1246 generic_dialog_add_button(ud->gd, GTK_STOCK_DELETE, NULL, file_util_ok_cb, TRUE);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1247
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1248
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1249 if (ud->dir_fd)
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1250 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1251 dir_msg = g_strdup_printf("%s\n\n%s\n", ud->messages.desc_source_fd, ud->dir_fd->path);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1252 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1253 else
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1254 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1255 dir_msg = g_strdup("");
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1256 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1257
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1258 box = generic_dialog_add_message(ud->gd, GTK_STOCK_DIALOG_QUESTION,
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
1259 ud->messages.question,
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1260 dir_msg);
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1261
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1262 g_free(dir_msg);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1263
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1264 box = pref_group_new(box, TRUE, ud->messages.desc_flist, GTK_ORIENTATION_HORIZONTAL);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1265
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1266 ud->listview = file_util_dialog_add_list(box, ud->flist, FALSE);
924
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
1267 file_util_dialog_add_list_column(ud->listview, _("Sidecars"), FALSE, UTILITY_COLUMN_SIDECARS);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1268
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1269 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(ud->listview));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1270 gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1271 gtk_tree_selection_set_select_function(selection, file_util_preview_cb, ud, NULL);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1272
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1273 generic_dialog_add_image(ud->gd, box, NULL, NULL, NULL, NULL, FALSE);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1274
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1275 box_append_safe_delete_status(ud->gd);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1276
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1277 gtk_widget_show(ud->gd->dialog);
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1278
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1279 file_util_dialog_list_select(ud->listview, 0);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1280 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1281
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1282 static void file_util_dialog_init_dest_folder(UtilityData *ud)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1283 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1284 FileDialog *fdlg;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1285 GtkWidget *label;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1286 const gchar *stock_id;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1287
995
6ca2c5fd7b13 Whitespaces cleanup.
zas_
parents: 974
diff changeset
1288 if (ud->type == UTILITY_TYPE_COPY)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1289 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1290 stock_id = GTK_STOCK_COPY;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1291 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1292 else
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1293 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1294 stock_id = GTK_STOCK_OK;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1295 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1296
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1297 fdlg = file_util_file_dlg(ud->messages.title, GQ_WMCLASS, "dlg_dest_folder", ud->parent,
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
1298 file_util_fdlg_cancel_cb, ud);
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1299
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1300 ud->fdlg = fdlg;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1301
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1302 generic_dialog_add_message(GENERIC_DIALOG(fdlg), NULL, ud->messages.question, NULL);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1303
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1304 label = pref_label_new(GENERIC_DIALOG(fdlg)->vbox, _("Choose the destination folder."));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1305 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1306 pref_spacer(GENERIC_DIALOG(fdlg)->vbox, 0);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1307
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1308 file_dialog_add_button(fdlg, stock_id, ud->messages.title, file_util_fdlg_ok_cb, TRUE);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1309
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1310 file_dialog_add_path_widgets(fdlg, NULL, ud->dest_path, "move_copy", NULL, NULL);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1311
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1312 g_signal_connect(G_OBJECT(fdlg->entry), "changed",
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1313 G_CALLBACK(file_util_dest_folder_entry_cb), ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1314
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1315 gtk_widget_show(GENERIC_DIALOG(fdlg)->dialog);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1316 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1317
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1318
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1319 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
1320 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1321 GtkWidget *vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1322 GtkWidget *label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1323
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1324 vbox = gtk_vbox_new(FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1325 gtk_box_pack_start(GTK_BOX(box), vbox, expand, expand, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1326 gtk_widget_show(vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1327
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1328 label = gtk_label_new(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1329 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1330 gtk_widget_show(label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1331
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1332 return vbox;
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
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1335
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1336 static void file_util_dialog_init_source_dest(UtilityData *ud)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1337 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1338 GtkTreeModel *store;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1339 GtkTreeSelection *selection;
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1340 GtkWidget *box;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1341 GtkWidget *hbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1342 GtkWidget *box2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1343 GtkWidget *table;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1344 GtkWidget *combo;
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1345 GtkWidget *page;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1346
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1347 ud->gd = file_util_gen_dlg(ud->messages.title, GQ_WMCLASS, "dlg_confirm",
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
1348 ud->parent, FALSE, file_util_cancel_cb, ud);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1349
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1350 box = generic_dialog_add_message(ud->gd, NULL, ud->messages.question, NULL);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1351 generic_dialog_add_button(ud->gd, GTK_STOCK_OK, ud->messages.title, file_util_ok_cb, TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1352
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1353 box = pref_group_new(box, TRUE, ud->messages.desc_flist, GTK_ORIENTATION_HORIZONTAL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1354
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1355 ud->listview = file_util_dialog_add_list(box, ud->flist, FALSE);
924
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
1356 file_util_dialog_add_list_column(ud->listview, _("Sidecars"), FALSE, UTILITY_COLUMN_SIDECARS);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 341
diff changeset
1357
924
96a1f535ce89 indicate check warnings and errors in delete and rename dialogs
nadvornik
parents: 921
diff changeset
1358 file_util_dialog_add_list_column(ud->listview, _("New name"), FALSE, UTILITY_COLUMN_DEST_NAME);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1359
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1360 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(ud->listview));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1361 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_SINGLE);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1362 gtk_tree_selection_set_select_function(selection, file_util_preview_cb, ud, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1363
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1364
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1365 // column = file_util_rename_multiple_add_column(rd, _("Preview"), RENAME_COLUMN_PREVIEW);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1366 // gtk_tree_view_column_set_visible(column, FALSE);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 341
diff changeset
1367
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1368 gtk_tree_view_set_reorderable(GTK_TREE_VIEW(ud->listview), TRUE);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1369
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1370 store = gtk_tree_view_get_model(GTK_TREE_VIEW(ud->listview));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1371 g_signal_connect(G_OBJECT(store), "row_changed",
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1372 G_CALLBACK(file_util_rename_preview_order_cb), ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1373 gtk_widget_set_size_request(ud->listview, 300, 150);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1374
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1375 generic_dialog_add_image(ud->gd, box, NULL, NULL, NULL, NULL, FALSE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1376
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1377 // gtk_container_add(GTK_CONTAINER(scrolled), view);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1378 gtk_widget_show(ud->gd->dialog);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1379
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1380
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1381 ud->notebook = gtk_notebook_new();
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1382
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1383 gtk_box_pack_start(GTK_BOX(ud->gd->vbox), ud->notebook, FALSE, FALSE, 0);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1384 gtk_widget_show(ud->notebook);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1385
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1386
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1387 page = gtk_vbox_new(FALSE, PREF_PAD_GAP);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1388 gtk_notebook_append_page(GTK_NOTEBOOK(ud->notebook), page, gtk_label_new(_("Manual rename")));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1389 gtk_widget_show(page);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1390
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1391 table = pref_table_new(page, 2, 2, FALSE, FALSE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1392
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1393 pref_table_label(table, 0, 0, _("Original name:"), 1.0);
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1394 ud->rename_label = pref_table_label(table, 1, 0, "", 0.0);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1395
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1396 pref_table_label(table, 0, 1, _("New name:"), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1397
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1398 ud->rename_entry = gtk_entry_new();
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1399 gtk_table_attach(GTK_TABLE(table), ud->rename_entry, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1400 generic_dialog_attach_default(GENERIC_DIALOG(ud->gd), ud->rename_entry);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1401 gtk_widget_grab_focus(ud->rename_entry);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1402
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1403 g_signal_connect(G_OBJECT(ud->rename_entry), "changed",
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1404 G_CALLBACK(file_util_rename_preview_entry_cb), ud);
42
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
1405
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1406 gtk_widget_show(ud->rename_entry);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1407
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1408 page = gtk_vbox_new(FALSE, PREF_PAD_GAP);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1409 gtk_notebook_append_page(GTK_NOTEBOOK(ud->notebook), page, gtk_label_new(_("Auto rename")));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1410 gtk_widget_show(page);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1411
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1412
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1413 hbox = pref_box_new(page, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_GAP);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1414
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1415 box2 = furm_simple_vlabel(hbox, _("Begin text"), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1416
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1417 combo = history_combo_new(&ud->auto_entry_front, "", "numerical_rename_prefix", -1);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1418 g_signal_connect(G_OBJECT(ud->auto_entry_front), "changed",
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1419 G_CALLBACK(file_util_rename_preview_entry_cb), ud);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1420 gtk_box_pack_start(GTK_BOX(box2), combo, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1421 gtk_widget_show(combo);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 341
diff changeset
1422
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1423 box2 = furm_simple_vlabel(hbox, _("Start #"), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1424
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1425 ud->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
1426 0.0, 1000000.0, 1.0, 0, 1.0,
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1427 G_CALLBACK(file_util_rename_preview_adj_cb), ud);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1428
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1429 box2 = furm_simple_vlabel(hbox, _("End text"), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1430
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1431 combo = history_combo_new(&ud->auto_entry_end, "", "numerical_rename_suffix", -1);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1432 g_signal_connect(G_OBJECT(ud->auto_entry_end), "changed",
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1433 G_CALLBACK(file_util_rename_preview_entry_cb), ud);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1434 gtk_box_pack_start(GTK_BOX(box2), combo, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1435 gtk_widget_show(combo);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1436
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1437 ud->auto_spin_pad = pref_spin_new(page, _("Padding:"), NULL,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1438 1.0, 8.0, 1.0, 0, 1.0,
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1439 G_CALLBACK(file_util_rename_preview_adj_cb), ud);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1440
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1441 page = gtk_vbox_new(FALSE, PREF_PAD_GAP);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1442 gtk_notebook_append_page(GTK_NOTEBOOK(ud->notebook), page, gtk_label_new(_("Formatted rename")));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1443 gtk_widget_show(page);
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1444
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1445 hbox = pref_box_new(page, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_GAP);
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1446
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1447 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
1448
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1449 combo = history_combo_new(&ud->format_entry, "", "auto_rename_format", -1);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1450 g_signal_connect(G_OBJECT(ud->format_entry), "changed",
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1451 G_CALLBACK(file_util_rename_preview_entry_cb), ud);
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1452 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
1453 gtk_widget_show(combo);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 341
diff changeset
1454
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1455 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
1456
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1457 ud->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
1458 0.0, 1000000.0, 1.0, 0, 1.0,
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1459 G_CALLBACK(file_util_rename_preview_adj_cb), ud);
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1460
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1461 // gtk_combo_box_set_active(GTK_COMBO_BOX(ud->combo_type), 0); /* callback will take care of the rest */
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1462
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1463 file_util_dialog_list_select(ud->listview, 0);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1464 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1465
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1466
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1467 void file_util_dialog_run(UtilityData *ud)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1468 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1469 switch (ud->phase)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1470 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1471 case UTILITY_PHASE_START:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1472 /* create the dialogs */
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1473 switch (ud->type)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1474 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1475 case UTILITY_TYPE_DELETE:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1476 case UTILITY_TYPE_DELETE_LINK:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1477 case UTILITY_TYPE_DELETE_FOLDER:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1478 case UTILITY_TYPE_EDITOR:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1479 file_util_dialog_init_simple_list(ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1480 break;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1481 case UTILITY_TYPE_RENAME:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1482 file_util_dialog_init_source_dest(ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1483 break;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1484 case UTILITY_TYPE_COPY:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1485 case UTILITY_TYPE_MOVE:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1486 case UTILITY_TYPE_FILTER:
901
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
1487 case UTILITY_TYPE_CREATE_FOLDER:
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1488 file_util_dialog_init_dest_folder(ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1489 break;
934
6aa60ae6f274 fixed renaming of directories
nadvornik
parents: 932
diff changeset
1490 case UTILITY_TYPE_RENAME_FOLDER:
6aa60ae6f274 fixed renaming of directories
nadvornik
parents: 932
diff changeset
1491 ud->phase = UTILITY_PHASE_CANCEL; /* FIXME - not handled for now */
6aa60ae6f274 fixed renaming of directories
nadvornik
parents: 932
diff changeset
1492 file_util_dialog_run(ud);
6aa60ae6f274 fixed renaming of directories
nadvornik
parents: 932
diff changeset
1493 return;
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1494 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1495 ud->phase = UTILITY_PHASE_ENTERING;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1496 break;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1497 case UTILITY_PHASE_ENTERING:
914
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
1498 file_util_check_ci(ud);
9427c91951e8 basic infrastructure for early error and dangerous operations checking
nadvornik
parents: 908
diff changeset
1499 break;
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1500
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1501 ud->phase = UTILITY_PHASE_CHECKED;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1502 case UTILITY_PHASE_CHECKED:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1503 file_util_perform_ci(ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1504 break;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1505 case UTILITY_PHASE_CANCEL:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1506 case UTILITY_PHASE_DONE:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1507 file_data_sc_free_ci_list(ud->flist);
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1508 file_data_sc_free_ci_list(ud->content_list);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1509 if (ud->dir_fd) file_data_sc_free_ci(ud->dir_fd);
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1510 file_util_data_free(ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1511 break;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1512 }
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1513 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1514
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1515
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1516
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1517
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
1518 static void file_util_warn_op_in_progress(const gchar *title)
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
1519 {
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
1520 file_util_warning_dialog(title, _("Another operation in progress.\n"), GTK_STOCK_DIALOG_ERROR, NULL);
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
1521 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1522
849
db68d673448f added possibility to disable grouping of selected files
nadvornik
parents: 800
diff changeset
1523 static void file_util_disable_grouping_sc_list(GList *list)
db68d673448f added possibility to disable grouping of selected files
nadvornik
parents: 800
diff changeset
1524 {
db68d673448f added possibility to disable grouping of selected files
nadvornik
parents: 800
diff changeset
1525 GList *work = list;
db68d673448f added possibility to disable grouping of selected files
nadvornik
parents: 800
diff changeset
1526
855
0c3f6ef17d18 Tidy up.
zas_
parents: 849
diff changeset
1527 while (work)
849
db68d673448f added possibility to disable grouping of selected files
nadvornik
parents: 800
diff changeset
1528 {
db68d673448f added possibility to disable grouping of selected files
nadvornik
parents: 800
diff changeset
1529 FileData *fd = work->data;
db68d673448f added possibility to disable grouping of selected files
nadvornik
parents: 800
diff changeset
1530 work = work->next;
db68d673448f added possibility to disable grouping of selected files
nadvornik
parents: 800
diff changeset
1531
db68d673448f added possibility to disable grouping of selected files
nadvornik
parents: 800
diff changeset
1532 if (fd->parent) file_data_disable_grouping(fd, TRUE);
db68d673448f added possibility to disable grouping of selected files
nadvornik
parents: 800
diff changeset
1533 }
db68d673448f added possibility to disable grouping of selected files
nadvornik
parents: 800
diff changeset
1534
db68d673448f added possibility to disable grouping of selected files
nadvornik
parents: 800
diff changeset
1535 }
db68d673448f added possibility to disable grouping of selected files
nadvornik
parents: 800
diff changeset
1536
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1537 static void file_util_delete_full(FileData *source_fd, GList *source_list, GtkWidget *parent, UtilityPhase phase)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1538 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1539 UtilityData *ud;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1540 GList *flist = filelist_copy(source_list);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1541
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1542 if (source_fd)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1543 flist = g_list_append(flist, file_data_ref(source_fd));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1544
947
368643594bc8 abort file operations when the file list is empty
nadvornik
parents: 946
diff changeset
1545 if (!flist) return;
368643594bc8 abort file operations when the file list is empty
nadvornik
parents: 946
diff changeset
1546
849
db68d673448f added possibility to disable grouping of selected files
nadvornik
parents: 800
diff changeset
1547 file_util_disable_grouping_sc_list(flist);
db68d673448f added possibility to disable grouping of selected files
nadvornik
parents: 800
diff changeset
1548
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1549 if (!file_data_sc_add_ci_delete_list(flist))
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1550 {
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
1551 file_util_warn_op_in_progress(_("File deletion failed"));
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1552 filelist_free(flist);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1553 return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1554 }
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1555
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1556 ud = file_util_data_new(UTILITY_TYPE_DELETE);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1557
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1558 ud->phase = phase;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1559
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1560 ud->dir_fd = NULL;
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1561 ud->flist = flist;
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1562 ud->content_list = NULL;
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1563 ud->parent = parent;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1564
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1565 ud->messages.title = _("Delete");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1566 ud->messages.question = _("Delete files?");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1567 ud->messages.desc_flist = _("This will delete the following files");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1568 ud->messages.desc_source_fd = "";
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1569 ud->messages.fail = _("File deletion failed");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1570
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1571 file_util_dialog_run(ud);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1572 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1573
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1574 static void file_util_move_full(FileData *source_fd, GList *source_list, const gchar *dest_path, GtkWidget *parent, UtilityPhase phase)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1575 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1576 UtilityData *ud;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1577 GList *flist = filelist_copy(source_list);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1578
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1579 if (source_fd)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1580 flist = g_list_append(flist, file_data_ref(source_fd));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1581
947
368643594bc8 abort file operations when the file list is empty
nadvornik
parents: 946
diff changeset
1582 if (!flist) return;
368643594bc8 abort file operations when the file list is empty
nadvornik
parents: 946
diff changeset
1583
849
db68d673448f added possibility to disable grouping of selected files
nadvornik
parents: 800
diff changeset
1584 file_util_disable_grouping_sc_list(flist);
db68d673448f added possibility to disable grouping of selected files
nadvornik
parents: 800
diff changeset
1585
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1586 if (!file_data_sc_add_ci_move_list(flist, dest_path))
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1587 {
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
1588 file_util_warn_op_in_progress(_("Move failed"));
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1589 filelist_free(flist);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1590 return;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1591 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1592
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1593 ud = file_util_data_new(UTILITY_TYPE_MOVE);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1594
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1595 ud->phase = phase;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1596
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1597 ud->dir_fd = NULL;
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1598 ud->flist = flist;
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1599 ud->content_list = NULL;
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1600 ud->parent = parent;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1601
900
dc13766d1eeb fixed file copy/move dialog
nadvornik
parents: 897
diff changeset
1602 if (dest_path) ud->dest_path = g_strdup(dest_path);
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1603
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1604 ud->messages.title = _("Move");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1605 ud->messages.question = _("Move files?");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1606 ud->messages.desc_flist = _("This will move the following files");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1607 ud->messages.desc_source_fd = "";
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1608 ud->messages.fail = _("Move failed");
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1609
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1610 file_util_dialog_run(ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1611 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1612 static void file_util_copy_full(FileData *source_fd, GList *source_list, const gchar *dest_path, GtkWidget *parent, UtilityPhase phase)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1613 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1614 UtilityData *ud;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1615 GList *flist = filelist_copy(source_list);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1616
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1617 if (source_fd)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1618 flist = g_list_append(flist, file_data_ref(source_fd));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1619
947
368643594bc8 abort file operations when the file list is empty
nadvornik
parents: 946
diff changeset
1620 if (!flist) return;
368643594bc8 abort file operations when the file list is empty
nadvornik
parents: 946
diff changeset
1621
849
db68d673448f added possibility to disable grouping of selected files
nadvornik
parents: 800
diff changeset
1622 file_util_disable_grouping_sc_list(flist);
db68d673448f added possibility to disable grouping of selected files
nadvornik
parents: 800
diff changeset
1623
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1624 if (!file_data_sc_add_ci_copy_list(flist, dest_path))
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1625 {
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
1626 file_util_warn_op_in_progress(_("Copy failed"));
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1627 filelist_free(flist);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1628 return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1629 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1630
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1631 ud = file_util_data_new(UTILITY_TYPE_COPY);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1632
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1633 ud->phase = phase;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1634
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1635 ud->dir_fd = NULL;
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1636 ud->flist = flist;
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1637 ud->content_list = NULL;
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1638 ud->parent = parent;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1639
900
dc13766d1eeb fixed file copy/move dialog
nadvornik
parents: 897
diff changeset
1640 if (dest_path) ud->dest_path = g_strdup(dest_path);
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1641
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1642 ud->messages.title = _("Copy");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1643 ud->messages.question = _("Copy files?");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1644 ud->messages.desc_flist = _("This will copy the following files");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1645 ud->messages.desc_source_fd = "";
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1646 ud->messages.fail = _("Copy failed");
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1647
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1648 file_util_dialog_run(ud);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1649 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1650
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1651 static void file_util_rename_full(FileData *source_fd, GList *source_list, const gchar *dest_path, GtkWidget *parent, UtilityPhase phase)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1652 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1653 UtilityData *ud;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1654 GList *flist = filelist_copy(source_list);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1655
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1656 if (source_fd)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1657 flist = g_list_append(flist, file_data_ref(source_fd));
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1658
947
368643594bc8 abort file operations when the file list is empty
nadvornik
parents: 946
diff changeset
1659 if (!flist) return;
368643594bc8 abort file operations when the file list is empty
nadvornik
parents: 946
diff changeset
1660
849
db68d673448f added possibility to disable grouping of selected files
nadvornik
parents: 800
diff changeset
1661 file_util_disable_grouping_sc_list(flist);
db68d673448f added possibility to disable grouping of selected files
nadvornik
parents: 800
diff changeset
1662
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1663 if (!file_data_sc_add_ci_rename_list(flist, dest_path))
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1664 {
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
1665 file_util_warn_op_in_progress(_("Rename failed"));
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1666 filelist_free(flist);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1667 return;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1668 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1669
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1670 ud = file_util_data_new(UTILITY_TYPE_RENAME);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1671
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1672 ud->phase = phase;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1673
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1674 ud->dir_fd = NULL;
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1675 ud->flist = flist;
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1676 ud->content_list = NULL;
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1677 ud->parent = parent;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1678
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1679 ud->messages.title = _("Rename");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1680 ud->messages.question = _("Rename files?");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1681 ud->messages.desc_flist = _("This will rename the following files");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1682 ud->messages.desc_source_fd = "";
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1683 ud->messages.fail = _("Rename failed");
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1684
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1685 file_util_dialog_run(ud);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1686 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1687
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1688 static void file_util_start_editor_full(gint n, FileData *source_fd, GList *source_list, const gchar *dest_path, GtkWidget *parent, UtilityPhase phase)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1689 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1690 UtilityData *ud;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1691 GList *flist = filelist_copy(source_list);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1692
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1693 if (source_fd)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1694 flist = g_list_append(flist, file_data_ref(source_fd));
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1695
947
368643594bc8 abort file operations when the file list is empty
nadvornik
parents: 946
diff changeset
1696 if (!flist) return;
368643594bc8 abort file operations when the file list is empty
nadvornik
parents: 946
diff changeset
1697
849
db68d673448f added possibility to disable grouping of selected files
nadvornik
parents: 800
diff changeset
1698 file_util_disable_grouping_sc_list(flist);
db68d673448f added possibility to disable grouping of selected files
nadvornik
parents: 800
diff changeset
1699
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1700 if (!file_data_sc_add_ci_unspecified_list(flist, dest_path))
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1701 {
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
1702 file_util_warn_op_in_progress(_("Can't run external editor"));
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1703 filelist_free(flist);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1704 return;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1705 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1706
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1707 if (editor_is_filter(n))
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1708 ud = file_util_data_new(UTILITY_TYPE_FILTER);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1709 else
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1710 ud = file_util_data_new(UTILITY_TYPE_EDITOR);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1711
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1712
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1713 /* ask for destination if we don't have it */
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1714 if (ud->type == UTILITY_TYPE_FILTER && dest_path == NULL) phase = UTILITY_PHASE_START;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1715
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1716 ud->phase = phase;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1717
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1718 ud->external_command = n;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1719
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1720 ud->dir_fd = NULL;
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1721 ud->flist = flist;
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1722 ud->content_list = NULL;
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1723 ud->parent = parent;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1724
900
dc13766d1eeb fixed file copy/move dialog
nadvornik
parents: 897
diff changeset
1725 if (dest_path) ud->dest_path = g_strdup(dest_path);
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1726
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1727 ud->messages.title = _("Editor");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1728 ud->messages.question = _("Run editor?");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1729 ud->messages.desc_flist = _("This will copy the following files");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1730 ud->messages.desc_source_fd = "";
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1731 ud->messages.fail = _("External command failed");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1732
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1733 file_util_dialog_run(ud);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1734 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1735
901
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
1736 static GList *file_util_delete_dir_remaining_folders(GList *dlist)
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
1737 {
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
1738 GList *rlist = NULL;
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
1739
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
1740 while (dlist)
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
1741 {
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
1742 FileData *fd;
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
1743
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
1744 fd = dlist->data;
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
1745 dlist = dlist->next;
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1746
901
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
1747 if (!fd->name ||
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
1748 (strcmp(fd->name, THUMB_FOLDER_GLOBAL) != 0 &&
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
1749 strcmp(fd->name, THUMB_FOLDER_LOCAL) != 0 &&
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
1750 strcmp(fd->name, GQ_CACHE_LOCAL_METADATA) != 0) )
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
1751 {
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
1752 rlist = g_list_prepend(rlist, fd);
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
1753 }
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
1754 }
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
1755
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
1756 return g_list_reverse(rlist);
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
1757 }
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1758
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1759 static gboolean file_util_delete_dir_empty_path(UtilityData *ud, FileData *fd, gint level)
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1760 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1761 GList *dlist;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1762 GList *flist;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1763 GList *work;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1764
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1765 gboolean ok = TRUE;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1766
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1767 DEBUG_1("deltree into: %s", fd->path);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1768
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1769 level++;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1770 if (level > UTILITY_DELETE_MAX_DEPTH)
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1771 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1772 log_printf("folder recursion depth past %d, giving up\n", UTILITY_DELETE_MAX_DEPTH);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1773 // ud->fail_fd = fd
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1774 return 0;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1775 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1776
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1777 if (!filelist_read_lstat(fd, &flist, &dlist))
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1778 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1779 // ud->fail_fd = fd
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1780 return 0;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1781 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1782
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1783 if (ok)
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1784 {
921
b416159a5820 Tidy up.
zas_
parents: 914
diff changeset
1785 ok = file_data_sc_add_ci_delete(fd);
b416159a5820 Tidy up.
zas_
parents: 914
diff changeset
1786 if (ok)
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1787 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1788 ud->content_list = g_list_prepend(ud->content_list, fd);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1789 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1790 // ud->fail_fd = fd
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1791 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1792
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1793 work = dlist;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1794 while (work && ok)
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1795 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1796 FileData *lfd;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1797
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1798 lfd = work->data;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1799 work = work->next;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1800
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1801 ok = file_util_delete_dir_empty_path(ud, lfd, level);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1802 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1803
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1804 work = flist;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1805 while (work && ok)
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1806 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1807 FileData *lfd;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1808
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1809 lfd = work->data;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1810 work = work->next;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1811
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1812 DEBUG_1("deltree child: %s", lfd->path);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1813
921
b416159a5820 Tidy up.
zas_
parents: 914
diff changeset
1814 ok = file_data_sc_add_ci_delete(lfd);
b416159a5820 Tidy up.
zas_
parents: 914
diff changeset
1815 if (ok)
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1816 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1817 ud->content_list = g_list_prepend(ud->content_list, lfd);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1818 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1819 // ud->fail_fd = fd
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1820 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1821
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1822 filelist_free(dlist);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1823 filelist_free(flist);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1824
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1825
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1826 DEBUG_1("deltree done: %s", fd->path);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1827
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1828 return ok;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1829 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1830
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1831 static gboolean file_util_delete_dir_prepare(UtilityData *ud, GList *flist, GList *dlist)
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1832 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1833 gboolean ok = TRUE;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1834 GList *work;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1835
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1836
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1837 work = dlist;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1838 while (work && ok)
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1839 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1840 FileData *fd;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1841
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1842 fd = work->data;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1843 work = work->next;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1844
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1845 ok = file_util_delete_dir_empty_path(ud, fd, 0);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1846 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1847
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1848 work = flist;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1849 if (ok && file_data_sc_add_ci_delete_list(flist))
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1850 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1851 ud->content_list = g_list_concat(filelist_copy(flist), ud->content_list);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1852 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1853 else
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1854 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1855 ok = FALSE;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1856 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1857
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1858 if (ok)
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1859 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1860 ok = file_data_sc_add_ci_delete(ud->dir_fd);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1861 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1862
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1863 if (!ok)
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1864 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1865 work = ud->content_list;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1866 while (work)
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1867 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1868 FileData *fd;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1869
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1870 fd = work->data;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1871 work = work->next;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1872 file_data_sc_free_ci(fd);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1873 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1874 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1875
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1876 return ok;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1877 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1878
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1879 static void file_util_delete_dir_full(FileData *fd, GtkWidget *parent, UtilityPhase phase)
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1880 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1881 GList *dlist;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1882 GList *flist;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1883 GList *rlist;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1884
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1885 if (!isdir(fd->path)) return;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1886
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1887 if (islink(fd->path))
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1888 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1889 UtilityData *ud;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1890 ud = file_util_data_new(UTILITY_TYPE_DELETE_LINK);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1891
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1892 ud->phase = phase;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1893 ud->dir_fd = file_data_ref(fd);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1894 ud->content_list = NULL;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1895 ud->flist = NULL;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1897 ud->parent = parent;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1898
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1899 ud->messages.title = _("Delete folder");
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1900 ud->messages.question = _("Delete symbolic link?");
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1901 ud->messages.desc_flist = "";
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1902 ud->messages.desc_source_fd = _("This will delete the symbolic link.\n"
995
6ca2c5fd7b13 Whitespaces cleanup.
zas_
parents: 974
diff changeset
1903 "The folder this link points to will not be deleted.");
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1904 ud->messages.fail = _("Link deletion failed");
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1905
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1906 file_util_dialog_run(ud);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1907 return;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1908 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1909
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1910 if (!access_file(fd->path, W_OK | X_OK))
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1911 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1912 gchar *text;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1913
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1914 text = g_strdup_printf(_("Unable to remove folder %s\n"
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1915 "Permissions do not allow writing to the folder."), fd->path);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1916 file_util_warning_dialog(_("Delete failed"), text, GTK_STOCK_DIALOG_ERROR, parent);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1917 g_free(text);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1918
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1919 return;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1920 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1921
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1922 if (!filelist_read_lstat(fd, &flist, &dlist))
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1923 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1924 gchar *text;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1925
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1926 text = g_strdup_printf(_("Unable to list contents of folder %s"), fd->path);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1927 file_util_warning_dialog(_("Delete failed"), text, GTK_STOCK_DIALOG_ERROR, parent);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1928 g_free(text);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1929
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1930 return;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1931 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1932
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1933 rlist = file_util_delete_dir_remaining_folders(dlist);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1934 if (rlist)
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1935 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1936 GenericDialog *gd;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1937 GtkWidget *box;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1938 gchar *text;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1939
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1940 gd = file_util_gen_dlg(_("Folder contains subfolders"), GQ_WMCLASS, "dlg_warning",
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1941 parent, TRUE, NULL, NULL);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1942 generic_dialog_add_button(gd, GTK_STOCK_CLOSE, NULL, NULL, TRUE);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1943
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1944 text = g_strdup_printf(_("Unable to delete the folder:\n\n%s\n\n"
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1945 "This folder contains subfolders which must be moved before it can be deleted."),
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1946 fd->path);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1947 box = generic_dialog_add_message(gd, GTK_STOCK_DIALOG_WARNING,
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1948 _("Folder contains subfolders"),
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1949 text);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1950 g_free(text);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1951
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1952 box = pref_group_new(box, TRUE, _("Subfolders:"), GTK_ORIENTATION_VERTICAL);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1953
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1954 rlist = filelist_sort_path(rlist);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1955 file_util_dialog_add_list(box, rlist, FALSE);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1956
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1957 gtk_widget_show(gd->dialog);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1958 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1959 else
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1960 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1961 UtilityData *ud;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1962 ud = file_util_data_new(UTILITY_TYPE_DELETE_FOLDER);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1963
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1964 ud->phase = phase;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1965 ud->dir_fd = file_data_ref(fd);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1966 ud->content_list = NULL; /* will be filled by file_util_delete_dir_prepare */
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1967 ud->flist = flist = filelist_sort_path(flist);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1968
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1969 ud->parent = parent;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1970
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1971 ud->messages.title = _("Delete folder");
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1972 ud->messages.question = _("Delete folder?");
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1973 ud->messages.desc_flist = _("The folder contains these files:");
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1974 ud->messages.desc_source_fd = _("This will delete the folder.\n"
995
6ca2c5fd7b13 Whitespaces cleanup.
zas_
parents: 974
diff changeset
1975 "The contents of this folder will also be deleted.");
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1976 ud->messages.fail = _("File deletion failed");
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1977
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1978 if (!file_util_delete_dir_prepare(ud, flist, dlist))
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1979 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1980 gchar *text;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1981
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1982 text = g_strdup_printf(_("Unable to list contents of folder %s"), fd->path);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1983 file_util_warning_dialog(_("Delete failed"), text, GTK_STOCK_DIALOG_ERROR, parent);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1984 g_free(text);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1985 file_data_unref(ud->dir_fd);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1986 file_util_data_free(ud);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1987 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1988 else
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1989 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1990 filelist_free(dlist);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1991 file_util_dialog_run(ud);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1992 return;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1993 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1994 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1995
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1996 g_list_free(rlist);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1997 filelist_free(dlist);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1998 filelist_free(flist);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
1999 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2000
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2001 static gboolean file_util_rename_dir_scan(UtilityData *ud, FileData *fd)
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2002 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2003 GList *dlist;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2004 GList *flist;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2005 GList *work;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2006
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2007 gboolean ok = TRUE;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2008
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2009 if (!filelist_read_lstat(fd, &flist, &dlist))
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2010 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2011 // ud->fail_fd = fd
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2012 return 0;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2013 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2014
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2015 ud->content_list = g_list_concat(flist, ud->content_list);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2016
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2017 work = dlist;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2018 while (work && ok)
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2019 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2020 FileData *lfd;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2021
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2022 lfd = work->data;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2023 work = work->next;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2024
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2025 ud->content_list = g_list_prepend(ud->content_list, file_data_ref(lfd));
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2026 ok = file_util_rename_dir_scan(ud, lfd);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2027 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2028
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2029 filelist_free(dlist);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2030
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2031 return ok;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2032 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2033
1000
4fe8f9656107 For the sake of consistency, use glib basic types everywhere.
zas_
parents: 995
diff changeset
2034 static gboolean file_util_rename_dir_prepare(UtilityData *ud, const gchar *new_path)
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2035 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2036 gboolean ok;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2037 GList *work;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2038 gint orig_len = strlen(ud->dir_fd->path);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2039
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2040 ok = file_util_rename_dir_scan(ud, ud->dir_fd);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2041
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2042 work = ud->content_list;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2043
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2044 while (ok && work)
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2045 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2046 gchar *np;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2047 FileData *fd;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2048
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2049 fd = work->data;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2050 work = work->next;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2051
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2052 g_assert(strncmp(fd->path, ud->dir_fd->path, orig_len) == 0);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2053
921
b416159a5820 Tidy up.
zas_
parents: 914
diff changeset
2054 np = g_strconcat(new_path, fd->path + orig_len, NULL);
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2055
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2056 ok = file_data_sc_add_ci_rename(fd, np);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2057
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2058 DEBUG_1("Dir rename: %s -> %s", fd->path, np);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2059 g_free(np);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2060 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2061
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2062 if (ok)
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2063 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2064 ok = file_data_sc_add_ci_rename(ud->dir_fd, new_path);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2065 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2066
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2067 if (!ok)
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2068 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2069 work = ud->content_list;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2070 while (work)
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2071 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2072 FileData *fd;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2073
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2074 fd = work->data;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2075 work = work->next;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2076 file_data_sc_free_ci(fd);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2077 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2078 }
921
b416159a5820 Tidy up.
zas_
parents: 914
diff changeset
2079
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2080 return ok;
995
6ca2c5fd7b13 Whitespaces cleanup.
zas_
parents: 974
diff changeset
2081 }
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2082
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2083
1000
4fe8f9656107 For the sake of consistency, use glib basic types everywhere.
zas_
parents: 995
diff changeset
2084 static void file_util_rename_dir_full(FileData *fd, const gchar *new_path, GtkWidget *parent, UtilityPhase phase)
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2085 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2086 UtilityData *ud;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2087
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2088 ud = file_util_data_new(UTILITY_TYPE_RENAME_FOLDER);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2089
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2090 ud->phase = phase;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2091
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2092 ud->dir_fd = file_data_ref(fd);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2093 ud->flist = NULL;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2094 ud->content_list = NULL;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2095 ud->parent = parent;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2096
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2097 ud->messages.title = _("Rename");
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2098 ud->messages.question = _("Rename folder?");
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2099 ud->messages.desc_flist = _("The folder contains the following files");
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2100 ud->messages.desc_source_fd = "";
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2101 ud->messages.fail = _("Rename failed");
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2102
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2103 if (!file_util_rename_dir_prepare(ud, new_path))
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2104 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2105 file_util_warn_op_in_progress(ud->messages.fail);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2106 file_util_data_free(ud);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2107 return;
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2108 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2109
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2110 // ud->flist = filelist_recursive(fd);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2111
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2112 file_util_dialog_run(ud);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2113 }
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2114
1000
4fe8f9656107 For the sake of consistency, use glib basic types everywhere.
zas_
parents: 995
diff changeset
2115 static void file_util_create_dir_full(FileData *fd, const gchar *dest_path, GtkWidget *parent, UtilityPhase phase)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2116 {
901
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
2117 UtilityData *ud;
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
2118
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
2119 ud = file_util_data_new(UTILITY_TYPE_CREATE_FOLDER);
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
2120
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
2121 ud->phase = phase;
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
2122
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
2123 ud->dir_fd = NULL;
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
2124 ud->flist = NULL;
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
2125 ud->content_list = NULL;
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
2126 ud->parent = parent;
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
2127
995
6ca2c5fd7b13 Whitespaces cleanup.
zas_
parents: 974
diff changeset
2128 if (dest_path)
901
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
2129 {
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
2130 ud->dest_path = g_strdup(dest_path);
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
2131 }
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
2132 else
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
2133 {
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
2134 gchar *buf = g_build_filename(fd->path, _("New folder"), NULL);
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
2135 ud->dest_path = unique_filename(buf, NULL, " ", FALSE);
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
2136 g_free(buf);
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
2137 }
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
2138
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
2139 ud->dir_fd = file_data_new_simple(ud->dest_path);
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
2140
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
2141 ud->messages.title = _("Create Folder");
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
2142 ud->messages.question = _("Create folder?");
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
2143 ud->messages.desc_flist = "";
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
2144 ud->messages.desc_source_fd = "";
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
2145 ud->messages.fail = _("Can't create folder");
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
2146
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
2147 file_util_dialog_run(ud);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2148 }
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
2149
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2150
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
2151 /* full-featured entry points
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2152 */
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2153
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2154 void file_util_delete(FileData *source_fd, GList *source_list, GtkWidget *parent)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2155 {
1054
9157291b79a4 fixed confirm_delete option
nadvornik
parents: 1000
diff changeset
2156 file_util_delete_full(source_fd, source_list, parent, options->file_ops.confirm_delete ? UTILITY_PHASE_START : UTILITY_PHASE_ENTERING);
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2157 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
2158
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2159 void file_util_copy(FileData *source_fd, GList *source_list, const gchar *dest_path, GtkWidget *parent)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2160 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2161 file_util_copy_full(source_fd, source_list, dest_path, parent, UTILITY_PHASE_START);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2162 }
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
2163
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2164 void file_util_move(FileData *source_fd, GList *source_list, const gchar *dest_path, GtkWidget *parent)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2165 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2166 file_util_move_full(source_fd, source_list, dest_path, parent, UTILITY_PHASE_START);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2167 }
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
2168
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2169 void file_util_rename(FileData *source_fd, GList *source_list, GtkWidget *parent)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2170 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2171 file_util_rename_full(source_fd, source_list, NULL, parent, UTILITY_PHASE_START);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2172 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
2173
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2174 /* these avoid the location entry dialog unless there is an error, list must be files only and
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2175 * dest_path must be a valid directory path
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
2176 */
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2177 void file_util_move_simple(GList *list, const gchar *dest_path, GtkWidget *parent)
44
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2178 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2179 file_util_move_full(NULL, list, dest_path, parent, UTILITY_PHASE_ENTERING);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2180 }
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
2181
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2182 void file_util_copy_simple(GList *list, const gchar *dest_path, GtkWidget *parent)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2183 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2184 file_util_copy_full(NULL, list, dest_path, parent, UTILITY_PHASE_ENTERING);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2185 }
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
2186
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2187 void file_util_rename_simple(FileData *fd, const gchar *dest_path, GtkWidget *parent)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2188 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2189 file_util_rename_full(fd, NULL, dest_path, parent, UTILITY_PHASE_ENTERING);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2190 }
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
2191
44
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2192
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2193 void file_util_start_editor_from_file(gint n, FileData *fd, GtkWidget *parent)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2194 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2195 file_util_start_editor_full(n, fd, NULL, NULL, parent, UTILITY_PHASE_ENTERING);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2196 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2197
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2198 void file_util_start_editor_from_filelist(gint n, GList *list, GtkWidget *parent)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2199 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2200 file_util_start_editor_full(n, NULL, list, NULL, parent, UTILITY_PHASE_ENTERING);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2201 }
44
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2202
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2203 void file_util_start_filter_from_file(gint n, FileData *fd, const gchar *dest_path, GtkWidget *parent)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2204 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2205 file_util_start_editor_full(n, fd, NULL, dest_path, parent, UTILITY_PHASE_ENTERING);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2206 }
44
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2207
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2208 void file_util_start_filter_from_filelist(gint n, GList *list, const gchar *dest_path, GtkWidget *parent)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2209 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2210 file_util_start_editor_full(n, NULL, list, dest_path, parent, UTILITY_PHASE_ENTERING);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2211 }
44
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
2212
896
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2213 void file_util_delete_dir(FileData *fd, GtkWidget *parent)
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2214 {
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2215 file_util_delete_dir_full(fd, parent, UTILITY_PHASE_START);
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2216 }
cf21dc928122 implemented directory rename and delete operations
nadvornik
parents: 855
diff changeset
2217
901
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
2218 void file_util_create_dir(FileData *dir_fd, GtkWidget *parent)
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
2219 {
901
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
2220 file_util_create_dir_full(dir_fd, NULL, parent, UTILITY_PHASE_ENTERING);
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
2221 }
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
2222
908
5a737cc935cc file_util_rename_dir should not return anything
nadvornik
parents: 907
diff changeset
2223 void file_util_rename_dir(FileData *source_fd, const gchar *new_path, GtkWidget *parent)
901
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
2224 {
ae75cd2b4d76 implemented "create directory" command
nadvornik
parents: 900
diff changeset
2225 file_util_rename_dir_full(source_fd, new_path, parent, UTILITY_PHASE_ENTERING);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
2226 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
2227
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2228
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2229 void file_util_copy_path_to_clipboard(FileData *fd)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2230 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2231 GtkClipboard *clipboard;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2232
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2233 if (!fd || !*fd->path) return;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2234
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2235 clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2236 gtk_clipboard_set_text(clipboard, g_shell_quote(fd->path), -1);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2237 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2238
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2239 void file_util_copy_path_list_to_clipboard(GList *list)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2240 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2241 GtkClipboard *clipboard;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2242 GList *work;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2243 GString *new;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2244
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2245 clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2246
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2247 new = g_string_new("");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2248 work = list;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2249 while (work) {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2250 FileData *fd = work->data;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2251 work = work->next;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2252
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2253 if (!fd || !*fd->path) continue;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2254
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2255 g_string_append(new, g_shell_quote(fd->path));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2256 if (work) g_string_append_c(new, ' ');
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2257 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2258
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2259 gtk_clipboard_set_text(clipboard, new->str, new->len);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2260 g_string_free(new, TRUE);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
2261 }
1055
1646720364cf Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents: 1054
diff changeset
2262 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */