Mercurial > geeqie
annotate src/view_dir.c @ 556:fe675761d091
Replace Layout icon_view field by more generic file_view_type.
Replace option layout.view_as_icons by layout.file_view_type.
author | zas_ |
---|---|
date | Sat, 03 May 2008 11:34:13 +0000 |
parents | 0717bcc4f2b7 |
children | 905688aa2317 |
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 |
475 | 3 * Copyright (C) 2008 The Geeqie Team |
380
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 } |
442 | 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 { |
523
0717bcc4f2b7
Handle the case of reduction of the number of view directory types.
zas_
parents:
522
diff
changeset
|
61 g_assert(VIEW_DIR_TYPES_COUNT <= G_N_ELEMENTS(menu_view_dir_radio_entries)); |
0717bcc4f2b7
Handle the case of reduction of the number of view directory types.
zas_
parents:
522
diff
changeset
|
62 |
384
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
63 ViewDir *vd = g_new0(ViewDir, 1); |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
64 |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
65 vd->path = NULL; |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
66 vd->click_fd = NULL; |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
67 |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
68 vd->drop_fd = NULL; |
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 vd->drop_scroll_id = -1; |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
71 vd->drop_list = NULL; |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
72 |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
73 vd->popup = NULL; |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
74 |
407 | 75 vd->dnd_drop_leave_func = NULL; |
76 vd->dnd_drop_update_func = NULL; | |
77 | |
384
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
78 vd->widget = gtk_scrolled_window_new(NULL, NULL); |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
79 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
|
80 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
|
81 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
82 |
391 | 83 vd->pf = folder_icons_new(); |
84 | |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
85 switch(type) |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
86 { |
384
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
87 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
|
88 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
|
89 } |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
90 |
405 | 91 gtk_container_add(GTK_CONTAINER(vd->widget), vd->view); |
442 | 92 |
405 | 93 vd_dnd_init(vd); |
94 | |
95 g_signal_connect(G_OBJECT(vd->view), "row_activated", | |
96 G_CALLBACK(vd_activate_cb), vd); | |
384
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
97 g_signal_connect(G_OBJECT(vd->widget), "destroy", |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
98 G_CALLBACK(vd_destroy_cb), vd); |
405 | 99 g_signal_connect(G_OBJECT(vd->view), "key_press_event", |
100 G_CALLBACK(vd_press_key_cb), vd); | |
101 g_signal_connect(G_OBJECT(vd->view), "button_press_event", | |
102 G_CALLBACK(vd_press_cb), vd); | |
103 g_signal_connect(G_OBJECT(vd->view), "button_release_event", | |
104 G_CALLBACK(vd_release_cb), vd); | |
105 | |
106 if (path) vd_set_path(vd, path); | |
107 | |
108 gtk_widget_show(vd->view); | |
384
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
109 |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
110 return vd; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
111 } |
442 | 112 |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
113 void vd_set_select_func(ViewDir *vd, |
442 | 114 void (*func)(ViewDir *vd, const gchar *path, gpointer data), gpointer data) |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
115 { |
442 | 116 vd->select_func = func; |
117 vd->select_data = data; | |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
118 } |
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 void vd_set_layout(ViewDir *vd, LayoutWindow *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 vd->layout = layout; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
123 } |
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 vd_set_path(ViewDir *vd, const gchar *path) |
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 gint ret = FALSE; |
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 switch(vd->type) |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
130 { |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
131 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
|
132 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
|
133 } |
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 return ret; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
136 } |
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 void vd_refresh(ViewDir *vd) |
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 switch(vd->type) |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
141 { |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
142 case DIRVIEW_LIST: return vdlist_refresh(vd); |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
143 case DIRVIEW_TREE: return vdtree_refresh(vd); |
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 } |
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 *vd_row_get_path(ViewDir *vd, gint row) |
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 const gchar *ret = NULL; |
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 switch(vd->type) |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
152 { |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
153 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
|
154 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
|
155 } |
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 return ret; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
158 } |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
159 |
396 | 160 void vd_select_row(ViewDir *vd, FileData *fd) |
161 { | |
162 switch(vd->type) | |
163 { | |
164 case DIRVIEW_LIST: vdlist_select_row(vd, fd); break; | |
165 case DIRVIEW_TREE: vdtree_select_row(vd, fd); break; | |
166 } | |
167 } | |
168 | |
389 | 169 gint vd_find_row(ViewDir *vd, FileData *fd, GtkTreeIter *iter) |
170 { | |
171 gint ret = FALSE; | |
172 | |
173 switch(vd->type) | |
174 { | |
175 case DIRVIEW_LIST: ret = vdlist_find_row(vd, fd, iter); break; | |
176 case DIRVIEW_TREE: ret = vdtree_find_row(vd, fd, iter, NULL); break; | |
177 } | |
178 | |
179 return ret; | |
180 } | |
181 | |
399 | 182 FileData *vd_get_fd_from_tree_path(ViewDir *vd, GtkTreeView *tview, GtkTreePath *tpath) |
183 { | |
184 GtkTreeIter iter; | |
185 FileData *fd = NULL; | |
186 GtkTreeModel *store; | |
187 | |
188 store = gtk_tree_view_get_model(tview); | |
189 gtk_tree_model_get_iter(store, &iter, tpath); | |
190 switch (vd->type) | |
191 { | |
192 case DIRVIEW_LIST: | |
193 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &fd, -1); | |
194 break; | |
195 case DIRVIEW_TREE: | |
196 { | |
197 NodeData *nd; | |
198 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1); | |
199 fd = (nd) ? nd->fd : NULL; | |
200 }; | |
201 break; | |
202 } | |
203 | |
204 return fd; | |
205 } | |
206 | |
389 | 207 static gint vd_rename_cb(TreeEditData *td, const gchar *old, const gchar *new, gpointer data) |
208 { | |
209 ViewDir *vd = data; | |
210 FileData *fd; | |
211 gchar *old_path; | |
212 gchar *new_path; | |
213 gchar *base; | |
214 | |
399 | 215 fd = vd_get_fd_from_tree_path(vd, GTK_TREE_VIEW(vd->view), td->path); |
389 | 216 if (!fd) return FALSE; |
217 | |
218 old_path = g_strdup(fd->path); | |
219 | |
220 base = remove_level_from_path(old_path); | |
221 new_path = concat_dir_and_file(base, new); | |
222 g_free(base); | |
223 | |
224 if (file_util_rename_dir(fd, new_path, vd->view)) | |
225 { | |
226 | |
227 if (vd->type == DIRVIEW_TREE) vdtree_populate_path(vd, new_path, TRUE, TRUE); | |
228 if (vd->layout && strcmp(vd->path, old_path) == 0) | |
229 { | |
230 layout_set_path(vd->layout, new_path); | |
231 } | |
232 else | |
233 { | |
234 if (vd->type == DIRVIEW_LIST) vd_refresh(vd); | |
235 } | |
236 } | |
237 | |
238 g_free(old_path); | |
239 g_free(new_path); | |
240 | |
241 return FALSE; | |
242 } | |
243 | |
244 static void vd_rename_by_data(ViewDir *vd, FileData *fd) | |
245 { | |
246 GtkTreeModel *store; | |
247 GtkTreePath *tpath; | |
248 GtkTreeIter iter; | |
249 | |
250 if (!fd || vd_find_row(vd, fd, &iter) < 0) return; | |
251 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view)); | |
252 tpath = gtk_tree_model_get_path(store, &iter); | |
253 | |
254 tree_edit_by_path(GTK_TREE_VIEW(vd->view), tpath, 0, fd->name, | |
255 vd_rename_cb, vd); | |
256 gtk_tree_path_free(tpath); | |
257 } | |
258 | |
259 | |
383
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
260 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
|
261 { |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
262 GtkTreeModel *store; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
263 GtkTreeIter iter; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
264 |
389 | 265 if (vd_find_row(vd, fd, &iter) < 0) return; |
266 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view)); | |
267 | |
383
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
268 switch(vd->type) |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
269 { |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
270 case DIRVIEW_LIST: |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
271 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
|
272 break; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
273 case DIRVIEW_TREE: |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
274 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
|
275 break; |
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 } |
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 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
|
280 { |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
281 ViewDir *vd = data; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
282 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
283 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
|
284 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
|
285 vd->popup = NULL; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
286 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
287 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
|
288 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
|
289 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
|
290 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
|
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 /* |
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 * 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
|
296 *----------------------------------------------------------------------------- |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
297 */ |
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 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
|
300 { |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
301 ViewDir *vd = data; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
302 const gchar *path; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
303 GList *list; |
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 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
|
306 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
307 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
|
308 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
|
309 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
|
310 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
311 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
|
312 } |
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 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
|
315 { |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
316 ViewDir *vd = data; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
317 const gchar *path; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
318 GList *list; |
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 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
|
321 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
322 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
|
323 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
|
324 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
325 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
|
326 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
327 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
|
328 } |
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 *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
|
331 { |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
332 GtkWidget *menu; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
333 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
334 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
|
335 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
|
336 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
|
337 |
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_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
|
339 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
|
340 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
|
341 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
342 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
|
343 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
|
344 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
345 return menu; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
346 } |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
347 |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
348 /* |
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 * pop-up menu |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
351 *----------------------------------------------------------------------------- |
442 | 352 */ |
388
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 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
|
355 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
356 ViewDir *vd = data; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
357 gchar *path; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
358 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
359 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
|
360 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
|
361 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
362 if (vd->select_func) |
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 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
|
365 } |
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 g_free(path); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
368 } |
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 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
|
371 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
372 ViewDir *vd = data; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
373 gchar *path; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
374 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
375 if (!vd->layout) return; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
376 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
|
377 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
378 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
|
379 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
380 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
|
381 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
|
382 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
|
383 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
|
384 } |
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 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
|
387 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
388 ViewDir *vd = data; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
389 gchar *path; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
390 GList *list; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
391 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
392 if (!vd->layout) return; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
393 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
|
394 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
395 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
|
396 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
397 list = filelist_recursive(path); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
398 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
399 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
|
400 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
|
401 } |
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 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
|
404 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
405 DupeWindow *dw; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
406 GList *list = NULL; |
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 (!vd->click_fd) return; |
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 if (recursive) |
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 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
|
413 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
414 else |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
415 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
416 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
|
417 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
|
418 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
419 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
420 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
|
421 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
|
422 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
423 filelist_free(list); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
424 } |
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 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
|
427 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
428 ViewDir *vd = data; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
429 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
|
430 } |
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 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
|
433 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
434 ViewDir *vd = data; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
435 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
|
436 } |
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 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
|
439 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
440 ViewDir *vd = data; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
441 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
442 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
|
443 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
|
444 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
445 |
522
fd4208f8b5f3
Allow to copy the path of a directory to clipboard from directory views.
zas_
parents:
512
diff
changeset
|
446 static void vd_pop_menu_copy_path_cb(GtkWidget *widget, gpointer data) |
fd4208f8b5f3
Allow to copy the path of a directory to clipboard from directory views.
zas_
parents:
512
diff
changeset
|
447 { |
fd4208f8b5f3
Allow to copy the path of a directory to clipboard from directory views.
zas_
parents:
512
diff
changeset
|
448 ViewDir *vd = data; |
fd4208f8b5f3
Allow to copy the path of a directory to clipboard from directory views.
zas_
parents:
512
diff
changeset
|
449 |
fd4208f8b5f3
Allow to copy the path of a directory to clipboard from directory views.
zas_
parents:
512
diff
changeset
|
450 if (!vd->click_fd) return; |
fd4208f8b5f3
Allow to copy the path of a directory to clipboard from directory views.
zas_
parents:
512
diff
changeset
|
451 |
fd4208f8b5f3
Allow to copy the path of a directory to clipboard from directory views.
zas_
parents:
512
diff
changeset
|
452 file_util_copy_path_to_clipboard(vd->click_fd); |
fd4208f8b5f3
Allow to copy the path of a directory to clipboard from directory views.
zas_
parents:
512
diff
changeset
|
453 } |
fd4208f8b5f3
Allow to copy the path of a directory to clipboard from directory views.
zas_
parents:
512
diff
changeset
|
454 |
419 | 455 #define VIEW_DIR_AS_SUBMENU_KEY "view_dir_as_submenu" |
417
440979320308
Fix directory view popup menu to display a View As submenu
zas_
parents:
407
diff
changeset
|
456 static void vd_pop_submenu_dir_view_as_cb(GtkWidget *widget, gpointer data) |
440979320308
Fix directory view popup menu to display a View As submenu
zas_
parents:
407
diff
changeset
|
457 { |
440979320308
Fix directory view popup menu to display a View As submenu
zas_
parents:
407
diff
changeset
|
458 ViewDir *vd = data; |
419 | 459 |
417
440979320308
Fix directory view popup menu to display a View As submenu
zas_
parents:
407
diff
changeset
|
460 DirViewType new_type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), VIEW_DIR_AS_SUBMENU_KEY)); |
556
fe675761d091
Replace Layout icon_view field by more generic file_view_type.
zas_
parents:
523
diff
changeset
|
461 layout_views_set(vd->layout, new_type, vd->layout->file_view_type); |
417
440979320308
Fix directory view popup menu to display a View As submenu
zas_
parents:
407
diff
changeset
|
462 } |
440979320308
Fix directory view popup menu to display a View As submenu
zas_
parents:
407
diff
changeset
|
463 |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
464 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
|
465 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
466 ViewDir *vd = data; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
467 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
468 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
|
469 } |
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 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
|
472 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
473 ViewDir *vd = data; |
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 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
|
476 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
|
477 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
478 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
479 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
|
480 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
481 ViewDir *vd = data; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
482 const gchar *path = NULL; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
483 gchar *new_path; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
484 gchar *buf; |
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 switch(vd->type) |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
487 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
488 case DIRVIEW_LIST: |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
489 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
490 if (!vd->path) return; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
491 path = vd->path; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
492 }; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
493 break; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
494 case DIRVIEW_TREE: |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
495 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
496 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
|
497 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
|
498 }; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
499 break; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
500 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
501 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
502 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
|
503 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
|
504 g_free(buf); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
505 if (!new_path) return; |
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 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
|
508 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
509 gchar *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 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
|
512 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
|
513 g_free(text); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
514 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
515 else |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
516 { |
389 | 517 FileData *fd = NULL; |
518 | |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
519 switch(vd->type) |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
520 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
521 case DIRVIEW_LIST: |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
522 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
523 vd_refresh(vd); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
524 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
|
525 }; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
526 break; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
527 case DIRVIEW_TREE: |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
528 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
|
529 break; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
530 } |
389 | 531 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
|
532 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
533 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
534 g_free(new_path); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
535 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
536 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
537 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
|
538 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
539 ViewDir *vd = data; |
442 | 540 |
389 | 541 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
|
542 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
543 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
544 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
|
545 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
546 GtkWidget *menu; |
417
440979320308
Fix directory view popup menu to display a View As submenu
zas_
parents:
407
diff
changeset
|
547 GtkWidget *submenu; |
440979320308
Fix directory view popup menu to display a View As submenu
zas_
parents:
407
diff
changeset
|
548 GtkWidget *item; |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
549 gint active; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
550 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
|
551 gint new_folder_active = FALSE; |
417
440979320308
Fix directory view popup menu to display a View As submenu
zas_
parents:
407
diff
changeset
|
552 gint i; |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
553 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
554 active = (fd != NULL); |
392
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
555 switch(vd->type) |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
556 { |
392
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
557 case DIRVIEW_LIST: |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
558 { |
392
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
559 /* check using . (always row 0) */ |
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
560 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
|
561 |
392
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
562 /* ignore .. and . */ |
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
563 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
|
564 strcmp(fd->name, ".") != 0 && |
442 | 565 strcmp(fd->name, "..") != 0 && |
566 access_file(fd->path, W_OK | X_OK)); | |
392
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
567 }; |
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
568 break; |
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
569 case DIRVIEW_TREE: |
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
570 { |
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
571 if (fd) |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
572 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
573 gchar *parent; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
574 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
|
575 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
|
576 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
|
577 g_free(parent); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
578 }; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
579 } |
392
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
580 break; |
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
581 } |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
582 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
583 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
|
584 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
|
585 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
|
586 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
587 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
|
588 (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
|
589 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
|
590 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
591 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
|
592 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
|
593 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
|
594 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
|
595 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
|
596 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
597 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
|
598 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
|
599 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
|
600 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
|
601 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
|
602 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
603 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
|
604 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
605 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
|
606 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
|
607 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
608 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
|
609 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
|
610 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
|
611 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
|
612 |
522
fd4208f8b5f3
Allow to copy the path of a directory to clipboard from directory views.
zas_
parents:
512
diff
changeset
|
613 if (options->show_copy_path) |
fd4208f8b5f3
Allow to copy the path of a directory to clipboard from directory views.
zas_
parents:
512
diff
changeset
|
614 menu_item_add(menu, _("_Copy path"), |
fd4208f8b5f3
Allow to copy the path of a directory to clipboard from directory views.
zas_
parents:
512
diff
changeset
|
615 G_CALLBACK(vd_pop_menu_copy_path_cb), vd); |
fd4208f8b5f3
Allow to copy the path of a directory to clipboard from directory views.
zas_
parents:
512
diff
changeset
|
616 |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
617 menu_item_add_divider(menu); |
442 | 618 |
417
440979320308
Fix directory view popup menu to display a View As submenu
zas_
parents:
407
diff
changeset
|
619 item = menu_item_add(menu, _("_View as"), NULL, NULL); |
440979320308
Fix directory view popup menu to display a View As submenu
zas_
parents:
407
diff
changeset
|
620 submenu = gtk_menu_new(); |
442 | 621 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
417
440979320308
Fix directory view popup menu to display a View As submenu
zas_
parents:
407
diff
changeset
|
622 |
523
0717bcc4f2b7
Handle the case of reduction of the number of view directory types.
zas_
parents:
522
diff
changeset
|
623 for (i = 0; i < VIEW_DIR_TYPES_COUNT; i++) |
417
440979320308
Fix directory view popup menu to display a View As submenu
zas_
parents:
407
diff
changeset
|
624 { |
421 | 625 item = menu_item_add_check(submenu, _(menu_view_dir_radio_entries[i].label), |
417
440979320308
Fix directory view popup menu to display a View As submenu
zas_
parents:
407
diff
changeset
|
626 (vd->type == menu_view_dir_radio_entries[i].value), |
440979320308
Fix directory view popup menu to display a View As submenu
zas_
parents:
407
diff
changeset
|
627 G_CALLBACK(vd_pop_submenu_dir_view_as_cb), vd); |
440979320308
Fix directory view popup menu to display a View As submenu
zas_
parents:
407
diff
changeset
|
628 g_object_set_data(G_OBJECT(item), VIEW_DIR_AS_SUBMENU_KEY, GINT_TO_POINTER(menu_view_dir_radio_entries[i].value)); |
440979320308
Fix directory view popup menu to display a View As submenu
zas_
parents:
407
diff
changeset
|
629 } |
440979320308
Fix directory view popup menu to display a View As submenu
zas_
parents:
407
diff
changeset
|
630 |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
631 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
|
632 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
|
633 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
634 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
|
635 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
|
636 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
637 return menu; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
638 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
639 |
394 | 640 /* |
641 *----------------------------------------------------------------------------- | |
642 * dnd | |
643 *----------------------------------------------------------------------------- | |
644 */ | |
645 | |
646 static GtkTargetEntry vd_dnd_drop_types[] = { | |
647 { "text/uri-list", 0, TARGET_URI_LIST } | |
648 }; | |
649 static gint vd_dnd_drop_types_count = 1; | |
650 | |
651 static void vd_dest_set(ViewDir *vd, gint enable) | |
652 { | |
653 if (enable) | |
654 { | |
655 gtk_drag_dest_set(vd->view, | |
656 GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP, | |
657 vd_dnd_drop_types, vd_dnd_drop_types_count, | |
658 GDK_ACTION_MOVE | GDK_ACTION_COPY); | |
659 } | |
660 else | |
661 { | |
662 gtk_drag_dest_unset(vd->view); | |
663 } | |
664 } | |
665 | |
666 static void vd_dnd_get(GtkWidget *widget, GdkDragContext *context, | |
667 GtkSelectionData *selection_data, guint info, | |
668 guint time, gpointer data) | |
669 { | |
670 ViewDir *vd = data; | |
671 GList *list; | |
672 gchar *uritext = NULL; | |
673 gint length = 0; | |
674 | |
675 if (!vd->click_fd) return; | |
676 | |
677 switch (info) | |
678 { | |
679 case TARGET_URI_LIST: | |
680 case TARGET_TEXT_PLAIN: | |
681 list = g_list_prepend(NULL, vd->click_fd); | |
682 uritext = uri_text_from_filelist(list, &length, (info == TARGET_TEXT_PLAIN)); | |
683 g_list_free(list); | |
684 break; | |
685 } | |
686 if (uritext) | |
687 { | |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
511
diff
changeset
|
688 gtk_selection_data_set(selection_data, selection_data->target, |
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
511
diff
changeset
|
689 8, (guchar *)uritext, length); |
394 | 690 g_free(uritext); |
691 } | |
692 } | |
693 | |
694 static void vd_dnd_begin(GtkWidget *widget, GdkDragContext *context, gpointer data) | |
695 { | |
696 ViewDir *vd = data; | |
697 | |
698 vd_color_set(vd, vd->click_fd, TRUE); | |
699 vd_dest_set(vd, FALSE); | |
700 } | |
701 | |
702 static void vd_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer data) | |
703 { | |
704 ViewDir *vd = data; | |
705 | |
706 vd_color_set(vd, vd->click_fd, FALSE); | |
707 | |
708 if (vd->type == DIRVIEW_LIST && context->action == GDK_ACTION_MOVE) | |
709 { | |
710 vd_refresh(vd); | |
711 } | |
712 vd_dest_set(vd, TRUE); | |
713 } | |
714 | |
715 static void vd_dnd_drop_receive(GtkWidget *widget, | |
511 | 716 GdkDragContext *context, gint x, gint y, |
717 GtkSelectionData *selection_data, guint info, | |
718 guint time, gpointer data) | |
394 | 719 { |
720 ViewDir *vd = data; | |
721 GtkTreePath *tpath; | |
722 FileData *fd = NULL; | |
723 | |
724 vd->click_fd = NULL; | |
725 | |
726 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), x, y, | |
727 &tpath, NULL, NULL, NULL)) | |
728 { | |
399 | 729 fd = vd_get_fd_from_tree_path(vd, GTK_TREE_VIEW(widget), tpath); |
394 | 730 gtk_tree_path_free(tpath); |
731 } | |
732 | |
733 if (!fd) return; | |
734 | |
735 if (info == TARGET_URI_LIST) | |
736 { | |
737 GList *list; | |
738 gint active; | |
494
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
739 gint done = FALSE; |
394 | 740 |
741 list = uri_filelist_from_text((gchar *)selection_data->data, TRUE); | |
742 if (!list) return; | |
743 | |
744 active = access_file(fd->path, W_OK | X_OK); | |
745 | |
746 vd_color_set(vd, fd, TRUE); | |
494
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
747 |
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
748 if (active) |
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
749 { |
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
750 if (context->actions == GDK_ACTION_COPY) |
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
751 { |
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
752 file_util_copy_simple(list, fd->path); |
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
753 done = TRUE; |
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
754 } |
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
755 else if (context->actions == GDK_ACTION_MOVE) |
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
756 { |
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
757 file_util_move_simple(list, fd->path); |
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
758 done = TRUE; |
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
759 } |
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
760 } |
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
761 |
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
762 if (done == FALSE) |
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
763 { |
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
764 vd->popup = vd_drop_menu(vd, active); |
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
765 gtk_menu_popup(GTK_MENU(vd->popup), NULL, NULL, NULL, NULL, 0, time); |
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
766 } |
394 | 767 |
768 vd->drop_fd = fd; | |
769 vd->drop_list = list; | |
770 } | |
771 } | |
772 | |
407 | 773 static void vd_dnd_drop_update(ViewDir *vd, gint x, gint y) |
394 | 774 { |
775 GtkTreePath *tpath; | |
776 FileData *fd = NULL; | |
777 | |
778 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vd->view), x, y, | |
779 &tpath, NULL, NULL, NULL)) | |
780 { | |
399 | 781 fd = vd_get_fd_from_tree_path(vd, GTK_TREE_VIEW(vd->view), tpath); |
394 | 782 gtk_tree_path_free(tpath); |
783 } | |
784 | |
785 if (fd != vd->drop_fd) | |
786 { | |
787 vd_color_set(vd, vd->drop_fd, FALSE); | |
788 vd_color_set(vd, fd, TRUE); | |
407 | 789 if (fd && vd->dnd_drop_update_func) vd->dnd_drop_update_func(vd); |
394 | 790 } |
791 | |
792 vd->drop_fd = fd; | |
793 } | |
794 | |
795 void vd_dnd_drop_scroll_cancel(ViewDir *vd) | |
796 { | |
797 if (vd->drop_scroll_id != -1) g_source_remove(vd->drop_scroll_id); | |
798 vd->drop_scroll_id = -1; | |
799 } | |
800 | |
801 static gint vd_auto_scroll_idle_cb(gpointer data) | |
802 { | |
803 ViewDir *vd = data; | |
804 | |
805 if (vd->drop_fd) | |
806 { | |
807 GdkWindow *window; | |
808 gint x, y; | |
809 gint w, h; | |
810 | |
811 window = vd->view->window; | |
812 gdk_window_get_pointer(window, &x, &y, NULL); | |
813 gdk_drawable_get_size(window, &w, &h); | |
814 if (x >= 0 && x < w && y >= 0 && y < h) | |
815 { | |
407 | 816 vd_dnd_drop_update(vd, x, y); |
394 | 817 } |
818 } | |
819 | |
820 vd->drop_scroll_id = -1; | |
821 return FALSE; | |
822 } | |
823 | |
824 static gint vd_auto_scroll_notify_cb(GtkWidget *widget, gint x, gint y, gpointer data) | |
825 { | |
826 ViewDir *vd = data; | |
827 | |
828 if (!vd->drop_fd || vd->drop_list) return FALSE; | |
829 | |
830 if (vd->drop_scroll_id == -1) vd->drop_scroll_id = g_idle_add(vd_auto_scroll_idle_cb, vd); | |
831 | |
832 return TRUE; | |
833 } | |
834 | |
835 static gint vd_dnd_drop_motion(GtkWidget *widget, GdkDragContext *context, | |
836 gint x, gint y, guint time, gpointer data) | |
837 { | |
442 | 838 ViewDir *vd = data; |
394 | 839 |
840 vd->click_fd = NULL; | |
841 | |
842 if (gtk_drag_get_source_widget(context) == vd->view) | |
843 { | |
844 /* from same window */ | |
845 gdk_drag_status(context, 0, time); | |
846 return TRUE; | |
847 } | |
848 else | |
849 { | |
850 gdk_drag_status(context, context->suggested_action, time); | |
851 } | |
852 | |
407 | 853 vd_dnd_drop_update(vd, x, y); |
394 | 854 |
855 if (vd->drop_fd) | |
856 { | |
857 GtkAdjustment *adj = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(vd->view)); | |
858 widget_auto_scroll_start(vd->view, adj, -1, -1, vd_auto_scroll_notify_cb, vd); | |
859 } | |
860 | |
861 return FALSE; | |
862 } | |
863 | |
864 static void vd_dnd_drop_leave(GtkWidget *widget, GdkDragContext *context, guint time, gpointer data) | |
865 { | |
866 ViewDir *vd = data; | |
867 | |
868 if (vd->drop_fd != vd->click_fd) vd_color_set(vd, vd->drop_fd, FALSE); | |
869 | |
870 vd->drop_fd = NULL; | |
871 | |
407 | 872 if (vd->dnd_drop_leave_func) vd->dnd_drop_leave_func(vd); |
394 | 873 } |
874 | |
875 void vd_dnd_init(ViewDir *vd) | |
876 { | |
877 gtk_drag_source_set(vd->view, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK, | |
878 dnd_file_drag_types, dnd_file_drag_types_count, | |
879 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_ASK); | |
880 g_signal_connect(G_OBJECT(vd->view), "drag_data_get", | |
881 G_CALLBACK(vd_dnd_get), vd); | |
882 g_signal_connect(G_OBJECT(vd->view), "drag_begin", | |
883 G_CALLBACK(vd_dnd_begin), vd); | |
884 g_signal_connect(G_OBJECT(vd->view), "drag_end", | |
885 G_CALLBACK(vd_dnd_end), vd); | |
886 | |
887 vd_dest_set(vd, TRUE); | |
888 g_signal_connect(G_OBJECT(vd->view), "drag_data_received", | |
889 G_CALLBACK(vd_dnd_drop_receive), vd); | |
890 g_signal_connect(G_OBJECT(vd->view), "drag_motion", | |
891 G_CALLBACK(vd_dnd_drop_motion), vd); | |
892 g_signal_connect(G_OBJECT(vd->view), "drag_leave", | |
893 G_CALLBACK(vd_dnd_drop_leave), vd); | |
894 } | |
895 | |
395 | 896 /* |
897 *---------------------------------------------------------------------------- | |
898 * callbacks | |
899 *---------------------------------------------------------------------------- | |
900 */ | |
901 | |
902 void vd_menu_position_cb(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer data) | |
903 { | |
904 ViewDir *vd = data; | |
905 GtkTreeModel *store; | |
906 GtkTreeIter iter; | |
907 GtkTreePath *tpath; | |
908 gint cw, ch; | |
909 | |
910 if (vd_find_row(vd, vd->click_fd, &iter) < 0) return; | |
911 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view)); | |
912 tpath = gtk_tree_model_get_path(store, &iter); | |
913 tree_view_get_cell_clamped(GTK_TREE_VIEW(vd->view), tpath, 0, TRUE, x, y, &cw, &ch); | |
914 gtk_tree_path_free(tpath); | |
915 *y += ch; | |
916 popup_menu_position_clamp(menu, x, y, 0); | |
917 } | |
918 | |
396 | 919 void vd_activate_cb(GtkTreeView *tview, GtkTreePath *tpath, GtkTreeViewColumn *column, gpointer data) |
920 { | |
921 ViewDir *vd = data; | |
399 | 922 FileData *fd = vd_get_fd_from_tree_path(vd, tview, tpath); |
396 | 923 |
924 vd_select_row(vd, fd); | |
925 } | |
926 | |
927 static GdkColor *vd_color_shifted(GtkWidget *widget) | |
928 { | |
929 static GdkColor color; | |
930 static GtkWidget *done = NULL; | |
931 | |
932 if (done != widget) | |
933 { | |
934 GtkStyle *style; | |
935 | |
936 style = gtk_widget_get_style(widget); | |
937 memcpy(&color, &style->base[GTK_STATE_NORMAL], sizeof(color)); | |
938 shift_color(&color, -1, 0); | |
939 done = widget; | |
940 } | |
941 | |
942 return &color; | |
943 } | |
944 | |
945 void vd_color_cb(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, | |
946 GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data) | |
947 { | |
948 ViewDir *vd = data; | |
949 gboolean set; | |
950 | |
951 gtk_tree_model_get(tree_model, iter, DIR_COLUMN_COLOR, &set, -1); | |
952 g_object_set(G_OBJECT(cell), | |
953 "cell-background-gdk", vd_color_shifted(vd->view), | |
954 "cell-background-set", set, NULL); | |
955 } | |
956 | |
397 | 957 gint vd_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) |
958 { | |
959 ViewDir *vd = data; | |
960 GtkTreePath *tpath; | |
961 FileData *fd = NULL; | |
962 | |
400 | 963 if (!vd->click_fd) return FALSE; |
397 | 964 vd_color_set(vd, vd->click_fd, FALSE); |
965 | |
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
442
diff
changeset
|
966 if (bevent->button != MOUSE_BUTTON_LEFT) return TRUE; |
397 | 967 |
968 if ((bevent->x != 0 || bevent->y != 0) && | |
969 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), bevent->x, bevent->y, | |
970 &tpath, NULL, NULL, NULL)) | |
971 { | |
399 | 972 fd = vd_get_fd_from_tree_path(vd, GTK_TREE_VIEW(widget), tpath); |
397 | 973 gtk_tree_path_free(tpath); |
974 } | |
975 | |
976 if (fd && vd->click_fd == fd) | |
977 { | |
978 vdlist_select_row(vd, vd->click_fd); | |
979 } | |
980 | |
400 | 981 return FALSE; |
397 | 982 } |
983 | |
401
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
984 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
|
985 { |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
986 ViewDir *vd = data; |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
987 gint ret = FALSE; |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
988 |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
989 switch(vd->type) |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
990 { |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
991 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
|
992 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
|
993 } |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
994 |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
995 return ret; |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
996 } |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
997 |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
998 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
|
999 { |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
1000 ViewDir *vd = data; |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
1001 gint ret = FALSE; |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
1002 |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
1003 switch(vd->type) |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
1004 { |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
1005 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
|
1006 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
|
1007 } |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
1008 |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
1009 return ret; |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
1010 } |