Use std::swap instead of temporary values
[geeqie.git] / src / collect-table.cc
index 99def0d..0d3016f 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "main.h"
 #include "collect-table.h"
 
+#include <cstddef>
+#include <utility>
+
+#include <cairo.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <gio/gio.h>
+#include <glib-object.h>
+
 #include "cellrenderericon.h"
 #include "collect-dlg.h"
 #include "collect-io.h"
+#include "collect.h"
+#include "compat.h"
+#include "debug.h"
 #include "dnd.h"
 #include "dupe.h"
 #include "filedata.h"
 #include "img-view.h"
-#include "layout.h"
+#include "intl.h"
 #include "layout-image.h"
+#include "layout.h"
+#include "main-defines.h"
 #include "menu.h"
 #include "metadata.h"
-#include "pixbuf-util.h"
+#include "misc.h"
+#include "options.h"
 #include "print.h"
-#include "utilops.h"
+#include "typedefs.h"
 #include "ui-fileops.h"
 #include "ui-menu.h"
 #include "ui-tree-edit.h"
 #include "uri-utils.h"
+#include "utilops.h"
 #include "view-file.h"
 
+namespace
+{
+
 /* between these, the icon width is increased by thumb_max_width / 2 */
-#define THUMB_MIN_ICON_WIDTH 128
-#define THUMB_MAX_ICON_WIDTH 150
+constexpr gint THUMB_MIN_ICON_WIDTH = 128;
+constexpr gint THUMB_MAX_ICON_WIDTH = 150;
 
-#define COLLECT_TABLE_MAX_COLUMNS 32
-#define THUMB_BORDER_PADDING 2
+constexpr gint COLLECT_TABLE_MAX_COLUMNS = 32;
 
-#define COLLECT_TABLE_TIP_DELAY 500
-#define COLLECT_TABLE_TIP_DELAY_PATH (COLLECT_TABLE_TIP_DELAY * 1.7)
+constexpr gint THUMB_BORDER_PADDING = 2;
 
+constexpr gint COLLECT_TABLE_TIP_DELAY = 500;
+constexpr gint COLLECT_TABLE_TIP_DELAY_PATH = 850;
 
 enum {
        CTABLE_COLUMN_POINTER = 0,
        CTABLE_COLUMN_COUNT
 };
 
-#define INFO_SELECTED(x) (x->flag_mask & SELECTION_SELECTED)
+struct ColumnData
+{
+       CollectTable *ct;
+       gint number;
+};
+
+inline gboolean info_selected(const CollectInfo *info)
+{
+       return info->flag_mask & SELECTION_SELECTED;
+}
 
+} // namespace
 
 static void collection_table_populate_at_new_size(CollectTable *ct, gint w, gint h, gboolean force);
 
@@ -95,6 +122,8 @@ hard_coded_window_keys collection_window_keys[] = {
        {static_cast<GdkModifierType>(0), 'B', N_("Sort by size")},
        {static_cast<GdkModifierType>(0), 'P', N_("Sort by path")},
        {GDK_SHIFT_MASK, 'P', N_("Print")},
+       {GDK_MOD1_MASK, 'A', N_("Append (Append collection dialog)")},
+       {GDK_MOD1_MASK, 'D', N_("Discard (Close modified collection dialog)")},
        {static_cast<GdkModifierType>(0), 0, nullptr}
 };
 
