2 * Copyright (C) 2004 John Ellis
3 * Copyright (C) 2008 - 2016 The Geeqie Team
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include "collect-table.h"
25 #include "cellrenderericon.h"
26 #include "collect-dlg.h"
27 #include "collect-io.h"
34 #include "layout_image.h"
37 #include "pixbuf_util.h"
40 #include "ui_fileops.h"
42 #include "ui_tree_edit.h"
43 #include "uri_utils.h"
44 #include "view_file.h"
46 #include "icons/marker.xpm"
47 #define MARKER_WIDTH 26
48 #define MARKER_HEIGHT 32
50 #include <gdk/gdkkeysyms.h> /* for keyboard values */
52 /* between these, the icon width is increased by thumb_max_width / 2 */
53 #define THUMB_MIN_ICON_WIDTH 128
54 #define THUMB_MAX_ICON_WIDTH 150
56 #define COLLECT_TABLE_MAX_COLUMNS 32
57 #define THUMB_BORDER_PADDING 2
59 #define COLLECT_TABLE_TIP_DELAY 500
60 #define COLLECT_TABLE_TIP_DELAY_PATH (COLLECT_TABLE_TIP_DELAY * 1.7)
64 CTABLE_COLUMN_POINTER = 0,
68 #define INFO_SELECTED(x) (x->flag_mask & SELECTION_SELECTED)
71 static void collection_table_populate_at_new_size(CollectTable *ct, gint w, gint h, gboolean force);
74 * This array must be kept in sync with the contents of:\n
75 * @link collection_table_press_key_cb @endlink \n
76 * @link collection_window_keypress @endlink \n
77 * @link collection_table_popup_menu @endlink
79 * See also @link hard_coded_window_keys @endlink
81 hard_coded_window_keys collection_window_keys[] = {
82 {GDK_CONTROL_MASK, 'C', N_("Copy")},
83 {GDK_CONTROL_MASK, 'M', N_("Move")},
84 {GDK_CONTROL_MASK, 'R', N_("Rename")},
85 {GDK_CONTROL_MASK, 'D', N_("Move to Trash")},
86 {GDK_CONTROL_MASK, 'W', N_("Close window")},
87 {0, GDK_KEY_Delete, N_("Remove")},
88 {0, GDK_KEY_Return, N_("View")},
89 {0, 'V', N_("View in new window")},
90 {GDK_CONTROL_MASK, 'A', N_("Select all")},
91 {GDK_CONTROL_MASK + GDK_SHIFT_MASK, 'A', N_("Select none")},
92 {GDK_MOD1_MASK, 'R', N_("Rectangular selection")},
93 {0, GDK_KEY_space, N_("Select single file")},
94 {GDK_CONTROL_MASK, GDK_KEY_space, N_("Toggle select image")},
95 {GDK_CONTROL_MASK, 'L', N_("Append from file selection")},
96 {0, 'A', N_("Append from collection")},
97 {0, 'S', N_("Save collection")},
98 {GDK_CONTROL_MASK, 'S', N_("Save collection as")},
99 {GDK_CONTROL_MASK, 'T', N_("Show filename text")},
100 {0, 'N', N_("Sort by name")},
101 {0, 'I', N_("Sort by number")},
102 {0, 'D', N_("Sort by date")},
103 {0, 'B', N_("Sort by size")},
104 {0, 'P', N_("Sort by path")},
105 {GDK_SHIFT_MASK, 'P', N_("Print")},
110 *-------------------------------------------------------------------
112 *-------------------------------------------------------------------
115 static gboolean collection_table_find_position(CollectTable *ct, CollectInfo *info, gint *row, gint *col)
119 n = g_list_index(ct->cd->list, info);
121 if (n < 0) return FALSE;
123 *row = n / ct->columns;
124 *col = n - (*row * ct->columns);
129 static gboolean collection_table_find_iter(CollectTable *ct, CollectInfo *info, GtkTreeIter *iter, gint *column)
134 store = gtk_tree_view_get_model(GTK_TREE_VIEW(ct->listview));
135 if (!collection_table_find_position(ct, info, &row, &col)) return FALSE;
136 if (!gtk_tree_model_iter_nth_child(store, iter, NULL, row)) return FALSE;
137 if (column) *column = col;
142 static CollectInfo *collection_table_find_data(CollectTable *ct, gint row, gint col, GtkTreeIter *iter)
147 if (row < 0 || col < 0) return NULL;
149 store = gtk_tree_view_get_model(GTK_TREE_VIEW(ct->listview));
150 if (gtk_tree_model_iter_nth_child(store, &p, NULL, row))
154 gtk_tree_model_get(store, &p, CTABLE_COLUMN_POINTER, &list, -1);
155 if (!list) return NULL;
159 return g_list_nth_data(list, col);
165 static CollectInfo *collection_table_find_data_by_coord(CollectTable *ct, gint x, gint y, GtkTreeIter *iter)
168 GtkTreeViewColumn *column;
174 if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(ct->listview), x, y,
175 &tpath, &column, NULL, NULL))
178 store = gtk_tree_view_get_model(GTK_TREE_VIEW(ct->listview));
179 gtk_tree_model_get_iter(store, &row, tpath);
180 gtk_tree_path_free(tpath);
182 gtk_tree_model_get(store, &row, CTABLE_COLUMN_POINTER, &list, -1);
183 if (!list) return NULL;
185 n = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(column), "column_number"));
186 if (iter) *iter = row;
187 return g_list_nth_data(list, n);
190 static guint collection_table_list_count(CollectTable *ct, gint64 *bytes)
200 CollectInfo *ci = work->data;
208 return g_list_length(ct->cd->list);
211 static guint collection_table_selection_count(CollectTable *ct, gint64 *bytes)
218 work = ct->selection;
221 CollectInfo *ci = work->data;
229 return g_list_length(ct->selection);
232 static void collection_table_update_status(CollectTable *ct)
240 if (!ct->status_label) return;
242 n = collection_table_list_count(ct, &n_bytes);
243 s = collection_table_selection_count(ct, &s_bytes);
247 gchar *b = text_from_size_abrev(n_bytes);
248 gchar *sb = text_from_size_abrev(s_bytes);
249 buf = g_strdup_printf(_("%s, %d images (%s, %d)"), b, n, sb, s);
255 gchar *b = text_from_size_abrev(n_bytes);
256 buf = g_strdup_printf(_("%s, %d images"), b, n);
261 buf = g_strdup(_("Empty"));
264 gtk_label_set_text(GTK_LABEL(ct->status_label), buf);
268 static void collection_table_update_extras(CollectTable *ct, gboolean loading, gdouble value)
272 if (!ct->extra_label) return;
275 text = _("Loading thumbs...");
279 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ct->extra_label), value);
280 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ct->extra_label), text);
283 static void collection_table_toggle_filenames(CollectTable *ct)
285 GtkAllocation allocation;
286 ct->show_text = !ct->show_text;
287 options->show_icon_names = ct->show_text;
289 gtk_widget_get_allocation(ct->listview, &allocation);
290 collection_table_populate_at_new_size(ct, allocation.width, allocation.height, TRUE);
293 static void collection_table_toggle_stars(CollectTable *ct)
295 GtkAllocation allocation;
296 ct->show_stars = !ct->show_stars;
297 options->show_star_rating = ct->show_stars;
299 gtk_widget_get_allocation(ct->listview, &allocation);
300 collection_table_populate_at_new_size(ct, allocation.width, allocation.height, TRUE);
303 static gint collection_table_get_icon_width(CollectTable *ct)
307 if (!ct->show_text) return options->thumbnails.max_width;
309 width = options->thumbnails.max_width + options->thumbnails.max_width / 2;
310 if (width < THUMB_MIN_ICON_WIDTH) width = THUMB_MIN_ICON_WIDTH;
311 if (width > THUMB_MAX_ICON_WIDTH) width = options->thumbnails.max_width;
317 *-------------------------------------------------------------------
319 *-------------------------------------------------------------------
322 static void collection_table_selection_set(CollectTable *ct, CollectInfo *info, SelectionType value, GtkTreeIter *iter)
329 if (info->flag_mask == value) return;
330 info->flag_mask = value;
332 store = gtk_tree_view_get_model(GTK_TREE_VIEW(ct->listview));
335 gtk_tree_model_get(store, iter, CTABLE_COLUMN_POINTER, &list, -1);
336 if (list) gtk_list_store_set(GTK_LIST_STORE(store), iter, CTABLE_COLUMN_POINTER, list, -1);
342 if (collection_table_find_iter(ct, info, &row, NULL))
344 gtk_tree_model_get(store, &row, CTABLE_COLUMN_POINTER, &list, -1);
345 if (list) gtk_list_store_set(GTK_LIST_STORE(store), &row, CTABLE_COLUMN_POINTER, list, -1);
350 static void collection_table_selection_add(CollectTable *ct, CollectInfo *info, SelectionType mask, GtkTreeIter *iter)
354 collection_table_selection_set(ct, info, info->flag_mask | mask, iter);
357 static void collection_table_selection_remove(CollectTable *ct, CollectInfo *info, SelectionType mask, GtkTreeIter *iter)
361 collection_table_selection_set(ct, info, info->flag_mask & ~mask, iter);
364 *-------------------------------------------------------------------
366 *-------------------------------------------------------------------
369 static void collection_table_verify_selections(CollectTable *ct)
373 work = ct->selection;
376 CollectInfo *info = work->data;
378 if (!g_list_find(ct->cd->list, info))
380 ct->selection = g_list_remove(ct->selection, info);
385 void collection_table_select_all(CollectTable *ct)
389 g_list_free(ct->selection);
390 ct->selection = NULL;
395 ct->selection = g_list_append(ct->selection, work->data);
396 collection_table_selection_add(ct, work->data, SELECTION_SELECTED, NULL);
400 collection_table_update_status(ct);
403 void collection_table_unselect_all(CollectTable *ct)
407 work = ct->selection;
410 collection_table_selection_remove(ct, work->data, SELECTION_SELECTED, NULL);
414 g_list_free(ct->selection);
415 ct->selection = NULL;
417 collection_table_update_status(ct);
420 /* Invert the current collection's selection */
421 static void collection_table_select_invert_all(CollectTable *ct)
424 GList *new_selection = NULL;
429 CollectInfo *info = work->data;
431 if (INFO_SELECTED(info))
433 collection_table_selection_remove(ct, info, SELECTION_SELECTED, NULL);
437 new_selection = g_list_append(new_selection, info);
438 collection_table_selection_add(ct, info, SELECTION_SELECTED, NULL);
445 g_list_free(ct->selection);
446 ct->selection = new_selection;
448 collection_table_update_status(ct);
451 void collection_table_select(CollectTable *ct, CollectInfo *info)
453 ct->prev_selection = info;
455 if (!info || INFO_SELECTED(info)) return;
457 ct->selection = g_list_append(ct->selection, info);
458 collection_table_selection_add(ct, info, SELECTION_SELECTED, NULL);
460 collection_table_update_status(ct);
463 static void collection_table_unselect(CollectTable *ct, CollectInfo *info)
465 ct->prev_selection = info;
467 if (!info || !INFO_SELECTED(info) ) return;
469 ct->selection = g_list_remove(ct->selection, info);
470 collection_table_selection_remove(ct, info, SELECTION_SELECTED, NULL);
472 collection_table_update_status(ct);
475 static void collection_table_select_util(CollectTable *ct, CollectInfo *info, gboolean select)
479 collection_table_select(ct, info);
483 collection_table_unselect(ct, info);
487 static void collection_table_select_region_util(CollectTable *ct, CollectInfo *start, CollectInfo *end, gboolean select)
494 if (!collection_table_find_position(ct, start, &row1, &col1) ||
495 !collection_table_find_position(ct, end, &row2, &col2) ) return;
497 ct->prev_selection = end;
499 if (!options->collections.rectangular_selection)
504 if (g_list_index(ct->cd->list, start) > g_list_index(ct->cd->list, end))
511 work = g_list_find(ct->cd->list, start);
515 collection_table_select_util(ct, info, select);
517 if (work->data != end)
538 DEBUG_1("table: %d x %d to %d x %d", row1, col1, row2, col2);
540 for (i = row1; i <= row2; i++)
542 for (j = col1; j <= col2; j++)
544 CollectInfo *info = collection_table_find_data(ct, i, j, NULL);
545 if (info) collection_table_select_util(ct, info, select);
550 GList *collection_table_selection_get_list(CollectTable *ct)
552 return collection_list_to_filelist(ct->selection);
555 static GList *collection_table_get_list(CollectTable *ct)
557 return collection_list_to_filelist(ct->cd->list);
561 *-------------------------------------------------------------------
562 * tooltip type window
563 *-------------------------------------------------------------------
566 static void tip_show(CollectTable *ct)
570 #if GTK_CHECK_VERSION(3,0,0)
572 GdkDeviceManager *device_manager;
576 if (ct->tip_window) return;
578 #if GTK_CHECK_VERSION(3,0,0)
579 device_manager = gdk_display_get_device_manager(gdk_window_get_display(
580 gtk_widget_get_window(ct->listview)));
581 device = gdk_device_manager_get_client_pointer(device_manager);
582 gdk_window_get_device_position(gtk_widget_get_window(ct->listview),
583 device, &x, &y, NULL);
585 gdk_window_get_pointer(gtk_widget_get_window(ct->listview), &x, &y, NULL);
588 ct->tip_info = collection_table_find_data_by_coord(ct, x, y, NULL);
589 if (!ct->tip_info) return;
591 ct->tip_window = gtk_window_new(GTK_WINDOW_POPUP);
592 gtk_window_set_resizable(GTK_WINDOW(ct->tip_window), FALSE);
593 gtk_container_set_border_width(GTK_CONTAINER(ct->tip_window), 2);
595 label = gtk_label_new(ct->show_text ? ct->tip_info->fd->path : ct->tip_info->fd->name);
597 g_object_set_data(G_OBJECT(ct->tip_window), "tip_label", label);
598 gtk_container_add(GTK_CONTAINER(ct->tip_window), label);
599 gtk_widget_show(label);
601 #if GTK_CHECK_VERSION(3,0,0)
602 display = gdk_display_get_default();
603 device_manager = gdk_display_get_device_manager(display);
604 device = gdk_device_manager_get_client_pointer(device_manager);
605 gdk_device_get_position(device, NULL, &x, &y);
607 gdk_window_get_pointer(NULL, &x, &y, NULL);
610 if (!gtk_widget_get_realized(ct->tip_window)) gtk_widget_realize(ct->tip_window);
611 gtk_window_move(GTK_WINDOW(ct->tip_window), x + 16, y + 16);
612 gtk_widget_show(ct->tip_window);
615 static void tip_hide(CollectTable *ct)
617 if (ct->tip_window) gtk_widget_destroy(ct->tip_window);
618 ct->tip_window = NULL;
621 static gboolean tip_schedule_cb(gpointer data)
623 CollectTable *ct = data;
625 if (!ct->tip_delay_id) return FALSE;
629 ct->tip_delay_id = 0;
633 static void tip_schedule(CollectTable *ct)
637 if (ct->tip_delay_id)
639 g_source_remove(ct->tip_delay_id);
640 ct->tip_delay_id = 0;
643 ct->tip_delay_id = g_timeout_add(ct->show_text ? COLLECT_TABLE_TIP_DELAY_PATH : COLLECT_TABLE_TIP_DELAY, tip_schedule_cb, ct);
646 static void tip_unschedule(CollectTable *ct)
650 if (ct->tip_delay_id)
652 g_source_remove(ct->tip_delay_id);
653 ct->tip_delay_id = 0;
657 static void tip_update(CollectTable *ct, CollectInfo *info)
659 #if GTK_CHECK_VERSION(3,0,0)
660 GdkDisplay *display = gdk_display_get_default();
661 GdkDeviceManager *device_manager = gdk_display_get_device_manager(display);
662 GdkDevice *device = gdk_device_manager_get_client_pointer(device_manager);
670 #if GTK_CHECK_VERSION(3,0,0)
671 gdk_device_get_position(device, NULL, &x, &y);
673 gdk_window_get_pointer(NULL, &x, &y, NULL);
675 gtk_window_move(GTK_WINDOW(ct->tip_window), x + 16, y + 16);
677 if (info != ct->tip_info)
688 label = g_object_get_data(G_OBJECT(ct->tip_window), "tip_label");
689 gtk_label_set_text(GTK_LABEL(label), ct->show_text ? ct->tip_info->fd->path : ct->tip_info->fd->name);
695 *-------------------------------------------------------------------
697 *-------------------------------------------------------------------
700 static void collection_table_popup_save_as_cb(GtkWidget *widget, gpointer data)
702 CollectTable *ct = data;
704 collection_dialog_save_as(NULL, ct->cd);
707 static void collection_table_popup_save_cb(GtkWidget *widget, gpointer data)
709 CollectTable *ct = data;
713 collection_table_popup_save_as_cb(widget, data);
717 if (!collection_save(ct->cd, ct->cd->path))
719 log_printf("failed saving to collection path: %s\n", ct->cd->path);
723 static GList *collection_table_popup_file_list(CollectTable *ct)
725 if (!ct->click_info) return NULL;
727 if (INFO_SELECTED(ct->click_info))
729 return collection_table_selection_get_list(ct);
732 return g_list_append(NULL, file_data_ref(ct->click_info->fd));
735 static void collection_table_popup_edit_cb(GtkWidget *widget, gpointer data)
738 const gchar *key = data;
740 ct = submenu_item_get_data(widget);
744 file_util_start_editor_from_filelist(key, collection_table_popup_file_list(ct), NULL, ct->listview);
747 static void collection_table_popup_copy_cb(GtkWidget *widget, gpointer data)
749 CollectTable *ct = data;
751 file_util_copy(NULL, collection_table_popup_file_list(ct), NULL, ct->listview);
754 static void collection_table_popup_move_cb(GtkWidget *widget, gpointer data)
756 CollectTable *ct = data;
758 file_util_move(NULL, collection_table_popup_file_list(ct), NULL, ct->listview);
761 static void collection_table_popup_rename_cb(GtkWidget *widget, gpointer data)
763 CollectTable *ct = data;
765 file_util_rename(NULL, collection_table_popup_file_list(ct), ct->listview);
768 static void collection_table_popup_delete_cb(GtkWidget *widget, gpointer data)
770 CollectTable *ct = data;
772 options->file_ops.safe_delete_enable = FALSE;
773 file_util_delete(NULL, collection_table_popup_file_list(ct), ct->listview);
776 static void collection_table_popup_move_to_trash_cb(GtkWidget *widget, gpointer data)
778 CollectTable *ct = data;
780 options->file_ops.safe_delete_enable = TRUE;
781 file_util_delete(NULL, collection_table_popup_file_list(ct), ct->listview);
784 static void collection_table_popup_copy_path_cb(GtkWidget *widget, gpointer data)
786 CollectTable *ct = data;
788 file_util_copy_path_list_to_clipboard(collection_table_popup_file_list(ct), TRUE);
791 static void collection_table_popup_copy_path_unquoted_cb(GtkWidget *widget, gpointer data)
793 CollectTable *ct = data;
795 file_util_copy_path_list_to_clipboard(collection_table_popup_file_list(ct), FALSE);
798 static void collection_table_popup_sort_cb(GtkWidget *widget, gpointer data)
803 ct = submenu_item_get_data(widget);
807 type = (SortType)GPOINTER_TO_INT(data);
809 collection_set_sort_method(ct->cd, type);
812 static void collection_table_popup_randomize_cb(GtkWidget *widget, gpointer data)
816 ct = submenu_item_get_data(widget);
820 collection_randomize(ct->cd);
823 static void collection_table_popup_view_new_cb(GtkWidget *widget, gpointer data)
825 CollectTable *ct = data;
827 if (ct->click_info && g_list_find(ct->cd->list, ct->click_info))
829 view_window_new_from_collection(ct->cd, ct->click_info);
833 static void collection_table_popup_view_cb(GtkWidget *widget, gpointer data)
835 CollectTable *ct = data;
837 if (ct->click_info && g_list_find(ct->cd->list, ct->click_info))
839 layout_image_set_collection(NULL, ct->cd, ct->click_info);
843 static void collection_table_popup_selectall_cb(GtkWidget *widget, gpointer data)
845 CollectTable *ct = data;
847 collection_table_select_all(ct);
848 ct->prev_selection= ct->click_info;
851 static void collection_table_popup_unselectall_cb(GtkWidget *widget, gpointer data)
853 CollectTable *ct = data;
855 collection_table_unselect_all(ct);
856 ct->prev_selection= ct->click_info;
859 static void collection_table_popup_select_invert_cb(GtkWidget *widget, gpointer data)
861 CollectTable *ct = data;
863 collection_table_select_invert_all(ct);
864 ct->prev_selection= ct->click_info;
867 static void collection_table_popup_rectangular_selection_cb(GtkWidget *widget, gpointer data)
869 options->collections.rectangular_selection = !(options->collections.rectangular_selection);
872 static void collection_table_popup_remove_cb(GtkWidget *widget, gpointer data)
874 CollectTable *ct = data;
877 if (!ct->click_info) return;
879 if (INFO_SELECTED(ct->click_info))
881 list = g_list_copy(ct->selection);
885 list = g_list_append(NULL, ct->click_info);
888 collection_remove_by_info_list(ct->cd, list);
892 static void collection_table_popup_add_file_selection_cb(GtkWidget *widget, gpointer data)
894 CollectTable *ct = data;
896 LayoutWindow *lw = NULL;
898 if (!layout_valid(&lw)) return;
900 list = vf_selection_get_list(lw->vf);
904 collection_table_add_filelist(ct, list);
909 static void collection_table_popup_add_collection_cb(GtkWidget *widget, gpointer data)
911 CollectTable *ct = data;
913 collection_dialog_append(NULL, ct->cd);
916 static void collection_table_popup_goto_original_cb(GtkWidget *widget, gpointer data)
918 CollectTable *ct = data;
920 LayoutWindow *lw = NULL;
923 if (!layout_valid(&lw)) return;
924 list = collection_table_selection_get_list(ct);
930 layout_set_fd(lw, fd);
936 static void collection_table_popup_find_dupes_cb(GtkWidget *widget, gpointer data)
938 CollectTable *ct = data;
941 dw = dupe_window_new();
942 dupe_window_add_collection(dw, ct->cd);
945 static void collection_table_popup_print_cb(GtkWidget *widget, gpointer data)
947 CollectTable *ct = data;
950 fd = (ct->click_info) ? ct->click_info->fd : NULL;
952 print_window_new(fd, collection_table_selection_get_list(ct), collection_table_get_list(ct), gtk_widget_get_toplevel(ct->listview));
955 static void collection_table_popup_show_names_cb(GtkWidget *widget, gpointer data)
957 CollectTable *ct = data;
959 collection_table_toggle_filenames(ct);
962 static void collection_table_popup_show_stars_cb(GtkWidget *widget, gpointer data)
964 CollectTable *ct = data;
966 collection_table_toggle_stars(ct);
969 static void collection_table_popup_destroy_cb(GtkWidget *widget, gpointer data)
971 CollectTable *ct = data;
973 collection_table_selection_remove(ct, ct->click_info, SELECTION_PRELIGHT, NULL);
974 ct->click_info = NULL;
977 filelist_free(ct->drop_list);
978 ct->drop_list = NULL;
979 ct->drop_info = NULL;
981 filelist_free(ct->editmenu_fd_list);
982 ct->editmenu_fd_list = NULL;
985 static GtkWidget *collection_table_popup_menu(CollectTable *ct, gboolean over_icon)
990 GtkAccelGroup *accel_group;
992 menu = popup_menu_short_lived();
994 accel_group = gtk_accel_group_new();
995 gtk_menu_set_accel_group(GTK_MENU(menu), accel_group);
997 g_object_set_data(G_OBJECT(menu), "window_keys", collection_window_keys);
998 g_object_set_data(G_OBJECT(menu), "accel_group", accel_group);
1000 g_signal_connect(G_OBJECT(menu), "destroy",
1001 G_CALLBACK(collection_table_popup_destroy_cb), ct);
1003 menu_item_add_sensitive(menu, _("_View"), over_icon,
1004 G_CALLBACK(collection_table_popup_view_cb), ct);
1005 menu_item_add_stock_sensitive(menu, _("View in _new window"), GTK_STOCK_NEW, over_icon,
1006 G_CALLBACK(collection_table_popup_view_new_cb), ct);
1007 menu_item_add_stock(menu, _("Go to original"), GTK_STOCK_FIND,
1008 G_CALLBACK(collection_table_popup_goto_original_cb), ct);
1009 menu_item_add_divider(menu);
1010 menu_item_add_stock_sensitive(menu, _("Rem_ove"), GTK_STOCK_REMOVE, over_icon,
1011 G_CALLBACK(collection_table_popup_remove_cb), ct);
1013 menu_item_add_stock(menu, _("Append from file selection"), GTK_STOCK_ADD,
1014 G_CALLBACK(collection_table_popup_add_file_selection_cb), ct);
1015 menu_item_add_stock(menu, _("Append from collection..."), GTK_STOCK_OPEN,
1016 G_CALLBACK(collection_table_popup_add_collection_cb), ct);
1017 menu_item_add_divider(menu);
1019 item = menu_item_add(menu, _("_Selection"), NULL, NULL);
1020 submenu = gtk_menu_new();
1021 menu_item_add(submenu, _("Select all"),
1022 G_CALLBACK(collection_table_popup_selectall_cb), ct);
1023 menu_item_add(submenu, _("Select none"),
1024 G_CALLBACK(collection_table_popup_unselectall_cb), ct);
1025 menu_item_add(submenu, _("Invert selection"),
1026 G_CALLBACK(collection_table_popup_select_invert_cb), ct);
1027 menu_item_add_check(submenu, _("Rectangular selection"), (options->collections.rectangular_selection != FALSE),
1028 G_CALLBACK(collection_table_popup_rectangular_selection_cb), ct);
1029 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);
1030 menu_item_add_divider(menu);
1033 ct->editmenu_fd_list = collection_table_selection_get_list(ct);
1034 submenu_add_edit(menu, &item,
1035 G_CALLBACK(collection_table_popup_edit_cb), ct, ct->editmenu_fd_list);
1036 gtk_widget_set_sensitive(item, over_icon);
1038 menu_item_add_divider(menu);
1039 menu_item_add_stock_sensitive(menu, _("_Copy..."), GTK_STOCK_COPY, over_icon,
1040 G_CALLBACK(collection_table_popup_copy_cb), ct);
1041 menu_item_add_sensitive(menu, _("_Move..."), over_icon,
1042 G_CALLBACK(collection_table_popup_move_cb), ct);
1043 menu_item_add_sensitive(menu, _("_Rename..."), over_icon,
1044 G_CALLBACK(collection_table_popup_rename_cb), ct);
1045 menu_item_add_sensitive(menu, _("_Copy path"), over_icon,
1046 G_CALLBACK(collection_table_popup_copy_path_cb), ct);
1047 menu_item_add_sensitive(menu, _("_Copy path unquoted"), over_icon,
1048 G_CALLBACK(collection_table_popup_copy_path_unquoted_cb), ct);
1050 menu_item_add_divider(menu);
1051 menu_item_add_stock_sensitive(menu,
1052 options->file_ops.confirm_move_to_trash ? _("Move to Trash...") :
1053 _("Move to Trash"), PIXBUF_INLINE_ICON_TRASH, over_icon,
1054 G_CALLBACK(collection_table_popup_move_to_trash_cb), ct);
1055 menu_item_add_stock_sensitive(menu,
1056 options->file_ops.confirm_delete ? _("_Delete...") :
1057 _("_Delete"), GTK_STOCK_DELETE, over_icon,
1058 G_CALLBACK(collection_table_popup_delete_cb), ct);
1060 menu_item_add_divider(menu);
1061 submenu = submenu_add_sort(NULL, G_CALLBACK(collection_table_popup_sort_cb), ct, FALSE, TRUE, FALSE, 0);
1062 menu_item_add_divider(submenu);
1063 menu_item_add(submenu, _("Randomize"),
1064 G_CALLBACK(collection_table_popup_randomize_cb), ct);
1065 item = menu_item_add(menu, _("_Sort"), NULL, NULL);
1066 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);
1068 menu_item_add_check(menu, _("Show filename _text"), ct->show_text,
1069 G_CALLBACK(collection_table_popup_show_names_cb), ct);
1070 menu_item_add_check(menu, _("Show star rating"), ct->show_stars,
1071 G_CALLBACK(collection_table_popup_show_stars_cb), ct);
1072 menu_item_add_divider(menu);
1073 menu_item_add_stock(menu, _("_Save collection"), GTK_STOCK_SAVE,
1074 G_CALLBACK(collection_table_popup_save_cb), ct);
1075 menu_item_add_stock(menu, _("Save collection _as..."), GTK_STOCK_SAVE_AS,
1076 G_CALLBACK(collection_table_popup_save_as_cb), ct);
1077 menu_item_add_divider(menu);
1078 menu_item_add_stock(menu, _("_Find duplicates..."), GTK_STOCK_FIND,
1079 G_CALLBACK(collection_table_popup_find_dupes_cb), ct);
1080 menu_item_add_stock_sensitive(menu, _("Print..."), GTK_STOCK_PRINT, over_icon,
1081 G_CALLBACK(collection_table_popup_print_cb), ct);
1086 *-------------------------------------------------------------------
1087 * keyboard callbacks
1088 *-------------------------------------------------------------------
1091 void collection_table_set_focus(CollectTable *ct, CollectInfo *info)
1096 if (g_list_find(ct->cd->list, ct->focus_info))
1098 if (info == ct->focus_info)
1100 /* ensure focus row col are correct */
1101 collection_table_find_position(ct, ct->focus_info,
1102 &ct->focus_row, &ct->focus_column);
1105 collection_table_selection_remove(ct, ct->focus_info, SELECTION_FOCUS, NULL);
1108 if (!collection_table_find_position(ct, info, &row, &col))
1110 ct->focus_info = NULL;
1112 ct->focus_column = -1;
1116 ct->focus_info = info;
1117 ct->focus_row = row;
1118 ct->focus_column = col;
1119 collection_table_selection_add(ct, ct->focus_info, SELECTION_FOCUS, NULL);
1121 if (collection_table_find_iter(ct, ct->focus_info, &iter, NULL))
1124 GtkTreeViewColumn *column;
1125 GtkTreeModel *store;
1127 tree_view_row_make_visible(GTK_TREE_VIEW(ct->listview), &iter, FALSE);
1129 store = gtk_tree_view_get_model(GTK_TREE_VIEW(ct->listview));
1130 tpath = gtk_tree_model_get_path(store, &iter);
1131 /* focus is set to an extra column with 0 width to hide focus, we draw it ourself */
1132 column = gtk_tree_view_get_column(GTK_TREE_VIEW(ct->listview), COLLECT_TABLE_MAX_COLUMNS);
1133 gtk_tree_view_set_cursor(GTK_TREE_VIEW(ct->listview), tpath, column, FALSE);
1134 gtk_tree_path_free(tpath);
1138 static void collection_table_move_focus(CollectTable *ct, gint row, gint col, gboolean relative)
1145 new_row = ct->focus_row;
1146 new_col = ct->focus_column;
1149 if (new_row < 0) new_row = 0;
1150 if (new_row >= ct->rows) new_row = ct->rows - 1;
1170 new_col = ct->columns - 1;
1177 if (new_col >= ct->columns)
1179 if (new_row < ct->rows - 1)
1186 new_col = ct->columns - 1;
1196 if (new_row >= ct->rows)
1199 new_row = ct->rows - 1;
1202 new_col = ct->columns - 1;
1204 if (new_col >= ct->columns) new_col = ct->columns - 1;
1207 if (new_row == ct->rows - 1)
1211 /* if we moved beyond the last image, go to the last image */
1213 l = g_list_length(ct->cd->list);
1214 if (ct->rows > 1) l -= (ct->rows - 1) * ct->columns;
1215 if (new_col >= l) new_col = l - 1;
1218 if (new_row == -1 || new_col == -1)
1220 if (!ct->cd->list) return;
1221 new_row = new_col = 0;
1224 collection_table_set_focus(ct, collection_table_find_data(ct, new_row, new_col, NULL));
1227 static void collection_table_update_focus(CollectTable *ct)
1232 if (ct->focus_info && collection_table_find_position(ct, ct->focus_info, &new_row, &new_col))
1234 /* first find the old focus, if it exists and is valid */
1238 /* (try to) stay where we were */
1239 new_row = ct->focus_row;
1240 new_col = ct->focus_column;
1243 collection_table_move_focus(ct, new_row, new_col, FALSE);
1246 /* used to figure the page up/down distances */
1247 static gint page_height(CollectTable *ct)
1254 adj = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(ct->listview));
1255 page_size = (gint)gtk_adjustment_get_page_increment(adj);
1257 row_height = options->thumbnails.max_height + THUMB_BORDER_PADDING * 2;
1258 if (ct->show_text) row_height += options->thumbnails.max_height / 3;
1260 ret = page_size / row_height;
1261 if (ret < 1) ret = 1;
1266 static void collection_table_menu_pos_cb(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer data)
1268 CollectTable *ct = data;
1269 GtkTreeModel *store;
1275 if (!collection_table_find_iter(ct, ct->click_info, &iter, &column)) return;
1276 store = gtk_tree_view_get_model(GTK_TREE_VIEW(ct->listview));
1277 tpath = gtk_tree_model_get_path(store, &iter);
1278 tree_view_get_cell_clamped(GTK_TREE_VIEW(ct->listview), tpath, column, FALSE, x, y, &cw, &ch);
1279 gtk_tree_path_free(tpath);
1281 popup_menu_position_clamp(menu, x, y, 0);
1284 static gboolean collection_table_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
1286 CollectTable *ct = data;
1290 gboolean stop_signal = TRUE;
1292 switch (event->keyval)
1294 case GDK_KEY_Left: case GDK_KEY_KP_Left:
1297 case GDK_KEY_Right: case GDK_KEY_KP_Right:
1300 case GDK_KEY_Up: case GDK_KEY_KP_Up:
1303 case GDK_KEY_Down: case GDK_KEY_KP_Down:
1306 case GDK_KEY_Page_Up: case GDK_KEY_KP_Page_Up:
1307 focus_row = -page_height(ct);
1309 case GDK_KEY_Page_Down: case GDK_KEY_KP_Page_Down:
1310 focus_row = page_height(ct);
1312 case GDK_KEY_Home: case GDK_KEY_KP_Home:
1313 focus_row = -ct->focus_row;
1314 focus_col = -ct->focus_column;
1316 case GDK_KEY_End: case GDK_KEY_KP_End:
1317 focus_row = ct->rows - 1 - ct->focus_row;
1318 focus_col = ct->columns - 1 - ct->focus_column;
1321 info = collection_table_find_data(ct, ct->focus_row, ct->focus_column, NULL);
1324 ct->click_info = info;
1325 if (event->state & GDK_CONTROL_MASK)
1327 collection_table_select_util(ct, info, !INFO_SELECTED(info));
1331 collection_table_unselect_all(ct);
1332 collection_table_select(ct, info);
1337 if (event->state & GDK_CONTROL_MASK) collection_table_toggle_filenames(ct);
1341 info = collection_table_find_data(ct, ct->focus_row, ct->focus_column, NULL);
1342 ct->click_info = info;
1344 collection_table_selection_add(ct, ct->click_info, SELECTION_PRELIGHT, NULL);
1347 ct->popup = collection_table_popup_menu(ct, (info != NULL));
1348 gtk_menu_popup(GTK_MENU(ct->popup), NULL, NULL, collection_table_menu_pos_cb, ct, 0, GDK_CURRENT_TIME);
1351 stop_signal = FALSE;
1355 if (focus_row != 0 || focus_col != 0)
1357 CollectInfo *new_info;
1358 CollectInfo *old_info;
1360 old_info = collection_table_find_data(ct, ct->focus_row, ct->focus_column, NULL);
1361 collection_table_move_focus(ct, focus_row, focus_col, TRUE);
1362 new_info = collection_table_find_data(ct, ct->focus_row, ct->focus_column, NULL);
1364 if (new_info != old_info)
1366 if (event->state & GDK_SHIFT_MASK)
1368 if (!options->collections.rectangular_selection)
1370 collection_table_select_region_util(ct, old_info, new_info, FALSE);
1374 collection_table_select_region_util(ct, ct->click_info, old_info, FALSE);
1376 collection_table_select_region_util(ct, ct->click_info, new_info, TRUE);
1378 else if (event->state & GDK_CONTROL_MASK)
1380 ct->click_info = new_info;
1384 ct->click_info = new_info;
1385 collection_table_unselect_all(ct);
1386 collection_table_select(ct, new_info);
1400 *-------------------------------------------------------------------
1402 *-------------------------------------------------------------------
1405 static CollectInfo *collection_table_insert_find(CollectTable *ct, CollectInfo *source, gboolean *after, GdkRectangle *cell,
1406 gboolean use_coord, gint x, gint y)
1408 CollectInfo *info = NULL;
1409 GtkTreeModel *store;
1412 GtkTreeViewColumn *column;
1413 #if GTK_CHECK_VERSION(3,0,0)
1414 GdkDeviceManager *device_manager;
1418 store = gtk_tree_view_get_model(GTK_TREE_VIEW(ct->listview));
1420 #if GTK_CHECK_VERSION(3,0,0)
1423 device_manager = gdk_display_get_device_manager(gdk_window_get_display(
1424 gtk_widget_get_window(ct->listview)));
1425 device = gdk_device_manager_get_client_pointer(device_manager);
1426 gdk_window_get_device_position(gtk_widget_get_window(ct->listview),
1427 device, &x, &y, NULL);
1430 if (!use_coord) gdk_window_get_pointer(gtk_widget_get_window(ct->listview), &x, &y, NULL);
1435 if (collection_table_find_iter(ct, source, &iter, &col))
1437 tpath = gtk_tree_model_get_path(store, &iter);
1438 column = gtk_tree_view_get_column(GTK_TREE_VIEW(ct->listview), col);
1439 gtk_tree_view_get_background_area(GTK_TREE_VIEW(ct->listview), tpath, column, cell);
1440 gtk_tree_path_free(tpath);
1443 *after = !!(x > cell->x + (cell->width / 2));
1448 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(ct->listview), x, y,
1449 &tpath, &column, NULL, NULL))
1454 gtk_tree_model_get_iter(store, &iter, tpath);
1455 gtk_tree_model_get(store, &iter, CTABLE_COLUMN_POINTER, &list, -1);
1457 n = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(column), "column_number"));
1458 info = g_list_nth_data(list, n);
1462 gtk_tree_view_get_background_area(GTK_TREE_VIEW(ct->listview), tpath, column, cell);
1463 *after = !!(x > cell->x + (cell->width / 2));
1466 gtk_tree_path_free(tpath);
1473 work = g_list_last(ct->cd->list);
1481 if (collection_table_find_iter(ct, info, &iter, &col))
1483 tpath = gtk_tree_model_get_path(store, &iter);
1484 column = gtk_tree_view_get_column(GTK_TREE_VIEW(ct->listview), col);
1485 gtk_tree_view_get_background_area(GTK_TREE_VIEW(ct->listview), tpath, column, cell);
1486 gtk_tree_path_free(tpath);
1494 static CollectInfo *collection_table_insert_point(CollectTable *ct, gint x, gint y)
1498 gboolean after = FALSE;
1500 info = collection_table_insert_find(ct, NULL, &after, &cell, TRUE, x, y);
1506 work = g_list_find(ct->cd->list, info);
1507 if (work && work->next)
1509 info = work->next->data;
1520 static void collection_table_insert_marker(CollectTable *ct, CollectInfo *info, gboolean enable)
1522 gboolean after = FALSE;
1525 gint x_parent, y_parent;
1527 parent = gtk_widget_get_window(gtk_widget_get_toplevel(ct->listview));
1528 gdk_window_get_position(parent, &x_parent, &y_parent);
1532 if (ct->marker_window) gdk_window_destroy(ct->marker_window);
1533 ct->marker_window = NULL;
1538 info = collection_table_insert_find(ct, info, &after, &cell, FALSE, 0, 0);
1540 /* this setting does not take into account (after), but since it is not really used... */
1541 ct->marker_info = info;
1543 if (!ct->marker_window)
1545 GdkWindowAttr attributes;
1546 gint attributes_mask;
1547 GdkPixbuf *pb = gdk_pixbuf_new_from_xpm_data((const gchar **)marker_xpm);
1548 gint w = gdk_pixbuf_get_width(pb);
1549 gint h = gdk_pixbuf_get_height(pb);
1551 attributes.window_type = GDK_WINDOW_CHILD;
1552 attributes.wclass = GDK_INPUT_OUTPUT;
1553 attributes.width = w;
1554 attributes.height = h;
1555 attributes.event_mask = gtk_widget_get_events(ct->listview);
1556 attributes_mask = 0;
1558 ct->marker_window = gdk_window_new(NULL, &attributes, attributes_mask);
1560 #if GTK_CHECK_VERSION(3,0,0)
1561 cairo_region_t *mask;
1562 cairo_pattern_t *pattern;
1563 cairo_surface_t *img = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h);
1564 cairo_t *cr = cairo_create(img);
1565 gdk_cairo_set_source_pixbuf(cr, pb, 0, 0);
1567 /** @FIXME this is a hack to get the background color */
1568 //~ pattern = cairo_pattern_create_for_surface(img);
1569 pattern = cairo_pattern_create_rgb (1.0, 0.0, 0.0);
1570 mask = gdk_cairo_region_create_from_surface(img);
1571 gdk_window_shape_combine_region(ct->marker_window, mask, 0, 0);
1572 gdk_window_set_background_pattern(ct->marker_window, pattern);
1573 cairo_region_destroy(mask);
1574 cairo_pattern_destroy(pattern);
1576 cairo_surface_destroy(img);
1580 gdk_pixbuf_render_pixmap_and_mask(pb, &pixmap, &mask, 128);
1582 gdk_window_set_back_pixmap(ct->marker_window, pixmap, FALSE);
1583 gdk_window_shape_combine_mask(ct->marker_window, mask, 0, 0);
1585 g_object_unref(pixmap);
1586 if (mask) g_object_unref(mask);
1596 w = gdk_window_get_width(ct->marker_window);
1597 h = gdk_window_get_height(ct->marker_window);
1605 x = cell.x + cell.width;
1608 y = cell.y + (cell.height / 2) - (h / 2);
1613 gdk_window_move(ct->marker_window, x, y);
1614 #if !GTK_CHECK_VERSION(3,0,0)
1615 gdk_window_clear(ct->marker_window);
1617 if (!gdk_window_is_visible(ct->marker_window)) gdk_window_show(ct->marker_window);
1621 if (gdk_window_is_visible(ct->marker_window)) gdk_window_hide(ct->marker_window);
1626 *-------------------------------------------------------------------
1627 * mouse drag auto-scroll
1628 *-------------------------------------------------------------------
1631 static void collection_table_motion_update(CollectTable *ct, gint x, gint y, gboolean drop_event)
1635 info = collection_table_find_data_by_coord(ct, x, y, NULL);
1640 collection_table_insert_marker(ct, info, TRUE);
1644 tip_update(ct, info);
1648 static gboolean collection_table_auto_scroll_idle_cb(gpointer data)
1650 CollectTable *ct = data;
1654 #if GTK_CHECK_VERSION(3,0,0)
1655 GdkDeviceManager *device_manager;
1659 if (!ct->drop_idle_id) return FALSE;
1661 window = gtk_widget_get_window(ct->listview);
1662 #if GTK_CHECK_VERSION(3,0,0)
1663 device_manager = gdk_display_get_device_manager(gdk_window_get_display(window));
1664 device = gdk_device_manager_get_client_pointer(device_manager);
1665 gdk_window_get_device_position(window, device, &x, &y, NULL);
1667 gdk_window_get_pointer(window, &x, &y, NULL);
1669 w = gdk_window_get_width(window);
1670 h = gdk_window_get_height(window);
1671 if (x >= 0 && x < w && y >= 0 && y < h)
1673 collection_table_motion_update(ct, x, y, TRUE);
1676 ct->drop_idle_id = 0;
1680 static gboolean collection_table_auto_scroll_notify_cb(GtkWidget *widget, gint x, gint y, gpointer data)
1682 CollectTable *ct = data;
1684 if (!ct->drop_idle_id)
1686 ct->drop_idle_id = g_idle_add(collection_table_auto_scroll_idle_cb, ct);
1692 static void collection_table_scroll(CollectTable *ct, gboolean scroll)
1696 if (ct->drop_idle_id)
1698 g_source_remove(ct->drop_idle_id);
1699 ct->drop_idle_id = 0;
1701 widget_auto_scroll_stop(ct->listview);
1702 collection_table_insert_marker(ct, NULL, FALSE);
1706 GtkAdjustment *adj = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(ct->listview));
1707 widget_auto_scroll_start(ct->listview, adj, -1, options->thumbnails.max_height / 2,
1708 collection_table_auto_scroll_notify_cb, ct);
1713 *-------------------------------------------------------------------
1715 *-------------------------------------------------------------------
1718 static gboolean collection_table_motion_cb(GtkWidget *widget, GdkEventMotion *event, gpointer data)
1720 CollectTable *ct = data;
1722 collection_table_motion_update(ct, (gint)event->x, (gint)event->y, FALSE);
1727 static gboolean collection_table_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
1729 CollectTable *ct = data;
1735 info = collection_table_find_data_by_coord(ct, (gint)bevent->x, (gint)bevent->y, &iter);
1737 ct->click_info = info;
1738 collection_table_selection_add(ct, ct->click_info, SELECTION_PRELIGHT, &iter);
1740 switch (bevent->button)
1742 case MOUSE_BUTTON_LEFT:
1743 if (bevent->type == GDK_2BUTTON_PRESS)
1747 layout_image_set_collection(NULL, ct->cd, info);
1750 else if (!gtk_widget_has_focus(ct->listview))
1752 gtk_widget_grab_focus(ct->listview);
1755 case MOUSE_BUTTON_RIGHT:
1756 ct->popup = collection_table_popup_menu(ct, (info != NULL));
1757 gtk_menu_popup(GTK_MENU(ct->popup), NULL, NULL, NULL, NULL, bevent->button, bevent->time);
1766 static gboolean collection_table_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
1768 CollectTable *ct = data;
1770 CollectInfo *info = NULL;
1774 if ((gint)bevent->x != 0 || (gint)bevent->y != 0)
1776 info = collection_table_find_data_by_coord(ct, (gint)bevent->x, (gint)bevent->y, &iter);
1781 collection_table_selection_remove(ct, ct->click_info, SELECTION_PRELIGHT, NULL);
1784 if (bevent->button == MOUSE_BUTTON_LEFT &&
1785 info && ct->click_info == info)
1787 collection_table_set_focus(ct, info);
1789 if (bevent->state & GDK_CONTROL_MASK)
1791 gboolean select = !INFO_SELECTED(info);
1793 if ((bevent->state & GDK_SHIFT_MASK) && ct->prev_selection)
1795 collection_table_select_region_util(ct, ct->prev_selection, info, select);
1799 collection_table_select_util(ct, info, select);
1804 collection_table_unselect_all(ct);
1806 if ((bevent->state & GDK_SHIFT_MASK) &&
1809 collection_table_select_region_util(ct, ct->prev_selection, info, TRUE);
1813 collection_table_select_util(ct, info, TRUE);
1817 else if (bevent->button == MOUSE_BUTTON_MIDDLE &&
1818 info && ct->click_info == info)
1820 collection_table_select_util(ct, info, !INFO_SELECTED(info));
1826 static gboolean collection_table_leave_cb(GtkWidget *widget, GdkEventCrossing *event, gpointer data)
1828 CollectTable *ct = data;
1835 *-------------------------------------------------------------------
1836 * populate, add, insert, etc.
1837 *-------------------------------------------------------------------
1840 static gboolean collection_table_destroy_node_cb(GtkTreeModel *store, GtkTreePath *tpath, GtkTreeIter *iter, gpointer data)
1844 gtk_tree_model_get(store, iter, CTABLE_COLUMN_POINTER, &list, -1);
1850 static void collection_table_clear_store(CollectTable *ct)
1852 GtkTreeModel *store;
1854 store = gtk_tree_view_get_model(GTK_TREE_VIEW(ct->listview));
1855 gtk_tree_model_foreach(store, collection_table_destroy_node_cb, NULL);
1857 gtk_list_store_clear(GTK_LIST_STORE(store));
1860 static GList *collection_table_add_row(CollectTable *ct, GtkTreeIter *iter)
1862 GtkListStore *store;
1866 for (i = 0; i < ct->columns; i++) list = g_list_prepend(list, NULL);
1868 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(ct->listview)));
1869 gtk_list_store_append(store, iter);
1870 gtk_list_store_set(store, iter, CTABLE_COLUMN_POINTER, list, -1);
1875 static void collection_table_populate(CollectTable *ct, gboolean resize)
1880 collection_table_verify_selections(ct);
1882 collection_table_clear_store(ct);
1889 thumb_width = collection_table_get_icon_width(ct);
1891 for (i = 0; i < COLLECT_TABLE_MAX_COLUMNS; i++)
1893 GtkTreeViewColumn *column;
1894 GtkCellRenderer *cell;
1897 column = gtk_tree_view_get_column(GTK_TREE_VIEW(ct->listview), i);
1898 gtk_tree_view_column_set_visible(column, (i < ct->columns));
1899 gtk_tree_view_column_set_fixed_width(column, thumb_width + (THUMB_BORDER_PADDING * 6));
1901 list = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(column));
1902 cell = (list) ? list->data : NULL;
1905 if (cell && GQV_IS_CELL_RENDERER_ICON(cell))
1907 g_object_set(G_OBJECT(cell), "fixed_width", thumb_width,
1908 "fixed_height", options->thumbnails.max_height,
1909 "show_text", ct->show_text || ct->show_stars, NULL);
1912 if (gtk_widget_get_realized(ct->listview)) gtk_tree_view_columns_autosize(GTK_TREE_VIEW(ct->listview));
1916 work = ct->cd->list;
1924 list = collection_table_add_row(ct, &iter);
1925 while (work && list)
1927 list->data = work->data;
1935 collection_table_update_focus(ct);
1936 collection_table_update_status(ct);
1939 static void collection_table_populate_at_new_size(CollectTable *ct, gint w, gint h, gboolean force)
1944 thumb_width = collection_table_get_icon_width(ct);
1946 new_cols = w / (thumb_width + (THUMB_BORDER_PADDING * 6));
1947 if (new_cols < 1) new_cols = 1;
1949 if (!force && new_cols == ct->columns) return;
1951 ct->columns = new_cols;
1953 collection_table_populate(ct, TRUE);
1955 DEBUG_1("col tab pop cols=%d rows=%d", ct->columns, ct->rows);
1958 static void collection_table_sync(CollectTable *ct)
1960 GtkTreeModel *store;
1965 store = gtk_tree_view_get_model(GTK_TREE_VIEW(ct->listview));
1970 work = ct->cd->list;
1976 if (gtk_tree_model_iter_nth_child(store, &iter, NULL, r))
1978 gtk_tree_model_get(store, &iter, CTABLE_COLUMN_POINTER, &list, -1);
1979 gtk_list_store_set(GTK_LIST_STORE(store), &iter, CTABLE_COLUMN_POINTER, list, -1);
1983 list = collection_table_add_row(ct, &iter);
2008 while (gtk_tree_model_iter_nth_child(store, &iter, NULL, r))
2012 gtk_tree_model_get(store, &iter, CTABLE_COLUMN_POINTER, &list, -1);
2013 gtk_list_store_remove(GTK_LIST_STORE(store), &iter);
2019 collection_table_update_focus(ct);
2020 collection_table_update_status(ct);
2023 static gboolean collection_table_sync_idle_cb(gpointer data)
2025 CollectTable *ct = data;
2027 if (!ct->sync_idle_id) return FALSE;
2028 g_source_remove(ct->sync_idle_id);
2029 ct->sync_idle_id = 0;
2031 collection_table_sync(ct);
2035 static void collection_table_sync_idle(CollectTable *ct)
2037 if (!ct->sync_idle_id)
2039 /* high priority, the view needs to be resynced before a redraw
2040 * may contain invalid pointers at this time
2042 ct->sync_idle_id = g_idle_add_full(G_PRIORITY_HIGH, collection_table_sync_idle_cb, ct, NULL);
2046 void collection_table_add_filelist(CollectTable *ct, GList *list)
2055 collection_add(ct->cd, (FileData *)work->data, FALSE);
2060 static void collection_table_insert_filelist(CollectTable *ct, GList *list, CollectInfo *insert_info)
2069 collection_insert(ct->cd, (FileData *)work->data, insert_info, FALSE);
2073 collection_table_sync_idle(ct);
2076 static void collection_table_move_by_info_list(CollectTable *ct, GList *info_list, gint row, gint col)
2079 GList *insert_pos = NULL;
2083 if (!info_list) return;
2085 info = collection_table_find_data(ct, row, col, NULL);
2087 if (!info_list->next && info_list->data == info) return;
2089 if (info) insert_pos = g_list_find(ct->cd->list, info);
2091 /** @FIXME this may get slow for large lists */
2093 while (insert_pos && work)
2095 if (insert_pos->data == work->data)
2097 insert_pos = insert_pos->next;
2109 ct->cd->list = g_list_remove(ct->cd->list, work->data);
2113 /* place them back in */
2114 temp = g_list_copy(info_list);
2118 ct->cd->list = uig_list_insert_list(ct->cd->list, insert_pos, temp);
2122 ct->cd->list = g_list_concat(temp, ct->cd->list);
2126 ct->cd->list = g_list_concat(ct->cd->list, temp);
2129 ct->cd->changed = TRUE;
2131 collection_table_sync_idle(ct);
2136 *-------------------------------------------------------------------
2138 *-------------------------------------------------------------------
2141 void collection_table_file_update(CollectTable *ct, CollectInfo *info)
2149 collection_table_update_extras(ct, FALSE, 0.0);
2153 if (!collection_table_find_position(ct, info, &row, &col)) return;
2155 if (ct->columns != 0 && ct->rows != 0)
2157 value = (gdouble)(row * ct->columns + col) / (ct->columns * ct->rows);
2164 collection_table_update_extras(ct, TRUE, value);
2166 if (collection_table_find_iter(ct, info, &iter, NULL))
2168 GtkTreeModel *store;
2171 store = gtk_tree_view_get_model(GTK_TREE_VIEW(ct->listview));
2172 gtk_tree_model_get(store, &iter, CTABLE_COLUMN_POINTER, &list, -1);
2173 gtk_list_store_set(GTK_LIST_STORE(store), &iter, CTABLE_COLUMN_POINTER, list, -1);
2177 void collection_table_file_add(CollectTable *ct, CollectInfo *info)
2179 collection_table_sync_idle(ct);
2182 void collection_table_file_insert(CollectTable *ct, CollectInfo *ci)
2184 collection_table_sync_idle(ct);
2187 void collection_table_file_remove(CollectTable *ct, CollectInfo *ci)
2189 if (ci && INFO_SELECTED(ci))
2191 ct->selection = g_list_remove(ct->selection, ci);
2194 collection_table_sync_idle(ct);
2197 void collection_table_refresh(CollectTable *ct)
2199 collection_table_populate(ct, FALSE);
2203 *-------------------------------------------------------------------
2205 *-------------------------------------------------------------------
2208 static void collection_table_add_dir_recursive(CollectTable *ct, FileData *dir_fd, gboolean recursive)
2214 if (!filelist_read(dir_fd, &f, recursive ? &d : NULL))
2217 f = filelist_filter(f, FALSE);
2218 d = filelist_filter(d, TRUE);
2220 f = filelist_sort_path(f);
2221 d = filelist_sort_path(d);
2223 collection_table_insert_filelist(ct, f, ct->marker_info);
2225 work = g_list_last(d);
2228 collection_table_add_dir_recursive(ct, (FileData *)work->data, TRUE);
2236 static void confirm_dir_list_do(CollectTable *ct, GList *list, gboolean recursive)
2241 FileData *fd = work->data;
2243 if (isdir(fd->path)) collection_table_add_dir_recursive(ct, fd, recursive);
2245 collection_table_insert_filelist(ct, list, ct->marker_info);
2249 static void confirm_dir_list_add(GtkWidget *widget, gpointer data)
2251 CollectTable *ct = data;
2253 confirm_dir_list_do(ct, ct->drop_list, FALSE);
2256 static void confirm_dir_list_recurse(GtkWidget *widget, gpointer data)
2258 CollectTable *ct = data;
2260 confirm_dir_list_do(ct, ct->drop_list, TRUE);
2263 static void confirm_dir_list_skip(GtkWidget *widget, gpointer data)
2265 CollectTable *ct = data;
2267 collection_table_insert_filelist(ct, ct->drop_list, ct->marker_info);
2270 static GtkWidget *collection_table_drop_menu(CollectTable *ct)
2274 menu = popup_menu_short_lived();
2275 g_signal_connect(G_OBJECT(menu), "destroy",
2276 G_CALLBACK(collection_table_popup_destroy_cb), ct);
2278 menu_item_add_stock(menu, _("Dropped list includes folders."), GTK_STOCK_DND_MULTIPLE, NULL, NULL);
2279 menu_item_add_divider(menu);
2280 menu_item_add_stock(menu, _("_Add contents"), GTK_STOCK_OK,
2281 G_CALLBACK(confirm_dir_list_add), ct);
2282 menu_item_add_stock(menu, _("Add contents _recursive"), GTK_STOCK_ADD,
2283 G_CALLBACK(confirm_dir_list_recurse), ct);
2284 menu_item_add_stock(menu, _("_Skip folders"), GTK_STOCK_REMOVE,
2285 G_CALLBACK(confirm_dir_list_skip), ct);
2286 menu_item_add_divider(menu);
2287 menu_item_add_stock(menu, _("Cancel"), GTK_STOCK_CANCEL, NULL, ct);
2293 *-------------------------------------------------------------------
2295 *-------------------------------------------------------------------
2298 static GtkTargetEntry collection_drag_types[] = {
2299 { TARGET_APP_COLLECTION_MEMBER_STRING, 0, TARGET_APP_COLLECTION_MEMBER },
2300 { "text/uri-list", 0, TARGET_URI_LIST },
2301 { "text/plain", 0, TARGET_TEXT_PLAIN }
2303 static gint n_collection_drag_types = 3;
2305 static GtkTargetEntry collection_drop_types[] = {
2306 { TARGET_APP_COLLECTION_MEMBER_STRING, 0, TARGET_APP_COLLECTION_MEMBER },
2307 { "text/uri-list", 0, TARGET_URI_LIST }
2309 static gint n_collection_drop_types = 2;
2312 static void collection_table_dnd_get(GtkWidget *widget, GdkDragContext *context,
2313 GtkSelectionData *selection_data, guint info,
2314 guint time, gpointer data)
2316 CollectTable *ct = data;
2319 gchar *uri_text = NULL;
2322 if (!ct->click_info) return;
2324 selected = INFO_SELECTED(ct->click_info);
2328 case TARGET_APP_COLLECTION_MEMBER:
2331 uri_text = collection_info_list_to_dnd_data(ct->cd, ct->selection, &total);
2335 list = g_list_append(NULL, ct->click_info);
2336 uri_text = collection_info_list_to_dnd_data(ct->cd, list, &total);
2339 gtk_selection_data_set(selection_data, gtk_selection_data_get_target(selection_data),
2340 8, (guchar *)uri_text, total);
2343 case TARGET_URI_LIST:
2344 case TARGET_TEXT_PLAIN:
2348 list = collection_table_selection_get_list(ct);
2352 list = g_list_append(NULL, file_data_ref(ct->click_info->fd));
2356 uri_selection_data_set_uris_from_filelist(selection_data, list);
2357 filelist_free(list);
2363 static void collection_table_dnd_receive(GtkWidget *widget, GdkDragContext *context,
2365 GtkSelectionData *selection_data, guint info,
2366 guint time, gpointer data)
2368 CollectTable *ct = data;
2370 GList *info_list = NULL;
2371 CollectionData *source;
2372 CollectInfo *drop_info;
2375 DEBUG_1("%s", gtk_selection_data_get_data(selection_data));
2377 collection_table_scroll(ct, FALSE);
2378 collection_table_insert_marker(ct, NULL, FALSE);
2380 drop_info = collection_table_insert_point(ct, x, y);
2384 case TARGET_APP_COLLECTION_MEMBER:
2385 source = collection_from_dnd_data((gchar *)gtk_selection_data_get_data(selection_data), &list, &info_list);
2388 if (source == ct->cd)
2393 /* it is a move within a collection */
2394 filelist_free(list);
2399 collection_table_move_by_info_list(ct, info_list, -1, -1);
2401 else if (collection_table_find_position(ct, drop_info, &row, &col))
2403 collection_table_move_by_info_list(ct, info_list, row, col);
2408 /* it is a move/copy across collections */
2409 if (gdk_drag_context_get_selected_action(context) == GDK_ACTION_MOVE)
2411 collection_remove_by_info_list(source, info_list);
2414 g_list_free(info_list);
2417 case TARGET_URI_LIST:
2418 list = uri_filelist_from_gtk_selection_data(selection_data);
2422 FileData *fd = work->data;
2423 if (isdir(fd->path))
2427 ct->drop_list = list;
2428 ct->drop_info = drop_info;
2429 menu = collection_table_drop_menu(ct);
2430 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, time);
2443 collection_table_insert_filelist(ct, list, drop_info);
2444 filelist_free(list);
2448 static void collection_table_dnd_begin(GtkWidget *widget, GdkDragContext *context, gpointer data)
2450 CollectTable *ct = data;
2452 if (ct->click_info && ct->click_info->pixbuf)
2456 if (INFO_SELECTED(ct->click_info))
2457 items = g_list_length(ct->selection);
2460 dnd_set_drag_icon(widget, context, ct->click_info->pixbuf, items);
2464 static void collection_table_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer data)
2466 CollectTable *ct = data;
2468 /* apparently a leave event is not generated on a drop */
2471 collection_table_scroll(ct, FALSE);
2474 static gint collection_table_dnd_motion(GtkWidget *widget, GdkDragContext *context,
2475 gint x, gint y, guint time, gpointer data)
2477 CollectTable *ct = data;
2479 collection_table_motion_update(ct, x, y, TRUE);
2480 collection_table_scroll(ct, TRUE);
2485 static void collection_table_dnd_leave(GtkWidget *widget, GdkDragContext *context, guint time, gpointer data)
2487 CollectTable *ct = data;
2489 collection_table_scroll(ct, FALSE);
2492 static void collection_table_dnd_init(CollectTable *ct)
2494 gtk_drag_source_set(ct->listview, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
2495 collection_drag_types, n_collection_drag_types,
2496 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
2497 g_signal_connect(G_OBJECT(ct->listview), "drag_data_get",
2498 G_CALLBACK(collection_table_dnd_get), ct);
2499 g_signal_connect(G_OBJECT(ct->listview), "drag_begin",
2500 G_CALLBACK(collection_table_dnd_begin), ct);
2501 g_signal_connect(G_OBJECT(ct->listview), "drag_end",
2502 G_CALLBACK(collection_table_dnd_end), ct);
2504 gtk_drag_dest_set(ct->listview,
2505 GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP,
2506 collection_drop_types, n_collection_drop_types,
2507 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_ASK);
2508 g_signal_connect(G_OBJECT(ct->listview), "drag_motion",
2509 G_CALLBACK(collection_table_dnd_motion), ct);
2510 g_signal_connect(G_OBJECT(ct->listview), "drag_leave",
2511 G_CALLBACK(collection_table_dnd_leave), ct);
2512 g_signal_connect(G_OBJECT(ct->listview), "drag_data_received",
2513 G_CALLBACK(collection_table_dnd_receive), ct);
2517 *-----------------------------------------------------------------------------
2519 *-----------------------------------------------------------------------------
2522 typedef struct _ColumnData ColumnData;
2529 static void collection_table_cell_data_cb(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell,
2530 GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data)
2532 ColumnData *cd = data;
2539 gchar *star_rating = NULL;
2540 gchar *display_text = NULL;
2544 gtk_tree_model_get(tree_model, iter, CTABLE_COLUMN_POINTER, &list, -1);
2546 #if GTK_CHECK_VERSION(3,0,0)
2547 /** @FIXME this is a primitive hack to stop a crash.
2548 * When compiled with GTK3, if a Collection window containing
2549 * say, 50 or so, images has its width changed, there is a segfault
2550 * https://github.com/BestImageViewer/geeqie/issues/531
2552 if (cd->number == COLLECT_TABLE_MAX_COLUMNS) return;
2554 info = g_list_nth_data(list, cd->number);
2556 style = gtk_widget_get_style(ct->listview);
2557 if (info && (info->flag_mask & SELECTION_SELECTED) )
2559 memcpy(&color_fg, &style->text[GTK_STATE_SELECTED], sizeof(color_fg));
2560 memcpy(&color_bg, &style->base[GTK_STATE_SELECTED], sizeof(color_bg));
2564 memcpy(&color_fg, &style->text[GTK_STATE_NORMAL], sizeof(color_fg));
2565 memcpy(&color_bg, &style->base[GTK_STATE_NORMAL], sizeof(color_bg));
2568 if (info && (info->flag_mask & SELECTION_PRELIGHT))
2570 shift_color(&color_bg, -1, 0);
2573 if (ct->show_stars && info && info->fd)
2575 star_rating = metadata_read_rating_stars(info->fd);
2579 star_rating = g_strdup("");
2582 if (info && info->fd)
2584 if (ct->show_text && ct->show_stars)
2586 display_text = g_strconcat(info->fd->name, "\n", star_rating, NULL);
2588 else if (ct->show_text)
2590 display_text = g_strdup(info->fd->name);
2592 else if (ct->show_stars)
2594 display_text = g_strdup(star_rating);
2598 display_text = g_strdup("");
2603 display_text = g_strdup("");
2606 if (GQV_IS_CELL_RENDERER_ICON(cell))
2610 g_object_set(cell, "pixbuf", info->pixbuf,
2611 "text", display_text,
2612 "cell-background-gdk", &color_bg,
2613 "cell-background-set", TRUE,
2614 "foreground-gdk", &color_fg,
2615 "foreground-set", TRUE,
2616 "has-focus", (ct->focus_info == info), NULL);
2620 g_object_set(cell, "pixbuf", NULL,
2622 "cell-background-set", FALSE,
2623 "foreground-set", FALSE,
2624 "has-focus", FALSE, NULL);
2628 g_free(display_text);
2629 g_free(star_rating);
2632 static void collection_table_append_column(CollectTable *ct, gint n)
2635 GtkTreeViewColumn *column;
2636 GtkCellRenderer *renderer;
2638 column = gtk_tree_view_column_new();
2639 gtk_tree_view_column_set_min_width(column, 0);
2641 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
2642 gtk_tree_view_column_set_alignment(column, 0.5);
2644 renderer = gqv_cell_renderer_icon_new();
2645 gtk_tree_view_column_pack_start(column, renderer, FALSE);
2646 g_object_set(G_OBJECT(renderer), "xpad", THUMB_BORDER_PADDING * 2,
2647 "ypad", THUMB_BORDER_PADDING,
2648 "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE, NULL);
2650 g_object_set_data(G_OBJECT(column), "column_number", GINT_TO_POINTER(n));
2652 cd = g_new0(ColumnData, 1);
2655 gtk_tree_view_column_set_cell_data_func(column, renderer, collection_table_cell_data_cb, cd, g_free);
2657 gtk_tree_view_append_column(GTK_TREE_VIEW(ct->listview), column);
2661 *-------------------------------------------------------------------
2663 *-------------------------------------------------------------------
2666 static void collection_table_destroy(GtkWidget *widget, gpointer data)
2668 CollectTable *ct = data;
2670 /* If there is no unsaved data, save the window geometry
2672 if (!ct->cd->changed)
2674 if (!collection_save(ct->cd, ct->cd->path))
2676 log_printf("failed saving to collection path: %s\n", ct->cd->path);
2682 g_signal_handlers_disconnect_matched(G_OBJECT(ct->popup), G_SIGNAL_MATCH_DATA,
2684 gtk_widget_destroy(ct->popup);
2687 if (ct->sync_idle_id) g_source_remove(ct->sync_idle_id);
2690 collection_table_scroll(ct, FALSE);
2695 static void collection_table_sized(GtkWidget *widget, GtkAllocation *allocation, gpointer data)
2697 CollectTable *ct = data;
2699 collection_table_populate_at_new_size(ct, allocation->width, allocation->height, FALSE);
2702 CollectTable *collection_table_new(CollectionData *cd)
2705 GtkListStore *store;
2706 GtkTreeSelection *selection;
2709 ct = g_new0(CollectTable, 1);
2712 ct->show_text = options->show_icon_names;
2713 ct->show_stars = options->show_star_rating;
2715 ct->scrolled = gtk_scrolled_window_new(NULL, NULL);
2716 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(ct->scrolled), GTK_SHADOW_IN);
2717 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(ct->scrolled),
2718 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
2720 store = gtk_list_store_new(1, G_TYPE_POINTER);
2721 ct->listview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
2722 g_object_unref(store);
2724 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(ct->listview));
2725 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_NONE);
2727 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(ct->listview), FALSE);
2728 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(ct->listview), FALSE);
2730 for (i = 0; i < COLLECT_TABLE_MAX_COLUMNS; i++)
2732 collection_table_append_column(ct, i);
2735 /* zero width column to hide tree view focus, we draw it ourselves */
2736 collection_table_append_column(ct, i);
2737 /* end column to fill white space */
2738 collection_table_append_column(ct, i);
2740 g_signal_connect(G_OBJECT(ct->listview), "destroy",
2741 G_CALLBACK(collection_table_destroy), ct);
2742 g_signal_connect(G_OBJECT(ct->listview), "size_allocate",
2743 G_CALLBACK(collection_table_sized), ct);
2744 g_signal_connect(G_OBJECT(ct->listview), "key_press_event",
2745 G_CALLBACK(collection_table_press_key_cb), ct);
2747 gtk_container_add(GTK_CONTAINER(ct->scrolled), ct->listview);
2748 gtk_widget_show(ct->listview);
2750 collection_table_dnd_init(ct);
2752 gtk_widget_set_events(ct->listview, GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK |
2753 GDK_BUTTON_PRESS_MASK | GDK_LEAVE_NOTIFY_MASK);
2754 g_signal_connect(G_OBJECT(ct->listview),"button_press_event",
2755 G_CALLBACK(collection_table_press_cb), ct);
2756 g_signal_connect(G_OBJECT(ct->listview),"button_release_event",
2757 G_CALLBACK(collection_table_release_cb), ct);
2758 g_signal_connect(G_OBJECT(ct->listview),"motion_notify_event",
2759 G_CALLBACK(collection_table_motion_cb), ct);
2760 g_signal_connect(G_OBJECT(ct->listview), "leave_notify_event",
2761 G_CALLBACK(collection_table_leave_cb), ct);
2766 void collection_table_set_labels(CollectTable *ct, GtkWidget *status, GtkWidget *extra)
2768 ct->status_label = status;
2769 ct->extra_label = extra;
2770 collection_table_update_status(ct);
2771 collection_table_update_extras(ct, FALSE, 0.0);
2774 CollectInfo *collection_table_get_focus_info(CollectTable *ct)
2776 return collection_table_find_data(ct, ct->focus_row, ct->focus_column, NULL);
2779 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */