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