Mercurial > geeqie
annotate src/view_file_list.c @ 773:4acde7a0bb01
do not change original FileData on copy
author | nadvornik |
---|---|
date | Sat, 31 May 2008 19:46:26 +0000 |
parents | f53c2bb5b1b1 |
children | 85253619d522 |
rev | line source |
---|---|
9 | 1 /* |
196 | 2 * Geeqie |
9 | 3 * (C) 2004 John Ellis |
475 | 4 * Copyright (C) 2008 The Geeqie Team |
9 | 5 * |
6 * Author: John Ellis | |
7 * | |
8 * This software is released under the GNU General Public License (GNU GPL). | |
9 * Please read the included file COPYING for more information. | |
10 * This software comes with no warranty of any kind, use at your own risk! | |
11 */ | |
12 | |
281 | 13 #include "main.h" |
9 | 14 #include "view_file_list.h" |
15 | |
16 #include "cache_maint.h" | |
17 #include "dnd.h" | |
18 #include "editors.h" | |
19 #include "img-view.h" | |
20 #include "info.h" | |
21 #include "layout.h" | |
22 #include "layout_image.h" | |
23 #include "menu.h" | |
24 #include "thumb.h" | |
25 #include "utilops.h" | |
26 #include "ui_bookmark.h" | |
27 #include "ui_fileops.h" | |
28 #include "ui_menu.h" | |
29 #include "ui_tree_edit.h" | |
633 | 30 #include "view_file.h" |
9 | 31 |
32 #include <gdk/gdkkeysyms.h> /* for keyboard values */ | |
33 | |
34 | |
35 enum { | |
36 FILE_COLUMN_POINTER = 0, | |
763
81f9e8dbb4bf
improved infrastructure for tracing changes, optimized vflist_populate_view
nadvornik
parents:
762
diff
changeset
|
37 FILE_COLUMN_VERSION, |
9 | 38 FILE_COLUMN_THUMB, |
39 FILE_COLUMN_NAME, | |
139 | 40 FILE_COLUMN_SIDECARS, |
9 | 41 FILE_COLUMN_SIZE, |
42 FILE_COLUMN_DATE, | |
43 FILE_COLUMN_COLOR, | |
139 | 44 FILE_COLUMN_MARKS, |
45 FILE_COLUMN_MARKS_LAST = FILE_COLUMN_MARKS + FILEDATA_MARKS_SIZE - 1, | |
9 | 46 FILE_COLUMN_COUNT |
47 }; | |
48 | |
49 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
50 static gint vflist_row_is_selected(ViewFile *vf, FileData *fd); |
9 | 51 static gint vflist_row_rename_cb(TreeEditData *td, const gchar *old, const gchar *new, gpointer data); |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
52 static void vflist_populate_view(ViewFile *vf); |
9 | 53 |
54 | |
55 /* | |
56 *----------------------------------------------------------------------------- | |
57 * misc | |
58 *----------------------------------------------------------------------------- | |
59 */ | |
168
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
60 typedef struct { |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
61 FileData *fd; |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
62 GtkTreeIter *iter; |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
63 gint found; |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
64 gint row; |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
65 } ViewFileFindRowData; |
168
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
66 |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
67 static gboolean vflist_find_row_cb(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
68 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
69 ViewFileFindRowData *find = data; |
168
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
70 FileData *fd; |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
71 gtk_tree_model_get(model, iter, FILE_COLUMN_POINTER, &fd, -1); |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
72 if (fd == find->fd) |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
73 { |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
74 *find->iter = *iter; |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
75 find->found = 1; |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
76 return TRUE; |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
77 } |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
78 find->row++; |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
79 return FALSE; |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
80 } |
9 | 81 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
82 static gint vflist_find_row(ViewFile *vf, FileData *fd, GtkTreeIter *iter) |
9 | 83 { |
84 GtkTreeModel *store; | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
85 ViewFileFindRowData data = {fd, iter, 0, 0}; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
86 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
87 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
168
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
88 gtk_tree_model_foreach(store, vflist_find_row_cb, &data); |
9 | 89 |
168
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
90 if (data.found) |
9 | 91 { |
168
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
92 return data.row; |
9 | 93 } |
94 | |
95 return -1; | |
96 } | |
97 | |
169 | 98 |
259 | 99 /* |
169 | 100 static gint vflist_find_sidecar_list_idx(GList *work, FileData *fd) |
101 { | |
102 gint i = 0; | |
103 while (work) | |
104 { | |
105 FileData *fd_p = work->data; | |
106 if (fd == fd_p) return i; | |
442 | 107 |
169 | 108 i++; |
109 | |
110 GList *work2 = fd_p->sidecar_files; | |
111 while (work2) | |
112 { | |
442 | 113 fd_p = work2->data; |
169 | 114 if (fd == fd_p) return i; |
442 | 115 |
169 | 116 i++; |
117 work2 = work2->next; | |
118 } | |
119 work = work->next; | |
120 } | |
121 return -1; | |
122 } | |
259 | 123 */ |
169 | 124 |
125 static gint vflist_sidecar_list_count(GList *work) | |
126 { | |
127 gint i = 0; | |
128 while (work) | |
129 { | |
130 FileData *fd = work->data; | |
131 i++; | |
132 | |
133 GList *work2 = fd->sidecar_files; | |
134 while (work2) | |
135 { | |
136 i++; | |
137 work2 = work2->next; | |
138 } | |
139 work = work->next; | |
140 } | |
141 return i; | |
142 } | |
143 | |
144 | |
659
542bb47fef04
Merge vflist_pop_menu() and vficon_pop_menu() into vf_pop_menu().
zas_
parents:
658
diff
changeset
|
145 void vflist_color_set(ViewFile *vf, FileData *fd, gint color_set) |
9 | 146 { |
147 GtkTreeModel *store; | |
148 GtkTreeIter iter; | |
149 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
150 if (vflist_find_row(vf, fd, &iter) < 0) return; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
151 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
152 gtk_tree_store_set(GTK_TREE_STORE(store), &iter, FILE_COLUMN_COLOR, color_set, -1); |
9 | 153 } |
154 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
155 static void vflist_move_cursor(ViewFile *vf, GtkTreeIter *iter) |
9 | 156 { |
157 GtkTreeModel *store; | |
158 GtkTreePath *tpath; | |
159 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
160 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
9 | 161 |
162 tpath = gtk_tree_model_get_path(store, iter); | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
163 gtk_tree_view_set_cursor(GTK_TREE_VIEW(vf->listview), tpath, NULL, FALSE); |
9 | 164 gtk_tree_path_free(tpath); |
165 } | |
166 | |
157 | 167 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
168 static gint vflist_column_idx(ViewFile *vf, gint store_idx) |
157 | 169 { |
170 GList *columns, *work; | |
171 gint i = 0; | |
172 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
173 columns = gtk_tree_view_get_columns(GTK_TREE_VIEW(vf->listview)); |
157 | 174 work = columns; |
175 while (work) | |
176 { | |
177 GtkTreeViewColumn *column = work->data; | |
178 if (store_idx == GPOINTER_TO_INT(g_object_get_data (G_OBJECT(column), "column_store_idx"))) | |
179 break; | |
180 work = work->next; | |
181 i++; | |
182 } | |
442 | 183 |
157 | 184 g_list_free(columns); |
185 return i; | |
186 } | |
187 | |
188 | |
9 | 189 /* |
190 *----------------------------------------------------------------------------- | |
191 * dnd | |
192 *----------------------------------------------------------------------------- | |
193 */ | |
194 | |
195 static void vflist_dnd_get(GtkWidget *widget, GdkDragContext *context, | |
196 GtkSelectionData *selection_data, guint info, | |
197 guint time, gpointer data) | |
198 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
199 ViewFile *vf = data; |
9 | 200 GList *list = NULL; |
201 gchar *uri_text = NULL; | |
202 gint total; | |
203 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
204 if (!VFLIST_INFO(vf, click_fd)) return; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
205 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
206 if (vflist_row_is_selected(vf, VFLIST_INFO(vf, click_fd))) |
9 | 207 { |
633 | 208 list = vf_selection_get_list(vf); |
9 | 209 } |
210 else | |
211 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
212 list = g_list_append(NULL, file_data_ref(VFLIST_INFO(vf, click_fd))); |
9 | 213 } |
214 | |
215 if (!list) return; | |
216 | |
138 | 217 uri_text = uri_text_from_filelist(list, &total, (info == TARGET_TEXT_PLAIN)); |
218 filelist_free(list); | |
9 | 219 |
495 | 220 DEBUG_1(uri_text); |
9 | 221 |
64
04ff0df3ad2f
Mon Aug 15 17:13:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
222 gtk_selection_data_set(selection_data, selection_data->target, |
04ff0df3ad2f
Mon Aug 15 17:13:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
223 8, (guchar *)uri_text, total); |
9 | 224 g_free(uri_text); |
225 } | |
226 | |
227 static void vflist_dnd_begin(GtkWidget *widget, GdkDragContext *context, gpointer data) | |
228 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
229 ViewFile *vf = data; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
230 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
231 vflist_color_set(vf, VFLIST_INFO(vf, click_fd), TRUE); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
232 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
233 if (VFLIST_INFO(vf, thumbs_enabled) && |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
234 VFLIST_INFO(vf, click_fd) && VFLIST_INFO(vf, click_fd)->pixbuf) |
9 | 235 { |
736 | 236 guint items; |
9 | 237 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
238 if (vflist_row_is_selected(vf, VFLIST_INFO(vf, click_fd))) |
633 | 239 items = vf_selection_count(vf, NULL); |
9 | 240 else |
241 items = 1; | |
242 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
243 dnd_set_drag_icon(widget, context, VFLIST_INFO(vf, click_fd)->pixbuf, items); |
9 | 244 } |
245 } | |
246 | |
247 static void vflist_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer data) | |
248 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
249 ViewFile *vf = data; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
250 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
251 vflist_color_set(vf, VFLIST_INFO(vf, click_fd), FALSE); |
9 | 252 |
253 if (context->action == GDK_ACTION_MOVE) | |
254 { | |
633 | 255 vf_refresh(vf); |
9 | 256 } |
257 } | |
258 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
259 void vflist_dnd_init(ViewFile *vf) |
9 | 260 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
261 gtk_drag_source_set(vf->listview, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK, |
9 | 262 dnd_file_drag_types, dnd_file_drag_types_count, |
263 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK); | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
264 g_signal_connect(G_OBJECT(vf->listview), "drag_data_get", |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
265 G_CALLBACK(vflist_dnd_get), vf); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
266 g_signal_connect(G_OBJECT(vf->listview), "drag_begin", |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
267 G_CALLBACK(vflist_dnd_begin), vf); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
268 g_signal_connect(G_OBJECT(vf->listview), "drag_end", |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
269 G_CALLBACK(vflist_dnd_end), vf); |
9 | 270 } |
271 | |
272 /* | |
273 *----------------------------------------------------------------------------- | |
274 * pop-up menu | |
275 *----------------------------------------------------------------------------- | |
276 */ | |
277 | |
634 | 278 GList *vflist_pop_menu_file_list(ViewFile *vf) |
9 | 279 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
280 if (!VFLIST_INFO(vf, click_fd)) return NULL; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
281 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
282 if (vflist_row_is_selected(vf, VFLIST_INFO(vf, click_fd))) |
9 | 283 { |
633 | 284 return vf_selection_get_list(vf); |
9 | 285 } |
286 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
287 return g_list_append(NULL, file_data_ref(VFLIST_INFO(vf, click_fd))); |
9 | 288 } |
289 | |
637 | 290 void vflist_pop_menu_view_cb(GtkWidget *widget, gpointer data) |
9 | 291 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
292 ViewFile *vf = data; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
293 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
294 if (vflist_row_is_selected(vf, VFLIST_INFO(vf, click_fd))) |
9 | 295 { |
296 GList *list; | |
297 | |
633 | 298 list = vf_selection_get_list(vf); |
9 | 299 view_window_new_from_list(list); |
138 | 300 filelist_free(list); |
9 | 301 } |
302 else | |
303 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
304 view_window_new(VFLIST_INFO(vf, click_fd)); |
9 | 305 } |
306 } | |
307 | |
637 | 308 void vflist_pop_menu_rename_cb(GtkWidget *widget, gpointer data) |
9 | 309 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
310 ViewFile *vf = data; |
9 | 311 GList *list; |
312 | |
634 | 313 list = vf_pop_menu_file_list(vf); |
341
15c6b94545a2
Move safe_delete* and in place rename options to file_ops
zas_
parents:
334
diff
changeset
|
314 if (options->file_ops.enable_in_place_rename && |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
315 list && !list->next && VFLIST_INFO(vf, click_fd)) |
9 | 316 { |
317 GtkTreeModel *store; | |
318 GtkTreeIter iter; | |
319 | |
138 | 320 filelist_free(list); |
9 | 321 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
322 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
323 if (vflist_find_row(vf, VFLIST_INFO(vf, click_fd), &iter) >= 0) |
9 | 324 { |
325 GtkTreePath *tpath; | |
326 | |
327 tpath = gtk_tree_model_get_path(store, &iter); | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
328 tree_edit_by_path(GTK_TREE_VIEW(vf->listview), tpath, |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
329 vflist_column_idx(vf, FILE_COLUMN_NAME), VFLIST_INFO(vf, click_fd)->name, |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
330 vflist_row_rename_cb, vf); |
9 | 331 gtk_tree_path_free(tpath); |
332 } | |
333 return; | |
334 } | |
335 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
336 file_util_rename(NULL, list, vf->listview); |
9 | 337 } |
338 | |
659
542bb47fef04
Merge vflist_pop_menu() and vficon_pop_menu() into vf_pop_menu().
zas_
parents:
658
diff
changeset
|
339 void vflist_pop_menu_thumbs_cb(GtkWidget *widget, gpointer data) |
9 | 340 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
341 ViewFile *vf = data; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
342 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
343 vflist_color_set(vf, VFLIST_INFO(vf, click_fd), FALSE); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
344 if (vf->layout) |
9 | 345 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
346 layout_thumb_set(vf->layout, !VFLIST_INFO(vf, thumbs_enabled)); |
9 | 347 } |
348 else | |
349 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
350 vflist_thumb_set(vf, !VFLIST_INFO(vf, thumbs_enabled)); |
9 | 351 } |
352 } | |
353 | |
637 | 354 void vflist_pop_menu_refresh_cb(GtkWidget *widget, gpointer data) |
9 | 355 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
356 ViewFile *vf = data; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
357 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
358 vflist_color_set(vf, VFLIST_INFO(vf, click_fd), FALSE); |
633 | 359 vf_refresh(vf); |
9 | 360 } |
361 | |
637 | 362 void vflist_popup_destroy_cb(GtkWidget *widget, gpointer data) |
9 | 363 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
364 ViewFile *vf = data; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
365 vflist_color_set(vf, VFLIST_INFO(vf, click_fd), FALSE); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
366 VFLIST_INFO(vf, click_fd) = NULL; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
367 vf->popup = NULL; |
9 | 368 } |
369 | |
150 | 370 |
9 | 371 /* |
372 *----------------------------------------------------------------------------- | |
373 * callbacks | |
374 *----------------------------------------------------------------------------- | |
375 */ | |
376 | |
377 static gint vflist_row_rename_cb(TreeEditData *td, const gchar *old, const gchar *new, gpointer data) | |
378 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
379 ViewFile *vf = data; |
9 | 380 gchar *old_path; |
381 gchar *new_path; | |
382 | |
383 if (strlen(new) == 0) return FALSE; | |
384 | |
702
e07895754e65
Drop concat_dir_and_file() and use g_build_filename() instead.
zas_
parents:
671
diff
changeset
|
385 old_path = g_build_filename(vf->path, old, NULL); |
e07895754e65
Drop concat_dir_and_file() and use g_build_filename() instead.
zas_
parents:
671
diff
changeset
|
386 new_path = g_build_filename(vf->path, new, NULL); |
9 | 387 |
726 | 388 if (strchr(new, G_DIR_SEPARATOR) != NULL) |
9 | 389 { |
390 gchar *text = g_strdup_printf(_("Invalid file name:\n%s"), new); | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
391 file_util_warning_dialog(_("Error renaming file"), text, GTK_STOCK_DIALOG_ERROR, vf->listview); |
9 | 392 g_free(text); |
393 } | |
394 else if (isfile(new_path)) | |
395 { | |
396 gchar *text = g_strdup_printf(_("A file with name %s already exists."), new); | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
397 file_util_warning_dialog(_("Error renaming file"), text, GTK_STOCK_DIALOG_ERROR, vf->listview); |
9 | 398 g_free(text); |
399 } | |
442 | 400 else |
9 | 401 { |
633 | 402 gint row = vf_index_by_path(vf, old_path); |
442 | 403 if (row >= 0) |
138 | 404 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
405 GList *work = g_list_nth(vf->list, row); |
138 | 406 FileData *fd = work->data; |
753 | 407 |
408 file_util_rename_simple(fd, new_path, vf->listview); | |
442 | 409 |
138 | 410 } |
411 | |
9 | 412 } |
413 g_free(old_path); | |
414 g_free(new_path); | |
415 | |
416 return FALSE; | |
417 } | |
418 | |
419 static void vflist_menu_position_cb(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer data) | |
420 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
421 ViewFile *vf = data; |
9 | 422 GtkTreeModel *store; |
423 GtkTreeIter iter; | |
424 GtkTreePath *tpath; | |
425 gint cw, ch; | |
426 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
427 if (vflist_find_row(vf, VFLIST_INFO(vf, click_fd), &iter) < 0) return; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
428 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
9 | 429 tpath = gtk_tree_model_get_path(store, &iter); |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
430 tree_view_get_cell_clamped(GTK_TREE_VIEW(vf->listview), tpath, FILE_COLUMN_NAME - 1, TRUE, x, y, &cw, &ch); |
9 | 431 gtk_tree_path_free(tpath); |
432 *y += ch; | |
433 popup_menu_position_clamp(menu, x, y, 0); | |
434 } | |
435 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
436 gint vflist_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) |
9 | 437 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
438 ViewFile *vf = data; |
9 | 439 GtkTreePath *tpath; |
440 | |
441 if (event->keyval != GDK_Menu) return FALSE; | |
442 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
443 gtk_tree_view_get_cursor(GTK_TREE_VIEW(vf->listview), &tpath, NULL); |
9 | 444 if (tpath) |
445 { | |
446 GtkTreeModel *store; | |
447 GtkTreeIter iter; | |
448 | |
449 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget)); | |
450 gtk_tree_model_get_iter(store, &iter, tpath); | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
451 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &VFLIST_INFO(vf, click_fd), -1); |
9 | 452 gtk_tree_path_free(tpath); |
453 } | |
454 else | |
455 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
456 VFLIST_INFO(vf, click_fd) = NULL; |
9 | 457 } |
458 | |
659
542bb47fef04
Merge vflist_pop_menu() and vficon_pop_menu() into vf_pop_menu().
zas_
parents:
658
diff
changeset
|
459 vf->popup = vf_pop_menu(vf); |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
460 gtk_menu_popup(GTK_MENU(vf->popup), NULL, NULL, vflist_menu_position_cb, vf, 0, GDK_CURRENT_TIME); |
9 | 461 |
462 return TRUE; | |
463 } | |
464 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
465 gint vflist_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) |
9 | 466 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
467 ViewFile *vf = data; |
9 | 468 GtkTreePath *tpath; |
469 GtkTreeIter iter; | |
470 FileData *fd = NULL; | |
149 | 471 GtkTreeViewColumn *column; |
654
6dcfac4b356f
Get rid of vflist_pop_menu() col_idx parameter, use new Viewfile field
zas_
parents:
637
diff
changeset
|
472 |
6dcfac4b356f
Get rid of vflist_pop_menu() col_idx parameter, use new Viewfile field
zas_
parents:
637
diff
changeset
|
473 vf->clicked_mark = 0; |
442 | 474 |
9 | 475 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), bevent->x, bevent->y, |
132 | 476 &tpath, &column, NULL, NULL)) |
9 | 477 { |
478 GtkTreeModel *store; | |
654
6dcfac4b356f
Get rid of vflist_pop_menu() col_idx parameter, use new Viewfile field
zas_
parents:
637
diff
changeset
|
479 gint col_idx = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(column), "column_store_idx")); |
442 | 480 |
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
446
diff
changeset
|
481 if (bevent->button == MOUSE_BUTTON_LEFT && |
149 | 482 col_idx >= FILE_COLUMN_MARKS && col_idx <= FILE_COLUMN_MARKS_LAST) |
483 return FALSE; | |
442 | 484 |
655
beacc4c68c53
Fix last patch, only set vf->clicked_mark for a valid mark.
zas_
parents:
654
diff
changeset
|
485 if (col_idx >= FILE_COLUMN_MARKS && col_idx <= FILE_COLUMN_MARKS_LAST) |
beacc4c68c53
Fix last patch, only set vf->clicked_mark for a valid mark.
zas_
parents:
654
diff
changeset
|
486 vf->clicked_mark = 1 + (col_idx - FILE_COLUMN_MARKS); |
654
6dcfac4b356f
Get rid of vflist_pop_menu() col_idx parameter, use new Viewfile field
zas_
parents:
637
diff
changeset
|
487 |
149 | 488 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget)); |
9 | 489 |
490 gtk_tree_model_get_iter(store, &iter, tpath); | |
491 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1); | |
492 #if 0 | |
493 gtk_tree_view_set_cursor(GTK_TREE_VIEW(widget), tpath, NULL, FALSE); | |
494 #endif | |
495 gtk_tree_path_free(tpath); | |
496 } | |
497 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
498 VFLIST_INFO(vf, click_fd) = fd; |
9 | 499 |
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
446
diff
changeset
|
500 if (bevent->button == MOUSE_BUTTON_RIGHT) |
9 | 501 { |
659
542bb47fef04
Merge vflist_pop_menu() and vficon_pop_menu() into vf_pop_menu().
zas_
parents:
658
diff
changeset
|
502 vf->popup = vf_pop_menu(vf); |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
503 gtk_menu_popup(GTK_MENU(vf->popup), NULL, NULL, NULL, NULL, |
9 | 504 bevent->button, bevent->time); |
505 return TRUE; | |
506 } | |
507 | |
508 if (!fd) return FALSE; | |
509 | |
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
446
diff
changeset
|
510 if (bevent->button == MOUSE_BUTTON_MIDDLE) |
9 | 511 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
512 if (!vflist_row_is_selected(vf, fd)) |
9 | 513 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
514 vflist_color_set(vf, fd, TRUE); |
9 | 515 } |
516 return TRUE; | |
517 } | |
518 | |
519 | |
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
446
diff
changeset
|
520 if (bevent->button == MOUSE_BUTTON_LEFT && bevent->type == GDK_BUTTON_PRESS && |
9 | 521 !(bevent->state & GDK_SHIFT_MASK ) && |
522 !(bevent->state & GDK_CONTROL_MASK ) && | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
523 vflist_row_is_selected(vf, fd)) |
9 | 524 { |
526 | 525 GtkTreeSelection *selection; |
526 | |
9 | 527 gtk_widget_grab_focus(widget); |
526 | 528 |
529 | |
530 /* returning FALSE and further processing of the event is needed for | |
531 correct operation of the expander, to show the sidecar files. | |
532 It however resets the selection of multiple files. With this condition | |
533 it should work for both cases */ | |
534 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget)); | |
535 return (gtk_tree_selection_count_selected_rows(selection) > 1); | |
9 | 536 } |
537 | |
538 #if 0 | |
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
446
diff
changeset
|
539 if (bevent->button == MOUSE_BUTTON_LEFT && bevent->type == GDK_2BUTTON_PRESS) |
9 | 540 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
541 if (vf->layout) layout_image_full_screen_start(vf->layout); |
9 | 542 } |
543 #endif | |
544 | |
545 return FALSE; | |
546 } | |
547 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
548 gint vflist_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) |
9 | 549 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
550 ViewFile *vf = data; |
9 | 551 GtkTreePath *tpath; |
552 GtkTreeIter iter; | |
553 FileData *fd = NULL; | |
554 | |
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
446
diff
changeset
|
555 if (bevent->button == MOUSE_BUTTON_MIDDLE) |
9 | 556 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
557 vflist_color_set(vf, VFLIST_INFO(vf, click_fd), FALSE); |
9 | 558 } |
559 | |
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
446
diff
changeset
|
560 if (bevent->button != MOUSE_BUTTON_LEFT && bevent->button != MOUSE_BUTTON_MIDDLE) |
9 | 561 { |
562 return TRUE; | |
563 } | |
564 | |
565 if ((bevent->x != 0 || bevent->y != 0) && | |
566 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), bevent->x, bevent->y, | |
567 &tpath, NULL, NULL, NULL)) | |
568 { | |
569 GtkTreeModel *store; | |
570 | |
571 store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget)); | |
572 gtk_tree_model_get_iter(store, &iter, tpath); | |
573 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1); | |
574 gtk_tree_path_free(tpath); | |
575 } | |
576 | |
448
a73cc0fa14d0
Use explicit names for mouse buttons instead of numbers.
zas_
parents:
446
diff
changeset
|
577 if (bevent->button == MOUSE_BUTTON_MIDDLE) |
9 | 578 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
579 if (fd && VFLIST_INFO(vf, click_fd) == fd) |
9 | 580 { |
581 GtkTreeSelection *selection; | |
582 | |
583 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget)); | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
584 if (vflist_row_is_selected(vf, fd)) |
9 | 585 { |
586 gtk_tree_selection_unselect_iter(selection, &iter); | |
587 } | |
588 else | |
589 { | |
590 gtk_tree_selection_select_iter(selection, &iter); | |
591 } | |
592 } | |
593 return TRUE; | |
594 } | |
595 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
596 if (fd && VFLIST_INFO(vf, click_fd) == fd && |
9 | 597 !(bevent->state & GDK_SHIFT_MASK ) && |
598 !(bevent->state & GDK_CONTROL_MASK ) && | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
599 vflist_row_is_selected(vf, fd)) |
9 | 600 { |
601 GtkTreeSelection *selection; | |
602 | |
603 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget)); | |
604 gtk_tree_selection_unselect_all(selection); | |
605 gtk_tree_selection_select_iter(selection, &iter); | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
606 vflist_move_cursor(vf, &iter); |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
607 // return TRUE;// FIXME - expand |
9 | 608 } |
609 | |
610 return FALSE; | |
611 } | |
612 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
613 static void vflist_select_image(ViewFile *vf, FileData *sel_fd) |
9 | 614 { |
138 | 615 FileData *read_ahead_fd = NULL; |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
616 gint row; |
144 | 617 FileData *cur_fd; |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
618 if (!sel_fd) return; |
442 | 619 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
620 cur_fd = layout_image_get_fd(vf->layout); |
144 | 621 if (sel_fd == cur_fd) return; /* no change */ |
442 | 622 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
623 row = g_list_index(vf->list, sel_fd); |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
624 // FIXME sidecar data |
9 | 625 |
334 | 626 if (sel_fd && options->image.enable_read_ahead && row >= 0) |
9 | 627 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
628 if (row > g_list_index(vf->list, cur_fd) && |
736 | 629 (guint) (row + 1) < vf_count(vf, NULL)) |
9 | 630 { |
633 | 631 read_ahead_fd = vf_index_get_data(vf, row + 1); |
9 | 632 } |
633 else if (row > 0) | |
634 { | |
633 | 635 read_ahead_fd = vf_index_get_data(vf, row - 1); |
9 | 636 } |
637 } | |
638 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
639 layout_image_set_with_ahead(vf->layout, sel_fd, read_ahead_fd); |
9 | 640 } |
641 | |
642 static gint vflist_select_idle_cb(gpointer data) | |
643 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
644 ViewFile *vf = data; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
645 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
646 if (!vf->layout) |
9 | 647 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
648 VFLIST_INFO(vf, select_idle_id) = -1; |
9 | 649 return FALSE; |
650 } | |
651 | |
633 | 652 vf_send_update(vf); |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
653 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
654 if (VFLIST_INFO(vf, select_fd)) |
9 | 655 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
656 vflist_select_image(vf, VFLIST_INFO(vf, select_fd)); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
657 VFLIST_INFO(vf, select_fd) = NULL; |
9 | 658 } |
659 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
660 VFLIST_INFO(vf, select_idle_id) = -1; |
9 | 661 return FALSE; |
662 } | |
663 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
664 static void vflist_select_idle_cancel(ViewFile *vf) |
9 | 665 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
666 if (VFLIST_INFO(vf, select_idle_id) != -1) g_source_remove(VFLIST_INFO(vf, select_idle_id)); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
667 VFLIST_INFO(vf, select_idle_id) = -1; |
9 | 668 } |
669 | |
670 static gboolean vflist_select_cb(GtkTreeSelection *selection, GtkTreeModel *store, GtkTreePath *tpath, | |
671 gboolean path_currently_selected, gpointer data) | |
672 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
673 ViewFile *vf = data; |
9 | 674 GtkTreeIter iter; |
675 | |
676 if (!path_currently_selected && | |
677 gtk_tree_model_get_iter(store, &iter, tpath)) | |
678 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
679 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &VFLIST_INFO(vf, select_fd), -1); |
9 | 680 } |
681 else | |
682 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
683 VFLIST_INFO(vf, select_fd) = NULL; |
9 | 684 } |
685 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
686 if (vf->layout && |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
687 VFLIST_INFO(vf, select_idle_id) == -1) |
9 | 688 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
689 VFLIST_INFO(vf, select_idle_id) = g_idle_add(vflist_select_idle_cb, vf); |
9 | 690 } |
691 | |
692 return TRUE; | |
693 } | |
694 | |
695 /* | |
696 *----------------------------------------------------------------------------- | |
697 * misc | |
698 *----------------------------------------------------------------------------- | |
699 */ | |
700 | |
259 | 701 /* |
93
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
702 static gboolean vflist_dummy_select_cb(GtkTreeSelection *selection, GtkTreeModel *store, GtkTreePath *tpath, |
442 | 703 gboolean path_currently_selected, gpointer data) |
93
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
704 { |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
705 return TRUE; |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
706 } |
259 | 707 */ |
93
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
708 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
709 static void vflist_setup_iter(ViewFile *vf, GtkTreeStore *store, GtkTreeIter *iter, FileData *fd) |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
710 { |
167 | 711 int i; |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
712 gchar *size; |
167 | 713 gchar *sidecars = NULL; |
714 | |
715 if (fd->sidecar_files) | |
596 | 716 sidecars = file_data_sc_list_to_string(fd); |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
717 size = text_from_size(fd->size); |
442 | 718 |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
719 gtk_tree_store_set(store, iter, FILE_COLUMN_POINTER, fd, |
763
81f9e8dbb4bf
improved infrastructure for tracing changes, optimized vflist_populate_view
nadvornik
parents:
762
diff
changeset
|
720 FILE_COLUMN_VERSION, fd->version, |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
721 FILE_COLUMN_THUMB, (VFLIST_INFO(vf, thumbs_enabled)) ? fd->pixbuf : NULL, |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
722 FILE_COLUMN_NAME, fd->name, |
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
723 FILE_COLUMN_SIDECARS, sidecars, |
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
724 FILE_COLUMN_SIZE, size, |
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
725 FILE_COLUMN_DATE, text_from_time(fd->date), |
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
726 FILE_COLUMN_COLOR, FALSE, -1); |
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
727 for (i = 0; i < FILEDATA_MARKS_SIZE; i++) |
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
728 gtk_tree_store_set(store, iter, FILE_COLUMN_MARKS + i, fd->marks[i], -1); |
168
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
729 |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
730 g_free(size); |
167 | 731 if (sidecars) |
732 g_free(sidecars); | |
733 } | |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
734 |
771
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
735 static void vflist_setup_iter_recursive(ViewFile *vf, GtkTreeStore *store, GtkTreeIter *parent_iter, GList *list, GList *selected) |
167 | 736 { |
737 GList *work; | |
769 | 738 GtkTreeIter iter; |
167 | 739 gint valid; |
740 | |
769 | 741 valid = gtk_tree_model_iter_children(GTK_TREE_MODEL(store), &iter, parent_iter); |
167 | 742 |
769 | 743 work = list; |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
744 while (work) |
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
745 { |
167 | 746 gint match; |
769 | 747 FileData *fd = work->data; |
167 | 748 gint done = FALSE; |
749 | |
750 while (!done) | |
751 { | |
769 | 752 FileData *old_fd = NULL; |
753 gint old_version = 0; | |
442 | 754 |
167 | 755 if (valid) |
756 { | |
769 | 757 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, |
758 FILE_COLUMN_POINTER, &old_fd, | |
759 FILE_COLUMN_VERSION, &old_version, | |
760 -1); | |
442 | 761 |
769 | 762 if (fd == old_fd) |
167 | 763 { |
764 match = 0; | |
765 } | |
766 else | |
767 { | |
769 | 768 if (parent_iter) |
769 match = filelist_sort_compare_filedata_full(fd, old_fd, SORT_NAME, TRUE); /* always sort sidecars by name */ | |
770 else | |
771 match = filelist_sort_compare_filedata_full(fd, old_fd, vf->sort_method, vf->sort_ascend); | |
772 | |
773 if (match == 0) g_warning("multiple fd for the same path"); | |
167 | 774 } |
769 | 775 |
167 | 776 } |
777 else | |
778 { | |
779 match = -1; | |
780 } | |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
781 |
167 | 782 if (match < 0) |
783 { | |
784 GtkTreeIter new; | |
442 | 785 |
167 | 786 if (valid) |
787 { | |
769 | 788 gtk_tree_store_insert_before(store, &new, parent_iter, &iter); |
167 | 789 } |
790 else | |
791 { | |
769 | 792 gtk_tree_store_append(store, &new, parent_iter); |
167 | 793 } |
442 | 794 |
769 | 795 vflist_setup_iter(vf, store, &new, fd); |
771
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
796 vflist_setup_iter_recursive(vf, store, &new, fd->sidecar_files, selected); |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
797 |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
798 if (g_list_find(selected, fd)) |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
799 { |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
800 /* renamed files - the same fd appears at different position - select it again*/ |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
801 GtkTreeSelection *selection; |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
802 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
803 gtk_tree_selection_select_iter(selection, &new); |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
804 } |
167 | 805 |
806 done = TRUE; | |
807 } | |
808 else if (match > 0) | |
809 { | |
769 | 810 valid = gtk_tree_store_remove(store, &iter); |
167 | 811 } |
812 else | |
813 { | |
769 | 814 if (fd->version != old_version) |
815 { | |
816 vflist_setup_iter(vf, store, &iter, fd); | |
771
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
817 vflist_setup_iter_recursive(vf, store, &iter, fd->sidecar_files, selected); |
769 | 818 } |
167 | 819 |
769 | 820 if (valid) valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter); |
167 | 821 |
822 done = TRUE; | |
823 } | |
824 } | |
825 work = work->next; | |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
826 } |
167 | 827 |
828 while (valid) | |
829 { | |
769 | 830 valid = gtk_tree_store_remove(store, &iter); |
167 | 831 } |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
832 } |
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
833 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
834 void vflist_sort_set(ViewFile *vf, SortType type, gint ascend) |
9 | 835 { |
168
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
836 gint i; |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
837 GHashTable *fd_idx_hash = g_hash_table_new(NULL, NULL); |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
838 gint *new_order; |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
839 GtkTreeStore *store; |
9 | 840 GList *work; |
841 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
842 if (vf->sort_method == type && vf->sort_ascend == ascend) return; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
843 if (!vf->list) return; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
844 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
845 work = vf->list; |
168
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
846 i = 0; |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
847 while (work) |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
848 { |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
849 FileData *fd = work->data; |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
850 g_hash_table_insert(fd_idx_hash, fd, GINT_TO_POINTER(i)); |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
851 i++; |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
852 work = work->next; |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
853 } |
9 | 854 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
855 vf->sort_method = type; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
856 vf->sort_ascend = ascend; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
857 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
858 vf->list = filelist_sort(vf->list, vf->sort_method, vf->sort_ascend); |
442 | 859 |
168
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
860 new_order = g_malloc(i * sizeof(gint)); |
442 | 861 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
862 work = vf->list; |
168
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
863 i = 0; |
93
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
864 while (work) |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
865 { |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
866 FileData *fd = work->data; |
168
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
867 new_order[i] = GPOINTER_TO_INT(g_hash_table_lookup(fd_idx_hash, fd)); |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
868 i++; |
93
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
869 work = work->next; |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
870 } |
442 | 871 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
872 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview))); |
168
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
873 gtk_tree_store_reorder(store, NULL, new_order); |
442 | 874 |
168
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
875 g_free(new_order); |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
876 g_hash_table_destroy(fd_idx_hash); |
9 | 877 } |
878 | |
879 /* | |
880 *----------------------------------------------------------------------------- | |
881 * thumb updates | |
882 *----------------------------------------------------------------------------- | |
883 */ | |
884 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
885 static gint vflist_thumb_next(ViewFile *vf); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
886 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
887 static void vflist_thumb_status(ViewFile *vf, gdouble val, const gchar *text) |
9 | 888 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
889 if (vf->func_thumb_status) |
9 | 890 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
891 vf->func_thumb_status(vf, val, text, vf->data_thumb_status); |
9 | 892 } |
893 } | |
894 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
895 static void vflist_thumb_cleanup(ViewFile *vf) |
9 | 896 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
897 vflist_thumb_status(vf, 0.0, NULL); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
898 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
899 vf->thumbs_count = 0; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
900 vf->thumbs_running = FALSE; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
901 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
902 thumb_loader_free(vf->thumbs_loader); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
903 vf->thumbs_loader = NULL; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
904 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
905 vf->thumbs_filedata = NULL; |
9 | 906 } |
907 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
908 static void vflist_thumb_stop(ViewFile *vf) |
9 | 909 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
910 if (vf->thumbs_running) vflist_thumb_cleanup(vf); |
9 | 911 } |
912 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
913 static void vflist_thumb_do(ViewFile *vf, ThumbLoader *tl, FileData *fd) |
9 | 914 { |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
915 GtkTreeStore *store; |
9 | 916 GtkTreeIter iter; |
917 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
918 if (!fd || vflist_find_row(vf, fd, &iter) < 0) return; |
9 | 919 |
920 if (fd->pixbuf) g_object_unref(fd->pixbuf); | |
921 fd->pixbuf = thumb_loader_get_pixbuf(tl, TRUE); | |
922 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
923 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview))); |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
924 gtk_tree_store_set(store, &iter, FILE_COLUMN_THUMB, fd->pixbuf, -1); |
9 | 925 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
926 vflist_thumb_status(vf, (gdouble)(vf->thumbs_count) / vflist_sidecar_list_count(vf->list), _("Loading thumbs...")); |
9 | 927 } |
928 | |
929 static void vflist_thumb_error_cb(ThumbLoader *tl, gpointer data) | |
930 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
931 ViewFile *vf = data; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
932 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
933 if (vf->thumbs_filedata && vf->thumbs_loader == tl) |
9 | 934 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
935 vflist_thumb_do(vf, tl, vf->thumbs_filedata); |
9 | 936 } |
937 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
938 while (vflist_thumb_next(vf)); |
9 | 939 } |
940 | |
941 static void vflist_thumb_done_cb(ThumbLoader *tl, gpointer data) | |
942 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
943 ViewFile *vf = data; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
944 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
945 if (vf->thumbs_filedata && vf->thumbs_loader == tl) |
9 | 946 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
947 vflist_thumb_do(vf, tl, vf->thumbs_filedata); |
9 | 948 } |
949 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
950 while (vflist_thumb_next(vf)); |
9 | 951 } |
952 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
953 static gint vflist_thumb_next(ViewFile *vf) |
9 | 954 { |
955 GtkTreePath *tpath; | |
956 FileData *fd = NULL; | |
957 | |
958 /* first check the visible files */ | |
959 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
960 if (GTK_WIDGET_REALIZED(vf->listview) && |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
961 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vf->listview), 0, 0, &tpath, NULL, NULL, NULL)) |
9 | 962 { |
963 GtkTreeModel *store; | |
964 GtkTreeIter iter; | |
965 gint valid = TRUE; | |
966 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
967 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
9 | 968 gtk_tree_model_get_iter(store, &iter, tpath); |
969 gtk_tree_path_free(tpath); | |
970 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
971 while (!fd && valid && tree_view_row_get_visibility(GTK_TREE_VIEW(vf->listview), &iter, FALSE) == 0) |
9 | 972 { |
973 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1); | |
974 if (fd->pixbuf) fd = NULL; | |
975 | |
976 valid = gtk_tree_model_iter_next(store, &iter); | |
977 } | |
978 } | |
979 | |
980 /* then find first undone */ | |
981 | |
982 if (!fd) | |
983 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
984 GList *work = vf->list; |
9 | 985 while (work && !fd) |
986 { | |
987 FileData *fd_p = work->data; | |
442 | 988 if (!fd_p->pixbuf) |
169 | 989 fd = fd_p; |
990 else | |
991 { | |
992 GList *work2 = fd_p->sidecar_files; | |
442 | 993 |
169 | 994 while (work2 && !fd) |
995 { | |
442 | 996 fd_p = work2->data; |
169 | 997 if (!fd_p->pixbuf) fd = fd_p; |
998 work2 = work2->next; | |
999 } | |
1000 } | |
9 | 1001 work = work->next; |
1002 } | |
1003 } | |
1004 | |
1005 if (!fd) | |
1006 { | |
1007 /* done */ | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1008 vflist_thumb_cleanup(vf); |
9 | 1009 return FALSE; |
1010 } | |
1011 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1012 vf->thumbs_count++; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1013 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1014 vf->thumbs_filedata = fd; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1015 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1016 thumb_loader_free(vf->thumbs_loader); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1017 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1018 vf->thumbs_loader = thumb_loader_new(options->thumbnails.max_width, options->thumbnails.max_height); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1019 thumb_loader_set_callbacks(vf->thumbs_loader, |
9 | 1020 vflist_thumb_done_cb, |
1021 vflist_thumb_error_cb, | |
1022 NULL, | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1023 vf); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1024 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1025 if (!thumb_loader_start(vf->thumbs_loader, fd->path)) |
9 | 1026 { |
1027 /* set icon to unknown, continue */ | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1028 DEBUG_1("thumb loader start failed %s", vf->thumbs_loader->path); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1029 vflist_thumb_do(vf, vf->thumbs_loader, fd); |
9 | 1030 |
1031 return TRUE; | |
1032 } | |
1033 | |
1034 return FALSE; | |
1035 } | |
1036 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1037 static void vflist_thumb_update(ViewFile *vf) |
9 | 1038 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1039 vflist_thumb_stop(vf); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1040 if (!VFLIST_INFO(vf, thumbs_enabled)) return; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1041 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1042 vflist_thumb_status(vf, 0.0, _("Loading thumbs...")); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1043 vf->thumbs_running = TRUE; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1044 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1045 while (vflist_thumb_next(vf)); |
9 | 1046 } |
1047 | |
1048 /* | |
1049 *----------------------------------------------------------------------------- | |
1050 * row stuff | |
1051 *----------------------------------------------------------------------------- | |
1052 */ | |
1053 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1054 FileData *vflist_index_get_data(ViewFile *vf, gint row) |
9 | 1055 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1056 return g_list_nth_data(vf->list, row); |
9 | 1057 } |
1058 | |
664
db373fb1b9d8
Merge vflist_row_by_path() into vflist_index_by_path().
zas_
parents:
659
diff
changeset
|
1059 gint vflist_index_by_path(ViewFile *vf, const gchar *path) |
9 | 1060 { |
1061 gint p = 0; | |
1062 GList *work; | |
1063 | |
1064 if (!path) return -1; | |
1065 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1066 work = vf->list; |
9 | 1067 while (work) |
1068 { | |
664
db373fb1b9d8
Merge vflist_row_by_path() into vflist_index_by_path().
zas_
parents:
659
diff
changeset
|
1069 FileData *fd = work->data; |
db373fb1b9d8
Merge vflist_row_by_path() into vflist_index_by_path().
zas_
parents:
659
diff
changeset
|
1070 if (strcmp(path, fd->path) == 0) return p; |
db373fb1b9d8
Merge vflist_row_by_path() into vflist_index_by_path().
zas_
parents:
659
diff
changeset
|
1071 |
9 | 1072 work = work->next; |
1073 p++; | |
1074 } | |
1075 | |
1076 return -1; | |
1077 } | |
1078 | |
736 | 1079 guint vflist_count(ViewFile *vf, gint64 *bytes) |
9 | 1080 { |
1081 if (bytes) | |
1082 { | |
1083 gint64 b = 0; | |
1084 GList *work; | |
1085 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1086 work = vf->list; |
9 | 1087 while (work) |
1088 { | |
1089 FileData *fd = work->data; | |
1090 work = work->next; | |
1091 b += fd->size; | |
1092 } | |
1093 | |
1094 *bytes = b; | |
1095 } | |
1096 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1097 return g_list_length(vf->list); |
9 | 1098 } |
1099 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1100 GList *vflist_get_list(ViewFile *vf) |
9 | 1101 { |
1102 GList *list = NULL; | |
1103 GList *work; | |
1104 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1105 work = vf->list; |
9 | 1106 while (work) |
1107 { | |
1108 FileData *fd = work->data; | |
1109 work = work->next; | |
1110 | |
138 | 1111 list = g_list_prepend(list, file_data_ref(fd)); |
9 | 1112 } |
1113 | |
1114 return g_list_reverse(list); | |
1115 } | |
1116 | |
1117 /* | |
1118 *----------------------------------------------------------------------------- | |
1119 * selections | |
1120 *----------------------------------------------------------------------------- | |
1121 */ | |
1122 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1123 static gint vflist_row_is_selected(ViewFile *vf, FileData *fd) |
9 | 1124 { |
1125 GtkTreeModel *store; | |
1126 GtkTreeSelection *selection; | |
1127 GList *slist; | |
1128 GList *work; | |
1129 gint found = FALSE; | |
1130 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1131 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
9 | 1132 slist = gtk_tree_selection_get_selected_rows(selection, &store); |
1133 work = slist; | |
1134 while (!found && work) | |
1135 { | |
1136 GtkTreePath *tpath = work->data; | |
1137 FileData *fd_n; | |
1138 GtkTreeIter iter; | |
1139 | |
1140 gtk_tree_model_get_iter(store, &iter, tpath); | |
1141 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd_n, -1); | |
1142 if (fd_n == fd) found = TRUE; | |
1143 work = work->next; | |
1144 } | |
1145 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL); | |
1146 g_list_free(slist); | |
1147 | |
1148 return found; | |
1149 } | |
1150 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1151 gint vflist_index_is_selected(ViewFile *vf, gint row) |
9 | 1152 { |
1153 FileData *fd; | |
1154 | |
633 | 1155 fd = vf_index_get_data(vf, row); |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1156 return vflist_row_is_selected(vf, fd); |
9 | 1157 } |
1158 | |
736 | 1159 guint vflist_selection_count(ViewFile *vf, gint64 *bytes) |
9 | 1160 { |
1161 GtkTreeModel *store; | |
1162 GtkTreeSelection *selection; | |
1163 GList *slist; | |
736 | 1164 guint count; |
9 | 1165 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1166 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
9 | 1167 slist = gtk_tree_selection_get_selected_rows(selection, &store); |
1168 | |
1169 if (bytes) | |
1170 { | |
1171 gint64 b = 0; | |
1172 GList *work; | |
1173 | |
1174 work = slist; | |
1175 while (work) | |
1176 { | |
1177 GtkTreePath *tpath = work->data; | |
1178 GtkTreeIter iter; | |
1179 FileData *fd; | |
1180 | |
1181 gtk_tree_model_get_iter(store, &iter, tpath); | |
1182 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1); | |
1183 b += fd->size; | |
1184 | |
1185 work = work->next; | |
1186 } | |
1187 | |
1188 *bytes = b; | |
1189 } | |
1190 | |
1191 count = g_list_length(slist); | |
1192 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL); | |
1193 g_list_free(slist); | |
1194 | |
1195 return count; | |
1196 } | |
1197 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1198 GList *vflist_selection_get_list(ViewFile *vf) |
9 | 1199 { |
1200 GtkTreeModel *store; | |
1201 GtkTreeSelection *selection; | |
1202 GList *slist; | |
1203 GList *list = NULL; | |
1204 GList *work; | |
1205 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1206 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
9 | 1207 slist = gtk_tree_selection_get_selected_rows(selection, &store); |
1208 work = slist; | |
1209 while (work) | |
1210 { | |
1211 GtkTreePath *tpath = work->data; | |
1212 FileData *fd; | |
1213 GtkTreeIter iter; | |
1214 | |
1215 gtk_tree_model_get_iter(store, &iter, tpath); | |
1216 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1); | |
1217 | |
138 | 1218 list = g_list_prepend(list, file_data_ref(fd)); |
9 | 1219 |
1220 work = work->next; | |
1221 } | |
1222 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL); | |
1223 g_list_free(slist); | |
1224 | |
1225 return g_list_reverse(list); | |
1226 } | |
1227 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1228 GList *vflist_selection_get_list_by_index(ViewFile *vf) |
9 | 1229 { |
1230 GtkTreeModel *store; | |
1231 GtkTreeSelection *selection; | |
1232 GList *slist; | |
1233 GList *list = NULL; | |
1234 GList *work; | |
1235 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1236 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
9 | 1237 slist = gtk_tree_selection_get_selected_rows(selection, &store); |
1238 work = slist; | |
1239 while (work) | |
1240 { | |
1241 GtkTreePath *tpath = work->data; | |
1242 FileData *fd; | |
1243 GtkTreeIter iter; | |
1244 | |
1245 gtk_tree_model_get_iter(store, &iter, tpath); | |
1246 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1); | |
1247 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1248 list = g_list_prepend(list, GINT_TO_POINTER(g_list_index(vf->list, fd))); |
9 | 1249 |
1250 work = work->next; | |
1251 } | |
1252 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL); | |
1253 g_list_free(slist); | |
1254 | |
1255 return g_list_reverse(list); | |
1256 } | |
1257 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1258 void vflist_select_all(ViewFile *vf) |
9 | 1259 { |
1260 GtkTreeSelection *selection; | |
1261 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1262 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
9 | 1263 gtk_tree_selection_select_all(selection); |
1264 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1265 VFLIST_INFO(vf, select_fd) = NULL; |
9 | 1266 } |
1267 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1268 void vflist_select_none(ViewFile *vf) |
9 | 1269 { |
1270 GtkTreeSelection *selection; | |
1271 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1272 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
9 | 1273 gtk_tree_selection_unselect_all(selection); |
1274 } | |
1275 | |
601 | 1276 static gboolean tree_model_iter_prev(GtkTreeModel *store, GtkTreeIter *iter) |
1277 { | |
1278 GtkTreePath *tpath; | |
1279 gboolean result; | |
1280 | |
1281 tpath = gtk_tree_model_get_path(store, iter); | |
1282 result = gtk_tree_path_prev(tpath); | |
1283 if (result) | |
1284 gtk_tree_model_get_iter(store, iter, tpath); | |
1285 | |
1286 gtk_tree_path_free(tpath); | |
1287 | |
1288 return result; | |
1289 } | |
1290 | |
1291 static gboolean tree_model_get_iter_last(GtkTreeModel *store, GtkTreeIter *iter) | |
1292 { | |
1293 if (!gtk_tree_model_get_iter_first(store, iter)) | |
1294 return FALSE; | |
1295 | |
1296 while (TRUE) | |
1297 { | |
1298 GtkTreeIter next = *iter; | |
1299 | |
1300 if (gtk_tree_model_iter_next(store, &next)) | |
1301 *iter = next; | |
1302 else | |
1303 break; | |
1304 } | |
1305 | |
1306 return TRUE; | |
1307 } | |
1308 | |
1309 void vflist_select_invert(ViewFile *vf) | |
1310 { | |
1311 GtkTreeIter iter; | |
1312 GtkTreeSelection *selection; | |
1313 GtkTreeModel *store; | |
1314 gboolean valid; | |
1315 | |
1316 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); | |
1317 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); | |
1318 | |
1319 /* Backward iteration prevents scrolling to the end of the list, | |
1320 * it scrolls to the first selected row instead. */ | |
1321 valid = tree_model_get_iter_last(store, &iter); | |
1322 | |
1323 while (valid) | |
1324 { | |
1325 gint selected = gtk_tree_selection_iter_is_selected(selection, &iter); | |
1326 | |
1327 if (selected) | |
1328 gtk_tree_selection_unselect_iter(selection, &iter); | |
1329 else | |
1330 gtk_tree_selection_select_iter(selection, &iter); | |
1331 | |
1332 valid = tree_model_iter_prev(store, &iter); | |
1333 } | |
1334 } | |
1335 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1336 void vflist_select_by_fd(ViewFile *vf, FileData *fd) |
138 | 1337 { |
9 | 1338 GtkTreeIter iter; |
1339 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1340 if (vflist_find_row(vf, fd, &iter) < 0) return; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1341 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1342 tree_view_row_make_visible(GTK_TREE_VIEW(vf->listview), &iter, TRUE); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1343 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1344 if (!vflist_row_is_selected(vf, fd)) |
9 | 1345 { |
1346 GtkTreeSelection *selection; | |
1347 GtkTreeModel *store; | |
1348 GtkTreePath *tpath; | |
1349 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1350 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
9 | 1351 gtk_tree_selection_unselect_all(selection); |
1352 gtk_tree_selection_select_iter(selection, &iter); | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1353 vflist_move_cursor(vf, &iter); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1354 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1355 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
9 | 1356 tpath = gtk_tree_model_get_path(store, &iter); |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1357 gtk_tree_view_set_cursor(GTK_TREE_VIEW(vf->listview), tpath, NULL, FALSE); |
9 | 1358 gtk_tree_path_free(tpath); |
1359 } | |
1360 } | |
1361 | |
771
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1362 static void vflist_select_closest(ViewFile *vf, FileData *sel_fd) |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1363 { |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1364 GList *work; |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1365 |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1366 if (sel_fd->parent) sel_fd = sel_fd->parent; |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1367 work = vf->list; |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1368 |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1369 while (work) |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1370 { |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1371 gint match; |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1372 FileData *fd = work->data; |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1373 work = work->next; |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1374 |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1375 |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1376 match = filelist_sort_compare_filedata_full(fd, sel_fd, vf->sort_method, vf->sort_ascend); |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1377 |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1378 if (match >= 0) |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1379 { |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1380 vflist_select_by_fd(vf, fd); |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1381 break; |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1382 } |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1383 } |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1384 |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1385 } |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1386 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1387 void vflist_mark_to_selection(ViewFile *vf, gint mark, MarkToSelectionMode mode) |
150 | 1388 { |
1389 GtkTreeModel *store; | |
1390 GtkTreeIter iter; | |
1391 GtkTreeSelection *selection; | |
1392 gint valid; | |
654
6dcfac4b356f
Get rid of vflist_pop_menu() col_idx parameter, use new Viewfile field
zas_
parents:
637
diff
changeset
|
1393 gint n = mark - 1; |
442 | 1394 |
654
6dcfac4b356f
Get rid of vflist_pop_menu() col_idx parameter, use new Viewfile field
zas_
parents:
637
diff
changeset
|
1395 g_assert(mark >= 1 && mark <= FILEDATA_MARKS_SIZE); |
150 | 1396 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1397 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1398 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
442 | 1399 |
150 | 1400 valid = gtk_tree_model_get_iter_first(store, &iter); |
1401 while (valid) | |
1402 { | |
1403 FileData *fd; | |
161 | 1404 gboolean mark_val, selected; |
150 | 1405 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, FILE_COLUMN_POINTER, &fd, -1); |
442 | 1406 |
654
6dcfac4b356f
Get rid of vflist_pop_menu() col_idx parameter, use new Viewfile field
zas_
parents:
637
diff
changeset
|
1407 mark_val = fd->marks[n]; |
161 | 1408 selected = gtk_tree_selection_iter_is_selected(selection, &iter); |
442 | 1409 |
1410 switch (mode) | |
161 | 1411 { |
1412 case MTS_MODE_SET: selected = mark_val; | |
1413 break; | |
1414 case MTS_MODE_OR: selected = mark_val | selected; | |
1415 break; | |
1416 case MTS_MODE_AND: selected = mark_val & selected; | |
1417 break; | |
1418 case MTS_MODE_MINUS: selected = !mark_val & selected; | |
1419 break; | |
1420 } | |
442 | 1421 |
161 | 1422 if (selected) |
150 | 1423 gtk_tree_selection_select_iter(selection, &iter); |
161 | 1424 else |
1425 gtk_tree_selection_unselect_iter(selection, &iter); | |
150 | 1426 |
1427 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter); | |
1428 } | |
1429 } | |
1430 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1431 void vflist_selection_to_mark(ViewFile *vf, gint mark, SelectionToMarkMode mode) |
150 | 1432 { |
1433 GtkTreeModel *store; | |
1434 GtkTreeSelection *selection; | |
1435 GList *slist; | |
1436 GList *work; | |
654
6dcfac4b356f
Get rid of vflist_pop_menu() col_idx parameter, use new Viewfile field
zas_
parents:
637
diff
changeset
|
1437 gint n = mark - 1; |
150 | 1438 |
654
6dcfac4b356f
Get rid of vflist_pop_menu() col_idx parameter, use new Viewfile field
zas_
parents:
637
diff
changeset
|
1439 g_assert(mark >= 1 && mark <= FILEDATA_MARKS_SIZE); |
150 | 1440 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1441 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
150 | 1442 slist = gtk_tree_selection_get_selected_rows(selection, &store); |
1443 work = slist; | |
1444 while (work) | |
1445 { | |
1446 GtkTreePath *tpath = work->data; | |
1447 FileData *fd; | |
1448 GtkTreeIter iter; | |
1449 | |
1450 gtk_tree_model_get_iter(store, &iter, tpath); | |
1451 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1); | |
442 | 1452 |
161 | 1453 switch (mode) |
1454 { | |
654
6dcfac4b356f
Get rid of vflist_pop_menu() col_idx parameter, use new Viewfile field
zas_
parents:
637
diff
changeset
|
1455 case STM_MODE_SET: fd->marks[n] = 1; |
161 | 1456 break; |
654
6dcfac4b356f
Get rid of vflist_pop_menu() col_idx parameter, use new Viewfile field
zas_
parents:
637
diff
changeset
|
1457 case STM_MODE_RESET: fd->marks[n] = 0; |
161 | 1458 break; |
654
6dcfac4b356f
Get rid of vflist_pop_menu() col_idx parameter, use new Viewfile field
zas_
parents:
637
diff
changeset
|
1459 case STM_MODE_TOGGLE: fd->marks[n] = !fd->marks[n]; |
161 | 1460 break; |
1461 } | |
763
81f9e8dbb4bf
improved infrastructure for tracing changes, optimized vflist_populate_view
nadvornik
parents:
762
diff
changeset
|
1462 |
81f9e8dbb4bf
improved infrastructure for tracing changes, optimized vflist_populate_view
nadvornik
parents:
762
diff
changeset
|
1463 file_data_increment_version(fd); |
442 | 1464 |
654
6dcfac4b356f
Get rid of vflist_pop_menu() col_idx parameter, use new Viewfile field
zas_
parents:
637
diff
changeset
|
1465 gtk_tree_store_set(GTK_TREE_STORE(store), &iter, FILE_COLUMN_MARKS + n, fd->marks[n], -1); |
150 | 1466 |
1467 work = work->next; | |
1468 } | |
1469 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL); | |
1470 g_list_free(slist); | |
1471 } | |
1472 | |
9 | 1473 /* |
1474 *----------------------------------------------------------------------------- | |
1475 * core (population) | |
1476 *----------------------------------------------------------------------------- | |
1477 */ | |
1478 | |
1479 static void vflist_listview_set_height(GtkWidget *listview, gint thumb) | |
1480 { | |
1481 GtkTreeViewColumn *column; | |
1482 GtkCellRenderer *cell; | |
1483 GList *list; | |
1484 | |
770 | 1485 column = gtk_tree_view_get_column(GTK_TREE_VIEW(listview), 0); /* first column is thumbnail */ |
9 | 1486 if (!column) return; |
1487 | |
333 | 1488 gtk_tree_view_column_set_fixed_width(column, ((thumb) ? options->thumbnails.max_width : 4) + 10); |
9 | 1489 |
1490 list = gtk_tree_view_column_get_cell_renderers(column); | |
1491 if (!list) return; | |
1492 cell = list->data; | |
1493 g_list_free(list); | |
1494 | |
333 | 1495 g_object_set(G_OBJECT(cell), "height", (thumb) ? options->thumbnails.max_height : -1, NULL); |
9 | 1496 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(listview)); |
1497 } | |
1498 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1499 static void vflist_populate_view(ViewFile *vf) |
9 | 1500 { |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1501 GtkTreeStore *store; |
9 | 1502 gint thumbs; |
1503 GtkTreeRowReference *visible_row = NULL; | |
1504 GtkTreePath *tpath; | |
771
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1505 GList *selected; |
9 | 1506 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1507 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview))); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1508 thumbs = VFLIST_INFO(vf, thumbs_enabled); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1509 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1510 vflist_thumb_stop(vf); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1511 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1512 if (!vf->list) |
9 | 1513 { |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1514 gtk_tree_store_clear(store); |
633 | 1515 vf_send_update(vf); |
9 | 1516 return; |
1517 } | |
1518 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1519 if (GTK_WIDGET_REALIZED(vf->listview) && |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1520 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vf->listview), 0, 0, &tpath, NULL, NULL, NULL)) |
9 | 1521 { |
1522 visible_row = gtk_tree_row_reference_new(GTK_TREE_MODEL(store), tpath); | |
1523 gtk_tree_path_free(tpath); | |
1524 } | |
1525 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1526 vflist_listview_set_height(vf->listview, thumbs); |
9 | 1527 |
771
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1528 selected = vflist_selection_get_list(vf); |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1529 |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1530 vflist_setup_iter_recursive(vf, store, NULL, vf->list, selected); |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1531 |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1532 if (selected && vflist_selection_count(vf, NULL) == 0) |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1533 { |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1534 /* all selected files disappeared */ |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1535 vflist_select_closest(vf, selected->data); |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1536 } |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1537 |
24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
nadvornik
parents:
770
diff
changeset
|
1538 filelist_free(selected); |
769 | 1539 |
9 | 1540 if (visible_row) |
1541 { | |
1542 if (gtk_tree_row_reference_valid(visible_row)) | |
1543 { | |
1544 tpath = gtk_tree_row_reference_get_path(visible_row); | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1545 gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(vf->listview), tpath, NULL, TRUE, 0.0, 0.0); |
9 | 1546 gtk_tree_path_free(tpath); |
1547 } | |
1548 gtk_tree_row_reference_free(visible_row); | |
1549 } | |
1550 | |
633 | 1551 vf_send_update(vf); |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1552 vflist_thumb_update(vf); |
9 | 1553 } |
1554 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1555 gint vflist_refresh(ViewFile *vf) |
9 | 1556 { |
1557 GList *old_list; | |
1558 gint ret = TRUE; | |
1559 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1560 old_list = vf->list; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1561 vf->list = NULL; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1562 |
762 | 1563 DEBUG_1("%s vflist_refresh: read dir", get_exec_time()); |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1564 if (vf->path) |
9 | 1565 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1566 ret = filelist_read(vf->path, &vf->list, NULL); |
9 | 1567 } |
762 | 1568 DEBUG_1("%s vflist_refresh: sort", get_exec_time()); |
9 | 1569 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1570 vf->list = filelist_sort(vf->list, vf->sort_method, vf->sort_ascend); |
762 | 1571 |
1572 DEBUG_1("%s vflist_refresh: populate view", get_exec_time()); | |
1573 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1574 vflist_populate_view(vf); |
9 | 1575 |
1576 filelist_free(old_list); | |
762 | 1577 DEBUG_1("%s vflist_refresh: done", get_exec_time()); |
9 | 1578 |
1579 return ret; | |
1580 } | |
1581 | |
772
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1582 static gint vflist_refresh_idle_cb(gpointer data) |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1583 { |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1584 ViewFile *vf = data; |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1585 |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1586 vflist_refresh(vf); |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1587 vf->refresh_idle_id = -1; |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1588 return FALSE; |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1589 } |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1590 |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1591 static void vflist_refresh_idle_cancel(ViewFile *vf) |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1592 { |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1593 if (vf->refresh_idle_id != -1) g_source_remove(vf->refresh_idle_id); |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1594 vf->refresh_idle_id = -1; |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1595 } |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1596 |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1597 |
9 | 1598 /* this overrides the low default of a GtkCellRenderer from 100 to CELL_HEIGHT_OVERRIDE, something sane for our purposes */ |
1599 | |
1600 #define CELL_HEIGHT_OVERRIDE 512 | |
1601 | |
1602 static void cell_renderer_height_override(GtkCellRenderer *renderer) | |
1603 { | |
1604 GParamSpec *spec; | |
1605 | |
1606 spec = g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(renderer)), "height"); | |
1607 if (spec && G_IS_PARAM_SPEC_INT(spec)) | |
1608 { | |
1609 GParamSpecInt *spec_int; | |
1610 | |
1611 spec_int = G_PARAM_SPEC_INT(spec); | |
1612 if (spec_int->maximum < CELL_HEIGHT_OVERRIDE) spec_int->maximum = CELL_HEIGHT_OVERRIDE; | |
1613 } | |
1614 } | |
1615 | |
1616 static GdkColor *vflist_listview_color_shifted(GtkWidget *widget) | |
1617 { | |
1618 static GdkColor color; | |
1619 static GtkWidget *done = NULL; | |
1620 | |
1621 if (done != widget) | |
1622 { | |
1623 GtkStyle *style; | |
1624 | |
1625 style = gtk_widget_get_style(widget); | |
1626 memcpy(&color, &style->base[GTK_STATE_NORMAL], sizeof(color)); | |
1627 shift_color(&color, -1, 0); | |
1628 done = widget; | |
1629 } | |
1630 | |
1631 return &color; | |
1632 } | |
1633 | |
1634 static void vflist_listview_color_cb(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, | |
1635 GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data) | |
1636 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1637 ViewFile *vf = data; |
9 | 1638 gboolean set; |
1639 | |
1640 gtk_tree_model_get(tree_model, iter, FILE_COLUMN_COLOR, &set, -1); | |
1641 g_object_set(G_OBJECT(cell), | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1642 "cell-background-gdk", vflist_listview_color_shifted(vf->listview), |
9 | 1643 "cell-background-set", set, NULL); |
1644 } | |
1645 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1646 static void vflist_listview_add_column(ViewFile *vf, gint n, const gchar *title, gint image, gint right_justify, gint expand) |
9 | 1647 { |
1648 GtkTreeViewColumn *column; | |
1649 GtkCellRenderer *renderer; | |
1650 | |
1651 column = gtk_tree_view_column_new(); | |
1652 gtk_tree_view_column_set_title(column, title); | |
1653 gtk_tree_view_column_set_min_width(column, 4); | |
1654 | |
1655 if (!image) | |
1656 { | |
149 | 1657 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY); |
9 | 1658 renderer = gtk_cell_renderer_text_new(); |
1659 if (right_justify) | |
1660 { | |
1661 g_object_set(G_OBJECT(renderer), "xalign", 1.0, NULL); | |
1662 } | |
1663 gtk_tree_view_column_pack_start(column, renderer, TRUE); | |
1664 gtk_tree_view_column_add_attribute(column, renderer, "text", n); | |
149 | 1665 if (expand) |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1666 gtk_tree_view_column_set_expand(column, TRUE); |
149 | 1667 } |
9 | 1668 else |
1669 { | |
1670 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED); | |
1671 renderer = gtk_cell_renderer_pixbuf_new(); | |
1672 cell_renderer_height_override(renderer); | |
1673 gtk_tree_view_column_pack_start(column, renderer, TRUE); | |
1674 gtk_tree_view_column_add_attribute(column, renderer, "pixbuf", n); | |
1675 } | |
1676 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1677 gtk_tree_view_column_set_cell_data_func(column, renderer, vflist_listview_color_cb, vf, NULL); |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1678 g_object_set_data(G_OBJECT(column), "column_store_idx", GUINT_TO_POINTER(n)); |
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1679 g_object_set_data(G_OBJECT(renderer), "column_store_idx", GUINT_TO_POINTER(n)); |
9 | 1680 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1681 gtk_tree_view_append_column(GTK_TREE_VIEW(vf->listview), column); |
9 | 1682 } |
1683 | |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1684 static void vflist_listview_mark_toggled(GtkCellRendererToggle *cell, gchar *path_str, GtkTreeStore *store) |
132 | 1685 { |
149 | 1686 GtkTreePath *path = gtk_tree_path_new_from_string(path_str); |
1687 GtkTreeIter iter; | |
1688 FileData *fd; | |
1689 gboolean mark; | |
1690 guint col_idx; | |
442 | 1691 |
149 | 1692 if (!path || !gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, path)) |
1693 return; | |
132 | 1694 |
513
985fdfebd89e
Remove whitespace between function name and first parenthesis for the sake of consistency. (pass 2)
zas_
parents:
512
diff
changeset
|
1695 col_idx = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cell), "column_store_idx")); |
442 | 1696 |
149 | 1697 g_assert(col_idx >= FILE_COLUMN_MARKS && col_idx <= FILE_COLUMN_MARKS_LAST); |
442 | 1698 |
149 | 1699 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, FILE_COLUMN_POINTER, &fd, col_idx, &mark, -1); |
150 | 1700 mark = !mark; |
149 | 1701 fd->marks[col_idx - FILE_COLUMN_MARKS] = mark; |
763
81f9e8dbb4bf
improved infrastructure for tracing changes, optimized vflist_populate_view
nadvornik
parents:
762
diff
changeset
|
1702 file_data_increment_version(fd); |
442 | 1703 |
149 | 1704 gtk_tree_store_set(store, &iter, col_idx, mark, -1); |
1705 gtk_tree_path_free(path); | |
132 | 1706 } |
1707 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1708 static void vflist_listview_add_column_toggle(ViewFile *vf, gint n, const gchar *title) |
132 | 1709 { |
149 | 1710 GtkTreeViewColumn *column; |
1711 GtkCellRenderer *renderer; | |
1712 GtkTreeStore *store; | |
1713 gint index; | |
442 | 1714 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1715 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview))); |
132 | 1716 |
149 | 1717 renderer = gtk_cell_renderer_toggle_new(); |
1718 column = gtk_tree_view_column_new_with_attributes(title, renderer, "active", n, NULL); | |
132 | 1719 |
149 | 1720 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED); |
512
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1721 g_object_set_data(G_OBJECT(column), "column_store_idx", GUINT_TO_POINTER(n)); |
f9bf33be53ff
Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents:
507
diff
changeset
|
1722 g_object_set_data(G_OBJECT(renderer), "column_store_idx", GUINT_TO_POINTER(n)); |
442 | 1723 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1724 index = gtk_tree_view_append_column(GTK_TREE_VIEW(vf->listview), column); |
149 | 1725 gtk_tree_view_column_set_fixed_width(column, 16); |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1726 gtk_tree_view_column_set_visible(column, vf->marks_enabled); |
132 | 1727 |
442 | 1728 |
149 | 1729 g_signal_connect(G_OBJECT(renderer), "toggled", G_CALLBACK(vflist_listview_mark_toggled), store); |
132 | 1730 } |
1731 | |
9 | 1732 /* |
1733 *----------------------------------------------------------------------------- | |
1734 * base | |
1735 *----------------------------------------------------------------------------- | |
1736 */ | |
1737 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1738 gint vflist_set_path(ViewFile *vf, const gchar *path) |
9 | 1739 { |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1740 GtkTreeStore *store; |
9 | 1741 |
1742 if (!path) return FALSE; | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1743 if (vf->path && strcmp(path, vf->path) == 0) return TRUE; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1744 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1745 g_free(vf->path); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1746 vf->path = g_strdup(path); |
9 | 1747 |
1748 /* force complete reload */ | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1749 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview))); |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1750 gtk_tree_store_clear(store); |
9 | 1751 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1752 filelist_free(vf->list); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1753 vf->list = NULL; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1754 |
633 | 1755 return vf_refresh(vf); |
9 | 1756 } |
1757 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1758 void vflist_destroy_cb(GtkWidget *widget, gpointer data) |
9 | 1759 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1760 ViewFile *vf = data; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1761 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1762 vflist_select_idle_cancel(vf); |
772
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1763 vflist_refresh_idle_cancel(vf); |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1764 vflist_thumb_stop(vf); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1765 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1766 filelist_free(vf->list); |
9 | 1767 } |
1768 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1769 ViewFile *vflist_new(ViewFile *vf, const gchar *path) |
9 | 1770 { |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1771 GtkTreeStore *store; |
9 | 1772 GtkTreeSelection *selection; |
1773 | |
149 | 1774 GType flist_types[FILE_COLUMN_COUNT]; |
1775 int i; | |
442 | 1776 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1777 vf->info = g_new0(ViewFileInfoList, 1); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1778 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1779 VFLIST_INFO(vf, click_fd) = NULL; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1780 VFLIST_INFO(vf, select_fd) = NULL; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1781 VFLIST_INFO(vf, thumbs_enabled) = FALSE; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1782 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1783 VFLIST_INFO(vf, select_idle_id) = -1; |
772
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1784 vf->refresh_idle_id = -1; |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1785 |
9 | 1786 |
139 | 1787 flist_types[FILE_COLUMN_POINTER] = G_TYPE_POINTER; |
763
81f9e8dbb4bf
improved infrastructure for tracing changes, optimized vflist_populate_view
nadvornik
parents:
762
diff
changeset
|
1788 flist_types[FILE_COLUMN_VERSION] = G_TYPE_INT; |
139 | 1789 flist_types[FILE_COLUMN_THUMB] = GDK_TYPE_PIXBUF; |
1790 flist_types[FILE_COLUMN_NAME] = G_TYPE_STRING; | |
1791 flist_types[FILE_COLUMN_SIDECARS] = G_TYPE_STRING; | |
1792 flist_types[FILE_COLUMN_SIZE] = G_TYPE_STRING; | |
1793 flist_types[FILE_COLUMN_DATE] = G_TYPE_STRING; | |
1794 flist_types[FILE_COLUMN_COLOR] = G_TYPE_BOOLEAN; | |
1795 for (i = FILE_COLUMN_MARKS; i < FILE_COLUMN_MARKS + FILEDATA_MARKS_SIZE; i++) | |
1796 flist_types[i] = G_TYPE_BOOLEAN; | |
132 | 1797 |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1798 store = gtk_tree_store_newv(FILE_COLUMN_COUNT, flist_types); |
442 | 1799 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1800 vf->listview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); |
9 | 1801 g_object_unref(store); |
1802 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1803 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
9 | 1804 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_MULTIPLE); |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1805 gtk_tree_selection_set_select_function(selection, vflist_select_cb, vf, NULL); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1806 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1807 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(vf->listview), FALSE); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1808 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(vf->listview), FALSE); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1809 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1810 vflist_listview_add_column(vf, FILE_COLUMN_THUMB, "", TRUE, FALSE, FALSE); |
9 | 1811 |
518 | 1812 for (i = 0; i < FILEDATA_MARKS_SIZE; i++) |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1813 vflist_listview_add_column_toggle(vf, i + FILE_COLUMN_MARKS, ""); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1814 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1815 vflist_listview_add_column(vf, FILE_COLUMN_NAME, _("Name"), FALSE, FALSE, FALSE); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1816 vflist_listview_add_column(vf, FILE_COLUMN_SIDECARS, _("SC"), FALSE, FALSE, FALSE); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1817 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1818 vflist_listview_add_column(vf, FILE_COLUMN_SIZE, _("Size"), FALSE, TRUE, FALSE); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1819 vflist_listview_add_column(vf, FILE_COLUMN_DATE, _("Date"), FALSE, TRUE, FALSE); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1820 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1821 return vf; |
9 | 1822 } |
1823 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1824 void vflist_thumb_set(ViewFile *vf, gint enable) |
9 | 1825 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1826 if (VFLIST_INFO(vf, thumbs_enabled) == enable) return; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1827 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1828 VFLIST_INFO(vf, thumbs_enabled) = enable; |
633 | 1829 if (vf->layout) vf_refresh(vf); |
9 | 1830 } |
1831 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1832 void vflist_marks_set(ViewFile *vf, gint enable) |
132 | 1833 { |
149 | 1834 GList *columns, *work; |
442 | 1835 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1836 if (vf->marks_enabled == enable) return; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1837 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1838 vf->marks_enabled = enable; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1839 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1840 columns = gtk_tree_view_get_columns(GTK_TREE_VIEW(vf->listview)); |
442 | 1841 |
149 | 1842 work = columns; |
1843 while (work) | |
1844 { | |
1845 GtkTreeViewColumn *column = work->data; | |
513
985fdfebd89e
Remove whitespace between function name and first parenthesis for the sake of consistency. (pass 2)
zas_
parents:
512
diff
changeset
|
1846 gint col_idx = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(column), "column_store_idx")); |
149 | 1847 work = work->next; |
442 | 1848 |
1849 if (col_idx <= FILE_COLUMN_MARKS_LAST && col_idx >= FILE_COLUMN_MARKS) | |
149 | 1850 gtk_tree_view_column_set_visible(column, enable); |
1851 } | |
442 | 1852 |
149 | 1853 g_list_free(columns); |
633 | 1854 //vf_refresh(vf); |
132 | 1855 } |
1856 | |
9 | 1857 /* |
1858 *----------------------------------------------------------------------------- | |
1859 * maintenance (for rename, move, remove) | |
1860 *----------------------------------------------------------------------------- | |
1861 */ | |
1862 | |
772
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1863 void vflist_maint(ViewFile *vf, FileData *fd) |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1864 { |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1865 gchar *source_base; |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1866 gchar *dest_base; |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1867 |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1868 if (vf->refresh_idle_id != -1) return; |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1869 |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1870 source_base = remove_level_from_path(fd->change->source); |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1871 dest_base = remove_level_from_path(fd->change->dest); |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1872 |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1873 if (strcmp(source_base, vf->path) == 0 || |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1874 strcmp(dest_base, vf->path) == 0 || |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1875 strcmp(fd->path, vf->path) == 0) |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1876 { |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1877 vf->refresh_idle_id = g_idle_add(vflist_refresh_idle_cb, vf); |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1878 } |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1879 g_free(source_base); |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1880 g_free(dest_base); |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1881 } |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1882 |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1883 /* the plan is to drop these functions and use vflist_maint directly */ |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1884 |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1885 gint vflist_maint_renamed(ViewFile *vf, FileData *fd) |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1886 { |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1887 vflist_maint(vf, fd); |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1888 return TRUE; |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1889 } |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1890 gint vflist_maint_removed(ViewFile *vf, FileData *fd, GList *ignore_list) |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1891 { |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1892 vflist_maint(vf, fd); |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1893 return TRUE; |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1894 } |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1895 gint vflist_maint_moved(ViewFile *vf, FileData *fd, GList *ignore_list) |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1896 { |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1897 vflist_maint(vf, fd); |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1898 return TRUE; |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1899 } |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1900 |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1901 |
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
1902 #if 0 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1903 static gint vflist_maint_find_closest(ViewFile *vf, gint row, gint count, GList *ignore_list) |
9 | 1904 { |
1905 GList *list = NULL; | |
1906 GList *work; | |
1907 gint rev = row - 1; | |
1908 row ++; | |
1909 | |
1910 work = ignore_list; | |
1911 while (work) | |
1912 { | |
633 | 1913 gint f = vf_index_by_path(vf, work->data); |
9 | 1914 if (f >= 0) list = g_list_prepend(list, GINT_TO_POINTER(f)); |
1915 work = work->next; | |
1916 } | |
1917 | |
1918 while (list) | |
1919 { | |
1920 gint c = TRUE; | |
1921 work = list; | |
1922 while (work && c) | |
1923 { | |
1924 gpointer p = work->data; | |
1925 work = work->next; | |
1926 if (row == GPOINTER_TO_INT(p)) | |
1927 { | |
1928 row++; | |
1929 c = FALSE; | |
1930 } | |
1931 if (rev == GPOINTER_TO_INT(p)) | |
1932 { | |
1933 rev--; | |
1934 c = FALSE; | |
1935 } | |
1936 if (!c) list = g_list_remove(list, p); | |
1937 } | |
1938 if (c && list) | |
1939 { | |
1940 g_list_free(list); | |
1941 list = NULL; | |
1942 } | |
1943 } | |
1944 if (row > count - 1) | |
1945 { | |
1946 if (rev < 0) | |
1947 return -1; | |
1948 else | |
1949 return rev; | |
1950 } | |
1951 else | |
1952 { | |
1953 return row; | |
1954 } | |
1955 } | |
1956 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1957 gint vflist_maint_renamed(ViewFile *vf, FileData *fd) |
9 | 1958 { |
1959 gint ret = FALSE; | |
1960 gchar *source_base; | |
1961 gchar *dest_base; | |
1962 | |
762 | 1963 DEBUG_1("%s vflist_maint_renamed: start", get_exec_time()); |
1964 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1965 if (g_list_index(vf->list, fd) < 0) return FALSE; |
9 | 1966 |
138 | 1967 source_base = remove_level_from_path(fd->change->source); |
1968 dest_base = remove_level_from_path(fd->change->dest); | |
9 | 1969 |
1970 | |
1971 if (strcmp(source_base, dest_base) == 0) | |
1972 { | |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1973 GtkTreeStore *store; |
9 | 1974 GtkTreeIter iter; |
1975 GtkTreeIter position; | |
1976 gint old_row; | |
1977 gint n; | |
1978 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1979 old_row = g_list_index(vf->list, fd); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1980 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1981 vf->list = g_list_remove(vf->list, fd); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1982 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1983 vf->list = filelist_insert_sort(vf->list, fd, vf->sort_method, vf->sort_ascend); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1984 n = g_list_index(vf->list, fd); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1985 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1986 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview))); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1987 if (vflist_find_row(vf, fd, &iter) >= 0 && |
9 | 1988 gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &position, NULL, n)) |
1989 { | |
1990 if (old_row >= n) | |
1991 { | |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1992 gtk_tree_store_move_before(store, &iter, &position); |
9 | 1993 } |
1994 else | |
1995 { | |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1996 gtk_tree_store_move_after(store, &iter, &position); |
9 | 1997 } |
1998 } | |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1999 gtk_tree_store_set(store, &iter, FILE_COLUMN_NAME, fd->name, -1); |
9 | 2000 |
2001 ret = TRUE; | |
2002 } | |
2003 else | |
2004 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2005 ret = vflist_maint_removed(vf, fd, NULL); |
9 | 2006 } |
2007 | |
2008 g_free(source_base); | |
2009 g_free(dest_base); | |
2010 | |
762 | 2011 DEBUG_1("%s vflist_maint_renamed: done", get_exec_time()); |
2012 | |
9 | 2013 return ret; |
2014 } | |
2015 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2016 gint vflist_maint_removed(ViewFile *vf, FileData *fd, GList *ignore_list) |
9 | 2017 { |
2018 GtkTreeIter iter; | |
2019 GList *list; | |
2020 gint row; | |
2021 gint new_row = -1; | |
2022 | |
762 | 2023 DEBUG_1("%s vflist_maint_removed: start", get_exec_time()); |
2024 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2025 row = g_list_index(vf->list, fd); |
9 | 2026 if (row < 0) return FALSE; |
2027 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2028 if (vflist_index_is_selected(vf, row) && |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2029 layout_image_get_collection(vf->layout, NULL) == NULL) |
9 | 2030 { |
2031 gint n; | |
2032 | |
633 | 2033 n = vf_count(vf, NULL); |
9 | 2034 if (ignore_list) |
2035 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2036 new_row = vflist_maint_find_closest(vf, row, n, ignore_list); |
506
fc9c8a3e1a8b
Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents:
497
diff
changeset
|
2037 DEBUG_1("row = %d, closest is %d", row, new_row); |
9 | 2038 } |
2039 else | |
2040 { | |
2041 if (row + 1 < n) | |
2042 { | |
2043 new_row = row + 1; | |
2044 } | |
2045 else if (row > 0) | |
2046 { | |
2047 new_row = row - 1; | |
2048 } | |
2049 } | |
633 | 2050 vf_select_none(vf); |
9 | 2051 if (new_row >= 0) |
2052 { | |
633 | 2053 fd = vf_index_get_data(vf, new_row); |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2054 if (vflist_find_row(vf, fd, &iter) >= 0) |
9 | 2055 { |
2056 GtkTreeSelection *selection; | |
2057 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2058 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
9 | 2059 gtk_tree_selection_select_iter(selection, &iter); |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2060 vflist_move_cursor(vf, &iter); |
9 | 2061 } |
2062 } | |
2063 } | |
2064 | |
633 | 2065 fd = vf_index_get_data(vf, row); |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2066 if (vflist_find_row(vf, fd, &iter) >= 0) |
9 | 2067 { |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
2068 GtkTreeStore *store; |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2069 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview))); |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
2070 gtk_tree_store_remove(store, &iter); |
9 | 2071 } |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2072 list = g_list_nth(vf->list, row); |
9 | 2073 fd = list->data; |
2074 | |
2075 /* thumbnail loader check */ | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2076 if (fd == vf->thumbs_filedata) vf->thumbs_filedata = NULL; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2077 if (vf->thumbs_count > 0) vf->thumbs_count--; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2078 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2079 vf->list = g_list_remove(vf->list, fd); |
138 | 2080 file_data_unref(fd); |
9 | 2081 |
633 | 2082 vf_send_update(vf); |
9 | 2083 |
762 | 2084 DEBUG_1("%s vflist_maint_removed: done", get_exec_time()); |
2085 | |
9 | 2086 return TRUE; |
2087 } | |
2088 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2089 gint vflist_maint_moved(ViewFile *vf, FileData *fd, GList *ignore_list) |
9 | 2090 { |
2091 gint ret = FALSE; | |
2092 gchar *buf; | |
2093 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2094 if (!fd->change->source || !vf->path) return FALSE; |
9 | 2095 |
138 | 2096 buf = remove_level_from_path(fd->change->source); |
9 | 2097 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2098 if (strcmp(buf, vf->path) == 0) |
9 | 2099 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
2100 ret = vflist_maint_removed(vf, fd, ignore_list); |
9 | 2101 } |
2102 | |
2103 g_free(buf); | |
2104 | |
2105 return ret; | |
2106 } | |
772
f53c2bb5b1b1
replaced vflist_maint functions by vflist_refresh - it allows to follow
nadvornik
parents:
771
diff
changeset
|
2107 #endif |