Mercurial > geeqie
annotate src/view_dir.c @ 1701:2309e6150e8c
do not try to reload deleted image
deleted image is replaced by the next one from the list, keep
the old image displayed until the new one is set
author | nadvornik |
---|---|
date | Fri, 24 Jul 2009 12:56:54 +0000 |
parents | 8ebc26a4383f |
children | 67145eade000 |
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 |
1284 | 3 * Copyright (C) 2008 - 2009 The Geeqie Team |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
4 * |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
5 * Author: Laurent Monin |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
6 * |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
7 * This software is released under the GNU General Public License (GNU GPL). |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
8 * Please read the included file COPYING for more information. |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
9 * This software comes with no warranty of any kind, use at your own risk! |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
10 */ |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
11 |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
12 #include "main.h" |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
13 #include "view_dir.h" |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
14 |
394 | 15 #include "dnd.h" |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
16 #include "dupe.h" |
902 | 17 #include "editors.h" |
586 | 18 #include "filedata.h" |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
19 #include "layout_image.h" |
384
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
20 #include "layout_util.h" |
1612
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
21 #include "pixbuf_util.h" |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
22 #include "ui_fileops.h" |
389 | 23 #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
|
24 #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
|
25 #include "utilops.h" |
904
1698baa37871
Move uri_*() functions to separate files: uri_utils.[ch]
zas_
parents:
902
diff
changeset
|
26 #include "uri_utils.h" |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
27 #include "view_dir_list.h" |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
28 #include "view_dir_tree.h" |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
29 |
1612
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
30 /* Folders icons to be used in tree or list directory view */ |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
31 static PixmapFolders *folder_icons_new(GtkWidget *widget) |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
32 { |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
33 PixmapFolders *pf = g_new0(PixmapFolders, 1); |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
34 |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
35 #if 1 |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
36 GtkIconSize size = GTK_ICON_SIZE_MENU; |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
37 |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
38 /* Attempt to use stock gtk icons */ |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
39 pf->close = gtk_widget_render_icon(widget, GTK_STOCK_DIRECTORY, size, NULL); |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
40 pf->open = gtk_widget_render_icon(widget, GTK_STOCK_OPEN, size, NULL); |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
41 pf->deny = gtk_widget_render_icon(widget, GTK_STOCK_STOP, size, NULL); |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
42 pf->parent = gtk_widget_render_icon(widget, GTK_STOCK_GO_UP, size, NULL); |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
43 #else |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
44 /* GQView legacy icons */ |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
45 pf->close = pixbuf_inline(PIXBUF_INLINE_FOLDER_CLOSED); |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
46 pf->open = pixbuf_inline(PIXBUF_INLINE_FOLDER_OPEN); |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
47 pf->deny = pixbuf_inline(PIXBUF_INLINE_FOLDER_LOCKED); |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
48 pf->parent = pixbuf_inline(PIXBUF_INLINE_FOLDER_UP); |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
49 #endif |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
50 return pf; |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
51 } |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
52 |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
53 static void folder_icons_free(PixmapFolders *pf) |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
54 { |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
55 if (!pf) return; |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
56 |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
57 g_object_unref(pf->close); |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
58 g_object_unref(pf->open); |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
59 g_object_unref(pf->deny); |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
60 g_object_unref(pf->parent); |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
61 |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
62 g_free(pf); |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
63 } |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
64 |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
65 |
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
66 |
907 | 67 static void vd_notify_cb(FileData *fd, NotifyType type, gpointer data); |
68 | |
401
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
69 static void vd_destroy_cb(GtkWidget *widget, gpointer data) |
384
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
70 { |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
71 ViewDir *vd = data; |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
72 |
907 | 73 file_data_unregister_notify_func(vd_notify_cb, vd); |
74 | |
384
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
75 if (vd->popup) |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
76 { |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
77 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
|
78 0, 0, 0, NULL, vd); |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
79 gtk_widget_destroy(vd->popup); |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
80 } |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
81 |
1347
79937bc55f3a
Add missing space between switch and first parenthesis.
zas_
parents:
1284
diff
changeset
|
82 switch (vd->type) |
401
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
83 { |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
84 case DIRVIEW_LIST: vdlist_destroy_cb(widget, data); break; |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
85 case DIRVIEW_TREE: vdtree_destroy_cb(widget, data); break; |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
86 } |
442 | 87 |
384
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
88 if (vd->pf) folder_icons_free(vd->pf); |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
89 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
|
90 |
783 | 91 if (vd->dir_fd) file_data_unref(vd->dir_fd); |
384
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
92 if (vd->info) g_free(vd->info); |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
93 |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
94 g_free(vd); |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
95 } |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
96 |
783 | 97 ViewDir *vd_new(DirViewType type, FileData *dir_fd) |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
98 { |
384
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
99 ViewDir *vd = g_new0(ViewDir, 1); |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
100 |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
101 vd->widget = gtk_scrolled_window_new(NULL, NULL); |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
102 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
|
103 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
|
104 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
105 |
1612
5d54bc073bfa
Attempt to use stock gtk icons for directory list and tree views.
zas_
parents:
1553
diff
changeset
|
106 vd->pf = folder_icons_new(vd->widget); |
391 | 107 |
1347
79937bc55f3a
Add missing space between switch and first parenthesis.
zas_
parents:
1284
diff
changeset
|
108 switch (type) |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
109 { |
783 | 110 case DIRVIEW_LIST: vd = vdlist_new(vd, dir_fd); break; |
111 case DIRVIEW_TREE: vd = vdtree_new(vd, dir_fd); break; | |
380
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 |
405 | 114 gtk_container_add(GTK_CONTAINER(vd->widget), vd->view); |
442 | 115 |
405 | 116 vd_dnd_init(vd); |
117 | |
118 g_signal_connect(G_OBJECT(vd->view), "row_activated", | |
119 G_CALLBACK(vd_activate_cb), vd); | |
384
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
120 g_signal_connect(G_OBJECT(vd->widget), "destroy", |
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
121 G_CALLBACK(vd_destroy_cb), vd); |
405 | 122 g_signal_connect(G_OBJECT(vd->view), "key_press_event", |
123 G_CALLBACK(vd_press_key_cb), vd); | |
124 g_signal_connect(G_OBJECT(vd->view), "button_press_event", | |
125 G_CALLBACK(vd_press_cb), vd); | |
126 g_signal_connect(G_OBJECT(vd->view), "button_release_event", | |
127 G_CALLBACK(vd_release_cb), vd); | |
128 | |
783 | 129 if (dir_fd) vd_set_fd(vd, dir_fd); |
405 | 130 |
907 | 131 file_data_register_notify_func(vd_notify_cb, vd, NOTIFY_PRIORITY_HIGH); |
132 | |
405 | 133 gtk_widget_show(vd->view); |
384
392dd6541d51
Merge parts of view_dir_list/tree constructors/destructors to
zas_
parents:
383
diff
changeset
|
134 |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
135 return vd; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
136 } |
442 | 137 |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
138 void vd_set_select_func(ViewDir *vd, |
1628 | 139 void (*func)(ViewDir *vd, FileData *fd, gpointer data), gpointer data) |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
140 { |
442 | 141 vd->select_func = func; |
142 vd->select_data = data; | |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
143 } |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
144 |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
145 void vd_set_layout(ViewDir *vd, LayoutWindow *layout) |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
146 { |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
147 vd->layout = layout; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
148 } |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
149 |
1452 | 150 gboolean vd_set_fd(ViewDir *vd, FileData *dir_fd) |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
151 { |
1437 | 152 gboolean ret = FALSE; |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
153 |
1230 | 154 file_data_unregister_notify_func(vd_notify_cb, vd); |
155 | |
1347
79937bc55f3a
Add missing space between switch and first parenthesis.
zas_
parents:
1284
diff
changeset
|
156 switch (vd->type) |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
157 { |
783 | 158 case DIRVIEW_LIST: ret = vdlist_set_fd(vd, dir_fd); break; |
159 case DIRVIEW_TREE: ret = vdtree_set_fd(vd, dir_fd); break; | |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
160 } |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
161 |
1230 | 162 file_data_register_notify_func(vd_notify_cb, vd, NOTIFY_PRIORITY_HIGH); |
163 | |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
164 return ret; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
165 } |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
166 |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
167 void vd_refresh(ViewDir *vd) |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
168 { |
1347
79937bc55f3a
Add missing space between switch and first parenthesis.
zas_
parents:
1284
diff
changeset
|
169 switch (vd->type) |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
170 { |
982 | 171 case DIRVIEW_LIST: vdlist_refresh(vd); break; |
172 case DIRVIEW_TREE: vdtree_refresh(vd); break; | |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
173 } |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
174 } |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
175 |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
176 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
|
177 { |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
178 const gchar *ret = NULL; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
179 |
1347
79937bc55f3a
Add missing space between switch and first parenthesis.
zas_
parents:
1284
diff
changeset
|
180 switch (vd->type) |
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
181 { |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
182 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
|
183 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
|
184 } |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
185 |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
186 return ret; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
187 } |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
188 |
1628 | 189 /* the calling stack is this: |
190 vd_select_row -> select_func -> layout_set_fd -> vd_set_fd | |
191 */ | |
396 | 192 void vd_select_row(ViewDir *vd, FileData *fd) |
193 { | |
1628 | 194 if (fd && vd->select_func) |
195 { | |
196 vd->select_func(vd, fd, vd->select_data); | |
197 } | |
396 | 198 } |
199 | |
1452 | 200 gboolean vd_find_row(ViewDir *vd, FileData *fd, GtkTreeIter *iter) |
389 | 201 { |
1437 | 202 gboolean ret = FALSE; |
389 | 203 |
1347
79937bc55f3a
Add missing space between switch and first parenthesis.
zas_
parents:
1284
diff
changeset
|
204 switch (vd->type) |
389 | 205 { |
206 case DIRVIEW_LIST: ret = vdlist_find_row(vd, fd, iter); break; | |
207 case DIRVIEW_TREE: ret = vdtree_find_row(vd, fd, iter, NULL); break; | |
208 } | |
209 | |
210 return ret; | |
211 } | |
212 | |
399 | 213 FileData *vd_get_fd_from_tree_path(ViewDir *vd, GtkTreeView *tview, GtkTreePath *tpath) |
214 { | |
215 GtkTreeIter iter; | |
216 FileData *fd = NULL; | |
217 GtkTreeModel *store; | |
218 | |
219 store = gtk_tree_view_get_model(tview); | |
220 gtk_tree_model_get_iter(store, &iter, tpath); | |
221 switch (vd->type) | |
222 { | |
223 case DIRVIEW_LIST: | |
224 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &fd, -1); | |
225 break; | |
226 case DIRVIEW_TREE: | |
227 { | |
228 NodeData *nd; | |
229 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1); | |
230 fd = (nd) ? nd->fd : NULL; | |
231 }; | |
232 break; | |
233 } | |
234 | |
235 return fd; | |
236 } | |
237 | |
1637 | 238 static void vd_rename_finished_cb(gboolean success, const gchar *new_path, gpointer data) |
239 { | |
240 ViewDir *vd = data; | |
241 if (success) | |
242 { | |
243 FileData *fd = file_data_new_simple(new_path); | |
244 GtkTreeIter iter; | |
245 | |
246 if (vd_find_row(vd, fd, &iter)) | |
247 { | |
248 tree_view_row_make_visible(GTK_TREE_VIEW(vd->view), &iter, TRUE); | |
249 } | |
250 | |
251 file_data_unref(fd); | |
252 } | |
253 } | |
254 | |
1452 | 255 static gboolean vd_rename_cb(TreeEditData *td, const gchar *old, const gchar *new, gpointer data) |
389 | 256 { |
257 ViewDir *vd = data; | |
258 FileData *fd; | |
259 gchar *new_path; | |
260 gchar *base; | |
261 | |
399 | 262 fd = vd_get_fd_from_tree_path(vd, GTK_TREE_VIEW(vd->view), td->path); |
389 | 263 if (!fd) return FALSE; |
264 | |
818 | 265 base = remove_level_from_path(fd->path); |
702
e07895754e65
Drop concat_dir_and_file() and use g_build_filename() instead.
zas_
parents:
586
diff
changeset
|
266 new_path = g_build_filename(base, new, NULL); |
389 | 267 g_free(base); |
268 | |
1637 | 269 file_util_rename_dir(fd, new_path, vd->view, vd_rename_finished_cb, vd); |
907 | 270 |
389 | 271 g_free(new_path); |
272 | |
273 return FALSE; | |
274 } | |
275 | |
276 static void vd_rename_by_data(ViewDir *vd, FileData *fd) | |
277 { | |
278 GtkTreeModel *store; | |
279 GtkTreePath *tpath; | |
280 GtkTreeIter iter; | |
281 | |
1553 | 282 if (!fd || !vd_find_row(vd, fd, &iter)) return; |
389 | 283 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view)); |
284 tpath = gtk_tree_model_get_path(store, &iter); | |
285 | |
286 tree_edit_by_path(GTK_TREE_VIEW(vd->view), tpath, 0, fd->name, | |
287 vd_rename_cb, vd); | |
288 gtk_tree_path_free(tpath); | |
289 } | |
290 | |
291 | |
383
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
292 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
|
293 { |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
294 GtkTreeModel *store; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
295 GtkTreeIter iter; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
296 |
1553 | 297 if (!vd_find_row(vd, fd, &iter)) return; |
389 | 298 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view)); |
299 | |
1347
79937bc55f3a
Add missing space between switch and first parenthesis.
zas_
parents:
1284
diff
changeset
|
300 switch (vd->type) |
383
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 case DIRVIEW_LIST: |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
303 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
|
304 break; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
305 case DIRVIEW_TREE: |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
306 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
|
307 break; |
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 } |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
310 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
311 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
|
312 { |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
313 ViewDir *vd = data; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
314 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
315 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
|
316 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
|
317 vd->popup = NULL; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
318 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
319 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
|
320 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
|
321 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
|
322 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
|
323 } |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
324 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
325 /* |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
326 *----------------------------------------------------------------------------- |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
327 * 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
|
328 *----------------------------------------------------------------------------- |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
329 */ |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
330 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
331 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
|
332 { |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
333 ViewDir *vd = data; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
334 const gchar *path; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
335 GList *list; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
336 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
337 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
|
338 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
339 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
|
340 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
|
341 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
|
342 |
753 | 343 file_util_copy_simple(list, path, vd->widget); |
383
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
344 } |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
345 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
346 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
|
347 { |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
348 ViewDir *vd = data; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
349 const gchar *path; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
350 GList *list; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
351 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
352 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
|
353 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
354 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
|
355 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
|
356 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
357 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
|
358 |
753 | 359 file_util_move_simple(list, path, vd->widget); |
383
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
360 } |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
361 |
753 | 362 static void vd_drop_menu_filter_cb(GtkWidget *widget, gpointer data) |
363 { | |
364 ViewDir *vd = data; | |
365 const gchar *path; | |
366 GList *list; | |
1272 | 367 const gchar *key; |
368 | |
753 | 369 if (!vd->drop_fd) return; |
370 | |
1272 | 371 key = g_object_get_data(G_OBJECT(widget), "filter_key"); |
753 | 372 |
373 path = vd->drop_fd->path; | |
374 list = vd->drop_list; | |
375 | |
376 vd->drop_list = NULL; | |
377 | |
1272 | 378 file_util_start_filter_from_filelist(key, list, path, vd->widget); |
753 | 379 } |
380 | |
1413
3bc4967aaa57
Use dynamic allocation for editor key passed to various callbacks.
zas_
parents:
1412
diff
changeset
|
381 static void vd_drop_menu_edit_item_free(gpointer data) |
3bc4967aaa57
Use dynamic allocation for editor key passed to various callbacks.
zas_
parents:
1412
diff
changeset
|
382 { |
3bc4967aaa57
Use dynamic allocation for editor key passed to various callbacks.
zas_
parents:
1412
diff
changeset
|
383 g_free(data); |
3bc4967aaa57
Use dynamic allocation for editor key passed to various callbacks.
zas_
parents:
1412
diff
changeset
|
384 } |
753 | 385 |
383
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
386 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
|
387 { |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
388 GtkWidget *menu; |
1272 | 389 GList *editors_list = editor_list_get(); |
390 GList *work = editors_list; | |
383
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
391 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
392 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
|
393 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
|
394 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
|
395 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
396 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
|
397 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
|
398 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
|
399 |
1272 | 400 while (work) |
753 | 401 { |
402 GtkWidget *item; | |
1272 | 403 const EditorDescription *editor = work->data; |
1413
3bc4967aaa57
Use dynamic allocation for editor key passed to various callbacks.
zas_
parents:
1412
diff
changeset
|
404 gchar *key; |
1272 | 405 work = work->next; |
406 | |
407 if (!editor_is_filter(editor->key)) continue; | |
1413
3bc4967aaa57
Use dynamic allocation for editor key passed to various callbacks.
zas_
parents:
1412
diff
changeset
|
408 key = g_strdup(editor->key); |
1272 | 409 item = menu_item_add_sensitive(menu, editor->name, active, G_CALLBACK(vd_drop_menu_filter_cb), vd); |
1413
3bc4967aaa57
Use dynamic allocation for editor key passed to various callbacks.
zas_
parents:
1412
diff
changeset
|
410 g_object_set_data_full(G_OBJECT(item), "filter_key", key, vd_drop_menu_edit_item_free); |
753 | 411 } |
1272 | 412 |
413 g_list_free(editors_list); | |
753 | 414 |
383
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
415 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
|
416 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
|
417 |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
418 return menu; |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
419 } |
499d7ba62261
Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents:
380
diff
changeset
|
420 |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
421 /* |
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 * pop-up menu |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
424 *----------------------------------------------------------------------------- |
442 | 425 */ |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
426 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
427 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
|
428 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
429 ViewDir *vd = data; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
430 gchar *path; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
431 |
783 | 432 if (!vd->dir_fd || strcmp(vd->dir_fd->path, G_DIR_SEPARATOR_S) == 0) return; |
433 path = remove_level_from_path(vd->dir_fd->path); | |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
434 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
435 if (vd->select_func) |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
436 { |
1628 | 437 FileData *fd = file_data_new_simple(path); |
438 vd->select_func(vd, fd, vd->select_data); | |
439 file_data_unref(fd); | |
388
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 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
442 g_free(path); |
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 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
445 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
|
446 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
447 ViewDir *vd = data; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
448 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
449 if (!vd->layout) return; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
450 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
|
451 |
783 | 452 layout_set_fd(vd->layout, vd->click_fd); |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
453 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
|
454 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
|
455 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
|
456 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
457 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
458 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
|
459 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
460 ViewDir *vd = data; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
461 GList *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->layout) return; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
464 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
|
465 |
783 | 466 list = filelist_recursive(vd->click_fd); |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
467 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
468 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
|
469 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
|
470 } |
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 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
|
473 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
474 DupeWindow *dw; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
475 GList *list = NULL; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
476 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
477 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
|
478 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
479 if (recursive) |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
480 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
481 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
|
482 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
483 else |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
484 { |
783 | 485 filelist_read(vd->click_fd, &list, NULL); |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
486 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
|
487 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
488 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
489 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
|
490 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
|
491 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
492 filelist_free(list); |
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 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
495 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
|
496 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
497 ViewDir *vd = data; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
498 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
|
499 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
500 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
501 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
|
502 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
503 ViewDir *vd = data; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
504 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
|
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 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
|
508 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
509 ViewDir *vd = data; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
510 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
511 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
|
512 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
|
513 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
514 |
522
fd4208f8b5f3
Allow to copy the path of a directory to clipboard from directory views.
zas_
parents:
512
diff
changeset
|
515 static void vd_pop_menu_copy_path_cb(GtkWidget *widget, gpointer data) |
fd4208f8b5f3
Allow to copy the path of a directory to clipboard from directory views.
zas_
parents:
512
diff
changeset
|
516 { |
fd4208f8b5f3
Allow to copy the path of a directory to clipboard from directory views.
zas_
parents:
512
diff
changeset
|
517 ViewDir *vd = data; |
fd4208f8b5f3
Allow to copy the path of a directory to clipboard from directory views.
zas_
parents:
512
diff
changeset
|
518 |
fd4208f8b5f3
Allow to copy the path of a directory to clipboard from directory views.
zas_
parents:
512
diff
changeset
|
519 if (!vd->click_fd) return; |
fd4208f8b5f3
Allow to copy the path of a directory to clipboard from directory views.
zas_
parents:
512
diff
changeset
|
520 |
fd4208f8b5f3
Allow to copy the path of a directory to clipboard from directory views.
zas_
parents:
512
diff
changeset
|
521 file_util_copy_path_to_clipboard(vd->click_fd); |
fd4208f8b5f3
Allow to copy the path of a directory to clipboard from directory views.
zas_
parents:
512
diff
changeset
|
522 } |
fd4208f8b5f3
Allow to copy the path of a directory to clipboard from directory views.
zas_
parents:
512
diff
changeset
|
523 |
417
440979320308
Fix directory view popup menu to display a View As submenu
zas_
parents:
407
diff
changeset
|
524 static void vd_pop_submenu_dir_view_as_cb(GtkWidget *widget, gpointer data) |
440979320308
Fix directory view popup menu to display a View As submenu
zas_
parents:
407
diff
changeset
|
525 { |
440979320308
Fix directory view popup menu to display a View As submenu
zas_
parents:
407
diff
changeset
|
526 ViewDir *vd = data; |
419 | 527 |
1668
8ebc26a4383f
use radio buttons for file and dir mode in popup menu
nadvornik
parents:
1666
diff
changeset
|
528 DirViewType new_type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "menu_item_radio_data")); |
1412 | 529 layout_views_set(vd->layout, new_type, vd->layout->options.file_view_type); |
417
440979320308
Fix directory view popup menu to display a View As submenu
zas_
parents:
407
diff
changeset
|
530 } |
440979320308
Fix directory view popup menu to display a View As submenu
zas_
parents:
407
diff
changeset
|
531 |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
532 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
|
533 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
534 ViewDir *vd = data; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
535 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
536 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
|
537 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
538 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
539 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
|
540 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
541 ViewDir *vd = data; |
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 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
|
544 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
|
545 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
546 |
1231 | 547 static void vd_pop_menu_new_rename_cb(gboolean success, const gchar *new_path, gpointer data) |
548 { | |
549 ViewDir *vd = data; | |
550 FileData *fd = NULL; | |
551 if (!success) return; | |
552 | |
1347
79937bc55f3a
Add missing space between switch and first parenthesis.
zas_
parents:
1284
diff
changeset
|
553 switch (vd->type) |
1231 | 554 { |
555 case DIRVIEW_LIST: | |
556 { | |
557 vd_refresh(vd); | |
558 fd = vdlist_row_by_path(vd, new_path, NULL); | |
559 }; | |
560 break; | |
561 case DIRVIEW_TREE: | |
562 { | |
563 FileData *new_fd = file_data_new_simple(new_path); | |
564 fd = vdtree_populate_path(vd, new_fd, TRUE, TRUE); | |
565 file_data_unref(new_fd); | |
566 } | |
567 break; | |
568 } | |
569 vd_rename_by_data(vd, fd); | |
570 } | |
571 | |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
572 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
|
573 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
574 ViewDir *vd = data; |
907 | 575 FileData *dir_fd = NULL; |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
576 |
1347
79937bc55f3a
Add missing space between switch and first parenthesis.
zas_
parents:
1284
diff
changeset
|
577 switch (vd->type) |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
578 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
579 case DIRVIEW_LIST: |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
580 { |
783 | 581 if (!vd->dir_fd) return; |
907 | 582 dir_fd = vd->dir_fd; |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
583 }; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
584 break; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
585 case DIRVIEW_TREE: |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
586 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
587 if (!vd->click_fd) return; |
907 | 588 dir_fd = vd->click_fd; |
388
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 break; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
591 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
592 |
1231 | 593 file_util_create_dir(dir_fd, widget, vd_pop_menu_new_rename_cb, vd); |
388
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 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
596 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
|
597 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
598 ViewDir *vd = data; |
442 | 599 |
389 | 600 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
|
601 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
602 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
603 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
|
604 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
605 GtkWidget *menu; |
417
440979320308
Fix directory view popup menu to display a View As submenu
zas_
parents:
407
diff
changeset
|
606 GtkWidget *item; |
1452 | 607 gboolean active; |
1437 | 608 gboolean rename_delete_active = FALSE; |
609 gboolean new_folder_active = FALSE; | |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
610 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
611 active = (fd != NULL); |
1347
79937bc55f3a
Add missing space between switch and first parenthesis.
zas_
parents:
1284
diff
changeset
|
612 switch (vd->type) |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
613 { |
392
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
614 case DIRVIEW_LIST: |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
615 { |
392
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
616 /* check using . (always row 0) */ |
783 | 617 new_folder_active = (vd->dir_fd && access_file(vd->dir_fd->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
|
618 |
392
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
619 /* ignore .. and . */ |
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
620 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
|
621 strcmp(fd->name, ".") != 0 && |
442 | 622 strcmp(fd->name, "..") != 0 && |
623 access_file(fd->path, W_OK | X_OK)); | |
392
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
624 }; |
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
625 break; |
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
626 case DIRVIEW_TREE: |
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
627 { |
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
628 if (fd) |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
629 { |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
630 gchar *parent; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
631 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
|
632 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
|
633 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
|
634 g_free(parent); |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
635 }; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
636 } |
392
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
637 break; |
5a73f2e1bf79
Fix new folder feature in dirlist mode, it was broken by revision 481.
zas_
parents:
391
diff
changeset
|
638 } |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
639 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
640 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
|
641 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
|
642 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
|
643 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
644 menu_item_add_stock_sensitive(menu, _("_Up to parent"), GTK_STOCK_GO_UP, |
783 | 645 (vd->dir_fd && strcmp(vd->dir_fd->path, G_DIR_SEPARATOR_S) != 0), |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
646 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
|
647 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
648 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
|
649 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
|
650 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
|
651 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
|
652 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
|
653 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
654 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
|
655 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
|
656 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
|
657 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
|
658 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
|
659 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
660 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
|
661 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
662 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
|
663 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
|
664 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
665 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
|
666 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
|
667 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
|
668 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
|
669 |
1513 | 670 menu_item_add(menu, _("_Copy path"), |
671 G_CALLBACK(vd_pop_menu_copy_path_cb), vd); | |
522
fd4208f8b5f3
Allow to copy the path of a directory to clipboard from directory views.
zas_
parents:
512
diff
changeset
|
672 |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
673 menu_item_add_divider(menu); |
442 | 674 |
1666 | 675 |
1668
8ebc26a4383f
use radio buttons for file and dir mode in popup menu
nadvornik
parents:
1666
diff
changeset
|
676 item = menu_item_add_radio(menu, _("View as _List"), GINT_TO_POINTER(DIRVIEW_LIST), vd->type == DIRVIEW_LIST, |
1666 | 677 G_CALLBACK(vd_pop_submenu_dir_view_as_cb), vd); |
417
440979320308
Fix directory view popup menu to display a View As submenu
zas_
parents:
407
diff
changeset
|
678 |
1668
8ebc26a4383f
use radio buttons for file and dir mode in popup menu
nadvornik
parents:
1666
diff
changeset
|
679 item = menu_item_add_radio(menu, _("View as _Tree"), GINT_TO_POINTER(DIRVIEW_TREE), vd->type == DIRVIEW_TREE, |
1666 | 680 G_CALLBACK(vd_pop_submenu_dir_view_as_cb), vd); |
681 | |
682 menu_item_add_divider(menu); | |
417
440979320308
Fix directory view popup menu to display a View As submenu
zas_
parents:
407
diff
changeset
|
683 |
388
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
684 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
|
685 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
|
686 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
687 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
|
688 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
|
689 |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
690 return menu; |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
691 } |
5186f8e38cb8
Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents:
384
diff
changeset
|
692 |
1637 | 693 void vd_new_folder(ViewDir *vd, FileData *dir_fd) |
694 { | |
695 file_util_create_dir(dir_fd, vd->widget, vd_pop_menu_new_rename_cb, vd); | |
696 } | |
697 | |
394 | 698 /* |
699 *----------------------------------------------------------------------------- | |
700 * dnd | |
701 *----------------------------------------------------------------------------- | |
702 */ | |
703 | |
704 static GtkTargetEntry vd_dnd_drop_types[] = { | |
705 { "text/uri-list", 0, TARGET_URI_LIST } | |
706 }; | |
707 static gint vd_dnd_drop_types_count = 1; | |
708 | |
709 static void vd_dest_set(ViewDir *vd, gint enable) | |
710 { | |
711 if (enable) | |
712 { | |
713 gtk_drag_dest_set(vd->view, | |
714 GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP, | |
715 vd_dnd_drop_types, vd_dnd_drop_types_count, | |
716 GDK_ACTION_MOVE | GDK_ACTION_COPY); | |
717 } | |
718 else | |
719 { | |
720 gtk_drag_dest_unset(vd->view); | |
721 } | |
722 } | |
723 | |
724 static void vd_dnd_get(GtkWidget *widget, GdkDragContext *context, | |
725 GtkSelectionData *selection_data, guint info, | |
726 guint time, gpointer data) | |
727 { | |
728 ViewDir *vd = data; | |
729 GList *list; | |
730 gchar *uritext = NULL; | |
731 gint length = 0; | |
732 | |
733 if (!vd->click_fd) return; | |
734 | |
735 switch (info) | |
736 { | |
737 case TARGET_URI_LIST: | |
738 case TARGET_TEXT_PLAIN: | |
739 list = g_list_prepend(NULL, vd->click_fd); | |
740 uritext = uri_text_from_filelist(list, &length, (info == TARGET_TEXT_PLAIN)); | |
741 g_list_free(list); | |
742 break; | |
743 } | |
744 if (uritext) | |
745 { | |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
511
diff
changeset
|
746 gtk_selection_data_set(selection_data, selection_data->target, |
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
511
diff
changeset
|
747 8, (guchar *)uritext, length); |
394 | 748 g_free(uritext); |
749 } | |
750 } | |
751 | |
752 static void vd_dnd_begin(GtkWidget *widget, GdkDragContext *context, gpointer data) | |
753 { | |
754 ViewDir *vd = data; | |
755 | |
756 vd_color_set(vd, vd->click_fd, TRUE); | |
757 vd_dest_set(vd, FALSE); | |
758 } | |
759 | |
760 static void vd_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer data) | |
761 { | |
762 ViewDir *vd = data; | |
763 | |
764 vd_color_set(vd, vd->click_fd, FALSE); | |
765 | |
766 if (vd->type == DIRVIEW_LIST && context->action == GDK_ACTION_MOVE) | |
767 { | |
768 vd_refresh(vd); | |
769 } | |
770 vd_dest_set(vd, TRUE); | |
771 } | |
772 | |
773 static void vd_dnd_drop_receive(GtkWidget *widget, | |
511 | 774 GdkDragContext *context, gint x, gint y, |
775 GtkSelectionData *selection_data, guint info, | |
776 guint time, gpointer data) | |
394 | 777 { |
778 ViewDir *vd = data; | |
779 GtkTreePath *tpath; | |
780 FileData *fd = NULL; | |
781 | |
782 vd->click_fd = NULL; | |
783 | |
784 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), x, y, | |
785 &tpath, NULL, NULL, NULL)) | |
786 { | |
399 | 787 fd = vd_get_fd_from_tree_path(vd, GTK_TREE_VIEW(widget), tpath); |
394 | 788 gtk_tree_path_free(tpath); |
789 } | |
790 | |
791 if (!fd) return; | |
792 | |
793 if (info == TARGET_URI_LIST) | |
794 { | |
795 GList *list; | |
796 gint active; | |
1437 | 797 gboolean done = FALSE; |
394 | 798 |
799 list = uri_filelist_from_text((gchar *)selection_data->data, TRUE); | |
800 if (!list) return; | |
801 | |
802 active = access_file(fd->path, W_OK | X_OK); | |
803 | |
804 vd_color_set(vd, fd, TRUE); | |
494
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
805 |
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
806 if (active) |
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
807 { |
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
808 if (context->actions == GDK_ACTION_COPY) |
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
809 { |
753 | 810 file_util_copy_simple(list, fd->path, vd->widget); |
494
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
811 done = TRUE; |
1656 | 812 list = NULL; |
494
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
813 } |
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
814 else if (context->actions == GDK_ACTION_MOVE) |
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
815 { |
753 | 816 file_util_move_simple(list, fd->path, vd->widget); |
494
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
817 done = TRUE; |
1656 | 818 list = NULL; |
494
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
819 } |
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
820 } |
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
821 |
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
822 if (done == FALSE) |
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
823 { |
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
824 vd->popup = vd_drop_menu(vd, active); |
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
825 gtk_menu_popup(GTK_MENU(vd->popup), NULL, NULL, NULL, NULL, 0, time); |
3bb9a8df6ee9
Honor Control and Shift keys while drag'n'droping files
zas_
parents:
475
diff
changeset
|
826 } |
394 | 827 |
828 vd->drop_fd = fd; | |
829 vd->drop_list = list; | |
830 } | |
831 } | |
832 | |
407 | 833 static void vd_dnd_drop_update(ViewDir *vd, gint x, gint y) |
394 | 834 { |
835 GtkTreePath *tpath; | |
836 FileData *fd = NULL; | |
837 | |
838 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vd->view), x, y, | |
839 &tpath, NULL, NULL, NULL)) | |
840 { | |
399 | 841 fd = vd_get_fd_from_tree_path(vd, GTK_TREE_VIEW(vd->view), tpath); |
394 | 842 gtk_tree_path_free(tpath); |
843 } | |
844 | |
845 if (fd != vd->drop_fd) | |
846 { | |
847 vd_color_set(vd, vd->drop_fd, FALSE); | |
848 vd_color_set(vd, fd, TRUE); | |
407 | 849 if (fd && vd->dnd_drop_update_func) vd->dnd_drop_update_func(vd); |
394 | 850 } |
851 | |
852 vd->drop_fd = fd; | |
853 } | |
854 | |
855 void vd_dnd_drop_scroll_cancel(ViewDir *vd) | |
856 { | |
1523 | 857 if (vd->drop_scroll_id) |
858 { | |
859 g_source_remove(vd->drop_scroll_id); | |
860 vd->drop_scroll_id = 0; | |
861 } | |
394 | 862 } |
863 | |
1452 | 864 static gboolean vd_auto_scroll_idle_cb(gpointer data) |
394 | 865 { |
866 ViewDir *vd = data; | |
867 | |
868 if (vd->drop_fd) | |
869 { | |
870 GdkWindow *window; | |
871 gint x, y; | |
872 gint w, h; | |
873 | |
874 window = vd->view->window; | |
875 gdk_window_get_pointer(window, &x, &y, NULL); | |
876 gdk_drawable_get_size(window, &w, &h); | |
877 if (x >= 0 && x < w && y >= 0 && y < h) | |
878 { | |
407 | 879 vd_dnd_drop_update(vd, x, y); |
394 | 880 } |
881 } | |
882 | |
1523 | 883 vd->drop_scroll_id = 0; |
394 | 884 return FALSE; |
885 } | |
886 | |
1452 | 887 static gboolean vd_auto_scroll_notify_cb(GtkWidget *widget, gint x, gint y, gpointer data) |
394 | 888 { |
889 ViewDir *vd = data; | |
890 | |
891 if (!vd->drop_fd || vd->drop_list) return FALSE; | |
892 | |
1523 | 893 if (!vd->drop_scroll_id) vd->drop_scroll_id = g_idle_add(vd_auto_scroll_idle_cb, vd); |
394 | 894 |
895 return TRUE; | |
896 } | |
897 | |
1452 | 898 static gboolean vd_dnd_drop_motion(GtkWidget *widget, GdkDragContext *context, |
394 | 899 gint x, gint y, guint time, gpointer data) |
900 { | |
442 | 901 ViewDir *vd = data; |
394 | 902 |
903 vd->click_fd = NULL; | |
904 | |
905 if (gtk_drag_get_source_widget(context) == vd->view) | |
906 { | |
907 /* from same window */ | |
908 gdk_drag_status(context, 0, time); | |
909 return TRUE; | |
910 } | |
911 else | |
912 { | |
913 gdk_drag_status(context, context->suggested_action, time); | |
914 } | |
915 | |
407 | 916 vd_dnd_drop_update(vd, x, y); |
394 | 917 |
918 if (vd->drop_fd) | |
919 { | |
920 GtkAdjustment *adj = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(vd->view)); | |
921 widget_auto_scroll_start(vd->view, adj, -1, -1, vd_auto_scroll_notify_cb, vd); | |
922 } | |
923 | |
924 return FALSE; | |
925 } | |
926 | |
927 static void vd_dnd_drop_leave(GtkWidget *widget, GdkDragContext *context, guint time, gpointer data) | |
928 { | |
929 ViewDir *vd = data; | |
930 | |
931 if (vd->drop_fd != vd->click_fd) vd_color_set(vd, vd->drop_fd, FALSE); | |
932 | |
933 vd->drop_fd = NULL; | |
934 | |
407 | 935 if (vd->dnd_drop_leave_func) vd->dnd_drop_leave_func(vd); |
394 | 936 } |
937 | |
938 void vd_dnd_init(ViewDir *vd) | |
939 { | |
940 gtk_drag_source_set(vd->view, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK, | |
941 dnd_file_drag_types, dnd_file_drag_types_count, | |
942 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_ASK); | |
943 g_signal_connect(G_OBJECT(vd->view), "drag_data_get", | |
944 G_CALLBACK(vd_dnd_get), vd); | |
945 g_signal_connect(G_OBJECT(vd->view), "drag_begin", | |
946 G_CALLBACK(vd_dnd_begin), vd); | |
947 g_signal_connect(G_OBJECT(vd->view), "drag_end", | |
948 G_CALLBACK(vd_dnd_end), vd); | |
949 | |
950 vd_dest_set(vd, TRUE); | |
951 g_signal_connect(G_OBJECT(vd->view), "drag_data_received", | |
952 G_CALLBACK(vd_dnd_drop_receive), vd); | |
953 g_signal_connect(G_OBJECT(vd->view), "drag_motion", | |
954 G_CALLBACK(vd_dnd_drop_motion), vd); | |
955 g_signal_connect(G_OBJECT(vd->view), "drag_leave", | |
956 G_CALLBACK(vd_dnd_drop_leave), vd); | |
957 } | |
958 | |
395 | 959 /* |
960 *---------------------------------------------------------------------------- | |
961 * callbacks | |
962 *---------------------------------------------------------------------------- | |
963 */ | |
964 | |
965 void vd_menu_position_cb(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer data) | |
966 { | |
967 ViewDir *vd = data; | |
968 GtkTreeModel *store; | |
969 GtkTreeIter iter; | |
970 GtkTreePath *tpath; | |
971 gint cw, ch; | |
972 | |
1553 | 973 if (!vd_find_row(vd, vd->click_fd, &iter)) return; |
395 | 974 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view)); |
975 tpath = gtk_tree_model_get_path(store, &iter); | |
976 tree_view_get_cell_clamped(GTK_TREE_VIEW(vd->view), tpath, 0, TRUE, x, y, &cw, &ch); | |
977 gtk_tree_path_free(tpath); | |
978 *y += ch; | |
979 popup_menu_position_clamp(menu, x, y, 0); | |
980 } | |
981 | |
396 | 982 void vd_activate_cb(GtkTreeView *tview, GtkTreePath *tpath, GtkTreeViewColumn *column, gpointer data) |
983 { | |
984 ViewDir *vd = data; | |
399 | 985 FileData *fd = vd_get_fd_from_tree_path(vd, tview, tpath); |
396 | 986 |
987 vd_select_row(vd, fd); | |
988 } | |
989 | |
990 static GdkColor *vd_color_shifted(GtkWidget *widget) | |
991 { | |
992 static GdkColor color; | |
993 static GtkWidget *done = NULL; | |
994 | |
995 if (done != widget) | |
996 { | |
997 GtkStyle *style; | |
998 | |
999 style = gtk_widget_get_style(widget); | |
1000 memcpy(&color, &style->base[GTK_STATE_NORMAL], sizeof(color)); | |
1001 shift_color(&color, -1, 0); | |
1002 done = widget; | |
1003 } | |
1004 | |
1005 return &color; | |
1006 } | |
1007 | |
1008 void vd_color_cb(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, | |
1009 GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data) | |
1010 { | |
1011 ViewDir *vd = data; | |
1012 gboolean set; | |
1013 | |
1014 gtk_tree_model_get(tree_model, iter, DIR_COLUMN_COLOR, &set, -1); | |
1015 g_object_set(G_OBJECT(cell), | |
1016 "cell-background-gdk", vd_color_shifted(vd->view), | |
1017 "cell-background-set", set, NULL); | |
1018 } | |
1019 | |
1452 | 1020 gboolean vd_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) |
397 | 1021 { |
1022 ViewDir *vd = data; | |
1023 GtkTreePath *tpath; | |
1024 FileData *fd = NULL; | |
1025 | |
400 | 1026 if (!vd->click_fd) return FALSE; |
397 | 1027 vd_color_set(vd, vd->click_fd, FALSE); |
1028 | |
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
442
diff
changeset
|
1029 if (bevent->button != MOUSE_BUTTON_LEFT) return TRUE; |
397 | 1030 |
1031 if ((bevent->x != 0 || bevent->y != 0) && | |
1032 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), bevent->x, bevent->y, | |
1033 &tpath, NULL, NULL, NULL)) | |
1034 { | |
399 | 1035 fd = vd_get_fd_from_tree_path(vd, GTK_TREE_VIEW(widget), tpath); |
397 | 1036 gtk_tree_path_free(tpath); |
1037 } | |
1038 | |
1039 if (fd && vd->click_fd == fd) | |
1040 { | |
1628 | 1041 vd_select_row(vd, vd->click_fd); |
397 | 1042 } |
1043 | |
400 | 1044 return FALSE; |
397 | 1045 } |
1046 | |
1452 | 1047 gboolean vd_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) |
401
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
1048 { |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
1049 ViewDir *vd = data; |
1437 | 1050 gboolean ret = FALSE; |
401
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
1051 |
1347
79937bc55f3a
Add missing space between switch and first parenthesis.
zas_
parents:
1284
diff
changeset
|
1052 switch (vd->type) |
401
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
1053 { |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
1054 case DIRVIEW_LIST: ret = vdlist_press_key_cb(widget, event, data); break; |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
1055 case DIRVIEW_TREE: ret = vdtree_press_key_cb(widget, event, data); break; |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
1056 } |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
1057 |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
1058 return ret; |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
1059 } |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
1060 |
1452 | 1061 gboolean vd_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) |
401
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
1062 { |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
1063 ViewDir *vd = data; |
1437 | 1064 gboolean ret = FALSE; |
401
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
1065 |
1347
79937bc55f3a
Add missing space between switch and first parenthesis.
zas_
parents:
1284
diff
changeset
|
1066 switch (vd->type) |
401
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
1067 { |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
1068 case DIRVIEW_LIST: ret = vdlist_press_cb(widget, bevent, data); break; |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
1069 case DIRVIEW_TREE: ret = vdtree_press_cb(widget, bevent, data); break; |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
1070 } |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
1071 |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
1072 return ret; |
0a2e1b130a25
Add some wrappers in view_dir.c and simplify even more.
zas_
parents:
400
diff
changeset
|
1073 } |
907 | 1074 |
1075 static void vd_notify_cb(FileData *fd, NotifyType type, gpointer data) | |
1076 { | |
1077 ViewDir *vd = data; | |
1078 gboolean refresh; | |
1079 gchar *base; | |
1080 | |
945
fd84847c8231
speed-up of directory notification on deleting large number of files
nadvornik
parents:
943
diff
changeset
|
1081 if (!S_ISDIR(fd->mode)) return; /* this gives correct results even on recently deleted files/directories */ |
907 | 1082 |
1498 | 1083 DEBUG_1("Notify vd: %s %04x", fd->path, type); |
1084 | |
907 | 1085 base = remove_level_from_path(fd->path); |
1086 | |
1087 if (vd->type == DIRVIEW_LIST) | |
1088 { | |
1089 refresh = (fd == vd->dir_fd); | |
1090 | |
1091 if (!refresh) | |
1092 { | |
1093 refresh = (strcmp(base, vd->dir_fd->path) == 0); | |
1094 } | |
1095 | |
1432 | 1096 if ((type & NOTIFY_CHANGE) && fd->change) |
907 | 1097 { |
1098 if (!refresh && fd->change->dest) | |
1099 { | |
1100 gchar *dest_base = remove_level_from_path(fd->change->dest); | |
1101 refresh = (strcmp(dest_base, vd->dir_fd->path) == 0); | |
1102 g_free(dest_base); | |
1103 } | |
1104 | |
1105 if (!refresh && fd->change->source) | |
1106 { | |
1107 gchar *source_base = remove_level_from_path(fd->change->source); | |
1108 refresh = (strcmp(source_base, vd->dir_fd->path) == 0); | |
1109 g_free(source_base); | |
1110 } | |
1111 } | |
1112 | |
1113 if (refresh) vd_refresh(vd); | |
1114 } | |
1115 | |
1116 if (vd->type == DIRVIEW_TREE) | |
1117 { | |
1118 GtkTreeIter iter; | |
1119 FileData *base_fd = file_data_new_simple(base); | |
1120 | |
1121 if (vd_find_row(vd, base_fd, &iter)) | |
1122 { | |
943 | 1123 vdtree_populate_path_by_iter(vd, &iter, TRUE, vd->dir_fd); |
995 | 1124 } |
907 | 1125 |
1126 file_data_unref(base_fd); | |
1127 } | |
1128 | |
1129 g_free(base); | |
917 | 1130 } |
1055
1646720364cf
Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents:
995
diff
changeset
|
1131 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ |