annotate src/view_dir_list.c @ 1586:249b539cc952

force the metadata dialog if it was triggered by the menu or the button
author nadvornik
date Sat, 02 May 2009 11:14:24 +0000
parents 626adbb26387
children 66bf394d162a
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
396
a01535f52b56 Merge few more functions to view_dir.c.
zas_
parents: 395
diff changeset
120 void vdlist_select_row(ViewDir *vd, FileData *fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
121 {
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
122 if (fd && vd->select_func)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
123 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
124 gchar *path;
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 path = g_strdup(fd->path);
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
127 vd->select_func(vd, path, vd->select_data);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
128 g_free(path);
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 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
131
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
132 const gchar *vdlist_row_get_path(ViewDir *vd, gint row)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
133 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
134 FileData *fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
135
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
136 fd = g_list_nth_data(VDLIST(vd)->list, row);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
137
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
138 if (fd) return fd->path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
139
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
140 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
141 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
142
1452
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
143 static gboolean vdlist_populate(ViewDir *vd, gboolean clear)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
144 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
145 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
146 GList *work;
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
147 GtkTreeIter iter;
1452
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
148 gboolean valid;
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
149 gchar *filepath;
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
150 GList *old_list;
1452
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
151 gboolean ret;
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
152 FileData *fd;
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
153
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
154 old_list = VDLIST(vd)->list;
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
155
978
9ff64efe11eb Replace macros VDLIST_INFO() and VDTREE_INFO() by shorter VDLIST() and VDTREE(). VDLIST_INFO(vd, part) becomes VDLIST(vd)->part.
zas_
parents: 973
diff changeset
156 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
157 VDLIST(vd)->list = filelist_sort(VDLIST(vd)->list, SORT_NAME, TRUE);
973
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 /* add . and .. */
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 if (strcmp(vd->dir_fd->path, G_DIR_SEPARATOR_S) != 0)
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
162 {
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
163 filepath = g_build_filename(vd->dir_fd->path, "..", NULL);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
164 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
165 VDLIST(vd)->list = g_list_prepend(VDLIST(vd)->list, fd);
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
166 g_free(filepath);
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
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
169 if (options->file_filter.show_dot_directory)
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
170 {
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
171 filepath = g_build_filename(vd->dir_fd->path, ".", NULL);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
172 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
173 VDLIST(vd)->list = g_list_prepend(VDLIST(vd)->list, fd);
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
174 g_free(filepath);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
175 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
176
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
177 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
178 if (clear) gtk_list_store_clear(store);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
179
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
180 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
181
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
182 work = VDLIST(vd)->list;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
183 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
184 {
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
185 gint match;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
186 GdkPixbuf *pixbuf;
825
ee33d2ddb661 Optionnally display directory's date in list view.
zas_
parents: 783
diff changeset
187 const gchar *date = "";
1452
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
188 gboolean done = FALSE;
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
189
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
190 fd = work->data;
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 if (access_file(fd->path, R_OK | X_OK) && fd->name)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
193 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
194 if (fd->name[0] == '.' && fd->name[1] == '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
195 {
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
196 pixbuf = vd->pf->open;
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 else if (fd->name[0] == '.' && fd->name[1] == '.' && fd->name[2] == '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
199 {
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
200 pixbuf = vd->pf->parent;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
201 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
202 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
203 {
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
204 pixbuf = vd->pf->close;
1436
d7a6fb7a90dd completely separated global and layout window options
nadvornik
parents: 1365
diff changeset
205 if (vd->layout && vd->layout->options.show_directory_date)
825
ee33d2ddb661 Optionnally display directory's date in list view.
zas_
parents: 783
diff changeset
206 date = text_from_time(fd->date);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
207 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
208 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
209 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
210 {
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
211 pixbuf = vd->pf->deny;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
212 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
213
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
214 while (!done)
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 FileData *old_fd = NULL;
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 if (valid)
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 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
221 DIR_COLUMN_POINTER, &old_fd,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
222 -1);
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 if (fd == old_fd)
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 = 0;
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 else
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
229 {
995
6ca2c5fd7b13 Whitespaces cleanup.
zas_
parents: 979
diff changeset
230 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
231
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
232 if (match == 0) g_warning("multiple fd for the same path");
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
233 }
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
234
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
235 }
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
236 else
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
237 {
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
238 match = -1;
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
239 }
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 if (match < 0)
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 GtkTreeIter new;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
244
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
245 if (valid)
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
246 {
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
247 gtk_list_store_insert_before(store, &new, &iter);
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 else
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 gtk_list_store_append(store, &new);
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
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
254 gtk_list_store_set(store, &new,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
255 DIR_COLUMN_POINTER, fd,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
256 DIR_COLUMN_ICON, pixbuf,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
257 DIR_COLUMN_NAME, fd->name,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
258 DIR_COLUMN_DATE, date,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
259 -1);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
260
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
261 done = TRUE;
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 else if (match > 0)
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 valid = gtk_list_store_remove(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 else
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 gtk_list_store_set(store, &iter,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
270 DIR_COLUMN_ICON, pixbuf,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
271 DIR_COLUMN_NAME, fd->name,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
272 DIR_COLUMN_DATE, date,
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
273 -1);
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 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
276
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
277 done = TRUE;
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 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
280 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
281 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
282
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
283 while (valid)
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 FileData *old_fd;
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
286 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
287
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
288 valid = gtk_list_store_remove(store, &iter);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
289 }
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
290
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
291
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
292 vd->click_fd = NULL;
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
293 vd->drop_fd = NULL;
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
294
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
295 filelist_free(old_list);
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
296 return ret;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
297 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
298
1452
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
299 gboolean vdlist_set_fd(ViewDir *vd, FileData *dir_fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
300 {
1452
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
301 gboolean ret;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
302 gchar *old_path = NULL;
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 if (!dir_fd) return FALSE;
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
305 if (vd->dir_fd == dir_fd) return TRUE;
9
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 if (vd->dir_fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
308 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
309 gchar *base;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
310
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
311 base = remove_level_from_path(vd->dir_fd->path);
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
312 if (strcmp(base, dir_fd->path) == 0)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
313 {
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
314 old_path = g_strdup(vd->dir_fd->name);
9
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 g_free(base);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
317 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
318
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
319 file_data_unref(vd->dir_fd);
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
320 vd->dir_fd = file_data_ref(dir_fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
321
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
322 ret = vdlist_populate(vd, TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
323
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
324 if (old_path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
325 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
326 /* scroll to make last path visible */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
327 FileData *found = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
328 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
329
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
330 work = VDLIST(vd)->list;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
331 while (work && !found)
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 FileData *fd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
334 if (strcmp(old_path, fd->name) == 0) found = fd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
335 work = work->next;
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
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
338 if (found) vdlist_scroll_to_row(vd, found, 0.5);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
339
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
340 g_free(old_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
341 return ret;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
342 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
343
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
344 if (GTK_WIDGET_REALIZED(vd->view))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
345 {
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
346 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
347 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
348
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
349 return ret;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
350 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
351
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
352 void vdlist_refresh(ViewDir *vd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
353 {
973
ad2ff9608beb improved refresh in view_dir_list
nadvornik
parents: 902
diff changeset
354 vdlist_populate(vd, FALSE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
355 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
356
1452
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
357 gboolean vdlist_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
358 {
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
359 ViewDir *vd = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
360 GtkTreePath *tpath;
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 if (event->keyval != GDK_Menu) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
363
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
364 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
365 if (tpath)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
366 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
367 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
368 GtkTreeIter iter;
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 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
371 gtk_tree_model_get_iter(store, &iter, tpath);
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
372 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &vd->click_fd, -1);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 406
diff changeset
373
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
374 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
375 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
376 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
377 {
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
378 vd->click_fd = NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
379 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
380
383
499d7ba62261 Move some dnd common code from view_dir_list.c and view_dir_tree.c
zas_
parents: 381
diff changeset
381 vd_color_set(vd, vd->click_fd, TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
382
388
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 385
diff changeset
383 vd->popup = vd_pop_menu(vd, vd->click_fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
384
395
c359fc2c5a1f Move common menu position callback to view_dir.c.
zas_
parents: 394
diff changeset
385 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
386
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
387 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
388 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
389
1452
67b40740122e gint -> gboolean where applicable.
zas_
parents: 1437
diff changeset
390 gboolean vdlist_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
391 {
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
392 ViewDir *vd = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
393 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
394 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
395 FileData *fd = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
396
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
397 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
398 &tpath, NULL, NULL, NULL))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
399 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
400 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
401
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
402 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
403 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
404 gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &fd, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
405 gtk_tree_view_set_cursor(GTK_TREE_VIEW(widget), tpath, NULL, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
406 gtk_tree_path_free(tpath);
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
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
409 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
410 vd_color_set(vd, vd->click_fd, TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
411
448
a73cc0fa14d0 Use explicit names for mouse buttons instead of numbers.
zas_
parents: 442
diff changeset
412 if (bevent->button == MOUSE_BUTTON_RIGHT)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
413 {
388
5186f8e38cb8 Make directory view popup menu common and move it to view_dir.{c,h}.
zas_
parents: 385
diff changeset
414 vd->popup = vd_pop_menu(vd, vd->click_fd);
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
415 gtk_menu_popup(GTK_MENU(vd->popup), NULL, NULL, NULL, NULL,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
416 bevent->button, bevent->time);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
417 }
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 return TRUE;
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
401
0a2e1b130a25 Add some wrappers in view_dir.c and simplify even more.
zas_
parents: 397
diff changeset
422 void vdlist_destroy_cb(GtkWidget *widget, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
423 {
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
424 ViewDir *vd = data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
425
394
4a5e1377f3d7 Merge dirlist/dirview dnd code.
zas_
parents: 389
diff changeset
426 vd_dnd_drop_scroll_cancel(vd);
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
427 widget_auto_scroll_stop(vd->view);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
428
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
429 filelist_free(VDLIST(vd)->list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
430 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
431
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
432 ViewDir *vdlist_new(ViewDir *vd, FileData *dir_fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
433 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
434 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
435 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
436 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
437 GtkCellRenderer *renderer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
438
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
439 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
440
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
441 vd->type = DIRVIEW_LIST;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
442
825
ee33d2ddb661 Optionnally display directory's date in list view.
zas_
parents: 783
diff changeset
443 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
444 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
445 g_object_unref(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
446
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
447 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(vd->view), FALSE);
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
448 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
449
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
450 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vd->view));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
451 gtk_tree_selection_set_mode(selection, GTK_SELECTION_NONE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
452
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
453 column = gtk_tree_view_column_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
454 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
455
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
456 renderer = gtk_cell_renderer_pixbuf_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
457 gtk_tree_view_column_pack_start(column, renderer, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
458 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
459 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
460
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
461 renderer = gtk_cell_renderer_text_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
462 gtk_tree_view_column_pack_start(column, renderer, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
463 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
464 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
465
825
ee33d2ddb661 Optionnally display directory's date in list view.
zas_
parents: 783
diff changeset
466 renderer = gtk_cell_renderer_text_new();
ee33d2ddb661 Optionnally display directory's date in list view.
zas_
parents: 783
diff changeset
467 gtk_tree_view_column_pack_start(column, renderer, TRUE);
ee33d2ddb661 Optionnally display directory's date in list view.
zas_
parents: 783
diff changeset
468 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
469 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
470
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
471 gtk_tree_view_append_column(GTK_TREE_VIEW(vd->view), column);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
472
381
ff63dcb0425c Rename vdl occurences to vd.
zas_
parents: 380
diff changeset
473 return vd;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
474 }
1055
1646720364cf Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents: 995
diff changeset
475 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */