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