annotate src/view_dir_list.c @ 1321:50b325a2386e

fixed filter initialization
author nadvornik
date Wed, 25 Feb 2009 18:21:20 +0000
parents 8b89e3ff286b
children 249bf204004a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1 /*
196
f6e307c7bad6 rename GQview -> Geeqie over the code
nadvornik
parents: 138
diff changeset
2 * Geeqie
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3 * (C) 2004 John Ellis
1284
8b89e3ff286b Add year 2009 to copyright info everywhere.
zas_
parents: 1055
diff changeset
4 * Copyright (C) 2008 - 2009 The Geeqie Team
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
5 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
6 * Author: John Ellis
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
7 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
8 * This software is released under the GNU General Public License (GNU GPL).
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
9 * Please read the included file COPYING for more information.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
10 * This software comes with no warranty of any kind, use at your own risk!
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
11 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
12
281
9995c5fb202a gqview.h -> main.h
zas_
parents: 250
diff changeset
13 #include "main.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
14 #include "view_dir_list.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
15
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
16 #include "dnd.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
17 #include "dupe.h"
586
905688aa2317 split filelist.c to filefilter.c and filedata.c
nadvornik
parents: 475
diff changeset
18 #include "filedata.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
19 #include "layout.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
20 #include "layout_image.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
21 #include "layout_util.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
22 #include "utilops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
23 #include "ui_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"
380
5afe77bb563a Introduce a new struct ViewDir to handle directory views common
zas_
parents: 373
diff changeset
26 #include "view_dir.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
27
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
28 #include <gdk/gdkkeysyms.h> /* for keyboard values */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
29
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
30
979
8732c06d8aeb Typo fix: vf -> vd
zas_
parents: 978
diff changeset
31 #define VDLIST(_vd_) ((ViewDirInfoList *)(_vd_->info))
9
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
34 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
35 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
36 * misc
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
37 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
38 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
39
383
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 381
diff changeset
40 gint vdlist_find_row(ViewDir *vd, FileData *fd, GtkTreeIter *iter)
9
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 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
43 gint valid;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
44 gint row = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
45
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
46 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
47 valid = gtk_tree_model_get_iter_first(store, iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
48 while (valid)
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 FileData *fd_n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
51 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
52 if (fd_n == fd) return row;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
53
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
54 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
55 row++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
56 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
57
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
58 return -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
59 }
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
388
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 385
diff changeset
62 FileData *vdlist_row_by_path(ViewDir *vd, const gchar *path, gint *row)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
63 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
64 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
65 gint n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
66
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
67 if (!path)
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 if (row) *row = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
70 return NULL;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
73 n = 0;
978
9ff64efe11eb Replace macros VDLIST_INFO() and VDTREE_INFO() by shorter VDLIST() and VDTREE(). VDLIST_INFO(vd, part) becomes VDLIST(vd)->part.
zas_
parents: 973
diff changeset
74 work = VDLIST(vd)->list;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
75 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
76 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
77 FileData *fd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
78 if (strcmp(fd->path, path) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
79 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
80 if (row) *row = n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
81 return fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
82 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
83 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
84 n++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
85 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
86
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
87 if (row) *row = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
88 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
89 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
90
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
91 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
92 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
93 * dnd
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 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
96
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
97 static void vdlist_scroll_to_row(ViewDir *vd, FileData *fd, gfloat y_align)
9
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 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
100
394
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 389
diff changeset
101 if (GTK_WIDGET_REALIZED(vd->view) && vd_find_row(vd, fd, &iter) >= 0)
9
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 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
104 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
105
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
106 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
107 tpath = gtk_tree_model_get_path(store, &iter);
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
108 gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(vd->view), tpath, NULL, TRUE, y_align, 0.0);
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
109 gtk_tree_view_set_cursor(GTK_TREE_VIEW(vd->view), tpath, NULL, FALSE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
110 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
111
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
112 if (!GTK_WIDGET_HAS_FOCUS(vd->view)) gtk_widget_grab_focus(vd->view);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
113 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
114 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
115
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
116 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
117 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
118 * main
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
119 *-----------------------------------------------------------------------------
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 406
diff changeset
120 */
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
121
396
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
122 void vdlist_select_row(ViewDir *vd, FileData *fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
123 {
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
124 if (fd && vd->select_func)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
125 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
126 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
127
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
128 path = g_strdup(fd->path);
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
129 vd->select_func(vd, path, vd->select_data);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
130 g_free(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 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
133
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
134 const gchar *vdlist_row_get_path(ViewDir *vd, gint row)
9
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 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
137
978
9ff64efe11eb Replace macros VDLIST_INFO() and VDTREE_INFO() by shorter VDLIST() and VDTREE(). VDLIST_INFO(vd, part) becomes VDLIST(vd)->part.
zas_
parents: 973
diff changeset
138 fd = g_list_nth_data(VDLIST(vd)->list, row);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
139
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
140 if (fd) return fd->path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
141
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
142 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
143 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
144
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
145 static gint vdlist_populate(ViewDir *vd, gboolean clear)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
146 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
147 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
148 GList *work;
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
149 GtkTreeIter iter;
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
150 gint valid;
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
151 gchar *filepath;
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
152 GList *old_list;
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
153 gint ret;
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
154 FileData *fd;
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
155
978
9ff64efe11eb Replace macros VDLIST_INFO() and VDTREE_INFO() by shorter VDLIST() and VDTREE(). VDLIST_INFO(vd, part) becomes VDLIST(vd)->part.
zas_
parents: 973
diff changeset
156 old_list = VDLIST(vd)->list;
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
157
978
9ff64efe11eb Replace macros VDLIST_INFO() and VDTREE_INFO() by shorter VDLIST() and VDTREE(). VDLIST_INFO(vd, part) becomes VDLIST(vd)->part.
zas_
parents: 973
diff changeset
158 ret = filelist_read(vd->dir_fd, NULL, &VDLIST(vd)->list);
9ff64efe11eb Replace macros VDLIST_INFO() and VDTREE_INFO() by shorter VDLIST() and VDTREE(). VDLIST_INFO(vd, part) becomes VDLIST(vd)->part.
zas_
parents: 973
diff changeset
159 VDLIST(vd)->list = filelist_sort(VDLIST(vd)->list, SORT_NAME, TRUE);
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
160
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
161 /* add . and .. */
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
162
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
163 if (strcmp(vd->dir_fd->path, G_DIR_SEPARATOR_S) != 0)
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
164 {
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
165 filepath = g_build_filename(vd->dir_fd->path, "..", NULL);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
166 fd = file_data_new_simple(filepath);
978
9ff64efe11eb Replace macros VDLIST_INFO() and VDTREE_INFO() by shorter VDLIST() and VDTREE(). VDLIST_INFO(vd, part) becomes VDLIST(vd)->part.
zas_
parents: 973
diff changeset
167 VDLIST(vd)->list = g_list_prepend(VDLIST(vd)->list, fd);
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
168 g_free(filepath);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
169 }
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
170
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
171 if (options->file_filter.show_dot_directory)
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
172 {
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
173 filepath = g_build_filename(vd->dir_fd->path, ".", NULL);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
174 fd = file_data_new_simple(filepath);
978
9ff64efe11eb Replace macros VDLIST_INFO() and VDTREE_INFO() by shorter VDLIST() and VDTREE(). VDLIST_INFO(vd, part) becomes VDLIST(vd)->part.
zas_
parents: 973
diff changeset
175 VDLIST(vd)->list = g_list_prepend(VDLIST(vd)->list, fd);
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
176 g_free(filepath);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
177 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
178
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
179 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view)));
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
180 if (clear) gtk_list_store_clear(store);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
181
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
182 valid = gtk_tree_model_iter_children(GTK_TREE_MODEL(store), &iter, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
183
978
9ff64efe11eb Replace macros VDLIST_INFO() and VDTREE_INFO() by shorter VDLIST() and VDTREE(). VDLIST_INFO(vd, part) becomes VDLIST(vd)->part.
zas_
parents: 973
diff changeset
184 work = VDLIST(vd)->list;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
185 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
186 {
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
187 gint match;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
188 GdkPixbuf *pixbuf;
825
ee33d2ddb661 Optionnally display directory's date in list view.
zas_
parents: 783
diff changeset
189 const gchar *date = "";
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
190 fd = work->data;
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
191 gint done = FALSE;
9
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 if (access_file(fd->path, R_OK | X_OK) && fd->name)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
194 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
195 if (fd->name[0] == '.' && fd->name[1] == '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
196 {
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
197 pixbuf = vd->pf->open;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
198 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
199 else if (fd->name[0] == '.' && fd->name[1] == '.' && fd->name[2] == '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
200 {
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
201 pixbuf = vd->pf->parent;
9
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
204 {
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
205 pixbuf = vd->pf->close;
825
ee33d2ddb661 Optionnally display directory's date in list view.
zas_
parents: 783
diff changeset
206 if (options->layout.show_directory_date)
ee33d2ddb661 Optionnally display directory's date in list view.
zas_
parents: 783
diff changeset
207 date = text_from_time(fd->date);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
208 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
209 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
210 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
211 {
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
212 pixbuf = vd->pf->deny;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
213 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
214
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
215 while (!done)
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
216 {
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
217 FileData *old_fd = NULL;
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
218
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
219 if (valid)
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
220 {
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
221 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
222 DIR_COLUMN_POINTER, &old_fd,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
223 -1);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
224
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
225 if (fd == old_fd)
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
226 {
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
227 match = 0;
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
228 }
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
229 else
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
230 {
995
6ca2c5fd7b13 Whitespaces cleanup.
zas_
parents: 979
diff changeset
231 match = filelist_sort_compare_filedata_full(fd, old_fd, SORT_NAME, TRUE);
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
232
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
233 if (match == 0) g_warning("multiple fd for the same path");
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
234 }
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
235
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
236 }
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
237 else
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
238 {
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
239 match = -1;
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
240 }
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
241
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
242 if (match < 0)
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
243 {
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
244 GtkTreeIter new;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
245
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
246 if (valid)
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
247 {
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
248 gtk_list_store_insert_before(store, &new, &iter);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
249 }
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
250 else
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
251 {
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
252 gtk_list_store_append(store, &new);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
253 }
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
254
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
255 gtk_list_store_set(store, &new,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
256 DIR_COLUMN_POINTER, fd,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
257 DIR_COLUMN_ICON, pixbuf,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
258 DIR_COLUMN_NAME, fd->name,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
259 DIR_COLUMN_DATE, date,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
260 -1);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
261
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
262 done = TRUE;
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
263 }
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
264 else if (match > 0)
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
265 {
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
266 valid = gtk_list_store_remove(store, &iter);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
267 }
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
268 else
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
269 {
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
270 gtk_list_store_set(store, &iter,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
271 DIR_COLUMN_ICON, pixbuf,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
272 DIR_COLUMN_NAME, fd->name,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
273 DIR_COLUMN_DATE, date,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
274 -1);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
275
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
276 if (valid) valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
277
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
278 done = TRUE;
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
279 }
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
280 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
281 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
282 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
283
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
284 while (valid)
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
285 {
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
286 FileData *old_fd;
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
287 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, DIR_COLUMN_POINTER, &old_fd, -1);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
288
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
289 valid = gtk_list_store_remove(store, &iter);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
290 }
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
291
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
292
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
293 vd->click_fd = NULL;
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
294 vd->drop_fd = NULL;
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
295
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
296 filelist_free(old_list);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
297 return ret;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
298 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
299
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
300 gint vdlist_set_fd(ViewDir *vd, FileData *dir_fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
301 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
302 gint ret;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
303 gchar *old_path = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
304
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
305 if (!dir_fd) return FALSE;
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
306 if (vd->dir_fd == dir_fd) return TRUE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
307
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
308 if (vd->dir_fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
309 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
310 gchar *base;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
311
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
312 base = remove_level_from_path(vd->dir_fd->path);
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
313 if (strcmp(base, dir_fd->path) == 0)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
314 {
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
315 old_path = g_strdup(vd->dir_fd->name);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
316 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
317 g_free(base);
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
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
320 file_data_unref(vd->dir_fd);
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
321 vd->dir_fd = file_data_ref(dir_fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
322
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
323 ret = vdlist_populate(vd, TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
324
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
325 if (old_path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
326 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
327 /* scroll to make last path visible */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
328 FileData *found = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
329 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
330
978
9ff64efe11eb Replace macros VDLIST_INFO() and VDTREE_INFO() by shorter VDLIST() and VDTREE(). VDLIST_INFO(vd, part) becomes VDLIST(vd)->part.
zas_
parents: 973
diff changeset
331 work = VDLIST(vd)->list;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
332 while (work && !found)
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 FileData *fd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
335 if (strcmp(old_path, fd->name) == 0) found = fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
336 work = work->next;
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
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
339 if (found) vdlist_scroll_to_row(vd, found, 0.5);
9
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 g_free(old_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
342 return ret;
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
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
345 if (GTK_WIDGET_REALIZED(vd->view))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
346 {
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
347 gtk_tree_view_scroll_to_point(GTK_TREE_VIEW(vd->view), 0, 0);
9
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
350 return ret;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
351 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
352
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
353 void vdlist_refresh(ViewDir *vd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
354 {
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
355 vdlist_populate(vd, FALSE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
356 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
357
401
0a2e1b130a25 Add some wrappers in view_dir.c and simplify even more.
zas_
parents: 397
diff changeset
358 gint vdlist_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
359 {
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
360 ViewDir *vd = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
361 GtkTreePath *tpath;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 406
diff changeset
362
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
363 if (event->keyval != GDK_Menu) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
364
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
365 gtk_tree_view_get_cursor(GTK_TREE_VIEW(vd->view), &tpath, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
366 if (tpath)
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 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
369 GtkTreeIter iter;
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 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
372 gtk_tree_model_get_iter(store, &iter, tpath);
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
373 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &vd->click_fd, -1);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 406
diff changeset
374
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
375 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
376 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
377 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
378 {
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
379 vd->click_fd = NULL;
9
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
383
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 381
diff changeset
382 vd_color_set(vd, vd->click_fd, TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
383
388
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 385
diff changeset
384 vd->popup = vd_pop_menu(vd, vd->click_fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
385
395
c359fc2c5a1f Move common menu position callback to view_dir.c.
zas_
parents: 394
diff changeset
386 gtk_menu_popup(GTK_MENU(vd->popup), NULL, NULL, vd_menu_position_cb, vd, 0, GDK_CURRENT_TIME);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
387
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
388 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
389 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
390
401
0a2e1b130a25 Add some wrappers in view_dir.c and simplify even more.
zas_
parents: 397
diff changeset
391 gint vdlist_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
392 {
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
393 ViewDir *vd = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
394 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
395 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
396 FileData *fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
397
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
398 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
399 &tpath, NULL, NULL, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
400 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
401 GtkTreeModel *store;
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 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
404 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
405 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &fd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
406 gtk_tree_view_set_cursor(GTK_TREE_VIEW(widget), tpath, NULL, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
407 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
408 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
409
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
410 vd->click_fd = fd;
383
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 381
diff changeset
411 vd_color_set(vd, vd->click_fd, TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
412
448
a73cc0fa14d0 Use explicit names for mouse buttons instead of numbers.
zas_
parents: 442
diff changeset
413 if (bevent->button == MOUSE_BUTTON_RIGHT)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
414 {
388
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 385
diff changeset
415 vd->popup = vd_pop_menu(vd, vd->click_fd);
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
416 gtk_menu_popup(GTK_MENU(vd->popup), NULL, NULL, NULL, NULL,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
417 bevent->button, bevent->time);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
418 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
419
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
420 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
421 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
422
401
0a2e1b130a25 Add some wrappers in view_dir.c and simplify even more.
zas_
parents: 397
diff changeset
423 void vdlist_destroy_cb(GtkWidget *widget, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
424 {
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
425 ViewDir *vd = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
426
394
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 389
diff changeset
427 vd_dnd_drop_scroll_cancel(vd);
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
428 widget_auto_scroll_stop(vd->view);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
429
978
9ff64efe11eb Replace macros VDLIST_INFO() and VDTREE_INFO() by shorter VDLIST() and VDTREE(). VDLIST_INFO(vd, part) becomes VDLIST(vd)->part.
zas_
parents: 973
diff changeset
430 filelist_free(VDLIST(vd)->list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
431 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
432
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
433 ViewDir *vdlist_new(ViewDir *vd, FileData *dir_fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
434 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
435 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
436 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
437 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
438 GtkCellRenderer *renderer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
439
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
440 vd->info = g_new0(ViewDirInfoList, 1);
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
441 vd->type = DIRVIEW_LIST;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
442
978
9ff64efe11eb Replace macros VDLIST_INFO() and VDTREE_INFO() by shorter VDLIST() and VDTREE(). VDLIST_INFO(vd, part) becomes VDLIST(vd)->part.
zas_
parents: 973
diff changeset
443 VDLIST(vd)->list = NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
444
825
ee33d2ddb661 Optionnally display directory's date in list view.
zas_
parents: 783
diff changeset
445 store = gtk_list_store_new(5, G_TYPE_POINTER, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING);
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
446 vd->view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
447 g_object_unref(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
448
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
449 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(vd->view), FALSE);
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
450 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(vd->view), FALSE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
451
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
452 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vd->view));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
453 gtk_tree_selection_set_mode(selection, GTK_SELECTION_NONE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
454
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
455 column = gtk_tree_view_column_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
456 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
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 renderer = gtk_cell_renderer_pixbuf_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
459 gtk_tree_view_column_pack_start(column, renderer, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
460 gtk_tree_view_column_add_attribute(column, renderer, "pixbuf", DIR_COLUMN_ICON);
396
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
461 gtk_tree_view_column_set_cell_data_func(column, renderer, vd_color_cb, vd, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
462
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
463 renderer = gtk_cell_renderer_text_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
464 gtk_tree_view_column_pack_start(column, renderer, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
465 gtk_tree_view_column_add_attribute(column, renderer, "text", DIR_COLUMN_NAME);
396
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
466 gtk_tree_view_column_set_cell_data_func(column, renderer, vd_color_cb, vd, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
467
825
ee33d2ddb661 Optionnally display directory's date in list view.
zas_
parents: 783
diff changeset
468 renderer = gtk_cell_renderer_text_new();
ee33d2ddb661 Optionnally display directory's date in list view.
zas_
parents: 783
diff changeset
469 gtk_tree_view_column_pack_start(column, renderer, TRUE);
ee33d2ddb661 Optionnally display directory's date in list view.
zas_
parents: 783
diff changeset
470 gtk_tree_view_column_add_attribute(column, renderer, "text", DIR_COLUMN_DATE);
ee33d2ddb661 Optionnally display directory's date in list view.
zas_
parents: 783
diff changeset
471 gtk_tree_view_column_set_cell_data_func(column, renderer, vd_color_cb, vd, NULL);
ee33d2ddb661 Optionnally display directory's date in list view.
zas_
parents: 783
diff changeset
472
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
473 gtk_tree_view_append_column(GTK_TREE_VIEW(vd->view), column);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
474
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
475 return vd;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
476 }
1055
1646720364cf Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents: 995
diff changeset
477 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */