annotate src/view_dir_list.c @ 1753:c4d37e0fc841 default tip

installation fix
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Fri, 29 Jan 2010 19:22:50 +0900
parents 9b5eb41f4311
children
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
1452
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
40 gboolean 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;
1452
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
43 gboolean valid;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
44
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
45 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
46 valid = gtk_tree_model_get_iter_first(store, iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
47 while (valid)
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 FileData *fd_n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
50 gtk_tree_model_get(GTK_TREE_MODEL(store), iter, DIR_COLUMN_POINTER, &fd_n, -1);
1501
299d45d4b1cc fixed vdlist_find_row return value
nadvornik
parents: 1452
diff changeset
51 if (fd_n == fd) return TRUE;
9
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 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
54 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
55
1501
299d45d4b1cc fixed vdlist_find_row return value
nadvornik
parents: 1452
diff changeset
56 return FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
57 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
58
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
59
388
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 385
diff changeset
60 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
61 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
62 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
63 gint n;
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 if (!path)
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 (row) *row = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
68 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
69 }
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 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
72 work = VDLIST(vd)->list;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
73 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
74 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
75 FileData *fd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
76 if (strcmp(fd->path, path) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
77 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
78 if (row) *row = n;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
79 return fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
80 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
81 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
82 n++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
83 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
84
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
85 if (row) *row = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
86 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
87 }
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 /*
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 * dnd
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 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
94
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
95 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
96 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
97 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
98
1553
626adbb26387 fixed tests for vd_find_row return value
nadvornik
parents: 1501
diff changeset
99 if (GTK_WIDGET_REALIZED(vd->view) && vd_find_row(vd, fd, &iter))
9
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 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
102 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
103
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
104 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
105 tpath = gtk_tree_model_get_path(store, &iter);
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
106 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
107 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
108 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
109
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
110 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
111 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
112 }
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 * main
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
117 *-----------------------------------------------------------------------------
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 406
diff changeset
118 */
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
119
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
120 const gchar *vdlist_row_get_path(ViewDir *vd, gint row)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
121 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
122 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
123
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
124 fd = g_list_nth_data(VDLIST(vd)->list, row);
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 if (fd) return fd->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 return NULL;
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
1452
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
131 static gboolean vdlist_populate(ViewDir *vd, gboolean clear)
9
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 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
134 GList *work;
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
135 GtkTreeIter iter;
1452
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
136 gboolean valid;
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
137 gchar *filepath;
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
138 GList *old_list;
1452
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
139 gboolean ret;
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
140 FileData *fd;
1741
9b5eb41f4311 Store sort parameters in appropriate variables.
zas_
parents: 1626
diff changeset
141 SortType sort_type = SORT_NAME;
9b5eb41f4311 Store sort parameters in appropriate variables.
zas_
parents: 1626
diff changeset
142 gboolean sort_ascend = TRUE;
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
143
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
144 old_list = VDLIST(vd)->list;
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
145
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
146 ret = filelist_read(vd->dir_fd, NULL, &VDLIST(vd)->list);
1741
9b5eb41f4311 Store sort parameters in appropriate variables.
zas_
parents: 1626
diff changeset
147 VDLIST(vd)->list = filelist_sort(VDLIST(vd)->list, sort_type, sort_ascend);
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
148
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
149 /* add . and .. */
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
150
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
151 if (strcmp(vd->dir_fd->path, G_DIR_SEPARATOR_S) != 0)
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
152 {
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
153 filepath = g_build_filename(vd->dir_fd->path, "..", NULL);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
154 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
155 VDLIST(vd)->list = g_list_prepend(VDLIST(vd)->list, fd);
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
156 g_free(filepath);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
157 }
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
158
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
159 if (options->file_filter.show_dot_directory)
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 filepath = g_build_filename(vd->dir_fd->path, ".", NULL);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
162 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
163 VDLIST(vd)->list = g_list_prepend(VDLIST(vd)->list, fd);
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
164 g_free(filepath);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
165 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
166
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
167 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
168 if (clear) gtk_list_store_clear(store);
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 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
171
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
172 work = VDLIST(vd)->list;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
173 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
174 {
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
175 gint match;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
176 GdkPixbuf *pixbuf;
825
ee33d2ddb661 Optionnally display directory's date in list view.
zas_
parents: 783
diff changeset
177 const gchar *date = "";
1452
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
178 gboolean done = FALSE;
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
179
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
180 fd = work->data;
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 if (access_file(fd->path, R_OK | X_OK) && fd->name)
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 if (fd->name[0] == '.' && fd->name[1] == '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
185 {
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
186 pixbuf = vd->pf->open;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
187 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
188 else if (fd->name[0] == '.' && fd->name[1] == '.' && fd->name[2] == '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
189 {
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
190 pixbuf = vd->pf->parent;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
191 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
192 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
193 {
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
194 pixbuf = vd->pf->close;
1436
d7a6fb7a90dd completely separated global and layout window options
nadvornik
parents: 1365
diff changeset
195 if (vd->layout && vd->layout->options.show_directory_date)
825
ee33d2ddb661 Optionnally display directory's date in list view.
zas_
parents: 783
diff changeset
196 date = text_from_time(fd->date);
9
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 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
199 else
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->deny;
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
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
204 while (!done)
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
205 {
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
206 FileData *old_fd = NULL;
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
207
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
208 if (valid)
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
209 {
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
210 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
211 DIR_COLUMN_POINTER, &old_fd,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
212 -1);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
213
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
214 if (fd == old_fd)
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
215 {
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
216 match = 0;
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
217 }
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
218 else
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
219 {
1741
9b5eb41f4311 Store sort parameters in appropriate variables.
zas_
parents: 1626
diff changeset
220 match = filelist_sort_compare_filedata_full(fd, old_fd, sort_type, sort_ascend);
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
221
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
222 if (match == 0) g_warning("multiple fd for the same path");
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
223 }
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 }
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
226 else
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
227 {
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
228 match = -1;
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
229 }
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
230
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
231 if (match < 0)
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 GtkTreeIter new;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
234
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
235 if (valid)
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 gtk_list_store_insert_before(store, &new, &iter);
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 else
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 gtk_list_store_append(store, &new);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
242 }
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 gtk_list_store_set(store, &new,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
245 DIR_COLUMN_POINTER, fd,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
246 DIR_COLUMN_ICON, pixbuf,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
247 DIR_COLUMN_NAME, fd->name,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
248 DIR_COLUMN_DATE, date,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
249 -1);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
250
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
251 done = TRUE;
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
252 }
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
253 else if (match > 0)
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 valid = gtk_list_store_remove(store, &iter);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
256 }
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
257 else
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
258 {
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
259 gtk_list_store_set(store, &iter,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
260 DIR_COLUMN_ICON, pixbuf,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
261 DIR_COLUMN_NAME, fd->name,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
262 DIR_COLUMN_DATE, date,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
263 -1);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
264
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
265 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
266
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
267 done = TRUE;
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
268 }
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
269 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
270 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
271 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
272
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
273 while (valid)
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
274 {
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
275 FileData *old_fd;
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
276 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
277
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
278 valid = gtk_list_store_remove(store, &iter);
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
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
281
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
282 vd->click_fd = NULL;
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
283 vd->drop_fd = NULL;
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
284
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
285 filelist_free(old_list);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
286 return ret;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
287 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
288
1452
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
289 gboolean vdlist_set_fd(ViewDir *vd, FileData *dir_fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
290 {
1452
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
291 gboolean ret;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
292 gchar *old_path = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
293
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
294 if (!dir_fd) return FALSE;
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
295 if (vd->dir_fd == dir_fd) return TRUE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
296
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
297 if (vd->dir_fd)
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 gchar *base;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
300
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
301 base = remove_level_from_path(vd->dir_fd->path);
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
302 if (strcmp(base, dir_fd->path) == 0)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
303 {
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
304 old_path = g_strdup(vd->dir_fd->name);
9
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 g_free(base);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
307 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
308
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
309 file_data_unref(vd->dir_fd);
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
310 vd->dir_fd = file_data_ref(dir_fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
311
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
312 ret = vdlist_populate(vd, TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
313
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
314 if (old_path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
315 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
316 /* scroll to make last path visible */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
317 FileData *found = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
318 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
319
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
320 work = VDLIST(vd)->list;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
321 while (work && !found)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
322 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
323 FileData *fd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
324 if (strcmp(old_path, fd->name) == 0) found = fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
325 work = work->next;
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
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
328 if (found) vdlist_scroll_to_row(vd, found, 0.5);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
329
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
330 g_free(old_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
331 return ret;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
332 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
333
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
334 if (GTK_WIDGET_REALIZED(vd->view))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
335 {
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
336 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
337 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
338
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
339 return ret;
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
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
342 void vdlist_refresh(ViewDir *vd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
343 {
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
344 vdlist_populate(vd, FALSE);
9
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
1452
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
347 gboolean vdlist_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
348 {
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
349 ViewDir *vd = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
350 GtkTreePath *tpath;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 406
diff changeset
351
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
352 if (event->keyval != GDK_Menu) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
353
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
354 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
355 if (tpath)
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 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
358 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
359
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
360 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
361 gtk_tree_model_get_iter(store, &iter, tpath);
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
362 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &vd->click_fd, -1);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 406
diff changeset
363
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
364 gtk_tree_path_free(tpath);
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
367 {
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
368 vd->click_fd = NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
369 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
370
383
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 381
diff changeset
371 vd_color_set(vd, vd->click_fd, TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
372
388
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 385
diff changeset
373 vd->popup = vd_pop_menu(vd, vd->click_fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
374
395
c359fc2c5a1f Move common menu position callback to view_dir.c.
zas_
parents: 394
diff changeset
375 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
376
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
377 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
378 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
379
1452
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
380 gboolean vdlist_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
381 {
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
382 ViewDir *vd = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
383 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
384 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
385 FileData *fd = NULL;
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 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
388 &tpath, NULL, NULL, NULL))
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 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
391
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
392 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
393 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
394 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &fd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
395 gtk_tree_view_set_cursor(GTK_TREE_VIEW(widget), tpath, NULL, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
396 gtk_tree_path_free(tpath);
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
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
399 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
400 vd_color_set(vd, vd->click_fd, TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
401
448
a73cc0fa14d0 Use explicit names for mouse buttons instead of numbers.
zas_
parents: 442
diff changeset
402 if (bevent->button == MOUSE_BUTTON_RIGHT)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
403 {
388
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 385
diff changeset
404 vd->popup = vd_pop_menu(vd, vd->click_fd);
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
405 gtk_menu_popup(GTK_MENU(vd->popup), NULL, NULL, NULL, NULL,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
406 bevent->button, bevent->time);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
407 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
408
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
409 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
410 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
411
401
0a2e1b130a25 Add some wrappers in view_dir.c and simplify even more.
zas_
parents: 397
diff changeset
412 void vdlist_destroy_cb(GtkWidget *widget, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
413 {
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
414 ViewDir *vd = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
415
394
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 389
diff changeset
416 vd_dnd_drop_scroll_cancel(vd);
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
417 widget_auto_scroll_stop(vd->view);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
418
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
419 filelist_free(VDLIST(vd)->list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
420 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
421
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
422 ViewDir *vdlist_new(ViewDir *vd, FileData *dir_fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
423 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
424 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
425 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
426 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
427 GtkCellRenderer *renderer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
428
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
429 vd->info = g_new0(ViewDirInfoList, 1);
1365
249bf204004a When g_new0() is used, drop redundant initializations to NULL, FALSE or 0.
zas_
parents: 1284
diff changeset
430
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
431 vd->type = DIRVIEW_LIST;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
432
825
ee33d2ddb661 Optionnally display directory's date in list view.
zas_
parents: 783
diff changeset
433 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
434 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
435 g_object_unref(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
436
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
437 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(vd->view), FALSE);
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
438 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
439
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
440 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vd->view));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
441 gtk_tree_selection_set_mode(selection, GTK_SELECTION_NONE);
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 column = gtk_tree_view_column_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
444 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
445
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
446 renderer = gtk_cell_renderer_pixbuf_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
447 gtk_tree_view_column_pack_start(column, renderer, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
448 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
449 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
450
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
451 renderer = gtk_cell_renderer_text_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
452 gtk_tree_view_column_pack_start(column, renderer, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
453 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
454 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
455
825
ee33d2ddb661 Optionnally display directory's date in list view.
zas_
parents: 783
diff changeset
456 renderer = gtk_cell_renderer_text_new();
ee33d2ddb661 Optionnally display directory's date in list view.
zas_
parents: 783
diff changeset
457 gtk_tree_view_column_pack_start(column, renderer, TRUE);
ee33d2ddb661 Optionnally display directory's date in list view.
zas_
parents: 783
diff changeset
458 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
459 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
460
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
461 gtk_tree_view_append_column(GTK_TREE_VIEW(vd->view), column);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
462
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
463 return vd;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
464 }
1055
1646720364cf Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents: 995
diff changeset
465 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */