Mercurial > geeqie
annotate src/view_dir.c @ 407:3a9074e73f53
Rename vd_drop_update() to vd_dnd_drop_update().
Add two function pointers to ViewDir struct to keep
vdtree_dnd_drop_expand_cancel() and vdtree_dnd_drop_expand()
static to view_dir_tree.c.
author | zas_ |
---|---|
date | Fri, 18 Apr 2008 16:53:41 +0000 |
parents | 7840ccc95aee |
children | 440979320308 |
rev | line source |
---|---|
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
1 /* |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
2 * Geeqie |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
3 * (C) 2008 Vladimir Nadvornik |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
4 * |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
5 * Author: Laurent Monin |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
6 * |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
7 * This software is released under the GNU General Public License (GNU GPL). |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
8 * Please read the included file COPYING for more information. |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
9 * This software comes with no warranty of any kind, use at your own risk! |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
10 */ |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
11 |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
12 #include "main.h" |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
13 #include "view_dir.h" |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
14 |
394 | 15 #include "dnd.h" |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
16 #include "dupe.h" |
383
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
17 #include "filelist.h" |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
18 #include "layout_image.h" |
384
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
19 #include "layout_util.h" |
394 | 20 #include "ui_bookmark.h" |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
21 #include "ui_fileops.h" |
389 | 22 #include "ui_tree_edit.h" |
383
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
23 #include "ui_menu.h" |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
24 #include "utilops.h" |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
25 #include "view_dir_list.h" |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
26 #include "view_dir_tree.h" |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
27 |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
28 GtkRadioActionEntry menu_view_dir_radio_entries[] = { |
402
f6046e1b3622
Add a shortcut key for List (L) and change the one for Tree (T),
zas_
parents:
401
diff
changeset
|
29 { "FolderList", NULL, N_("_List"), "<meta>L", NULL, DIRVIEW_LIST }, |
f6046e1b3622
Add a shortcut key for List (L) and change the one for Tree (T),
zas_
parents:
401
diff
changeset
|
30 { "FolderTree", NULL, N_("_Tree"), "<control>T", NULL, DIRVIEW_TREE }, |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
31 }; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
32 |
401
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
33 static void vd_destroy_cb(GtkWidget *widget, gpointer data) |
384
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
34 { |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
35 ViewDir *vd = data; |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
36 |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
37 if (vd->popup) |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
38 { |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
39 g_signal_handlers_disconnect_matched(G_OBJECT(vd->popup), G_SIGNAL_MATCH_DATA, |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
40 0, 0, 0, NULL, vd); |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
41 gtk_widget_destroy(vd->popup); |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
42 } |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
43 |
401
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
44 switch(vd->type) |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
45 { |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
46 case DIRVIEW_LIST: vdlist_destroy_cb(widget, data); break; |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
47 case DIRVIEW_TREE: vdtree_destroy_cb(widget, data); break; |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
48 } |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
49 |
384
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
50 if (vd->pf) folder_icons_free(vd->pf); |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
51 if (vd->drop_list) filelist_free(vd->drop_list); |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
52 |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
53 if (vd->path) g_free(vd->path); |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
54 if (vd->info) g_free(vd->info); |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
55 |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
56 g_free(vd); |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
57 } |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
58 |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
59 ViewDir *vd_new(DirViewType type, const gchar *path) |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
60 { |
384
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
61 ViewDir *vd = g_new0(ViewDir, 1); |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
62 |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
63 vd->path = NULL; |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
64 vd->click_fd = NULL; |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
65 |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
66 vd->drop_fd = NULL; |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
67 vd->drop_list = NULL; |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
68 vd->drop_scroll_id = -1; |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
69 vd->drop_list = NULL; |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
70 |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
71 vd->popup = NULL; |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
72 |
407 | 73 vd->dnd_drop_leave_func = NULL; |
74 vd->dnd_drop_update_func = NULL; | |
75 | |
384
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
76 vd->widget = gtk_scrolled_window_new(NULL, NULL); |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
77 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(vd->widget), GTK_SHADOW_IN); |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
78 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(vd->widget), |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
79 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
80 |
391 | 81 vd->pf = folder_icons_new(); |
82 | |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
83 switch(type) |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
84 { |
384
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
85 case DIRVIEW_LIST: vd = vdlist_new(vd, path); break; |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
86 case DIRVIEW_TREE: vd = vdtree_new(vd, path); break; |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
87 } |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
88 |
405 | 89 gtk_container_add(GTK_CONTAINER(vd->widget), vd->view); |
90 | |
91 vd_dnd_init(vd); | |
92 | |
93 g_signal_connect(G_OBJECT(vd->view), "row_activated", | |
94 G_CALLBACK(vd_activate_cb), vd); | |
384
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
95 g_signal_connect(G_OBJECT(vd->widget), "destroy", |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
96 G_CALLBACK(vd_destroy_cb), vd); |
405 | 97 g_signal_connect(G_OBJECT(vd->view), "key_press_event", |
98 G_CALLBACK(vd_press_key_cb), vd); | |
99 g_signal_connect(G_OBJECT(vd->view), "button_press_event", | |
100 G_CALLBACK(vd_press_cb), vd); | |
101 g_signal_connect(G_OBJECT(vd->view), "button_release_event", | |
102 G_CALLBACK(vd_release_cb), vd); | |
103 | |
104 if (path) vd_set_path(vd, path); | |
105 | |
106 gtk_widget_show(vd->view); | |
384
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
107 |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
108 return vd; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
109 } |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
110 |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
111 void vd_set_select_func(ViewDir *vd, |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
112 void (*func)(ViewDir *vd, const gchar *path, gpointer data), gpointer data) |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
113 { |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
114 vd->select_func = func; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
115 vd->select_data = data; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
116 } |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
117 |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
118 void vd_set_layout(ViewDir *vd, LayoutWindow *layout) |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
119 { |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
120 vd->layout = layout; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
121 } |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
122 |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
123 gint vd_set_path(ViewDir *vd, const gchar *path) |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
124 { |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
125 gint ret = FALSE; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
126 |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
127 switch(vd->type) |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
128 { |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
129 case DIRVIEW_LIST: ret = vdlist_set_path(vd, path); break; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
130 case DIRVIEW_TREE: ret = vdtree_set_path(vd, path); break; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
131 } |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
132 |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
133 return ret; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
134 } |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
135 |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
136 void vd_refresh(ViewDir *vd) |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
137 { |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
138 switch(vd->type) |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
139 { |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
140 case DIRVIEW_LIST: return vdlist_refresh(vd); |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
141 case DIRVIEW_TREE: return vdtree_refresh(vd); |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
142 } |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
143 } |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
144 |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
145 const gchar *vd_row_get_path(ViewDir *vd, gint row) |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
146 { |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
147 const gchar *ret = NULL; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
148 |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
149 switch(vd->type) |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
150 { |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
151 case DIRVIEW_LIST: ret = vdlist_row_get_path(vd, row); break; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
152 case DIRVIEW_TREE: ret = vdtree_row_get_path(vd, row); break; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
153 } |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
154 |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
155 return ret; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
156 } |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
157 |
396 | 158 void vd_select_row(ViewDir *vd, FileData *fd) |
159 { | |
160 switch(vd->type) | |
161 { | |
162 case DIRVIEW_LIST: vdlist_select_row(vd, fd); break; | |
163 case DIRVIEW_TREE: vdtree_select_row(vd, fd); break; | |
164 } | |
165 } | |
166 | |
389 | 167 gint vd_find_row(ViewDir *vd, FileData *fd, GtkTreeIter *iter) |
168 { | |
169 gint ret = FALSE; | |
170 | |
171 switch(vd->type) | |
172 { | |
173 case DIRVIEW_LIST: ret = vdlist_find_row(vd, fd, iter); break; | |
174 case DIRVIEW_TREE: ret = vdtree_find_row(vd, fd, iter, NULL); break; | |
175 } | |
176 | |
177 return ret; | |
178 } | |
179 | |
399 | 180 FileData *vd_get_fd_from_tree_path(ViewDir *vd, GtkTreeView *tview, GtkTreePath *tpath) |
181 { | |
182 GtkTreeIter iter; | |
183 FileData *fd = NULL; | |
184 GtkTreeModel *store; | |
185 | |
186 store = gtk_tree_view_get_model(tview); | |
187 gtk_tree_model_get_iter(store, &iter, tpath); | |
188 switch (vd->type) | |
189 { | |
190 case DIRVIEW_LIST: | |
191 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &fd, -1); | |
192 break; | |
193 case DIRVIEW_TREE: | |
194 { | |
195 NodeData *nd; | |
196 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1); | |
197 fd = (nd) ? nd->fd : NULL; | |
198 }; | |
199 break; | |
200 } | |
201 | |
202 return fd; | |
203 } | |
204 | |
389 | 205 static gint vd_rename_cb(TreeEditData *td, const gchar *old, const gchar *new, gpointer data) |
206 { | |
207 ViewDir *vd = data; | |
208 FileData *fd; | |
209 gchar *old_path; | |
210 gchar *new_path; | |
211 gchar *base; | |
212 | |
399 | 213 fd = vd_get_fd_from_tree_path(vd, GTK_TREE_VIEW(vd->view), td->path); |
389 | 214 if (!fd) return FALSE; |
215 | |
216 old_path = g_strdup(fd->path); | |
217 | |
218 base = remove_level_from_path(old_path); | |
219 new_path = concat_dir_and_file(base, new); | |
220 g_free(base); | |
221 | |
222 if (file_util_rename_dir(fd, new_path, vd->view)) | |
223 { | |
224 | |
225 if (vd->type == DIRVIEW_TREE) vdtree_populate_path(vd, new_path, TRUE, TRUE); | |
226 if (vd->layout && strcmp(vd->path, old_path) == 0) | |
227 { | |
228 layout_set_path(vd->layout, new_path); | |
229 } | |
230 else | |
231 { | |
232 if (vd->type == DIRVIEW_LIST) vd_refresh(vd); | |
233 } | |
234 } | |
235 | |
236 g_free(old_path); | |
237 g_free(new_path); | |
238 | |
239 return FALSE; | |
240 } | |
241 | |
242 static void vd_rename_by_data(ViewDir *vd, FileData *fd) | |
243 { | |
244 GtkTreeModel *store; | |
245 GtkTreePath *tpath; | |
246 GtkTreeIter iter; | |
247 | |
248 if (!fd || vd_find_row(vd, fd, &iter) < 0) return; | |
249 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view)); | |
250 tpath = gtk_tree_model_get_path(store, &iter); | |
251 | |
252 tree_edit_by_path(GTK_TREE_VIEW(vd->view), tpath, 0, fd->name, | |
253 vd_rename_cb, vd); | |
254 gtk_tree_path_free(tpath); | |
255 } | |
256 | |
257 | |
383
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
258 void vd_color_set(ViewDir *vd, FileData *fd, gint color_set) |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
259 { |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
260 GtkTreeModel *store; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
261 GtkTreeIter iter; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
262 |
389 | 263 if (vd_find_row(vd, fd, &iter) < 0) return; |
264 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view)); | |
265 | |
383
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
266 switch(vd->type) |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
267 { |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
268 case DIRVIEW_LIST: |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
269 gtk_list_store_set(GTK_LIST_STORE(store), &iter, DIR_COLUMN_COLOR, color_set, -1); |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
270 break; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
271 case DIRVIEW_TREE: |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
272 gtk_tree_store_set(GTK_TREE_STORE(store), &iter, DIR_COLUMN_COLOR, color_set, -1); |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
273 break; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
274 } |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
275 } |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
276 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
277 void vd_popup_destroy_cb(GtkWidget *widget, gpointer data) |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
278 { |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
279 ViewDir *vd = data; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
280 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
281 vd_color_set(vd, vd->click_fd, FALSE); |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
282 vd->click_fd = NULL; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
283 vd->popup = NULL; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
284 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
285 vd_color_set(vd, vd->drop_fd, FALSE); |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
286 filelist_free(vd->drop_list); |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
287 vd->drop_list = NULL; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
288 vd->drop_fd = NULL; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
289 } |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
290 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
291 /* |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
292 *----------------------------------------------------------------------------- |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
293 * drop menu (from dnd) |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
294 *----------------------------------------------------------------------------- |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
295 */ |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
296 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
297 static void vd_drop_menu_copy_cb(GtkWidget *widget, gpointer data) |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
298 { |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
299 ViewDir *vd = data; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
300 const gchar *path; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
301 GList *list; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
302 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
303 if (!vd->drop_fd) return; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
304 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
305 path = vd->drop_fd->path; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
306 list = vd->drop_list; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
307 vd->drop_list = NULL; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
308 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
309 file_util_copy_simple(list, path); |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
310 } |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
311 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
312 static void vd_drop_menu_move_cb(GtkWidget *widget, gpointer data) |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
313 { |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
314 ViewDir *vd = data; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
315 const gchar *path; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
316 GList *list; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
317 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
318 if (!vd->drop_fd) return; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
319 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
320 path = vd->drop_fd->path; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
321 list = vd->drop_list; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
322 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
323 vd->drop_list = NULL; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
324 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
325 file_util_move_simple(list, path); |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
326 } |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
327 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
328 GtkWidget *vd_drop_menu(ViewDir *vd, gint active) |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
329 { |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
330 GtkWidget *menu; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
331 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
332 menu = popup_menu_short_lived(); |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
333 g_signal_connect(G_OBJECT(menu), "destroy", |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
334 G_CALLBACK(vd_popup_destroy_cb), vd); |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
335 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
336 menu_item_add_stock_sensitive(menu, _("_Copy"), GTK_STOCK_COPY, active, |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
337 G_CALLBACK(vd_drop_menu_copy_cb), vd); |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
338 menu_item_add_sensitive(menu, _("_Move"), active, G_CALLBACK(vd_drop_menu_move_cb), vd); |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
339 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
340 menu_item_add_divider(menu); |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
341 menu_item_add_stock(menu, _("Cancel"), GTK_STOCK_CANCEL, NULL, vd); |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
342 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
343 return menu; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
344 } |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
345 |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
346 /* |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
347 *----------------------------------------------------------------------------- |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
348 * pop-up menu |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
349 *----------------------------------------------------------------------------- |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
350 */ |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
351 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
352 static void vd_pop_menu_up_cb(GtkWidget *widget, gpointer data) |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
353 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
354 ViewDir *vd = data; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
355 gchar *path; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
356 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
357 if (!vd->path || strcmp(vd->path, "/") == 0) return; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
358 path = remove_level_from_path(vd->path); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
359 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
360 if (vd->select_func) |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
361 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
362 vd->select_func(vd, path, vd->select_data); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
363 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
364 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
365 g_free(path); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
366 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
367 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
368 static void vd_pop_menu_slide_cb(GtkWidget *widget, gpointer data) |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
369 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
370 ViewDir *vd = data; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
371 gchar *path; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
372 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
373 if (!vd->layout) return; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
374 if (!vd->click_fd) return; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
375 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
376 path = vd->click_fd->path; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
377 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
378 layout_set_path(vd->layout, path); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
379 layout_select_none(vd->layout); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
380 layout_image_slideshow_stop(vd->layout); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
381 layout_image_slideshow_start(vd->layout); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
382 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
383 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
384 static void vd_pop_menu_slide_rec_cb(GtkWidget *widget, gpointer data) |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
385 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
386 ViewDir *vd = data; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
387 gchar *path; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
388 GList *list; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
389 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
390 if (!vd->layout) return; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
391 if (!vd->click_fd) return; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
392 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
393 path = vd->click_fd->path; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
394 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
395 list = filelist_recursive(path); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
396 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
397 layout_image_slideshow_stop(vd->layout); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
398 layout_image_slideshow_start_from_list(vd->layout, list); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
399 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
400 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
401 static void vd_pop_menu_dupe(ViewDir *vd, gint recursive) |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
402 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
403 DupeWindow *dw; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
404 GList *list = NULL; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
405 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
406 if (!vd->click_fd) return; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
407 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
408 if (recursive) |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
409 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
410 list = g_list_append(list, file_data_ref(vd->click_fd)); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
411 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
412 else |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
413 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
414 filelist_read(vd->click_fd->path, &list, NULL); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
415 list = filelist_filter(list, FALSE); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
416 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
417 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
418 dw = dupe_window_new(DUPE_MATCH_NAME); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
419 dupe_window_add_files(dw, list, recursive); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
420 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
421 filelist_free(list); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
422 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
423 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
424 static void vd_pop_menu_dupe_cb(GtkWidget *widget, gpointer data) |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
425 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
426 ViewDir *vd = data; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
427 vd_pop_menu_dupe(vd, FALSE); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
428 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
429 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
430 static void vd_pop_menu_dupe_rec_cb(GtkWidget *widget, gpointer data) |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
431 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
432 ViewDir *vd = data; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
433 vd_pop_menu_dupe(vd, TRUE); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
434 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
435 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
436 static void vd_pop_menu_delete_cb(GtkWidget *widget, gpointer data) |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
437 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
438 ViewDir *vd = data; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
439 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
440 if (!vd->click_fd) return; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
441 file_util_delete_dir(vd->click_fd, vd->widget); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
442 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
443 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
444 static void vd_pop_menu_dir_view_as_cb(GtkWidget *widget, gpointer data) |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
445 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
446 ViewDir *vd = data; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
447 DirViewType new_type = DIRVIEW_LIST; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
448 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
449 if (!vd->layout) return; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
450 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
451 switch(vd->type) |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
452 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
453 case DIRVIEW_LIST: new_type = DIRVIEW_TREE; break; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
454 case DIRVIEW_TREE: new_type = DIRVIEW_LIST; break; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
455 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
456 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
457 layout_views_set(vd->layout, new_type, vd->layout->icon_view); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
458 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
459 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
460 static void vd_pop_menu_refresh_cb(GtkWidget *widget, gpointer data) |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
461 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
462 ViewDir *vd = data; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
463 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
464 if (vd->layout) layout_refresh(vd->layout); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
465 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
466 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
467 static void vd_toggle_show_hidden_files_cb(GtkWidget *widget, gpointer data) |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
468 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
469 ViewDir *vd = data; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
470 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
471 options->file_filter.show_hidden_files = !options->file_filter.show_hidden_files; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
472 if (vd->layout) layout_refresh(vd->layout); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
473 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
474 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
475 static void vd_pop_menu_new_cb(GtkWidget *widget, gpointer data) |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
476 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
477 ViewDir *vd = data; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
478 const gchar *path = NULL; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
479 gchar *new_path; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
480 gchar *buf; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
481 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
482 switch(vd->type) |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
483 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
484 case DIRVIEW_LIST: |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
485 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
486 if (!vd->path) return; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
487 path = vd->path; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
488 }; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
489 break; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
490 case DIRVIEW_TREE: |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
491 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
492 if (!vd->click_fd) return; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
493 path = vd->click_fd->path; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
494 }; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
495 break; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
496 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
497 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
498 buf = concat_dir_and_file(path, _("new_folder")); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
499 new_path = unique_filename(buf, NULL, NULL, FALSE); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
500 g_free(buf); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
501 if (!new_path) return; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
502 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
503 if (!mkdir_utf8(new_path, 0755)) |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
504 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
505 gchar *text; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
506 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
507 text = g_strdup_printf(_("Unable to create folder:\n%s"), new_path); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
508 file_util_warning_dialog(_("Error creating folder"), text, GTK_STOCK_DIALOG_ERROR, vd->view); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
509 g_free(text); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
510 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
511 else |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
512 { |
389 | 513 FileData *fd = NULL; |
514 | |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
515 switch(vd->type) |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
516 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
517 case DIRVIEW_LIST: |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
518 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
519 vd_refresh(vd); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
520 fd = vdlist_row_by_path(vd, new_path, NULL); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
521 }; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
522 break; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
523 case DIRVIEW_TREE: |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
524 fd = vdtree_populate_path(vd, new_path, TRUE, TRUE); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
525 break; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
526 } |
389 | 527 vd_rename_by_data(vd, fd); |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
528 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
529 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
530 g_free(new_path); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
531 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
532 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
533 static void vd_pop_menu_rename_cb(GtkWidget *widget, gpointer data) |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
534 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
535 ViewDir *vd = data; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
536 |
389 | 537 vd_rename_by_data(vd, vd->click_fd); |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
538 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
539 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
540 GtkWidget *vd_pop_menu(ViewDir *vd, FileData *fd) |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
541 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
542 GtkWidget *menu; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
543 gint active; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
544 gint rename_delete_active = FALSE; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
545 gint new_folder_active = FALSE; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
546 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
547 active = (fd != NULL); |
392
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
548 switch(vd->type) |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
549 { |
392
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
550 case DIRVIEW_LIST: |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
551 { |
392
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
552 /* check using . (always row 0) */ |
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
553 new_folder_active = (vd->path && access_file(vd->path , W_OK | X_OK)); |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
554 |
392
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
555 /* ignore .. and . */ |
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
556 rename_delete_active = (new_folder_active && fd && |
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
557 strcmp(fd->name, ".") != 0 && |
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
558 strcmp(fd->name, "..") != 0 && |
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
559 access_file(fd->path, W_OK | X_OK)); |
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
560 }; |
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
561 break; |
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
562 case DIRVIEW_TREE: |
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
563 { |
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
564 if (fd) |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
565 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
566 gchar *parent; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
567 new_folder_active = (fd && access_file(fd->path, W_OK | X_OK)); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
568 parent = remove_level_from_path(fd->path); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
569 rename_delete_active = access_file(parent, W_OK | X_OK); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
570 g_free(parent); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
571 }; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
572 } |
392
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
573 break; |
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
574 } |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
575 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
576 menu = popup_menu_short_lived(); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
577 g_signal_connect(G_OBJECT(menu), "destroy", |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
578 G_CALLBACK(vd_popup_destroy_cb), vd); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
579 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
580 menu_item_add_stock_sensitive(menu, _("_Up to parent"), GTK_STOCK_GO_UP, |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
581 (vd->path && strcmp(vd->path, "/") != 0), |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
582 G_CALLBACK(vd_pop_menu_up_cb), vd); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
583 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
584 menu_item_add_divider(menu); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
585 menu_item_add_sensitive(menu, _("_Slideshow"), active, |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
586 G_CALLBACK(vd_pop_menu_slide_cb), vd); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
587 menu_item_add_sensitive(menu, _("Slideshow recursive"), active, |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
588 G_CALLBACK(vd_pop_menu_slide_rec_cb), vd); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
589 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
590 menu_item_add_divider(menu); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
591 menu_item_add_stock_sensitive(menu, _("Find _duplicates..."), GTK_STOCK_FIND, active, |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
592 G_CALLBACK(vd_pop_menu_dupe_cb), vd); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
593 menu_item_add_stock_sensitive(menu, _("Find duplicates recursive..."), GTK_STOCK_FIND, active, |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
594 G_CALLBACK(vd_pop_menu_dupe_rec_cb), vd); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
595 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
596 menu_item_add_divider(menu); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
597 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
598 menu_item_add_sensitive(menu, _("_New folder..."), new_folder_active, |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
599 G_CALLBACK(vd_pop_menu_new_cb), vd); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
600 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
601 menu_item_add_sensitive(menu, _("_Rename..."), rename_delete_active, |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
602 G_CALLBACK(vd_pop_menu_rename_cb), vd); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
603 menu_item_add_stock_sensitive(menu, _("_Delete..."), GTK_STOCK_DELETE, rename_delete_active, |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
604 G_CALLBACK(vd_pop_menu_delete_cb), vd); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
605 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
606 menu_item_add_divider(menu); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
607 /* FIXME */ |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
608 menu_item_add_check(menu, _("View as _tree"), vd->type, |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
609 G_CALLBACK(vd_pop_menu_dir_view_as_cb), vd); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
610 menu_item_add_check(menu, _("Show _hidden files"), options->file_filter.show_hidden_files, |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
611 G_CALLBACK(vd_toggle_show_hidden_files_cb), vd); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
612 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
613 menu_item_add_stock(menu, _("Re_fresh"), GTK_STOCK_REFRESH, |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
614 G_CALLBACK(vd_pop_menu_refresh_cb), vd); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
615 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
616 return menu; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
617 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
618 |
394 | 619 /* |
620 *----------------------------------------------------------------------------- | |
621 * dnd | |
622 *----------------------------------------------------------------------------- | |
623 */ | |
624 | |
625 static GtkTargetEntry vd_dnd_drop_types[] = { | |
626 { "text/uri-list", 0, TARGET_URI_LIST } | |
627 }; | |
628 static gint vd_dnd_drop_types_count = 1; | |
629 | |
630 static void vd_dest_set(ViewDir *vd, gint enable) | |
631 { | |
632 if (enable) | |
633 { | |
634 gtk_drag_dest_set(vd->view, | |
635 GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP, | |
636 vd_dnd_drop_types, vd_dnd_drop_types_count, | |
637 GDK_ACTION_MOVE | GDK_ACTION_COPY); | |
638 } | |
639 else | |
640 { | |
641 gtk_drag_dest_unset(vd->view); | |
642 } | |
643 } | |
644 | |
645 static void vd_dnd_get(GtkWidget *widget, GdkDragContext *context, | |
646 GtkSelectionData *selection_data, guint info, | |
647 guint time, gpointer data) | |
648 { | |
649 ViewDir *vd = data; | |
650 GList *list; | |
651 gchar *uritext = NULL; | |
652 gint length = 0; | |
653 | |
654 if (!vd->click_fd) return; | |
655 | |
656 switch (info) | |
657 { | |
658 case TARGET_URI_LIST: | |
659 case TARGET_TEXT_PLAIN: | |
660 list = g_list_prepend(NULL, vd->click_fd); | |
661 uritext = uri_text_from_filelist(list, &length, (info == TARGET_TEXT_PLAIN)); | |
662 g_list_free(list); | |
663 break; | |
664 } | |
665 if (uritext) | |
666 { | |
667 gtk_selection_data_set (selection_data, selection_data->target, | |
668 8, (guchar *)uritext, length); | |
669 g_free(uritext); | |
670 } | |
671 } | |
672 | |
673 static void vd_dnd_begin(GtkWidget *widget, GdkDragContext *context, gpointer data) | |
674 { | |
675 ViewDir *vd = data; | |
676 | |
677 vd_color_set(vd, vd->click_fd, TRUE); | |
678 vd_dest_set(vd, FALSE); | |
679 } | |
680 | |
681 static void vd_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer data) | |
682 { | |
683 ViewDir *vd = data; | |
684 | |
685 vd_color_set(vd, vd->click_fd, FALSE); | |
686 | |
687 if (vd->type == DIRVIEW_LIST && context->action == GDK_ACTION_MOVE) | |
688 { | |
689 vd_refresh(vd); | |
690 } | |
691 vd_dest_set(vd, TRUE); | |
692 } | |
693 | |
694 static void vd_dnd_drop_receive(GtkWidget *widget, | |
695 GdkDragContext *context, gint x, gint y, | |
696 GtkSelectionData *selection_data, guint info, | |
697 guint time, gpointer data) | |
698 { | |
699 ViewDir *vd = data; | |
700 GtkTreePath *tpath; | |
701 FileData *fd = NULL; | |
702 | |
703 vd->click_fd = NULL; | |
704 | |
705 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), x, y, | |
706 &tpath, NULL, NULL, NULL)) | |
707 { | |
399 | 708 fd = vd_get_fd_from_tree_path(vd, GTK_TREE_VIEW(widget), tpath); |
394 | 709 gtk_tree_path_free(tpath); |
710 } | |
711 | |
712 if (!fd) return; | |
713 | |
714 if (info == TARGET_URI_LIST) | |
715 { | |
716 GList *list; | |
717 gint active; | |
718 | |
719 list = uri_filelist_from_text((gchar *)selection_data->data, TRUE); | |
720 if (!list) return; | |
721 | |
722 active = access_file(fd->path, W_OK | X_OK); | |
723 | |
724 vd_color_set(vd, fd, TRUE); | |
725 vd->popup = vd_drop_menu(vd, active); | |
726 gtk_menu_popup(GTK_MENU(vd->popup), NULL, NULL, NULL, NULL, 0, time); | |
727 | |
728 vd->drop_fd = fd; | |
729 vd->drop_list = list; | |
730 } | |
731 } | |
732 | |
407 | 733 static void vd_dnd_drop_update(ViewDir *vd, gint x, gint y) |
394 | 734 { |
735 GtkTreePath *tpath; | |
736 FileData *fd = NULL; | |
737 | |
738 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vd->view), x, y, | |
739 &tpath, NULL, NULL, NULL)) | |
740 { | |
399 | 741 fd = vd_get_fd_from_tree_path(vd, GTK_TREE_VIEW(vd->view), tpath); |
394 | 742 gtk_tree_path_free(tpath); |
743 } | |
744 | |
745 if (fd != vd->drop_fd) | |
746 { | |
747 vd_color_set(vd, vd->drop_fd, FALSE); | |
748 vd_color_set(vd, fd, TRUE); | |
407 | 749 if (fd && vd->dnd_drop_update_func) vd->dnd_drop_update_func(vd); |
394 | 750 } |
751 | |
752 vd->drop_fd = fd; | |
753 } | |
754 | |
755 void vd_dnd_drop_scroll_cancel(ViewDir *vd) | |
756 { | |
757 if (vd->drop_scroll_id != -1) g_source_remove(vd->drop_scroll_id); | |
758 vd->drop_scroll_id = -1; | |
759 } | |
760 | |
761 static gint vd_auto_scroll_idle_cb(gpointer data) | |
762 { | |
763 ViewDir *vd = data; | |
764 | |
765 if (vd->drop_fd) | |
766 { | |
767 GdkWindow *window; | |
768 gint x, y; | |
769 gint w, h; | |
770 | |
771 window = vd->view->window; | |
772 gdk_window_get_pointer(window, &x, &y, NULL); | |
773 gdk_drawable_get_size(window, &w, &h); | |
774 if (x >= 0 && x < w && y >= 0 && y < h) | |
775 { | |
407 | 776 vd_dnd_drop_update(vd, x, y); |
394 | 777 } |
778 } | |
779 | |
780 vd->drop_scroll_id = -1; | |
781 return FALSE; | |
782 } | |
783 | |
784 static gint vd_auto_scroll_notify_cb(GtkWidget *widget, gint x, gint y, gpointer data) | |
785 { | |
786 ViewDir *vd = data; | |
787 | |
788 if (!vd->drop_fd || vd->drop_list) return FALSE; | |
789 | |
790 if (vd->drop_scroll_id == -1) vd->drop_scroll_id = g_idle_add(vd_auto_scroll_idle_cb, vd); | |
791 | |
792 return TRUE; | |
793 } | |
794 | |
795 static gint vd_dnd_drop_motion(GtkWidget *widget, GdkDragContext *context, | |
796 gint x, gint y, guint time, gpointer data) | |
797 { | |
798 ViewDir *vd = data; | |
799 | |
800 vd->click_fd = NULL; | |
801 | |
802 if (gtk_drag_get_source_widget(context) == vd->view) | |
803 { | |
804 /* from same window */ | |
805 gdk_drag_status(context, 0, time); | |
806 return TRUE; | |
807 } | |
808 else | |
809 { | |
810 gdk_drag_status(context, context->suggested_action, time); | |
811 } | |
812 | |
407 | 813 vd_dnd_drop_update(vd, x, y); |
394 | 814 |
815 if (vd->drop_fd) | |
816 { | |
817 GtkAdjustment *adj = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(vd->view)); | |
818 widget_auto_scroll_start(vd->view, adj, -1, -1, vd_auto_scroll_notify_cb, vd); | |
819 } | |
820 | |
821 return FALSE; | |
822 } | |
823 | |
824 static void vd_dnd_drop_leave(GtkWidget *widget, GdkDragContext *context, guint time, gpointer data) | |
825 { | |
826 ViewDir *vd = data; | |
827 | |
828 if (vd->drop_fd != vd->click_fd) vd_color_set(vd, vd->drop_fd, FALSE); | |
829 | |
830 vd->drop_fd = NULL; | |
831 | |
407 | 832 if (vd->dnd_drop_leave_func) vd->dnd_drop_leave_func(vd); |
394 | 833 } |
834 | |
835 void vd_dnd_init(ViewDir *vd) | |
836 { | |
837 gtk_drag_source_set(vd->view, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK, | |
838 dnd_file_drag_types, dnd_file_drag_types_count, | |
839 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_ASK); | |
840 g_signal_connect(G_OBJECT(vd->view), "drag_data_get", | |
841 G_CALLBACK(vd_dnd_get), vd); | |
842 g_signal_connect(G_OBJECT(vd->view), "drag_begin", | |
843 G_CALLBACK(vd_dnd_begin), vd); | |
844 g_signal_connect(G_OBJECT(vd->view), "drag_end", | |
845 G_CALLBACK(vd_dnd_end), vd); | |
846 | |
847 vd_dest_set(vd, TRUE); | |
848 g_signal_connect(G_OBJECT(vd->view), "drag_data_received", | |
849 G_CALLBACK(vd_dnd_drop_receive), vd); | |
850 g_signal_connect(G_OBJECT(vd->view), "drag_motion", | |
851 G_CALLBACK(vd_dnd_drop_motion), vd); | |
852 g_signal_connect(G_OBJECT(vd->view), "drag_leave", | |
853 G_CALLBACK(vd_dnd_drop_leave), vd); | |
854 } | |
855 | |
395 | 856 /* |
857 *---------------------------------------------------------------------------- | |
858 * callbacks | |
859 *---------------------------------------------------------------------------- | |
860 */ | |
861 | |
862 void vd_menu_position_cb(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer data) | |
863 { | |
864 ViewDir *vd = data; | |
865 GtkTreeModel *store; | |
866 GtkTreeIter iter; | |
867 GtkTreePath *tpath; | |
868 gint cw, ch; | |
869 | |
870 if (vd_find_row(vd, vd->click_fd, &iter) < 0) return; | |
871 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view)); | |
872 tpath = gtk_tree_model_get_path(store, &iter); | |
873 tree_view_get_cell_clamped(GTK_TREE_VIEW(vd->view), tpath, 0, TRUE, x, y, &cw, &ch); | |
874 gtk_tree_path_free(tpath); | |
875 *y += ch; | |
876 popup_menu_position_clamp(menu, x, y, 0); | |
877 } | |
878 | |
396 | 879 void vd_activate_cb(GtkTreeView *tview, GtkTreePath *tpath, GtkTreeViewColumn *column, gpointer data) |
880 { | |
881 ViewDir *vd = data; | |
399 | 882 FileData *fd = vd_get_fd_from_tree_path(vd, tview, tpath); |
396 | 883 |
884 vd_select_row(vd, fd); | |
885 } | |
886 | |
887 static GdkColor *vd_color_shifted(GtkWidget *widget) | |
888 { | |
889 static GdkColor color; | |
890 static GtkWidget *done = NULL; | |
891 | |
892 if (done != widget) | |
893 { | |
894 GtkStyle *style; | |
895 | |
896 style = gtk_widget_get_style(widget); | |
897 memcpy(&color, &style->base[GTK_STATE_NORMAL], sizeof(color)); | |
898 shift_color(&color, -1, 0); | |
899 done = widget; | |
900 } | |
901 | |
902 return &color; | |
903 } | |
904 | |
905 void vd_color_cb(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, | |
906 GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data) | |
907 { | |
908 ViewDir *vd = data; | |
909 gboolean set; | |
910 | |
911 gtk_tree_model_get(tree_model, iter, DIR_COLUMN_COLOR, &set, -1); | |
912 g_object_set(G_OBJECT(cell), | |
913 "cell-background-gdk", vd_color_shifted(vd->view), | |
914 "cell-background-set", set, NULL); | |
915 } | |
916 | |
397 | 917 gint vd_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) |
918 { | |
919 ViewDir *vd = data; | |
920 GtkTreePath *tpath; | |
921 FileData *fd = NULL; | |
922 | |
400 | 923 if (!vd->click_fd) return FALSE; |
397 | 924 vd_color_set(vd, vd->click_fd, FALSE); |
925 | |
926 if (bevent->button != 1) return TRUE; | |
927 | |
928 if ((bevent->x != 0 || bevent->y != 0) && | |
929 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), bevent->x, bevent->y, | |
930 &tpath, NULL, NULL, NULL)) | |
931 { | |
399 | 932 fd = vd_get_fd_from_tree_path(vd, GTK_TREE_VIEW(widget), tpath); |
397 | 933 gtk_tree_path_free(tpath); |
934 } | |
935 | |
936 if (fd && vd->click_fd == fd) | |
937 { | |
938 vdlist_select_row(vd, vd->click_fd); | |
939 } | |
940 | |
400 | 941 return FALSE; |
397 | 942 } |
943 | |
401
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
944 gint vd_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
945 { |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
946 ViewDir *vd = data; |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
947 gint ret = FALSE; |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
948 |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
949 switch(vd->type) |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
950 { |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
951 case DIRVIEW_LIST: ret = vdlist_press_key_cb(widget, event, data); break; |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
952 case DIRVIEW_TREE: ret = vdtree_press_key_cb(widget, event, data); break; |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
953 } |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
954 |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
955 return ret; |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
956 } |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
957 |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
958 gint vd_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
959 { |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
960 ViewDir *vd = data; |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
961 gint ret = FALSE; |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
962 |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
963 switch(vd->type) |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
964 { |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
965 case DIRVIEW_LIST: ret = vdlist_press_cb(widget, bevent, data); break; |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
966 case DIRVIEW_TREE: ret = vdtree_press_cb(widget, bevent, data); break; |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
967 } |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
968 |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
969 return ret; |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
970 } |