annotate src/view_dir_list.c @ 1738:808dd5257146

Some systems do not have SA_SIGINFO (siginfo_t), like GNU/Hurd, so just test if defined or not. Patch by Michal iha (Bug ID: 2894271).
author zas_
date Fri, 04 Dec 2009 21:01:11 +0000
parents 94e4a47ccaff
children 9b5eb41f4311
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;
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
141
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
142 old_list = VDLIST(vd)->list;
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 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
145 VDLIST(vd)->list = filelist_sort(VDLIST(vd)->list, SORT_NAME, TRUE);
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
146
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
147 /* add . and .. */
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 if (strcmp(vd->dir_fd->path, G_DIR_SEPARATOR_S) != 0)
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 filepath = g_build_filename(vd->dir_fd->path, "..", NULL);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
152 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
153 VDLIST(vd)->list = g_list_prepend(VDLIST(vd)->list, fd);
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
154 g_free(filepath);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
155 }
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
156
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
157 if (options->file_filter.show_dot_directory)
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 filepath = g_build_filename(vd->dir_fd->path, ".", NULL);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
160 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
161 VDLIST(vd)->list = g_list_prepend(VDLIST(vd)->list, fd);
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
162 g_free(filepath);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
163 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
164
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
165 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
166 if (clear) gtk_list_store_clear(store);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
167
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
168 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
169
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
170 work = VDLIST(vd)->list;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
171 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
172 {
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
173 gint match;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
174 GdkPixbuf *pixbuf;
825
ee33d2ddb661 Optionnally display directory's date in list view.
zas_
parents: 783
diff changeset
175 const gchar *date = "";
1452
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
176 gboolean done = FALSE;
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
177
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
178 fd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
179
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
180 if (access_file(fd->path, R_OK | X_OK) && fd->name)
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 (fd->name[0] == '.' && fd->name[1] == '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
183 {
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
184 pixbuf = vd->pf->open;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
185 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
186 else if (fd->name[0] == '.' && fd->name[1] == '.' && fd->name[2] == '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
187 {
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
188 pixbuf = vd->pf->parent;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
189 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
190 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
191 {
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
192 pixbuf = vd->pf->close;
1436
d7a6fb7a90dd completely separated global and layout window options
nadvornik
parents: 1365
diff changeset
193 if (vd->layout && vd->layout->options.show_directory_date)
825
ee33d2ddb661 Optionnally display directory's date in list view.
zas_
parents: 783
diff changeset
194 date = text_from_time(fd->date);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
195 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
196 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
197 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
198 {
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
199 pixbuf = vd->pf->deny;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
200 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
201
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
202 while (!done)
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
203 {
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
204 FileData *old_fd = NULL;
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 if (valid)
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 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
209 DIR_COLUMN_POINTER, &old_fd,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
210 -1);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
211
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
212 if (fd == old_fd)
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 match = 0;
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 else
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
217 {
995
6ca2c5fd7b13 Whitespaces cleanup.
zas_
parents: 979
diff changeset
218 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
219
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
220 if (match == 0) g_warning("multiple fd for the same path");
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
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 else
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 match = -1;
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
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
229 if (match < 0)
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 GtkTreeIter new;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
232
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
233 if (valid)
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 gtk_list_store_insert_before(store, &new, &iter);
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 gtk_list_store_append(store, &new);
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 gtk_list_store_set(store, &new,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
243 DIR_COLUMN_POINTER, fd,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
244 DIR_COLUMN_ICON, pixbuf,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
245 DIR_COLUMN_NAME, fd->name,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
246 DIR_COLUMN_DATE, date,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
247 -1);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
248
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
249 done = TRUE;
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 else if (match > 0)
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 valid = gtk_list_store_remove(store, &iter);
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 else
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 gtk_list_store_set(store, &iter,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
258 DIR_COLUMN_ICON, pixbuf,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
259 DIR_COLUMN_NAME, fd->name,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
260 DIR_COLUMN_DATE, date,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
261 -1);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
262
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
263 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
264
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
265 done = TRUE;
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 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
268 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
269 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
270
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
271 while (valid)
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
272 {
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
273 FileData *old_fd;
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
274 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
275
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
276 valid = gtk_list_store_remove(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
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
279
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
280 vd->click_fd = NULL;
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
281 vd->drop_fd = NULL;
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
282
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
283 filelist_free(old_list);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
284 return ret;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
285 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
286
1452
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
287 gboolean vdlist_set_fd(ViewDir *vd, FileData *dir_fd)
9
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 ret;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
290 gchar *old_path = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
291
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
292 if (!dir_fd) return FALSE;
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
293 if (vd->dir_fd == dir_fd) return TRUE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
294
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
295 if (vd->dir_fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
296 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
297 gchar *base;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
298
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
299 base = remove_level_from_path(vd->dir_fd->path);
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
300 if (strcmp(base, dir_fd->path) == 0)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
301 {
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
302 old_path = g_strdup(vd->dir_fd->name);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
303 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
304 g_free(base);
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
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
307 file_data_unref(vd->dir_fd);
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
308 vd->dir_fd = file_data_ref(dir_fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
309
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
310 ret = vdlist_populate(vd, TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
311
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
312 if (old_path)
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 /* scroll to make last path visible */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
315 FileData *found = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
316 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
317
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
318 work = VDLIST(vd)->list;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
319 while (work && !found)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
320 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
321 FileData *fd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
322 if (strcmp(old_path, fd->name) == 0) found = fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
323 work = work->next;
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
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
326 if (found) vdlist_scroll_to_row(vd, found, 0.5);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
327
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
328 g_free(old_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
329 return ret;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
330 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
331
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
332 if (GTK_WIDGET_REALIZED(vd->view))
9
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 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
335 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
336
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
337 return ret;
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
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
340 void vdlist_refresh(ViewDir *vd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
341 {
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
342 vdlist_populate(vd, FALSE);
9
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
1452
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
345 gboolean vdlist_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
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 ViewDir *vd = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
348 GtkTreePath *tpath;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 406
diff changeset
349
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
350 if (event->keyval != GDK_Menu) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
351
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
352 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
353 if (tpath)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
354 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
355 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
356 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
357
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
358 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
359 gtk_tree_model_get_iter(store, &iter, tpath);
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
360 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &vd->click_fd, -1);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 406
diff changeset
361
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
362 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
363 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
364 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
365 {
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
366 vd->click_fd = NULL;
9
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
383
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 381
diff changeset
369 vd_color_set(vd, vd->click_fd, TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
370
388
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 385
diff changeset
371 vd->popup = vd_pop_menu(vd, vd->click_fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
372
395
c359fc2c5a1f Move common menu position callback to view_dir.c.
zas_
parents: 394
diff changeset
373 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
374
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
375 return TRUE;
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
1452
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
378 gboolean vdlist_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
379 {
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
380 ViewDir *vd = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
381 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
382 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
383 FileData *fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
384
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
385 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
386 &tpath, NULL, NULL, NULL))
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 GtkTreeModel *store;
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 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
391 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
392 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &fd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
393 gtk_tree_view_set_cursor(GTK_TREE_VIEW(widget), tpath, NULL, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
394 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
395 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
396
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
397 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
398 vd_color_set(vd, vd->click_fd, TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
399
448
a73cc0fa14d0 Use explicit names for mouse buttons instead of numbers.
zas_
parents: 442
diff changeset
400 if (bevent->button == MOUSE_BUTTON_RIGHT)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
401 {
388
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 385
diff changeset
402 vd->popup = vd_pop_menu(vd, vd->click_fd);
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
403 gtk_menu_popup(GTK_MENU(vd->popup), NULL, NULL, NULL, NULL,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
404 bevent->button, bevent->time);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
405 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
406
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
407 return TRUE;
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
401
0a2e1b130a25 Add some wrappers in view_dir.c and simplify even more.
zas_
parents: 397
diff changeset
410 void vdlist_destroy_cb(GtkWidget *widget, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
411 {
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
412 ViewDir *vd = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
413
394
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 389
diff changeset
414 vd_dnd_drop_scroll_cancel(vd);
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
415 widget_auto_scroll_stop(vd->view);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
416
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
417 filelist_free(VDLIST(vd)->list);
9
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
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
420 ViewDir *vdlist_new(ViewDir *vd, FileData *dir_fd)
9
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 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
423 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
424 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
425 GtkCellRenderer *renderer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
426
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
427 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
428
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
429 vd->type = DIRVIEW_LIST;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
430
825
ee33d2ddb661 Optionnally display directory's date in list view.
zas_
parents: 783
diff changeset
431 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
432 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
433 g_object_unref(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
434
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
435 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(vd->view), FALSE);
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
436 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
437
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
438 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vd->view));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
439 gtk_tree_selection_set_mode(selection, GTK_SELECTION_NONE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
440
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
441 column = gtk_tree_view_column_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
442 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
443
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
444 renderer = gtk_cell_renderer_pixbuf_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
445 gtk_tree_view_column_pack_start(column, renderer, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
446 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
447 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
448
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
449 renderer = gtk_cell_renderer_text_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
450 gtk_tree_view_column_pack_start(column, renderer, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
451 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
452 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
453
825
ee33d2ddb661 Optionnally display directory's date in list view.
zas_
parents: 783
diff changeset
454 renderer = gtk_cell_renderer_text_new();
ee33d2ddb661 Optionnally display directory's date in list view.
zas_
parents: 783
diff changeset
455 gtk_tree_view_column_pack_start(column, renderer, TRUE);
ee33d2ddb661 Optionnally display directory's date in list view.
zas_
parents: 783
diff changeset
456 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
457 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
458
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
459 gtk_tree_view_append_column(GTK_TREE_VIEW(vd->view), column);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
460
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
461 return vd;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
462 }
1055
1646720364cf Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents: 995
diff changeset
463 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */