annotate src/view_dir_list.c @ 134:9009856628f7

started implementation of external commands; external Delete should work
author nadvornik
date Wed, 15 Aug 2007 21:37:51 +0000
parents b15d4c18168f
children 71e1ebee420e
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_list.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 #include "dnd.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
16 #include "dupe.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
17 #include "filelist.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
18 #include "layout.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
19 #include "layout_image.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
20 #include "layout_util.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
21 #include "utilops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
22 #include "ui_bookmark.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
23 #include "ui_fileops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
24 #include "ui_menu.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
25 #include "ui_tree_edit.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
26
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
27 #include <gdk/gdkkeysyms.h> /* for keyboard values */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
28
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
29
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
30 #define VDLIST_PAD 4
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
31
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
32
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
33 enum {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
34 DIR_COLUMN_POINTER = 0,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
35 DIR_COLUMN_ICON,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
36 DIR_COLUMN_NAME,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
37 DIR_COLUMN_COLOR,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
38 DIR_COLUMN_COUNT
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
39 };
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 static void vdlist_popup_destroy_cb(GtkWidget *widget, gpointer data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
43 static gint vdlist_auto_scroll_notify_cb(GtkWidget *widget, gint x, gint y, gpointer data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
44
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
45 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
46 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
47 * misc
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
51 static gint vdlist_find_row(ViewDirList *vdl, FileData *fd, GtkTreeIter *iter)
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 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
54 gint valid;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
55 gint row = 0;
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 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
58 valid = gtk_tree_model_get_iter_first(store, iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
59 while (valid)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
60 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
61 FileData *fd_n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
62 gtk_tree_model_get(GTK_TREE_MODEL(store), iter, DIR_COLUMN_POINTER, &fd_n, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
63 if (fd_n == fd) return row;
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 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
66 row++;
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 return -1;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
72 static gint vdlist_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
73 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
74 ViewDirList *vdl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
75 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
76 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
77 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
78 gchar *old_path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
79 gchar *new_path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
80 gchar *base;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
81
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
82 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
83 if (!gtk_tree_model_get_iter(store, &iter, td->path)) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
84 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &fd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
85 if (!fd) return FALSE;
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 old_path = g_strdup(fd->path);
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 base = remove_level_from_path(old_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
90 new_path = concat_dir_and_file(base, new);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
91 g_free(base);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
92
44
458e396d3f35 Wed May 18 19:36:49 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
93 if (file_util_rename_dir(old_path, new_path, vdl->listview))
9
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 if (vdl->layout && strcmp(vdl->path, old_path) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
96 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
97 layout_set_path(vdl->layout, new_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
98 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
99 else
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 vdlist_refresh(vdl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
102 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
103 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
104
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
105 g_free(old_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
106 g_free(new_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
107 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
108 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
109
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
110 static void vdlist_rename_by_row(ViewDirList *vdl, FileData *fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
111 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
112 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
113 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
114 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
115
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
116 if (vdlist_find_row(vdl, fd, &iter) < 0) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
117 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
118 tpath = gtk_tree_model_get_path(store, &iter);
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 tree_edit_by_path(GTK_TREE_VIEW(vdl->listview), tpath, 0, fd->name,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
121 vdlist_rename_row_cb, vdl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
122 gtk_tree_path_free(tpath);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
125 static FileData *vdlist_row_by_path(ViewDirList *vdl, const gchar *path, gint *row)
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 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
128 gint n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
129
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
130 if (!path)
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 if (row) *row = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
133 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
134 }
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 n = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
137 work = vdl->list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
138 while (work)
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 FileData *fd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
141 if (strcmp(fd->path, path) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
142 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
143 if (row) *row = n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
144 return fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
145 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
146 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
147 n++;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
150 if (row) *row = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
151 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
152 }
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 static void vdlist_color_set(ViewDirList *vdl, FileData *fd, gint color_set)
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 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
157 GtkTreeIter iter;
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 if (vdlist_find_row(vdl, fd, &iter) < 0) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
160 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
161 gtk_list_store_set(GTK_LIST_STORE(store), &iter, DIR_COLUMN_COLOR, color_set, -1);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
164 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
165 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
166 * drop menu (from dnd)
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
170 static void vdlist_drop_menu_copy_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
171 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
172 ViewDirList *vdl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
173 const gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
174 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
175
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
176 if (!vdl->drop_fd) return;
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 path = vdl->drop_fd->path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
179 list = vdl->drop_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
180 vdl->drop_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
181
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
182 file_util_copy_simple(list, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
183 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
184
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
185 static void vdlist_drop_menu_move_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
186 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
187 ViewDirList *vdl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
188 const gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
189 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
190
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
191 if (!vdl->drop_fd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
192
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
193 path = vdl->drop_fd->path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
194 list = vdl->drop_list;
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 vdl->drop_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
197
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
198 file_util_move_simple(list, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
199 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
200
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
201 static GtkWidget *vdlist_drop_menu(ViewDirList *vdl, gint active)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
202 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
203 GtkWidget *menu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
204
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
205 menu = popup_menu_short_lived();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
206 g_signal_connect(G_OBJECT(menu), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
207 G_CALLBACK(vdlist_popup_destroy_cb), vdl);
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 menu_item_add_stock_sensitive(menu, _("_Copy"), GTK_STOCK_COPY, active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
210 G_CALLBACK(vdlist_drop_menu_copy_cb), vdl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
211 menu_item_add_sensitive(menu, _("_Move"), active, G_CALLBACK(vdlist_drop_menu_move_cb), vdl);
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 menu_item_add_divider(menu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
214 menu_item_add_stock(menu, _("Cancel"), GTK_STOCK_CANCEL, NULL, vdl);
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 return menu;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
219 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
220 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
221 * pop-up menu
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
222 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
223 */
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 static void vdlist_pop_menu_up_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
226 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
227 ViewDirList *vdl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
228 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
229
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
230 if (!vdl->path || strcmp(vdl->path, "/") == 0) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
231 path = remove_level_from_path(vdl->path);
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 if (vdl->select_func)
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 vdl->select_func(vdl, path, vdl->select_data);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
238 g_free(path);
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 vdlist_pop_menu_slide_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 ViewDirList *vdl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
244 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
245
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
246 if (!vdl->layout || !vdl->click_fd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
247
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
248 path = g_strdup(vdl->click_fd->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
249
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
250 layout_set_path(vdl->layout, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
251 layout_select_none(vdl->layout);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
252 layout_image_slideshow_stop(vdl->layout);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
253 layout_image_slideshow_start(vdl->layout);
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 g_free(path);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
258 static void vdlist_pop_menu_slide_rec_cb(GtkWidget *widget, gpointer data)
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 ViewDirList *vdl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
261 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
262 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
263
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
264 if (!vdl->layout || !vdl->click_fd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
265
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
266 path = g_strdup(vdl->click_fd->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
267
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
268 list = path_list_recursive(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
269
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
270 layout_image_slideshow_stop(vdl->layout);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
271 layout_image_slideshow_start_from_list(vdl->layout, list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
272
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
273 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
274 }
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 static void vdlist_pop_menu_dupe(ViewDirList *vdl, gint recursive)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
277 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
278 DupeWindow *dw;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
279 const gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
280 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
281
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
282 if (!vdl->click_fd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
283 path = vdl->click_fd->path;
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 if (recursive)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
286 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
287 list = g_list_append(list, g_strdup(path));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
288 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
289 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
290 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
291 path_list(path, &list, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
292 list = path_list_filter(list, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
293 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
294
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
295 dw = dupe_window_new(DUPE_MATCH_NAME);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
296 dupe_window_add_files(dw, list, recursive);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
297
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
298 path_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
299 }
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 static void vdlist_pop_menu_dupe_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
302 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
303 ViewDirList *vdl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
304 vdlist_pop_menu_dupe(vdl, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
305 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
306
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
307 static void vdlist_pop_menu_dupe_rec_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
308 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
309 ViewDirList *vdl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
310 vdlist_pop_menu_dupe(vdl, TRUE);
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 static void vdlist_pop_menu_new_cb(GtkWidget *widget, gpointer data)
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 ViewDirList *vdl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
316 gchar *new_path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
317 gchar *buf;
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 if (!vdl->path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
320
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
321 buf = concat_dir_and_file(vdl->path, _("new_folder"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
322 new_path = unique_filename(buf, NULL, NULL, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
323 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
324 if (!new_path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
325
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
326 if (!mkdir_utf8(new_path, 0755))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
327 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
328 gchar *text;
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 text = g_strdup_printf(_("Unable to create folder:\n%s"), new_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
331 file_util_warning_dialog(_("Error creating folder"), text, GTK_STOCK_DIALOG_ERROR, vdl->listview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
332 g_free(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
333 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
334 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
335 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
336 FileData *fd;
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 vdlist_refresh(vdl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
339 fd = vdlist_row_by_path(vdl, new_path, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
340
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
341 vdlist_rename_by_row(vdl, fd);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
344 g_free(new_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
345 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
346
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
347 static void vdlist_pop_menu_rename_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
348 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
349 ViewDirList *vdl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
350
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
351 vdlist_rename_by_row(vdl, vdl->click_fd);
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
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
354 static void vdlist_pop_menu_delete_cb(GtkWidget *widget, gpointer data)
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
355 {
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
356 ViewDirList *vdl = data;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
357
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
358 if (!vdl->click_fd) return;
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
359 file_util_delete_dir(vdl->click_fd->path, vdl->widget);
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
360 }
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
361
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
362 static void vdlist_pop_menu_tree_cb(GtkWidget *widget, gpointer data)
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 ViewDirList *vdl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
365
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
366 if (vdl->layout) layout_views_set(vdl->layout, TRUE, vdl->layout->icon_view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
367 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
368
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
369 static void vdlist_pop_menu_refresh_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
370 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
371 ViewDirList *vdl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
372
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
373 if (vdl->layout) layout_refresh(vdl->layout);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
374 }
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 static GtkWidget *vdlist_pop_menu(ViewDirList *vdl, FileData *fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
377 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
378 GtkWidget *menu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
379 gint active;
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 active = (fd != NULL);
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 menu = popup_menu_short_lived();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
384 g_signal_connect(G_OBJECT(menu), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
385 G_CALLBACK(vdlist_popup_destroy_cb), vdl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
386
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
387 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
388 (vdl->path && strcmp(vdl->path, "/") != 0),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
389 G_CALLBACK(vdlist_pop_menu_up_cb), vdl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
390
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
391 menu_item_add_divider(menu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
392 menu_item_add_sensitive(menu, _("_Slideshow"), active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
393 G_CALLBACK(vdlist_pop_menu_slide_cb), vdl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
394 menu_item_add_sensitive(menu, _("Slideshow recursive"), active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
395 G_CALLBACK(vdlist_pop_menu_slide_rec_cb), vdl);
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 menu_item_add_divider(menu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
398 menu_item_add_stock_sensitive(menu, _("Find _duplicates..."), GTK_STOCK_FIND, active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
399 G_CALLBACK(vdlist_pop_menu_dupe_cb), vdl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
400 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
401 G_CALLBACK(vdlist_pop_menu_dupe_rec_cb), vdl);
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 menu_item_add_divider(menu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
404
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
405 /* check using . (always row 0) */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
406 active = (vdl->path && access_file(vdl->path , W_OK | X_OK));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
407 menu_item_add_sensitive(menu, _("_New folder..."), active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
408 G_CALLBACK(vdlist_pop_menu_new_cb), vdl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
409
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
410 /* ignore .. and . */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
411 active = (active && fd &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
412 strcmp(fd->name, ".") != 0 &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
413 strcmp(fd->name, "..") != 0 &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
414 access_file(fd->path, W_OK | X_OK));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
415 menu_item_add_sensitive(menu, _("_Rename..."), active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
416 G_CALLBACK(vdlist_pop_menu_rename_cb), vdl);
112
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
417 menu_item_add_stock_sensitive(menu, _("_Delete..."), GTK_STOCK_DELETE, active,
b15d4c18168f Fri Nov 17 19:06:19 2006 John Ellis <johne@verizon.net>
gqview
parents: 64
diff changeset
418 G_CALLBACK(vdlist_pop_menu_delete_cb), vdl);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
419
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
420 menu_item_add_divider(menu);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
421 menu_item_add_check(menu, _("View as _tree"), FALSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
422 G_CALLBACK(vdlist_pop_menu_tree_cb), vdl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
423 menu_item_add_stock(menu, _("Re_fresh"), GTK_STOCK_REFRESH,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
424 G_CALLBACK(vdlist_pop_menu_refresh_cb), vdl);
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 return menu;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
427 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
428
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
429 static void vdlist_popup_destroy_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
430 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
431 ViewDirList *vdl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
432
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
433 vdlist_color_set(vdl, vdl->click_fd, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
434 vdl->click_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
435 vdl->popup = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
436
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
437 vdlist_color_set(vdl, vdl->drop_fd, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
438 path_list_free(vdl->drop_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
439 vdl->drop_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
440 vdl->drop_fd = NULL;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
443 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
444 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
445 * dnd
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
446 *-----------------------------------------------------------------------------
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 GtkTargetEntry vdlist_dnd_drop_types[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
450 { "text/uri-list", 0, TARGET_URI_LIST }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
451 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
452 static gint vdlist_dnd_drop_types_count = 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
453
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
454 static void vdlist_dest_set(ViewDirList *vdl, gint enable)
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 if (enable)
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 gtk_drag_dest_set(vdl->listview,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
459 GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
460 vdlist_dnd_drop_types, vdlist_dnd_drop_types_count,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
461 GDK_ACTION_MOVE | GDK_ACTION_COPY);
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 else
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 gtk_drag_dest_unset(vdl->listview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
466 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
467 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
468
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
469 static void vdlist_dnd_get(GtkWidget *widget, GdkDragContext *context,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
470 GtkSelectionData *selection_data, guint info,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
471 guint time, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
472 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
473 ViewDirList *vdl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
474 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
475 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
476 gchar *text = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
477 gint length = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
478
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
479 if (!vdl->click_fd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
480 path = vdl->click_fd->path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
481
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
482 switch (info)
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 case TARGET_URI_LIST:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
485 case TARGET_TEXT_PLAIN:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
486 list = g_list_prepend(NULL, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
487 text = uri_text_from_list(list, &length, (info == TARGET_TEXT_PLAIN));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
488 g_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
489 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
490 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
491 if (text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
492 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
493 gtk_selection_data_set (selection_data, selection_data->target,
64
04ff0df3ad2f Mon Aug 15 17:13:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
494 8, (guchar *)text, length);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
495 g_free(text);
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 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
498
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
499 static void vdlist_dnd_begin(GtkWidget *widget, GdkDragContext *context, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
500 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
501 ViewDirList *vdl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
502
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
503 vdlist_color_set(vdl, vdl->click_fd, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
504 vdlist_dest_set(vdl, FALSE);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
507 static void vdlist_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer data)
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 ViewDirList *vdl = data;
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 vdlist_color_set(vdl, vdl->click_fd, FALSE);
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 if (context->action == GDK_ACTION_MOVE)
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 vdlist_refresh(vdl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
516 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
517 vdlist_dest_set(vdl, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
518 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
519
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
520 static void vdlist_dnd_drop_receive(GtkWidget *widget,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
521 GdkDragContext *context, gint x, gint y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
522 GtkSelectionData *selection_data, guint info,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
523 guint time, gpointer data)
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 ViewDirList *vdl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
526 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
527 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
528 FileData *fd = NULL;
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 vdl->click_fd = NULL;
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 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
533 &tpath, NULL, NULL, NULL))
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 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
536
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
537 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
538 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
539 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &fd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
540 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
541 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
542
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
543 if (!fd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
544
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
545 if (info == TARGET_URI_LIST)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
546 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
547 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
548 gint active;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
549
64
04ff0df3ad2f Mon Aug 15 17:13:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 44
diff changeset
550 list = uri_list_from_text((gchar *)selection_data->data, TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
551 if (!list) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
552
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
553 active = access_file(fd->path, W_OK | X_OK);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
554
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
555 vdlist_color_set(vdl, fd, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
556 vdl->popup = vdlist_drop_menu(vdl, active);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
557 gtk_menu_popup(GTK_MENU(vdl->popup), NULL, NULL, NULL, NULL, 0, time);
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 vdl->drop_fd = fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
560 vdl->drop_list = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
561 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
562 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
563
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
564 #if 0
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
565 static gint vdlist_get_row_visibility(ViewDirList *vdl, FileData *fd)
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 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
568 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
569 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
570 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
571
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
572 GdkRectangle vrect;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
573 GdkRectangle crect;
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 if (!fd || vdlist_find_row(vdl, fd, &iter) < 0) return 0;
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 column = gtk_tree_view_get_column(GTK_TREE_VIEW(vdl->listview), 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
578 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
579 tpath = gtk_tree_model_get_path(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
580
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
581 gtk_tree_view_get_visible_rect(GTK_TREE_VIEW(vdl->listview), &vrect);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
582 gtk_tree_view_get_cell_area(GTK_TREE_VIEW(vdl->listview), tpath, column, &crect);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
583 printf("window: %d + %d; cell: %d + %d\n", vrect.y, vrect.height, crect.y, crect.height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
584 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
585
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
586 if (crect.y + crect.height < vrect.y) return -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
587 if (crect.y > vrect.y + vrect.height) return 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
588 return 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
589 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
590 #endif
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
591
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
592 static void vdlist_scroll_to_row(ViewDirList *vdl, FileData *fd, gfloat y_align)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
593 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
594 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
595
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
596 if (GTK_WIDGET_REALIZED(vdl->listview) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
597 vdlist_find_row(vdl, fd, &iter) >= 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
598 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
599 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
600 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
601
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
602 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
603 tpath = gtk_tree_model_get_path(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
604 gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(vdl->listview), tpath, NULL, TRUE, y_align, 0.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
605 gtk_tree_view_set_cursor(GTK_TREE_VIEW(vdl->listview), tpath, NULL, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
606 gtk_tree_path_free(tpath);
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 if (!GTK_WIDGET_HAS_FOCUS(vdl->listview)) gtk_widget_grab_focus(vdl->listview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
609 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
610 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
611
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
612 static void vdlist_drop_update(ViewDirList *vdl, gint x, gint y)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
613 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
614 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
615 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
616 FileData *fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
617
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
618 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vdl->listview), x, y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
619 &tpath, NULL, NULL, NULL))
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 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
622
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
623 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
624 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
625 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &fd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
626 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
627 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
628
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
629 if (fd != vdl->drop_fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
630 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
631 vdlist_color_set(vdl, vdl->drop_fd, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
632 vdlist_color_set(vdl, fd, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
633 }
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 vdl->drop_fd = fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
636 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
637
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
638 static void vdlist_dnd_drop_scroll_cancel(ViewDirList *vdl)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
639 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
640 if (vdl->drop_scroll_id != -1) g_source_remove(vdl->drop_scroll_id);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
641 vdl->drop_scroll_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
642 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
643
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
644 static gint vdlist_auto_scroll_idle_cb(gpointer data)
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 ViewDirList *vdl = data;
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 (vdl->drop_fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
649 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
650 GdkWindow *window;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
651 gint x, y;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
652 gint w, h;
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 window = vdl->listview->window;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
655 gdk_window_get_pointer(window, &x, &y, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
656 gdk_drawable_get_size(window, &w, &h);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
657 if (x >= 0 && x < w && y >= 0 && y < h)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
658 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
659 vdlist_drop_update(vdl, x, y);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
660 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
661 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
662
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
663 vdl->drop_scroll_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
664 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
665 }
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 static gint vdlist_auto_scroll_notify_cb(GtkWidget *widget, gint x, gint y, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
668 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
669 ViewDirList *vdl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
670
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
671 if (!vdl->drop_fd || vdl->drop_list) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
672
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
673 if (vdl->drop_scroll_id == -1) vdl->drop_scroll_id = g_idle_add(vdlist_auto_scroll_idle_cb, vdl);
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 return TRUE;
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 static gint vdlist_dnd_drop_motion(GtkWidget *widget, GdkDragContext *context,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
679 gint x, gint y, guint time, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
680 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
681 ViewDirList *vdl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
682
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
683 vdl->click_fd = NULL;
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 if (gtk_drag_get_source_widget(context) == vdl->listview)
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 /* from same window */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
688 gdk_drag_status(context, 0, time);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
689 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
690 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
691 else
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 gdk_drag_status(context, context->suggested_action, time);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
694 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
695
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
696 vdlist_drop_update(vdl, x, y);
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 (vdl->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 GtkAdjustment *adj = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(vdl->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
701 widget_auto_scroll_start(vdl->listview, adj, -1, -1, vdlist_auto_scroll_notify_cb, vdl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
702 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
703
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
704 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
705 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
706
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
707 static void vdlist_dnd_drop_leave(GtkWidget *widget, GdkDragContext *context, guint time, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
708 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
709 ViewDirList *vdl = data;
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 if (vdl->drop_fd != vdl->click_fd) vdlist_color_set(vdl, vdl->drop_fd, FALSE);
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 vdl->drop_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
714 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
715
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
716 static void vdlist_dnd_init(ViewDirList *vdl)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
717 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
718 gtk_drag_source_set(vdl->listview, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
719 dnd_file_drag_types, dnd_file_drag_types_count,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
720 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
721 g_signal_connect(G_OBJECT(vdl->listview), "drag_data_get",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
722 G_CALLBACK(vdlist_dnd_get), vdl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
723 g_signal_connect(G_OBJECT(vdl->listview), "drag_begin",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
724 G_CALLBACK(vdlist_dnd_begin), vdl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
725 g_signal_connect(G_OBJECT(vdl->listview), "drag_end",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
726 G_CALLBACK(vdlist_dnd_end), vdl);
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 vdlist_dest_set(vdl, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
729 g_signal_connect(G_OBJECT(vdl->listview), "drag_data_received",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
730 G_CALLBACK(vdlist_dnd_drop_receive), vdl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
731 g_signal_connect(G_OBJECT(vdl->listview), "drag_motion",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
732 G_CALLBACK(vdlist_dnd_drop_motion), vdl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
733 g_signal_connect(G_OBJECT(vdl->listview), "drag_leave",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
734 G_CALLBACK(vdlist_dnd_drop_leave), vdl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
735 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
736
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
737 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
738 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
739 * main
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
740 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
741 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
742
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
743 static void vdlist_select_row(ViewDirList *vdl, FileData *fd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
744 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
745 if (fd && vdl->select_func)
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 gchar *path;
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 path = g_strdup(fd->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
750 vdl->select_func(vdl, path, vdl->select_data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
751 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
752 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
753 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
754
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
755 const gchar *vdlist_row_get_path(ViewDirList *vdl, gint row)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
756 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
757 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
758
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
759 fd = g_list_nth_data(vdl->list, row);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
760
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
761 if (fd) return fd->path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
762
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
763 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
764 }
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 static void vdlist_populate(ViewDirList *vdl)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
767 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
768 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
769 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
770
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
771 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->listview)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
772 gtk_list_store_clear(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
773
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
774 work = vdl->list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
775 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
776 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
777 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
778 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
779 GdkPixbuf *pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
780
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
781 fd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
782
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
783 if (access_file(fd->path, R_OK | X_OK) && fd->name)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
784 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
785 if (fd->name[0] == '.' && fd->name[1] == '\0')
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 pixbuf = vdl->pf->open;
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 else if (fd->name[0] == '.' && fd->name[1] == '.' && fd->name[2] == '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
790 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
791 pixbuf = vdl->pf->parent;
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
794 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
795 pixbuf = vdl->pf->close;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
796 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
797 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
798 else
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 pixbuf = vdl->pf->deny;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
801 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
802
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
803 gtk_list_store_append(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
804 gtk_list_store_set(store, &iter,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
805 DIR_COLUMN_POINTER, fd,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
806 DIR_COLUMN_ICON, pixbuf,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
807 DIR_COLUMN_NAME, fd->name, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
808
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
809 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
810 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
811
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
812 vdl->click_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
813 vdl->drop_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
814 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
815
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
816 gint vdlist_set_path(ViewDirList *vdl, const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
817 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
818 gint ret;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
819 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
820 gchar *old_path = NULL;
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 if (!path) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
823 if (vdl->path && strcmp(path, vdl->path) == 0) return TRUE;
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 if (vdl->path)
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 gchar *base;
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 base = remove_level_from_path(vdl->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
830 if (strcmp(base, path) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
831 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
832 old_path = g_strdup(filename_from_path(vdl->path));
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 g_free(base);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
835 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
836
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
837 g_free(vdl->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
838 vdl->path = g_strdup(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
839
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
840 filelist_free(vdl->list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
841 vdl->list = NULL;
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 ret = filelist_read(vdl->path, NULL, &vdl->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 vdl->list = filelist_sort(vdl->list, SORT_NAME, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
846
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
847 /* add . and .. */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
848
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
849 if (strcmp(vdl->path, "/") != 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
850 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
851 fd = g_new0(FileData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
852 fd->path = remove_level_from_path(vdl->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
853 fd->name = "..";
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
854 vdl->list = g_list_prepend(vdl->list, fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
855 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
856
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
857 fd = g_new0(FileData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
858 fd->path = g_strdup(vdl->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
859 fd->name = ".";
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
860 vdl->list = g_list_prepend(vdl->list, fd);
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 vdlist_populate(vdl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
863
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
864 if (old_path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
865 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
866 /* scroll to make last path visible */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
867 FileData *found = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
868 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
869
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
870 work = vdl->list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
871 while (work && !found)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
872 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
873 FileData *fd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
874 if (strcmp(old_path, fd->name) == 0) found = fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
875 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
876 }
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 if (found) vdlist_scroll_to_row(vdl, found, 0.5);
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 g_free(old_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
881 return ret;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
882 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
883
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
884 if (GTK_WIDGET_REALIZED(vdl->listview))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
885 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
886 gtk_tree_view_scroll_to_point(GTK_TREE_VIEW(vdl->listview), 0, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
887 }
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 return ret;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
890 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
891
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
892 void vdlist_refresh(ViewDirList *vdl)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
893 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
894 gchar *path;
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 path = g_strdup(vdl->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
897 vdl->path = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
898 vdlist_set_path(vdl, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
899 g_free(path);
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 static void vdlist_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
903 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
904 ViewDirList *vdl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
905 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
906 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
907 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
908 gint cw, ch;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
909
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
910 if (vdlist_find_row(vdl, vdl->click_fd, &iter) < 0) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
911 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
912 tpath = gtk_tree_model_get_path(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
913 tree_view_get_cell_clamped(GTK_TREE_VIEW(vdl->listview), tpath, 0, TRUE, x, y, &cw, &ch);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
914 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
915 *y += ch;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
916 popup_menu_position_clamp(menu, x, y, 0);
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 static gint vdlist_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
920 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
921 ViewDirList *vdl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
922 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
923
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
924 if (event->keyval != GDK_Menu) return FALSE;
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 gtk_tree_view_get_cursor(GTK_TREE_VIEW(vdl->listview), &tpath, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
927 if (tpath)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
928 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
929 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
930 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
931
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
932 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
933 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
934 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &vdl->click_fd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
935
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
936 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
937 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
938 else
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 vdl->click_fd = NULL;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
943 vdlist_color_set(vdl, vdl->click_fd, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
944
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
945 vdl->popup = vdlist_pop_menu(vdl, vdl->click_fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
946
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
947 gtk_menu_popup(GTK_MENU(vdl->popup), NULL, NULL, vdlist_menu_position_cb, vdl, 0, GDK_CURRENT_TIME);
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 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
950 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
951
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
952 static gint vdlist_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
953 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
954 ViewDirList *vdl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
955 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
956 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
957 FileData *fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
958
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
959 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
960 &tpath, NULL, NULL, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
961 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
962 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
963
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
964 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
965 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
966 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &fd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
967 gtk_tree_view_set_cursor(GTK_TREE_VIEW(widget), tpath, NULL, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
968 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
969 }
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 vdl->click_fd = fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
972 vdlist_color_set(vdl, vdl->click_fd, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
973
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
974 if (bevent->button == 3)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
975 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
976 vdl->popup = vdlist_pop_menu(vdl, vdl->click_fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
977 gtk_menu_popup(GTK_MENU(vdl->popup), NULL, NULL, NULL, NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
978 bevent->button, bevent->time);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
981 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
982 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
983
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
984 static gint vdlist_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
985 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
986 ViewDirList *vdl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
987 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
988 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
989 FileData *fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
990
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
991 vdlist_color_set(vdl, vdl->click_fd, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
992
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
993 if (bevent->button != 1) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
994
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
995 if ((bevent->x != 0 || bevent->y != 0) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
996 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
997 &tpath, NULL, NULL, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
998 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
999 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1000
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1001 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1002 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1003 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &fd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1004 gtk_tree_path_free(tpath);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1007 if (fd && vdl->click_fd == fd)
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 vdlist_select_row(vdl, vdl->click_fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1010 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1011
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1012 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1013 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1014
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1015 static void vdlist_select_cb(GtkTreeView *tview, GtkTreePath *tpath, GtkTreeViewColumn *column, gpointer data)
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 ViewDirList *vdl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1018 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1019 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1020 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1021
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1022 store = gtk_tree_view_get_model(tview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1023 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1024 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &fd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1025
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1026 vdlist_select_row(vdl, fd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1027 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1028
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1029 static GdkColor *vdlist_color_shifted(GtkWidget *widget)
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 static GdkColor color;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1032 static GtkWidget *done = NULL;
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 (done != widget)
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 GtkStyle *style;
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 style = gtk_widget_get_style(widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1039 memcpy(&color, &style->base[GTK_STATE_NORMAL], sizeof(color));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1040 shift_color(&color, -1, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1041 done = widget;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1044 return &color;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1045 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1046
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1047 static void vdlist_color_cb(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1048 GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1049 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1050 ViewDirList *vdl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1051 gboolean set;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1052
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1053 gtk_tree_model_get(tree_model, iter, DIR_COLUMN_COLOR, &set, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1054 g_object_set(G_OBJECT(cell),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1055 "cell-background-gdk", vdlist_color_shifted(vdl->listview),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1056 "cell-background-set", set, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1057 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1058
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1059 static void vdlist_destroy_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1060 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1061 ViewDirList *vdl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1062
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1063 if (vdl->popup)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1064 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1065 g_signal_handlers_disconnect_matched(G_OBJECT(vdl->popup), G_SIGNAL_MATCH_DATA,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1066 0, 0, 0, NULL, vdl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1067 gtk_widget_destroy(vdl->popup);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1070 vdlist_dnd_drop_scroll_cancel(vdl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1071 widget_auto_scroll_stop(vdl->listview);
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 path_list_free(vdl->drop_list);
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 folder_icons_free(vdl->pf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1076
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1077 g_free(vdl->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1078 filelist_free(vdl->list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1079 g_free(vdl);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1082 ViewDirList *vdlist_new(const gchar *path)
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 ViewDirList *vdl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1085 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1086 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1087 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1088 GtkCellRenderer *renderer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1089
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1090 vdl = g_new0(ViewDirList, 1);
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 vdl->path = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1093 vdl->list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1094 vdl->click_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1095
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1096 vdl->drop_fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1097 vdl->drop_list = NULL;
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 vdl->drop_scroll_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1100
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1101 vdl->popup = NULL;
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 vdl->widget = gtk_scrolled_window_new(NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1104 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(vdl->widget), GTK_SHADOW_IN);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1105 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(vdl->widget),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1106 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1107 g_signal_connect(G_OBJECT(vdl->widget), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1108 G_CALLBACK(vdlist_destroy_cb), vdl);
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 store = gtk_list_store_new(4, G_TYPE_POINTER, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_BOOLEAN);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1111 vdl->listview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1112 g_object_unref(store);
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 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(vdl->listview), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1115 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(vdl->listview), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1116 g_signal_connect(G_OBJECT(vdl->listview), "row_activated",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1117
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1118 G_CALLBACK(vdlist_select_cb), vdl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1119
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1120 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vdl->listview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1121 gtk_tree_selection_set_mode(selection, GTK_SELECTION_NONE);
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 column = gtk_tree_view_column_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1124 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
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 renderer = gtk_cell_renderer_pixbuf_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1127 gtk_tree_view_column_pack_start(column, renderer, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1128 gtk_tree_view_column_add_attribute(column, renderer, "pixbuf", DIR_COLUMN_ICON);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1129 gtk_tree_view_column_set_cell_data_func(column, renderer, vdlist_color_cb, vdl, NULL);
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 renderer = gtk_cell_renderer_text_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1132 gtk_tree_view_column_pack_start(column, renderer, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1133 gtk_tree_view_column_add_attribute(column, renderer, "text", DIR_COLUMN_NAME);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1134 gtk_tree_view_column_set_cell_data_func(column, renderer, vdlist_color_cb, vdl, NULL);
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 gtk_tree_view_append_column(GTK_TREE_VIEW(vdl->listview), column);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1137
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1138 g_signal_connect(G_OBJECT(vdl->listview), "key_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1139 G_CALLBACK(vdlist_press_key_cb), vdl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1140 gtk_container_add(GTK_CONTAINER(vdl->widget), vdl->listview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1141 gtk_widget_show(vdl->listview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1142
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1143 vdl->pf = folder_icons_new();
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 vdlist_dnd_init(vdl);
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 g_signal_connect(G_OBJECT(vdl->listview), "button_press_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1148 G_CALLBACK(vdlist_press_cb), vdl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1149 g_signal_connect(G_OBJECT(vdl->listview), "button_release_event",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1150 G_CALLBACK(vdlist_release_cb), vdl);
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 if (path) vdlist_set_path(vdl, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1153
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1154 return vdl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1155 }
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 void vdlist_set_select_func(ViewDirList *vdl,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1158 void (*func)(ViewDirList *vdl, const gchar *path, gpointer data), gpointer data)
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 vdl->select_func = func;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1161 vdl->select_data = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1162 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1163
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1164 void vdlist_set_layout(ViewDirList *vdl, LayoutWindow *layout)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1165 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1166 vdl->layout = layout;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1167 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1168