annotate src/view_dir_tree.c @ 334:df868b947aa0

Rename image-related options.
author zas_
date Sat, 12 Apr 2008 15:04:58 +0000
parents 3c4bad726e98
children 0b82646e977f
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
465 static GtkWidget *vdtree_pop_menu(ViewDirTree *vdt, FileData *fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
466 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
467 GtkWidget *menu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
468 gint active;
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
469 gint parent_active = FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
470
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
471 active = (fd != NULL);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
472 if (fd)
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
473 {
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
474 gchar *parent;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
475
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
476 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
477 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
478 g_free(parent);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
479 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
480
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
481 menu = popup_menu_short_lived();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
482 g_signal_connect(G_OBJECT(menu), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
483 G_CALLBACK(vdtree_popup_destroy_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
484
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
485 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
486 (vdt->path && strcmp(vdt->path, "/") != 0),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
487 G_CALLBACK(vdtree_pop_menu_up_cb), vdt);
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_item_add_divider(menu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
490 menu_item_add_sensitive(menu, _("_Slideshow"), active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
491 G_CALLBACK(vdtree_pop_menu_slide_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
492 menu_item_add_sensitive(menu, _("Slideshow recursive"), active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
493 G_CALLBACK(vdtree_pop_menu_slide_rec_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
494
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
495 menu_item_add_divider(menu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
496 menu_item_add_stock_sensitive(menu, _("Find _duplicates..."), GTK_STOCK_FIND, active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
497 G_CALLBACK(vdtree_pop_menu_dupe_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
498 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
499 G_CALLBACK(vdtree_pop_menu_dupe_rec_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
500
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
501 menu_item_add_divider(menu);
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 active = (fd &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
504 access_file(fd->path, W_OK | X_OK));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
505 menu_item_add_sensitive(menu, _("_New folder..."), active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
506 G_CALLBACK(vdtree_pop_menu_new_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
507
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
508 menu_item_add_sensitive(menu, _("_Rename..."), parent_active,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
509 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
510 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
511 G_CALLBACK(vdtree_pop_menu_delete_cb), vdt);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
512
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
513 menu_item_add_divider(menu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
514 menu_item_add_check(menu, _("View as _tree"), TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
515 G_CALLBACK(vdtree_pop_menu_tree_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
516 menu_item_add_stock(menu, _("Re_fresh"), GTK_STOCK_REFRESH,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
517 G_CALLBACK(vdtree_pop_menu_refresh_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
518
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
519 return menu;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
522 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
523 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
524 * dnd
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
525 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
526 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
527
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
528 static GtkTargetEntry vdtree_dnd_drop_types[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
529 { "text/uri-list", 0, TARGET_URI_LIST }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
530 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
531 static gint vdtree_dnd_drop_types_count = 1;
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 static void vdtree_dest_set(ViewDirTree *vdt, gint enable)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
535 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
536 if (enable)
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 gtk_drag_dest_set(vdt->treeview,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
539 GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
540 vdtree_dnd_drop_types, vdtree_dnd_drop_types_count,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
541 GDK_ACTION_MOVE | GDK_ACTION_COPY);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
542 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
543 else
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 gtk_drag_dest_unset(vdt->treeview);
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 }
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 static void vdtree_dnd_get(GtkWidget *widget, GdkDragContext *context,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
550 GtkSelectionData *selection_data, guint info,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
551 guint time, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
552 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
553 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
554 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
555 gchar *uri_text = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
556 gint length = 0;
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 if (!vdt->click_fd) return;
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 switch (info)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
561 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
562 case TARGET_URI_LIST:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
563 case TARGET_TEXT_PLAIN:
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
564 list = g_list_prepend(NULL, vdt->click_fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
565 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
566 g_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
567 break;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
570 if (uri_text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
571 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
572 gtk_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
573 8, (guchar *)uri_text, length);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
574 g_free(uri_text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
575 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
576 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
577
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
578 static void vdtree_dnd_begin(GtkWidget *widget, GdkDragContext *context, gpointer data)
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 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
581
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
582 vdtree_color_set(vdt, vdt->click_fd, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
583 vdtree_dest_set(vdt, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
584 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
585
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
586 static void vdtree_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer data)
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 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
589
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
590 vdtree_color_set(vdt, vdt->click_fd, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
591 vdtree_dest_set(vdt, TRUE);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
594 static void vdtree_dnd_drop_receive(GtkWidget *widget,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
595 GdkDragContext *context, gint x, gint y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
596 GtkSelectionData *selection_data, guint info,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
597 guint time, 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 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
601 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
602 FileData *fd = NULL;
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 vdt->click_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
605
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
606 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
607 &tpath, NULL, NULL, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
608 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
609 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
610 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
611
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
612 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
613 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
614 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
615 gtk_tree_path_free(tpath);
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 fd = (nd) ? nd->fd : NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
618 }
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 if (!fd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
621
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
622 if (info == TARGET_URI_LIST)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
623 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
624 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
625 gint active;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
626
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
627 list = uri_filelist_from_text((gchar *)selection_data->data, TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
628 if (!list) return;
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 active = access_file(fd->path, W_OK | X_OK);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
631
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
632 vdtree_color_set(vdt, fd, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
633 vdt->popup = vdtree_drop_menu(vdt, active);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
634 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
635
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
636 vdt->drop_fd = fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
637 vdt->drop_list = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
638 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
639 }
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 static gint vdtree_dnd_drop_expand_cb(gpointer data)
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 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
644 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
645
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
646 if (vdt->drop_fd &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
647 vdtree_find_row(vdt, vdt->drop_fd, &iter, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
648 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
649 vdtree_populate_path_by_iter(vdt, &iter, FALSE, vdt->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
650 vdtree_expand_by_data(vdt, vdt->drop_fd, TRUE);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
653 vdt->drop_expand_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
654 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
655 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
656
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
657 static void vdtree_dnd_drop_expand_cancel(ViewDirTree *vdt)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
658 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
659 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
660 vdt->drop_expand_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
661 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
662
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
663 static void vdtree_dnd_drop_expand(ViewDirTree *vdt)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
664 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
665 vdtree_dnd_drop_expand_cancel(vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
666 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
667 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
668
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
669 static void vdtree_drop_update(ViewDirTree *vdt, gint x, gint y)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
670 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
671 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
672 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
673 FileData *fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
674
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
675 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
676 &tpath, NULL, NULL, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
677 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
678 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
679 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
680
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
681 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
682 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
683 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
684 gtk_tree_path_free(tpath);
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 fd = (nd) ? nd->fd : NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
687 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
688
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
689 if (fd != vdt->drop_fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
690 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
691 vdtree_color_set(vdt, vdt->drop_fd, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
692 vdtree_color_set(vdt, fd, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
693 if (fd) vdtree_dnd_drop_expand(vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
694 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
695
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
696 vdt->drop_fd = fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
697 }
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 static void vdtree_dnd_drop_scroll_cancel(ViewDirTree *vdt)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
700 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
701 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
702 vdt->drop_scroll_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
703 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
704
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
705 static gint vdtree_auto_scroll_idle_cb(gpointer data)
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 ViewDirTree *vdt = data;
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 if (vdt->drop_fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
710 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
711 GdkWindow *window;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
712 gint x, y;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
713 gint w, h;
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 window = vdt->treeview->window;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
716 gdk_window_get_pointer(window, &x, &y, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
717 gdk_drawable_get_size(window, &w, &h);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
718 if (x >= 0 && x < w && y >= 0 && y < h)
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 vdtree_drop_update(vdt, x, y);
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 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
723
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
724 vdt->drop_scroll_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
725 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
726 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
727
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
728 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
729 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
730 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
731
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
732 if (!vdt->drop_fd || vdt->drop_list) return FALSE;
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 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
735
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
736 return TRUE;
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_dnd_drop_motion(GtkWidget *widget, GdkDragContext *context,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
740 gint x, gint y, guint time, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
741 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
742 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
743
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
744 vdt->click_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
745
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
746 if (gtk_drag_get_source_widget(context) == vdt->treeview)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
747 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
748 gdk_drag_status(context, 0, time);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
749 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
750 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
751 else
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 gdk_drag_status(context, context->suggested_action, time);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
756 vdtree_drop_update(vdt, x, y);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
757
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
758 if (vdt->drop_fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
759 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
760 GtkAdjustment *adj = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
761 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
762 }
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 return FALSE;
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 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
768 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
769 ViewDirTree *vdt = data;
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 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
772
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
773 vdt->drop_fd = NULL;
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 vdtree_dnd_drop_expand_cancel(vdt);
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_init(ViewDirTree *vdt)
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 gtk_drag_source_set(vdt->treeview, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
781 dnd_file_drag_types, dnd_file_drag_types_count,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
782 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_ASK);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
783 g_signal_connect(G_OBJECT(vdt->treeview), "drag_data_get",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
784 G_CALLBACK(vdtree_dnd_get), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
785 g_signal_connect(G_OBJECT(vdt->treeview), "drag_begin",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
786 G_CALLBACK(vdtree_dnd_begin), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
787 g_signal_connect(G_OBJECT(vdt->treeview), "drag_end",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
788 G_CALLBACK(vdtree_dnd_end), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
789
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
790 vdtree_dest_set(vdt, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
791 g_signal_connect(G_OBJECT(vdt->treeview), "drag_data_received",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
792 G_CALLBACK(vdtree_dnd_drop_receive), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
793 g_signal_connect(G_OBJECT(vdt->treeview), "drag_motion",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
794 G_CALLBACK(vdtree_dnd_drop_motion), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
795 g_signal_connect(G_OBJECT(vdt->treeview), "drag_leave",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
796 G_CALLBACK(vdtree_dnd_drop_leave), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
797 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
798
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
799 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
800 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
801 * parts lists
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
802 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
803 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
804
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
805 static GList *parts_list(const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
806 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
807 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
808 const gchar *strb, *strp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
809 gint l;
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 strp = path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
812
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
813 if (*strp != '/') return NULL;
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 strp++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
816 strb = strp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
817 l = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
818
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
819 while (*strp != '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
820 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
821 if (*strp == '/')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
822 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
823 if (l > 0) list = g_list_prepend(list, g_strndup(strb, l));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
824 strp++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
825 strb = strp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
826 l = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
827 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
828 else
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 strp++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
831 l++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
832 }
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
836 list = g_list_reverse(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
837
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
838 list = g_list_prepend(list, g_strdup("/"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
839
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
840 return list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
841 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
842
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
843 static void parts_list_free(GList *list)
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 GList *work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
846 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
847 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
848 PathData *pd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
849 g_free(pd->name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
850 g_free(pd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
851 work = work->next;
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 g_list_free(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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
857 static GList *parts_list_add_node_points(ViewDirTree *vdt, GList *list)
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 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
860 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
861 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
862 gint valid;
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 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
865 valid = gtk_tree_model_get_iter_first(store, &iter);
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 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
868 while (work)
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 PathData *pd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
871 FileData *fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
872
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
873 pd = g_new0(PathData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
874 pd->name = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
875
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
876 while (valid && !fd)
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 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
879
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
880 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
881 if (strcmp(nd->fd->name, pd->name) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
882 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
883 fd = nd->fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
884 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
885 else
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 valid = gtk_tree_model_iter_next(store, &iter);
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 }
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 pd->node = fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
892 work->data = pd;
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 if (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 GtkTreeIter parent;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
897 memcpy(&parent, &iter, sizeof(parent));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
898 valid = gtk_tree_model_iter_children(store, &iter, &parent);
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 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
902 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
903
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
904 return list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
905 }
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 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
908 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
909 * misc
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
913 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
914 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
915 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
916 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
917 NodeData *nd;
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 gtk_tree_model_get_iter(tree_model, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
920 gtk_tree_model_get(tree_model, &iter, DIR_COLUMN_POINTER, &nd, -1);
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 if (!nd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
923
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
924 file_data_unref(nd->fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
925 g_free(nd);
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 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
928
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 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
931 * node traversal, management
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 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
934
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
935 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
936 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
937 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
938
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
939 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
940 if (!nd || !gtk_tree_model_iter_children(store, iter, parent)) return -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
941 do {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
942 NodeData *cnd;
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 gtk_tree_model_get(store, iter, DIR_COLUMN_POINTER, &cnd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
945 if (cnd == nd) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
946 } while (gtk_tree_model_iter_next(store, 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 return FALSE;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
951 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
952 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
953 GtkTreeModel *store;
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 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
956 if (!name || !gtk_tree_model_iter_children(store, iter, parent)) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
957 do {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
958 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
959
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
960 gtk_tree_model_get(store, iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
961 if (nd && strcmp(nd->fd->name, name) == 0) return nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
962 } while (gtk_tree_model_iter_next(store, 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 return NULL;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
967 static void vdtree_add_by_data(ViewDirTree *vdt, FileData *fd, GtkTreeIter *parent)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
968 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
969 GtkTreeStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
970 GtkTreeIter child;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
971 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
972 GdkPixbuf *pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
973 NodeData *end;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
974 GtkTreeIter empty;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
975
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
976 if (!fd) return;
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 if (access_file(fd->path, R_OK | X_OK))
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 pixbuf = vdt->pf->close;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
981 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
982 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
983 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
984 pixbuf = vdt->pf->deny;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
985 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
986
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
987 nd = g_new0(NodeData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
988 nd->fd = fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
989 nd->expanded = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
990 nd->last_update = time(NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
991
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
992 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
993 gtk_tree_store_append(store, &child, parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
994 gtk_tree_store_set(store, &child, DIR_COLUMN_POINTER, nd,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
995 DIR_COLUMN_ICON, pixbuf,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
996 DIR_COLUMN_NAME, nd->fd->name,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
997 DIR_COLUMN_COLOR, FALSE, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
998
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
999 /* 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
1000 * this is removed when the child is populated */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1001 end = g_new0(NodeData, 1);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
1002 end->fd = file_data_new_simple("");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1003 end->expanded = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1004
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1005 gtk_tree_store_append(store, &empty, &child);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1006 gtk_tree_store_set(store, &empty, DIR_COLUMN_POINTER, end,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1007 DIR_COLUMN_NAME, "empty", -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1008
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1009 if (parent)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1010 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1011 NodeData *pnd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1012 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1013
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1014 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
1015 tpath = gtk_tree_model_get_path(GTK_TREE_MODEL(store), parent);
320
c74af1cbd61a Move more options to ConfOptions.
zas_
parents: 318
diff changeset
1016 if (options->tree_descend_subdirs &&
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1017 gtk_tree_view_row_expanded(GTK_TREE_VIEW(vdt->treeview), tpath) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1018 !nd->expanded)
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 vdtree_populate_path_by_iter(vdt, &child, FALSE, vdt->path);
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 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1023 }
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1026 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
1027 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1028 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1029 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1030 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1031 GList *old;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1032 time_t current_time;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1033 GtkTreeIter child;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1034 NodeData *nd;
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 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1037 gtk_tree_model_get(store, iter, DIR_COLUMN_POINTER, &nd, -1);
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 if (!nd) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1040
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1041 current_time = time(NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1042
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1043 if (nd->expanded)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1044 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1045 if (!force && current_time - nd->last_update < 10) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1046 if (!isdir(nd->fd->path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1047 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1048 if (vdt->click_fd == nd->fd) vdt->click_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1049 if (vdt->drop_fd == nd->fd) vdt->drop_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1050 gtk_tree_store_remove(GTK_TREE_STORE(store), iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1051 vdtree_node_free(nd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1052 return FALSE;
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 (!force && filetime(nd->fd->path) == nd->fd->date) return TRUE;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1057 vdtree_busy_push(vdt);
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 list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1060 filelist_read(nd->fd->path, NULL, &list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1061
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1062 /* 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
1063 * 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
1064 */
332
3c4bad726e98 Rename file filtering options.
zas_
parents: 320
diff changeset
1065 if (!options->file_filter.show_dot_files &&
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1066 target_path &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1067 strncmp(nd->fd->path, target_path, strlen(nd->fd->path)) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1068 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1069 gint n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1070
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1071 n = strlen(nd->fd->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1072 if (target_path[n] == '/' && target_path[n+1] == '.')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1073 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1074 gchar *name8;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1075 struct stat sbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1076
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1077 n++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1078
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1079 while (target_path[n] != '\0' && target_path[n] != '/') n++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1080 name8 = g_strndup(target_path, 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 if (stat_utf8(name8, &sbuf))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1083 {
145
8be2cc687304 fixed grouping sidecar files and made it configurable via config file
nadvornik
parents: 138
diff changeset
1084 list = g_list_prepend(list, file_data_new_simple(name8));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1085 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1086
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1087 g_free(name8);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1088 }
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1091 old = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1092 if (gtk_tree_model_iter_children(store, &child, iter))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1093 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1094 do {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1095 NodeData *cnd;
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 gtk_tree_model_get(store, &child, DIR_COLUMN_POINTER, &cnd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1098 old = g_list_prepend(old, cnd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1099 } while (gtk_tree_model_iter_next(store, &child));
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 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1103 while (work)
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 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1106
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1107 fd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1108 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1109
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1110 if (strcmp(fd->name, ".") == 0 || strcmp(fd->name, "..") == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1111 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
1112 file_data_unref(fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1113 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1114 else
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 NodeData *cnd;
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 cnd = vdtree_find_iter_by_name(vdt, iter, fd->name, &child);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1119 if (cnd)
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 old = g_list_remove(old, cnd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1122 if (cnd->expanded && cnd->fd->date != fd->date &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1123 vdtree_populate_path_by_iter(vdt, &child, FALSE, target_path))
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 cnd->fd->size = fd->size;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1126 cnd->fd->date = fd->date;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1127 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1128
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
1129 file_data_unref(fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1130 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1131 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1132 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1133 vdtree_add_by_data(vdt, fd, iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1134 }
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 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1137
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1138 work = old;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1139 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1140 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1141 NodeData *cnd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1142 work = work->next;
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 if (vdt->click_fd == cnd->fd) vdt->click_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1145 if (vdt->drop_fd == cnd->fd) vdt->drop_fd = NULL;
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 if (vdtree_find_iter_by_data(vdt, iter, cnd, &child))
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 gtk_tree_store_remove(GTK_TREE_STORE(store), &child);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1150 vdtree_node_free(cnd);
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 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1153
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1154 g_list_free(old);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1155 g_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1156
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1157 vdtree_busy_pop(vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1158
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1159 nd->expanded = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1160 nd->last_update = current_time;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1161
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1162 return TRUE;
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 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
1166 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1167 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1168 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1169 FileData *fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1170
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1171 if (!path) return NULL;
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 vdtree_busy_push(vdt);
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 list = parts_list(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1176 list = parts_list_add_node_points(vdt, list);
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 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1179 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1180 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1181 PathData *pd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1182 if (pd->node == 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 PathData *parent_pd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1185 GtkTreeIter parent_iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1186 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1187 NodeData *nd;
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 if (work == list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1190 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1191 /* should not happen */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1192 printf("vdtree warning, root node not found\n");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1193 parts_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1194 vdtree_busy_pop(vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1195 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1196 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1197
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1198 parent_pd = work->prev->data;
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 (!vdtree_find_row(vdt, parent_pd->node, &parent_iter, NULL) ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1201 !vdtree_populate_path_by_iter(vdt, &parent_iter, force, path) ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1202 (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
1203 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1204 printf("vdtree warning, aborted at %s\n", parent_pd->name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1205 parts_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1206 vdtree_busy_pop(vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1207 return NULL;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1210 pd->node = nd->fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1211
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1212 if (pd->node)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1213 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1214 if (expand)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1215 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1216 vdtree_expand_by_iter(vdt, &parent_iter, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1217 vdtree_expand_by_iter(vdt, &iter, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1218 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1219 vdtree_populate_path_by_iter(vdt, &iter, force, path);
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 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1222 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1223 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1224 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1225
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1226 if (vdtree_find_row(vdt, pd->node, &iter, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1227 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1228 if (expand) vdtree_expand_by_iter(vdt, &iter, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1229 vdtree_populate_path_by_iter(vdt, &iter, force, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1230 }
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 work = work->next;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1236 work = g_list_last(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1237 if (work)
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 PathData *pd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1240 fd = pd->node;
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 parts_list_free(list);
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 vdtree_busy_pop(vdt);
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 return fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1247 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1248
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 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1251 * access
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 */
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 static gint selection_is_ok = FALSE;
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 static gboolean vdtree_select_cb(GtkTreeSelection *selection, GtkTreeModel *store, GtkTreePath *tpath,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1258 gboolean path_currently_selected, gpointer data)
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 return selection_is_ok;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1263 static void vdtree_select_row(ViewDirTree *vdt, FileData *fd)
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 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1266 GtkTreeIter iter;
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 if (!vdtree_find_row(vdt, fd, &iter, NULL)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1269 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vdt->treeview));
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 /* hack, such that selection is only allowed to be changed from here */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1272 selection_is_ok = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1273 gtk_tree_selection_select_iter(selection, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1274 selection_is_ok = FALSE;
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 if (!vdtree_populate_path_by_iter(vdt, &iter, FALSE, vdt->path)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1277
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1278 vdtree_expand_by_iter(vdt, &iter, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1279
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1280 if (fd && vdt->select_func)
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 vdt->select_func(vdt, fd->path, vdt->select_data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1283 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1284 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1285
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1286 gint vdtree_set_path(ViewDirTree *vdt, const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1287 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1288 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1289 GtkTreeIter iter;
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 (!path) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1292 if (vdt->path && strcmp(path, vdt->path) == 0) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1293
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1294 g_free(vdt->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1295 vdt->path = g_strdup(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1296
63
e29c291e106b Mon Aug 15 16:35:15 2005 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1297 fd = vdtree_populate_path(vdt, vdt->path, TRUE, FALSE);
9
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 if (!fd) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1300
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1301 if (vdtree_find_row(vdt, fd, &iter, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1302 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1303 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1304 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1305
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1306 tree_view_row_make_visible(GTK_TREE_VIEW(vdt->treeview), &iter, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1307
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1308 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1309 tpath = gtk_tree_model_get_path(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1310 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
1311 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1312
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1313 vdtree_select_row(vdt, fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1314 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1315
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1316 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1317 }
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 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1320 const gchar *vdtree_get_path(ViewDirTree *vdt)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1321 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1322 return vdt->path;
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 #endif
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 void vdtree_refresh(ViewDirTree *vdt)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1327 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1328 vdtree_populate_path(vdt, vdt->path, FALSE, TRUE);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1331 const gchar *vdtree_row_get_path(ViewDirTree *vdt, gint row)
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 printf("FIXME: no get row path\n");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1334 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1335 }
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 /*
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 * callbacks
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1343 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
1344 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1345 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1346 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1347 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1348 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1349 gint cw, ch;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1350
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1351 if (vdtree_find_row(vdt, vdt->click_fd, &iter, NULL) < 0) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1352 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1353 tpath = gtk_tree_model_get_path(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1354 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
1355 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1356 *y += ch;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1357 popup_menu_position_clamp(menu, x, y, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1358 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1359
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1360 static gint vdtree_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
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 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1363 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1364 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1365 FileData *fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1366
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1367 gtk_tree_view_get_cursor(GTK_TREE_VIEW(vdt->treeview), &tpath, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1368 if (tpath)
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 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1371 NodeData *nd;
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 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1374 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1375 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1376
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1377 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1378
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1379 fd = (nd) ? nd->fd : NULL;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1382 switch (event->keyval)
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 case GDK_Menu:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1385 vdt->click_fd = fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1386 vdtree_color_set(vdt, vdt->click_fd, TRUE);
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 vdt->popup = vdtree_pop_menu(vdt, vdt->click_fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1389 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
1390
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1391 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1392 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1393 case GDK_plus:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1394 case GDK_Right:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1395 case GDK_KP_Add:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1396 if (fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1397 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1398 vdtree_populate_path_by_iter(vdt, &iter, FALSE, vdt->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1399 vdtree_icon_set_by_iter(vdt, &iter, vdt->pf->open);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1400 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1401 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1402 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1403
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1404 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1405 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1406
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1407 static gint vdtree_clicked_on_expander(GtkTreeView *treeview, GtkTreePath *tpath,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1408 GtkTreeViewColumn *column, gint x, gint y, gint *left_of_expander)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1409 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1410 gint depth;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1411 gint size;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1412 gint sep;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1413 gint exp_width;
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 if (column != gtk_tree_view_get_expander_column(treeview)) 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 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
1418 depth = gtk_tree_path_get_depth(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1419
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1420 exp_width = sep + size + sep;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1421
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1422 if (x <= depth * exp_width)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1423 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1424 if (left_of_expander) *left_of_expander = !(x >= (depth - 1) * exp_width);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1425 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1426 }
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 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1429 }
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 static gint vdtree_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
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 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1434 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1435 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1436 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1437 NodeData *nd = NULL;
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 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
1440 &tpath, &column, NULL, NULL))
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 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1443 gint left_of_expander;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1444
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1445 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1446 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1447 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1448 gtk_tree_view_set_cursor(GTK_TREE_VIEW(widget), tpath, NULL, FALSE);
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 (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
1451 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1452 vdt->click_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1453
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1454 /* clicking this region should automatically reveal an expander, if necessary
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1455 * 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
1456 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1457 if (bevent->button == 1 &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1458 !left_of_expander &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1459 !gtk_tree_view_row_expanded(GTK_TREE_VIEW(vdt->treeview), tpath))
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 vdtree_populate_path_by_iter(vdt, &iter, FALSE, vdt->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1462 vdtree_icon_set_by_iter(vdt, &iter, vdt->pf->open);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1463 }
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 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1466 return FALSE;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1469 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1470 }
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 vdt->click_fd = (nd) ? nd->fd : NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1473 vdtree_color_set(vdt, vdt->click_fd, TRUE);
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 if (bevent->button == 3)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1476 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1477 vdt->popup = vdtree_pop_menu(vdt, vdt->click_fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1478 gtk_menu_popup(GTK_MENU(vdt->popup), NULL, NULL, NULL, NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1479 bevent->button, bevent->time);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1480 }
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 return (bevent->button != 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1483 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1484
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1485 static gint vdtree_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1486 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1487 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1488 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1489 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1490 NodeData *nd = NULL;
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 if (!vdt->click_fd) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1493 vdtree_color_set(vdt, vdt->click_fd, FALSE);
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 if (bevent->button != 1) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1496
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1497 if ((bevent->x != 0 || bevent->y != 0) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1498 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
1499 &tpath, NULL, NULL, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1500 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1501 GtkTreeModel *store;
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 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1504 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1505 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1506 gtk_tree_path_free(tpath);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1509 if (nd && vdt->click_fd == nd->fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1510 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1511 vdtree_select_row(vdt, vdt->click_fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1512 }
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 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1515 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1516
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1517 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
1518 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1519 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1520
25
0c3b353b666e Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
1521 vdtree_populate_path_by_iter(vdt, iter, FALSE, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1522 vdtree_icon_set_by_iter(vdt, iter, vdt->pf->open);
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 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
1526 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1527 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1528
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1529 vdtree_icon_set_by_iter(vdt, iter, vdt->pf->close);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1530 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1531
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1532 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
1533 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1534 NodeData *nda;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1535 NodeData *ndb;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1536
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1537 gtk_tree_model_get(store, a, DIR_COLUMN_POINTER, &nda, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1538 gtk_tree_model_get(store, b, DIR_COLUMN_POINTER, &ndb, -1);
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 return CASE_SORT(nda->fd->name, ndb->fd->name);
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 /*
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 * core
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1546 *----------------------------------------------------------------------------
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1549 static void vdtree_setup_root(ViewDirTree *vdt)
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 const gchar *path = "/";
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1552 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1553
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
1554
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
1555 fd = file_data_new_simple(path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1556 vdtree_add_by_data(vdt, fd, NULL);
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 vdtree_expand_by_data(vdt, fd, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1559 vdtree_populate_path(vdt, path, FALSE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1560 }
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 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
1563 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1564 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1565 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1566 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1567 NodeData *nd;
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 store = gtk_tree_view_get_model(tview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1570 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1571 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
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 vdtree_select_row(vdt, nd->fd);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1576 static GdkColor *vdtree_color_shifted(GtkWidget *widget)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1577 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1578 static GdkColor color;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1579 static GtkWidget *done = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1580
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1581 if (done != widget)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1582 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1583 GtkStyle *style;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1584
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1585 style = gtk_widget_get_style(widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1586 memcpy(&color, &style->base[GTK_STATE_NORMAL], sizeof(color));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1587 shift_color(&color, -1, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1588 done = widget;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1589 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1590
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1591 return &color;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1592 }
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 static void vdtree_color_cb(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1595 GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1596 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1597 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1598 gboolean set;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1599
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1600 gtk_tree_model_get(tree_model, iter, DIR_COLUMN_COLOR, &set, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1601 g_object_set(G_OBJECT(cell),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1602 "cell-background-gdk", vdtree_color_shifted(vdt->treeview),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1603 "cell-background-set", set, NULL);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1606 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
1607 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1608 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1609
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1610 gtk_tree_model_get(store, iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1611 vdtree_node_free(nd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1612
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1613 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1614 }
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 static void vdtree_destroy_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1617 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1618 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1619 GtkTreeModel *store;
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 if (vdt->popup)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1622 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1623 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
1624 0, 0, 0, NULL, vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1625 gtk_widget_destroy(vdt->popup);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1628 vdtree_dnd_drop_expand_cancel(vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1629 vdtree_dnd_drop_scroll_cancel(vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1630 widget_auto_scroll_stop(vdt->treeview);
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 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1633 gtk_tree_model_foreach(store, vdtree_destroy_node_cb, vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1634
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 125
diff changeset
1635 filelist_free(vdt->drop_list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1636
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1637 folder_icons_free(vdt->pf);
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 g_free(vdt->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1640 g_free(vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1641 }
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 ViewDirTree *vdtree_new(const gchar *path, gint expand)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1644 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1645 ViewDirTree *vdt;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1646 GtkTreeStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1647 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1648 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1649 GtkCellRenderer *renderer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1650
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1651 vdt = g_new0(ViewDirTree, 1);
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 vdt->path = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1654 vdt->click_fd = NULL;
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 vdt->drop_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1657 vdt->drop_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1658 vdt->drop_scroll_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1659 vdt->drop_expand_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1660
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1661 vdt->popup = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1662
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1663 vdt->busy_ref = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1664
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1665 vdt->widget = gtk_scrolled_window_new(NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1666 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
1667 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(vdt->widget),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1668 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1669 g_signal_connect(G_OBJECT(vdt->widget), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1670 G_CALLBACK(vdtree_destroy_cb), vdt);
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 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
1673 vdt->treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1674 g_object_unref(store);
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 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(vdt->treeview), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1677 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(vdt->treeview), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1678 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
1679 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1680 GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, GTK_SORT_ASCENDING);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1681
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1682 g_signal_connect(G_OBJECT(vdt->treeview), "row_activated",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1683 G_CALLBACK(vdtree_activate_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1684 g_signal_connect(G_OBJECT(vdt->treeview), "row_expanded",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1685 G_CALLBACK(vdtree_row_expanded), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1686 g_signal_connect(G_OBJECT(vdt->treeview), "row_collapsed",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1687 G_CALLBACK(vdtree_row_collapsed), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1688 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1689 g_signal_connect(G_OBJECT(store), "row_deleted",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1690 G_CALLBACK(vdtree_row_deleted_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1691 #endif
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 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1694 gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1695 gtk_tree_selection_set_select_function(selection, vdtree_select_cb, vdt, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1696
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1697 column = gtk_tree_view_column_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1698 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
1699
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1700 renderer = gtk_cell_renderer_pixbuf_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1701 gtk_tree_view_column_pack_start(column, renderer, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1702 gtk_tree_view_column_add_attribute(column, renderer, "pixbuf", DIR_COLUMN_ICON);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1703 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
1704
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1705 renderer = gtk_cell_renderer_text_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1706 gtk_tree_view_column_pack_start(column, renderer, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1707 gtk_tree_view_column_add_attribute(column, renderer, "text", DIR_COLUMN_NAME);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1708 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
1709
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1710 gtk_tree_view_append_column(GTK_TREE_VIEW(vdt->treeview), column);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1711
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1712 g_signal_connect(G_OBJECT(vdt->treeview), "key_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1713 G_CALLBACK(vdtree_press_key_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1714
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1715 gtk_container_add(GTK_CONTAINER(vdt->widget), vdt->treeview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1716 gtk_widget_show(vdt->treeview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1717
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1718 vdt->pf = folder_icons_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1719
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1720 vdtree_setup_root(vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1721
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1722 vdtree_dnd_init(vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1723
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1724 g_signal_connect(G_OBJECT(vdt->treeview), "button_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1725 G_CALLBACK(vdtree_press_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1726 g_signal_connect(G_OBJECT(vdt->treeview), "button_release_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1727 G_CALLBACK(vdtree_release_cb), vdt);
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 vdtree_set_path(vdt, path);
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 return 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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1734 void vdtree_set_select_func(ViewDirTree *vdt,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1735 void (*func)(ViewDirTree *vdt, const gchar *path, gpointer data), gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1736 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1737 vdt->select_func = func;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1738 vdt->select_data = data;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1741 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1742 void vdtree_set_click_func(ViewDirTree *vdt,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1743 void (*func)(ViewDirTree *vdt, GdkEventButton *event, FileData *fd, gpointer), gpointer data)
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 if (!td) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1746 vdt->click_func = func;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1747 vdt->click_data = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1748 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1749 #endif
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 void vdtree_set_layout(ViewDirTree *vdt, LayoutWindow *layout)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1752 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1753 vdt->layout = layout;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1754 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1755