Mercurial > geeqie.yaz
annotate src/view_file_list.c @ 769:110462fdf31b
simplified vflist_populate_view
author | nadvornik |
---|---|
date | Fri, 30 May 2008 19:53:52 +0000 |
parents | 81f9e8dbb4bf |
children | 842c15317bdf |
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 |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
709 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
710 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
|
711 { |
167 | 712 int i; |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
713 gchar *size; |
167 | 714 gchar *sidecars = NULL; |
715 | |
716 if (fd->sidecar_files) | |
596 | 717 sidecars = file_data_sc_list_to_string(fd); |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
718 size = text_from_size(fd->size); |
442 | 719 |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
720 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
|
721 FILE_COLUMN_VERSION, fd->version, |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
722 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
|
723 FILE_COLUMN_NAME, fd->name, |
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
724 FILE_COLUMN_SIDECARS, sidecars, |
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
725 FILE_COLUMN_SIZE, size, |
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
726 FILE_COLUMN_DATE, text_from_time(fd->date), |
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
727 FILE_COLUMN_COLOR, FALSE, -1); |
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
728 for (i = 0; i < FILEDATA_MARKS_SIZE; i++) |
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
729 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
|
730 |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
731 g_free(size); |
167 | 732 if (sidecars) |
733 g_free(sidecars); | |
734 } | |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
735 |
769 | 736 static void vflist_setup_iter_recursive(ViewFile *vf, GtkTreeStore *store, GtkTreeIter *parent_iter, GList *list, GList *selection) |
167 | 737 { |
738 GList *work; | |
769 | 739 GtkTreeIter iter; |
167 | 740 gint valid; |
741 | |
769 | 742 valid = gtk_tree_model_iter_children(GTK_TREE_MODEL(store), &iter, parent_iter); |
167 | 743 |
769 | 744 work = list; |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
745 while (work) |
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
746 { |
167 | 747 gint match; |
769 | 748 FileData *fd = work->data; |
167 | 749 gint done = FALSE; |
750 | |
751 while (!done) | |
752 { | |
769 | 753 FileData *old_fd = NULL; |
754 gint old_version = 0; | |
442 | 755 |
167 | 756 if (valid) |
757 { | |
769 | 758 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, |
759 FILE_COLUMN_POINTER, &old_fd, | |
760 FILE_COLUMN_VERSION, &old_version, | |
761 -1); | |
442 | 762 |
769 | 763 if (fd == old_fd) |
167 | 764 { |
765 match = 0; | |
766 } | |
767 else | |
768 { | |
769 | 769 if (parent_iter) |
770 match = filelist_sort_compare_filedata_full(fd, old_fd, SORT_NAME, TRUE); /* always sort sidecars by name */ | |
771 else | |
772 match = filelist_sort_compare_filedata_full(fd, old_fd, vf->sort_method, vf->sort_ascend); | |
773 | |
774 if (match == 0) g_warning("multiple fd for the same path"); | |
167 | 775 } |
769 | 776 |
167 | 777 } |
778 else | |
779 { | |
780 match = -1; | |
781 } | |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
782 |
167 | 783 if (match < 0) |
784 { | |
785 GtkTreeIter new; | |
442 | 786 |
167 | 787 if (valid) |
788 { | |
769 | 789 gtk_tree_store_insert_before(store, &new, parent_iter, &iter); |
167 | 790 } |
791 else | |
792 { | |
769 | 793 gtk_tree_store_append(store, &new, parent_iter); |
167 | 794 } |
442 | 795 |
769 | 796 vflist_setup_iter(vf, store, &new, fd); |
797 vflist_setup_iter_recursive(vf, store, &new, fd->sidecar_files, selection); | |
167 | 798 |
799 done = TRUE; | |
800 } | |
801 else if (match > 0) | |
802 { | |
769 | 803 valid = gtk_tree_store_remove(store, &iter); |
167 | 804 } |
805 else | |
806 { | |
769 | 807 if (fd->version != old_version) |
808 { | |
809 vflist_setup_iter(vf, store, &iter, fd); | |
810 vflist_setup_iter_recursive(vf, store, &iter, fd->sidecar_files, selection); | |
811 } | |
167 | 812 |
769 | 813 if (valid) valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter); |
167 | 814 |
815 done = TRUE; | |
816 } | |
817 } | |
818 work = work->next; | |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
819 } |
167 | 820 |
821 while (valid) | |
822 { | |
769 | 823 valid = gtk_tree_store_remove(store, &iter); |
167 | 824 } |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
825 } |
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
826 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
827 void vflist_sort_set(ViewFile *vf, SortType type, gint ascend) |
9 | 828 { |
168
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
829 gint i; |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
830 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
|
831 gint *new_order; |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
832 GtkTreeStore *store; |
9 | 833 GList *work; |
834 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
835 if (vf->sort_method == type && vf->sort_ascend == ascend) return; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
836 if (!vf->list) return; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
837 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
838 work = vf->list; |
168
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
839 i = 0; |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
840 while (work) |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
841 { |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
842 FileData *fd = work->data; |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
843 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
|
844 i++; |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
845 work = work->next; |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
846 } |
9 | 847 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
848 vf->sort_method = type; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
849 vf->sort_ascend = ascend; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
850 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
851 vf->list = filelist_sort(vf->list, vf->sort_method, vf->sort_ascend); |
442 | 852 |
168
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
853 new_order = g_malloc(i * sizeof(gint)); |
442 | 854 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
855 work = vf->list; |
168
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
856 i = 0; |
93
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
857 while (work) |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
858 { |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
859 FileData *fd = work->data; |
168
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
860 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
|
861 i++; |
93
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
862 work = work->next; |
f1c8f8632e23
Thu Nov 2 14:38:54 2006 John Ellis <johne@verizon.net>
gqview
parents:
64
diff
changeset
|
863 } |
442 | 864 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
865 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
|
866 gtk_tree_store_reorder(store, NULL, new_order); |
442 | 867 |
168
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
868 g_free(new_order); |
a55ada12322a
fixed vflist_find_row and vflist_sort_set to work correctly with sidecar
nadvornik
parents:
167
diff
changeset
|
869 g_hash_table_destroy(fd_idx_hash); |
9 | 870 } |
871 | |
872 /* | |
873 *----------------------------------------------------------------------------- | |
874 * thumb updates | |
875 *----------------------------------------------------------------------------- | |
876 */ | |
877 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
878 static gint vflist_thumb_next(ViewFile *vf); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
879 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
880 static void vflist_thumb_status(ViewFile *vf, gdouble val, const gchar *text) |
9 | 881 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
882 if (vf->func_thumb_status) |
9 | 883 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
884 vf->func_thumb_status(vf, val, text, vf->data_thumb_status); |
9 | 885 } |
886 } | |
887 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
888 static void vflist_thumb_cleanup(ViewFile *vf) |
9 | 889 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
890 vflist_thumb_status(vf, 0.0, NULL); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
891 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
892 vf->thumbs_count = 0; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
893 vf->thumbs_running = FALSE; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
894 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
895 thumb_loader_free(vf->thumbs_loader); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
896 vf->thumbs_loader = NULL; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
897 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
898 vf->thumbs_filedata = NULL; |
9 | 899 } |
900 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
901 static void vflist_thumb_stop(ViewFile *vf) |
9 | 902 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
903 if (vf->thumbs_running) vflist_thumb_cleanup(vf); |
9 | 904 } |
905 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
906 static void vflist_thumb_do(ViewFile *vf, ThumbLoader *tl, FileData *fd) |
9 | 907 { |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
908 GtkTreeStore *store; |
9 | 909 GtkTreeIter iter; |
910 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
911 if (!fd || vflist_find_row(vf, fd, &iter) < 0) return; |
9 | 912 |
913 if (fd->pixbuf) g_object_unref(fd->pixbuf); | |
914 fd->pixbuf = thumb_loader_get_pixbuf(tl, TRUE); | |
915 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
916 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
|
917 gtk_tree_store_set(store, &iter, FILE_COLUMN_THUMB, fd->pixbuf, -1); |
9 | 918 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
919 vflist_thumb_status(vf, (gdouble)(vf->thumbs_count) / vflist_sidecar_list_count(vf->list), _("Loading thumbs...")); |
9 | 920 } |
921 | |
922 static void vflist_thumb_error_cb(ThumbLoader *tl, gpointer data) | |
923 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
924 ViewFile *vf = data; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
925 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
926 if (vf->thumbs_filedata && vf->thumbs_loader == tl) |
9 | 927 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
928 vflist_thumb_do(vf, tl, vf->thumbs_filedata); |
9 | 929 } |
930 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
931 while (vflist_thumb_next(vf)); |
9 | 932 } |
933 | |
934 static void vflist_thumb_done_cb(ThumbLoader *tl, gpointer data) | |
935 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
936 ViewFile *vf = data; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
937 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
938 if (vf->thumbs_filedata && vf->thumbs_loader == tl) |
9 | 939 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
940 vflist_thumb_do(vf, tl, vf->thumbs_filedata); |
9 | 941 } |
942 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
943 while (vflist_thumb_next(vf)); |
9 | 944 } |
945 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
946 static gint vflist_thumb_next(ViewFile *vf) |
9 | 947 { |
948 GtkTreePath *tpath; | |
949 FileData *fd = NULL; | |
950 | |
951 /* first check the visible files */ | |
952 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
953 if (GTK_WIDGET_REALIZED(vf->listview) && |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
954 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vf->listview), 0, 0, &tpath, NULL, NULL, NULL)) |
9 | 955 { |
956 GtkTreeModel *store; | |
957 GtkTreeIter iter; | |
958 gint valid = TRUE; | |
959 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
960 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
9 | 961 gtk_tree_model_get_iter(store, &iter, tpath); |
962 gtk_tree_path_free(tpath); | |
963 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
964 while (!fd && valid && tree_view_row_get_visibility(GTK_TREE_VIEW(vf->listview), &iter, FALSE) == 0) |
9 | 965 { |
966 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1); | |
967 if (fd->pixbuf) fd = NULL; | |
968 | |
969 valid = gtk_tree_model_iter_next(store, &iter); | |
970 } | |
971 } | |
972 | |
973 /* then find first undone */ | |
974 | |
975 if (!fd) | |
976 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
977 GList *work = vf->list; |
9 | 978 while (work && !fd) |
979 { | |
980 FileData *fd_p = work->data; | |
442 | 981 if (!fd_p->pixbuf) |
169 | 982 fd = fd_p; |
983 else | |
984 { | |
985 GList *work2 = fd_p->sidecar_files; | |
442 | 986 |
169 | 987 while (work2 && !fd) |
988 { | |
442 | 989 fd_p = work2->data; |
169 | 990 if (!fd_p->pixbuf) fd = fd_p; |
991 work2 = work2->next; | |
992 } | |
993 } | |
9 | 994 work = work->next; |
995 } | |
996 } | |
997 | |
998 if (!fd) | |
999 { | |
1000 /* done */ | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1001 vflist_thumb_cleanup(vf); |
9 | 1002 return FALSE; |
1003 } | |
1004 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1005 vf->thumbs_count++; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1006 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1007 vf->thumbs_filedata = fd; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1008 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1009 thumb_loader_free(vf->thumbs_loader); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1010 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1011 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
|
1012 thumb_loader_set_callbacks(vf->thumbs_loader, |
9 | 1013 vflist_thumb_done_cb, |
1014 vflist_thumb_error_cb, | |
1015 NULL, | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1016 vf); |
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 if (!thumb_loader_start(vf->thumbs_loader, fd->path)) |
9 | 1019 { |
1020 /* set icon to unknown, continue */ | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1021 DEBUG_1("thumb loader start failed %s", vf->thumbs_loader->path); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1022 vflist_thumb_do(vf, vf->thumbs_loader, fd); |
9 | 1023 |
1024 return TRUE; | |
1025 } | |
1026 | |
1027 return FALSE; | |
1028 } | |
1029 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1030 static void vflist_thumb_update(ViewFile *vf) |
9 | 1031 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1032 vflist_thumb_stop(vf); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1033 if (!VFLIST_INFO(vf, thumbs_enabled)) return; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1034 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1035 vflist_thumb_status(vf, 0.0, _("Loading thumbs...")); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1036 vf->thumbs_running = TRUE; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1037 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1038 while (vflist_thumb_next(vf)); |
9 | 1039 } |
1040 | |
1041 /* | |
1042 *----------------------------------------------------------------------------- | |
1043 * row stuff | |
1044 *----------------------------------------------------------------------------- | |
1045 */ | |
1046 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1047 FileData *vflist_index_get_data(ViewFile *vf, gint row) |
9 | 1048 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1049 return g_list_nth_data(vf->list, row); |
9 | 1050 } |
1051 | |
664
db373fb1b9d8
Merge vflist_row_by_path() into vflist_index_by_path().
zas_
parents:
659
diff
changeset
|
1052 gint vflist_index_by_path(ViewFile *vf, const gchar *path) |
9 | 1053 { |
1054 gint p = 0; | |
1055 GList *work; | |
1056 | |
1057 if (!path) return -1; | |
1058 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1059 work = vf->list; |
9 | 1060 while (work) |
1061 { | |
664
db373fb1b9d8
Merge vflist_row_by_path() into vflist_index_by_path().
zas_
parents:
659
diff
changeset
|
1062 FileData *fd = work->data; |
db373fb1b9d8
Merge vflist_row_by_path() into vflist_index_by_path().
zas_
parents:
659
diff
changeset
|
1063 if (strcmp(path, fd->path) == 0) return p; |
db373fb1b9d8
Merge vflist_row_by_path() into vflist_index_by_path().
zas_
parents:
659
diff
changeset
|
1064 |
9 | 1065 work = work->next; |
1066 p++; | |
1067 } | |
1068 | |
1069 return -1; | |
1070 } | |
1071 | |
736 | 1072 guint vflist_count(ViewFile *vf, gint64 *bytes) |
9 | 1073 { |
1074 if (bytes) | |
1075 { | |
1076 gint64 b = 0; | |
1077 GList *work; | |
1078 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1079 work = vf->list; |
9 | 1080 while (work) |
1081 { | |
1082 FileData *fd = work->data; | |
1083 work = work->next; | |
1084 b += fd->size; | |
1085 } | |
1086 | |
1087 *bytes = b; | |
1088 } | |
1089 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1090 return g_list_length(vf->list); |
9 | 1091 } |
1092 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1093 GList *vflist_get_list(ViewFile *vf) |
9 | 1094 { |
1095 GList *list = NULL; | |
1096 GList *work; | |
1097 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1098 work = vf->list; |
9 | 1099 while (work) |
1100 { | |
1101 FileData *fd = work->data; | |
1102 work = work->next; | |
1103 | |
138 | 1104 list = g_list_prepend(list, file_data_ref(fd)); |
9 | 1105 } |
1106 | |
1107 return g_list_reverse(list); | |
1108 } | |
1109 | |
1110 /* | |
1111 *----------------------------------------------------------------------------- | |
1112 * selections | |
1113 *----------------------------------------------------------------------------- | |
1114 */ | |
1115 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1116 static gint vflist_row_is_selected(ViewFile *vf, FileData *fd) |
9 | 1117 { |
1118 GtkTreeModel *store; | |
1119 GtkTreeSelection *selection; | |
1120 GList *slist; | |
1121 GList *work; | |
1122 gint found = FALSE; | |
1123 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1124 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
9 | 1125 slist = gtk_tree_selection_get_selected_rows(selection, &store); |
1126 work = slist; | |
1127 while (!found && work) | |
1128 { | |
1129 GtkTreePath *tpath = work->data; | |
1130 FileData *fd_n; | |
1131 GtkTreeIter iter; | |
1132 | |
1133 gtk_tree_model_get_iter(store, &iter, tpath); | |
1134 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd_n, -1); | |
1135 if (fd_n == fd) found = TRUE; | |
1136 work = work->next; | |
1137 } | |
1138 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL); | |
1139 g_list_free(slist); | |
1140 | |
1141 return found; | |
1142 } | |
1143 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1144 gint vflist_index_is_selected(ViewFile *vf, gint row) |
9 | 1145 { |
1146 FileData *fd; | |
1147 | |
633 | 1148 fd = vf_index_get_data(vf, row); |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1149 return vflist_row_is_selected(vf, fd); |
9 | 1150 } |
1151 | |
736 | 1152 guint vflist_selection_count(ViewFile *vf, gint64 *bytes) |
9 | 1153 { |
1154 GtkTreeModel *store; | |
1155 GtkTreeSelection *selection; | |
1156 GList *slist; | |
736 | 1157 guint count; |
9 | 1158 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1159 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
9 | 1160 slist = gtk_tree_selection_get_selected_rows(selection, &store); |
1161 | |
1162 if (bytes) | |
1163 { | |
1164 gint64 b = 0; | |
1165 GList *work; | |
1166 | |
1167 work = slist; | |
1168 while (work) | |
1169 { | |
1170 GtkTreePath *tpath = work->data; | |
1171 GtkTreeIter iter; | |
1172 FileData *fd; | |
1173 | |
1174 gtk_tree_model_get_iter(store, &iter, tpath); | |
1175 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1); | |
1176 b += fd->size; | |
1177 | |
1178 work = work->next; | |
1179 } | |
1180 | |
1181 *bytes = b; | |
1182 } | |
1183 | |
1184 count = g_list_length(slist); | |
1185 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL); | |
1186 g_list_free(slist); | |
1187 | |
1188 return count; | |
1189 } | |
1190 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1191 GList *vflist_selection_get_list(ViewFile *vf) |
9 | 1192 { |
1193 GtkTreeModel *store; | |
1194 GtkTreeSelection *selection; | |
1195 GList *slist; | |
1196 GList *list = NULL; | |
1197 GList *work; | |
1198 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1199 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
9 | 1200 slist = gtk_tree_selection_get_selected_rows(selection, &store); |
1201 work = slist; | |
1202 while (work) | |
1203 { | |
1204 GtkTreePath *tpath = work->data; | |
1205 FileData *fd; | |
1206 GtkTreeIter iter; | |
1207 | |
1208 gtk_tree_model_get_iter(store, &iter, tpath); | |
1209 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1); | |
1210 | |
138 | 1211 list = g_list_prepend(list, file_data_ref(fd)); |
9 | 1212 |
1213 work = work->next; | |
1214 } | |
1215 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL); | |
1216 g_list_free(slist); | |
1217 | |
1218 return g_list_reverse(list); | |
1219 } | |
1220 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1221 GList *vflist_selection_get_list_by_index(ViewFile *vf) |
9 | 1222 { |
1223 GtkTreeModel *store; | |
1224 GtkTreeSelection *selection; | |
1225 GList *slist; | |
1226 GList *list = NULL; | |
1227 GList *work; | |
1228 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1229 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
9 | 1230 slist = gtk_tree_selection_get_selected_rows(selection, &store); |
1231 work = slist; | |
1232 while (work) | |
1233 { | |
1234 GtkTreePath *tpath = work->data; | |
1235 FileData *fd; | |
1236 GtkTreeIter iter; | |
1237 | |
1238 gtk_tree_model_get_iter(store, &iter, tpath); | |
1239 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1); | |
1240 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1241 list = g_list_prepend(list, GINT_TO_POINTER(g_list_index(vf->list, fd))); |
9 | 1242 |
1243 work = work->next; | |
1244 } | |
1245 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL); | |
1246 g_list_free(slist); | |
1247 | |
1248 return g_list_reverse(list); | |
1249 } | |
1250 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1251 void vflist_select_all(ViewFile *vf) |
9 | 1252 { |
1253 GtkTreeSelection *selection; | |
1254 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1255 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
9 | 1256 gtk_tree_selection_select_all(selection); |
1257 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1258 VFLIST_INFO(vf, select_fd) = NULL; |
9 | 1259 } |
1260 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1261 void vflist_select_none(ViewFile *vf) |
9 | 1262 { |
1263 GtkTreeSelection *selection; | |
1264 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1265 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
9 | 1266 gtk_tree_selection_unselect_all(selection); |
1267 } | |
1268 | |
601 | 1269 static gboolean tree_model_iter_prev(GtkTreeModel *store, GtkTreeIter *iter) |
1270 { | |
1271 GtkTreePath *tpath; | |
1272 gboolean result; | |
1273 | |
1274 tpath = gtk_tree_model_get_path(store, iter); | |
1275 result = gtk_tree_path_prev(tpath); | |
1276 if (result) | |
1277 gtk_tree_model_get_iter(store, iter, tpath); | |
1278 | |
1279 gtk_tree_path_free(tpath); | |
1280 | |
1281 return result; | |
1282 } | |
1283 | |
1284 static gboolean tree_model_get_iter_last(GtkTreeModel *store, GtkTreeIter *iter) | |
1285 { | |
1286 if (!gtk_tree_model_get_iter_first(store, iter)) | |
1287 return FALSE; | |
1288 | |
1289 while (TRUE) | |
1290 { | |
1291 GtkTreeIter next = *iter; | |
1292 | |
1293 if (gtk_tree_model_iter_next(store, &next)) | |
1294 *iter = next; | |
1295 else | |
1296 break; | |
1297 } | |
1298 | |
1299 return TRUE; | |
1300 } | |
1301 | |
1302 void vflist_select_invert(ViewFile *vf) | |
1303 { | |
1304 GtkTreeIter iter; | |
1305 GtkTreeSelection *selection; | |
1306 GtkTreeModel *store; | |
1307 gboolean valid; | |
1308 | |
1309 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); | |
1310 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); | |
1311 | |
1312 /* Backward iteration prevents scrolling to the end of the list, | |
1313 * it scrolls to the first selected row instead. */ | |
1314 valid = tree_model_get_iter_last(store, &iter); | |
1315 | |
1316 while (valid) | |
1317 { | |
1318 gint selected = gtk_tree_selection_iter_is_selected(selection, &iter); | |
1319 | |
1320 if (selected) | |
1321 gtk_tree_selection_unselect_iter(selection, &iter); | |
1322 else | |
1323 gtk_tree_selection_select_iter(selection, &iter); | |
1324 | |
1325 valid = tree_model_iter_prev(store, &iter); | |
1326 } | |
1327 } | |
1328 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1329 void vflist_select_by_fd(ViewFile *vf, FileData *fd) |
138 | 1330 { |
9 | 1331 GtkTreeIter iter; |
1332 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1333 if (vflist_find_row(vf, fd, &iter) < 0) return; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1334 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1335 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
|
1336 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1337 if (!vflist_row_is_selected(vf, fd)) |
9 | 1338 { |
1339 GtkTreeSelection *selection; | |
1340 GtkTreeModel *store; | |
1341 GtkTreePath *tpath; | |
1342 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1343 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
9 | 1344 gtk_tree_selection_unselect_all(selection); |
1345 gtk_tree_selection_select_iter(selection, &iter); | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1346 vflist_move_cursor(vf, &iter); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1347 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1348 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
9 | 1349 tpath = gtk_tree_model_get_path(store, &iter); |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1350 gtk_tree_view_set_cursor(GTK_TREE_VIEW(vf->listview), tpath, NULL, FALSE); |
9 | 1351 gtk_tree_path_free(tpath); |
1352 } | |
1353 } | |
1354 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1355 void vflist_mark_to_selection(ViewFile *vf, gint mark, MarkToSelectionMode mode) |
150 | 1356 { |
1357 GtkTreeModel *store; | |
1358 GtkTreeIter iter; | |
1359 GtkTreeSelection *selection; | |
1360 gint valid; | |
654
6dcfac4b356f
Get rid of vflist_pop_menu() col_idx parameter, use new Viewfile field
zas_
parents:
637
diff
changeset
|
1361 gint n = mark - 1; |
442 | 1362 |
654
6dcfac4b356f
Get rid of vflist_pop_menu() col_idx parameter, use new Viewfile field
zas_
parents:
637
diff
changeset
|
1363 g_assert(mark >= 1 && mark <= FILEDATA_MARKS_SIZE); |
150 | 1364 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1365 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1366 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
442 | 1367 |
150 | 1368 valid = gtk_tree_model_get_iter_first(store, &iter); |
1369 while (valid) | |
1370 { | |
1371 FileData *fd; | |
161 | 1372 gboolean mark_val, selected; |
150 | 1373 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, FILE_COLUMN_POINTER, &fd, -1); |
442 | 1374 |
654
6dcfac4b356f
Get rid of vflist_pop_menu() col_idx parameter, use new Viewfile field
zas_
parents:
637
diff
changeset
|
1375 mark_val = fd->marks[n]; |
161 | 1376 selected = gtk_tree_selection_iter_is_selected(selection, &iter); |
442 | 1377 |
1378 switch (mode) | |
161 | 1379 { |
1380 case MTS_MODE_SET: selected = mark_val; | |
1381 break; | |
1382 case MTS_MODE_OR: selected = mark_val | selected; | |
1383 break; | |
1384 case MTS_MODE_AND: selected = mark_val & selected; | |
1385 break; | |
1386 case MTS_MODE_MINUS: selected = !mark_val & selected; | |
1387 break; | |
1388 } | |
442 | 1389 |
161 | 1390 if (selected) |
150 | 1391 gtk_tree_selection_select_iter(selection, &iter); |
161 | 1392 else |
1393 gtk_tree_selection_unselect_iter(selection, &iter); | |
150 | 1394 |
1395 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter); | |
1396 } | |
1397 } | |
1398 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1399 void vflist_selection_to_mark(ViewFile *vf, gint mark, SelectionToMarkMode mode) |
150 | 1400 { |
1401 GtkTreeModel *store; | |
1402 GtkTreeSelection *selection; | |
1403 GList *slist; | |
1404 GList *work; | |
654
6dcfac4b356f
Get rid of vflist_pop_menu() col_idx parameter, use new Viewfile field
zas_
parents:
637
diff
changeset
|
1405 gint n = mark - 1; |
150 | 1406 |
654
6dcfac4b356f
Get rid of vflist_pop_menu() col_idx parameter, use new Viewfile field
zas_
parents:
637
diff
changeset
|
1407 g_assert(mark >= 1 && mark <= FILEDATA_MARKS_SIZE); |
150 | 1408 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1409 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
150 | 1410 slist = gtk_tree_selection_get_selected_rows(selection, &store); |
1411 work = slist; | |
1412 while (work) | |
1413 { | |
1414 GtkTreePath *tpath = work->data; | |
1415 FileData *fd; | |
1416 GtkTreeIter iter; | |
1417 | |
1418 gtk_tree_model_get_iter(store, &iter, tpath); | |
1419 gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1); | |
442 | 1420 |
161 | 1421 switch (mode) |
1422 { | |
654
6dcfac4b356f
Get rid of vflist_pop_menu() col_idx parameter, use new Viewfile field
zas_
parents:
637
diff
changeset
|
1423 case STM_MODE_SET: fd->marks[n] = 1; |
161 | 1424 break; |
654
6dcfac4b356f
Get rid of vflist_pop_menu() col_idx parameter, use new Viewfile field
zas_
parents:
637
diff
changeset
|
1425 case STM_MODE_RESET: fd->marks[n] = 0; |
161 | 1426 break; |
654
6dcfac4b356f
Get rid of vflist_pop_menu() col_idx parameter, use new Viewfile field
zas_
parents:
637
diff
changeset
|
1427 case STM_MODE_TOGGLE: fd->marks[n] = !fd->marks[n]; |
161 | 1428 break; |
1429 } | |
763
81f9e8dbb4bf
improved infrastructure for tracing changes, optimized vflist_populate_view
nadvornik
parents:
762
diff
changeset
|
1430 |
81f9e8dbb4bf
improved infrastructure for tracing changes, optimized vflist_populate_view
nadvornik
parents:
762
diff
changeset
|
1431 file_data_increment_version(fd); |
442 | 1432 |
654
6dcfac4b356f
Get rid of vflist_pop_menu() col_idx parameter, use new Viewfile field
zas_
parents:
637
diff
changeset
|
1433 gtk_tree_store_set(GTK_TREE_STORE(store), &iter, FILE_COLUMN_MARKS + n, fd->marks[n], -1); |
150 | 1434 |
1435 work = work->next; | |
1436 } | |
1437 g_list_foreach(slist, (GFunc)gtk_tree_path_free, NULL); | |
1438 g_list_free(slist); | |
1439 } | |
1440 | |
9 | 1441 /* |
1442 *----------------------------------------------------------------------------- | |
1443 * core (population) | |
1444 *----------------------------------------------------------------------------- | |
1445 */ | |
1446 | |
1447 static void vflist_listview_set_height(GtkWidget *listview, gint thumb) | |
1448 { | |
1449 GtkTreeViewColumn *column; | |
1450 GtkCellRenderer *cell; | |
1451 GList *list; | |
1452 | |
1453 column = gtk_tree_view_get_column(GTK_TREE_VIEW(listview), FILE_COLUMN_THUMB - 1); | |
1454 if (!column) return; | |
1455 | |
333 | 1456 gtk_tree_view_column_set_fixed_width(column, ((thumb) ? options->thumbnails.max_width : 4) + 10); |
9 | 1457 |
1458 list = gtk_tree_view_column_get_cell_renderers(column); | |
1459 if (!list) return; | |
1460 cell = list->data; | |
1461 g_list_free(list); | |
1462 | |
333 | 1463 g_object_set(G_OBJECT(cell), "height", (thumb) ? options->thumbnails.max_height : -1, NULL); |
9 | 1464 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(listview)); |
1465 } | |
1466 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1467 static void vflist_populate_view(ViewFile *vf) |
9 | 1468 { |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1469 GtkTreeStore *store; |
9 | 1470 gint thumbs; |
1471 GtkTreeRowReference *visible_row = NULL; | |
1472 GtkTreePath *tpath; | |
1473 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1474 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
|
1475 thumbs = VFLIST_INFO(vf, thumbs_enabled); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1476 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1477 vflist_thumb_stop(vf); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1478 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1479 if (!vf->list) |
9 | 1480 { |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1481 gtk_tree_store_clear(store); |
633 | 1482 vf_send_update(vf); |
9 | 1483 return; |
1484 } | |
1485 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1486 if (GTK_WIDGET_REALIZED(vf->listview) && |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1487 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vf->listview), 0, 0, &tpath, NULL, NULL, NULL)) |
9 | 1488 { |
1489 visible_row = gtk_tree_row_reference_new(GTK_TREE_MODEL(store), tpath); | |
1490 gtk_tree_path_free(tpath); | |
1491 } | |
1492 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1493 vflist_listview_set_height(vf->listview, thumbs); |
9 | 1494 |
769 | 1495 vflist_setup_iter_recursive(vf, store, NULL, vf->list, NULL); |
1496 | |
9 | 1497 if (visible_row) |
1498 { | |
1499 if (gtk_tree_row_reference_valid(visible_row)) | |
1500 { | |
1501 tpath = gtk_tree_row_reference_get_path(visible_row); | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1502 gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(vf->listview), tpath, NULL, TRUE, 0.0, 0.0); |
9 | 1503 gtk_tree_path_free(tpath); |
1504 } | |
1505 gtk_tree_row_reference_free(visible_row); | |
1506 } | |
1507 | |
633 | 1508 vf_send_update(vf); |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1509 vflist_thumb_update(vf); |
9 | 1510 } |
1511 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1512 gint vflist_refresh(ViewFile *vf) |
9 | 1513 { |
1514 GList *old_list; | |
1515 gint ret = TRUE; | |
1516 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1517 old_list = vf->list; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1518 vf->list = NULL; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1519 |
762 | 1520 DEBUG_1("%s vflist_refresh: read dir", get_exec_time()); |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1521 if (vf->path) |
9 | 1522 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1523 ret = filelist_read(vf->path, &vf->list, NULL); |
9 | 1524 } |
762 | 1525 DEBUG_1("%s vflist_refresh: sort", get_exec_time()); |
9 | 1526 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1527 vf->list = filelist_sort(vf->list, vf->sort_method, vf->sort_ascend); |
762 | 1528 |
1529 DEBUG_1("%s vflist_refresh: populate view", get_exec_time()); | |
1530 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1531 vflist_populate_view(vf); |
9 | 1532 |
1533 filelist_free(old_list); | |
762 | 1534 DEBUG_1("%s vflist_refresh: done", get_exec_time()); |
9 | 1535 |
1536 return ret; | |
1537 } | |
1538 | |
1539 /* this overrides the low default of a GtkCellRenderer from 100 to CELL_HEIGHT_OVERRIDE, something sane for our purposes */ | |
1540 | |
1541 #define CELL_HEIGHT_OVERRIDE 512 | |
1542 | |
1543 static void cell_renderer_height_override(GtkCellRenderer *renderer) | |
1544 { | |
1545 GParamSpec *spec; | |
1546 | |
1547 spec = g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(renderer)), "height"); | |
1548 if (spec && G_IS_PARAM_SPEC_INT(spec)) | |
1549 { | |
1550 GParamSpecInt *spec_int; | |
1551 | |
1552 spec_int = G_PARAM_SPEC_INT(spec); | |
1553 if (spec_int->maximum < CELL_HEIGHT_OVERRIDE) spec_int->maximum = CELL_HEIGHT_OVERRIDE; | |
1554 } | |
1555 } | |
1556 | |
1557 static GdkColor *vflist_listview_color_shifted(GtkWidget *widget) | |
1558 { | |
1559 static GdkColor color; | |
1560 static GtkWidget *done = NULL; | |
1561 | |
1562 if (done != widget) | |
1563 { | |
1564 GtkStyle *style; | |
1565 | |
1566 style = gtk_widget_get_style(widget); | |
1567 memcpy(&color, &style->base[GTK_STATE_NORMAL], sizeof(color)); | |
1568 shift_color(&color, -1, 0); | |
1569 done = widget; | |
1570 } | |
1571 | |
1572 return &color; | |
1573 } | |
1574 | |
1575 static void vflist_listview_color_cb(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, | |
1576 GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data) | |
1577 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1578 ViewFile *vf = data; |
9 | 1579 gboolean set; |
1580 | |
1581 gtk_tree_model_get(tree_model, iter, FILE_COLUMN_COLOR, &set, -1); | |
1582 g_object_set(G_OBJECT(cell), | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1583 "cell-background-gdk", vflist_listview_color_shifted(vf->listview), |
9 | 1584 "cell-background-set", set, NULL); |
1585 } | |
1586 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1587 static void vflist_listview_add_column(ViewFile *vf, gint n, const gchar *title, gint image, gint right_justify, gint expand) |
9 | 1588 { |
1589 GtkTreeViewColumn *column; | |
1590 GtkCellRenderer *renderer; | |
1591 | |
1592 column = gtk_tree_view_column_new(); | |
1593 gtk_tree_view_column_set_title(column, title); | |
1594 gtk_tree_view_column_set_min_width(column, 4); | |
1595 | |
1596 if (!image) | |
1597 { | |
149 | 1598 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY); |
9 | 1599 renderer = gtk_cell_renderer_text_new(); |
1600 if (right_justify) | |
1601 { | |
1602 g_object_set(G_OBJECT(renderer), "xalign", 1.0, NULL); | |
1603 } | |
1604 gtk_tree_view_column_pack_start(column, renderer, TRUE); | |
1605 gtk_tree_view_column_add_attribute(column, renderer, "text", n); | |
149 | 1606 if (expand) |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1607 gtk_tree_view_column_set_expand(column, TRUE); |
149 | 1608 } |
9 | 1609 else |
1610 { | |
1611 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED); | |
1612 renderer = gtk_cell_renderer_pixbuf_new(); | |
1613 cell_renderer_height_override(renderer); | |
1614 gtk_tree_view_column_pack_start(column, renderer, TRUE); | |
1615 gtk_tree_view_column_add_attribute(column, renderer, "pixbuf", n); | |
1616 } | |
1617 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1618 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
|
1619 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
|
1620 g_object_set_data(G_OBJECT(renderer), "column_store_idx", GUINT_TO_POINTER(n)); |
9 | 1621 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1622 gtk_tree_view_append_column(GTK_TREE_VIEW(vf->listview), column); |
9 | 1623 } |
1624 | |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1625 static void vflist_listview_mark_toggled(GtkCellRendererToggle *cell, gchar *path_str, GtkTreeStore *store) |
132 | 1626 { |
149 | 1627 GtkTreePath *path = gtk_tree_path_new_from_string(path_str); |
1628 GtkTreeIter iter; | |
1629 FileData *fd; | |
1630 gboolean mark; | |
1631 guint col_idx; | |
442 | 1632 |
149 | 1633 if (!path || !gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, path)) |
1634 return; | |
132 | 1635 |
513
985fdfebd89e
Remove whitespace between function name and first parenthesis for the sake of consistency. (pass 2)
zas_
parents:
512
diff
changeset
|
1636 col_idx = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cell), "column_store_idx")); |
442 | 1637 |
149 | 1638 g_assert(col_idx >= FILE_COLUMN_MARKS && col_idx <= FILE_COLUMN_MARKS_LAST); |
442 | 1639 |
149 | 1640 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, FILE_COLUMN_POINTER, &fd, col_idx, &mark, -1); |
150 | 1641 mark = !mark; |
149 | 1642 fd->marks[col_idx - FILE_COLUMN_MARKS] = mark; |
763
81f9e8dbb4bf
improved infrastructure for tracing changes, optimized vflist_populate_view
nadvornik
parents:
762
diff
changeset
|
1643 file_data_increment_version(fd); |
442 | 1644 |
149 | 1645 gtk_tree_store_set(store, &iter, col_idx, mark, -1); |
1646 gtk_tree_path_free(path); | |
132 | 1647 } |
1648 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1649 static void vflist_listview_add_column_toggle(ViewFile *vf, gint n, const gchar *title) |
132 | 1650 { |
149 | 1651 GtkTreeViewColumn *column; |
1652 GtkCellRenderer *renderer; | |
1653 GtkTreeStore *store; | |
1654 gint index; | |
442 | 1655 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1656 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview))); |
132 | 1657 |
149 | 1658 renderer = gtk_cell_renderer_toggle_new(); |
1659 column = gtk_tree_view_column_new_with_attributes(title, renderer, "active", n, NULL); | |
132 | 1660 |
149 | 1661 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
|
1662 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
|
1663 g_object_set_data(G_OBJECT(renderer), "column_store_idx", GUINT_TO_POINTER(n)); |
442 | 1664 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1665 index = gtk_tree_view_append_column(GTK_TREE_VIEW(vf->listview), column); |
149 | 1666 gtk_tree_view_column_set_fixed_width(column, 16); |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1667 gtk_tree_view_column_set_visible(column, vf->marks_enabled); |
132 | 1668 |
442 | 1669 |
149 | 1670 g_signal_connect(G_OBJECT(renderer), "toggled", G_CALLBACK(vflist_listview_mark_toggled), store); |
132 | 1671 } |
1672 | |
9 | 1673 /* |
1674 *----------------------------------------------------------------------------- | |
1675 * base | |
1676 *----------------------------------------------------------------------------- | |
1677 */ | |
1678 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1679 gint vflist_set_path(ViewFile *vf, const gchar *path) |
9 | 1680 { |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1681 GtkTreeStore *store; |
9 | 1682 |
1683 if (!path) return FALSE; | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1684 if (vf->path && strcmp(path, vf->path) == 0) return TRUE; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1685 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1686 g_free(vf->path); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1687 vf->path = g_strdup(path); |
9 | 1688 |
1689 /* force complete reload */ | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1690 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
|
1691 gtk_tree_store_clear(store); |
9 | 1692 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1693 filelist_free(vf->list); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1694 vf->list = NULL; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1695 |
633 | 1696 return vf_refresh(vf); |
9 | 1697 } |
1698 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1699 void vflist_destroy_cb(GtkWidget *widget, gpointer data) |
9 | 1700 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1701 ViewFile *vf = data; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1702 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1703 vflist_select_idle_cancel(vf); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1704 vflist_thumb_stop(vf); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1705 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1706 filelist_free(vf->list); |
9 | 1707 } |
1708 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1709 ViewFile *vflist_new(ViewFile *vf, const gchar *path) |
9 | 1710 { |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1711 GtkTreeStore *store; |
9 | 1712 GtkTreeSelection *selection; |
1713 | |
149 | 1714 GType flist_types[FILE_COLUMN_COUNT]; |
1715 int i; | |
442 | 1716 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1717 vf->info = g_new0(ViewFileInfoList, 1); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1718 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1719 VFLIST_INFO(vf, click_fd) = NULL; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1720 VFLIST_INFO(vf, select_fd) = NULL; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1721 VFLIST_INFO(vf, thumbs_enabled) = FALSE; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1722 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1723 VFLIST_INFO(vf, select_idle_id) = -1; |
9 | 1724 |
139 | 1725 flist_types[FILE_COLUMN_POINTER] = G_TYPE_POINTER; |
763
81f9e8dbb4bf
improved infrastructure for tracing changes, optimized vflist_populate_view
nadvornik
parents:
762
diff
changeset
|
1726 flist_types[FILE_COLUMN_VERSION] = G_TYPE_INT; |
139 | 1727 flist_types[FILE_COLUMN_THUMB] = GDK_TYPE_PIXBUF; |
1728 flist_types[FILE_COLUMN_NAME] = G_TYPE_STRING; | |
1729 flist_types[FILE_COLUMN_SIDECARS] = G_TYPE_STRING; | |
1730 flist_types[FILE_COLUMN_SIZE] = G_TYPE_STRING; | |
1731 flist_types[FILE_COLUMN_DATE] = G_TYPE_STRING; | |
1732 flist_types[FILE_COLUMN_COLOR] = G_TYPE_BOOLEAN; | |
1733 for (i = FILE_COLUMN_MARKS; i < FILE_COLUMN_MARKS + FILEDATA_MARKS_SIZE; i++) | |
1734 flist_types[i] = G_TYPE_BOOLEAN; | |
132 | 1735 |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1736 store = gtk_tree_store_newv(FILE_COLUMN_COUNT, flist_types); |
442 | 1737 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1738 vf->listview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); |
9 | 1739 g_object_unref(store); |
1740 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1741 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
9 | 1742 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
|
1743 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
|
1744 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1745 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
|
1746 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
|
1747 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1748 vflist_listview_add_column(vf, FILE_COLUMN_THUMB, "", TRUE, FALSE, FALSE); |
9 | 1749 |
518 | 1750 for (i = 0; i < FILEDATA_MARKS_SIZE; i++) |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1751 vflist_listview_add_column_toggle(vf, i + FILE_COLUMN_MARKS, ""); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1752 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1753 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
|
1754 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
|
1755 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1756 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
|
1757 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
|
1758 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1759 return vf; |
9 | 1760 } |
1761 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1762 void vflist_thumb_set(ViewFile *vf, gint enable) |
9 | 1763 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1764 if (VFLIST_INFO(vf, thumbs_enabled) == enable) return; |
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 VFLIST_INFO(vf, thumbs_enabled) = enable; |
633 | 1767 if (vf->layout) vf_refresh(vf); |
9 | 1768 } |
1769 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1770 void vflist_marks_set(ViewFile *vf, gint enable) |
132 | 1771 { |
149 | 1772 GList *columns, *work; |
442 | 1773 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1774 if (vf->marks_enabled == enable) return; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1775 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1776 vf->marks_enabled = enable; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1777 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1778 columns = gtk_tree_view_get_columns(GTK_TREE_VIEW(vf->listview)); |
442 | 1779 |
149 | 1780 work = columns; |
1781 while (work) | |
1782 { | |
1783 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
|
1784 gint col_idx = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(column), "column_store_idx")); |
149 | 1785 work = work->next; |
442 | 1786 |
1787 if (col_idx <= FILE_COLUMN_MARKS_LAST && col_idx >= FILE_COLUMN_MARKS) | |
149 | 1788 gtk_tree_view_column_set_visible(column, enable); |
1789 } | |
442 | 1790 |
149 | 1791 g_list_free(columns); |
633 | 1792 //vf_refresh(vf); |
132 | 1793 } |
1794 | |
9 | 1795 /* |
1796 *----------------------------------------------------------------------------- | |
1797 * maintenance (for rename, move, remove) | |
1798 *----------------------------------------------------------------------------- | |
1799 */ | |
1800 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1801 static gint vflist_maint_find_closest(ViewFile *vf, gint row, gint count, GList *ignore_list) |
9 | 1802 { |
1803 GList *list = NULL; | |
1804 GList *work; | |
1805 gint rev = row - 1; | |
1806 row ++; | |
1807 | |
1808 work = ignore_list; | |
1809 while (work) | |
1810 { | |
633 | 1811 gint f = vf_index_by_path(vf, work->data); |
9 | 1812 if (f >= 0) list = g_list_prepend(list, GINT_TO_POINTER(f)); |
1813 work = work->next; | |
1814 } | |
1815 | |
1816 while (list) | |
1817 { | |
1818 gint c = TRUE; | |
1819 work = list; | |
1820 while (work && c) | |
1821 { | |
1822 gpointer p = work->data; | |
1823 work = work->next; | |
1824 if (row == GPOINTER_TO_INT(p)) | |
1825 { | |
1826 row++; | |
1827 c = FALSE; | |
1828 } | |
1829 if (rev == GPOINTER_TO_INT(p)) | |
1830 { | |
1831 rev--; | |
1832 c = FALSE; | |
1833 } | |
1834 if (!c) list = g_list_remove(list, p); | |
1835 } | |
1836 if (c && list) | |
1837 { | |
1838 g_list_free(list); | |
1839 list = NULL; | |
1840 } | |
1841 } | |
1842 if (row > count - 1) | |
1843 { | |
1844 if (rev < 0) | |
1845 return -1; | |
1846 else | |
1847 return rev; | |
1848 } | |
1849 else | |
1850 { | |
1851 return row; | |
1852 } | |
1853 } | |
1854 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1855 gint vflist_maint_renamed(ViewFile *vf, FileData *fd) |
9 | 1856 { |
1857 gint ret = FALSE; | |
1858 gchar *source_base; | |
1859 gchar *dest_base; | |
1860 | |
762 | 1861 DEBUG_1("%s vflist_maint_renamed: start", get_exec_time()); |
1862 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1863 if (g_list_index(vf->list, fd) < 0) return FALSE; |
9 | 1864 |
138 | 1865 source_base = remove_level_from_path(fd->change->source); |
1866 dest_base = remove_level_from_path(fd->change->dest); | |
9 | 1867 |
1868 | |
1869 if (strcmp(source_base, dest_base) == 0) | |
1870 { | |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1871 GtkTreeStore *store; |
9 | 1872 GtkTreeIter iter; |
1873 GtkTreeIter position; | |
1874 gint old_row; | |
1875 gint n; | |
1876 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1877 old_row = g_list_index(vf->list, fd); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1878 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1879 vf->list = g_list_remove(vf->list, fd); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1880 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1881 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
|
1882 n = g_list_index(vf->list, fd); |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1883 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1884 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
|
1885 if (vflist_find_row(vf, fd, &iter) >= 0 && |
9 | 1886 gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &position, NULL, n)) |
1887 { | |
1888 if (old_row >= n) | |
1889 { | |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1890 gtk_tree_store_move_before(store, &iter, &position); |
9 | 1891 } |
1892 else | |
1893 { | |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1894 gtk_tree_store_move_after(store, &iter, &position); |
9 | 1895 } |
1896 } | |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1897 gtk_tree_store_set(store, &iter, FILE_COLUMN_NAME, fd->name, -1); |
9 | 1898 |
1899 ret = TRUE; | |
1900 } | |
1901 else | |
1902 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1903 ret = vflist_maint_removed(vf, fd, NULL); |
9 | 1904 } |
1905 | |
1906 g_free(source_base); | |
1907 g_free(dest_base); | |
1908 | |
762 | 1909 DEBUG_1("%s vflist_maint_renamed: done", get_exec_time()); |
1910 | |
9 | 1911 return ret; |
1912 } | |
1913 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1914 gint vflist_maint_removed(ViewFile *vf, FileData *fd, GList *ignore_list) |
9 | 1915 { |
1916 GtkTreeIter iter; | |
1917 GList *list; | |
1918 gint row; | |
1919 gint new_row = -1; | |
1920 | |
762 | 1921 DEBUG_1("%s vflist_maint_removed: start", get_exec_time()); |
1922 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1923 row = g_list_index(vf->list, fd); |
9 | 1924 if (row < 0) return FALSE; |
1925 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1926 if (vflist_index_is_selected(vf, row) && |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1927 layout_image_get_collection(vf->layout, NULL) == NULL) |
9 | 1928 { |
1929 gint n; | |
1930 | |
633 | 1931 n = vf_count(vf, NULL); |
9 | 1932 if (ignore_list) |
1933 { | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1934 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
|
1935 DEBUG_1("row = %d, closest is %d", row, new_row); |
9 | 1936 } |
1937 else | |
1938 { | |
1939 if (row + 1 < n) | |
1940 { | |
1941 new_row = row + 1; | |
1942 } | |
1943 else if (row > 0) | |
1944 { | |
1945 new_row = row - 1; | |
1946 } | |
1947 } | |
633 | 1948 vf_select_none(vf); |
9 | 1949 if (new_row >= 0) |
1950 { | |
633 | 1951 fd = vf_index_get_data(vf, new_row); |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1952 if (vflist_find_row(vf, fd, &iter) >= 0) |
9 | 1953 { |
1954 GtkTreeSelection *selection; | |
1955 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1956 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); |
9 | 1957 gtk_tree_selection_select_iter(selection, &iter); |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1958 vflist_move_cursor(vf, &iter); |
9 | 1959 } |
1960 } | |
1961 } | |
1962 | |
633 | 1963 fd = vf_index_get_data(vf, row); |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1964 if (vflist_find_row(vf, fd, &iter) >= 0) |
9 | 1965 { |
142
b5aa95241859
display sidecar files (jpeg + raw) using gtk_tree_store
nadvornik
parents:
139
diff
changeset
|
1966 GtkTreeStore *store; |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1967 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
|
1968 gtk_tree_store_remove(store, &iter); |
9 | 1969 } |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1970 list = g_list_nth(vf->list, row); |
9 | 1971 fd = list->data; |
1972 | |
1973 /* thumbnail loader check */ | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1974 if (fd == vf->thumbs_filedata) vf->thumbs_filedata = NULL; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1975 if (vf->thumbs_count > 0) vf->thumbs_count--; |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1976 |
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1977 vf->list = g_list_remove(vf->list, fd); |
138 | 1978 file_data_unref(fd); |
9 | 1979 |
633 | 1980 vf_send_update(vf); |
9 | 1981 |
762 | 1982 DEBUG_1("%s vflist_maint_removed: done", get_exec_time()); |
1983 | |
9 | 1984 return TRUE; |
1985 } | |
1986 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1987 gint vflist_maint_moved(ViewFile *vf, FileData *fd, GList *ignore_list) |
9 | 1988 { |
1989 gint ret = FALSE; | |
1990 gchar *buf; | |
1991 | |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1992 if (!fd->change->source || !vf->path) return FALSE; |
9 | 1993 |
138 | 1994 buf = remove_level_from_path(fd->change->source); |
9 | 1995 |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1996 if (strcmp(buf, vf->path) == 0) |
9 | 1997 { |
573
2996f1bbc305
Drop ViewFileList, use ViewFile and ViewFileInfoList instead.
zas_
parents:
559
diff
changeset
|
1998 ret = vflist_maint_removed(vf, fd, ignore_list); |
9 | 1999 } |
2000 | |
2001 g_free(buf); | |
2002 | |
2003 return ret; | |
2004 } |