annotate src/view_dir.c @ 400:35346871af88

Fix a bug introduced in revision 489.
author zas_
date Thu, 17 Apr 2008 19:57:41 +0000
parents d071a3555011
children 0a2e1b130a25
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
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
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
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
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
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[] = {
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
29 { "FolderList", NULL, N_("List"), "<meta>L", NULL, DIRVIEW_LIST },
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
30 { "FolderTree", NULL, N_("Tr_ee"), "<control>T", NULL, DIRVIEW_TREE },
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
384
392dd6541d51 Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents: 383
diff changeset
33 void vd_destroy_cb(GtkWidget *widget, gpointer data)
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
392dd6541d51 Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents: 383
diff changeset
44 if (vd->widget_destroy_cb) vd->widget_destroy_cb(widget, data);
392dd6541d51 Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents: 383
diff changeset
45
392dd6541d51 Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents: 383
diff changeset
46 if (vd->pf) folder_icons_free(vd->pf);
392dd6541d51 Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents: 383
diff changeset
47 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
48
392dd6541d51 Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents: 383
diff changeset
49 if (vd->path) g_free(vd->path);
392dd6541d51 Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents: 383
diff changeset
50 if (vd->info) g_free(vd->info);
392dd6541d51 Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents: 383
diff changeset
51
392dd6541d51 Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents: 383
diff changeset
52 g_free(vd);
392dd6541d51 Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents: 383
diff changeset
53 }
392dd6541d51 Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents: 383
diff changeset
54
380
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
55 ViewDir *vd_new(DirViewType type, const gchar *path)
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
56 {
384
392dd6541d51 Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents: 383
diff changeset
57 ViewDir *vd = g_new0(ViewDir, 1);
392dd6541d51 Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents: 383
diff changeset
58
392dd6541d51 Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents: 383
diff changeset
59 vd->path = NULL;
392dd6541d51 Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents: 383
diff changeset
60 vd->click_fd = NULL;
392dd6541d51 Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents: 383
diff changeset
61
392dd6541d51 Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents: 383
diff changeset
62 vd->drop_fd = NULL;
392dd6541d51 Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents: 383
diff changeset
63 vd->drop_list = NULL;
392dd6541d51 Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents: 383
diff changeset
64 vd->drop_scroll_id = -1;
392dd6541d51 Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents: 383
diff changeset
65 vd->drop_list = NULL;
392dd6541d51 Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents: 383
diff changeset
66
392dd6541d51 Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents: 383
diff changeset
67 vd->popup = NULL;
392dd6541d51 Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents: 383
diff changeset
68
392dd6541d51 Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents: 383
diff changeset
69 vd->widget = gtk_scrolled_window_new(NULL, NULL);
392dd6541d51 Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents: 383
diff changeset
70 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
71 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
72 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
380
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
73
391
fcaf9c175742 Fix a crash introduced in revision 477.
zas_
parents: 389
diff changeset
74 vd->pf = folder_icons_new();
fcaf9c175742 Fix a crash introduced in revision 477.
zas_
parents: 389
diff changeset
75
380
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
76 switch(type)
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
77 {
384
392dd6541d51 Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents: 383
diff changeset
78 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
79 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
80 }
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
81
384
392dd6541d51 Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents: 383
diff changeset
82 g_signal_connect(G_OBJECT(vd->widget), "destroy",
392dd6541d51 Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents: 383
diff changeset
83 G_CALLBACK(vd_destroy_cb), vd);
392dd6541d51 Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents: 383
diff changeset
84
380
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
85 return vd;
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
86 }
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 void vd_set_select_func(ViewDir *vd,
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
89 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
90 {
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
91 vd->select_func = func;
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
92 vd->select_data = data;
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
93 }
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
94
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
95 void vd_set_layout(ViewDir *vd, LayoutWindow *layout)
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
96 {
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
97 vd->layout = layout;
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
98 }
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
99
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
100 gint vd_set_path(ViewDir *vd, const gchar *path)
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
101 {
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
102 gint ret = FALSE;
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
103
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
104 switch(vd->type)
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
105 {
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
106 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
107 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
108 }
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 return ret;
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
111 }
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
112
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
113 void vd_refresh(ViewDir *vd)
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
114 {
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
115 switch(vd->type)
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 case DIRVIEW_LIST: return vdlist_refresh(vd);
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
118 case DIRVIEW_TREE: return vdtree_refresh(vd);
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 }
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 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
123 {
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
124 const gchar *ret = NULL;
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
125
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
126 switch(vd->type)
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
127 {
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff changeset
128 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
129 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
130 }
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 return ret;
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
396
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
135 void vd_select_row(ViewDir *vd, FileData *fd)
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
136 {
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
137 switch(vd->type)
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
138 {
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
139 case DIRVIEW_LIST: vdlist_select_row(vd, fd); break;
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
140 case DIRVIEW_TREE: vdtree_select_row(vd, fd); break;
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
141 }
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
142 }
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
143
389
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
144 gint vd_find_row(ViewDir *vd, FileData *fd, GtkTreeIter *iter)
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
145 {
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
146 gint ret = FALSE;
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
147
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
148 switch(vd->type)
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
149 {
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
150 case DIRVIEW_LIST: ret = vdlist_find_row(vd, fd, iter); break;
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
151 case DIRVIEW_TREE: ret = vdtree_find_row(vd, fd, iter, NULL); break;
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
152 }
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
153
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
154 return ret;
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
155 }
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
156
399
d071a3555011 Reduce code redundancy with the introduction of a new
zas_
parents: 397
diff changeset
157 FileData *vd_get_fd_from_tree_path(ViewDir *vd, GtkTreeView *tview, GtkTreePath *tpath)
d071a3555011 Reduce code redundancy with the introduction of a new
zas_
parents: 397
diff changeset
158 {
d071a3555011 Reduce code redundancy with the introduction of a new
zas_
parents: 397
diff changeset
159 GtkTreeIter iter;
d071a3555011 Reduce code redundancy with the introduction of a new
zas_
parents: 397
diff changeset
160 FileData *fd = NULL;
d071a3555011 Reduce code redundancy with the introduction of a new
zas_
parents: 397
diff changeset
161 GtkTreeModel *store;
d071a3555011 Reduce code redundancy with the introduction of a new
zas_
parents: 397
diff changeset
162
d071a3555011 Reduce code redundancy with the introduction of a new
zas_
parents: 397
diff changeset
163 store = gtk_tree_view_get_model(tview);
d071a3555011 Reduce code redundancy with the introduction of a new
zas_
parents: 397
diff changeset
164 gtk_tree_model_get_iter(store, &iter, tpath);
d071a3555011 Reduce code redundancy with the introduction of a new
zas_
parents: 397
diff changeset
165 switch (vd->type)
d071a3555011 Reduce code redundancy with the introduction of a new
zas_
parents: 397
diff changeset
166 {
d071a3555011 Reduce code redundancy with the introduction of a new
zas_
parents: 397
diff changeset
167 case DIRVIEW_LIST:
d071a3555011 Reduce code redundancy with the introduction of a new
zas_
parents: 397
diff changeset
168 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &fd, -1);
d071a3555011 Reduce code redundancy with the introduction of a new
zas_
parents: 397
diff changeset
169 break;
d071a3555011 Reduce code redundancy with the introduction of a new
zas_
parents: 397
diff changeset
170 case DIRVIEW_TREE:
d071a3555011 Reduce code redundancy with the introduction of a new
zas_
parents: 397
diff changeset
171 {
d071a3555011 Reduce code redundancy with the introduction of a new
zas_
parents: 397
diff changeset
172 NodeData *nd;
d071a3555011 Reduce code redundancy with the introduction of a new
zas_
parents: 397
diff changeset
173 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
d071a3555011 Reduce code redundancy with the introduction of a new
zas_
parents: 397
diff changeset
174 fd = (nd) ? nd->fd : NULL;
d071a3555011 Reduce code redundancy with the introduction of a new
zas_
parents: 397
diff changeset
175 };
d071a3555011 Reduce code redundancy with the introduction of a new
zas_
parents: 397
diff changeset
176 break;
d071a3555011 Reduce code redundancy with the introduction of a new
zas_
parents: 397
diff changeset
177 }
d071a3555011 Reduce code redundancy with the introduction of a new
zas_
parents: 397
diff changeset
178
d071a3555011 Reduce code redundancy with the introduction of a new
zas_
parents: 397
diff changeset
179 return fd;
d071a3555011 Reduce code redundancy with the introduction of a new
zas_
parents: 397
diff changeset
180 }
d071a3555011 Reduce code redundancy with the introduction of a new
zas_
parents: 397
diff changeset
181
389
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
182 static gint vd_rename_cb(TreeEditData *td, const gchar *old, const gchar *new, gpointer data)
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
183 {
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
184 ViewDir *vd = data;
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
185 FileData *fd;
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
186 gchar *old_path;
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
187 gchar *new_path;
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
188 gchar *base;
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
189
399
d071a3555011 Reduce code redundancy with the introduction of a new
zas_
parents: 397
diff changeset
190 fd = vd_get_fd_from_tree_path(vd, GTK_TREE_VIEW(vd->view), td->path);
389
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
191 if (!fd) return FALSE;
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
192
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
193 old_path = g_strdup(fd->path);
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
194
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
195 base = remove_level_from_path(old_path);
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
196 new_path = concat_dir_and_file(base, new);
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
197 g_free(base);
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
198
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
199 if (file_util_rename_dir(fd, new_path, vd->view))
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
200 {
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
201
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
202 if (vd->type == DIRVIEW_TREE) vdtree_populate_path(vd, new_path, TRUE, TRUE);
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
203 if (vd->layout && strcmp(vd->path, old_path) == 0)
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
204 {
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
205 layout_set_path(vd->layout, new_path);
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
206 }
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
207 else
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
208 {
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
209 if (vd->type == DIRVIEW_LIST) vd_refresh(vd);
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
210 }
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
211 }
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
212
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
213 g_free(old_path);
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
214 g_free(new_path);
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
215
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
216 return FALSE;
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
217 }
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
218
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
219 static void vd_rename_by_data(ViewDir *vd, FileData *fd)
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
220 {
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
221 GtkTreeModel *store;
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
222 GtkTreePath *tpath;
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
223 GtkTreeIter iter;
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
224
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
225 if (!fd || vd_find_row(vd, fd, &iter) < 0) return;
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
226 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view));
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
227 tpath = gtk_tree_model_get_path(store, &iter);
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
228
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
229 tree_edit_by_path(GTK_TREE_VIEW(vd->view), tpath, 0, fd->name,
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
230 vd_rename_cb, vd);
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
231 gtk_tree_path_free(tpath);
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
232 }
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
233
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
234
383
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
235 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
236 {
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
237 GtkTreeModel *store;
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
238 GtkTreeIter iter;
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
239
389
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
240 if (vd_find_row(vd, fd, &iter) < 0) return;
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
241 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view));
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
242
383
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
243 switch(vd->type)
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
244 {
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
245 case DIRVIEW_LIST:
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
246 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
247 break;
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
248 case DIRVIEW_TREE:
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
249 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
250 break;
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
251 }
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
252 }
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
253
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
254 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
255 {
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
256 ViewDir *vd = data;
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
257
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
258 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
259 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
260 vd->popup = NULL;
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 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
263 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
264 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
265 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
266 }
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 /*
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 * 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
271 *-----------------------------------------------------------------------------
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
272 */
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
273
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
274 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
275 {
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
276 ViewDir *vd = data;
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
277 const gchar *path;
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
278 GList *list;
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
279
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
280 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
281
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
282 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
283 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
284 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
285
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
286 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
287 }
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
288
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
289 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
290 {
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
291 ViewDir *vd = data;
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
292 const gchar *path;
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
293 GList *list;
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 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
296
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
297 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
298 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
299
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
300 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
301
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
302 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
303 }
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 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
306 {
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
307 GtkWidget *menu;
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 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
310 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
311 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
312
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
313 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
314 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
315 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
316
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
317 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
318 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
319
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 380
diff changeset
320 return menu;
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
388
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
323 /*
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
324 *-----------------------------------------------------------------------------
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
325 * pop-up menu
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
326 *-----------------------------------------------------------------------------
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
327 */
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
328
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
329 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
330 {
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
331 ViewDir *vd = data;
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
332 gchar *path;
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
333
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
334 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
335 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
336
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
337 if (vd->select_func)
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
338 {
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
339 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
340 }
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
341
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
342 g_free(path);
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
343 }
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
344
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
345 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
346 {
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
347 ViewDir *vd = data;
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
348 gchar *path;
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 if (!vd->layout) return;
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
351 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
352
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
353 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
354
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
355 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
356 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
357 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
358 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
359 }
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
360
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
361 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
362 {
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
363 ViewDir *vd = data;
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
364 gchar *path;
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
365 GList *list;
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 if (!vd->layout) return;
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
368 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
369
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
370 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
371
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
372 list = filelist_recursive(path);
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
373
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
374 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
375 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
376 }
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 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
379 {
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
380 DupeWindow *dw;
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
381 GList *list = NULL;
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 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
384
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
385 if (recursive)
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
386 {
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
387 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
388 }
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
389 else
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
390 {
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
391 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
392 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
393 }
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 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
396 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
397
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
398 filelist_free(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_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
402 {
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
403 ViewDir *vd = data;
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
404 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
405 }
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
406
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
407 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
408 {
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
409 ViewDir *vd = data;
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
410 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
411 }
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
412
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
413 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
414 {
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
415 ViewDir *vd = data;
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 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
418 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
419 }
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 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
422 {
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
423 ViewDir *vd = data;
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
424 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
425
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
426 if (!vd->layout) return;
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 switch(vd->type)
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 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
431 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
432 }
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 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
435 }
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 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
438 {
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
439 ViewDir *vd = data;
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
440
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
441 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
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_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
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
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
448 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
449 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
450 }
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
451
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
452 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
453 {
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
454 ViewDir *vd = data;
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
455 const gchar *path = NULL;
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
456 gchar *new_path;
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
457 gchar *buf;
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 switch(vd->type)
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
460 {
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
461 case DIRVIEW_LIST:
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
462 {
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
463 if (!vd->path) return;
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
464 path = vd->path;
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 break;
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
467 case DIRVIEW_TREE:
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 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
470 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
471 };
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
472 break;
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 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
476 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
477 g_free(buf);
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
478 if (!new_path) return;
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
479
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
480 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
481 {
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
482 gchar *text;
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 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
485 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
486 g_free(text);
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 else
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
489 {
389
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
490 FileData *fd = NULL;
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
491
388
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
492 switch(vd->type)
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
493 {
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
494 case DIRVIEW_LIST:
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 vd_refresh(vd);
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
497 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
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 case DIRVIEW_TREE:
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
501 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
502 break;
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
503 }
389
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
504 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
505 }
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 g_free(new_path);
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
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
510 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
511 {
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
512 ViewDir *vd = data;
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
513
389
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
514 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
515 }
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 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
518 {
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
519 GtkWidget *menu;
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
520 gint active;
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
521 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
522 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
523
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
524 active = (fd != NULL);
392
5a73f2e1bf79 Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents: 391
diff changeset
525 switch(vd->type)
388
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
526 {
392
5a73f2e1bf79 Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents: 391
diff changeset
527 case DIRVIEW_LIST:
388
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
528 {
392
5a73f2e1bf79 Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents: 391
diff changeset
529 /* check using . (always row 0) */
5a73f2e1bf79 Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents: 391
diff changeset
530 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
531
392
5a73f2e1bf79 Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents: 391
diff changeset
532 /* ignore .. and . */
5a73f2e1bf79 Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents: 391
diff changeset
533 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
534 strcmp(fd->name, ".") != 0 &&
5a73f2e1bf79 Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents: 391
diff changeset
535 strcmp(fd->name, "..") != 0 &&
5a73f2e1bf79 Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents: 391
diff changeset
536 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
537 };
5a73f2e1bf79 Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents: 391
diff changeset
538 break;
5a73f2e1bf79 Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents: 391
diff changeset
539 case DIRVIEW_TREE:
5a73f2e1bf79 Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents: 391
diff changeset
540 {
5a73f2e1bf79 Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents: 391
diff changeset
541 if (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 gchar *parent;
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
544 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
545 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
546 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
547 g_free(parent);
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
548 };
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 break;
5a73f2e1bf79 Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents: 391
diff changeset
551 }
388
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
552
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
553 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
554 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
555 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
556
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
557 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
558 (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
559 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
560
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
561 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
562 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
563 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
564 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
565 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
566
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
567 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
568 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
569 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
570 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
571 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
572
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
573 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
574
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
575 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
576 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
577
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
578 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
579 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
580 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
581 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
582
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
583 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
584 /* FIXME */
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
585 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
586 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
587 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
588 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
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_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
591 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
592
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
593 return menu;
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
594 }
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
595
394
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
596 /*
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
597 *-----------------------------------------------------------------------------
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
598 * dnd
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
599 *-----------------------------------------------------------------------------
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
600 */
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
601
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
602 static GtkTargetEntry vd_dnd_drop_types[] = {
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
603 { "text/uri-list", 0, TARGET_URI_LIST }
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
604 };
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
605 static gint vd_dnd_drop_types_count = 1;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
606
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
607 static void vd_dest_set(ViewDir *vd, gint enable)
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
608 {
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
609 if (enable)
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
610 {
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
611 gtk_drag_dest_set(vd->view,
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
612 GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
613 vd_dnd_drop_types, vd_dnd_drop_types_count,
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
614 GDK_ACTION_MOVE | GDK_ACTION_COPY);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
615 }
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
616 else
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
617 {
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
618 gtk_drag_dest_unset(vd->view);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
619 }
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
620 }
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
621
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
622 static void vd_dnd_get(GtkWidget *widget, GdkDragContext *context,
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
623 GtkSelectionData *selection_data, guint info,
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
624 guint time, gpointer data)
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
625 {
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
626 ViewDir *vd = data;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
627 GList *list;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
628 gchar *uritext = NULL;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
629 gint length = 0;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
630
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
631 if (!vd->click_fd) return;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
632
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
633 switch (info)
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
634 {
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
635 case TARGET_URI_LIST:
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
636 case TARGET_TEXT_PLAIN:
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
637 list = g_list_prepend(NULL, vd->click_fd);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
638 uritext = uri_text_from_filelist(list, &length, (info == TARGET_TEXT_PLAIN));
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
639 g_list_free(list);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
640 break;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
641 }
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
642 if (uritext)
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
643 {
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
644 gtk_selection_data_set (selection_data, selection_data->target,
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
645 8, (guchar *)uritext, length);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
646 g_free(uritext);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
647 }
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
648 }
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
649
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
650 static void vd_dnd_begin(GtkWidget *widget, GdkDragContext *context, gpointer data)
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
651 {
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
652 ViewDir *vd = data;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
653
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
654 vd_color_set(vd, vd->click_fd, TRUE);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
655 vd_dest_set(vd, FALSE);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
656 }
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
657
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
658 static void vd_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer data)
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
659 {
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
660 ViewDir *vd = data;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
661
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
662 vd_color_set(vd, vd->click_fd, FALSE);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
663
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
664 if (vd->type == DIRVIEW_LIST && context->action == GDK_ACTION_MOVE)
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
665 {
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
666 vd_refresh(vd);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
667 }
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
668 vd_dest_set(vd, TRUE);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
669 }
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
670
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
671 static void vd_dnd_drop_receive(GtkWidget *widget,
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
672 GdkDragContext *context, gint x, gint y,
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
673 GtkSelectionData *selection_data, guint info,
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
674 guint time, gpointer data)
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
675 {
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
676 ViewDir *vd = data;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
677 GtkTreePath *tpath;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
678 FileData *fd = NULL;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
679
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
680 vd->click_fd = NULL;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
681
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
682 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), x, y,
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
683 &tpath, NULL, NULL, NULL))
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
684 {
399
d071a3555011 Reduce code redundancy with the introduction of a new
zas_
parents: 397
diff changeset
685 fd = vd_get_fd_from_tree_path(vd, GTK_TREE_VIEW(widget), tpath);
394
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
686 gtk_tree_path_free(tpath);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
687 }
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
688
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
689 if (!fd) return;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
690
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
691 if (info == TARGET_URI_LIST)
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
692 {
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
693 GList *list;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
694 gint active;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
695
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
696 list = uri_filelist_from_text((gchar *)selection_data->data, TRUE);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
697 if (!list) return;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
698
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
699 active = access_file(fd->path, W_OK | X_OK);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
700
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
701 vd_color_set(vd, fd, TRUE);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
702 vd->popup = vd_drop_menu(vd, active);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
703 gtk_menu_popup(GTK_MENU(vd->popup), NULL, NULL, NULL, NULL, 0, time);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
704
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
705 vd->drop_fd = fd;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
706 vd->drop_list = list;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
707 }
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
708 }
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
709
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
710 static void vd_drop_update(ViewDir *vd, gint x, gint y)
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
711 {
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
712 GtkTreePath *tpath;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
713 FileData *fd = NULL;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
714
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
715 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vd->view), x, y,
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
716 &tpath, NULL, NULL, NULL))
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
717 {
399
d071a3555011 Reduce code redundancy with the introduction of a new
zas_
parents: 397
diff changeset
718 fd = vd_get_fd_from_tree_path(vd, GTK_TREE_VIEW(vd->view), tpath);
394
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
719 gtk_tree_path_free(tpath);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
720 }
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
721
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
722 if (fd != vd->drop_fd)
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
723 {
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
724 vd_color_set(vd, vd->drop_fd, FALSE);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
725 vd_color_set(vd, fd, TRUE);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
726 if (vd->type == DIRVIEW_TREE && fd) vdtree_dnd_drop_expand(vd);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
727 }
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
728
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
729 vd->drop_fd = fd;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
730 }
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
731
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
732 void vd_dnd_drop_scroll_cancel(ViewDir *vd)
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
733 {
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
734 if (vd->drop_scroll_id != -1) g_source_remove(vd->drop_scroll_id);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
735 vd->drop_scroll_id = -1;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
736 }
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
737
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
738 static gint vd_auto_scroll_idle_cb(gpointer data)
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
739 {
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
740 ViewDir *vd = data;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
741
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
742 if (vd->drop_fd)
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
743 {
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
744 GdkWindow *window;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
745 gint x, y;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
746 gint w, h;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
747
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
748 window = vd->view->window;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
749 gdk_window_get_pointer(window, &x, &y, NULL);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
750 gdk_drawable_get_size(window, &w, &h);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
751 if (x >= 0 && x < w && y >= 0 && y < h)
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
752 {
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
753 vd_drop_update(vd, x, y);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
754 }
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
755 }
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
756
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
757 vd->drop_scroll_id = -1;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
758 return FALSE;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
759 }
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
760
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
761 static gint vd_auto_scroll_notify_cb(GtkWidget *widget, gint x, gint y, gpointer data)
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
762 {
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
763 ViewDir *vd = data;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
764
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
765 if (!vd->drop_fd || vd->drop_list) return FALSE;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
766
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
767 if (vd->drop_scroll_id == -1) vd->drop_scroll_id = g_idle_add(vd_auto_scroll_idle_cb, vd);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
768
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
769 return TRUE;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
770 }
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
771
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
772 static gint vd_dnd_drop_motion(GtkWidget *widget, GdkDragContext *context,
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
773 gint x, gint y, guint time, gpointer data)
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
774 {
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
775 ViewDir *vd = data;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
776
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
777 vd->click_fd = NULL;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
778
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
779 if (gtk_drag_get_source_widget(context) == vd->view)
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
780 {
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
781 /* from same window */
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
782 gdk_drag_status(context, 0, time);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
783 return TRUE;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
784 }
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
785 else
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
786 {
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
787 gdk_drag_status(context, context->suggested_action, time);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
788 }
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
789
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
790 vd_drop_update(vd, x, y);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
791
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
792 if (vd->drop_fd)
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
793 {
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
794 GtkAdjustment *adj = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(vd->view));
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
795 widget_auto_scroll_start(vd->view, adj, -1, -1, vd_auto_scroll_notify_cb, vd);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
796 }
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
797
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
798 return FALSE;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
799 }
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
800
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
801 static void vd_dnd_drop_leave(GtkWidget *widget, GdkDragContext *context, guint time, gpointer data)
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
802 {
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
803 ViewDir *vd = data;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
804
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
805 if (vd->drop_fd != vd->click_fd) vd_color_set(vd, vd->drop_fd, FALSE);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
806
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
807 vd->drop_fd = NULL;
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
808
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
809 if (vd->type == DIRVIEW_TREE) vdtree_dnd_drop_expand_cancel(vd);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
810 }
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
811
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
812 void vd_dnd_init(ViewDir *vd)
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
813 {
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
814 gtk_drag_source_set(vd->view, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
815 dnd_file_drag_types, dnd_file_drag_types_count,
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
816 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_ASK);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
817 g_signal_connect(G_OBJECT(vd->view), "drag_data_get",
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
818 G_CALLBACK(vd_dnd_get), vd);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
819 g_signal_connect(G_OBJECT(vd->view), "drag_begin",
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
820 G_CALLBACK(vd_dnd_begin), vd);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
821 g_signal_connect(G_OBJECT(vd->view), "drag_end",
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
822 G_CALLBACK(vd_dnd_end), vd);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
823
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
824 vd_dest_set(vd, TRUE);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
825 g_signal_connect(G_OBJECT(vd->view), "drag_data_received",
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
826 G_CALLBACK(vd_dnd_drop_receive), vd);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
827 g_signal_connect(G_OBJECT(vd->view), "drag_motion",
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
828 G_CALLBACK(vd_dnd_drop_motion), vd);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
829 g_signal_connect(G_OBJECT(vd->view), "drag_leave",
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
830 G_CALLBACK(vd_dnd_drop_leave), vd);
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
831 }
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 392
diff changeset
832
395
c359fc2c5a1f Move common menu position callback to view_dir.c.
zas_
parents: 394
diff changeset
833 /*
c359fc2c5a1f Move common menu position callback to view_dir.c.
zas_
parents: 394
diff changeset
834 *----------------------------------------------------------------------------
c359fc2c5a1f Move common menu position callback to view_dir.c.
zas_
parents: 394
diff changeset
835 * callbacks
c359fc2c5a1f Move common menu position callback to view_dir.c.
zas_
parents: 394
diff changeset
836 *----------------------------------------------------------------------------
c359fc2c5a1f Move common menu position callback to view_dir.c.
zas_
parents: 394
diff changeset
837 */
c359fc2c5a1f Move common menu position callback to view_dir.c.
zas_
parents: 394
diff changeset
838
c359fc2c5a1f Move common menu position callback to view_dir.c.
zas_
parents: 394
diff changeset
839 void vd_menu_position_cb(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer data)
c359fc2c5a1f Move common menu position callback to view_dir.c.
zas_
parents: 394
diff changeset
840 {
c359fc2c5a1f Move common menu position callback to view_dir.c.
zas_
parents: 394
diff changeset
841 ViewDir *vd = data;
c359fc2c5a1f Move common menu position callback to view_dir.c.
zas_
parents: 394
diff changeset
842 GtkTreeModel *store;
c359fc2c5a1f Move common menu position callback to view_dir.c.
zas_
parents: 394
diff changeset
843 GtkTreeIter iter;
c359fc2c5a1f Move common menu position callback to view_dir.c.
zas_
parents: 394
diff changeset
844 GtkTreePath *tpath;
c359fc2c5a1f Move common menu position callback to view_dir.c.
zas_
parents: 394
diff changeset
845 gint cw, ch;
c359fc2c5a1f Move common menu position callback to view_dir.c.
zas_
parents: 394
diff changeset
846
c359fc2c5a1f Move common menu position callback to view_dir.c.
zas_
parents: 394
diff changeset
847 if (vd_find_row(vd, vd->click_fd, &iter) < 0) return;
c359fc2c5a1f Move common menu position callback to view_dir.c.
zas_
parents: 394
diff changeset
848 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view));
c359fc2c5a1f Move common menu position callback to view_dir.c.
zas_
parents: 394
diff changeset
849 tpath = gtk_tree_model_get_path(store, &iter);
c359fc2c5a1f Move common menu position callback to view_dir.c.
zas_
parents: 394
diff changeset
850 tree_view_get_cell_clamped(GTK_TREE_VIEW(vd->view), tpath, 0, TRUE, x, y, &cw, &ch);
c359fc2c5a1f Move common menu position callback to view_dir.c.
zas_
parents: 394
diff changeset
851 gtk_tree_path_free(tpath);
c359fc2c5a1f Move common menu position callback to view_dir.c.
zas_
parents: 394
diff changeset
852 *y += ch;
c359fc2c5a1f Move common menu position callback to view_dir.c.
zas_
parents: 394
diff changeset
853 popup_menu_position_clamp(menu, x, y, 0);
c359fc2c5a1f Move common menu position callback to view_dir.c.
zas_
parents: 394
diff changeset
854 }
c359fc2c5a1f Move common menu position callback to view_dir.c.
zas_
parents: 394
diff changeset
855
396
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
856 void vd_activate_cb(GtkTreeView *tview, GtkTreePath *tpath, GtkTreeViewColumn *column, gpointer data)
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
857 {
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
858 ViewDir *vd = data;
399
d071a3555011 Reduce code redundancy with the introduction of a new
zas_
parents: 397
diff changeset
859 FileData *fd = vd_get_fd_from_tree_path(vd, tview, tpath);
396
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
860
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
861 vd_select_row(vd, fd);
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
862 }
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
863
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
864 static GdkColor *vd_color_shifted(GtkWidget *widget)
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
865 {
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
866 static GdkColor color;
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
867 static GtkWidget *done = NULL;
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
868
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
869 if (done != widget)
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
870 {
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
871 GtkStyle *style;
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
872
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
873 style = gtk_widget_get_style(widget);
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
874 memcpy(&color, &style->base[GTK_STATE_NORMAL], sizeof(color));
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
875 shift_color(&color, -1, 0);
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
876 done = widget;
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
877 }
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
878
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
879 return &color;
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
880 }
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
881
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
882 void vd_color_cb(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell,
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
883 GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data)
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
884 {
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
885 ViewDir *vd = data;
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
886 gboolean set;
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
887
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
888 gtk_tree_model_get(tree_model, iter, DIR_COLUMN_COLOR, &set, -1);
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
889 g_object_set(G_OBJECT(cell),
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
890 "cell-background-gdk", vd_color_shifted(vd->view),
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
891 "cell-background-set", set, NULL);
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
892 }
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
893
397
a7be56e84870 Merge vd(list|tree)_release_cb() in vd_release_cb().
zas_
parents: 396
diff changeset
894 gint vd_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
a7be56e84870 Merge vd(list|tree)_release_cb() in vd_release_cb().
zas_
parents: 396
diff changeset
895 {
a7be56e84870 Merge vd(list|tree)_release_cb() in vd_release_cb().
zas_
parents: 396
diff changeset
896 ViewDir *vd = data;
a7be56e84870 Merge vd(list|tree)_release_cb() in vd_release_cb().
zas_
parents: 396
diff changeset
897 GtkTreePath *tpath;
a7be56e84870 Merge vd(list|tree)_release_cb() in vd_release_cb().
zas_
parents: 396
diff changeset
898 FileData *fd = NULL;
a7be56e84870 Merge vd(list|tree)_release_cb() in vd_release_cb().
zas_
parents: 396
diff changeset
899
400
35346871af88 Fix a bug introduced in revision 489.
zas_
parents: 399
diff changeset
900 if (!vd->click_fd) return FALSE;
397
a7be56e84870 Merge vd(list|tree)_release_cb() in vd_release_cb().
zas_
parents: 396
diff changeset
901 vd_color_set(vd, vd->click_fd, FALSE);
a7be56e84870 Merge vd(list|tree)_release_cb() in vd_release_cb().
zas_
parents: 396
diff changeset
902
a7be56e84870 Merge vd(list|tree)_release_cb() in vd_release_cb().
zas_
parents: 396
diff changeset
903 if (bevent->button != 1) return TRUE;
a7be56e84870 Merge vd(list|tree)_release_cb() in vd_release_cb().
zas_
parents: 396
diff changeset
904
a7be56e84870 Merge vd(list|tree)_release_cb() in vd_release_cb().
zas_
parents: 396
diff changeset
905 if ((bevent->x != 0 || bevent->y != 0) &&
a7be56e84870 Merge vd(list|tree)_release_cb() in vd_release_cb().
zas_
parents: 396
diff changeset
906 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), bevent->x, bevent->y,
a7be56e84870 Merge vd(list|tree)_release_cb() in vd_release_cb().
zas_
parents: 396
diff changeset
907 &tpath, NULL, NULL, NULL))
a7be56e84870 Merge vd(list|tree)_release_cb() in vd_release_cb().
zas_
parents: 396
diff changeset
908 {
399
d071a3555011 Reduce code redundancy with the introduction of a new
zas_
parents: 397
diff changeset
909 fd = vd_get_fd_from_tree_path(vd, GTK_TREE_VIEW(widget), tpath);
397
a7be56e84870 Merge vd(list|tree)_release_cb() in vd_release_cb().
zas_
parents: 396
diff changeset
910 gtk_tree_path_free(tpath);
a7be56e84870 Merge vd(list|tree)_release_cb() in vd_release_cb().
zas_
parents: 396
diff changeset
911 }
a7be56e84870 Merge vd(list|tree)_release_cb() in vd_release_cb().
zas_
parents: 396
diff changeset
912
a7be56e84870 Merge vd(list|tree)_release_cb() in vd_release_cb().
zas_
parents: 396
diff changeset
913 if (fd && vd->click_fd == fd)
a7be56e84870 Merge vd(list|tree)_release_cb() in vd_release_cb().
zas_
parents: 396
diff changeset
914 {
a7be56e84870 Merge vd(list|tree)_release_cb() in vd_release_cb().
zas_
parents: 396
diff changeset
915 vdlist_select_row(vd, vd->click_fd);
a7be56e84870 Merge vd(list|tree)_release_cb() in vd_release_cb().
zas_
parents: 396
diff changeset
916 }
a7be56e84870 Merge vd(list|tree)_release_cb() in vd_release_cb().
zas_
parents: 396
diff changeset
917
400
35346871af88 Fix a bug introduced in revision 489.
zas_
parents: 399
diff changeset
918 return FALSE;
397
a7be56e84870 Merge vd(list|tree)_release_cb() in vd_release_cb().
zas_
parents: 396
diff changeset
919 }
a7be56e84870 Merge vd(list|tree)_release_cb() in vd_release_cb().
zas_
parents: 396
diff changeset
920