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