Include a Other Software section in Help file
[geeqie.git] / src / collect-table.c
index 61ae086..6bf85df 100644 (file)
@@ -1,16 +1,24 @@
 /*
- * Geeqie
- * (C) 2004 John Ellis
- * Copyright (C) 2008 - 2009 The Geeqie Team
+ * Copyright (C) 2004 John Ellis
+ * Copyright (C) 2008 - 2016 The Geeqie Team
  *
  * Author: John Ellis
  *
- * This software is released under the GNU General Public License (GNU GPL).
- * Please read the included file COPYING for more information.
- * This software comes with no warranty of any kind, use at your own risk!
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-
 #include "main.h"
 #include "collect-table.h"
 
 #include "layout.h"
 #include "layout_image.h"
 #include "menu.h"
+#include "metadata.h"
+#include "pixbuf_util.h"
 #include "print.h"
 #include "utilops.h"
 #include "ui_fileops.h"
 #include "ui_menu.h"
 #include "ui_tree_edit.h"
 #include "uri_utils.h"
+#include "view_file.h"
 
 #include "icons/marker.xpm"
 #define MARKER_WIDTH 26
@@ -54,14 +65,6 @@ enum {
        CTABLE_COLUMN_COUNT
 };
 
-typedef enum {
-       SELECTION_NONE          = 0,
-       SELECTION_SELECTED      = 1 << 0,
-       SELECTION_PRELIGHT      = 1 << 1,
-       SELECTION_FOCUS         = 1 << 2
-} SelectionType;
-
-
 #define INFO_SELECTED(x) (x->flag_mask & SELECTION_SELECTED)
 
 
@@ -244,10 +247,22 @@ static void collection_table_update_extras(CollectTable *ct, gboolean loading, g
 
 static void collection_table_toggle_filenames(CollectTable *ct)
 {
+       GtkAllocation allocation;
        ct->show_text = !ct->show_text;
        options->show_icon_names = ct->show_text;
 
-       collection_table_populate_at_new_size(ct, ct->listview->allocation.width, ct->listview->allocation.height, TRUE);
+       gtk_widget_get_allocation(ct->listview, &allocation);
+       collection_table_populate_at_new_size(ct, allocation.width, allocation.height, TRUE);
+}
+
+static void collection_table_toggle_stars(CollectTable *ct)
+{
+       GtkAllocation allocation;
+       ct->show_stars = !ct->show_stars;
+       options->show_star_rating = ct->show_stars;
+
+       gtk_widget_get_allocation(ct->listview, &allocation);
+       collection_table_populate_at_new_size(ct, allocation.width, allocation.height, TRUE);
 }
 
 static gint collection_table_get_icon_width(CollectTable *ct)
@@ -398,7 +413,7 @@ static void collection_table_select_invert_all(CollectTable *ct)
        collection_table_update_status(ct);
 }
 
-static void collection_table_select(CollectTable *ct, CollectInfo *info)
+void collection_table_select(CollectTable *ct, CollectInfo *info)
 {
        ct->prev_selection = info;
 
@@ -517,10 +532,23 @@ static void tip_show(CollectTable *ct)
 {
        GtkWidget *label;
        gint x, y;
+#if GTK_CHECK_VERSION(3,0,0)
+       GdkDisplay *display;
+       GdkDeviceManager *device_manager;
+       GdkDevice *device;
+#endif
 
        if (ct->tip_window) return;
 
-       gdk_window_get_pointer(ct->listview->window, &x, &y, NULL);
+#if GTK_CHECK_VERSION(3,0,0)
+       device_manager = gdk_display_get_device_manager(gdk_window_get_display(
+                                                               gtk_widget_get_window(ct->listview)));
+       device = gdk_device_manager_get_client_pointer(device_manager);
+       gdk_window_get_device_position(gtk_widget_get_window(ct->listview),
+                                                               device, &x, &y, NULL);
+#else
+       gdk_window_get_pointer(gtk_widget_get_window(ct->listview), &x, &y, NULL);
+#endif
 
        ct->tip_info = collection_table_find_data_by_coord(ct, x, y, NULL);
        if (!ct->tip_info) return;
@@ -535,9 +563,16 @@ static void tip_show(CollectTable *ct)
        gtk_container_add(GTK_CONTAINER(ct->tip_window), label);
        gtk_widget_show(label);
 
+#if GTK_CHECK_VERSION(3,0,0)
+       display = gdk_display_get_default();
+       device_manager = gdk_display_get_device_manager(display);
+       device = gdk_device_manager_get_client_pointer(device_manager);
+       gdk_device_get_position(device, NULL, &x, &y);
+#else
        gdk_window_get_pointer(NULL, &x, &y, NULL);
+#endif
 
-       if (!GTK_WIDGET_REALIZED(ct->tip_window)) gtk_widget_realize(ct->tip_window);
+       if (!gtk_widget_get_realized(ct->tip_window)) gtk_widget_realize(ct->tip_window);
        gtk_window_move(GTK_WINDOW(ct->tip_window), x + 16, y + 16);
        gtk_widget_show(ct->tip_window);
 }
@@ -586,13 +621,22 @@ static void tip_unschedule(CollectTable *ct)
 
 static void tip_update(CollectTable *ct, CollectInfo *info)
 {
+#if GTK_CHECK_VERSION(3,0,0)
+       GdkDisplay *display = gdk_display_get_default();
+       GdkDeviceManager *device_manager = gdk_display_get_device_manager(display);
+       GdkDevice *device = gdk_device_manager_get_client_pointer(device_manager);
+#endif
+
        tip_schedule(ct);
 
        if (ct->tip_window)
                {
                gint x, y;
-
+#if GTK_CHECK_VERSION(3,0,0)
+               gdk_device_get_position(device, NULL, &x, &y);
+#else
                gdk_window_get_pointer(NULL, &x, &y, NULL);
+#endif
                gtk_window_move(GTK_WINDOW(ct->tip_window), x + 16, y + 16);
 
                if (info != ct->tip_info)
@@ -690,6 +734,15 @@ static void collection_table_popup_delete_cb(GtkWidget *widget, gpointer data)
 {
        CollectTable *ct = data;
 
+       options->file_ops.safe_delete_enable = FALSE;
+       file_util_delete(NULL, collection_table_popup_file_list(ct), ct->listview);
+}
+
+static void collection_table_popup_move_to_trash_cb(GtkWidget *widget, gpointer data)
+{
+       CollectTable *ct = data;
+
+       options->file_ops.safe_delete_enable = TRUE;
        file_util_delete(NULL, collection_table_popup_file_list(ct), ct->listview);
 }
 
@@ -697,7 +750,14 @@ static void collection_table_popup_copy_path_cb(GtkWidget *widget, gpointer data
 {
        CollectTable *ct = data;
 
-       file_util_copy_path_list_to_clipboard(collection_table_popup_file_list(ct));
+       file_util_copy_path_list_to_clipboard(collection_table_popup_file_list(ct), TRUE);
+}
+
+static void collection_table_popup_copy_path_unquoted_cb(GtkWidget *widget, gpointer data)
+{
+       CollectTable *ct = data;
+
+       file_util_copy_path_list_to_clipboard(collection_table_popup_file_list(ct), FALSE);
 }
 
 static void collection_table_popup_sort_cb(GtkWidget *widget, gpointer data)
@@ -769,6 +829,11 @@ static void collection_table_popup_select_invert_cb(GtkWidget *widget, gpointer
        ct->prev_selection= ct->click_info;
 }
 
+static void collection_table_popup_rectangular_selection_cb(GtkWidget *widget, gpointer data)
+{
+       options->collections.rectangular_selection = !(options->collections.rectangular_selection);
+}
+
 static void collection_table_popup_remove_cb(GtkWidget *widget, gpointer data)
 {
        CollectTable *ct = data;
@@ -789,12 +854,15 @@ static void collection_table_popup_remove_cb(GtkWidget *widget, gpointer data)
        g_list_free(list);
 }
 
-static void collection_table_popup_add_filelist_cb(GtkWidget *widget, gpointer data)
+static void collection_table_popup_add_file_selection_cb(GtkWidget *widget, gpointer data)
 {
        CollectTable *ct = data;
        GList *list;
+       LayoutWindow *lw = NULL;
+
+       if (!layout_valid(&lw)) return;
 
-       list = layout_list(NULL);
+       list = vf_selection_get_list(lw->vf);
 
        if (list)
                {
@@ -810,12 +878,32 @@ static void collection_table_popup_add_collection_cb(GtkWidget *widget, gpointer
        collection_dialog_append(NULL, ct->cd);
 }
 
+static void collection_table_popup_goto_original_cb(GtkWidget *widget, gpointer data)
+{
+       CollectTable *ct = data;
+       GList *list;
+       LayoutWindow *lw = NULL;
+       FileData *fd;
+
+       if (!layout_valid(&lw)) return;
+       list = collection_table_selection_get_list(ct);
+       if (list)
+               {
+               fd = list->data;
+               if (fd)
+                       {
+                       layout_set_fd(lw, fd);
+                       }
+               }
+       g_list_free(list);
+}
+
 static void collection_table_popup_find_dupes_cb(GtkWidget *widget, gpointer data)
 {
        CollectTable *ct = data;
        DupeWindow *dw;
 
-       dw = dupe_window_new(DUPE_MATCH_NAME);
+       dw = dupe_window_new();
        dupe_window_add_collection(dw, ct->cd);
 }
 
@@ -826,7 +914,7 @@ static void collection_table_popup_print_cb(GtkWidget *widget, gpointer data)
 
        fd = (ct->click_info) ? ct->click_info->fd : NULL;
 
-       print_window_new(fd, collection_table_selection_get_list(ct), collection_table_get_list(ct), ct->listview);
+       print_window_new(fd, collection_table_selection_get_list(ct), collection_table_get_list(ct), gtk_widget_get_toplevel(ct->listview));
 }
 
 static void collection_table_popup_show_names_cb(GtkWidget *widget, gpointer data)
@@ -836,6 +924,13 @@ static void collection_table_popup_show_names_cb(GtkWidget *widget, gpointer dat
        collection_table_toggle_filenames(ct);
 }
 
+static void collection_table_popup_show_stars_cb(GtkWidget *widget, gpointer data)
+{
+       CollectTable *ct = data;
+
+       collection_table_toggle_stars(ct);
+}
+
 static void collection_table_popup_destroy_cb(GtkWidget *widget, gpointer data)
 {
        CollectTable *ct = data;
@@ -867,12 +962,14 @@ static GtkWidget *collection_table_popup_menu(CollectTable *ct, gboolean over_ic
                        G_CALLBACK(collection_table_popup_view_cb), ct);
        menu_item_add_stock_sensitive(menu, _("View in _new window"), GTK_STOCK_NEW, over_icon,
                        G_CALLBACK(collection_table_popup_view_new_cb), ct);
+       menu_item_add_stock(menu, _("Go to original"), GTK_STOCK_FIND,
+                       G_CALLBACK(collection_table_popup_goto_original_cb), ct);
        menu_item_add_divider(menu);
        menu_item_add_stock_sensitive(menu, _("Rem_ove"), GTK_STOCK_REMOVE, over_icon,
                        G_CALLBACK(collection_table_popup_remove_cb), ct);
 
-       menu_item_add_stock(menu, _("Append from file list"), GTK_STOCK_ADD,
-                       G_CALLBACK(collection_table_popup_add_filelist_cb), ct);
+       menu_item_add_stock(menu, _("Append from file selection"), GTK_STOCK_ADD,
+                       G_CALLBACK(collection_table_popup_add_file_selection_cb), ct);
        menu_item_add_stock(menu, _("Append from collection..."), GTK_STOCK_OPEN,
                        G_CALLBACK(collection_table_popup_add_collection_cb), ct);
        menu_item_add_divider(menu);
@@ -885,10 +982,12 @@ static GtkWidget *collection_table_popup_menu(CollectTable *ct, gboolean over_ic
                        G_CALLBACK(collection_table_popup_unselectall_cb), ct);
        menu_item_add(submenu, _("Invert selection"),
                        G_CALLBACK(collection_table_popup_select_invert_cb), ct);
+       menu_item_add_check(submenu, _("Rectangular selection"), (options->collections.rectangular_selection != FALSE),
+                       G_CALLBACK(collection_table_popup_rectangular_selection_cb), ct);
        gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);
        menu_item_add_divider(menu);
 
-       
+
        ct->editmenu_fd_list = collection_table_selection_get_list(ct);
        submenu_add_edit(menu, &item,
                        G_CALLBACK(collection_table_popup_edit_cb), ct, ct->editmenu_fd_list);
@@ -901,12 +1000,22 @@ static GtkWidget *collection_table_popup_menu(CollectTable *ct, gboolean over_ic
                        G_CALLBACK(collection_table_popup_move_cb), ct);
        menu_item_add_sensitive(menu, _("_Rename..."), over_icon,
                        G_CALLBACK(collection_table_popup_rename_cb), ct);
-       menu_item_add_stock_sensitive(menu, _("_Delete..."), GTK_STOCK_DELETE, over_icon,
-                       G_CALLBACK(collection_table_popup_delete_cb), ct);
        menu_item_add_sensitive(menu, _("_Copy path"), over_icon,
                                G_CALLBACK(collection_table_popup_copy_path_cb), ct);
+       menu_item_add_sensitive(menu, _("_Copy path unquoted"), over_icon,
+                               G_CALLBACK(collection_table_popup_copy_path_unquoted_cb), ct);
+
        menu_item_add_divider(menu);
+       menu_item_add_stock_sensitive(menu,
+                               options->file_ops.confirm_move_to_trash ? _("Move to Trash...") :
+                                       _("Move to Trash"), PIXBUF_INLINE_ICON_TRASH, over_icon,
+                               G_CALLBACK(collection_table_popup_move_to_trash_cb), ct);
+       menu_item_add_stock_sensitive(menu,
+                               options->file_ops.confirm_delete ? _("_Delete...") :
+                                       _("_Delete"), GTK_STOCK_DELETE, over_icon,
+                               G_CALLBACK(collection_table_popup_delete_cb), ct);
 
+       menu_item_add_divider(menu);
        submenu = submenu_add_sort(NULL, G_CALLBACK(collection_table_popup_sort_cb), ct, FALSE, TRUE, FALSE, 0);
        menu_item_add_divider(submenu);
        menu_item_add(submenu, _("Randomize"),
@@ -916,6 +1025,8 @@ static GtkWidget *collection_table_popup_menu(CollectTable *ct, gboolean over_ic
 
        menu_item_add_check(menu, _("Show filename _text"), ct->show_text,
                        G_CALLBACK(collection_table_popup_show_names_cb), ct);
+       menu_item_add_check(menu, _("Show star rating"), ct->show_stars,
+                               G_CALLBACK(collection_table_popup_show_stars_cb), ct);
        menu_item_add_divider(menu);
        menu_item_add_stock(menu, _("_Save collection"), GTK_STOCK_SAVE,
                        G_CALLBACK(collection_table_popup_save_cb), ct);
@@ -935,7 +1046,7 @@ static GtkWidget *collection_table_popup_menu(CollectTable *ct, gboolean over_ic
  *-------------------------------------------------------------------
  */
 
