annotate src/view_dir.c @ 1637:cc3ccf3c7c27

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