@@ -121,7 +150,8 @@ static gboolean collection_table_find_position(CollectTable *ct, CollectInfo *in
 static gboolean collection_table_find_iter(CollectTable *ct, CollectInfo *info, GtkTreeIter *iter, gint *column)
 {
        GtkTreeModel *store;
-       gint row, col;
+       gint row;
+       gint col;
 
        store = gtk_tree_view_get_model(GTK_TREE_VIEW(ct->listview));
        if (!collection_table_find_position(ct, info, &row, &col)) return FALSE;
@@ -420,7 +450,7 @@ static void collection_table_select_invert_all(CollectTable *ct)
                {
                auto info = static_cast<CollectInfo *>(work->data);
 
-               if (INFO_SELECTED(info))
+               if (info_selected(info))
                        {
                        collection_table_selection_remove(ct, info, SELECTION_SELECTED, nullptr);
                        }
@@ -444,7 +474,7 @@ void collection_table_select(CollectTable *ct, CollectInfo *info)
 {
        ct->prev_selection = info;
 
-       if (!info || INFO_SELECTED(info)) return;
+       if (!info || info_selected(info)) return;
 
        ct->selection = g_list_append(ct->selection, info);
        collection_table_selection_add(ct, info, SELECTION_SELECTED, nullptr);
@@ -456,7 +486,7 @@ static void collection_table_unselect(CollectTable *ct, CollectInfo *info)
 {
        ct->prev_selection = info;
 
-       if (!info || !INFO_SELECTED(info) ) return;
+       if (!info || !info_selected(info) ) return;
 
        ct->selection = g_list_remove(ct->selection, info);
        collection_table_selection_remove(ct, info, SELECTION_SELECTED, nullptr);
@@ -478,10 +508,12 @@ static void collection_table_select_util(CollectTable *ct, CollectInfo *info, gb
 
 static void collection_table_select_region_util(CollectTable *ct, CollectInfo *start, CollectInfo *end, gboolean select)
 {
-       gint row1, col1;
-       gint row2, col2;
-       gint t;
-       gint i, j;
+       gint row1;
+       gint col1;
+       gint row2;
+       gint col2;
+       gint i;
+       gint j;
 
        if (!collection_table_find_position(ct, start, &row1, &col1) ||
            !collection_table_find_position(ct, end, &row2, &col2) ) return;
@@ -516,15 +548,11 @@ static void collection_table_select_region_util(CollectTable *ct, CollectInfo *s
 
        if (row2 < row1)
                {
-               t = row1;
-               row1 = row2;
-               row2 = t;
+               std::swap(row1, row2);
                }
        if (col2 < col1)
                {
-               t = col1;
-               col1 = col2;
-               col2 = t;
+               std::swap(col1, col2);
                }
 
        DEBUG_1("table: %d x %d to %d x %d", row1, col1, row2, col2);
@@ -558,7 +586,8 @@ static GList *collection_table_get_list(CollectTable *ct)
 static void tip_show(CollectTable *ct)
 {
        GtkWidget *label;
-       gint x, y;
+       gint x;
+       gint y;
        GdkDisplay *display;
        GdkSeat *seat;
        GdkDevice *device;
@@ -580,7 +609,7 @@ static void tip_show(CollectTable *ct)
        label = gtk_label_new(ct->show_text ? ct->tip_info->fd->path : ct->tip_info->fd->name);
 
        g_object_set_data(G_OBJECT(ct->tip_window), "tip_label", label);
-       gtk_container_add(GTK_CONTAINER(ct->tip_window), label);
+       gq_gtk_container_add(GTK_WIDGET(ct->tip_window), label);
        gtk_widget_show(label);
 
        display = gdk_display_get_default();
@@ -589,13 +618,13 @@ static void tip_show(CollectTable *ct)
        gdk_device_get_position(device, nullptr, &x, &y);
 
        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);
+       gq_gtk_window_move(GTK_WINDOW(ct->tip_window), x + 16, y + 16);
        gtk_widget_show(ct->tip_window);
 }
 
 static void tip_hide(CollectTable *ct)
 {
-       if (ct->tip_window) gtk_widget_destroy(ct->tip_window);
+       if (ct->tip_window) gq_gtk_widget_destroy(ct->tip_window);
        ct->tip_window = nullptr;
 }
 
@@ -645,10 +674,11 @@ static void tip_update(CollectTable *ct, CollectInfo *info)
 
        if (ct->tip_window)
                {
-               gint x, y;
+               gint x;
+               gint y;
                gdk_device_get_position(device, nullptr, &x, &y);
 
-               gtk_window_move(GTK_WINDOW(ct->tip_window), x + 16, y + 16);
+               gq_gtk_window_move(GTK_WINDOW(ct->tip_window), x + 16, y + 16);
 
                if (info != ct->tip_info)
                        {
@@ -673,11 +703,11 @@ static void tip_update(CollectTable *ct, CollectInfo *info)
  *-------------------------------------------------------------------
  */
 
-static void collection_table_popup_save_as_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_save_as_cb(GtkWidget *, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
 
-       collection_dialog_save_as(nullptr, ct->cd);
+       collection_dialog_save_as(ct->cd);
 }
 
 static void collection_table_popup_save_cb(GtkWidget *widget, gpointer data)
@@ -700,7 +730,7 @@ static GList *collection_table_popup_file_list(CollectTable *ct)
 {
        if (!ct->click_info) return nullptr;
 
-       if (INFO_SELECTED(ct->click_info))
+       if (info_selected(ct->click_info))
                {
                return collection_table_selection_get_list(ct);
                }
@@ -720,28 +750,28 @@ static void collection_table_popup_edit_cb(GtkWidget *widget, gpointer data)
        file_util_start_editor_from_filelist(key, collection_table_popup_file_list(ct), nullptr, ct->listview);
 }
 
-static void collection_table_popup_copy_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_copy_cb(GtkWidget *, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
 
        file_util_copy(nullptr, collection_table_popup_file_list(ct), nullptr, ct->listview);
 }
 
-static void collection_table_popup_move_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_move_cb(GtkWidget *, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
 
        file_util_move(nullptr, collection_table_popup_file_list(ct), nullptr, ct->listview);
 }
 
-static void collection_table_popup_rename_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_rename_cb(GtkWidget *, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
 
        file_util_rename(nullptr, collection_table_popup_file_list(ct), ct->listview);
 }
 
-static void collection_table_popup_delete_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_delete_cb(GtkWidget *, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
 
@@ -749,7 +779,7 @@ static void collection_table_popup_delete_cb(GtkWidget *UNUSED(widget), gpointer
        file_util_delete(nullptr, collection_table_popup_file_list(ct), ct->listview);
 }
 
-static void collection_table_popup_move_to_trash_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_move_to_trash_cb(GtkWidget *, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
 
@@ -757,14 +787,14 @@ static void collection_table_popup_move_to_trash_cb(GtkWidget *UNUSED(widget), g
        file_util_delete(nullptr, collection_table_popup_file_list(ct), ct->listview);
 }
 
-static void collection_table_popup_copy_path_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_copy_path_cb(GtkWidget *, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
 
        file_util_copy_path_list_to_clipboard(collection_table_popup_file_list(ct), TRUE);
 }
 
-static void collection_table_popup_copy_path_unquoted_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_copy_path_unquoted_cb(GtkWidget *, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
 
@@ -785,7 +815,7 @@ static void collection_table_popup_sort_cb(GtkWidget *widget, gpointer data)
        collection_set_sort_method(ct->cd, type);
 }
 
-static void collection_table_popup_randomize_cb(GtkWidget *widget, gpointer UNUSED(data))
+static void collection_table_popup_randomize_cb(GtkWidget *widget, gpointer)
 {
        CollectTable *ct;
 
@@ -796,7 +826,7 @@ static void collection_table_popup_randomize_cb(GtkWidget *widget, gpointer UNUS
        collection_randomize(ct->cd);
 }
 
-static void collection_table_popup_view_new_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_view_new_cb(GtkWidget *, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
 
@@ -806,7 +836,7 @@ static void collection_table_popup_view_new_cb(GtkWidget *UNUSED(widget), gpoint
                }
 }
 
-static void collection_table_popup_view_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_view_cb(GtkWidget *, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
 
@@ -816,7 +846,7 @@ static void collection_table_popup_view_cb(GtkWidget *UNUSED(widget), gpointer d
                }
 }
 
-static void collection_table_popup_selectall_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_selectall_cb(GtkWidget *, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
 
@@ -824,7 +854,7 @@ static void collection_table_popup_selectall_cb(GtkWidget *UNUSED(widget), gpoin
        ct->prev_selection= ct->click_info;
 }
 
-static void collection_table_popup_unselectall_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_unselectall_cb(GtkWidget *, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
 
@@ -832,7 +862,7 @@ static void collection_table_popup_unselectall_cb(GtkWidget *UNUSED(widget), gpo
        ct->prev_selection= ct->click_info;
 }
 
-static void collection_table_popup_select_invert_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_select_invert_cb(GtkWidget *, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
 
@@ -840,19 +870,19 @@ static void collection_table_popup_select_invert_cb(GtkWidget *UNUSED(widget), g
        ct->prev_selection= ct->click_info;
 }
 
-static void collection_table_popup_rectangular_selection_cb(GtkWidget *UNUSED(widget), gpointer UNUSED(data))
+static void collection_table_popup_rectangular_selection_cb(GtkWidget *, gpointer)
 {
        options->collections.rectangular_selection = !(options->collections.rectangular_selection);
 }
 
-static void collection_table_popup_remove_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_remove_cb(GtkWidget *, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
        GList *list;
 
        if (!ct->click_info) return;
 
-       if (INFO_SELECTED(ct->click_info))
+       if (info_selected(ct->click_info))
                {
                list = g_list_copy(ct->selection);
                }
@@ -862,10 +892,11 @@ static void collection_table_popup_remove_cb(GtkWidget *UNUSED(widget), gpointer
                }
 
        collection_remove_by_info_list(ct->cd, list);
+       collection_table_refresh(ct);
        g_list_free(list);
 }
 
-static void collection_table_popup_add_file_selection_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_add_file_selection_cb(GtkWidget *, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
        GList *list;
@@ -882,14 +913,14 @@ static void collection_table_popup_add_file_selection_cb(GtkWidget *UNUSED(widge
                }
 }
 
-static void collection_table_popup_add_collection_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_add_collection_cb(GtkWidget *, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
 
-       collection_dialog_append(nullptr, ct->cd);
+       collection_dialog_append(ct->cd);
 }
 
-static void collection_table_popup_goto_original_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_goto_original_cb(GtkWidget *, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
        GList *list;
@@ -909,7 +940,7 @@ static void collection_table_popup_goto_original_cb(GtkWidget *UNUSED(widget), g
        g_list_free(list);
 }
 
-static void collection_table_popup_find_dupes_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_find_dupes_cb(GtkWidget *, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
        DupeWindow *dw;
@@ -918,7 +949,7 @@ static void collection_table_popup_find_dupes_cb(GtkWidget *UNUSED(widget), gpoi
        dupe_window_add_collection(dw, ct->cd);
 }
 
-static void collection_table_popup_print_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_print_cb(GtkWidget *, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
        FileData *fd;
@@ -928,21 +959,21 @@ static void collection_table_popup_print_cb(GtkWidget *UNUSED(widget), gpointer
        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 *UNUSED(widget), gpointer data)
+static void collection_table_popup_show_names_cb(GtkWidget *, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
 
        collection_table_toggle_filenames(ct);
 }
 
-static void collection_table_popup_show_stars_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_show_stars_cb(GtkWidget *, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
 
        collection_table_toggle_stars(ct);
 }
 
-static void collection_table_popup_destroy_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_popup_destroy_cb(GtkWidget *, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
 
@@ -978,17 +1009,17 @@ static GtkWidget *collection_table_popup_menu(CollectTable *ct, gboolean over_ic
 
        menu_item_add_sensitive(menu, _("_View"), over_icon,
                        G_CALLBACK(collection_table_popup_view_cb), ct);
-       menu_item_add_stock_sensitive(menu, _("View in _new window"), GTK_STOCK_NEW, over_icon,
+       menu_item_add_icon_sensitive(menu, _("View in _new window"), GQ_ICON_NEW, over_icon,
                        G_CALLBACK(collection_table_popup_view_new_cb), ct);
-       menu_item_add_stock(menu, _("Go to original"), GTK_STOCK_FIND,
+       menu_item_add_icon(menu, _("Go to original"), GQ_ICON_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,
+       menu_item_add_icon_sensitive(menu, _("Rem_ove"), GQ_ICON_REMOVE, over_icon,
                        G_CALLBACK(collection_table_popup_remove_cb), ct);
 
-       menu_item_add_stock(menu, _("Append from file selection"), GTK_STOCK_ADD,
+       menu_item_add_icon(menu, _("Append from file selection"), GQ_ICON_ADD,
                        G_CALLBACK(collection_table_popup_add_file_selection_cb), ct);
-       menu_item_add_stock(menu, _("Append from collection..."), GTK_STOCK_OPEN,
+       menu_item_add_icon(menu, _("Append from collection..."), GQ_ICON_OPEN,
                        G_CALLBACK(collection_table_popup_add_collection_cb), ct);
        menu_item_add_divider(menu);
 
@@ -1012,7 +1043,7 @@ static GtkWidget *collection_table_popup_menu(CollectTable *ct, gboolean over_ic
        gtk_widget_set_sensitive(item, over_icon);
 
        menu_item_add_divider(menu);
-       menu_item_add_stock_sensitive(menu, _("_Copy..."), GTK_STOCK_COPY, over_icon,
+       menu_item_add_icon_sensitive(menu, _("_Copy..."), GQ_ICON_COPY, over_icon,
                        G_CALLBACK(collection_table_popup_copy_cb), ct);
        menu_item_add_sensitive(menu, _("_Move..."), over_icon,
                        G_CALLBACK(collection_table_popup_move_cb), ct);
@@ -1024,13 +1055,13 @@ static GtkWidget *collection_table_popup_menu(CollectTable *ct, gboolean over_ic
                                G_CALLBACK(collection_table_popup_copy_path_unquoted_cb), ct);
 
        menu_item_add_divider(menu);
-       menu_item_add_stock_sensitive(menu,
+       menu_item_add_icon_sensitive(menu,
                                options->file_ops.confirm_move_to_trash ? _("Move to Trash...") :
-                                       _("Move to Trash"), PIXBUF_INLINE_ICON_TRASH, over_icon,
+                                       _("Move to Trash"), GQ_ICON_DELETE, over_icon,
                                G_CALLBACK(collection_table_popup_move_to_trash_cb), ct);
-       menu_item_add_stock_sensitive(menu,
+       menu_item_add_icon_sensitive(menu,
                                options->file_ops.confirm_delete ? _("_Delete...") :
-                                       _("_Delete"), GTK_STOCK_DELETE, over_icon,
+                                       _("_Delete"), GQ_ICON_DELETE_SHRED, over_icon,
                                G_CALLBACK(collection_table_popup_delete_cb), ct);
 
        menu_item_add_divider(menu);
@@ -1046,14 +1077,14 @@ static GtkWidget *collection_table_popup_menu(CollectTable *ct, gboolean over_ic
        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,
+       menu_item_add_icon(menu, _("_Save collection"), GQ_ICON_SAVE,
                        G_CALLBACK(collection_table_popup_save_cb), ct);
-       menu_item_add_stock(menu, _("Save collection _as..."), GTK_STOCK_SAVE_AS,
+       menu_item_add_icon(menu, _("Save collection _as..."), GQ_ICON_SAVE_AS,
                        G_CALLBACK(collection_table_popup_save_as_cb), ct);
        menu_item_add_divider(menu);
-       menu_item_add_stock(menu, _("_Find duplicates..."), GTK_STOCK_FIND,
+       menu_item_add_icon(menu, _("_Find duplicates..."), GQ_ICON_FIND,
                        G_CALLBACK(collection_table_popup_find_dupes_cb), ct);
-       menu_item_add_stock_sensitive(menu, _("Print..."), GTK_STOCK_PRINT, over_icon,
+       menu_item_add_icon_sensitive(menu, _("Print..."), GQ_ICON_PRINT, over_icon,
                        G_CALLBACK(collection_table_popup_print_cb), ct);
 
        return menu;
@@ -1067,7 +1098,8 @@ static GtkWidget *collection_table_popup_menu(CollectTable *ct, gboolean over_ic
 void collection_table_set_focus(CollectTable *ct, CollectInfo *info)
 {
        GtkTreeIter iter;
-       gint row, col;
+       gint row;
+       gint col;
 
        if (g_list_find(ct->cd->list, ct->focus_info))
                {
@@ -1227,7 +1259,7 @@ static gint page_height(CollectTable *ct)
        gint row_height;
        gint ret;
 
-       adj = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(ct->listview));
+       adj = gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(ct->listview));
        page_size = static_cast<gint>(gtk_adjustment_get_page_increment(adj));
 
        row_height = options->thumbnails.max_height + THUMB_BORDER_PADDING * 2;
@@ -1282,7 +1314,7 @@ static gboolean collection_table_press_key_cb(GtkWidget *widget, GdkEventKey *ev
                                ct->click_info = info;
                                if (event->state & GDK_CONTROL_MASK)
                                        {
-                                       collection_table_select_util(ct, info, !INFO_SELECTED(info));
+                                       collection_table_select_util(ct, info, !info_selected(info));
                                        }
                                else
                                        {
@@ -1475,11 +1507,11 @@ static void collection_table_insert_marker(CollectTable *ct, CollectInfo *info,
        gboolean after = FALSE;
        GdkRectangle cell;
        GdkWindow *parent;
-       gint x_parent, y_parent;
+       gint x_parent;
+       gint y_parent;
        GError *error = nullptr;
        GInputStream *in_stream;
        GdkPixbuf *pb;
-       gchar *path;
 
        parent = gtk_widget_get_window(gtk_widget_get_toplevel(ct->listview));
        gdk_window_get_position(parent, &x_parent, &y_parent);
@@ -1502,10 +1534,7 @@ static void collection_table_insert_marker(CollectTable *ct, CollectInfo *info,
                GdkWindowAttr attributes;
                gint attributes_mask;
 
-               path = g_build_filename(GQ_RESOURCE_PATH_ICONS, "gq-marker.xpm", NULL);
-               in_stream = g_resources_open_stream(path, G_RESOURCE_LOOKUP_FLAGS_NONE, &error);
-               g_free(path);
-
+               in_stream = g_resources_open_stream(GQ_RESOURCE_PATH_ICONS "/gq-marker.xpm", G_RESOURCE_LOOKUP_FLAGS_NONE, &error);
                pb = gdk_pixbuf_new_from_stream(in_stream, nullptr, &error);
                g_object_unref(in_stream);
 
@@ -1534,8 +1563,9 @@ static void collection_table_insert_marker(CollectTable *ct, CollectInfo *info,
                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);
+               /** @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);
@@ -1549,8 +1579,10 @@ static void collection_table_insert_marker(CollectTable *ct, CollectInfo *info,
 
        if (info)
                {
-               gint x, y;
-               gint w, h;
+               gint x;
+               gint y;
+               gint w;
+               gint h;
 
                w = gdk_window_get_width(ct->marker_window);
                h = gdk_window_get_height(ct->marker_window);
@@ -1606,8 +1638,10 @@ static gboolean collection_table_auto_scroll_idle_cb(gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
        GdkWindow *window;
-       gint x, y;
-       gint w, h;
+       gint x;
+       gint y;
+       gint w;
+       gint h;
        GdkSeat *seat;
        GdkDevice *device;
 
@@ -1629,7 +1663,7 @@ static gboolean collection_table_auto_scroll_idle_cb(gpointer data)
        return G_SOURCE_REMOVE;
 }
 
-static gboolean collection_table_auto_scroll_notify_cb(GtkWidget *UNUSED(widget), gint UNUSED(x), gint UNUSED(y), gpointer data)
+static gboolean collection_table_auto_scroll_notify_cb(GtkWidget *, gint, gint, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
 
@@ -1655,7 +1689,7 @@ static void collection_table_scroll(CollectTable *ct, gboolean scroll)
                }
        else
                {
-               GtkAdjustment *adj = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(ct->listview));
+               GtkAdjustment *adj = gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(ct->listview));
                widget_auto_scroll_start(ct->listview, adj, -1, options->thumbnails.max_height / 2,
                                         collection_table_auto_scroll_notify_cb, ct);
                }
@@ -1667,7 +1701,7 @@ static void collection_table_scroll(CollectTable *ct, gboolean scroll)
  *-------------------------------------------------------------------
  */
 
-static gboolean collection_table_motion_cb(GtkWidget *UNUSED(widget), GdkEventMotion *event, gpointer data)
+static gboolean collection_table_motion_cb(GtkWidget *, GdkEventMotion *event, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
 
@@ -1676,7 +1710,7 @@ static gboolean collection_table_motion_cb(GtkWidget *UNUSED(widget), GdkEventMo
        return FALSE;
 }
 
-static gboolean collection_table_press_cb(GtkWidget *UNUSED(widget), GdkEventButton *bevent, gpointer data)
+static gboolean collection_table_press_cb(GtkWidget *, GdkEventButton *bevent, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
        GtkTreeIter iter;
@@ -1715,7 +1749,7 @@ static gboolean collection_table_press_cb(GtkWidget *UNUSED(widget), GdkEventBut
        return TRUE;
 }
 
-static gboolean collection_table_release_cb(GtkWidget *UNUSED(widget), GdkEventButton *bevent, gpointer data)
+static gboolean collection_table_release_cb(GtkWidget *, GdkEventButton *bevent, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
        GtkTreeIter iter;
@@ -1740,7 +1774,7 @@ static gboolean collection_table_release_cb(GtkWidget *UNUSED(widget), GdkEventB
 
                if (bevent->state & GDK_CONTROL_MASK)
                        {
-                       gboolean select = !INFO_SELECTED(info);
+                       gboolean select = !info_selected(info);
 
                        if ((bevent->state & GDK_SHIFT_MASK) && ct->prev_selection)
                                {
@@ -1769,13 +1803,13 @@ static gboolean collection_table_release_cb(GtkWidget *UNUSED(widget), GdkEventB
        else if (bevent->button == MOUSE_BUTTON_MIDDLE &&
                 info && ct->click_info == info)
                {
-               collection_table_select_util(ct, info, !INFO_SELECTED(info));
+               collection_table_select_util(ct, info, !info_selected(info));
                }
 
        return TRUE;
 }
 
-static gboolean collection_table_leave_cb(GtkWidget *UNUSED(widget), GdkEventCrossing *UNUSED(event), gpointer data)
+static gboolean collection_table_leave_cb(GtkWidget *, GdkEventCrossing *, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
 
@@ -1789,7 +1823,7 @@ static gboolean collection_table_leave_cb(GtkWidget *UNUSED(widget), GdkEventCro
  *-------------------------------------------------------------------
  */
 
-static gboolean collection_table_destroy_node_cb(GtkTreeModel *store, GtkTreePath *UNUSED(tpath), GtkTreeIter *iter, gpointer UNUSED(data))
+static gboolean collection_table_destroy_node_cb(GtkTreeModel *store, GtkTreePath *, GtkTreeIter *iter, gpointer)
 {
        GList *list;
 
@@ -1888,7 +1922,7 @@ static void collection_table_populate(CollectTable *ct, gboolean resize)
        collection_table_update_status(ct);
 }
 
-static void collection_table_populate_at_new_size(CollectTable *ct, gint w, gint UNUSED(h), gboolean force)
+static void collection_table_populate_at_new_size(CollectTable *ct, gint w, gint, gboolean force)
 {
        gint new_cols;
        gint thumb_width;
@@ -1912,19 +1946,17 @@ static void collection_table_sync(CollectTable *ct)
        GtkTreeModel *store;
        GtkTreeIter iter;
        GList *work;
-       gint r, c;
+       gint r;
 
        store = gtk_tree_view_get_model(GTK_TREE_VIEW(ct->listview));
 
        r = -1;
-       c = 0;
 
        work = ct->cd->list;
        while (work)
                {
                GList *list;
                r++;
-               c = 0;
                if (gtk_tree_model_iter_nth_child(store, &iter, nullptr, r))
                        {
                        gtk_tree_model_get(store, &iter, CTABLE_COLUMN_POINTER, &list, -1);
@@ -1942,7 +1974,6 @@ static void collection_table_sync(CollectTable *ct)
                                {
                                info = static_cast<CollectInfo *>(work->data);
                                work = work->next;
-                               c++;
                                }
                        else
                                {
@@ -2093,7 +2124,8 @@ static void collection_table_move_by_info_list(CollectTable *ct, GList *info_lis
 void collection_table_file_update(CollectTable *ct, CollectInfo *info)
 {
        GtkTreeIter iter;
-       gint row, col;
+       gint row;
+       gint col;
        gdouble value;
 
        if (!info)
@@ -2126,19 +2158,19 @@ void collection_table_file_update(CollectTable *ct, CollectInfo *info)
                }
 }
 
-void collection_table_file_add(CollectTable *ct, CollectInfo *UNUSED(info))
+void collection_table_file_add(CollectTable *ct, CollectInfo *)
 {
        collection_table_sync_idle(ct);
 }
 
-void collection_table_file_insert(CollectTable *ct, CollectInfo *UNUSED(ci))
+void collection_table_file_insert(CollectTable *ct, CollectInfo *)
 {
        collection_table_sync_idle(ct);
 }
 
 void collection_table_file_remove(CollectTable *ct, CollectInfo *ci)
 {
-       if (ci && INFO_SELECTED(ci))
+       if (ci && info_selected(ci))
                {
                ct->selection = g_list_remove(ct->selection, ci);
                }
@@ -2198,21 +2230,21 @@ static void confirm_dir_list_do(CollectTable *ct, GList *list, gboolean recursiv
 }
 
 
-static void confirm_dir_list_add(GtkWidget *UNUSED(widget), gpointer data)
+static void confirm_dir_list_add(GtkWidget *, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
 
        confirm_dir_list_do(ct, ct->drop_list, FALSE);
 }
 
-static void confirm_dir_list_recurse(GtkWidget *UNUSED(widget), gpointer data)
+static void confirm_dir_list_recurse(GtkWidget *, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
 
        confirm_dir_list_do(ct, ct->drop_list, TRUE);
 }
 
-static void confirm_dir_list_skip(GtkWidget *UNUSED(widget), gpointer data)
+static void confirm_dir_list_skip(GtkWidget *, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
 
@@ -2227,16 +2259,16 @@ static GtkWidget *collection_table_drop_menu(CollectTable *ct)
        g_signal_connect(G_OBJECT(menu), "destroy",
                         G_CALLBACK(collection_table_popup_destroy_cb), ct);
 
-       menu_item_add_stock(menu, _("Dropped list includes folders."), GTK_STOCK_DND_MULTIPLE, nullptr, nullptr);
+       menu_item_add_stock(menu, _("Dropped list includes folders."), GQ_ICON_DND, nullptr, nullptr);
        menu_item_add_divider(menu);
-       menu_item_add_stock(menu, _("_Add contents"), GTK_STOCK_OK,
+       menu_item_add_icon(menu, _("_Add contents"), GQ_ICON_OK,
                            G_CALLBACK(confirm_dir_list_add), ct);
-       menu_item_add_stock(menu, _("Add contents _recursive"), GTK_STOCK_ADD,
+       menu_item_add_icon(menu, _("Add contents _recursive"), GQ_ICON_ADD,
                            G_CALLBACK(confirm_dir_list_recurse), ct);
-       menu_item_add_stock(menu, _("_Skip folders"), GTK_STOCK_REMOVE,
+       menu_item_add_icon(menu, _("_Skip folders"), GQ_ICON_REMOVE,
                            G_CALLBACK(confirm_dir_list_skip), ct);
        menu_item_add_divider(menu);
-       menu_item_add_stock(menu, _("Cancel"), GTK_STOCK_CANCEL, nullptr, ct);
+       menu_item_add_icon(menu, _("Cancel"), GQ_ICON_CANCEL, nullptr, ct);
 
        return menu;
 }
@@ -2261,9 +2293,9 @@ static GtkTargetEntry collection_drop_types[] = {
 static gint n_collection_drop_types = 2;
 
 
-static void collection_table_dnd_get(GtkWidget *UNUSED(widget), GdkDragContext *UNUSED(context),
+static void collection_table_dnd_get(GtkWidget *, GdkDragContext *,
                                     GtkSelectionData *selection_data, guint info,
-                                    guint UNUSED(time), gpointer data)
+                                    guint, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
        gboolean selected;
@@ -2273,7 +2305,7 @@ static void collection_table_dnd_get(GtkWidget *UNUSED(widget), GdkDragContext *
 
        if (!ct->click_info) return;
 
-       selected = INFO_SELECTED(ct->click_info);
+       selected = info_selected(ct->click_info);
 
        switch (info)
                {
@@ -2312,10 +2344,10 @@ static void collection_table_dnd_get(GtkWidget *UNUSED(widget), GdkDragContext *
 }
 
 
-static void collection_table_dnd_receive(GtkWidget *UNUSED(widget), GdkDragContext *context,
+static void collection_table_dnd_receive(GtkWidget *, GdkDragContext *context,
                                          gint x, gint y,
                                          GtkSelectionData *selection_data, guint info,
-                                         guint UNUSED(time), gpointer data)
+                                         guint, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
        GList *list = nullptr;
@@ -2405,7 +2437,7 @@ static void collection_table_dnd_begin(GtkWidget *widget, GdkDragContext *contex
                {
                gint items;
 
-               if (INFO_SELECTED(ct->click_info))
+               if (info_selected(ct->click_info))
                        items = g_list_length(ct->selection);
                else
                        items = 1;
@@ -2413,7 +2445,7 @@ static void collection_table_dnd_begin(GtkWidget *widget, GdkDragContext *contex
                }
 }
 
-static void collection_table_dnd_end(GtkWidget *UNUSED(widget), GdkDragContext *UNUSED(context), gpointer data)
+static void collection_table_dnd_end(GtkWidget *, GdkDragContext *, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
 
@@ -2423,8 +2455,7 @@ static void collection_table_dnd_end(GtkWidget *UNUSED(widget), GdkDragContext *
        collection_table_scroll(ct, FALSE);
 }
 
-static gint collection_table_dnd_motion(GtkWidget *UNUSED(widget), GdkDragContext *UNUSED(context),
-                                       gint x, gint y, guint UNUSED(time), gpointer data)
+static gint collection_table_dnd_motion(GtkWidget *, GdkDragContext *, gint x, gint y, guint, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
 
@@ -2434,7 +2465,7 @@ static gint collection_table_dnd_motion(GtkWidget *UNUSED(widget), GdkDragContex
        return FALSE;
 }
 
-static void collection_table_dnd_leave(GtkWidget *UNUSED(widget), GdkDragContext *UNUSED(context), guint UNUSED(time), gpointer data)
+static void collection_table_dnd_leave(GtkWidget *, GdkDragContext *, guint, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
 
@@ -2471,24 +2502,18 @@ static void collection_table_dnd_init(CollectTable *ct)
  *-----------------------------------------------------------------------------
  */
 
-struct ColumnData
-{
-       CollectTable *ct;
-       gint number;
-};
-
-static void collection_table_cell_data_cb(GtkTreeViewColumn *UNUSED(tree_column), GtkCellRenderer *cell,
+static void collection_table_cell_data_cb(GtkTreeViewColumn *, GtkCellRenderer *cell,
                                          GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data)
 {
        auto cd = static_cast<ColumnData *>(data);
-       CollectTable *ct;
-       GtkStyle *style;
-       GList *list;
        CollectInfo *info;
-       GdkColor color_fg;
-       GdkColor color_bg;
-       gchar *star_rating = nullptr;
+       CollectTable *ct;
        gchar *display_text = nullptr;
+       gchar *star_rating = nullptr;
+       GdkRGBA color_bg;
+       GdkRGBA color_fg;
+       GList *list;
+       GtkStyle *style;
 
        ct = cd->ct;
 
@@ -2506,13 +2531,13 @@ static void collection_table_cell_data_cb(GtkTreeViewColumn *UNUSED(tree_column)
        style = gtk_widget_get_style(ct->listview);
        if (info && (info->flag_mask & SELECTION_SELECTED) )
                {
-               memcpy(&color_fg, &style->text[GTK_STATE_SELECTED], sizeof(color_fg));
-               memcpy(&color_bg, &style->base[GTK_STATE_SELECTED], sizeof(color_bg));
+               convert_gdkcolor_to_gdkrgba(&style->text[GTK_STATE_SELECTED], &color_fg);
+               convert_gdkcolor_to_gdkrgba(&style->base[GTK_STATE_SELECTED], &color_bg);
                }
        else
                {
-               memcpy(&color_fg, &style->text[GTK_STATE_NORMAL], sizeof(color_fg));
-               memcpy(&color_bg, &style->base[GTK_STATE_NORMAL], sizeof(color_bg));
+               convert_gdkcolor_to_gdkrgba(&style->text[GTK_STATE_NORMAL], &color_fg);
+               convert_gdkcolor_to_gdkrgba(&style->base[GTK_STATE_NORMAL], &color_bg);
                }
 
        if (info && (info->flag_mask & SELECTION_PRELIGHT))
@@ -2559,9 +2584,9 @@ static void collection_table_cell_data_cb(GtkTreeViewColumn *UNUSED(tree_column)
                        {
                        g_object_set(cell,      "pixbuf", info->pixbuf,
                                                "text",  display_text,
-                                               "cell-background-gdk", &color_bg,
+                                               "cell-background-rgba", &color_bg,
                                                "cell-background-set", TRUE,
-                                               "foreground-gdk", &color_fg,
+                                               "foreground-rgba", &color_fg,
                                                "foreground-set", TRUE,
                                                "has-focus", (ct->focus_info == info), NULL);
                        }
@@ -2613,7 +2638,7 @@ static void collection_table_append_column(CollectTable *ct, gint n)
  *-------------------------------------------------------------------
  */
 
-static void collection_table_destroy(GtkWidget *UNUSED(widget), gpointer data)
+static void collection_table_destroy(GtkWidget *, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
 
@@ -2631,7 +2656,7 @@ static void collection_table_destroy(GtkWidget *UNUSED(widget), gpointer data)
                {
                g_signal_handlers_disconnect_matched(G_OBJECT(ct->popup), G_SIGNAL_MATCH_DATA,
                                                     0, 0, nullptr, nullptr, ct);
-               gtk_widget_destroy(ct->popup);
+               gq_gtk_widget_destroy(ct->popup);
                }
 
        if (ct->sync_idle_id) g_source_remove(ct->sync_idle_id);
@@ -2642,7 +2667,7 @@ static void collection_table_destroy(GtkWidget *UNUSED(widget), gpointer data)
        g_free(ct);
 }
 
-static void collection_table_sized(GtkWidget *UNUSED(widget), GtkAllocation *allocation, gpointer data)
+static void collection_table_sized(GtkWidget *, GtkAllocation *allocation, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
 
@@ -2662,8 +2687,8 @@ CollectTable *collection_table_new(CollectionData *cd)
        ct->show_text = options->show_icon_names;
        ct->show_stars = options->show_star_rating;
 
-       ct->scrolled = gtk_scrolled_window_new(nullptr, nullptr);
-       gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(ct->scrolled), GTK_SHADOW_IN);
+       ct->scrolled = gq_gtk_scrolled_window_new(nullptr, nullptr);
+       gq_gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(ct->scrolled), GTK_SHADOW_IN);
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(ct->scrolled),
                                       GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
 
@@ -2694,7 +2719,7 @@ CollectTable *collection_table_new(CollectionData *cd)
        g_signal_connect(G_OBJECT(ct->listview), "key_press_event",
                         G_CALLBACK(collection_table_press_key_cb), ct);
 
-       gtk_container_add(GTK_CONTAINER(ct->scrolled), ct->listview);
+       gq_gtk_container_add(GTK_WIDGET(ct->scrolled), ct->listview);
        gtk_widget_show(ct->listview);
 
        collection_table_dnd_init(ct);