annotate src/utilops.c @ 821:fb249b8e63e4

Move some functions from image.[ch] to image-overlay.c and make them static: - image_overlay_add() - image_overlay_set() - image_overlay_remove() - image_overlay_get() (unused)
author zas_
date Thu, 12 Jun 2008 20:17:22 +0000
parents a25b228978a0
children db68d673448f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1 /*
196
f6e307c7bad6 rename GQview -> Geeqie over the code
nadvornik
parents: 143
diff changeset
2 * Geeqie
67
f63ecca6c087 Fri Oct 13 05:22:43 2006 John Ellis <johne@verizon.net>
gqview
parents: 66
diff changeset
3 * (C) 2006 John Ellis
475
48c8e49b571c updated copyright in source files
nadvornik
parents: 448
diff changeset
4 * Copyright (C) 2008 The Geeqie Team
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
5 *
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
6 * Author: John Ellis
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
7 *
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
8 * This software is released under the GNU General Public License (GNU GPL).
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
9 * Please read the included file COPYING for more information.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
10 * This software comes with no warranty of any kind, use at your own risk!
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
11 */
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
12
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
13
281
9995c5fb202a gqview.h -> main.h
zas_
parents: 254
diff changeset
14 #include "main.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
15 #include "utilops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
16
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
17
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
18 #include "cache.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
19 #include "cache_maint.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
20 #include "collect.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
21 #include "dupe.h"
586
905688aa2317 split filelist.c to filefilter.c and filedata.c
nadvornik
parents: 513
diff changeset
22 #include "filedata.h"
905688aa2317 split filelist.c to filefilter.c and filedata.c
nadvornik
parents: 513
diff changeset
23 #include "filefilter.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
24 #include "image.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
25 #include "img-view.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
26 #include "layout.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
27 #include "search.h"
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
28 #include "thumb_standard.h"
597
5da092a6a92a moved safe delete functions to separate file
nadvornik
parents: 596
diff changeset
29 #include "trash.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
30 #include "ui_bookmark.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
31 #include "ui_fileops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
32 #include "ui_misc.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
33 #include "ui_tabcomp.h"
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
34 #include "editors.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
35
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
36 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
37 *--------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
38 * 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
39 *--------------------------------------------------------------------------
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 #define DIALOG_DEF_IMAGE_DIM_X 200
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
43 #define DIALOG_DEF_IMAGE_DIM_Y 150
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
44
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
45 static void generic_dialog_add_image(GenericDialog *gd, GtkWidget *box,
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
46 FileData *fd1, const gchar *header1,
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
47 FileData *fd2, const gchar *header2,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
48 gint show_filename)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
49 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
50 ImageWindow *imd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
51 GtkWidget *hbox = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
52 GtkWidget *vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
53 GtkWidget *label = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
54
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
55 if (!box) box = gd->vbox;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
56
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
57 if (fd2)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
58 {
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
59 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
60 }
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 /* image 1 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
63
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
64 vbox = gtk_vbox_new(FALSE, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
65 if (hbox)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
66 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
67 GtkWidget *sep;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
68
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
69 gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
70
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
71 sep = gtk_vseparator_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
72 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
73 gtk_widget_show(sep);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
74 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
75 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
76 {
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
77 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
78 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
79 gtk_widget_show(vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
80
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
81 if (header1)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
82 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
83 GtkWidget *head;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
84
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
85 head = pref_label_new(vbox, header1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
86 pref_label_bold(head, TRUE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
87 gtk_misc_set_alignment(GTK_MISC(head), 0.0, 0.5);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
88 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
89
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
90 imd = image_new(FALSE);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
91 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
92 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
93 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
94 image_change_fd(imd, fd1, 0.0);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
95 gtk_widget_show(imd->widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
96
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
97 if (show_filename)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
98 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
99 label = pref_label_new(vbox, (fd1 == NULL) ? "" : fd1->name);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
100 }
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 /* 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
103 g_object_set_data(G_OBJECT(gd->dialog), "img_image", imd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
104 g_object_set_data(G_OBJECT(gd->dialog), "img_label", label);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 341
diff changeset
105
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
106
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
107 /* image 2 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
108
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
109 if (hbox && fd2)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
110 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
111 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
112
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
113 if (header2)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
114 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
115 GtkWidget *head;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
116
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
117 head = pref_label_new(vbox, header2);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
118 pref_label_bold(head, TRUE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
119 gtk_misc_set_alignment(GTK_MISC(head), 0.0, 0.5);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
120 }
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 imd = image_new(FALSE);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
123 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
124 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
125 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
126 image_change_fd(imd, fd2, 0.0);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
127 gtk_widget_show(imd->widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
128
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
129 pref_label_new(vbox, fd2->name);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
130 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
131 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
132
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
133 static void generic_dialog_image_set(GenericDialog *gd, FileData *fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
134 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
135 ImageWindow *imd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
136 GtkWidget *label;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 341
diff changeset
137
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
138 imd = g_object_get_data(G_OBJECT(gd->dialog), "img_image");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
139 label = g_object_get_data(G_OBJECT(gd->dialog), "img_label");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
140
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
141 if (!imd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
142
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
143 image_change_fd(imd, fd, 0.0);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
144 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
145 }
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 * Wrappers to aid in setting additional dialog properties (unde mouse, etc.)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
150 *--------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
151 */
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 GenericDialog *file_util_gen_dlg(const gchar *title,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
154 const gchar *wmclass, const gchar *wmsubclass,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
155 GtkWidget *parent, gint auto_close,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
156 void (*cancel_cb)(GenericDialog *, gpointer), gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
157 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
158 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
159
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
160 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
161 if (options->place_dialogs_under_mouse)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
162 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
163 gtk_window_set_position(GTK_WINDOW(gd->dialog), GTK_WIN_POS_MOUSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
164 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
165
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
166 return gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
167 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
168
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
169 FileDialog *file_util_file_dlg(const gchar *title,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
170 const gchar *wmclass, const gchar *wmsubclass,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
171 GtkWidget *parent,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
172 void (*cancel_cb)(FileDialog *, gpointer), gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
173 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
174 FileDialog *fdlg;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
175
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
176 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
177 if (options->place_dialogs_under_mouse)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
178 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
179 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
180 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
181
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
182 return fdlg;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
183 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
184
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
185 /* this warning dialog is copied from SLIK's ui_utildg.c,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
186 * because it does not have a mouse center option,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
187 * and we must center it before show, implement it here.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
188 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
189 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
190 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
191 /* no op */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
192 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
193
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
194 GenericDialog *file_util_warning_dialog(const gchar *heading, const gchar *message,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
195 const gchar *icon_stock_id, GtkWidget *parent)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
196 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
197 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
198
254
9faf34f047b1 Make the wmclass value unique among the code by defining
zas_
parents: 223
diff changeset
199 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
200 generic_dialog_add_message(gd, icon_stock_id, heading, message);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
201 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
202 if (options->place_dialogs_under_mouse)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
203 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
204 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
205 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
206 gtk_widget_show(gd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
207
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
208 return gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
209 }
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
210
42
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
211 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
212 {
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
213 gint n;
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
214
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
215 if (!name) return 0;
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
216
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
217 n = strlen(name);
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
218
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
219 if (filter_name_exists(name))
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
220 {
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
221 const gchar *ext;
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
222
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
223 ext = extension_from_path(name);
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
224 if (ext) n -= strlen(ext);
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
225 }
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 return n;
606fcf461a68 Sat May 14 13:04:23 2005 John Ellis <johne@verizon.net>
gqview
parents: 15
diff changeset
228 }
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
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
231
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
232
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
233 typedef enum {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
234 UTILITY_TYPE_COPY,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
235 UTILITY_TYPE_MOVE,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
236 UTILITY_TYPE_RENAME,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
237 UTILITY_TYPE_EDITOR,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
238 UTILITY_TYPE_FILTER,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
239 UTILITY_TYPE_DELETE,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
240 UTILITY_TYPE_DELETE_LINK,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
241 UTILITY_TYPE_DELETE_FOLDER
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
242 } UtilityType;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
243
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
244 typedef enum {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
245 UTILITY_PHASE_START = 0,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
246 UTILITY_PHASE_ENTERING,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
247 UTILITY_PHASE_CHECKED,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
248 UTILITY_PHASE_DONE,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
249 UTILITY_PHASE_CANCEL
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
250 } UtilityPhase;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
251
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
252 enum {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
253 UTILITY_RENAME = 0,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
254 UTILITY_RENAME_AUTO,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
255 UTILITY_RENAME_FORMATTED
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
256 };
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
257
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
258 typedef struct _UtilityDataMessages UtilityDataMessages;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
259 struct _UtilityDataMessages {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
260 gchar *title;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
261 gchar *question;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
262 gchar *desc_flist;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
263 gchar *desc_dlist;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
264 gchar *desc_source_fd;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
265 gchar *fail;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
266 };
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
267
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
268 typedef struct _UtilityData UtilityData;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
269
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
270 struct _UtilityData {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
271 UtilityType type;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
272 UtilityPhase phase;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
273
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
274 FileData *source_fd;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
275 GList *dlist;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
276 GList *flist;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
277
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
278 GtkWidget *parent;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
279 GenericDialog *gd;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
280 FileDialog *fdlg;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
281
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
282 gint update_idle_id;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
283
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
284 /* alternative dialog parts */
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
285 GtkWidget *notebook;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
286
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
287 UtilityDataMessages messages;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
288
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
289 /* helper entries for various modes */
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
290 GtkWidget *rename_entry;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
291 GtkWidget *rename_label;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
292 GtkWidget *auto_entry_front;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
293 GtkWidget *auto_entry_end;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
294 GtkWidget *auto_spin_start;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
295 GtkWidget *auto_spin_pad;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
296 GtkWidget *format_entry;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
297 GtkWidget *format_spin;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
298
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
299 GtkWidget *listview;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
300
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
301
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
302 gchar *dest_path;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
303
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
304 /* data for the operation itself, internal or external */
755
be382bffd11f Typo fix.
zas_
parents: 753
diff changeset
305 gboolean external; /* TRUE for external command, FALSE for internal */
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
306
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
307 gint external_command;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
308 gpointer resume_data;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
309 };
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
310
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
311 enum {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
312 UTILITY_COLUMN_FD = 0,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
313 UTILITY_COLUMN_PATH,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
314 UTILITY_COLUMN_NAME,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
315 UTILITY_COLUMN_SIDECARS,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
316 UTILITY_COLUMN_DEST_PATH,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
317 UTILITY_COLUMN_DEST_NAME,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
318 UTILITY_COLUMN_COUNT
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
319 };
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
320
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
321 #define UTILITY_LIST_MIN_WIDTH 250
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
322 #define UTILITY_LIST_MIN_HEIGHT 150
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
323
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
324 /* thumbnail spec has a max depth of 4 (.thumb??/fail/appname/??.png) */
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
325 #define UTILITY_DELETE_MAX_DEPTH 5
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
326
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
327 static UtilityData *file_util_data_new(UtilityType type)
136
18c2a29e681c more external commands
nadvornik
parents: 135
diff changeset
328 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
329 UtilityData *ud;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
330
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
331 ud = g_new0(UtilityData, 1);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
332 ud->type = type;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
333 ud->phase = UTILITY_PHASE_START;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
334 ud->update_idle_id = -1;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
335 ud->external_command = -1;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
336 return ud;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
337 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
338
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
339 static void file_util_data_free(UtilityData *ud)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
340 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
341 if (!ud) return;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
342
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
343 if (ud->update_idle_id != -1) g_source_remove(ud->update_idle_id);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
344
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
345 file_data_unref(ud->source_fd);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
346 filelist_free(ud->dlist);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
347 filelist_free(ud->flist);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
348
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
349 if (ud->gd) generic_dialog_close(ud->gd);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
350
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
351 g_free(ud->dest_path);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
352
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
353 g_free(ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
354 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
355
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
356 static GtkTreeViewColumn *file_util_dialog_add_list_column(GtkWidget *view, const gchar *text, gint n)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
357 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
358 GtkTreeViewColumn *column;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
359 GtkCellRenderer *renderer;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
360
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
361 column = gtk_tree_view_column_new();
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
362 gtk_tree_view_column_set_title(column, text);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
363 gtk_tree_view_column_set_min_width(column, 4);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
364 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
365 renderer = gtk_cell_renderer_text_new();
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
366 gtk_tree_view_column_pack_start(column, renderer, TRUE);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
367 gtk_tree_view_column_add_attribute(column, renderer, "text", n);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
368 gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
369
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
370 return column;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
371 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
372
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
373 static void file_util_dialog_list_select(GtkWidget *view, gint n)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
374 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
375 GtkTreeModel *store;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
376 GtkTreeIter iter;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
377 GtkTreeSelection *selection;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
378
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
379 store = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
380 if (gtk_tree_model_iter_nth_child(store, &iter, NULL, n))
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
381 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
382 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
383 gtk_tree_selection_select_iter(selection, &iter);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
384 }
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 GtkWidget *file_util_dialog_add_list(GtkWidget *box, GList *list, gint full_paths)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
388 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
389 GtkWidget *scrolled;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
390 GtkWidget *view;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
391 GtkListStore *store;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
392
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
393 scrolled = gtk_scrolled_window_new(NULL, NULL);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
394 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
395 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
396 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
397 gtk_box_pack_start(GTK_BOX(box), scrolled, TRUE, TRUE, 0);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
398 gtk_widget_show(scrolled);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
399
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
400 store = gtk_list_store_new(UTILITY_COLUMN_COUNT, G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
401 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
402 g_object_unref(store);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
403
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
404 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), TRUE);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
405 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(view), FALSE);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
406
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
407 if (full_paths)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
408 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
409 file_util_dialog_add_list_column(view, _("Location"), UTILITY_COLUMN_PATH);
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
410 }
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
411 else
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
412 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
413 file_util_dialog_add_list_column(view, _("Name"), UTILITY_COLUMN_NAME);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
414 }
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
415
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
416 gtk_widget_set_size_request(view, UTILITY_LIST_MIN_WIDTH, UTILITY_LIST_MIN_HEIGHT);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
417 gtk_container_add(GTK_CONTAINER(scrolled), view);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
418 gtk_widget_show(view);
136
18c2a29e681c more external commands
nadvornik
parents: 135
diff changeset
419
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
420 while (list)
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
421 {
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
422 FileData *fd = list->data;
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
423 GtkTreeIter iter;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
424 gchar *sidecars;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
425
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
426 sidecars = file_data_sc_list_to_string(fd);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
427
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
428 gtk_list_store_append(store, &iter);
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
429 gtk_list_store_set(store, &iter,
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
430 UTILITY_COLUMN_FD, fd,
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
431 UTILITY_COLUMN_PATH, fd->path,
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
432 UTILITY_COLUMN_NAME, fd->name,
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
433 UTILITY_COLUMN_SIDECARS, sidecars,
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
434 UTILITY_COLUMN_DEST_PATH, fd->change ? fd->change->dest : "error",
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
435 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
436 -1);
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
437 g_free(sidecars);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
438
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
439 list = list->next;
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
440 }
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
441
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
442 return view;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
443 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
444
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
445 // FIXME
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
446 static void file_util_delete_dir_ok_cb(GenericDialog *gd, gpointer data);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
447
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
448 void file_util_perform_ci_internal(UtilityData *ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
449 void file_util_dialog_run(UtilityData *ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
450 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
451
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
452 /* call file_util_perform_ci_internal or start_editor_from_filelist_full */
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
453
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
454
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
455 static void file_util_resume_cb(GenericDialog *gd, gpointer data)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
456 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
457 UtilityData *ud = data;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
458 if (ud->external)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
459 editor_resume(ud->resume_data);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
460 else
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
461 file_util_perform_ci_internal(ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
462 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
463
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
464 static void file_util_abort_cb(GenericDialog *gd, gpointer data)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
465 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
466 UtilityData *ud = data;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
467 if (ud->external)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
468 editor_skip(ud->resume_data);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
469 else
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
470 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
471
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
472 }
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
473
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
474
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
475 static gint file_util_perform_ci_cb(gpointer resume_data, gint flags, GList *list, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
476 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
477 UtilityData *ud = data;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
478 ud->resume_data = resume_data;
497
a33badd85f16 Allow the copy of file paths to clipboard.
zas_
parents: 495
diff changeset
479
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
480 gint ret = EDITOR_CB_CONTINUE;
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
481 if ((flags & EDITOR_ERROR_MASK) && !(flags & EDITOR_ERROR_SKIPPED))
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
482 {
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
483 GString *msg = g_string_new(editor_get_error_str(flags));
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
484 GenericDialog *d;
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
485 g_string_append(msg, "\n");
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
486 g_string_append(msg, ud->messages.fail);
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
487 g_string_append(msg, "\n");
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
488 while (list)
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
489 {
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
490 FileData *fd = list->data;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 341
diff changeset
491
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
492 g_string_append(msg, fd->path);
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
493 g_string_append(msg, "\n");
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
494 list = list->next;
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
495 }
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
496 if (resume_data)
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
497 {
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
498 g_string_append(msg, _("\n Continue multiple file operation?"));
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
499 d = file_util_gen_dlg(ud->messages.fail, GQ_WMCLASS, "dlg_confirm",
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
500 NULL, TRUE,
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
501 file_util_abort_cb, ud);
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
502
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
503 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
504
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
505 generic_dialog_add_button(d, GTK_STOCK_GO_FORWARD, _("Co_ntinue"),
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
506 file_util_resume_cb, TRUE);
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
507 gtk_widget_show(d->dialog);
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
508 ret = EDITOR_CB_SUSPEND;
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
509 }
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
510 else
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
511 {
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
512 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
513 }
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
514 g_string_free(msg, TRUE);
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
515 }
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 341
diff changeset
516
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 341
diff changeset
517
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
518 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
519 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
520 FileData *fd = list->data;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
521 list = list->next;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
522
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
523 if (!(flags & EDITOR_ERROR_MASK)) /* files were successfully deleted, call the maint functions */
761
a2dda8e61e0f another fix in notification
nadvornik
parents: 758
diff changeset
524 {
a2dda8e61e0f another fix in notification
nadvornik
parents: 758
diff changeset
525 file_data_sc_apply_ci(fd);
a2dda8e61e0f another fix in notification
nadvornik
parents: 758
diff changeset
526 }
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
527
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
528 ud->flist = g_list_remove(ud->flist, fd);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
529 file_data_sc_free_ci(fd);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
530 file_data_unref(fd);
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
531 }
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
532
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
533 if (!resume_data) /* end of the list */
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
534 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
535 ud->phase = UTILITY_PHASE_DONE;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
536 file_util_dialog_run(ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
537 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
538
140
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
539 return ret;
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
540 }
e57b0207e180 editors.c was almost completely rewritten:
nadvornik
parents: 138
diff changeset
541
143
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
542
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
543 /*
756
573121c002c3 Typo fix.
zas_
parents: 755
diff changeset
544 * Perform the operation described by FileDataChangeInfo on all files in the list
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
545 * it is an alternative to start_editor_from_filelist_full, it should use similar interface
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
546 */
143
0d1bf3ac6cd8 improved FileDataChangeInfo structure, check for another file operation in progress
nadvornik
parents: 140
diff changeset
547
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
548
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
549 void file_util_perform_ci_internal(UtilityData *ud)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
550 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
551
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
552 while (ud->flist)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
553 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
554 gint ret;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
555
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
556 /* take a single entry each time, this allows better control over the operation */
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
557 GList *single_entry = g_list_append(NULL, ud->flist->data);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
558 gboolean last = !ud->flist->next;
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
559 gint status = EDITOR_ERROR_STATUS;
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
560
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
561 if (file_data_sc_perform_ci(single_entry->data))
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
562 status = 0; /* OK */
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
563
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
564 ret = file_util_perform_ci_cb(GINT_TO_POINTER(!last), status, single_entry, ud);
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
565 g_list_free(single_entry);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
566
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
567 if (ret == EDITOR_CB_SUSPEND || last) return;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
568
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
569 if (ret == EDITOR_CB_SKIP)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
570 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
571 file_util_perform_ci_cb(NULL, EDITOR_ERROR_SKIPPED, ud->flist, ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
572 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
573
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
574 /* FIXME: convert the loop to idle call */
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
575
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
576 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
577 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
578
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
579
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
580 void file_util_perform_ci(UtilityData *ud)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
581 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
582 switch (ud->type)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
583 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
584 case UTILITY_TYPE_COPY:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
585 ud->external_command = CMD_COPY;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
586 break;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
587 case UTILITY_TYPE_MOVE:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
588 ud->external_command = CMD_MOVE;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
589 break;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
590 case UTILITY_TYPE_RENAME:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
591 ud->external_command = CMD_RENAME;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
592 break;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
593 case UTILITY_TYPE_DELETE:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
594 case UTILITY_TYPE_DELETE_LINK:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
595 case UTILITY_TYPE_DELETE_FOLDER:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
596 ud->external_command = CMD_DELETE;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
597 break;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
598 case UTILITY_TYPE_FILTER:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
599 case UTILITY_TYPE_EDITOR:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
600 g_assert(ud->external_command != -1); /* it should be already set */
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
601 break;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
602 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
603
766
7148e125bf23 Check for existing editor command using is_valid_editor_command().
zas_
parents: 761
diff changeset
604 if (is_valid_editor_command(ud->external_command))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
605 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
606 gint flags;
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
607
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
608 ud->external = TRUE;
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
609 flags = start_editor_from_filelist_full(ud->external_command, ud->flist, file_util_perform_ci_cb, ud);
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
610
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
611 if (flags)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
612 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
613 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
614 file_util_warning_dialog(ud->messages.fail, text, GTK_STOCK_DIALOG_ERROR, NULL);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
615 g_free(text);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
616 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
617 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
618 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
619 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
620 ud->external = FALSE;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
621 file_util_perform_ci_internal(ud);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
622 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
623 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
624
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
625 static void file_util_cancel_cb(GenericDialog *gd, gpointer data)
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
626 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
627 UtilityData *ud = data;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
628
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
629 generic_dialog_close(gd);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
630
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
631 ud->gd = NULL;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
632
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
633 ud->phase = UTILITY_PHASE_CANCEL;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
634 file_util_dialog_run(ud);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
635 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
636
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
637 static void file_util_ok_cb(GenericDialog *gd, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
638 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
639 UtilityData *ud = data;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
640
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
641 generic_dialog_close(gd);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
642
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
643 ud->gd = NULL;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
644
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
645 file_util_dialog_run(ud);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
646 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
647
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
648 static void file_util_fdlg_cancel_cb(FileDialog *fdlg, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
649 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
650 UtilityData *ud = data;
675
cca86176bf81 Fix redundant application name in window titles.
zas_
parents: 673
diff changeset
651
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
652 file_dialog_close(fdlg);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
653
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
654 ud->fdlg = NULL;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
655
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
656 ud->phase = UTILITY_PHASE_CANCEL;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
657 file_util_dialog_run(ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
658 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
659
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
660 static void file_util_fdlg_ok_cb(FileDialog *fdlg, gpointer data)
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
661 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
662 UtilityData *ud = data;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
663
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
664 file_dialog_close(fdlg);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
665
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
666 ud->fdlg = NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
667
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
668 file_util_dialog_run(ud);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
669 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
670
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
671
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
672 static void file_util_dest_folder_entry_cb(GtkWidget *entry, gpointer data)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
673 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
674 UtilityData *ud = data;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
675
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
676 g_free(ud->dest_path);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
677 ud->dest_path = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
678
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
679 switch (ud->type)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
680 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
681 case UTILITY_TYPE_COPY:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
682 file_data_sc_update_ci_copy_list(ud->flist, ud->dest_path);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
683 break;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
684 case UTILITY_TYPE_MOVE:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
685 file_data_sc_update_ci_move_list(ud->flist, ud->dest_path);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
686 break;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
687 case UTILITY_TYPE_FILTER:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
688 case UTILITY_TYPE_EDITOR:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
689 file_data_sc_update_ci_unspecified_list(ud->flist, ud->dest_path);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
690 break;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
691 case UTILITY_TYPE_DELETE:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
692 case UTILITY_TYPE_DELETE_LINK:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
693 case UTILITY_TYPE_DELETE_FOLDER:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
694 case UTILITY_TYPE_RENAME:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
695 g_warning("unhandled operation");
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
696 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
697 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
698
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
699
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
700 /* 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
701 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
702 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
703 gchar *new_name;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
704 gchar *parsed;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
705 const gchar *ext;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
706 gchar *middle;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
707 gchar *tmp;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
708 gchar *pad_start;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
709 gchar *pad_end;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
710 gint padding;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
711
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
712 if (!format || !name) return NULL;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
713
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
714 tmp = g_strdup(format);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
715 pad_start = strchr(tmp, '#');
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
716 if (pad_start)
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
717 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
718 pad_end = pad_start;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
719 padding = 0;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
720 while (*pad_end == '#')
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
721 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
722 pad_end++;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
723 padding++;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
724 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
725 *pad_start = '\0';
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
726
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
727 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
728 g_free(tmp);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
729 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
730 else
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
731 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
732 parsed = tmp;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
733 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
734
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
735 ext = extension_from_path(name);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
736
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
737 middle = strchr(parsed, '*');
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
738 if (middle)
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
739 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
740 gchar *base;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
741
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
742 *middle = '\0';
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
743 middle++;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
744
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
745 base = remove_extension_from_path(name);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
746 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
747 g_free(base);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
748 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
749 else
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
750 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
751 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
752 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
753
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
754 g_free(parsed);
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
755
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
756 return new_name;
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
757 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
758
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
759
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
760 static void file_util_rename_preview_update(UtilityData *ud)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
761 {
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
762 GtkTreeModel *store;
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
763 GtkTreeSelection *selection;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
764 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
765 const gchar *front;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
766 const gchar *end;
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
767 const gchar *format;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
768 gint valid;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
769 gint start_n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
770 gint padding;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
771 gint n;
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
772 gint mode;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
773
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
774 mode = gtk_notebook_get_current_page(GTK_NOTEBOOK(ud->notebook));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
775
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
776 if (mode == UTILITY_RENAME)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
777 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
778 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(ud->listview));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
779 if (gtk_tree_selection_get_selected(selection, &store, &iter))
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
780 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
781 FileData *fd;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
782 const gchar *dest = gtk_entry_get_text(GTK_ENTRY(ud->rename_entry));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
783
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
784 gtk_tree_model_get(store, &iter, UTILITY_COLUMN_FD, &fd, -1);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
785 file_data_sc_update_ci_rename(fd, dest);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
786 gtk_list_store_set(GTK_LIST_STORE(store), &iter,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
787 UTILITY_COLUMN_DEST_PATH, fd->change->dest,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
788 UTILITY_COLUMN_DEST_NAME, filename_from_path(fd->change->dest),
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
789 -1);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
790 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
791 return;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
792 }
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
793
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
794
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
795 front = gtk_entry_get_text(GTK_ENTRY(ud->auto_entry_front));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
796 end = gtk_entry_get_text(GTK_ENTRY(ud->auto_entry_end));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
797 padding = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ud->auto_spin_pad));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
798
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
799 format = gtk_entry_get_text(GTK_ENTRY(ud->format_entry));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
800
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
801 if (mode == UTILITY_RENAME_FORMATTED)
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
802 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
803 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
804 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
805 else
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
806 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
807 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
808 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
809
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
810 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
811 n = start_n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
812 valid = gtk_tree_model_get_iter_first(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
813 while (valid)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
814 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
815 gchar *dest;
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
816 FileData *fd;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
817 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
818
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
819 if (mode == UTILITY_RENAME_FORMATTED)
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
820 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
821 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
822 }
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
823 else
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
824 {
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
825 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
826 }
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
827
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
828 file_data_sc_update_ci_rename(fd, dest);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
829 gtk_list_store_set(GTK_LIST_STORE(store), &iter,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
830 UTILITY_COLUMN_DEST_PATH, fd->change->dest,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
831 UTILITY_COLUMN_DEST_NAME, filename_from_path(fd->change->dest),
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
832 -1);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
833 g_free(dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
834
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
835 n++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
836 valid = gtk_tree_model_iter_next(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
837 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
838
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
839 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
840
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
841 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
842 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
843 UtilityData *ud = data;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
844 file_util_rename_preview_update(ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
845 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
846
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
847 static void file_util_rename_preview_adj_cb(GtkWidget *spin, gpointer data)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
848 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
849 UtilityData *ud = data;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
850 file_util_rename_preview_update(ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
851 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
852
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
853 static gboolean file_util_rename_idle_cb(gpointer data)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
854 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
855 UtilityData *ud = data;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
856
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
857 file_util_rename_preview_update(ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
858
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
859 ud->update_idle_id = -1;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
860 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
861 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
862
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
863 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
864 GtkTreeIter *iter, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
865 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
866 UtilityData *ud = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
867
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
868 if (ud->update_idle_id != -1) return;
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
869
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
870 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
871 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
872
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
873
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
874 static gboolean file_util_preview_cb(GtkTreeSelection *selection, GtkTreeModel *store,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
875 GtkTreePath *tpath, gboolean path_currently_selected,
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
876 gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
877 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
878 UtilityData *ud = data;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
879 GtkTreeIter iter;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
880 FileData *fd = NULL;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
881
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
882 if (path_currently_selected ||
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
883 !gtk_tree_model_get_iter(store, &iter, tpath)) return TRUE;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
884
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
885 gtk_tree_model_get(store, &iter, UTILITY_COLUMN_FD, &fd, -1);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
886 generic_dialog_image_set(ud->gd, fd);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
887
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
888 if (ud->type == UTILITY_TYPE_RENAME)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
889 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
890 const gchar *name = filename_from_path(fd->change->dest);
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
891
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
892 gtk_widget_grab_focus(ud->rename_entry);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
893 gtk_label_set_text(GTK_LABEL(ud->rename_label), fd->name);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
894 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
895 gtk_entry_set_text(GTK_ENTRY(ud->rename_entry), name);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
896 gtk_editable_select_region(GTK_EDITABLE(ud->rename_entry), 0, filename_base_length(name));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
897 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
898 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
899
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
900 return TRUE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
901 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
902
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
903
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
904
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
905 static void box_append_safe_delete_status(GenericDialog *gd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
906 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
907 GtkWidget *label;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
908 gchar *buf;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
909
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
910 buf = file_util_safe_delete_status();
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
911 label = pref_label_new(gd->vbox, buf);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
912 g_free(buf);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
913
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
914 gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
915 gtk_widget_set_sensitive(label, FALSE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
916 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
917
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
918
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
919 static void file_util_dialog_init_simple_list(UtilityData *ud)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
920 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
921 GtkWidget *box;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
922 GtkTreeSelection *selection;
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
923
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
924 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
925 ud->parent, FALSE, file_util_cancel_cb, ud);
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
926 generic_dialog_add_button(ud->gd, GTK_STOCK_DELETE, NULL, file_util_ok_cb, TRUE);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
927
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
928 box = generic_dialog_add_message(ud->gd, GTK_STOCK_DIALOG_QUESTION,
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
929 ud->messages.question,
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
930 ud->messages.desc_flist);
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
931
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
932 box = pref_group_new(box, TRUE, ud->messages.desc_flist, GTK_ORIENTATION_HORIZONTAL);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
933
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
934 ud->listview = file_util_dialog_add_list(box, ud->flist, FALSE);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
935 file_util_dialog_add_list_column(ud->listview, _("Sidecars"), UTILITY_COLUMN_SIDECARS);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
936
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
937 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(ud->listview));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
938 gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
939 gtk_tree_selection_set_select_function(selection, file_util_preview_cb, ud, NULL);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
940
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
941 generic_dialog_add_image(ud->gd, box, NULL, NULL, NULL, NULL, FALSE);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
942
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
943 box_append_safe_delete_status(ud->gd);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
944
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
945 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
946
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
947 file_util_dialog_list_select(ud->listview, 0);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
948 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
949
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
950 static void file_util_dialog_init_dest_folder(UtilityData *ud)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
951 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
952 FileDialog *fdlg;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
953 GtkWidget *label;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
954 const gchar *stock_id;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
955
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
956 if (ud->type == UTILITY_TYPE_COPY)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
957 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
958 stock_id = GTK_STOCK_COPY;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
959 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
960 else
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
961 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
962 stock_id = GTK_STOCK_OK;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
963 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
964
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
965 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
966 file_util_fdlg_cancel_cb, ud);
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
967
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
968 ud->fdlg = fdlg;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
969
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
970 generic_dialog_add_message(GENERIC_DIALOG(fdlg), NULL, ud->messages.question, NULL);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
971
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
972 label = pref_label_new(GENERIC_DIALOG(fdlg)->vbox, _("Choose the destination folder."));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
973 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
974 pref_spacer(GENERIC_DIALOG(fdlg)->vbox, 0);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
975
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
976 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
977
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
978 file_dialog_add_path_widgets(fdlg, NULL, ud->dest_path, "move_copy", NULL, NULL);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
979
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
980 g_signal_connect(G_OBJECT(fdlg->entry), "changed",
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
981 G_CALLBACK(file_util_dest_folder_entry_cb), ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
982
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
983 gtk_widget_show(GENERIC_DIALOG(fdlg)->dialog);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
984 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
985
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
986
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
987 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
988 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
989 GtkWidget *vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
990 GtkWidget *label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
991
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
992 vbox = gtk_vbox_new(FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
993 gtk_box_pack_start(GTK_BOX(box), vbox, expand, expand, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
994 gtk_widget_show(vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
995
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
996 label = gtk_label_new(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
997 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
998 gtk_widget_show(label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
999
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1000 return vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1001 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1002
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1003
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1004 static void file_util_dialog_init_source_dest(UtilityData *ud)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1005 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1006 GtkTreeModel *store;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1007 GtkTreeSelection *selection;
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1008 GtkWidget *box;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1009 GtkWidget *hbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1010 GtkWidget *box2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1011 GtkWidget *table;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1012 GtkWidget *combo;
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1013 GtkWidget *page;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1014
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1015 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
1016 ud->parent, FALSE, file_util_cancel_cb, ud);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1017
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1018 box = generic_dialog_add_message(ud->gd, NULL, ud->messages.question, NULL);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1019 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
1020
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1021 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
1022
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1023 ud->listview = file_util_dialog_add_list(box, ud->flist, FALSE);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1024 file_util_dialog_add_list_column(ud->listview, _("Sidecars"), UTILITY_COLUMN_SIDECARS);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 341
diff changeset
1025
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1026 file_util_dialog_add_list_column(ud->listview, _("New name"), UTILITY_COLUMN_DEST_NAME);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1027
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1028 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(ud->listview));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1029 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_SINGLE);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1030 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
1031
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1032
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1033 // column = file_util_rename_multiple_add_column(rd, _("Preview"), RENAME_COLUMN_PREVIEW);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1034 // gtk_tree_view_column_set_visible(column, FALSE);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 341
diff changeset
1035
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1036 gtk_tree_view_set_reorderable(GTK_TREE_VIEW(ud->listview), TRUE);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1037
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1038 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
1039 g_signal_connect(G_OBJECT(store), "row_changed",
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1040 G_CALLBACK(file_util_rename_preview_order_cb), ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1041 gtk_widget_set_size_request(ud->listview, 300, 150);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1042
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1043 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
1044
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1045 // gtk_container_add(GTK_CONTAINER(scrolled), view);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1046 gtk_widget_show(ud->gd->dialog);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1047
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1048
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1049 ud->notebook = gtk_notebook_new();
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1050
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1051 gtk_box_pack_start(GTK_BOX(ud->gd->vbox), ud->notebook, FALSE, FALSE, 0);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1052 gtk_widget_show(ud->notebook);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1053
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1054
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1055 page = gtk_vbox_new(FALSE, PREF_PAD_GAP);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1056 gtk_notebook_append_page(GTK_NOTEBOOK(ud->notebook), page, gtk_label_new(_("Manual rename")));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1057 gtk_widget_show(page);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1058
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1059 table = pref_table_new(page, 2, 2, FALSE, FALSE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1060
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1061 pref_table_label(table, 0, 0, _("Original name:"), 1.0);
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1062 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
1063
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1064 pref_table_label(table, 0, 1, _("New name:"), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1065
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1066 ud->rename_entry = gtk_entry_new();
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1067 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
1068 generic_dialog_attach_default(GENERIC_DIALOG(ud->gd), ud->rename_entry);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1069 gtk_widget_grab_focus(ud->rename_entry);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1070
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1071 g_signal_connect(G_OBJECT(ud->rename_entry), "changed",
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1072 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
1073
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1074 gtk_widget_show(ud->rename_entry);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1075
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1076 page = gtk_vbox_new(FALSE, PREF_PAD_GAP);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1077 gtk_notebook_append_page(GTK_NOTEBOOK(ud->notebook), page, gtk_label_new(_("Auto rename")));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1078 gtk_widget_show(page);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1079
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1080
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1081 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
1082
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1083 box2 = furm_simple_vlabel(hbox, _("Begin text"), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1084
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1085 combo = history_combo_new(&ud->auto_entry_front, "", "numerical_rename_prefix", -1);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1086 g_signal_connect(G_OBJECT(ud->auto_entry_front), "changed",
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1087 G_CALLBACK(file_util_rename_preview_entry_cb), ud);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1088 gtk_box_pack_start(GTK_BOX(box2), combo, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1089 gtk_widget_show(combo);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 341
diff changeset
1090
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1091 box2 = furm_simple_vlabel(hbox, _("Start #"), FALSE);
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 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
1094 0.0, 1000000.0, 1.0, 0, 1.0,
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1095 G_CALLBACK(file_util_rename_preview_adj_cb), ud);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1096
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1097 box2 = furm_simple_vlabel(hbox, _("End text"), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1098
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1099 combo = history_combo_new(&ud->auto_entry_end, "", "numerical_rename_suffix", -1);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1100 g_signal_connect(G_OBJECT(ud->auto_entry_end), "changed",
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1101 G_CALLBACK(file_util_rename_preview_entry_cb), ud);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1102 gtk_box_pack_start(GTK_BOX(box2), combo, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1103 gtk_widget_show(combo);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1104
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1105 ud->auto_spin_pad = pref_spin_new(page, _("Padding:"), NULL,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1106 1.0, 8.0, 1.0, 0, 1.0,
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1107 G_CALLBACK(file_util_rename_preview_adj_cb), ud);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1108
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1109 page = gtk_vbox_new(FALSE, PREF_PAD_GAP);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1110 gtk_notebook_append_page(GTK_NOTEBOOK(ud->notebook), page, gtk_label_new(_("Formatted rename")));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1111 gtk_widget_show(page);
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1112
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1113 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
1114
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1115 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
1116
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1117 combo = history_combo_new(&ud->format_entry, "", "auto_rename_format", -1);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1118 g_signal_connect(G_OBJECT(ud->format_entry), "changed",
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1119 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
1120 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
1121 gtk_widget_show(combo);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 341
diff changeset
1122
66
ebbff299ad0d Fri Sep 1 02:12:45 2006 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1123 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
1124
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1125 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
1126 0.0, 1000000.0, 1.0, 0, 1.0,
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1127 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
1128
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1129 // 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
1130
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1131 file_util_dialog_list_select(ud->listview, 0);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1132 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1133
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1134
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1135 void file_util_dialog_run(UtilityData *ud)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1136 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1137 switch (ud->phase)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1138 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1139 case UTILITY_PHASE_START:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1140 /* create the dialogs */
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1141 switch (ud->type)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1142 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1143 case UTILITY_TYPE_DELETE:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1144 case UTILITY_TYPE_DELETE_LINK:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1145 case UTILITY_TYPE_DELETE_FOLDER:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1146 case UTILITY_TYPE_EDITOR:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1147 file_util_dialog_init_simple_list(ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1148 break;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1149 case UTILITY_TYPE_RENAME:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1150 file_util_dialog_init_source_dest(ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1151 break;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1152 case UTILITY_TYPE_COPY:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1153 case UTILITY_TYPE_MOVE:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1154 case UTILITY_TYPE_FILTER:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1155 file_util_dialog_init_dest_folder(ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1156 break;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1157 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1158 ud->phase = UTILITY_PHASE_ENTERING;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1159 break;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1160 case UTILITY_PHASE_ENTERING:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1161 /* FIXME use file_data_sc_check_ci_dest to detect problems and eventually go back to PHASE_START
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1162 or to PHASE_CANCEL */
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1163
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1164 ud->phase = UTILITY_PHASE_CHECKED;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1165 case UTILITY_PHASE_CHECKED:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1166 file_util_perform_ci(ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1167 break;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1168 case UTILITY_PHASE_CANCEL:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1169 case UTILITY_PHASE_DONE:
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1170 file_data_sc_free_ci_list(ud->flist);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1171 file_data_sc_free_ci_list(ud->dlist);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1172 if (ud->source_fd) file_data_sc_free_ci(ud->source_fd);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1173 file_util_data_free(ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1174 break;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1175 }
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1176 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1177
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1178
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1179
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1180
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1181 static gint file_util_unlink(FileData *fd)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1182 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1183 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1184
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
1185 static void file_util_warn_op_in_progress(const gchar *title)
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
1186 {
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
1187 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
1188 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1189
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1190 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
1191 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1192 UtilityData *ud;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1193 GList *flist = filelist_copy(source_list);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1194
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1195 if (source_fd)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1196 flist = g_list_append(flist, file_data_ref(source_fd));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1197
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1198 if (!file_data_sc_add_ci_delete_list(flist))
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1199 {
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
1200 file_util_warn_op_in_progress(_("File deletion failed"));
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1201 filelist_free(flist);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1202 return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1203 }
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1204
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1205 ud = file_util_data_new(UTILITY_TYPE_DELETE);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1206
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1207 ud->phase = phase;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1208
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1209 ud->source_fd = NULL;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1210 ud->flist = flist;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1211 ud->dlist = NULL;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1212 ud->parent = parent;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1213
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1214 ud->messages.title = _("Delete");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1215 ud->messages.question = _("Delete files?");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1216 ud->messages.desc_flist = _("This will delete the following files");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1217 ud->messages.desc_dlist = "";
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1218 ud->messages.desc_source_fd = "";
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1219 ud->messages.fail = _("File deletion failed");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1220
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1221 file_util_dialog_run(ud);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1222 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1223
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1224 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
1225 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1226 UtilityData *ud;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1227 GList *flist = filelist_copy(source_list);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1228
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1229 if (source_fd)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1230 flist = g_list_append(flist, file_data_ref(source_fd));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1231
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1232 if (!file_data_sc_add_ci_move_list(flist, dest_path))
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1233 {
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
1234 file_util_warn_op_in_progress(_("Move failed"));
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1235 filelist_free(flist);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1236 return;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1237 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1238
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1239 ud = file_util_data_new(UTILITY_TYPE_MOVE);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1240
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1241 ud->phase = phase;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1242
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1243 ud->source_fd = NULL;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1244 ud->flist = flist;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1245 ud->dlist = NULL;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1246 ud->parent = parent;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1247
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1248 ud->dest_path = g_strdup(dest_path ? dest_path : "");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1249
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1250 ud->messages.title = _("Move");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1251 ud->messages.question = _("Move files?");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1252 ud->messages.desc_flist = _("This will move the following files");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1253 ud->messages.desc_dlist = "";
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1254 ud->messages.desc_source_fd = "";
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1255 ud->messages.fail = _("Move failed");
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1256
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1257 file_util_dialog_run(ud);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1258 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1259 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
1260 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1261 UtilityData *ud;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1262 GList *flist = filelist_copy(source_list);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1263
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1264 if (source_fd)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1265 flist = g_list_append(flist, file_data_ref(source_fd));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1266
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1267 if (!file_data_sc_add_ci_copy_list(flist, dest_path))
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1268 {
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
1269 file_util_warn_op_in_progress(_("Copy failed"));
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1270 filelist_free(flist);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1271 return;
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1272 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1273
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1274 ud = file_util_data_new(UTILITY_TYPE_COPY);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1275
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1276 ud->phase = phase;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1277
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1278 ud->source_fd = NULL;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1279 ud->flist = flist;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1280 ud->dlist = NULL;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1281 ud->parent = parent;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1282
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1283 ud->dest_path = g_strdup(dest_path ? dest_path : "");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1284
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1285 ud->messages.title = _("Copy");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1286 ud->messages.question = _("Copy files?");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1287 ud->messages.desc_flist = _("This will copy the following files");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1288 ud->messages.desc_dlist = "";
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1289 ud->messages.desc_source_fd = "";
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1290 ud->messages.fail = _("Copy failed");
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1291
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1292 file_util_dialog_run(ud);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1293 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1294
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1295 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
1296 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1297 UtilityData *ud;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1298 GList *flist = filelist_copy(source_list);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1299
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1300 if (source_fd)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1301 flist = g_list_append(flist, file_data_ref(source_fd));
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1302
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1303 if (!file_data_sc_add_ci_rename_list(flist, dest_path))
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1304 {
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
1305 file_util_warn_op_in_progress(_("Rename failed"));
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1306 filelist_free(flist);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1307 return;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1308 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1309
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1310 ud = file_util_data_new(UTILITY_TYPE_RENAME);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1311
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1312 ud->phase = phase;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1313
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1314 ud->source_fd = NULL;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1315 ud->flist = flist;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1316 ud->dlist = NULL;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1317 ud->parent = parent;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1318
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1319 ud->messages.title = _("Rename");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1320 ud->messages.question = _("Rename files?");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1321 ud->messages.desc_flist = _("This will rename the following files");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1322 ud->messages.desc_dlist = "";
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1323 ud->messages.desc_source_fd = "";
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1324 ud->messages.fail = _("Rename failed");
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1325
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1326 file_util_dialog_run(ud);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1327 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1328
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1329 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
1330 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1331 UtilityData *ud;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1332 GList *flist = filelist_copy(source_list);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1333
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1334 if (source_fd)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1335 flist = g_list_append(flist, file_data_ref(source_fd));
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1336
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1337 if (!file_data_sc_add_ci_unspecified_list(flist, dest_path))
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1338 {
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
1339 file_util_warn_op_in_progress(_("Can't run external editor"));
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1340 filelist_free(flist);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1341 return;
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1342 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1343
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1344 if (editor_is_filter(n))
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1345 ud = file_util_data_new(UTILITY_TYPE_FILTER);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1346 else
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1347 ud = file_util_data_new(UTILITY_TYPE_EDITOR);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1348
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1349
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1350 /* ask for destination if we don't have it */
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1351 if (ud->type == UTILITY_TYPE_FILTER && dest_path == NULL) phase = UTILITY_PHASE_START;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1352
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1353 ud->phase = phase;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1354
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1355 ud->external_command = n;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1356
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1357 ud->source_fd = NULL;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1358 ud->flist = flist;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1359 ud->dlist = NULL;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1360 ud->parent = parent;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1361
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1362 ud->dest_path = g_strdup(dest_path ? dest_path : "");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1363
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1364 ud->messages.title = _("Editor");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1365 ud->messages.question = _("Run editor?");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1366 ud->messages.desc_flist = _("This will copy the following files");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1367 ud->messages.desc_dlist = "";
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1368 ud->messages.desc_source_fd = "";
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1369 ud->messages.fail = _("External command failed");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1370
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1371 file_util_dialog_run(ud);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1372 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1373
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1374
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1375 /* FIXME: */
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
1376 void file_util_create_dir(FileData *dir_fd, GtkWidget *parent)
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1377 {
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1378 }
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
1379
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1380 gint file_util_rename_dir(FileData *source_fd, const gchar *new_path, GtkWidget *parent)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1381 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1382 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1383
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
1384 /* full-featured entry points
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1385 */
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1386
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1387 void file_util_delete(FileData *source_fd, GList *source_list, GtkWidget *parent)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1388 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1389 file_util_delete_full(source_fd, source_list, parent, UTILITY_PHASE_START);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1390 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents: 3
diff changeset
1391
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1392 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
1393 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1394 file_util_copy_full(source_fd, source_list, dest_path, parent, UTILITY_PHASE_START);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1395 }
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
1396
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1397 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
1398 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1399 file_util_move_full(source_fd, source_list, dest_path, parent, UTILITY_PHASE_START);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1400 }
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
1401
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1402 void file_util_rename(FileData *source_fd, GList *source_list, GtkWidget *parent)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1403 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1404 file_util_rename_full(source_fd, source_list, NULL, parent, UTILITY_PHASE_START);
1
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1405 }
b3e0e515fabf Initial revision
gqview
parents:
diff changeset
1406
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1407 /* 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
1408 * dest_path must be a valid directory path
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
1409 */
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1410 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
1411 {
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1412 file_util_move_full(NULL, list, dest_path, parent, UTILITY_PHASE_ENTERING);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1413 }
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
1414
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1415 void file_util_copy_simple(GList *list, const gchar *dest_path, GtkWidget *parent)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1416 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1417 file_util_copy_full(NULL, list, dest_path, parent, UTILITY_PHASE_ENTERING);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1418 }
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
1419
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1420 void file_util_rename_simple(FileData *fd, const gchar *dest_path, GtkWidget *parent)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1421 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1422 file_util_rename_full(fd, NULL, dest_path, parent, UTILITY_PHASE_ENTERING);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1423 }
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1424
44
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
1425
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1426 void file_util_start_editor_from_file(gint n, FileData *fd, GtkWidget *parent)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1427 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1428 file_util_start_editor_full(n, fd, NULL, NULL, parent, UTILITY_PHASE_ENTERING);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1429 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1430
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1431 void file_util_start_editor_from_filelist(gint n, GList *list, GtkWidget *parent)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1432 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1433 file_util_start_editor_full(n, NULL, list, NULL, parent, UTILITY_PHASE_ENTERING);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1434 }
44
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
1435
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1436 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
1437 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1438 file_util_start_editor_full(n, fd, NULL, dest_path, parent, UTILITY_PHASE_ENTERING);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1439 }
44
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
1440
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1441 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
1442 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1443 file_util_start_editor_full(n, NULL, list, dest_path, parent, UTILITY_PHASE_ENTERING);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1444 }
44
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
1445
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 42
diff changeset
1446
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1447 /*
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1448 *--------------------------------------------------------------------------
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1449 * Delete directory routines
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1450 *--------------------------------------------------------------------------
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1451 */
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1452
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1453 // FIXME
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1454
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1455
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1456
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1457 FileData *file_util_delete_dir_empty_path(FileData *fd, gint real_content, gint level)
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1458 {
780
44128da39e13 Drop initialization to NULL since filelist_read() will take care of it.
zas_
parents: 766
diff changeset
1459 GList *dlist;
44128da39e13 Drop initialization to NULL since filelist_read() will take care of it.
zas_
parents: 766
diff changeset
1460 GList *flist;
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1461 GList *work;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1462 FileData *fail = NULL;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1463
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 497
diff changeset
1464 DEBUG_1("deltree into: %s", fd->path);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1465
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1466 level++;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1467 if (level > UTILITY_DELETE_MAX_DEPTH)
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1468 {
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
1469 log_printf("folder recursion depth past %d, giving up\n", UTILITY_DELETE_MAX_DEPTH);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1470 return file_data_ref(fd);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1471 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1472
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
1473 if (!filelist_read_lstat(fd, &flist, &dlist)) file_data_ref(fd);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1474
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1475 work = dlist;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1476 while (work && !fail)
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1477 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1478 FileData *lfd;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1479
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1480 lfd = work->data;
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1481 work = work->next;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1482
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1483 fail = file_util_delete_dir_empty_path(lfd, real_content, level);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1484 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1485
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1486 work = flist;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1487 while (work && !fail)
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1488 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1489 FileData *lfd;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1490
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1491 lfd = work->data;
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1492 work = work->next;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1493
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 497
diff changeset
1494 DEBUG_1("deltree child: %s", lfd->path);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1495
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1496 if (real_content && !islink(lfd->path))
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1497 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1498 if (!file_util_unlink(lfd)) fail = file_data_ref(lfd);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1499 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1500 else
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1501 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1502 if (!unlink_file(lfd->path)) fail = file_data_ref(lfd);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1503 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1504 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1505
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1506 filelist_free(dlist);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1507 filelist_free(flist);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1508
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1509 if (!fail && !rmdir_utf8(fd->path))
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1510 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1511 fail = file_data_ref(fd);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1512 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1513
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 497
diff changeset
1514 DEBUG_1("deltree done: %s", fd->path);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1515
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1516 return fail;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1517 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1518
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1519 static void file_util_delete_dir_ok_cb(GenericDialog *gd, gpointer data)
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1520 {
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1521 UtilityData *ud = data;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1522
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1523 ud->gd = NULL;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1524
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1525 if (ud->type == UTILITY_TYPE_DELETE_LINK)
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1526 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1527 if (!unlink_file(ud->source_fd->path))
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1528 {
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1529 gchar *text;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1530
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1531 text = g_strdup_printf("Unable to remove symbolic link:\n %s", ud->source_fd->path);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1532 file_util_warning_dialog(_("Delete failed"), text,
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1533 GTK_STOCK_DIALOG_ERROR, NULL);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1534 g_free(text);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1535 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1536 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1537 else
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1538 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1539 FileData *fail = NULL;
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1540 GList *work;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1541
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1542 work = ud->dlist;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1543 while (work && !fail)
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1544 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1545 FileData *fd;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1546
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1547 fd = work->data;
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1548 work = work->next;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1549
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1550 fail = file_util_delete_dir_empty_path(fd, FALSE, 0);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1551 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1552
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1553 work = ud->flist;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1554 while (work && !fail)
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1555 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1556 FileData *fd;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1557
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1558 fd = work->data;
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1559 work = work->next;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1560
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 497
diff changeset
1561 DEBUG_1("deltree unlink: %s", fd->path);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1562
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1563 if (islink(fd->path))
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1564 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1565 if (!unlink_file(fd->path)) fail = file_data_ref(fd);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1566 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1567 else
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1568 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1569 if (!file_util_unlink(fd)) fail = file_data_ref(fd);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1570 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1571 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1572
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1573 if (!fail)
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1574 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1575 if (!rmdir_utf8(ud->source_fd->path)) fail = file_data_ref(ud->source_fd);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1576 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1577
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1578 if (fail)
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1579 {
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1580 gchar *text;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1581
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1582 text = g_strdup_printf(_("Unable to delete folder:\n\n%s"), ud->source_fd->path);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1583 gd = file_util_warning_dialog(_("Delete failed"), text, GTK_STOCK_DIALOG_ERROR, NULL);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1584 g_free(text);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1585
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1586 if (fail != ud->source_fd)
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1587 {
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1588 pref_spacer(gd->vbox, PREF_PAD_GROUP);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1589 text = g_strdup_printf(_("Removal of folder contents failed at this file:\n\n%s"),
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1590 fail->path);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1591 pref_label_new(gd->vbox, text);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1592 g_free(text);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1593 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1594
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1595 file_data_unref(fail);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1596 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1597 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1598
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1599 file_util_data_free(ud);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1600 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1601
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1602 static GList *file_util_delete_dir_remaining_folders(GList *dlist)
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1603 {
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1604 GList *rlist = NULL;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1605
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1606 while (dlist)
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1607 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1608 FileData *fd;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1609
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1610 fd = dlist->data;
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1611 dlist = dlist->next;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1612
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1613 if (!fd->name ||
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1614 (strcmp(fd->name, THUMB_FOLDER_GLOBAL) != 0 &&
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1615 strcmp(fd->name, THUMB_FOLDER_LOCAL) != 0 &&
283
e213fb025621 GQVIEW_* -> GQ_*
zas_
parents: 281
diff changeset
1616 strcmp(fd->name, GQ_CACHE_LOCAL_METADATA) != 0) )
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1617 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1618 rlist = g_list_prepend(rlist, fd);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1619 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1620 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1621
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1622 return g_list_reverse(rlist);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1623 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1624
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1625 void file_util_delete_dir(FileData *fd, GtkWidget *parent)
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1626 {
780
44128da39e13 Drop initialization to NULL since filelist_read() will take care of it.
zas_
parents: 766
diff changeset
1627 GList *dlist;
44128da39e13 Drop initialization to NULL since filelist_read() will take care of it.
zas_
parents: 766
diff changeset
1628 GList *flist;
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1629 GList *rlist;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1630
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1631 if (!isdir(fd->path)) return;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1632
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1633 if (islink(fd->path))
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1634 {
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1635 UtilityData *ud;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1636 gchar *text;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1637
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1638 ud = g_new0(UtilityData, 1);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1639 ud->type = UTILITY_TYPE_DELETE_LINK;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1640 ud->source_fd = file_data_ref(fd);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1641 ud->dlist = NULL;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1642 ud->flist = NULL;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1643
254
9faf34f047b1 Make the wmclass value unique among the code by defining
zas_
parents: 223
diff changeset
1644 ud->gd = file_util_gen_dlg(_("Delete folder"), GQ_WMCLASS, "dlg_confirm",
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1645 parent, TRUE,
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
1646 file_util_cancel_cb, ud);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1647
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1648 text = g_strdup_printf(_("This will delete the symbolic link:\n\n%s\n\n"
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1649 "The folder this link points to will not be deleted."),
757
eb2e2dac712d Tidy up: indentation fixes, typo fixes, ...
zas_
parents: 756
diff changeset
1650 fd->path);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1651 generic_dialog_add_message(ud->gd, GTK_STOCK_DIALOG_QUESTION,
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1652 _("Delete symbolic link to folder?"),
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1653 text);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1654 g_free(text);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1655
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1656 generic_dialog_add_button(ud->gd, GTK_STOCK_DELETE, NULL, file_util_delete_dir_ok_cb, TRUE);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1657
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1658 gtk_widget_show(ud->gd->dialog);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1659
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1660 return;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1661 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1662
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1663 if (!access_file(fd->path, W_OK | X_OK))
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1664 {
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1665 gchar *text;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1666
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1667 text = g_strdup_printf(_("Unable to remove folder %s\n"
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1668 "Permissions do not allow writing to the folder."), fd->path);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1669 file_util_warning_dialog(_("Delete failed"), text, GTK_STOCK_DIALOG_ERROR, parent);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1670 g_free(text);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1671
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1672 return;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1673 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1674
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
1675 if (!filelist_read_lstat(fd, &flist, &dlist))
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1676 {
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1677 gchar *text;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1678
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1679 text = g_strdup_printf(_("Unable to list contents of folder %s"), fd->path);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1680 file_util_warning_dialog(_("Delete failed"), text, GTK_STOCK_DIALOG_ERROR, parent);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1681 g_free(text);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1682
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1683 return;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1684 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1685
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1686 rlist = file_util_delete_dir_remaining_folders(dlist);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1687 if (rlist)
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1688 {
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1689 GenericDialog *gd;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1690 GtkWidget *box;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1691 gchar *text;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1692
254
9faf34f047b1 Make the wmclass value unique among the code by defining
zas_
parents: 223
diff changeset
1693 gd = file_util_gen_dlg(_("Folder contains subfolders"), GQ_WMCLASS, "dlg_warning",
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1694 parent, TRUE, NULL, NULL);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1695 generic_dialog_add_button(gd, GTK_STOCK_CLOSE, NULL, NULL, TRUE);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1696
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1697 text = g_strdup_printf(_("Unable to delete the folder:\n\n%s\n\n"
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1698 "This folder contains subfolders which must be moved before it can be deleted."),
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1699 fd->path);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1700 box = generic_dialog_add_message(gd, GTK_STOCK_DIALOG_WARNING,
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1701 _("Folder contains subfolders"),
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1702 text);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1703 g_free(text);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1704
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1705 box = pref_group_new(box, TRUE, _("Subfolders:"), GTK_ORIENTATION_VERTICAL);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1706
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1707 rlist = filelist_sort_path(rlist);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1708 file_util_dialog_add_list(box, rlist, FALSE);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1709
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1710 gtk_widget_show(gd->dialog);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1711 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1712 else
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1713 {
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1714 UtilityData *ud;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1715 GtkWidget *box;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1716 GtkWidget *view;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1717 GtkTreeSelection *selection;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1718 gchar *text;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1719
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1720 ud = g_new0(UtilityData, 1);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1721 ud->type = UTILITY_TYPE_DELETE_FOLDER;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1722 ud->source_fd = file_data_ref(fd);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1723 ud->dlist = dlist;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1724 dlist = NULL;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1725 ud->flist = filelist_sort_path(flist);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1726 flist = NULL;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1727
254
9faf34f047b1 Make the wmclass value unique among the code by defining
zas_
parents: 223
diff changeset
1728 ud->gd = file_util_gen_dlg(_("Delete folder"), GQ_WMCLASS, "dlg_confirm",
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1729 parent, TRUE, file_util_cancel_cb, ud);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1730 generic_dialog_add_button(ud->gd, GTK_STOCK_DELETE, NULL, file_util_delete_dir_ok_cb, TRUE);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1731
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1732 text = g_strdup_printf(_("This will delete the folder:\n\n%s\n\n"
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1733 "The contents of this folder will also be deleted."),
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1734 fd->path);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1735 box = generic_dialog_add_message(ud->gd, GTK_STOCK_DIALOG_QUESTION,
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1736 _("Delete folder?"),
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1737 text);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1738 g_free(text);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1739
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1740 box = pref_group_new(box, TRUE, _("Contents:"), GTK_ORIENTATION_HORIZONTAL);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1741
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1742 view = file_util_dialog_add_list(box, ud->flist, FALSE);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1743 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1744 gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1745 gtk_tree_selection_set_select_function(selection, file_util_preview_cb, ud, NULL);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1746
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1747 generic_dialog_add_image(ud->gd, box, NULL, NULL, NULL, NULL, FALSE);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1748
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1749 box_append_safe_delete_status(ud->gd);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1750
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1751 gtk_widget_show(ud->gd->dialog);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1752 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1753
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1754 g_list_free(rlist);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1755 filelist_free(dlist);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 136
diff changeset
1756 filelist_free(flist);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 80
diff changeset
1757 }
753
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1758
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1759
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1760 void file_util_copy_path_to_clipboard(FileData *fd)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1761 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1762 GtkClipboard *clipboard;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1763
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1764 if (!fd || !*fd->path) return;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1765
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1766 clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1767 gtk_clipboard_set_text(clipboard, g_shell_quote(fd->path), -1);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1768 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1769
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1770 void file_util_copy_path_list_to_clipboard(GList *list)
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1771 {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1772 GtkClipboard *clipboard;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1773 GList *work;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1774 GString *new;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1775
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1776 clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1777
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1778 new = g_string_new("");
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1779 work = list;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1780 while (work) {
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1781 FileData *fd = work->data;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1782 work = work->next;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1783
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1784 if (!fd || !*fd->path) continue;
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1785
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1786 g_string_append(new, g_shell_quote(fd->path));
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1787 if (work) g_string_append_c(new, ' ');
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1788 }
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1789
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1790 gtk_clipboard_set_text(clipboard, new->str, new->len);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1791 g_string_free(new, TRUE);
477f48ba28d8 rewritten utilops.h:
nadvornik
parents: 730
diff changeset
1792 }