annotate src/view_dir_tree.c @ 372:8ce8d565c038

Add and use few new macros in rc file writing code.
author zas_
date Tue, 15 Apr 2008 20:00:27 +0000
parents 673d1eb5af73
children 5afe77bb563a
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
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
4 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
5 * Author: John Ellis
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
6 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
7 * This software is released under the GNU General Public License (GNU GPL).
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
8 * Please read the included file COPYING for more information.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
9 * 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
10 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
11
281
9995c5fb202a gqview.h -> main.h
zas_
parents: 250
diff changeset
12 #include "main.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
13 #include "view_dir_tree.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
14
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 #include "dnd.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
17 #include "dupe.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
18 #include "filelist.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
19 #include "layout.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
20 #include "layout_image.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
21 #include "layout_util.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
22 #include "utilops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
23 #include "ui_bookmark.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"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
27
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
28 #include <gdk/gdkkeysyms.h> /* for keyboard values */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
29
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 #define VDTREE_INDENT 14
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
32 #define VDTREE_PAD 4
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 enum {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
35 DIR_COLUMN_POINTER = 0,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
36 DIR_COLUMN_ICON,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
37 DIR_COLUMN_NAME,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
38 DIR_COLUMN_COLOR,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
39 DIR_COLUMN_COUNT
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
43 typedef struct _PathData PathData;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
44 struct _PathData
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 gchar *name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
47 FileData *node;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
48 };
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 typedef struct _NodeData NodeData;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
51 struct _NodeData
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
52 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
53 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
54 gint expanded;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
55 time_t last_update;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
56 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
57
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
58
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
59 static gint vdtree_populate_path_by_iter(ViewDirTree *vdt, GtkTreeIter *iter, gint force, const gchar *target_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
60 static FileData *vdtree_populate_path(ViewDirTree *vdt, const gchar *path, gint expand, gint force);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
61
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 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
64 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
65 * utils
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
66 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
67 */
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 static void set_cursor(GtkWidget *widget, GdkCursorType cursor_type)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
70 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
71 GdkCursor *cursor = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
72
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
73 if (!widget || !widget->window) return;
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 if (cursor_type > -1) cursor = gdk_cursor_new (cursor_type);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
76 gdk_window_set_cursor (widget->window, cursor);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
77 if (cursor) gdk_cursor_unref(cursor);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
78 gdk_flush();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
79 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
80
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
81 static void vdtree_busy_push(ViewDirTree *vdt)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
82 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
83 if (vdt->busy_ref == 0) set_cursor(vdt->treeview, GDK_WATCH);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
84 vdt->busy_ref++;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
87 static void vdtree_busy_pop(ViewDirTree *vdt)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
88 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
89 if (vdt->busy_ref == 1) set_cursor(vdt->treeview, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
90 if (vdt->busy_ref > 0) vdt->busy_ref--;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
93 static gint vdtree_find_row(ViewDirTree *vdt, FileData *fd, GtkTreeIter *iter, GtkTreeIter *parent)
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 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
96 gint valid;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
97
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
98 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
99 if (parent)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
100 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
101 valid = gtk_tree_model_iter_children(store, iter, parent);
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
104 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
105 valid = gtk_tree_model_get_iter_first(store, iter);
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 while (valid)
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 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
110 GtkTreeIter found;
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 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
113 if (nd->fd == fd) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
114
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
115 if (vdtree_find_row(vdt, fd, &found, iter))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
116 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
117 memcpy(iter, &found, sizeof(found));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
118 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
119 }
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 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
122 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
123
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
124 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
125 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
126
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
127 static void vdtree_icon_set_by_iter(ViewDirTree *vdt, GtkTreeIter *iter, GdkPixbuf *pixbuf)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
128 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
129 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
130 GdkPixbuf *old;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
131
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
132 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
133 gtk_tree_model_get(store, iter, DIR_COLUMN_ICON, &old, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
134 if (old != vdt->pf->deny)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
135 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
136 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
137 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
138 }
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 static void vdtree_expand_by_iter(ViewDirTree *vdt, GtkTreeIter *iter, gint expand)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
141 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
142 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
143 GtkTreePath *tpath;
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 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
146 tpath = gtk_tree_model_get_path(store, iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
147 if (expand)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
148 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
149 gtk_tree_view_expand_row(GTK_TREE_VIEW(vdt->treeview), tpath, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
150 vdtree_icon_set_by_iter(vdt, iter, vdt->pf->open);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
151 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
152 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
153 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
154 gtk_tree_view_collapse_row(GTK_TREE_VIEW(vdt->treeview), tpath);
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 gtk_tree_path_free(tpath);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
159 static void vdtree_expand_by_data(ViewDirTree *vdt, FileData *fd, gint expand)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
160 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
161 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
162
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
163 if (vdtree_find_row(vdt, fd, &iter, NULL))
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 vdtree_expand_by_iter(vdt, &iter, expand);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
169 static void vdtree_color_set(ViewDirTree *vdt, FileData *fd, gint color_set)
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 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
172 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
173
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
174 if (!vdtree_find_row(vdt, fd, &iter, NULL)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
175 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
176 gtk_tree_store_set(GTK_TREE_STORE(store), &iter, DIR_COLUMN_COLOR, color_set, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
177 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
178
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
179 static gint vdtree_rename_row_cb(TreeEditData *td, const gchar *old, const gchar *new, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
180 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
181 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
182 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
183 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
184 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
185 gchar *old_path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
186 gchar *new_path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
187 gchar *base;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
188
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
189 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
190 if (!gtk_tree_model_get_iter(store, &iter, td->path)) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
191 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
192 if (!nd) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
193
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
194 old_path = g_strdup(nd->fd->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
195
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
196 base = remove_level_from_path(old_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
197 new_path = concat_dir_and_file(base, new);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
198 g_free(base);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
199
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
200 if (file_util_rename_dir(nd->fd, new_path, vdt->treeview))
9
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 vdtree_populate_path(vdt, new_path, TRUE, TRUE);
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 if (vdt->layout && strcmp(vdt->path, old_path) == 0)
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 layout_set_path(vdt->layout, new_path);
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 }
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 g_free(old_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
211 g_free(new_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
212
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
213 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
214 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
215
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
216 static void vdtree_rename_by_data(ViewDirTree *vdt, FileData *fd)
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 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
219 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
220 GtkTreeIter iter;
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 if (!fd ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
223 !vdtree_find_row(vdt, fd, &iter, NULL)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
224
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
225 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
226 tpath = gtk_tree_model_get_path(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
227
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
228 tree_edit_by_path(GTK_TREE_VIEW(vdt->treeview), tpath, 0, fd->name,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
229 vdtree_rename_row_cb, vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
230 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
231 }
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 static void vdtree_node_free(NodeData *nd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
234 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
235 if (!nd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
236
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
237 file_data_unref(nd->fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
238 g_free(nd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
239 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
240
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
241 static void vdtree_popup_destroy_cb(GtkWidget *widget, gpointer data)
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 ViewDirTree *vdt = data;
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 vdtree_color_set(vdt, vdt->click_fd, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
246 vdt->click_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
247 vdt->popup = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
248
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
249 vdtree_color_set(vdt, vdt->drop_fd, FALSE);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
250 filelist_free(vdt->drop_list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
251 vdt->drop_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
252 vdt->drop_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
253 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
254
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 * drop menu (from dnd)
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 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
260
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
261 static void vdtree_drop_menu_copy_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
262 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
263 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
264 const gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
265 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
266
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
267 if (!vdt->drop_fd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
268
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
269 path = vdt->drop_fd->path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
270 list = vdt->drop_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
271
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
272 vdt->drop_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
273
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
274 file_util_copy_simple(list, path);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
277 static void vdtree_drop_menu_move_cb(GtkWidget *widget, gpointer 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 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
280 const gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
281 GList *list;
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 if (!vdt->drop_fd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
284
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
285 path = vdt->drop_fd->path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
286 list = vdt->drop_list;
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 vdt->drop_list = NULL;
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 file_util_move_simple(list, path);
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 static GtkWidget *vdtree_drop_menu(ViewDirTree *vdt, gint active)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
294 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
295 GtkWidget *menu;
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 menu = popup_menu_short_lived();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
298 g_signal_connect(G_OBJECT(menu), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
299 G_CALLBACK(vdtree_popup_destroy_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
300
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
301 menu_item_add_stock_sensitive(menu, _("_Copy"), GTK_STOCK_COPY, active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
302 G_CALLBACK(vdtree_drop_menu_copy_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
303 menu_item_add_sensitive(menu, _("_Move"), active, G_CALLBACK(vdtree_drop_menu_move_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
304
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
305 menu_item_add_divider(menu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
306 menu_item_add_stock(menu, _("Cancel"), GTK_STOCK_CANCEL, NULL, vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
307
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
308 return menu;
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 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
313 * pop-up menu
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
317 static void vdtree_pop_menu_up_cb(GtkWidget *widget, 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 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
320 gchar *path;
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 if (!vdt->path || strcmp(vdt->path, "/") == 0) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
323 path = remove_level_from_path(vdt->path);
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 (vdt->select_func)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
326 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
327 vdt->select_func(vdt, path, vdt->select_data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
328 }
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 g_free(path);
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 static void vdtree_pop_menu_slide_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
334 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
335 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
336 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
337
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
338 if (!vdt->layout) return;
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 if (!vdt->click_fd) return;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
341 path = vdt->click_fd->path;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
342
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
343 layout_set_path(vdt->layout, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
344 layout_select_none(vdt->layout);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
345 layout_image_slideshow_stop(vdt->layout);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
346 layout_image_slideshow_start(vdt->layout);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
347 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
348
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
349 static void vdtree_pop_menu_slide_rec_cb(GtkWidget *widget, gpointer data)
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 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
352 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
353 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
354
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
355 if (!vdt->layout) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
356
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
357 if (!vdt->click_fd) return;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
358 path = vdt->click_fd->path;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
359
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
360 list = filelist_recursive(path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
361
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
362 layout_image_slideshow_stop(vdt->layout);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
363 layout_image_slideshow_start_from_list(vdt->layout, list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
364 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
365
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
366 static void vdtree_pop_menu_dupe(ViewDirTree *vdt, gint recursive)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
367 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
368 DupeWindow *dw;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
369 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
370
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
371 if (!vdt->click_fd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
372
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
373 if (recursive)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
374 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
375 list = g_list_append(list, file_data_ref(vdt->click_fd));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
376 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
377 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
378 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
379 filelist_read(vdt->click_fd->path, &list, NULL);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
380 list = filelist_filter(list, FALSE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
381 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
382
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
383 dw = dupe_window_new(DUPE_MATCH_NAME);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
384 dupe_window_add_files(dw, list, recursive);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
385
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
386 filelist_free(list);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
389 static void vdtree_pop_menu_dupe_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
390 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
391 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
392 vdtree_pop_menu_dupe(vdt, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
393 }
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 static void vdtree_pop_menu_dupe_rec_cb(GtkWidget *widget, gpointer data)
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 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
398 vdtree_pop_menu_dupe(vdt, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
399 }
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 static void vdtree_pop_menu_new_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
402 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
403 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
404 const gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
405 gchar *new_path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
406 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
407
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
408 if (!vdt->click_fd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
409 path = vdt->click_fd->path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
410
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
411 buf = concat_dir_and_file(path, _("new_folder"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
412 new_path = unique_filename(buf, NULL, NULL, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
413 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
414 if (!new_path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
415
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
416 if (!mkdir_utf8(new_path, 0755))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
417 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
418 gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
419
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
420 text = g_strdup_printf(_("Unable to create folder:\n%s"), new_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
421 file_util_warning_dialog(_("Error creating folder"), text, GTK_STOCK_DIALOG_ERROR, vdt->treeview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
422 g_free(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
423 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
424 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
425 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
426 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
427
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
428 fd = vdtree_populate_path(vdt, new_path, TRUE, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
429
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
430 vdtree_rename_by_data(vdt, fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
431 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
432
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
433 g_free(new_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
434 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
435
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
436 static void vdtree_pop_menu_rename_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
437 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
438 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
439
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
440 vdtree_rename_by_data(vdt, vdt->click_fd);
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
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
443 static void vdtree_pop_menu_delete_cb(GtkWidget *widget, gpointer data)
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
444 {
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
445 ViewDirTree *vdt = data;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
446
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
447 if (!vdt->click_fd) return;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
448 file_util_delete_dir(vdt->click_fd, vdt->widget);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
449 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
450
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
451 static void vdtree_pop_menu_tree_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
452 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
453 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
454
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
455 if (vdt->layout) layout_views_set(vdt->layout, FALSE, vdt->layout->icon_view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
456 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
457
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
458 static void vdtree_pop_menu_refresh_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
459 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
460 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
461
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
462 if (vdt->layout) layout_refresh(vdt->layout);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
463 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
464
356
673d1eb5af73 Rename show_dot_files to show_hidden_files.
zas_
parents: 355
diff changeset
465 static void vdtree_toggle_show_hidden_files_cb(GtkWidget *widget, gpointer data)
355
0b82646e977f Let toggle the visibility of hidden files from directories list
zas_
parents: 332
diff changeset
466 {
0b82646e977f Let toggle the visibility of hidden files from directories list
zas_
parents: 332
diff changeset
467 ViewDirTree *vdt = data;
0b82646e977f Let toggle the visibility of hidden files from directories list
zas_
parents: 332
diff changeset
468
356
673d1eb5af73 Rename show_dot_files to show_hidden_files.
zas_
parents: 355
diff changeset
469 options->file_filter.show_hidden_files = !options->file_filter.show_hidden_files;
355
0b82646e977f Let toggle the visibility of hidden files from directories list
zas_
parents: 332
diff changeset
470 if (vdt->layout) layout_refresh(vdt->layout);
0b82646e977f Let toggle the visibility of hidden files from directories list
zas_
parents: 332
diff changeset
471 }
0b82646e977f Let toggle the visibility of hidden files from directories list
zas_
parents: 332
diff changeset
472
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
473 static GtkWidget *vdtree_pop_menu(ViewDirTree *vdt, FileData *fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
474 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
475 GtkWidget *menu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
476 gint active;
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
477 gint parent_active = FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
478
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
479 active = (fd != NULL);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
480 if (fd)
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
481 {
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
482 gchar *parent;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
483
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
484 parent = remove_level_from_path(fd->path);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
485 parent_active = access_file(parent, W_OK | X_OK);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
486 g_free(parent);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
487 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
488
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
489 menu = popup_menu_short_lived();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
490 g_signal_connect(G_OBJECT(menu), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
491 G_CALLBACK(vdtree_popup_destroy_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
492
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
493 menu_item_add_stock_sensitive(menu, _("_Up to parent"), GTK_STOCK_GO_UP,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
494 (vdt->path && strcmp(vdt->path, "/") != 0),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
495 G_CALLBACK(vdtree_pop_menu_up_cb), vdt);
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 menu_item_add_divider(menu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
498 menu_item_add_sensitive(menu, _("_Slideshow"), active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
499 G_CALLBACK(vdtree_pop_menu_slide_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
500 menu_item_add_sensitive(menu, _("Slideshow recursive"), active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
501 G_CALLBACK(vdtree_pop_menu_slide_rec_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
502
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
503 menu_item_add_divider(menu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
504 menu_item_add_stock_sensitive(menu, _("Find _duplicates..."), GTK_STOCK_FIND, active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
505 G_CALLBACK(vdtree_pop_menu_dupe_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
506 menu_item_add_stock_sensitive(menu, _("Find duplicates recursive..."), GTK_STOCK_FIND, active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
507 G_CALLBACK(vdtree_pop_menu_dupe_rec_cb), vdt);
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 menu_item_add_divider(menu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
510
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
511 active = (fd &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
512 access_file(fd->path, W_OK | X_OK));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
513 menu_item_add_sensitive(menu, _("_New folder..."), active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
514 G_CALLBACK(vdtree_pop_menu_new_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
515
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
516 menu_item_add_sensitive(menu, _("_Rename..."), parent_active,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
517 G_CALLBACK(vdtree_pop_menu_rename_cb), vdt);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
518 menu_item_add_stock_sensitive(menu, _("_Delete..."), GTK_STOCK_DELETE, parent_active,
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
519 G_CALLBACK(vdtree_pop_menu_delete_cb), vdt);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
520
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
521 menu_item_add_divider(menu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
522 menu_item_add_check(menu, _("View as _tree"), TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
523 G_CALLBACK(vdtree_pop_menu_tree_cb), vdt);
356
673d1eb5af73 Rename show_dot_files to show_hidden_files.
zas_
parents: 355
diff changeset
524 menu_item_add_check(menu, _("Show _hidden files"), options->file_filter.show_hidden_files,
673d1eb5af73 Rename show_dot_files to show_hidden_files.
zas_
parents: 355
diff changeset
525 G_CALLBACK(vdtree_toggle_show_hidden_files_cb), vdt);
355
0b82646e977f Let toggle the visibility of hidden files from directories list
zas_
parents: 332
diff changeset
526
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
527 menu_item_add_stock(menu, _("Re_fresh"), GTK_STOCK_REFRESH,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
528 G_CALLBACK(vdtree_pop_menu_refresh_cb), vdt);
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 return menu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
531 }
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 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
534 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
535 * dnd
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 */
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 static GtkTargetEntry vdtree_dnd_drop_types[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
540 { "text/uri-list", 0, TARGET_URI_LIST }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
541 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
542 static gint vdtree_dnd_drop_types_count = 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
543
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
544
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
545 static void vdtree_dest_set(ViewDirTree *vdt, gint enable)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
546 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
547 if (enable)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
548 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
549 gtk_drag_dest_set(vdt->treeview,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
550 GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
551 vdtree_dnd_drop_types, vdtree_dnd_drop_types_count,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
552 GDK_ACTION_MOVE | GDK_ACTION_COPY);
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 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
556 gtk_drag_dest_unset(vdt->treeview);
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 static void vdtree_dnd_get(GtkWidget *widget, GdkDragContext *context,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
561 GtkSelectionData *selection_data, guint info,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
562 guint time, gpointer data)
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 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
565 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
566 gchar *uri_text = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
567 gint length = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
568
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
569 if (!vdt->click_fd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
570
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
571 switch (info)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
572 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
573 case TARGET_URI_LIST:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
574 case TARGET_TEXT_PLAIN:
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
575 list = g_list_prepend(NULL, vdt->click_fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
576 uri_text = uri_text_from_filelist(list, &length, (info == TARGET_TEXT_PLAIN));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
577 g_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
578 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
579 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
580
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
581 if (uri_text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
582 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
583 gtk_selection_data_set(selection_data, selection_data->target,
64
04ff0df3ad2f Mon Aug 15 17:13:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 63
diff changeset
584 8, (guchar *)uri_text, length);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
585 g_free(uri_text);
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 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
588
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
589 static void vdtree_dnd_begin(GtkWidget *widget, GdkDragContext *context, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
590 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
591 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
592
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
593 vdtree_color_set(vdt, vdt->click_fd, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
594 vdtree_dest_set(vdt, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
595 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
596
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
597 static void vdtree_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
598 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
599 ViewDirTree *vdt = data;
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 vdtree_color_set(vdt, vdt->click_fd, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
602 vdtree_dest_set(vdt, TRUE);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
605 static void vdtree_dnd_drop_receive(GtkWidget *widget,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
606 GdkDragContext *context, gint x, gint y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
607 GtkSelectionData *selection_data, guint info,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
608 guint time, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
609 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
610 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
611 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
612 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
613 FileData *fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
614
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
615 vdt->click_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
616
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
617 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), x, y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
618 &tpath, NULL, NULL, 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 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
621 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
622
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
623 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
624 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
625 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
626 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
627
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
628 fd = (nd) ? nd->fd : NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
629 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
630
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
631 if (!fd) return;
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 if (info == TARGET_URI_LIST)
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 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
636 gint active;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
637
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
638 list = uri_filelist_from_text((gchar *)selection_data->data, TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
639 if (!list) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
640
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
641 active = access_file(fd->path, W_OK | X_OK);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
642
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
643 vdtree_color_set(vdt, fd, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
644 vdt->popup = vdtree_drop_menu(vdt, active);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
645 gtk_menu_popup(GTK_MENU(vdt->popup), NULL, NULL, NULL, NULL, 0, time);
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 vdt->drop_fd = fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
648 vdt->drop_list = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
649 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
650 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
651
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
652 static gint vdtree_dnd_drop_expand_cb(gpointer data)
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 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
655 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
656
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
657 if (vdt->drop_fd &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
658 vdtree_find_row(vdt, vdt->drop_fd, &iter, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
659 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
660 vdtree_populate_path_by_iter(vdt, &iter, FALSE, vdt->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
661 vdtree_expand_by_data(vdt, vdt->drop_fd, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
662 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
663
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
664 vdt->drop_expand_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
665 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
666 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
667
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
668 static void vdtree_dnd_drop_expand_cancel(ViewDirTree *vdt)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
669 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
670 if (vdt->drop_expand_id != -1) g_source_remove(vdt->drop_expand_id);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
671 vdt->drop_expand_id = -1;
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 static void vdtree_dnd_drop_expand(ViewDirTree *vdt)
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 vdtree_dnd_drop_expand_cancel(vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
677 vdt->drop_expand_id = g_timeout_add(1000, vdtree_dnd_drop_expand_cb, vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
678 }
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 void vdtree_drop_update(ViewDirTree *vdt, gint x, gint y)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
681 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
682 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
683 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
684 FileData *fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
685
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
686 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vdt->treeview), x, y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
687 &tpath, NULL, NULL, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
688 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
689 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
690 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
691
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
692 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
693 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
694 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
695 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
696
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
697 fd = (nd) ? nd->fd : NULL;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
700 if (fd != vdt->drop_fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
701 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
702 vdtree_color_set(vdt, vdt->drop_fd, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
703 vdtree_color_set(vdt, fd, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
704 if (fd) vdtree_dnd_drop_expand(vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
705 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
706
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
707 vdt->drop_fd = fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
708 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
709
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
710 static void vdtree_dnd_drop_scroll_cancel(ViewDirTree *vdt)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
711 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
712 if (vdt->drop_scroll_id != -1) g_source_remove(vdt->drop_scroll_id);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
713 vdt->drop_scroll_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
714 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
715
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
716 static gint vdtree_auto_scroll_idle_cb(gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
717 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
718 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
719
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
720 if (vdt->drop_fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
721 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
722 GdkWindow *window;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
723 gint x, y;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
724 gint w, h;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
725
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
726 window = vdt->treeview->window;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
727 gdk_window_get_pointer(window, &x, &y, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
728 gdk_drawable_get_size(window, &w, &h);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
729 if (x >= 0 && x < w && y >= 0 && y < h)
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 vdtree_drop_update(vdt, x, y);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
732 }
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 vdt->drop_scroll_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
736 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
737 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
738
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
739 static gint vdtree_auto_scroll_notify_cb(GtkWidget *widget, gint x, gint y, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
740 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
741 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
742
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
743 if (!vdt->drop_fd || vdt->drop_list) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
744
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
745 if (vdt->drop_scroll_id == -1) vdt->drop_scroll_id = g_idle_add(vdtree_auto_scroll_idle_cb, vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
746
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
747 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
748 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
749
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
750 static gint vdtree_dnd_drop_motion(GtkWidget *widget, GdkDragContext *context,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
751 gint x, gint y, guint time, gpointer data)
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 ViewDirTree *vdt = data;
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 vdt->click_fd = NULL;
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 if (gtk_drag_get_source_widget(context) == vdt->treeview)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
758 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
759 gdk_drag_status(context, 0, time);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
760 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
761 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
762 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
763 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
764 gdk_drag_status(context, context->suggested_action, time);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
765 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
766
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
767 vdtree_drop_update(vdt, x, y);
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 if (vdt->drop_fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
770 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
771 GtkAdjustment *adj = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
772 widget_auto_scroll_start(vdt->treeview, adj, -1, -1, vdtree_auto_scroll_notify_cb, vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
773 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
774
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
775 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
776 }
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 static void vdtree_dnd_drop_leave(GtkWidget *widget, GdkDragContext *context, guint time, gpointer data)
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 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
781
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
782 if (vdt->drop_fd != vdt->click_fd) vdtree_color_set(vdt, vdt->drop_fd, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
783
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
784 vdt->drop_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
785
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
786 vdtree_dnd_drop_expand_cancel(vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
787 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
788
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
789 static void vdtree_dnd_init(ViewDirTree *vdt)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
790 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
791 gtk_drag_source_set(vdt->treeview, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
792 dnd_file_drag_types, dnd_file_drag_types_count,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
793 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_ASK);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
794 g_signal_connect(G_OBJECT(vdt->treeview), "drag_data_get",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
795 G_CALLBACK(vdtree_dnd_get), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
796 g_signal_connect(G_OBJECT(vdt->treeview), "drag_begin",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
797 G_CALLBACK(vdtree_dnd_begin), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
798 g_signal_connect(G_OBJECT(vdt->treeview), "drag_end",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
799 G_CALLBACK(vdtree_dnd_end), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
800
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
801 vdtree_dest_set(vdt, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
802 g_signal_connect(G_OBJECT(vdt->treeview), "drag_data_received",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
803 G_CALLBACK(vdtree_dnd_drop_receive), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
804 g_signal_connect(G_OBJECT(vdt->treeview), "drag_motion",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
805 G_CALLBACK(vdtree_dnd_drop_motion), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
806 g_signal_connect(G_OBJECT(vdt->treeview), "drag_leave",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
807 G_CALLBACK(vdtree_dnd_drop_leave), vdt);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
810 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
811 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
812 * parts lists
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 */
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 static GList *parts_list(const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
817 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
818 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
819 const gchar *strb, *strp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
820 gint l;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
821
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
822 strp = path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
823
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
824 if (*strp != '/') return NULL;
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 strp++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
827 strb = strp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
828 l = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
829
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
830 while (*strp != '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
831 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
832 if (*strp == '/')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
833 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
834 if (l > 0) list = g_list_prepend(list, g_strndup(strb, l));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
835 strp++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
836 strb = strp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
837 l = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
838 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
839 else
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 strp++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
842 l++;
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 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
845 if (l > 0) list = g_list_prepend(list, g_strndup(strb, l));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
846
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
847 list = g_list_reverse(list);
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 list = g_list_prepend(list, g_strdup("/"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
850
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
851 return list;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
854 static void parts_list_free(GList *list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
855 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
856 GList *work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
857 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
858 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
859 PathData *pd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
860 g_free(pd->name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
861 g_free(pd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
862 work = work->next;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
865 g_list_free(list);
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 static GList *parts_list_add_node_points(ViewDirTree *vdt, GList *list)
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 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
871 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
872 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
873 gint valid;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
874
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
875 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
876 valid = gtk_tree_model_get_iter_first(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
877
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
878 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
879 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
880 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
881 PathData *pd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
882 FileData *fd = NULL;
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 pd = g_new0(PathData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
885 pd->name = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
886
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
887 while (valid && !fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
888 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
889 NodeData *nd;
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 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
892 if (strcmp(nd->fd->name, pd->name) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
893 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
894 fd = nd->fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
895 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
896 else
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 valid = gtk_tree_model_iter_next(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
899 }
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
902 pd->node = fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
903 work->data = pd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
904
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
905 if (fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
906 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
907 GtkTreeIter parent;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
908 memcpy(&parent, &iter, sizeof(parent));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
909 valid = gtk_tree_model_iter_children(store, &iter, &parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
910 }
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 work = work->next;
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 return list;
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 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
919 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
920 * misc
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
921 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
922 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
923
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
924 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
925 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
926 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
927 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
928 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
929
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
930 gtk_tree_model_get_iter(tree_model, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
931 gtk_tree_model_get(tree_model, &iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
932
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
933 if (!nd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
934
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
935 file_data_unref(nd->fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
936 g_free(nd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
937 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
938 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
939
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 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
942 * node traversal, management
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
943 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
944 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
945
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
946 static gint vdtree_find_iter_by_data(ViewDirTree *vdt, GtkTreeIter *parent, NodeData *nd, GtkTreeIter *iter)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
947 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
948 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
949
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
950 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
951 if (!nd || !gtk_tree_model_iter_children(store, iter, parent)) return -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
952 do {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
953 NodeData *cnd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
954
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
955 gtk_tree_model_get(store, iter, DIR_COLUMN_POINTER, &cnd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
956 if (cnd == nd) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
957 } while (gtk_tree_model_iter_next(store, iter));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
958
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
959 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
960 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
961
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
962 static NodeData *vdtree_find_iter_by_name(ViewDirTree *vdt, GtkTreeIter *parent, const gchar *name, GtkTreeIter *iter)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
963 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
964 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
965
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
966 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
967 if (!name || !gtk_tree_model_iter_children(store, iter, parent)) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
968 do {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
969 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
970
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
971 gtk_tree_model_get(store, iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
972 if (nd && strcmp(nd->fd->name, name) == 0) return nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
973 } while (gtk_tree_model_iter_next(store, iter));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
974
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
975 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
976 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
977
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
978 static void vdtree_add_by_data(ViewDirTree *vdt, FileData *fd, GtkTreeIter *parent)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
979 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
980 GtkTreeStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
981 GtkTreeIter child;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
982 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
983 GdkPixbuf *pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
984 NodeData *end;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
985 GtkTreeIter empty;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
986
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
987 if (!fd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
988
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
989 if (access_file(fd->path, R_OK | X_OK))
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 pixbuf = vdt->pf->close;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
992 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
993 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
994 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
995 pixbuf = vdt->pf->deny;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
996 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
997
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
998 nd = g_new0(NodeData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
999 nd->fd = fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1000 nd->expanded = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1001 nd->last_update = time(NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1002
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1003 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1004 gtk_tree_store_append(store, &child, parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1005 gtk_tree_store_set(store, &child, DIR_COLUMN_POINTER, nd,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1006 DIR_COLUMN_ICON, pixbuf,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1007 DIR_COLUMN_NAME, nd->fd->name,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1008 DIR_COLUMN_COLOR, FALSE, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1009
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1010 /* 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
1011 * this is removed when the child is populated */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1012 end = g_new0(NodeData, 1);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
1013 end->fd = file_data_new_simple("");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1014 end->expanded = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1015
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1016 gtk_tree_store_append(store, &empty, &child);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1017 gtk_tree_store_set(store, &empty, DIR_COLUMN_POINTER, end,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1018 DIR_COLUMN_NAME, "empty", -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1019
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1020 if (parent)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1021 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1022 NodeData *pnd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1023 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1024
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1025 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
1026 tpath = gtk_tree_model_get_path(GTK_TREE_MODEL(store), parent);
320
c74af1cbd61a Move more options to ConfOptions.
zas_
parents: 318
diff changeset
1027 if (options->tree_descend_subdirs &&
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1028 gtk_tree_view_row_expanded(GTK_TREE_VIEW(vdt->treeview), tpath) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1029 !nd->expanded)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1030 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1031 vdtree_populate_path_by_iter(vdt, &child, FALSE, vdt->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1032 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1033 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1034 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1035 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1036
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1037 static gint vdtree_populate_path_by_iter(ViewDirTree *vdt, GtkTreeIter *iter, gint force, const gchar *target_path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1038 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1039 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1040 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1041 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1042 GList *old;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1043 time_t current_time;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1044 GtkTreeIter child;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1045 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1046
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1047 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1048 gtk_tree_model_get(store, iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1049
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1050 if (!nd) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1051
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1052 current_time = time(NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1053
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1054 if (nd->expanded)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1055 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1056 if (!force && current_time - nd->last_update < 10) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1057 if (!isdir(nd->fd->path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1058 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1059 if (vdt->click_fd == nd->fd) vdt->click_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1060 if (vdt->drop_fd == nd->fd) vdt->drop_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1061 gtk_tree_store_remove(GTK_TREE_STORE(store), iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1062 vdtree_node_free(nd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1063 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1064 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1065 if (!force && filetime(nd->fd->path) == nd->fd->date) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1066 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1067
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1068 vdtree_busy_push(vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1069
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1070 list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1071 filelist_read(nd->fd->path, NULL, &list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1072
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1073 /* 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
1074 * 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
1075 */
356
673d1eb5af73 Rename show_dot_files to show_hidden_files.
zas_
parents: 355
diff changeset
1076 if (!options->file_filter.show_hidden_files &&
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1077 target_path &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1078 strncmp(nd->fd->path, target_path, strlen(nd->fd->path)) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1079 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1080 gint n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1081
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1082 n = strlen(nd->fd->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1083 if (target_path[n] == '/' && target_path[n+1] == '.')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1084 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1085 gchar *name8;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1086 struct stat sbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1087
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1088 n++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1089
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1090 while (target_path[n] != '\0' && target_path[n] != '/') n++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1091 name8 = g_strndup(target_path, n);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1092
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1093 if (stat_utf8(name8, &sbuf))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1094 {
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 138
diff changeset
1095 list = g_list_prepend(list, file_data_new_simple(name8));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1096 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1097
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1098 g_free(name8);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1099 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1100 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1101
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1102 old = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1103 if (gtk_tree_model_iter_children(store, &child, iter))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1104 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1105 do {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1106 NodeData *cnd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1107
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1108 gtk_tree_model_get(store, &child, DIR_COLUMN_POINTER, &cnd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1109 old = g_list_prepend(old, cnd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1110 } while (gtk_tree_model_iter_next(store, &child));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1111 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1112
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1113 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1114 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1115 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1116 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1117
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1118 fd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1119 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1120
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1121 if (strcmp(fd->name, ".") == 0 || strcmp(fd->name, "..") == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1122 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
1123 file_data_unref(fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1124 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1125 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1126 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1127 NodeData *cnd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1128
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1129 cnd = vdtree_find_iter_by_name(vdt, iter, fd->name, &child);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1130 if (cnd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1131 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1132 old = g_list_remove(old, cnd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1133 if (cnd->expanded && cnd->fd->date != fd->date &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1134 vdtree_populate_path_by_iter(vdt, &child, FALSE, target_path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1135 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1136 cnd->fd->size = fd->size;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1137 cnd->fd->date = fd->date;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1138 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1139
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
1140 file_data_unref(fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1141 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1142 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1143 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1144 vdtree_add_by_data(vdt, fd, iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1145 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1146 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1147 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1148
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1149 work = old;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1150 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1151 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1152 NodeData *cnd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1153 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1154
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1155 if (vdt->click_fd == cnd->fd) vdt->click_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1156 if (vdt->drop_fd == cnd->fd) vdt->drop_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1157
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1158 if (vdtree_find_iter_by_data(vdt, iter, cnd, &child))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1159 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1160 gtk_tree_store_remove(GTK_TREE_STORE(store), &child);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1161 vdtree_node_free(cnd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1162 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1163 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1164
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1165 g_list_free(old);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1166 g_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1167
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1168 vdtree_busy_pop(vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1169
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1170 nd->expanded = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1171 nd->last_update = current_time;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1172
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1173 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1174 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1175
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1176 static FileData *vdtree_populate_path(ViewDirTree *vdt, const gchar *path, gint expand, gint force)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1177 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1178 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1179 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1180 FileData *fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1181
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1182 if (!path) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1183
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1184 vdtree_busy_push(vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1185
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1186 list = parts_list(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1187 list = parts_list_add_node_points(vdt, list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1188
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1189 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1190 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1191 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1192 PathData *pd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1193 if (pd->node == NULL)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1194 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1195 PathData *parent_pd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1196 GtkTreeIter parent_iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1197 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1198 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1199
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1200 if (work == list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1201 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1202 /* should not happen */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1203 printf("vdtree warning, root node not found\n");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1204 parts_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1205 vdtree_busy_pop(vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1206 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1207 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1208
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1209 parent_pd = work->prev->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1210
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1211 if (!vdtree_find_row(vdt, parent_pd->node, &parent_iter, NULL) ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1212 !vdtree_populate_path_by_iter(vdt, &parent_iter, force, path) ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1213 (nd = vdtree_find_iter_by_name(vdt, &parent_iter, pd->name, &iter)) == NULL)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1214 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1215 printf("vdtree warning, aborted at %s\n", parent_pd->name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1216 parts_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1217 vdtree_busy_pop(vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1218 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1219 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1220
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1221 pd->node = nd->fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1222
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1223 if (pd->node)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1224 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1225 if (expand)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1226 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1227 vdtree_expand_by_iter(vdt, &parent_iter, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1228 vdtree_expand_by_iter(vdt, &iter, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1229 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1230 vdtree_populate_path_by_iter(vdt, &iter, force, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1231 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1232 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1233 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1234 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1235 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1236
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1237 if (vdtree_find_row(vdt, pd->node, &iter, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1238 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1239 if (expand) vdtree_expand_by_iter(vdt, &iter, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1240 vdtree_populate_path_by_iter(vdt, &iter, force, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1241 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1242 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1243
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1244 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1245 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1246
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1247 work = g_list_last(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1248 if (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1249 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1250 PathData *pd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1251 fd = pd->node;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1252 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1253 parts_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1254
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1255 vdtree_busy_pop(vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1256
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1257 return fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1258 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1259
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1260 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1261 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1262 * access
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1263 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1264 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1265
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1266 static gint selection_is_ok = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1267
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1268 static gboolean vdtree_select_cb(GtkTreeSelection *selection, GtkTreeModel *store, GtkTreePath *tpath,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1269 gboolean path_currently_selected, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1270 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1271 return selection_is_ok;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1272 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1273
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1274 static void vdtree_select_row(ViewDirTree *vdt, FileData *fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1275 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1276 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1277 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1278
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1279 if (!vdtree_find_row(vdt, fd, &iter, NULL)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1280 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1281
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1282 /* hack, such that selection is only allowed to be changed from here */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1283 selection_is_ok = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1284 gtk_tree_selection_select_iter(selection, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1285 selection_is_ok = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1286
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1287 if (!vdtree_populate_path_by_iter(vdt, &iter, FALSE, vdt->path)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1288
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1289 vdtree_expand_by_iter(vdt, &iter, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1290
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1291 if (fd && vdt->select_func)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1292 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1293 vdt->select_func(vdt, fd->path, vdt->select_data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1294 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1295 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1296
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1297 gint vdtree_set_path(ViewDirTree *vdt, const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1298 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1299 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1300 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1301
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1302 if (!path) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1303 if (vdt->path && strcmp(path, vdt->path) == 0) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1304
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1305 g_free(vdt->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1306 vdt->path = g_strdup(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1307
63
e29c291e106b Mon Aug 15 16:35:15 2005 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1308 fd = vdtree_populate_path(vdt, vdt->path, TRUE, FALSE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1309
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1310 if (!fd) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1311
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1312 if (vdtree_find_row(vdt, fd, &iter, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1313 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1314 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1315 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1316
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1317 tree_view_row_make_visible(GTK_TREE_VIEW(vdt->treeview), &iter, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1318
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1319 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1320 tpath = gtk_tree_model_get_path(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1321 gtk_tree_view_set_cursor(GTK_TREE_VIEW(vdt->treeview), tpath, NULL, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1322 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1323
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1324 vdtree_select_row(vdt, fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1325 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1326
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1327 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1328 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1329
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1330 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1331 const gchar *vdtree_get_path(ViewDirTree *vdt)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1332 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1333 return vdt->path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1334 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1335 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1336
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1337 void vdtree_refresh(ViewDirTree *vdt)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1338 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1339 vdtree_populate_path(vdt, vdt->path, FALSE, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1340 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1341
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1342 const gchar *vdtree_row_get_path(ViewDirTree *vdt, gint row)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1343 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1344 printf("FIXME: no get row path\n");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1345 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1346 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1347
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1348 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1349 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1350 * callbacks
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1351 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1352 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1353
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1354 static void vdtree_menu_position_cb(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1355 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1356 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1357 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1358 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1359 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1360 gint cw, ch;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1361
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1362 if (vdtree_find_row(vdt, vdt->click_fd, &iter, NULL) < 0) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1363 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1364 tpath = gtk_tree_model_get_path(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1365 tree_view_get_cell_clamped(GTK_TREE_VIEW(vdt->treeview), tpath, 0, TRUE, x, y, &cw, &ch);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1366 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1367 *y += ch;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1368 popup_menu_position_clamp(menu, x, y, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1369 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1370
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1371 static gint vdtree_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1372 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1373 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1374 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1375 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1376 FileData *fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1377
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1378 gtk_tree_view_get_cursor(GTK_TREE_VIEW(vdt->treeview), &tpath, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1379 if (tpath)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1380 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1381 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1382 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1383
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1384 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1385 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1386 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1387
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1388 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1389
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1390 fd = (nd) ? nd->fd : NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1391 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1392
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1393 switch (event->keyval)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1394 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1395 case GDK_Menu:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1396 vdt->click_fd = fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1397 vdtree_color_set(vdt, vdt->click_fd, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1398
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1399 vdt->popup = vdtree_pop_menu(vdt, vdt->click_fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1400 gtk_menu_popup(GTK_MENU(vdt->popup), NULL, NULL, vdtree_menu_position_cb, vdt, 0, GDK_CURRENT_TIME);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1401
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1402 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1403 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1404 case GDK_plus:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1405 case GDK_Right:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1406 case GDK_KP_Add:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1407 if (fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1408 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1409 vdtree_populate_path_by_iter(vdt, &iter, FALSE, vdt->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1410 vdtree_icon_set_by_iter(vdt, &iter, vdt->pf->open);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1411 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1412 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1413 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1414
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1415 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1416 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1417
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1418 static gint vdtree_clicked_on_expander(GtkTreeView *treeview, GtkTreePath *tpath,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1419 GtkTreeViewColumn *column, gint x, gint y, gint *left_of_expander)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1420 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1421 gint depth;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1422 gint size;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1423 gint sep;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1424 gint exp_width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1425
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1426 if (column != gtk_tree_view_get_expander_column(treeview)) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1427
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1428 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
1429 depth = gtk_tree_path_get_depth(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1430
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1431 exp_width = sep + size + sep;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1432
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1433 if (x <= depth * exp_width)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1434 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1435 if (left_of_expander) *left_of_expander = !(x >= (depth - 1) * exp_width);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1436 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1437 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1438
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1439 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1440 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1441
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1442 static gint vdtree_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1443 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1444 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1445 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1446 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1447 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1448 NodeData *nd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1449
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1450 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
1451 &tpath, &column, NULL, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1452 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1453 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1454 gint left_of_expander;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1455
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1456 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1457 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1458 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1459 gtk_tree_view_set_cursor(GTK_TREE_VIEW(widget), tpath, NULL, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1460
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1461 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
1462 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1463 vdt->click_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1464
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1465 /* clicking this region should automatically reveal an expander, if necessary
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1466 * 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
1467 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1468 if (bevent->button == 1 &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1469 !left_of_expander &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1470 !gtk_tree_view_row_expanded(GTK_TREE_VIEW(vdt->treeview), tpath))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1471 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1472 vdtree_populate_path_by_iter(vdt, &iter, FALSE, vdt->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1473 vdtree_icon_set_by_iter(vdt, &iter, vdt->pf->open);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1474 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1475
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1476 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1477 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1478 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1479
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1480 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1481 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1482
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1483 vdt->click_fd = (nd) ? nd->fd : NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1484 vdtree_color_set(vdt, vdt->click_fd, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1485
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1486 if (bevent->button == 3)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1487 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1488 vdt->popup = vdtree_pop_menu(vdt, vdt->click_fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1489 gtk_menu_popup(GTK_MENU(vdt->popup), NULL, NULL, NULL, NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1490 bevent->button, bevent->time);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1491 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1492
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1493 return (bevent->button != 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1494 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1495
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1496 static gint vdtree_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1497 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1498 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1499 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1500 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1501 NodeData *nd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1502
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1503 if (!vdt->click_fd) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1504 vdtree_color_set(vdt, vdt->click_fd, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1505
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1506 if (bevent->button != 1) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1507
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1508 if ((bevent->x != 0 || bevent->y != 0) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1509 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
1510 &tpath, NULL, NULL, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1511 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1512 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1513
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1514 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1515 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1516 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1517 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1518 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1519
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1520 if (nd && vdt->click_fd == nd->fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1521 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1522 vdtree_select_row(vdt, vdt->click_fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1523 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1524
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1525 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1526 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1527
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1528 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
1529 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1530 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1531
25
0c3b353b666e Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
1532 vdtree_populate_path_by_iter(vdt, iter, FALSE, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1533 vdtree_icon_set_by_iter(vdt, iter, vdt->pf->open);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1534 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1535
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1536 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
1537 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1538 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1539
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1540 vdtree_icon_set_by_iter(vdt, iter, vdt->pf->close);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1541 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1542
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1543 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
1544 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1545 NodeData *nda;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1546 NodeData *ndb;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1547
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1548 gtk_tree_model_get(store, a, DIR_COLUMN_POINTER, &nda, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1549 gtk_tree_model_get(store, b, DIR_COLUMN_POINTER, &ndb, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1550
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1551 return CASE_SORT(nda->fd->name, ndb->fd->name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1552 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1553
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1554 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1555 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1556 * core
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1557 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1558 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1559
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1560 static void vdtree_setup_root(ViewDirTree *vdt)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1561 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1562 const gchar *path = "/";
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1563 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1564
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
1565
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
1566 fd = file_data_new_simple(path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1567 vdtree_add_by_data(vdt, fd, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1568
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1569 vdtree_expand_by_data(vdt, fd, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1570 vdtree_populate_path(vdt, path, FALSE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1571 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1572
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1573 static void vdtree_activate_cb(GtkTreeView *tview, GtkTreePath *tpath, GtkTreeViewColumn *column, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1574 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1575 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1576 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1577 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1578 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1579
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1580 store = gtk_tree_view_get_model(tview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1581 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1582 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1583
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1584 vdtree_select_row(vdt, nd->fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1585 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1586
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1587 static GdkColor *vdtree_color_shifted(GtkWidget *widget)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1588 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1589 static GdkColor color;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1590 static GtkWidget *done = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1591
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1592 if (done != widget)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1593 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1594 GtkStyle *style;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1595
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1596 style = gtk_widget_get_style(widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1597 memcpy(&color, &style->base[GTK_STATE_NORMAL], sizeof(color));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1598 shift_color(&color, -1, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1599 done = widget;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1600 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1601
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1602 return &color;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1603 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1604
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1605 static void vdtree_color_cb(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1606 GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1607 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1608 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1609 gboolean set;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1610
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1611 gtk_tree_model_get(tree_model, iter, DIR_COLUMN_COLOR, &set, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1612 g_object_set(G_OBJECT(cell),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1613 "cell-background-gdk", vdtree_color_shifted(vdt->treeview),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1614 "cell-background-set", set, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1615 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1616
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1617 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
1618 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1619 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1620
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1621 gtk_tree_model_get(store, iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1622 vdtree_node_free(nd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1623
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1624 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1625 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1626
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1627 static void vdtree_destroy_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1628 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1629 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1630 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1631
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1632 if (vdt->popup)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1633 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1634 g_signal_handlers_disconnect_matched(G_OBJECT(vdt->popup), G_SIGNAL_MATCH_DATA,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1635 0, 0, 0, NULL, vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1636 gtk_widget_destroy(vdt->popup);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1637 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1638
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1639 vdtree_dnd_drop_expand_cancel(vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1640 vdtree_dnd_drop_scroll_cancel(vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1641 widget_auto_scroll_stop(vdt->treeview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1642
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1643 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1644 gtk_tree_model_foreach(store, vdtree_destroy_node_cb, vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1645
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
1646 filelist_free(vdt->drop_list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1647
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1648 folder_icons_free(vdt->pf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1649
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1650 g_free(vdt->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1651 g_free(vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1652 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1653
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1654 ViewDirTree *vdtree_new(const gchar *path, gint expand)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1655 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1656 ViewDirTree *vdt;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1657 GtkTreeStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1658 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1659 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1660 GtkCellRenderer *renderer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1661
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1662 vdt = g_new0(ViewDirTree, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1663
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1664 vdt->path = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1665 vdt->click_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1666
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1667 vdt->drop_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1668 vdt->drop_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1669 vdt->drop_scroll_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1670 vdt->drop_expand_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1671
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1672 vdt->popup = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1673
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1674 vdt->busy_ref = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1675
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1676 vdt->widget = gtk_scrolled_window_new(NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1677 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(vdt->widget), GTK_SHADOW_IN);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1678 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(vdt->widget),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1679 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1680 g_signal_connect(G_OBJECT(vdt->widget), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1681 G_CALLBACK(vdtree_destroy_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1682
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1683 store = gtk_tree_store_new(4, G_TYPE_POINTER, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1684 vdt->treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1685 g_object_unref(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1686
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1687 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(vdt->treeview), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1688 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(vdt->treeview), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1689 gtk_tree_sortable_set_default_sort_func(GTK_TREE_SORTABLE(store), vdtree_sort_cb, vdt, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1690 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1691 GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, GTK_SORT_ASCENDING);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1692
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1693 g_signal_connect(G_OBJECT(vdt->treeview), "row_activated",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1694 G_CALLBACK(vdtree_activate_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1695 g_signal_connect(G_OBJECT(vdt->treeview), "row_expanded",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1696 G_CALLBACK(vdtree_row_expanded), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1697 g_signal_connect(G_OBJECT(vdt->treeview), "row_collapsed",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1698 G_CALLBACK(vdtree_row_collapsed), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1699 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1700 g_signal_connect(G_OBJECT(store), "row_deleted",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1701 G_CALLBACK(vdtree_row_deleted_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1702 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1703
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1704 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1705 gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1706 gtk_tree_selection_set_select_function(selection, vdtree_select_cb, vdt, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1707
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1708 column = gtk_tree_view_column_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1709 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
1710
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1711 renderer = gtk_cell_renderer_pixbuf_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1712 gtk_tree_view_column_pack_start(column, renderer, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1713 gtk_tree_view_column_add_attribute(column, renderer, "pixbuf", DIR_COLUMN_ICON);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1714 gtk_tree_view_column_set_cell_data_func(column, renderer, vdtree_color_cb, vdt, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1715
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1716 renderer = gtk_cell_renderer_text_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1717 gtk_tree_view_column_pack_start(column, renderer, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1718 gtk_tree_view_column_add_attribute(column, renderer, "text", DIR_COLUMN_NAME);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1719 gtk_tree_view_column_set_cell_data_func(column, renderer, vdtree_color_cb, vdt, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1720
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1721 gtk_tree_view_append_column(GTK_TREE_VIEW(vdt->treeview), column);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1722
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1723 g_signal_connect(G_OBJECT(vdt->treeview), "key_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1724 G_CALLBACK(vdtree_press_key_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1725
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1726 gtk_container_add(GTK_CONTAINER(vdt->widget), vdt->treeview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1727 gtk_widget_show(vdt->treeview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1728
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1729 vdt->pf = folder_icons_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1730
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1731 vdtree_setup_root(vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1732
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1733 vdtree_dnd_init(vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1734
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1735 g_signal_connect(G_OBJECT(vdt->treeview), "button_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1736 G_CALLBACK(vdtree_press_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1737 g_signal_connect(G_OBJECT(vdt->treeview), "button_release_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1738 G_CALLBACK(vdtree_release_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1739
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1740 vdtree_set_path(vdt, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1741
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1742 return vdt;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1743 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1744
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1745 void vdtree_set_select_func(ViewDirTree *vdt,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1746 void (*func)(ViewDirTree *vdt, const gchar *path, gpointer data), gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1747 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1748 vdt->select_func = func;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1749 vdt->select_data = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1750 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1751
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1752 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1753 void vdtree_set_click_func(ViewDirTree *vdt,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1754 void (*func)(ViewDirTree *vdt, GdkEventButton *event, FileData *fd, gpointer), gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1755 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1756 if (!td) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1757 vdt->click_func = func;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1758 vdt->click_data = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1759 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1760 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1761
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1762 void vdtree_set_layout(ViewDirTree *vdt, LayoutWindow *layout)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1763 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1764 vdt->layout = layout;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1765 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1766