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