annotate src/view_dir_tree.c @ 63:e29c291e106b

Mon Aug 15 16:35:15 2005 John Ellis <johne@verizon.net> * view_dir_tree.c (vdtree_set_path): Do not force reading folder contents, to allow the check for a changed timestamp do it's job. * doc/10_options.html: Fix page link in docs.
author gqview
date Mon, 15 Aug 2005 20:47:03 +0000
parents 458e396d3f35
children 04ff0df3ad2f
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 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2 * GQview
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3 * (C) 2004 John Ellis
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
12 #include "gqview.h"
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
44
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 25
diff changeset
200 if (file_util_rename_dir(old_path, 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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
237 file_data_free(nd->fd);
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);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
250 path_list_free(vdt->drop_list);
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;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
341 path = g_strdup(vdt->click_fd->path);
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 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
349 }
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 static void vdtree_pop_menu_slide_rec_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
352 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
353 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
354 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
355 GList *list;
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->layout) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
358
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
359 if (!vdt->click_fd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
360 path = g_strdup(vdt->click_fd->path);
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 list = path_list_recursive(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
363
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
364 layout_image_slideshow_stop(vdt->layout);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
365 layout_image_slideshow_start_from_list(vdt->layout, list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
366
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
367 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
368 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
369
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
370 static void vdtree_pop_menu_dupe(ViewDirTree *vdt, gint recursive)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
371 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
372 DupeWindow *dw;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
373 const gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
374 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
375
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
376 if (!vdt->click_fd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
377 path = vdt->click_fd->path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
378
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
379 if (recursive)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
380 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
381 list = g_list_append(list, g_strdup(path));
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
384 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
385 path_list(path, &list, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
386 list = path_list_filter(list, FALSE);
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 dw = dupe_window_new(DUPE_MATCH_NAME);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
390 dupe_window_add_files(dw, list, recursive);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
391
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
392 path_list_free(list);
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_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, FALSE);
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_dupe_rec_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 vdtree_pop_menu_dupe(vdt, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
405 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
406
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
407 static void vdtree_pop_menu_new_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
408 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
409 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
410 const gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
411 gchar *new_path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
412 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
413
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
414 if (!vdt->click_fd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
415 path = vdt->click_fd->path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
416
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
417 buf = concat_dir_and_file(path, _("new_folder"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
418 new_path = unique_filename(buf, NULL, NULL, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
419 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
420 if (!new_path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
421
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
422 if (!mkdir_utf8(new_path, 0755))
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 gchar *text;
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 text = g_strdup_printf(_("Unable to create folder:\n%s"), new_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
427 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
428 g_free(text);
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 else
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 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
433
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
434 fd = vdtree_populate_path(vdt, new_path, TRUE, TRUE);
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 vdtree_rename_by_data(vdt, fd);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
439 g_free(new_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
440 }
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 static void vdtree_pop_menu_rename_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
443 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
444 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
445
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
446 vdtree_rename_by_data(vdt, vdt->click_fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
447 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
448
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
449 static void vdtree_pop_menu_tree_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
450 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
451 ViewDirTree *vdt = 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 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
454 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
455
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
456 static void vdtree_pop_menu_refresh_cb(GtkWidget *widget, gpointer data)
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 ViewDirTree *vdt = 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 if (vdt->layout) layout_refresh(vdt->layout);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
463 static GtkWidget *vdtree_pop_menu(ViewDirTree *vdt, FileData *fd)
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 GtkWidget *menu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
466 gint active;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
467
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
468 active = (fd != NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
469
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
470 menu = popup_menu_short_lived();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
471 g_signal_connect(G_OBJECT(menu), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
472 G_CALLBACK(vdtree_popup_destroy_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
473
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
474 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
475 (vdt->path && strcmp(vdt->path, "/") != 0),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
476 G_CALLBACK(vdtree_pop_menu_up_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
477
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
478 menu_item_add_divider(menu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
479 menu_item_add_sensitive(menu, _("_Slideshow"), active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
480 G_CALLBACK(vdtree_pop_menu_slide_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
481 menu_item_add_sensitive(menu, _("Slideshow recursive"), active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
482 G_CALLBACK(vdtree_pop_menu_slide_rec_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
483
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
484 menu_item_add_divider(menu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
485 menu_item_add_stock_sensitive(menu, _("Find _duplicates..."), GTK_STOCK_FIND, active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
486 G_CALLBACK(vdtree_pop_menu_dupe_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
487 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
488 G_CALLBACK(vdtree_pop_menu_dupe_rec_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
489
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
490 menu_item_add_divider(menu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
491
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
492 active = (fd &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
493 access_file(fd->path, W_OK | X_OK));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
494 menu_item_add_sensitive(menu, _("_New folder..."), active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
495 G_CALLBACK(vdtree_pop_menu_new_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
496
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
497 menu_item_add_sensitive(menu, _("_Rename..."), active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
498 G_CALLBACK(vdtree_pop_menu_rename_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
499
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
500 menu_item_add_divider(menu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
501 menu_item_add_check(menu, _("View as _tree"), TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
502 G_CALLBACK(vdtree_pop_menu_tree_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
503 menu_item_add_stock(menu, _("Re_fresh"), GTK_STOCK_REFRESH,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
504 G_CALLBACK(vdtree_pop_menu_refresh_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
505
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
506 return menu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
507 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
508
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
509 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
510 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
511 * dnd
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
512 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
513 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
514
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
515 static GtkTargetEntry vdtree_dnd_drop_types[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
516 { "text/uri-list", 0, TARGET_URI_LIST }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
517 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
518 static gint vdtree_dnd_drop_types_count = 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
519
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
520
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
521 static void vdtree_dest_set(ViewDirTree *vdt, gint enable)
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 if (enable)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
524 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
525 gtk_drag_dest_set(vdt->treeview,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
526 GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
527 vdtree_dnd_drop_types, vdtree_dnd_drop_types_count,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
528 GDK_ACTION_MOVE | GDK_ACTION_COPY);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
529 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
530 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
531 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
532 gtk_drag_dest_unset(vdt->treeview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
533 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
534 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
535
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
536 static void vdtree_dnd_get(GtkWidget *widget, GdkDragContext *context,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
537 GtkSelectionData *selection_data, guint info,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
538 guint time, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
539 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
540 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
541 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
542 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
543 gchar *uri_text = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
544 gint length = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
545
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
546 if (!vdt->click_fd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
547 path = vdt->click_fd->path;
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 switch (info)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
550 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
551 case TARGET_URI_LIST:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
552 case TARGET_TEXT_PLAIN:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
553 list = g_list_prepend(NULL, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
554 uri_text = uri_text_from_list(list, &length, (info == TARGET_TEXT_PLAIN));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
555 g_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
556 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
557 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
558
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
559 if (uri_text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
560 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
561 gtk_selection_data_set(selection_data, selection_data->target,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
562 8, uri_text, length);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
563 g_free(uri_text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
564 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
565 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
566
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
567 static void vdtree_dnd_begin(GtkWidget *widget, GdkDragContext *context, gpointer data)
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 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
570
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
571 vdtree_color_set(vdt, vdt->click_fd, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
572 vdtree_dest_set(vdt, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
573 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
574
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
575 static void vdtree_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer data)
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 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
578
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
579 vdtree_color_set(vdt, vdt->click_fd, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
580 vdtree_dest_set(vdt, TRUE);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
583 static void vdtree_dnd_drop_receive(GtkWidget *widget,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
584 GdkDragContext *context, gint x, gint y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
585 GtkSelectionData *selection_data, guint info,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
586 guint time, 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 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
590 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
591 FileData *fd = NULL;
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 vdt->click_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
594
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
595 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
596 &tpath, NULL, NULL, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
597 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
598 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
599 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
600
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
601 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
602 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
603 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
604 gtk_tree_path_free(tpath);
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 fd = (nd) ? nd->fd : NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
607 }
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 if (!fd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
610
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
611 if (info == TARGET_URI_LIST)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
612 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
613 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
614 gint active;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
615
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
616 list = uri_list_from_text(selection_data->data, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
617 if (!list) return;
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 active = access_file(fd->path, W_OK | X_OK);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
620
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
621 vdtree_color_set(vdt, fd, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
622 vdt->popup = vdtree_drop_menu(vdt, active);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
623 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
624
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
625 vdt->drop_fd = fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
626 vdt->drop_list = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
627 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
628 }
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 static gint vdtree_dnd_drop_expand_cb(gpointer data)
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 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
633 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
634
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
635 if (vdt->drop_fd &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
636 vdtree_find_row(vdt, vdt->drop_fd, &iter, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
637 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
638 vdtree_populate_path_by_iter(vdt, &iter, FALSE, vdt->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
639 vdtree_expand_by_data(vdt, vdt->drop_fd, TRUE);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
642 vdt->drop_expand_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
643 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
644 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
645
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
646 static void vdtree_dnd_drop_expand_cancel(ViewDirTree *vdt)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
647 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
648 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
649 vdt->drop_expand_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
650 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
651
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
652 static void vdtree_dnd_drop_expand(ViewDirTree *vdt)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
653 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
654 vdtree_dnd_drop_expand_cancel(vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
655 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
656 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
657
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
658 static void vdtree_drop_update(ViewDirTree *vdt, gint x, gint y)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
659 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
660 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
661 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
662 FileData *fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
663
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
664 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
665 &tpath, NULL, NULL, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
666 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
667 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
668 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
669
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
670 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
671 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
672 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
673 gtk_tree_path_free(tpath);
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 fd = (nd) ? nd->fd : NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
676 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
677
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
678 if (fd != vdt->drop_fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
679 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
680 vdtree_color_set(vdt, vdt->drop_fd, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
681 vdtree_color_set(vdt, fd, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
682 if (fd) vdtree_dnd_drop_expand(vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
683 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
684
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
685 vdt->drop_fd = fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
686 }
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 static void vdtree_dnd_drop_scroll_cancel(ViewDirTree *vdt)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
689 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
690 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
691 vdt->drop_scroll_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
692 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
693
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
694 static gint vdtree_auto_scroll_idle_cb(gpointer data)
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 ViewDirTree *vdt = data;
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 if (vdt->drop_fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
699 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
700 GdkWindow *window;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
701 gint x, y;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
702 gint w, h;
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 window = vdt->treeview->window;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
705 gdk_window_get_pointer(window, &x, &y, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
706 gdk_drawable_get_size(window, &w, &h);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
707 if (x >= 0 && x < w && y >= 0 && y < h)
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 vdtree_drop_update(vdt, x, y);
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 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
712
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
713 vdt->drop_scroll_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
714 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
715 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
716
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
717 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
718 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
719 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
720
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
721 if (!vdt->drop_fd || vdt->drop_list) return FALSE;
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 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
724
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
725 return TRUE;
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_dnd_drop_motion(GtkWidget *widget, GdkDragContext *context,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
729 gint x, gint y, guint time, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
730 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
731 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
732
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
733 vdt->click_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
734
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
735 if (gtk_drag_get_source_widget(context) == vdt->treeview)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
736 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
737 gdk_drag_status(context, 0, time);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
738 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
739 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
740 else
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 gdk_drag_status(context, context->suggested_action, time);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
745 vdtree_drop_update(vdt, x, y);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
746
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
747 if (vdt->drop_fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
748 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
749 GtkAdjustment *adj = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
750 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
751 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
752
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
753 return FALSE;
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 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
757 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
758 ViewDirTree *vdt = data;
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 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
761
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
762 vdt->drop_fd = NULL;
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 vdtree_dnd_drop_expand_cancel(vdt);
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_init(ViewDirTree *vdt)
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 gtk_drag_source_set(vdt->treeview, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
770 dnd_file_drag_types, dnd_file_drag_types_count,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
771 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_ASK);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
772 g_signal_connect(G_OBJECT(vdt->treeview), "drag_data_get",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
773 G_CALLBACK(vdtree_dnd_get), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
774 g_signal_connect(G_OBJECT(vdt->treeview), "drag_begin",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
775 G_CALLBACK(vdtree_dnd_begin), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
776 g_signal_connect(G_OBJECT(vdt->treeview), "drag_end",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
777 G_CALLBACK(vdtree_dnd_end), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
778
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
779 vdtree_dest_set(vdt, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
780 g_signal_connect(G_OBJECT(vdt->treeview), "drag_data_received",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
781 G_CALLBACK(vdtree_dnd_drop_receive), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
782 g_signal_connect(G_OBJECT(vdt->treeview), "drag_motion",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
783 G_CALLBACK(vdtree_dnd_drop_motion), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
784 g_signal_connect(G_OBJECT(vdt->treeview), "drag_leave",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
785 G_CALLBACK(vdtree_dnd_drop_leave), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
786 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
787
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
788 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
789 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
790 * parts lists
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
791 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
792 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
793
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
794 static GList *parts_list(const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
795 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
796 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
797 const gchar *strb, *strp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
798 gint l;
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 strp = path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
801
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
802 if (*strp != '/') return NULL;
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 strp++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
805 strb = strp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
806 l = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
807
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
808 while (*strp != '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
809 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
810 if (*strp == '/')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
811 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
812 if (l > 0) list = g_list_prepend(list, g_strndup(strb, l));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
813 strp++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
814 strb = strp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
815 l = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
816 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
817 else
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 strp++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
820 l++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
821 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
822 }
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
825 list = g_list_reverse(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
826
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
827 list = g_list_prepend(list, g_strdup("/"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
828
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
829 return list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
830 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
831
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
832 static void parts_list_free(GList *list)
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 GList *work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
835 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
836 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
837 PathData *pd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
838 g_free(pd->name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
839 g_free(pd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
840 work = work->next;
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 g_list_free(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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
846 static GList *parts_list_add_node_points(ViewDirTree *vdt, GList *list)
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 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
849 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
850 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
851 gint valid;
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 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
854 valid = gtk_tree_model_get_iter_first(store, &iter);
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 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
857 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
858 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
859 PathData *pd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
860 FileData *fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
861
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
862 pd = g_new0(PathData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
863 pd->name = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
864
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
865 while (valid && !fd)
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 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
868
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
869 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
870 if (strcmp(nd->fd->name, pd->name) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
871 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
872 fd = nd->fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
873 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
874 else
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 valid = gtk_tree_model_iter_next(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
877 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
878 }
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 pd->node = fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
881 work->data = pd;
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 if (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 GtkTreeIter parent;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
886 memcpy(&parent, &iter, sizeof(parent));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
887 valid = gtk_tree_model_iter_children(store, &iter, &parent);
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 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
891 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
892
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
893 return list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
894 }
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 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
897 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
898 * misc
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
899 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
900 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
901
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
902 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
903 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
904 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
905 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
906 NodeData *nd;
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 gtk_tree_model_get_iter(tree_model, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
909 gtk_tree_model_get(tree_model, &iter, DIR_COLUMN_POINTER, &nd, -1);
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 if (!nd) return;
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 file_data_free(nd->fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
914 g_free(nd);
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 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
917
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
918 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
919 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
920 * node traversal, management
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
921 *----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
922 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
923
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
924 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
925 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
926 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
927
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
928 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
929 if (!nd || !gtk_tree_model_iter_children(store, iter, parent)) return -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
930 do {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
931 NodeData *cnd;
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 gtk_tree_model_get(store, iter, DIR_COLUMN_POINTER, &cnd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
934 if (cnd == nd) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
935 } while (gtk_tree_model_iter_next(store, 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 return FALSE;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
940 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
941 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
942 GtkTreeModel *store;
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 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
945 if (!name || !gtk_tree_model_iter_children(store, iter, parent)) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
946 do {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
947 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
948
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
949 gtk_tree_model_get(store, iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
950 if (nd && strcmp(nd->fd->name, name) == 0) return nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
951 } while (gtk_tree_model_iter_next(store, 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 return NULL;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
956 static void vdtree_add_by_data(ViewDirTree *vdt, FileData *fd, GtkTreeIter *parent)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
957 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
958 GtkTreeStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
959 GtkTreeIter child;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
960 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
961 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
962 GdkPixbuf *pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
963 NodeData *end;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
964 GtkTreeIter empty;
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 if (!fd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
967
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
968 list = parts_list(fd->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
969 if (!list) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
970
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
971 if (access_file(fd->path, R_OK | X_OK))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
972 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
973 pixbuf = vdt->pf->close;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
974 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
975 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
976 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
977 pixbuf = vdt->pf->deny;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
978 }
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 nd = g_new0(NodeData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
981 nd->fd = fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
982 nd->expanded = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
983 nd->last_update = time(NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
984
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
985 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
986 gtk_tree_store_append(store, &child, parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
987 gtk_tree_store_set(store, &child, DIR_COLUMN_POINTER, nd,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
988 DIR_COLUMN_ICON, pixbuf,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
989 DIR_COLUMN_NAME, nd->fd->name,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
990 DIR_COLUMN_COLOR, FALSE, -1);
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 /* 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
993 * this is removed when the child is populated */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
994 end = g_new0(NodeData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
995 end->fd = g_new0(FileData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
996 end->fd->path = g_strdup("");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
997 end->fd->name = end->fd->path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
998 end->expanded = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
999
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1000 gtk_tree_store_append(store, &empty, &child);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1001 gtk_tree_store_set(store, &empty, DIR_COLUMN_POINTER, end,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1002 DIR_COLUMN_NAME, "empty", -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1003
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1004 if (parent)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1005 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1006 NodeData *pnd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1007 GtkTreePath *tpath;
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 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
1010 tpath = gtk_tree_model_get_path(GTK_TREE_MODEL(store), parent);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1011 if (tree_descend_subdirs &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1012 gtk_tree_view_row_expanded(GTK_TREE_VIEW(vdt->treeview), tpath) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1013 !nd->expanded)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1014 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1015 vdtree_populate_path_by_iter(vdt, &child, FALSE, vdt->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1016 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1017 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1018 }
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1021 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
1022 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1023 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1024 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1025 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1026 GList *old;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1027 time_t current_time;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1028 GtkTreeIter child;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1029 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1030
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1031 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1032 gtk_tree_model_get(store, iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1033
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1034 if (!nd) return FALSE;
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 current_time = time(NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1037
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1038 if (nd->expanded)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1039 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1040 if (!force && current_time - nd->last_update < 10) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1041 if (!isdir(nd->fd->path))
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 (vdt->click_fd == nd->fd) vdt->click_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1044 if (vdt->drop_fd == nd->fd) vdt->drop_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1045 gtk_tree_store_remove(GTK_TREE_STORE(store), iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1046 vdtree_node_free(nd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1047 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1048 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1049 if (!force && filetime(nd->fd->path) == nd->fd->date) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1050 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1051
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1052 vdtree_busy_push(vdt);
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 list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1055 filelist_read(nd->fd->path, NULL, &list);
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 /* 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
1058 * 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
1059 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1060 if (!show_dot_files &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1061 target_path &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1062 strncmp(nd->fd->path, target_path, strlen(nd->fd->path)) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1063 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1064 gint n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1065
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1066 n = strlen(nd->fd->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1067 if (target_path[n] == '/' && target_path[n+1] == '.')
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 gchar *name8;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1070 gchar *namel;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1071 struct stat sbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1072
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1073 n++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1074
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1075 while (target_path[n] != '\0' && target_path[n] != '/') n++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1076 name8 = g_strndup(target_path, n);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1077 namel = path_from_utf8(name8);
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 if (stat_utf8(name8, &sbuf))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1080 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1081 list = g_list_prepend(list, file_data_new(namel, &sbuf));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1082 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1083
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1084 g_free(namel);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1085 g_free(name8);
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 }
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 old = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1090 if (gtk_tree_model_iter_children(store, &child, iter))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1091 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1092 do {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1093 NodeData *cnd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1094
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1095 gtk_tree_model_get(store, &child, DIR_COLUMN_POINTER, &cnd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1096 old = g_list_prepend(old, cnd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1097 } while (gtk_tree_model_iter_next(store, &child));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1098 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1099
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1100 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1101 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1102 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1103 FileData *fd;
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 fd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1106 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1107
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1108 if (strcmp(fd->name, ".") == 0 || strcmp(fd->name, "..") == 0)
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 file_data_free(fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1111 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1112 else
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 NodeData *cnd;
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 cnd = vdtree_find_iter_by_name(vdt, iter, fd->name, &child);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1117 if (cnd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1118 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1119 old = g_list_remove(old, cnd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1120 if (cnd->expanded && cnd->fd->date != fd->date &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1121 vdtree_populate_path_by_iter(vdt, &child, FALSE, target_path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1122 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1123 cnd->fd->size = fd->size;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1124 cnd->fd->date = fd->date;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1125 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1126
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1127 file_data_free(fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1128 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1129 else
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 vdtree_add_by_data(vdt, fd, iter);
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 }
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 work = old;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1137 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1138 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1139 NodeData *cnd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1140 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1141
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1142 if (vdt->click_fd == cnd->fd) vdt->click_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1143 if (vdt->drop_fd == cnd->fd) vdt->drop_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1144
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1145 if (vdtree_find_iter_by_data(vdt, iter, cnd, &child))
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 gtk_tree_store_remove(GTK_TREE_STORE(store), &child);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1148 vdtree_node_free(cnd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1149 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1150 }
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 g_list_free(old);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1153 g_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1154
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1155 vdtree_busy_pop(vdt);
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 nd->expanded = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1158 nd->last_update = current_time;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1159
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1160 return TRUE;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1163 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
1164 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1165 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1166 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1167 FileData *fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1168
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1169 if (!path) return 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 vdtree_busy_push(vdt);
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 list = parts_list(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1174 list = parts_list_add_node_points(vdt, list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1175
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1176 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1177 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1178 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1179 PathData *pd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1180 if (pd->node == NULL)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1181 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1182 PathData *parent_pd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1183 GtkTreeIter parent_iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1184 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1185 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1186
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1187 if (work == list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1188 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1189 /* should not happen */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1190 printf("vdtree warning, root node not found\n");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1191 parts_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1192 vdtree_busy_pop(vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1193 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1194 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1195
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1196 parent_pd = work->prev->data;
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 if (!vdtree_find_row(vdt, parent_pd->node, &parent_iter, NULL) ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1199 !vdtree_populate_path_by_iter(vdt, &parent_iter, force, path) ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1200 (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
1201 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1202 printf("vdtree warning, aborted at %s\n", parent_pd->name);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1203 parts_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1204 vdtree_busy_pop(vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1205 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1206 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1207
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1208 pd->node = nd->fd;
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 if (pd->node)
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 (expand)
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 vdtree_expand_by_iter(vdt, &parent_iter, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1215 vdtree_expand_by_iter(vdt, &iter, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1216 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1217 vdtree_populate_path_by_iter(vdt, &iter, force, path);
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 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1220 else
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 GtkTreeIter iter;
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 if (vdtree_find_row(vdt, pd->node, &iter, NULL))
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 (expand) vdtree_expand_by_iter(vdt, &iter, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1227 vdtree_populate_path_by_iter(vdt, &iter, force, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1228 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1229 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1230
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1231 work = work->next;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1234 work = g_list_last(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1235 if (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1236 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1237 PathData *pd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1238 fd = pd->node;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1239 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1240 parts_list_free(list);
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 vdtree_busy_pop(vdt);
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 return fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1245 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1246
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1247 /*
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 * access
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 */
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 static gint selection_is_ok = FALSE;
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 gboolean vdtree_select_cb(GtkTreeSelection *selection, GtkTreeModel *store, GtkTreePath *tpath,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1256 gboolean path_currently_selected, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1257 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1258 return selection_is_ok;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1259 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1260
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1261 static void vdtree_select_row(ViewDirTree *vdt, FileData *fd)
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 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1264 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1265
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1266 if (!vdtree_find_row(vdt, fd, &iter, NULL)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1267 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1268
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1269 /* hack, such that selection is only allowed to be changed from here */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1270 selection_is_ok = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1271 gtk_tree_selection_select_iter(selection, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1272 selection_is_ok = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1273
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1274 if (!vdtree_populate_path_by_iter(vdt, &iter, FALSE, vdt->path)) return;
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 vdtree_expand_by_iter(vdt, &iter, TRUE);
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 if (fd && vdt->select_func)
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 vdt->select_func(vdt, fd->path, vdt->select_data);
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 }
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 gint vdtree_set_path(ViewDirTree *vdt, const gchar *path)
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 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1287 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1288
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1289 if (!path) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1290 if (vdt->path && strcmp(path, vdt->path) == 0) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1291
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1292 g_free(vdt->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1293 vdt->path = g_strdup(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1294
63
e29c291e106b Mon Aug 15 16:35:15 2005 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
1295 fd = vdtree_populate_path(vdt, vdt->path, TRUE, FALSE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1296
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1297 if (!fd) return FALSE;
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 (vdtree_find_row(vdt, fd, &iter, NULL))
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 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1302 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1303
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1304 tree_view_row_make_visible(GTK_TREE_VIEW(vdt->treeview), &iter, TRUE);
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 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1307 tpath = gtk_tree_model_get_path(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1308 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
1309 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1310
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1311 vdtree_select_row(vdt, fd);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1314 return TRUE;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1317 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1318 const gchar *vdtree_get_path(ViewDirTree *vdt)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1319 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1320 return vdt->path;
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 #endif
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 void vdtree_refresh(ViewDirTree *vdt)
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 vdtree_populate_path(vdt, vdt->path, FALSE, TRUE);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1329 const gchar *vdtree_row_get_path(ViewDirTree *vdt, gint row)
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 printf("FIXME: no get row path\n");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1332 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1333 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1334
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1335 /*
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 * callbacks
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 */
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 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
1342 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1343 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1344 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1345 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1346 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1347 gint cw, ch;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1348
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1349 if (vdtree_find_row(vdt, vdt->click_fd, &iter, NULL) < 0) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1350 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1351 tpath = gtk_tree_model_get_path(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1352 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
1353 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1354 *y += ch;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1355 popup_menu_position_clamp(menu, x, y, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1356 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1357
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1358 static gint vdtree_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
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 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1361 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1362 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1363 FileData *fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1364
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1365 gtk_tree_view_get_cursor(GTK_TREE_VIEW(vdt->treeview), &tpath, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1366 if (tpath)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1367 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1368 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1369 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1370
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1371 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1372 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1373 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1374
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1375 gtk_tree_path_free(tpath);
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 fd = (nd) ? nd->fd : NULL;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1380 switch (event->keyval)
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 case GDK_Menu:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1383 vdt->click_fd = fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1384 vdtree_color_set(vdt, vdt->click_fd, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1385
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1386 vdt->popup = vdtree_pop_menu(vdt, vdt->click_fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1387 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
1388
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1389 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1390 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1391 case GDK_plus:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1392 case GDK_Right:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1393 case GDK_KP_Add:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1394 if (fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1395 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1396 vdtree_populate_path_by_iter(vdt, &iter, FALSE, vdt->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1397 vdtree_icon_set_by_iter(vdt, &iter, vdt->pf->open);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1398 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1399 break;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1402 return FALSE;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1405 static gint vdtree_clicked_on_expander(GtkTreeView *treeview, GtkTreePath *tpath,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1406 GtkTreeViewColumn *column, gint x, gint y, gint *left_of_expander)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1407 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1408 gint depth;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1409 gint size;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1410 gint sep;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1411 gint exp_width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1412
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1413 if (column != gtk_tree_view_get_expander_column(treeview)) return FALSE;
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 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
1416 depth = gtk_tree_path_get_depth(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1417
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1418 exp_width = sep + size + sep;
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 if (x <= depth * exp_width)
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 (left_of_expander) *left_of_expander = !(x >= (depth - 1) * exp_width);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1423 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1424 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1425
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1426 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1427 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1428
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1429 static gint vdtree_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
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 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1432 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1433 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1434 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1435 NodeData *nd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1436
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1437 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
1438 &tpath, &column, NULL, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1439 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1440 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1441 gint left_of_expander;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1442
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1443 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1444 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1445 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1446 gtk_tree_view_set_cursor(GTK_TREE_VIEW(widget), tpath, NULL, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1447
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1448 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
1449 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1450 vdt->click_fd = NULL;
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 /* clicking this region should automatically reveal an expander, if necessary
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1453 * 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
1454 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1455 if (bevent->button == 1 &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1456 !left_of_expander &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1457 !gtk_tree_view_row_expanded(GTK_TREE_VIEW(vdt->treeview), tpath))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1458 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1459 vdtree_populate_path_by_iter(vdt, &iter, FALSE, vdt->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1460 vdtree_icon_set_by_iter(vdt, &iter, vdt->pf->open);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1461 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1462
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1463 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1464 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1465 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1466
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1467 gtk_tree_path_free(tpath);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1470 vdt->click_fd = (nd) ? nd->fd : NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1471 vdtree_color_set(vdt, vdt->click_fd, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1472
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1473 if (bevent->button == 3)
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 vdt->popup = vdtree_pop_menu(vdt, vdt->click_fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1476 gtk_menu_popup(GTK_MENU(vdt->popup), NULL, NULL, NULL, NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1477 bevent->button, bevent->time);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1478 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1479
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1480 return (bevent->button != 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1481 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1482
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1483 static gint vdtree_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
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 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1486 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1487 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1488 NodeData *nd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1489
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1490 if (!vdt->click_fd) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1491 vdtree_color_set(vdt, vdt->click_fd, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1492
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1493 if (bevent->button != 1) return TRUE;
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->x != 0 || bevent->y != 0) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1496 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
1497 &tpath, NULL, NULL, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1498 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1499 GtkTreeModel *store;
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 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1502 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1503 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1504 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1505 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1506
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1507 if (nd && vdt->click_fd == nd->fd)
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 vdtree_select_row(vdt, vdt->click_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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1512 return FALSE;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1515 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
1516 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1517 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1518
25
0c3b353b666e Fri Mar 25 22:39:30 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
1519 vdtree_populate_path_by_iter(vdt, iter, FALSE, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1520 vdtree_icon_set_by_iter(vdt, iter, vdt->pf->open);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1521 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1522
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1523 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
1524 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1525 ViewDirTree *vdt = 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 vdtree_icon_set_by_iter(vdt, iter, vdt->pf->close);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1530 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
1531 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1532 NodeData *nda;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1533 NodeData *ndb;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1534
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1535 gtk_tree_model_get(store, a, DIR_COLUMN_POINTER, &nda, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1536 gtk_tree_model_get(store, b, DIR_COLUMN_POINTER, &ndb, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1537
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1538 return CASE_SORT(nda->fd->name, ndb->fd->name);
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
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 * core
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 */
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 static void vdtree_setup_root(ViewDirTree *vdt)
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 const gchar *path = "/";
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1550 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1551
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1552 fd = g_new0(FileData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1553 fd->path = g_strdup(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1554 fd->name = fd->path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1555 fd->size = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1556 fd->date = filetime(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1557 vdtree_add_by_data(vdt, fd, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1558
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1559 vdtree_expand_by_data(vdt, fd, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1560 vdtree_populate_path(vdt, path, FALSE, FALSE);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1563 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
1564 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1565 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1566 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1567 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1568 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1569
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1570 store = gtk_tree_view_get_model(tview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1571 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1572 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1573
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1574 vdtree_select_row(vdt, nd->fd);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1577 static GdkColor *vdtree_color_shifted(GtkWidget *widget)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1578 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1579 static GdkColor color;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1580 static GtkWidget *done = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1581
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1582 if (done != widget)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1583 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1584 GtkStyle *style;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1585
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1586 style = gtk_widget_get_style(widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1587 memcpy(&color, &style->base[GTK_STATE_NORMAL], sizeof(color));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1588 shift_color(&color, -1, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1589 done = widget;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1592 return &color;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1595 static void vdtree_color_cb(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1596 GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1597 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1598 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1599 gboolean set;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1600
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1601 gtk_tree_model_get(tree_model, iter, DIR_COLUMN_COLOR, &set, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1602 g_object_set(G_OBJECT(cell),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1603 "cell-background-gdk", vdtree_color_shifted(vdt->treeview),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1604 "cell-background-set", set, NULL);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1607 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
1608 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1609 NodeData *nd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1610
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1611 gtk_tree_model_get(store, iter, DIR_COLUMN_POINTER, &nd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1612 vdtree_node_free(nd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1613
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1614 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1615 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1616
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1617 static void vdtree_destroy_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1618 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1619 ViewDirTree *vdt = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1620 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1621
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1622 if (vdt->popup)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1623 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1624 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
1625 0, 0, 0, NULL, vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1626 gtk_widget_destroy(vdt->popup);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1629 vdtree_dnd_drop_expand_cancel(vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1630 vdtree_dnd_drop_scroll_cancel(vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1631 widget_auto_scroll_stop(vdt->treeview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1632
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1633 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1634 gtk_tree_model_foreach(store, vdtree_destroy_node_cb, vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1635
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1636 path_list_free(vdt->drop_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1637
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1638 folder_icons_free(vdt->pf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1639
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1640 g_free(vdt->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1641 g_free(vdt);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1644 ViewDirTree *vdtree_new(const gchar *path, gint expand)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1645 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1646 ViewDirTree *vdt;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1647 GtkTreeStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1648 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1649 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1650 GtkCellRenderer *renderer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1651
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1652 vdt = g_new0(ViewDirTree, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1653
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1654 vdt->path = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1655 vdt->click_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1656
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1657 vdt->drop_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1658 vdt->drop_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1659 vdt->drop_scroll_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1660 vdt->drop_expand_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1661
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1662 vdt->popup = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1663
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1664 vdt->busy_ref = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1665
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1666 vdt->widget = gtk_scrolled_window_new(NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1667 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
1668 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(vdt->widget),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1669 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1670 g_signal_connect(G_OBJECT(vdt->widget), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1671 G_CALLBACK(vdtree_destroy_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1672
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1673 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
1674 vdt->treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1675 g_object_unref(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1676
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1677 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(vdt->treeview), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1678 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(vdt->treeview), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1679 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
1680 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1681 GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, GTK_SORT_ASCENDING);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1682
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1683 g_signal_connect(G_OBJECT(vdt->treeview), "row_activated",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1684 G_CALLBACK(vdtree_activate_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1685 g_signal_connect(G_OBJECT(vdt->treeview), "row_expanded",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1686 G_CALLBACK(vdtree_row_expanded), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1687 g_signal_connect(G_OBJECT(vdt->treeview), "row_collapsed",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1688 G_CALLBACK(vdtree_row_collapsed), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1689 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1690 g_signal_connect(G_OBJECT(store), "row_deleted",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1691 G_CALLBACK(vdtree_row_deleted_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1692 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1693
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1694 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vdt->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1695 gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1696 gtk_tree_selection_set_select_function(selection, vdtree_select_cb, vdt, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1697
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1698 column = gtk_tree_view_column_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1699 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
1700
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1701 renderer = gtk_cell_renderer_pixbuf_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1702 gtk_tree_view_column_pack_start(column, renderer, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1703 gtk_tree_view_column_add_attribute(column, renderer, "pixbuf", DIR_COLUMN_ICON);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1704 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
1705
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1706 renderer = gtk_cell_renderer_text_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1707 gtk_tree_view_column_pack_start(column, renderer, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1708 gtk_tree_view_column_add_attribute(column, renderer, "text", DIR_COLUMN_NAME);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1709 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
1710
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1711 gtk_tree_view_append_column(GTK_TREE_VIEW(vdt->treeview), column);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1712
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1713 g_signal_connect(G_OBJECT(vdt->treeview), "key_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1714 G_CALLBACK(vdtree_press_key_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1715
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1716 gtk_container_add(GTK_CONTAINER(vdt->widget), vdt->treeview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1717 gtk_widget_show(vdt->treeview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1718
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1719 vdt->pf = folder_icons_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1720
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1721 vdtree_setup_root(vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1722
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1723 vdtree_dnd_init(vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1724
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1725 g_signal_connect(G_OBJECT(vdt->treeview), "button_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1726 G_CALLBACK(vdtree_press_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1727 g_signal_connect(G_OBJECT(vdt->treeview), "button_release_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1728 G_CALLBACK(vdtree_release_cb), vdt);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1729
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1730 vdtree_set_path(vdt, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1731
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1732 return vdt;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1735 void vdtree_set_select_func(ViewDirTree *vdt,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1736 void (*func)(ViewDirTree *vdt, const gchar *path, gpointer data), gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1737 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1738 vdt->select_func = func;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1739 vdt->select_data = data;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1742 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1743 void vdtree_set_click_func(ViewDirTree *vdt,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1744 void (*func)(ViewDirTree *vdt, GdkEventButton *event, FileData *fd, gpointer), gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1745 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1746 if (!td) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1747 vdt->click_func = func;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1748 vdt->click_data = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1749 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1750 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1751
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1752 void vdtree_set_layout(ViewDirTree *vdt, LayoutWindow *layout)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1753 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1754 vdt->layout = layout;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1755 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1756