-static void collection_table_set_focus(CollectTable *ct, CollectInfo *info)
+void collection_table_set_focus(CollectTable *ct, CollectInfo *info)
 {
        GtkTreeIter iter;
        gint row, col;
@@ -1099,7 +1210,7 @@ static gint page_height(CollectTable *ct)
        gint ret;
 
        adj = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(ct->listview));
-       page_size = (gint)adj->page_increment;
+       page_size = (gint)gtk_adjustment_get_page_increment(adj);
 
        row_height = options->thumbnails.max_height + THUMB_BORDER_PADDING * 2;
        if (ct->show_text) row_height += options->thumbnails.max_height / 3;
@@ -1138,33 +1249,33 @@ static gboolean collection_table_press_key_cb(GtkWidget *widget, GdkEventKey *ev
 
        switch (event->keyval)
                {
-               case GDK_Left: case GDK_KP_Left:
+               case GDK_KEY_Left: case GDK_KEY_KP_Left:
                        focus_col = -1;
                        break;
-               case GDK_Right: case GDK_KP_Right:
+               case GDK_KEY_Right: case GDK_KEY_KP_Right:
                        focus_col = 1;
                        break;
-               case GDK_Up: case GDK_KP_Up:
+               case GDK_KEY_Up: case GDK_KEY_KP_Up:
                        focus_row = -1;
                        break;
-               case GDK_Down: case GDK_KP_Down:
+               case GDK_KEY_Down: case GDK_KEY_KP_Down:
                        focus_row = 1;
                        break;
-               case GDK_Page_Up: case GDK_KP_Page_Up:
+               case GDK_KEY_Page_Up: case GDK_KEY_KP_Page_Up:
                        focus_row = -page_height(ct);
                        break;
-               case GDK_Page_Down: case GDK_KP_Page_Down:
+               case GDK_KEY_Page_Down: case GDK_KEY_KP_Page_Down:
                        focus_row = page_height(ct);
                        break;
-               case GDK_Home: case GDK_KP_Home:
+               case GDK_KEY_Home: case GDK_KEY_KP_Home:
                        focus_row = -ct->focus_row;
                        focus_col = -ct->focus_column;
                        break;
-               case GDK_End: case GDK_KP_End:
+               case GDK_KEY_End: case GDK_KEY_KP_End:
                        focus_row = ct->rows - 1 - ct->focus_row;
                        focus_col = ct->columns - 1 - ct->focus_column;
                        break;
-               case GDK_space:
+               case GDK_KEY_space:
                        info = collection_table_find_data(ct, ct->focus_row, ct->focus_column, NULL);
                        if (info)
                                {
@@ -1183,8 +1294,8 @@ static gboolean collection_table_press_key_cb(GtkWidget *widget, GdkEventKey *ev
                case 'T': case 't':
                        if (event->state & GDK_CONTROL_MASK) collection_table_toggle_filenames(ct);
                        break;
-               case GDK_Menu:
-               case GDK_F10:
+               case GDK_KEY_Menu:
+               case GDK_KEY_F10:
                        info = collection_table_find_data(ct, ct->focus_row, ct->focus_column, NULL);
                        ct->click_info = info;
 
@@ -1237,9 +1348,6 @@ static gboolean collection_table_press_key_cb(GtkWidget *widget, GdkEventKey *ev
 
        if (stop_signal)
                {
-#if 0
-               g_signal_stop_emission_by_name(GTK_OBJECT(widget), "key_press_event");
-#endif
                tip_unschedule(ct);
                }
 
@@ -1260,11 +1368,25 @@ static CollectInfo *collection_table_insert_find(CollectTable *ct, CollectInfo *
        GtkTreeIter iter;
        GtkTreePath *tpath;
        GtkTreeViewColumn *column;
+#if GTK_CHECK_VERSION(3,0,0)
+       GdkDeviceManager *device_manager;
+       GdkDevice *device;
+#endif
 
        store = gtk_tree_view_get_model(GTK_TREE_VIEW(ct->listview));
 
-       if (!use_coord) gdk_window_get_pointer(ct->listview->window, &x, &y, NULL);
-
+#if GTK_CHECK_VERSION(3,0,0)
+       if (!use_coord)
+               {
+               device_manager = gdk_display_get_device_manager(gdk_window_get_display(
+                                                                       gtk_widget_get_window(ct->listview)));
+               device = gdk_device_manager_get_client_pointer(device_manager);
+               gdk_window_get_device_position(gtk_widget_get_window(ct->listview),
+                                                                       device, &x, &y, NULL);
+               }
+#else
+       if (!use_coord) gdk_window_get_pointer(gtk_widget_get_window(ct->listview), &x, &y, NULL);
+#endif
        if (source)
                {
                gint col;
@@ -1355,9 +1477,13 @@ static CollectInfo *collection_table_insert_point(CollectTable *ct, gint x, gint
 
 static void collection_table_insert_marker(CollectTable *ct, CollectInfo *info, gboolean enable)
 {
-       gint row, col;
        gboolean after = FALSE;
        GdkRectangle cell;
+       GdkWindow *parent;
+       gint x_parent, y_parent;
+
+       parent = gtk_widget_get_window(gtk_widget_get_toplevel(ct->listview));
+       gdk_window_get_position(parent, &x_parent, &y_parent);
 
        if (!enable)
                {
@@ -1372,26 +1498,13 @@ static void collection_table_insert_marker(CollectTable *ct, CollectInfo *info,
        /* this setting does not take into account (after), but since it is not really used... */
        ct->marker_info = info;
 
-       row = -1;
-       col = -1;
-
        if (!ct->marker_window)
                {
-               GdkWindow *parent;
                GdkWindowAttr attributes;
                gint attributes_mask;
-               GdkPixmap *pixmap;
-               GdkBitmap *mask;
-               GdkPixbuf *pb;
-               gint w, h;
-
-               parent = gtk_tree_view_get_bin_window(GTK_TREE_VIEW(ct->listview));
-
-               pb = gdk_pixbuf_new_from_xpm_data((const gchar **)marker_xpm);
-               gdk_pixbuf_render_pixmap_and_mask(pb, &pixmap, &mask, 128);
-               g_object_unref(pb);
-
-               gdk_drawable_get_size(pixmap, &w, &h);
+               GdkPixbuf *pb = gdk_pixbuf_new_from_xpm_data((const gchar **)marker_xpm);
+               gint w = gdk_pixbuf_get_width(pb);
+               gint h = gdk_pixbuf_get_height(pb);
 
                attributes.window_type = GDK_WINDOW_CHILD;
                attributes.wclass = GDK_INPUT_OUTPUT;
@@ -1400,12 +1513,37 @@ static void collection_table_insert_marker(CollectTable *ct, CollectInfo *info,
                attributes.event_mask = gtk_widget_get_events(ct->listview);
                attributes_mask = 0;
 
-               ct->marker_window = gdk_window_new(parent, &attributes, attributes_mask);
+               ct->marker_window = gdk_window_new(NULL, &attributes, attributes_mask);
+
+#if GTK_CHECK_VERSION(3,0,0)
+               cairo_region_t *mask;
+               cairo_pattern_t *pattern;
+               cairo_surface_t *img = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h);
+               cairo_t *cr = cairo_create(img);
+               gdk_cairo_set_source_pixbuf(cr, pb, 0, 0);
+               cairo_paint(cr);
+               /** @FIXME this is a hack to get the background color */
+               //~ pattern = cairo_pattern_create_for_surface(img);
+               pattern = cairo_pattern_create_rgb (1.0, 0.0, 0.0);
+               mask = gdk_cairo_region_create_from_surface(img);
+               gdk_window_shape_combine_region(ct->marker_window, mask, 0, 0);
+               gdk_window_set_background_pattern(ct->marker_window, pattern);
+               cairo_region_destroy(mask);
+               cairo_pattern_destroy(pattern);
+               cairo_destroy(cr);
+               cairo_surface_destroy(img);
+#else
+               GdkPixmap *pixmap;
+               GdkBitmap *mask;
+               gdk_pixbuf_render_pixmap_and_mask(pb, &pixmap, &mask, 128);
+
                gdk_window_set_back_pixmap(ct->marker_window, pixmap, FALSE);
                gdk_window_shape_combine_mask(ct->marker_window, mask, 0, 0);
 
                g_object_unref(pixmap);
                if (mask) g_object_unref(mask);
+#endif
+               g_object_unref(pb);
                }
 
        if (info)
@@ -1413,7 +1551,8 @@ static void collection_table_insert_marker(CollectTable *ct, CollectInfo *info,
                gint x, y;
                gint w, h;
 
-               gdk_drawable_get_size(ct->marker_window, &w, &h);
+               w = gdk_window_get_width(ct->marker_window);
+               h = gdk_window_get_height(ct->marker_window);
 
                if (!after)
                        {
@@ -1426,8 +1565,13 @@ static void collection_table_insert_marker(CollectTable *ct, CollectInfo *info,
                x -= (w / 2);
                y = cell.y + (cell.height / 2) - (h / 2);
 
+               x = x + x_parent;
+               y = y + y_parent;
+
                gdk_window_move(ct->marker_window, x, y);
+#if !GTK_CHECK_VERSION(3,0,0)
                gdk_window_clear(ct->marker_window);
+#endif
                if (!gdk_window_is_visible(ct->marker_window)) gdk_window_show(ct->marker_window);
                }
        else
@@ -1465,12 +1609,23 @@ static gboolean collection_table_auto_scroll_idle_cb(gpointer data)
        GdkWindow *window;
        gint x, y;
        gint w, h;
+#if GTK_CHECK_VERSION(3,0,0)
+       GdkDeviceManager *device_manager;
+       GdkDevice *device;
+#endif
 
        if (!ct->drop_idle_id) return FALSE;
 
-       window = ct->listview->window;
+       window = gtk_widget_get_window(ct->listview);
+#if GTK_CHECK_VERSION(3,0,0)
+       device_manager = gdk_display_get_device_manager(gdk_window_get_display(window));
+       device = gdk_device_manager_get_client_pointer(device_manager);
+       gdk_window_get_device_position(window, device, &x, &y, NULL);
+#else
        gdk_window_get_pointer(window, &x, &y, NULL);
-       gdk_drawable_get_size(window, &w, &h);
+#endif
+       w = gdk_window_get_width(window);
+       h = gdk_window_get_height(window);
        if (x >= 0 && x < w && y >= 0 && y < h)
                {
                collection_table_motion_update(ct, x, y, TRUE);
@@ -1518,11 +1673,11 @@ static void collection_table_scroll(CollectTable *ct, gboolean scroll)
  *-------------------------------------------------------------------
  */
 
-static gboolean collection_table_motion_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
+static gboolean collection_table_motion_cb(GtkWidget *widget, GdkEventMotion *event, gpointer data)
 {
        CollectTable *ct = data;
 
-       collection_table_motion_update(ct, (gint)bevent->x, (gint)bevent->y, FALSE);
+       collection_table_motion_update(ct, (gint)event->x, (gint)event->y, FALSE);
 
        return FALSE;
 }
@@ -1550,7 +1705,7 @@ static gboolean collection_table_press_cb(GtkWidget *widget, GdkEventButton *bev
                                        layout_image_set_collection(NULL, ct->cd, info);
                                        }
                                }
-                       else if (!GTK_WIDGET_HAS_FOCUS(ct->listview))
+                       else if (!gtk_widget_has_focus(ct->listview))
                                {
                                gtk_widget_grab_focus(ct->listview);
                                }
@@ -1701,11 +1856,7 @@ static void collection_table_populate(CollectTable *ct, gboolean resize)
                        gtk_tree_view_column_set_visible(column, (i < ct->columns));
                        gtk_tree_view_column_set_fixed_width(column, thumb_width + (THUMB_BORDER_PADDING * 6));
 
-#if GTK_CHECK_VERSION(2,18,0)
                        list = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(column));
-#else
-                       list = gtk_tree_view_column_get_cell_renderers(column);
-#endif
                        cell = (list) ? list->data : NULL;
                        g_list_free(list);
 
@@ -1713,10 +1864,10 @@ static void collection_table_populate(CollectTable *ct, gboolean resize)
                                {
                                g_object_set(G_OBJECT(cell), "fixed_width", thumb_width,
                                                             "fixed_height", options->thumbnails.max_height,
-                                                            "show_text", ct->show_text, NULL);
+                                                            "show_text", ct->show_text || ct->show_stars, NULL);
                                }
                        }
-               if (GTK_WIDGET_REALIZED(ct->listview)) gtk_tree_view_columns_autosize(GTK_TREE_VIEW(ct->listview));
+               if (gtk_widget_get_realized(ct->listview)) gtk_tree_view_columns_autosize(GTK_TREE_VIEW(ct->listview));
                }
 
        row = -1;
@@ -1895,7 +2046,7 @@ static void collection_table_move_by_info_list(CollectTable *ct, GList *info_lis
 
        if (info) insert_pos = g_list_find(ct->cd->list, info);
 
-       /* FIXME: this may get slow for large lists */
+       /** @FIXME this may get slow for large lists */
        work = info_list;
        while (insert_pos && work)
                {
@@ -2143,6 +2294,9 @@ static void collection_table_dnd_get(GtkWidget *widget, GdkDragContext *context,
                                uri_text = collection_info_list_to_dnd_data(ct->cd, list, &total);
                                g_list_free(list);
                                }
+                       gtk_selection_data_set(selection_data, gtk_selection_data_get_target(selection_data),
+                                               8, (guchar *)uri_text, total);
+                       g_free(uri_text);
                        break;
                case TARGET_URI_LIST:
                case TARGET_TEXT_PLAIN:
@@ -2157,14 +2311,10 @@ static void collection_table_dnd_get(GtkWidget *widget, GdkDragContext *context,
                                }
                        if (!list) return;
 
-                       uri_text = uri_text_from_filelist(list, &total, (info == TARGET_TEXT_PLAIN));
+                       uri_selection_data_set_uris_from_filelist(selection_data, list);
                        filelist_free(list);
                        break;
                }
-
-       gtk_selection_data_set(selection_data, selection_data->target,
-                              8, (guchar *)uri_text, total);
-       g_free(uri_text);
 }
 
 
@@ -2180,7 +2330,7 @@ static void collection_table_dnd_receive(GtkWidget *widget, GdkDragContext *cont
        CollectInfo *drop_info;
        GList *work;
 
-       DEBUG_1("%s", selection_data->data);
+       DEBUG_1("%s", gtk_selection_data_get_data(selection_data));
 
        collection_table_scroll(ct, FALSE);
        collection_table_insert_marker(ct, NULL, FALSE);
@@ -2190,7 +2340,7 @@ static void collection_table_dnd_receive(GtkWidget *widget, GdkDragContext *cont
        switch (info)
                {
                case TARGET_APP_COLLECTION_MEMBER:
-                       source = collection_from_dnd_data((gchar *)selection_data->data, &list, &info_list);
+                       source = collection_from_dnd_data((gchar *)gtk_selection_data_get_data(selection_data), &list, &info_list);
                        if (source)
                                {
                                if (source == ct->cd)
@@ -2214,7 +2364,7 @@ static void collection_table_dnd_receive(GtkWidget *widget, GdkDragContext *cont
                                else
                                        {
                                        /* it is a move/copy across collections */
-                                       if (context->action == GDK_ACTION_MOVE)
+                                       if (gdk_drag_context_get_selected_action(context) == GDK_ACTION_MOVE)
                                                {
                                                collection_remove_by_info_list(source, info_list);
                                                }
@@ -2223,7 +2373,7 @@ static void collection_table_dnd_receive(GtkWidget *widget, GdkDragContext *cont
                                }
                        break;
                case TARGET_URI_LIST:
-                       list = uri_filelist_from_text((gchar *)selection_data->data, TRUE);
+                       list = uri_filelist_from_gtk_selection_data(selection_data);
                        work = list;
                        while (work)
                                {
@@ -2344,10 +2494,21 @@ static void collection_table_cell_data_cb(GtkTreeViewColumn *tree_column, GtkCel
        CollectInfo *info;
        GdkColor color_fg;
        GdkColor color_bg;
+       gchar *star_rating = NULL;
+       gchar *display_text = NULL;
 
        ct = cd->ct;
 
        gtk_tree_model_get(tree_model, iter, CTABLE_COLUMN_POINTER, &list, -1);
+
+#if GTK_CHECK_VERSION(3,0,0)
+       /** @FIXME this is a primitive hack to stop a crash.
+        * When compiled with GTK3, if a Collection window containing
+        * say, 50 or so, images has its width changed, there is a segfault
+        * https://github.com/BestImageViewer/geeqie/issues/531
+        */
+       if (cd->number == COLLECT_TABLE_MAX_COLUMNS) return;
+#endif
        info = g_list_nth_data(list, cd->number);
 
        style = gtk_widget_get_style(ct->listview);
@@ -2364,18 +2525,48 @@ static void collection_table_cell_data_cb(GtkTreeViewColumn *tree_column, GtkCel
 
        if (info && (info->flag_mask & SELECTION_PRELIGHT))
                {
-#if 0
-               shift_color(&color_fg, -1, 0);
-#endif
                shift_color(&color_bg, -1, 0);
                }
 
+       if (ct->show_stars && info && info->fd)
+               {
+               star_rating = metadata_read_rating_stars(info->fd);
+               }
+       else
+               {
+               star_rating = g_strdup("");
+               }
+
+       if (info && info->fd)
+               {
+               if (ct->show_text && ct->show_stars)
+                       {
+                       display_text = g_strconcat(info->fd->name, "\n", star_rating, NULL);
+                       }
+               else if (ct->show_text)
+                       {
+                       display_text = g_strdup(info->fd->name);
+                       }
+               else if (ct->show_stars)
+                       {
+                       display_text = g_strdup(star_rating);
+                       }
+               else
+                       {
+                       display_text = g_strdup("");
+                       }
+               }
+       else
+               {
+               display_text = g_strdup("");
+               }
+
        if (GQV_IS_CELL_RENDERER_ICON(cell))
                {
                if (info)
                        {
                        g_object_set(cell,      "pixbuf", info->pixbuf,
-                                               "text", info->fd->name,
+                                               "text",  display_text,
                                                "cell-background-gdk", &color_bg,
                                                "cell-background-set", TRUE,
                                                "foreground-gdk", &color_fg,
@@ -2391,6 +2582,9 @@ static void collection_table_cell_data_cb(GtkTreeViewColumn *tree_column, GtkCel
                                                "has-focus", FALSE,  NULL);
                        }
                }
+
+       g_free(display_text);
+       g_free(star_rating);
 }
 
 static void collection_table_append_column(CollectTable *ct, gint n)
@@ -2431,9 +2625,19 @@ static void collection_table_destroy(GtkWidget *widget, gpointer data)
 {
        CollectTable *ct = data;
 
+       /* If there is no unsaved data, save the window geometry
+        */
+       if (!ct->cd->changed)
+               {
+               if (!collection_save(ct->cd, ct->cd->path))
+                       {
+                       log_printf("failed saving to collection path: %s\n", ct->cd->path);
+                       }
+               }
+
        if (ct->popup)
                {
-               g_signal_handlers_disconnect_matched(GTK_OBJECT(ct->popup), G_SIGNAL_MATCH_DATA,
+               g_signal_handlers_disconnect_matched(G_OBJECT(ct->popup), G_SIGNAL_MATCH_DATA,
                                                     0, 0, 0, NULL, ct);
                gtk_widget_destroy(ct->popup);
                }
@@ -2461,9 +2665,10 @@ CollectTable *collection_table_new(CollectionData *cd)
        gint i;
 
        ct = g_new0(CollectTable, 1);
-       
+
        ct->cd = cd;
        ct->show_text = options->show_icon_names;
+       ct->show_stars = options->show_star_rating;
 
        ct->scrolled = gtk_scrolled_window_new(NULL, NULL);
        gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(ct->scrolled), GTK_SHADOW_IN);