annotate src/view_dir_tree.c @ 1717:61bd3a2f633d

added possibility to use geeqie-rotate as a standalone script
author nadvornik
date Sun, 13 Sep 2009 09:55:21 +0000
parents f8503019ac38
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1 /*
196
f6e307c7bad6 rename GQview -> Geeqie over the code
nadvornik
parents: 145
diff changeset
2 * Geeqie
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
3 * (C) 2006 John Ellis
1284
8b89e3ff286b Add year 2009 to copyright info everywhere.
zas_
parents: 1232
diff changeset
4 * Copyright (C) 2008 - 2009 The Geeqie Team
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
5 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
6 * Author: John Ellis
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
7 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
8 * This software is released under the GNU General Public License (GNU GPL).
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
9 * Please read the included file COPYING for more information.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
10 * This software comes with no warranty of any kind, use at your own risk!
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
11 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
12
281
9995c5fb202a gqview.h -> main.h
zas_
parents: 250
diff changeset
13 #include "main.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
14 #include "view_dir_tree.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
15
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
16
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
17 #include "dnd.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
18 #include "dupe.h"
586
905688aa2317 split filelist.c to filefilter.c and filedata.c
nadvornik
parents: 512
diff changeset
19 #include "filedata.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
20 #include "layout.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
21 #include "layout_image.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
22 #include "layout_util.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
23 #include "utilops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
24 #include "ui_fileops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
25 #include "ui_menu.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
26 #include "ui_tree_edit.h"
380
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents: 356
diff changeset
27 #include "view_dir.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
28
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
29 #include <gdk/gdkkeysyms.h> /* for keyboard values */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
30
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
31
979
8732c06d8aeb Typo fix: vf -> vd
zas_
parents: 978
diff changeset
32 #define VDTREE(_vd_) ((ViewDirInfoTree *)(_vd_->info))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
33
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
34
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
35 typedef struct _PathData PathData;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
36 struct _PathData
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
37 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
38 gchar *name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
39 FileData *node;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
40 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
41
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
42
1628
738b70daa3af do not call signal handler from vdtree_row_expanded
nadvornik
parents: 1627
diff changeset
43 static void vdtree_row_expanded(GtkTreeView *treeview, GtkTreeIter *iter, GtkTreePath *tpath, gpointer data);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
44
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
45
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
46 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
47 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
48 * utils
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
49 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
50 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
51
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
52 static void set_cursor(GtkWidget *widget, GdkCursorType cursor_type)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
53 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
54 GdkCursor *cursor = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
55
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
56 if (!widget || !widget->window) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
57
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 475
diff changeset
58 if (cursor_type > -1) cursor = gdk_cursor_new(cursor_type);
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 475
diff changeset
59 gdk_window_set_cursor(widget->window, cursor);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
60 if (cursor) gdk_cursor_unref(cursor);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
61 gdk_flush();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
62 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
63
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
64 static void vdtree_busy_push(ViewDir *vd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
65 {
978
9ff64efe11eb Replace macros VDLIST_INFO() and VDTREE_INFO() by shorter VDLIST() and VDTREE(). VDLIST_INFO(vd, part) becomes VDLIST(vd)->part.
zas_
parents: 943
diff changeset
66 if (VDTREE(vd)->busy_ref == 0) set_cursor(vd->view, GDK_WATCH);
9ff64efe11eb Replace macros VDLIST_INFO() and VDTREE_INFO() by shorter VDLIST() and VDTREE(). VDLIST_INFO(vd, part) becomes VDLIST(vd)->part.
zas_
parents: 943
diff changeset
67 VDTREE(vd)->busy_ref++;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
68 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
69
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
70 static void vdtree_busy_pop(ViewDir *vd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
71 {
978
9ff64efe11eb Replace macros VDLIST_INFO() and VDTREE_INFO() by shorter VDLIST() and VDTREE(). VDLIST_INFO(vd, part) becomes VDLIST(vd)->part.
zas_
parents: 943
diff changeset
72 if (VDTREE(vd)->busy_ref == 1) set_cursor(vd->view, -1);
9ff64efe11eb Replace macros VDLIST_INFO() and VDTREE_INFO() by shorter VDLIST() and VDTREE(). VDLIST_INFO(vd, part) becomes VDLIST(vd)->part.
zas_
parents: 943
diff changeset
73 if (VDTREE(vd)->busy_ref > 0) VDTREE(vd)->busy_ref--;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
74 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
75
1501
299d45d4b1cc fixed vdlist_find_row return value
nadvornik
parents: 1452
diff changeset
76 gboolean vdtree_find_row(ViewDir *vd, FileData *fd, GtkTreeIter *iter, GtkTreeIter *parent)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
77 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
78 GtkTreeModel *store;
1452
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
79 gboolean valid;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
80
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
81 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
82 if (parent)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
83 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
84 valid = gtk_tree_model_iter_children(store, iter, parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
85 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
86 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
87 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
88 valid = gtk_tree_model_get_iter_first(store, iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
89 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
90 while (valid)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
91 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
92 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
93 GtkTreeIter found;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
94
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
95 gtk_tree_model_get(GTK_TREE_MODEL(store), iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
96 if (nd->fd == fd) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
97
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
98 if (vdtree_find_row(vd, fd, &found, iter))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
99 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
100 memcpy(iter, &found, sizeof(found));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
101 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
102 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
103
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
104 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
105 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
106
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
107 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
108 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
109
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
110 static void vdtree_icon_set_by_iter(ViewDir *vd, GtkTreeIter *iter, GdkPixbuf *pixbuf)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
111 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
112 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
113 GdkPixbuf *old;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
114
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
115 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
116 gtk_tree_model_get(store, iter, DIR_COLUMN_ICON, &old, -1);
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
117 if (old != vd->pf->deny)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
118 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
119 gtk_tree_store_set(GTK_TREE_STORE(store), iter, DIR_COLUMN_ICON, pixbuf, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
120 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
121 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
122
1452
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
123 static void vdtree_expand_by_iter(ViewDir *vd, GtkTreeIter *iter, gboolean expand)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
124 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
125 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
126 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
127
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
128 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
129 tpath = gtk_tree_model_get_path(store, iter);
1628
738b70daa3af do not call signal handler from vdtree_row_expanded
nadvornik
parents: 1627
diff changeset
130
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
131 if (expand)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
132 {
1628
738b70daa3af do not call signal handler from vdtree_row_expanded
nadvornik
parents: 1627
diff changeset
133 /* block signal handler, icon is set here, the caller of vdtree_expand_by_iter must make sure
738b70daa3af do not call signal handler from vdtree_row_expanded
nadvornik
parents: 1627
diff changeset
134 that the iter is populated */
738b70daa3af do not call signal handler from vdtree_row_expanded
nadvornik
parents: 1627
diff changeset
135 g_signal_handlers_block_by_func(G_OBJECT(vd->view), vdtree_row_expanded, vd);
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
136 gtk_tree_view_expand_row(GTK_TREE_VIEW(vd->view), tpath, FALSE);
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
137 vdtree_icon_set_by_iter(vd, iter, vd->pf->open);
1628
738b70daa3af do not call signal handler from vdtree_row_expanded
nadvornik
parents: 1627
diff changeset
138 g_signal_handlers_unblock_by_func(G_OBJECT(vd->view), vdtree_row_expanded, vd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
139 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
140 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
141 {
1628
738b70daa3af do not call signal handler from vdtree_row_expanded
nadvornik
parents: 1627
diff changeset
142 /* signal handler vdtree_row_collapsed is called, it updates the icon */
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
143 gtk_tree_view_collapse_row(GTK_TREE_VIEW(vd->view), tpath);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
144 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
145 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
146 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
147
1452
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
148 static void vdtree_expand_by_data(ViewDir *vd, FileData *fd, gboolean expand)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
149 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
150 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
151
389
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
152 if (vd_find_row(vd, fd, &iter))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
153 {
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
154 vdtree_expand_by_iter(vd, &iter, expand);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
155 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
156 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
157
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
158 static void vdtree_node_free(NodeData *nd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
159 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
160 if (!nd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
161
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
162 file_data_unref(nd->fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
163 g_free(nd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
164 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
165
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
166 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
167 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
168 * dnd
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
169 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
170 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
171
1452
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
172 static gboolean vdtree_dnd_drop_expand_cb(gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
173 {
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
174 ViewDir *vd = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
175 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
176
394
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 389
diff changeset
177 if (vd->drop_fd && vd_find_row(vd, vd->drop_fd, &iter))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
178 {
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
179 vdtree_populate_path_by_iter(vd, &iter, FALSE, vd->dir_fd);
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
180 vdtree_expand_by_data(vd, vd->drop_fd, TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
181 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
182
1523
24a12aa0cb54 Fix up event source ids type: gint -> guint.
zas_
parents: 1501
diff changeset
183 VDTREE(vd)->drop_expand_id = 0;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
184 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
185 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
186
407
3a9074e73f53 Rename vd_drop_update() to vd_dnd_drop_update().
zas_
parents: 406
diff changeset
187 static void vdtree_dnd_drop_expand_cancel(ViewDir *vd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
188 {
1523
24a12aa0cb54 Fix up event source ids type: gint -> guint.
zas_
parents: 1501
diff changeset
189 if (VDTREE(vd)->drop_expand_id)
24a12aa0cb54 Fix up event source ids type: gint -> guint.
zas_
parents: 1501
diff changeset
190 {
24a12aa0cb54 Fix up event source ids type: gint -> guint.
zas_
parents: 1501
diff changeset
191 g_source_remove(VDTREE(vd)->drop_expand_id);
24a12aa0cb54 Fix up event source ids type: gint -> guint.
zas_
parents: 1501
diff changeset
192 VDTREE(vd)->drop_expand_id = 0;
24a12aa0cb54 Fix up event source ids type: gint -> guint.
zas_
parents: 1501
diff changeset
193 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
194 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
195
407
3a9074e73f53 Rename vd_drop_update() to vd_dnd_drop_update().
zas_
parents: 406
diff changeset
196 static void vdtree_dnd_drop_expand(ViewDir *vd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
197 {
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
198 vdtree_dnd_drop_expand_cancel(vd);
978
9ff64efe11eb Replace macros VDLIST_INFO() and VDTREE_INFO() by shorter VDLIST() and VDTREE(). VDLIST_INFO(vd, part) becomes VDLIST(vd)->part.
zas_
parents: 943
diff changeset
199 VDTREE(vd)->drop_expand_id = g_timeout_add(1000, vdtree_dnd_drop_expand_cb, vd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
200 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
201
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
202 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
203 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
204 * parts lists
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
205 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
206 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
207
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
208 static GList *parts_list(const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
209 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
210 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
211 const gchar *strb, *strp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
212 gint l;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
213
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
214 strp = path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
215
726
a1dcef8cd1ae Use G_DIR_SEPARATOR where applicable.
zas_
parents: 725
diff changeset
216 if (*strp != G_DIR_SEPARATOR) return NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
217
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
218 strp++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
219 strb = strp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
220 l = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
221
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
222 while (*strp != '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
223 {
726
a1dcef8cd1ae Use G_DIR_SEPARATOR where applicable.
zas_
parents: 725
diff changeset
224 if (*strp == G_DIR_SEPARATOR)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
225 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
226 if (l > 0) list = g_list_prepend(list, g_strndup(strb, l));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
227 strp++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
228 strb = strp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
229 l = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
230 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
231 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
232 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
233 strp++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
234 l++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
235 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
236 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
237 if (l > 0) list = g_list_prepend(list, g_strndup(strb, l));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
238
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
239 list = g_list_reverse(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
240
725
eda074e91ddd Use G_DIR_SEPARATOR_S where applicable.
zas_
parents: 673
diff changeset
241 list = g_list_prepend(list, g_strdup(G_DIR_SEPARATOR_S));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
242
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
243 return list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
244 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
245
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
246 static void parts_list_free(GList *list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
247 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
248 GList *work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
249 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
250 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
251 PathData *pd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
252 g_free(pd->name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
253 g_free(pd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
254 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
255 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
256
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
257 g_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
258 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
259
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
260 static GList *parts_list_add_node_points(ViewDir *vd, GList *list)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
261 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
262 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
263 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
264 GtkTreeIter iter;
1452
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
265 gboolean valid;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
266
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
267 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
268 valid = gtk_tree_model_get_iter_first(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
269
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
270 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
271 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
272 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
273 PathData *pd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
274 FileData *fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
275
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
276 pd = g_new0(PathData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
277 pd->name = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
278
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
279 while (valid && !fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
280 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
281 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
282
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
283 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
284 if (strcmp(nd->fd->name, pd->name) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
285 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
286 fd = nd->fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
287 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
288 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
289 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
290 valid = gtk_tree_model_iter_next(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
291 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
292 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
293
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
294 pd->node = fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
295 work->data = pd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
296
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
297 if (fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
298 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
299 GtkTreeIter parent;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
300 memcpy(&parent, &iter, sizeof(parent));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
301 valid = gtk_tree_model_iter_children(store, &iter, &parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
302 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
303
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
304 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
305 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
306
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
307 return list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
308 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
309
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
310 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
311 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
312 * misc
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
313 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
314 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
315
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
316 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
317 static void vdtree_row_deleted_cb(GtkTreeModel *tree_model, GtkTreePath *tpath, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
318 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
319 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
320 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
321
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
322 gtk_tree_model_get_iter(tree_model, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
323 gtk_tree_model_get(tree_model, &iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
324
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
325 if (!nd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
326
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
327 file_data_unref(nd->fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
328 g_free(nd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
329 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
330 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
331
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
332 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
333 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
334 * node traversal, management
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
335 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
336 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
337
1452
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
338 static gboolean vdtree_find_iter_by_data(ViewDir *vd, GtkTreeIter *parent, NodeData *nd, GtkTreeIter *iter)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
339 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
340 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
341
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
342 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
343 if (!nd || !gtk_tree_model_iter_children(store, iter, parent)) return -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
344 do {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
345 NodeData *cnd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
346
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
347 gtk_tree_model_get(store, iter, DIR_COLUMN_POINTER, &cnd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
348 if (cnd == nd) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
349 } while (gtk_tree_model_iter_next(store, iter));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
350
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
351 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
352 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
353
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
354 static NodeData *vdtree_find_iter_by_name(ViewDir *vd, GtkTreeIter *parent, const gchar *name, GtkTreeIter *iter)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
355 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
356 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
357
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
358 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
359 if (!name || !gtk_tree_model_iter_children(store, iter, parent)) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
360 do {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
361 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
362
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
363 gtk_tree_model_get(store, iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
364 if (nd && strcmp(nd->fd->name, name) == 0) return nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
365 } while (gtk_tree_model_iter_next(store, iter));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
366
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
367 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
368 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
369
1232
98be4a5e36f8 do not enter a directory after rename
nadvornik
parents: 1055
diff changeset
370 static NodeData *vdtree_find_iter_by_fd(ViewDir *vd, GtkTreeIter *parent, FileData *fd, GtkTreeIter *iter)
98be4a5e36f8 do not enter a directory after rename
nadvornik
parents: 1055
diff changeset
371 {
98be4a5e36f8 do not enter a directory after rename
nadvornik
parents: 1055
diff changeset
372 GtkTreeModel *store;
98be4a5e36f8 do not enter a directory after rename
nadvornik
parents: 1055
diff changeset
373
98be4a5e36f8 do not enter a directory after rename
nadvornik
parents: 1055
diff changeset
374 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view));
98be4a5e36f8 do not enter a directory after rename
nadvornik
parents: 1055
diff changeset
375 if (!fd || !gtk_tree_model_iter_children(store, iter, parent)) return NULL;
98be4a5e36f8 do not enter a directory after rename
nadvornik
parents: 1055
diff changeset
376 do {
98be4a5e36f8 do not enter a directory after rename
nadvornik
parents: 1055
diff changeset
377 NodeData *nd;
98be4a5e36f8 do not enter a directory after rename
nadvornik
parents: 1055
diff changeset
378
98be4a5e36f8 do not enter a directory after rename
nadvornik
parents: 1055
diff changeset
379 gtk_tree_model_get(store, iter, DIR_COLUMN_POINTER, &nd, -1);
98be4a5e36f8 do not enter a directory after rename
nadvornik
parents: 1055
diff changeset
380 if (nd && nd->fd == fd) return nd;
98be4a5e36f8 do not enter a directory after rename
nadvornik
parents: 1055
diff changeset
381 } while (gtk_tree_model_iter_next(store, iter));
98be4a5e36f8 do not enter a directory after rename
nadvornik
parents: 1055
diff changeset
382
98be4a5e36f8 do not enter a directory after rename
nadvornik
parents: 1055
diff changeset
383 return NULL;
98be4a5e36f8 do not enter a directory after rename
nadvornik
parents: 1055
diff changeset
384 }
98be4a5e36f8 do not enter a directory after rename
nadvornik
parents: 1055
diff changeset
385
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
386 static void vdtree_add_by_data(ViewDir *vd, FileData *fd, GtkTreeIter *parent)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
387 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
388 GtkTreeStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
389 GtkTreeIter child;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
390 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
391 GdkPixbuf *pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
392 NodeData *end;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
393 GtkTreeIter empty;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
394
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
395 if (!fd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
396
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
397 if (access_file(fd->path, R_OK | X_OK))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
398 {
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
399 pixbuf = vd->pf->close;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
400 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
401 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
402 {
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
403 pixbuf = vd->pf->deny;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
404 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
405
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
406 nd = g_new0(NodeData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
407 nd->fd = fd;
907
ca8022a156ec added notification handler to view_dir
nadvornik
parents: 902
diff changeset
408 nd->version = fd->version;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
409 nd->expanded = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
410 nd->last_update = time(NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
411
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
412 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view)));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
413 gtk_tree_store_append(store, &child, parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
414 gtk_tree_store_set(store, &child, DIR_COLUMN_POINTER, nd,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
415 DIR_COLUMN_ICON, pixbuf,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
416 DIR_COLUMN_NAME, nd->fd->name,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
417 DIR_COLUMN_COLOR, FALSE, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
418
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
419 /* all nodes are created with an "empty" node, so that the expander is shown
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
420 * this is removed when the child is populated */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
421 end = g_new0(NodeData, 1);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
422 end->fd = file_data_new_simple("");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
423 end->expanded = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
424
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
425 gtk_tree_store_append(store, &empty, &child);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
426 gtk_tree_store_set(store, &empty, DIR_COLUMN_POINTER, end,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
427 DIR_COLUMN_NAME, "empty", -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
428
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
429 if (parent)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
430 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
431 NodeData *pnd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
432 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
433
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
434 gtk_tree_model_get(GTK_TREE_MODEL(store), parent, DIR_COLUMN_POINTER, &pnd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
435 tpath = gtk_tree_model_get_path(GTK_TREE_MODEL(store), parent);
320
c74af1cbd61a Move more options to ConfOptions.
zas_
parents: 318
diff changeset
436 if (options->tree_descend_subdirs &&
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
437 gtk_tree_view_row_expanded(GTK_TREE_VIEW(vd->view), tpath) &&
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
438 !nd->expanded)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
439 {
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
440 vdtree_populate_path_by_iter(vd, &child, FALSE, vd->dir_fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
441 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
442 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
443 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
444 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
445
1452
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
446 gboolean vdtree_populate_path_by_iter(ViewDir *vd, GtkTreeIter *iter, gboolean force, FileData *target_fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
447 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
448 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
449 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
450 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
451 GList *old;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
452 time_t current_time;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
453 GtkTreeIter child;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
454 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
455
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
456 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
457 gtk_tree_model_get(store, iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
458
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
459 if (!nd) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
460
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
461 current_time = time(NULL);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 407
diff changeset
462
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
463 if (nd->expanded)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
464 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
465 if (!isdir(nd->fd->path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
466 {
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
467 if (vd->click_fd == nd->fd) vd->click_fd = NULL;
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
468 if (vd->drop_fd == nd->fd) vd->drop_fd = NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
469 gtk_tree_store_remove(GTK_TREE_STORE(store), iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
470 vdtree_node_free(nd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
471 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
472 }
995
6ca2c5fd7b13 Whitespaces cleanup.
zas_
parents: 979
diff changeset
473 if (!force && current_time - nd->last_update < 2)
943
b483d8cdedb6 improved updating of view_dir_tree
nadvornik
parents: 916
diff changeset
474 {
b483d8cdedb6 improved updating of view_dir_tree
nadvornik
parents: 916
diff changeset
475 DEBUG_1("Too frequent update of %s", nd->fd->path);
b483d8cdedb6 improved updating of view_dir_tree
nadvornik
parents: 916
diff changeset
476 return TRUE;
b483d8cdedb6 improved updating of view_dir_tree
nadvornik
parents: 916
diff changeset
477 }
b483d8cdedb6 improved updating of view_dir_tree
nadvornik
parents: 916
diff changeset
478 if (nd->fd->version == nd->version) return TRUE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
479 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
480
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
481 vdtree_busy_push(vd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
482
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
483 filelist_read(nd->fd, NULL, &list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
484
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
485 /* when hidden files are not enabled, and the user enters a hidden path,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
486 * allow the tree to display that path by specifically inserting the hidden entries
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
487 */
356
673d1eb5af73 Rename show_dot_files to show_hidden_files.
zas_
parents: 355
diff changeset
488 if (!options->file_filter.show_hidden_files &&
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
489 target_fd &&
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
490 strncmp(nd->fd->path, target_fd->path, strlen(nd->fd->path)) == 0)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
491 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
492 gint n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
493
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
494 n = strlen(nd->fd->path);
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
495 if (target_fd->path[n] == G_DIR_SEPARATOR && target_fd->path[n+1] == '.')
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
496 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
497 gchar *name8;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
498 struct stat sbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
499
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
500 n++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
501
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
502 while (target_fd->path[n] != '\0' && target_fd->path[n] != G_DIR_SEPARATOR) n++;
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
503 name8 = g_strndup(target_fd->path, n);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
504
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
505 if (stat_utf8(name8, &sbuf))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
506 {
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 138
diff changeset
507 list = g_list_prepend(list, file_data_new_simple(name8));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
508 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
509
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
510 g_free(name8);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
511 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
512 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
513
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
514 old = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
515 if (gtk_tree_model_iter_children(store, &child, iter))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
516 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
517 do {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
518 NodeData *cnd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
519
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
520 gtk_tree_model_get(store, &child, DIR_COLUMN_POINTER, &cnd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
521 old = g_list_prepend(old, cnd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
522 } while (gtk_tree_model_iter_next(store, &child));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
523 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
524
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
525 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
526 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
527 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
528 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
529
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
530 fd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
531 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
532
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
533 if (strcmp(fd->name, ".") == 0 || strcmp(fd->name, "..") == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
534 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
535 file_data_unref(fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
536 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
537 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
538 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
539 NodeData *cnd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
540
1232
98be4a5e36f8 do not enter a directory after rename
nadvornik
parents: 1055
diff changeset
541 cnd = vdtree_find_iter_by_fd(vd, iter, fd, &child);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
542 if (cnd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
543 {
1232
98be4a5e36f8 do not enter a directory after rename
nadvornik
parents: 1055
diff changeset
544 if (cnd->expanded && cnd->version != fd->version)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
545 {
1232
98be4a5e36f8 do not enter a directory after rename
nadvornik
parents: 1055
diff changeset
546 vdtree_populate_path_by_iter(vd, &child, FALSE, target_fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
547 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
548
1232
98be4a5e36f8 do not enter a directory after rename
nadvornik
parents: 1055
diff changeset
549 gtk_tree_store_set(GTK_TREE_STORE(store), &child, DIR_COLUMN_NAME, fd->name, -1);
98be4a5e36f8 do not enter a directory after rename
nadvornik
parents: 1055
diff changeset
550 cnd->version = fd->version;
98be4a5e36f8 do not enter a directory after rename
nadvornik
parents: 1055
diff changeset
551 old = g_list_remove(old, cnd);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
552 file_data_unref(fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
553 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
554 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
555 {
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
556 vdtree_add_by_data(vd, fd, iter);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
557 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
558 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
559 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
560
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
561 work = old;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
562 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
563 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
564 NodeData *cnd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
565 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
566
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
567 if (vd->click_fd == cnd->fd) vd->click_fd = NULL;
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
568 if (vd->drop_fd == cnd->fd) vd->drop_fd = NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
569
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
570 if (vdtree_find_iter_by_data(vd, iter, cnd, &child))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
571 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
572 gtk_tree_store_remove(GTK_TREE_STORE(store), &child);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
573 vdtree_node_free(cnd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
574 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
575 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
576
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
577 g_list_free(old);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
578 g_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
579
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
580 vdtree_busy_pop(vd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
581
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
582 nd->expanded = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
583 nd->last_update = current_time;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
584
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
585 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
586 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
587
1452
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
588 FileData *vdtree_populate_path(ViewDir *vd, FileData *target_fd, gboolean expand, gboolean force)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
589 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
590 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
591 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
592 FileData *fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
593
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
594 if (!target_fd) return NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
595
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
596 vdtree_busy_push(vd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
597
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
598 list = parts_list(target_fd->path);
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
599 list = parts_list_add_node_points(vd, list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
600
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
601 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
602 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
603 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
604 PathData *pd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
605 if (pd->node == NULL)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
606 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
607 PathData *parent_pd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
608 GtkTreeIter parent_iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
609 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
610 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
611
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
612 if (work == list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
613 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
614 /* should not happen */
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 586
diff changeset
615 log_printf("vdtree warning, root node not found\n");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
616 parts_list_free(list);
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
617 vdtree_busy_pop(vd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
618 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
619 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
620
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
621 parent_pd = work->prev->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
622
389
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
623 if (!vd_find_row(vd, parent_pd->node, &parent_iter) ||
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
624 !vdtree_populate_path_by_iter(vd, &parent_iter, force, target_fd) ||
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
625 (nd = vdtree_find_iter_by_name(vd, &parent_iter, pd->name, &iter)) == NULL)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
626 {
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 586
diff changeset
627 log_printf("vdtree warning, aborted at %s\n", parent_pd->name);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
628 parts_list_free(list);
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
629 vdtree_busy_pop(vd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
630 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
631 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
632
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
633 pd->node = nd->fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
634
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
635 if (pd->node)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
636 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
637 if (expand)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
638 {
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
639 vdtree_expand_by_iter(vd, &parent_iter, TRUE);
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
640 vdtree_expand_by_iter(vd, &iter, TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
641 }
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
642 vdtree_populate_path_by_iter(vd, &iter, force, target_fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
643 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
644 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
645 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
646 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
647 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
648
389
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
649 if (vd_find_row(vd, pd->node, &iter))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
650 {
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
651 if (expand) vdtree_expand_by_iter(vd, &iter, TRUE);
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
652 vdtree_populate_path_by_iter(vd, &iter, force, target_fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
653 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
654 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
655
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
656 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
657 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
658
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
659 work = g_list_last(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
660 if (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
661 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
662 PathData *pd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
663 fd = pd->node;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
664 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
665 parts_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
666
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
667 vdtree_busy_pop(vd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
668
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
669 return fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
670 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
671
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
672 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
673 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
674 * access
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
675 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
676 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
677
1437
a3d3208b0c50 gint -> gboolean.
zas_
parents: 1365
diff changeset
678 static gboolean selection_is_ok = FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
679
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
680 static gboolean vdtree_select_cb(GtkTreeSelection *selection, GtkTreeModel *store, GtkTreePath *tpath,
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 407
diff changeset
681 gboolean path_currently_selected, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
682 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
683 return selection_is_ok;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
684 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
685
1452
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
686 gboolean vdtree_set_fd(ViewDir *vd, FileData *dir_fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
687 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
688 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
689 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
690
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
691 if (!dir_fd) return FALSE;
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
692 if (vd->dir_fd == dir_fd) return TRUE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
693
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
694 file_data_unref(vd->dir_fd);
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
695 vd->dir_fd = file_data_ref(dir_fd);;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
696
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
697 fd = vdtree_populate_path(vd, vd->dir_fd, TRUE, FALSE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
698
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
699 if (!fd) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
700
389
b78077f65eff Merge few more vdlist/vdtree functions.
zas_
parents: 388
diff changeset
701 if (vd_find_row(vd, fd, &iter))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
702 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
703 GtkTreeModel *store;
1627
909bf83bf9a4 reduced jumping of directory tree when user clicks on folders
nadvornik
parents: 1626
diff changeset
704 GtkTreePath *tpath, *old_tpath;
1626
94e4a47ccaff simplified the code around vd_select_row
nadvornik
parents: 1523
diff changeset
705 GtkTreeSelection *selection;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
706
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
707 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
708
1626
94e4a47ccaff simplified the code around vd_select_row
nadvornik
parents: 1523
diff changeset
709 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vd->view));
94e4a47ccaff simplified the code around vd_select_row
nadvornik
parents: 1523
diff changeset
710
94e4a47ccaff simplified the code around vd_select_row
nadvornik
parents: 1523
diff changeset
711 /* hack, such that selection is only allowed to be changed from here */
94e4a47ccaff simplified the code around vd_select_row
nadvornik
parents: 1523
diff changeset
712 selection_is_ok = TRUE;
94e4a47ccaff simplified the code around vd_select_row
nadvornik
parents: 1523
diff changeset
713 gtk_tree_selection_select_iter(selection, &iter);
94e4a47ccaff simplified the code around vd_select_row
nadvornik
parents: 1523
diff changeset
714 selection_is_ok = FALSE;
94e4a47ccaff simplified the code around vd_select_row
nadvornik
parents: 1523
diff changeset
715
1627
909bf83bf9a4 reduced jumping of directory tree when user clicks on folders
nadvornik
parents: 1626
diff changeset
716 gtk_tree_view_get_cursor(GTK_TREE_VIEW(vd->view), &old_tpath, NULL);
909bf83bf9a4 reduced jumping of directory tree when user clicks on folders
nadvornik
parents: 1626
diff changeset
717 tpath = gtk_tree_model_get_path(store, &iter);
909bf83bf9a4 reduced jumping of directory tree when user clicks on folders
nadvornik
parents: 1626
diff changeset
718
909bf83bf9a4 reduced jumping of directory tree when user clicks on folders
nadvornik
parents: 1626
diff changeset
719 if (!old_tpath || gtk_tree_path_compare(tpath, old_tpath) != 0)
909bf83bf9a4 reduced jumping of directory tree when user clicks on folders
nadvornik
parents: 1626
diff changeset
720 {
909bf83bf9a4 reduced jumping of directory tree when user clicks on folders
nadvornik
parents: 1626
diff changeset
721 /* setting the cursor scrolls the view; do not do that unless it is necessary */
909bf83bf9a4 reduced jumping of directory tree when user clicks on folders
nadvornik
parents: 1626
diff changeset
722 gtk_tree_view_set_cursor(GTK_TREE_VIEW(vd->view), tpath, NULL, FALSE);
1629
f8503019ac38 better implementation of tree_view_row_get_visibility,
nadvornik
parents: 1628
diff changeset
723
f8503019ac38 better implementation of tree_view_row_get_visibility,
nadvornik
parents: 1628
diff changeset
724 /* gtk_tree_view_set_cursor scrolls the window itself, but it sometimes
f8503019ac38 better implementation of tree_view_row_get_visibility,
nadvornik
parents: 1628
diff changeset
725 does not work (switch from dir_list to dir_tree) */
f8503019ac38 better implementation of tree_view_row_get_visibility,
nadvornik
parents: 1628
diff changeset
726 tree_view_row_make_visible(GTK_TREE_VIEW(vd->view), &iter, TRUE);
1627
909bf83bf9a4 reduced jumping of directory tree when user clicks on folders
nadvornik
parents: 1626
diff changeset
727 }
909bf83bf9a4 reduced jumping of directory tree when user clicks on folders
nadvornik
parents: 1626
diff changeset
728 gtk_tree_path_free(tpath);
909bf83bf9a4 reduced jumping of directory tree when user clicks on folders
nadvornik
parents: 1626
diff changeset
729 gtk_tree_path_free(old_tpath);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
730 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
731
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
732 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
733 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
734
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
735 #if 0
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
736 const gchar *vdtree_get_path(ViewDir *vd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
737 {
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
738 return vd->path;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
739 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
740 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
741
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
742 void vdtree_refresh(ViewDir *vd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
743 {
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
744 vdtree_populate_path(vd, vd->dir_fd, FALSE, TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
745 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
746
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
747 const gchar *vdtree_row_get_path(ViewDir *vd, gint row)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
748 {
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 586
diff changeset
749 log_printf("FIXME: no get row path\n");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
750 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
751 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
752
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
753 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
754 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
755 * callbacks
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
756 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
757 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
758
1452
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
759 gboolean vdtree_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
760 {
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
761 ViewDir *vd = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
762 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
763 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
764 FileData *fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
765
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
766 gtk_tree_view_get_cursor(GTK_TREE_VIEW(vd->view), &tpath, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
767 if (tpath)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
768 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
769 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
770 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
771
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
772 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
773 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
774 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
775
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
776 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
777
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
778 fd = (nd) ? nd->fd : NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
779 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
780
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
781 switch (event->keyval)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
782 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
783 case GDK_Menu:
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
784 vd->click_fd = fd;
383
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 382
diff changeset
785 vd_color_set(vd, vd->click_fd, TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
786
388
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
787 vd->popup = vd_pop_menu(vd, vd->click_fd);
395
c359fc2c5a1f Move common menu position callback to view_dir.c.
zas_
parents: 394
diff changeset
788 gtk_menu_popup(GTK_MENU(vd->popup), NULL, NULL, vd_menu_position_cb, vd, 0, GDK_CURRENT_TIME);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
789
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
790 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
791 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
792 case GDK_plus:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
793 case GDK_Right:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
794 case GDK_KP_Add:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
795 if (fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
796 {
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
797 vdtree_populate_path_by_iter(vd, &iter, FALSE, vd->dir_fd);
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
798 vdtree_icon_set_by_iter(vd, &iter, vd->pf->open);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
799 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
800 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
801 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
802
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
803 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
804 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
805
1452
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
806 static gboolean vdtree_clicked_on_expander(GtkTreeView *treeview, GtkTreePath *tpath,
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
807 GtkTreeViewColumn *column, gint x, gint y, gint *left_of_expander)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
808 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
809 gint depth;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
810 gint size;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
811 gint sep;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
812 gint exp_width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
813
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
814 if (column != gtk_tree_view_get_expander_column(treeview)) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
815
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
816 gtk_widget_style_get(GTK_WIDGET(treeview), "expander-size", &size, "horizontal-separator", &sep, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
817 depth = gtk_tree_path_get_depth(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
818
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
819 exp_width = sep + size + sep;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
820
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
821 if (x <= depth * exp_width)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
822 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
823 if (left_of_expander) *left_of_expander = !(x >= (depth - 1) * exp_width);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
824 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
825 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
826
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
827 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
828 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
829
1452
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
830 gboolean vdtree_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
831 {
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
832 ViewDir *vd = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
833 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
834 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
835 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
836 NodeData *nd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
837
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
838 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), bevent->x, bevent->y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
839 &tpath, &column, NULL, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
840 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
841 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
842 gint left_of_expander;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
843
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
844 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
845 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
846 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
847 gtk_tree_view_set_cursor(GTK_TREE_VIEW(widget), tpath, NULL, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
848
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
849 if (vdtree_clicked_on_expander(GTK_TREE_VIEW(widget), tpath, column, bevent->x, bevent->y, &left_of_expander))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
850 {
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
851 vd->click_fd = NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
852
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
853 /* clicking this region should automatically reveal an expander, if necessary
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
854 * treeview bug: the expander will not expand until a button_motion_event highlights it.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
855 */
448
a73cc0fa14d0 Use explicit names for mouse buttons instead of numbers.
zas_
parents: 442
diff changeset
856 if (bevent->button == MOUSE_BUTTON_LEFT &&
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
857 !left_of_expander &&
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
858 !gtk_tree_view_row_expanded(GTK_TREE_VIEW(vd->view), tpath))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
859 {
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
860 vdtree_populate_path_by_iter(vd, &iter, FALSE, vd->dir_fd);
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
861 vdtree_icon_set_by_iter(vd, &iter, vd->pf->open);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
862 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
863
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
864 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
865 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
866 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
867
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
868 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
869 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
870
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
871 vd->click_fd = (nd) ? nd->fd : NULL;
383
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 382
diff changeset
872 vd_color_set(vd, vd->click_fd, TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
873
448
a73cc0fa14d0 Use explicit names for mouse buttons instead of numbers.
zas_
parents: 442
diff changeset
874 if (bevent->button == MOUSE_BUTTON_RIGHT)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
875 {
388
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 384
diff changeset
876 vd->popup = vd_pop_menu(vd, vd->click_fd);
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
877 gtk_menu_popup(GTK_MENU(vd->popup), NULL, NULL, NULL, NULL,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
878 bevent->button, bevent->time);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
879 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
880
448
a73cc0fa14d0 Use explicit names for mouse buttons instead of numbers.
zas_
parents: 442
diff changeset
881 return (bevent->button != MOUSE_BUTTON_LEFT);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
882 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
883
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
884 static void vdtree_row_expanded(GtkTreeView *treeview, GtkTreeIter *iter, GtkTreePath *tpath, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
885 {
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
886 ViewDir *vd = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
887
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
888 vdtree_populate_path_by_iter(vd, iter, FALSE, NULL);
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
889 vdtree_icon_set_by_iter(vd, iter, vd->pf->open);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
890 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
891
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
892 static void vdtree_row_collapsed(GtkTreeView *treeview, GtkTreeIter *iter, GtkTreePath *tpath, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
893 {
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
894 ViewDir *vd = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
895
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
896 vdtree_icon_set_by_iter(vd, iter, vd->pf->close);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
897 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
898
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
899 static gint vdtree_sort_cb(GtkTreeModel *store, GtkTreeIter *a, GtkTreeIter *b, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
900 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
901 NodeData *nda;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
902 NodeData *ndb;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
903
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
904 gtk_tree_model_get(store, a, DIR_COLUMN_POINTER, &nda, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
905 gtk_tree_model_get(store, b, DIR_COLUMN_POINTER, &ndb, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
906
785
548b193c084c Use uft8_collate_key() to sort utf8 strings.
zas_
parents: 783
diff changeset
907 if (options->file_sort.case_sensitive)
819
c90eb9539f6e fixed vdtree_sort_cb
nadvornik
parents: 785
diff changeset
908 return strcmp(nda->fd->collate_key_name, ndb->fd->collate_key_name);
785
548b193c084c Use uft8_collate_key() to sort utf8 strings.
zas_
parents: 783
diff changeset
909 else
819
c90eb9539f6e fixed vdtree_sort_cb
nadvornik
parents: 785
diff changeset
910 return strcmp(nda->fd->collate_key_name_nocase, ndb->fd->collate_key_name_nocase);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
911 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
912
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
913 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
914 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
915 * core
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
916 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
917 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
918
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
919 static void vdtree_setup_root(ViewDir *vd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
920 {
725
eda074e91ddd Use G_DIR_SEPARATOR_S where applicable.
zas_
parents: 673
diff changeset
921 const gchar *path = G_DIR_SEPARATOR_S;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
922 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
923
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
924
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
925 fd = file_data_new_simple(path);
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
926 vdtree_add_by_data(vd, fd, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
927
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
928 vdtree_expand_by_data(vd, fd, TRUE);
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
929 vdtree_populate_path(vd, fd, FALSE, FALSE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
930 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
931
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
932 static gboolean vdtree_destroy_node_cb(GtkTreeModel *store, GtkTreePath *tpath, GtkTreeIter *iter, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
933 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
934 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
935
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
936 gtk_tree_model_get(store, iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
937 vdtree_node_free(nd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
938
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
939 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
940 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
941
401
0a2e1b130a25 Add some wrappers in view_dir.c and simplify even more.
zas_
parents: 397
diff changeset
942 void vdtree_destroy_cb(GtkWidget *widget, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
943 {
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
944 ViewDir *vd = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
945 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
946
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
947 vdtree_dnd_drop_expand_cancel(vd);
394
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 389
diff changeset
948 vd_dnd_drop_scroll_cancel(vd);
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
949 widget_auto_scroll_stop(vd->view);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
950
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
951 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view));
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
952 gtk_tree_model_foreach(store, vdtree_destroy_node_cb, vd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
953 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
954
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
955 ViewDir *vdtree_new(ViewDir *vd, FileData *dir_fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
956 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
957 GtkTreeStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
958 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
959 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
960 GtkCellRenderer *renderer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
961
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
962 vd->info = g_new0(ViewDirInfoTree, 1);
1365
249bf204004a When g_new0() is used, drop redundant initializations to NULL, FALSE or 0.
zas_
parents: 1284
diff changeset
963
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
964 vd->type = DIRVIEW_TREE;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 407
diff changeset
965
407
3a9074e73f53 Rename vd_drop_update() to vd_dnd_drop_update().
zas_
parents: 406
diff changeset
966 vd->dnd_drop_leave_func = vdtree_dnd_drop_expand_cancel;
3a9074e73f53 Rename vd_drop_update() to vd_dnd_drop_update().
zas_
parents: 406
diff changeset
967 vd->dnd_drop_update_func = vdtree_dnd_drop_expand;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
968
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
969 store = gtk_tree_store_new(4, G_TYPE_POINTER, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT);
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
970 vd->view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
971 g_object_unref(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
972
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
973 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(vd->view), FALSE);
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
974 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(vd->view), FALSE);
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
975 gtk_tree_sortable_set_default_sort_func(GTK_TREE_SORTABLE(store), vdtree_sort_cb, vd, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
976 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
977 GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, GTK_SORT_ASCENDING);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
978
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
979 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vd->view));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
980 gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
981 gtk_tree_selection_set_select_function(selection, vdtree_select_cb, vd, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
982
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
983 column = gtk_tree_view_column_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
984 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
985
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
986 renderer = gtk_cell_renderer_pixbuf_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
987 gtk_tree_view_column_pack_start(column, renderer, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
988 gtk_tree_view_column_add_attribute(column, renderer, "pixbuf", DIR_COLUMN_ICON);
396
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
989 gtk_tree_view_column_set_cell_data_func(column, renderer, vd_color_cb, vd, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
990
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
991 renderer = gtk_cell_renderer_text_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
992 gtk_tree_view_column_pack_start(column, renderer, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
993 gtk_tree_view_column_add_attribute(column, renderer, "text", DIR_COLUMN_NAME);
396
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
994 gtk_tree_view_column_set_cell_data_func(column, renderer, vd_color_cb, vd, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
995
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
996 gtk_tree_view_append_column(GTK_TREE_VIEW(vd->view), column);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
997
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
998 vdtree_setup_root(vd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
999
405
7840ccc95aee Fix forgotten vd->pf affectation.
zas_
parents: 401
diff changeset
1000 g_signal_connect(G_OBJECT(vd->view), "row_expanded",
7840ccc95aee Fix forgotten vd->pf affectation.
zas_
parents: 401
diff changeset
1001 G_CALLBACK(vdtree_row_expanded), vd);
7840ccc95aee Fix forgotten vd->pf affectation.
zas_
parents: 401
diff changeset
1002 g_signal_connect(G_OBJECT(vd->view), "row_collapsed",
7840ccc95aee Fix forgotten vd->pf affectation.
zas_
parents: 401
diff changeset
1003 G_CALLBACK(vdtree_row_collapsed), vd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1004
382
eceeced4cbb9 Rename vdt occurences to vd.
zas_
parents: 380
diff changeset
1005 return vd;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1006 }
1055
1646720364cf Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents: 995
diff changeset
1007 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */