Sort headers using clang-tidy
[geeqie.git] / src / view-file / view-file-icon.cc
index 1275546..ae27a33 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "main.h"
 #include "view-file-icon.h"
 
+#include <config.h>
+
 #include "cellrenderericon.h"
 #include "collect.h"
+#include "compat.h"
+#include "debug.h"
 #include "dnd.h"
 #include "img-view.h"
+#include "intl.h"
 #include "layout-image.h"
+#include "main-defines.h"
 #include "metadata.h"
 #include "misc.h"
-#include "utilops.h"
+#include "options.h"
 #include "ui-fileops.h"
 #include "ui-misc.h"
 #include "ui-tree-edit.h"
 #include "uri-utils.h"
+#include "utilops.h"
 #include "view-file.h"
 
 /* between these, the icon width is increased by thumb_max_width / 2 */
-#define THUMB_MIN_ICON_WIDTH 128
-#define THUMB_MAX_ICON_WIDTH 160
+enum {
+       THUMB_MIN_ICON_WIDTH = 128,
+       THUMB_MAX_ICON_WIDTH = 160
+};
 #define THUMB_MIN_ICON_WIDTH_WITH_MARKS TOGGLE_SPACING * FILEDATA_MARKS_SIZE
 
-#define VFICON_MAX_COLUMNS 32
-#define THUMB_BORDER_PADDING 2
+enum {
+       VFICON_MAX_COLUMNS = 32,
+       THUMB_BORDER_PADDING = 2
+};
 
-#define VFICON_TIP_DELAY 500
+enum {
+       VFICON_TIP_DELAY = 500
+};
 
 enum {
        FILE_COLUMN_POINTER = 0,
@@ -52,7 +64,7 @@ enum {
 };
 
 static void vficon_toggle_filenames(ViewFile *vf);
-static void vficon_selection_remove(ViewFile *vf, FileData *id, SelectionType mask, GtkTreeIter *iter);
+static void vficon_selection_remove(ViewFile *vf, FileData *fd, SelectionType mask, GtkTreeIter *iter);
 static void vficon_move_focus(ViewFile *vf, gint row, gint col, gboolean relative);
 static void vficon_set_focus(ViewFile *vf, FileData *fd);
 static void vficon_populate_at_new_size(ViewFile *vf, gint w, gint h, gboolean force);
@@ -64,14 +76,14 @@ static void vficon_populate_at_new_size(ViewFile *vf, gint w, gint h, gboolean f
  *-----------------------------------------------------------------------------
  */
 
-GList *vficon_selection_get_one(ViewFile *UNUSED(vf), FileData *fd)
+GList *vficon_selection_get_one(ViewFile *, FileData *fd)
 {
        return g_list_prepend(filelist_copy(fd->sidecar_files), file_data_ref(fd));
 }
 
 GList *vficon_pop_menu_file_list(ViewFile *vf)
 {
-       if (!VFICON(vf)->click_fd) return NULL;
+       if (!VFICON(vf)->click_fd) return nullptr;
 
        if (VFICON(vf)->click_fd->selected & SELECTION_SELECTED)
                {
@@ -81,9 +93,9 @@ GList *vficon_pop_menu_file_list(ViewFile *vf)
        return vficon_selection_get_one(vf, VFICON(vf)->click_fd);
 }
 
-void vficon_pop_menu_view_cb(GtkWidget *UNUSED(widget), gpointer data)
+void vficon_pop_menu_view_cb(GtkWidget *, gpointer data)
 {
-       auto vf = (ViewFile *)data;
+       auto vf = static_cast<ViewFile *>(data);
 
        if (!VFICON(vf)->click_fd) return;
 
@@ -101,16 +113,16 @@ void vficon_pop_menu_view_cb(GtkWidget *UNUSED(widget), gpointer data)
                }
 }
 
-void vficon_pop_menu_rename_cb(GtkWidget *UNUSED(widget), gpointer data)
+void vficon_pop_menu_rename_cb(GtkWidget *, gpointer data)
 {
-       auto vf = (ViewFile *)data;
+       auto vf = static_cast<ViewFile *>(data);
 
-       file_util_rename(NULL, vf_pop_menu_file_list(vf), vf->listview);
+       file_util_rename(nullptr, vf_pop_menu_file_list(vf), vf->listview);
 }
 
-void vficon_pop_menu_show_names_cb(GtkWidget *UNUSED(widget), gpointer data)
+void vficon_pop_menu_show_names_cb(GtkWidget *, gpointer data)
 {
-       auto vf = (ViewFile *)data;
+       auto vf = static_cast<ViewFile *>(data);
 
        vficon_toggle_filenames(vf);
 }
@@ -125,26 +137,26 @@ static void vficon_toggle_star_rating(ViewFile *vf)
        vficon_populate_at_new_size(vf, allocation.width, allocation.height, TRUE);
 }
 
-void vficon_pop_menu_show_star_rating_cb(GtkWidget *UNUSED(widget), gpointer data)
+void vficon_pop_menu_show_star_rating_cb(GtkWidget *, gpointer data)
 {
-       auto vf = (ViewFile *)data;
+       auto vf = static_cast<ViewFile *>(data);
 
        vficon_toggle_star_rating(vf);
 }
 
-void vficon_pop_menu_refresh_cb(GtkWidget *UNUSED(widget), gpointer data)
+void vficon_pop_menu_refresh_cb(GtkWidget *, gpointer data)
 {
-       auto vf = (ViewFile *)data;
+       auto vf = static_cast<ViewFile *>(data);
 
        vf_refresh(vf);
 }
 
-void vficon_popup_destroy_cb(GtkWidget *UNUSED(widget), gpointer data)
+void vficon_popup_destroy_cb(GtkWidget *, gpointer data)
 {
-       auto vf = (ViewFile *)data;
-       vficon_selection_remove(vf, VFICON(vf)->click_fd, SELECTION_PRELIGHT, NULL);
-       VFICON(vf)->click_fd = NULL;
-       vf->popup = NULL;
+       auto vf = static_cast<ViewFile *>(data);
+       vficon_selection_remove(vf, VFICON(vf)->click_fd, SELECTION_PRELIGHT, nullptr);
+       VFICON(vf)->click_fd = nullptr;
+       vf->popup = nullptr;
 }
 
 /*
@@ -155,7 +167,7 @@ void vficon_popup_destroy_cb(GtkWidget *UNUSED(widget), gpointer data)
 
 static void vficon_send_layout_select(ViewFile *vf, FileData *fd)
 {
-       FileData *read_ahead_fd = NULL;
+       FileData *read_ahead_fd = nullptr;
        FileData *sel_fd;
        FileData *cur_fd;
 
@@ -172,7 +184,7 @@ static void vficon_send_layout_select(ViewFile *vf, FileData *fd)
 
                row = g_list_index(vf->list, fd);
                if (row > vficon_index_by_fd(vf, cur_fd) &&
-                   (guint) (row + 1) < vf_count(vf, NULL))
+                   static_cast<guint>(row + 1) < vf_count(vf, nullptr))
                        {
                        read_ahead_fd = vf_index_get_data(vf, row + 1);
                        }
@@ -232,11 +244,12 @@ static gboolean vficon_find_position(ViewFile *vf, FileData *fd, gint *row, gint
 static gboolean vficon_find_iter(ViewFile *vf, FileData *fd, GtkTreeIter *iter, gint *column)
 {
        GtkTreeModel *store;
-       gint row, col;
+       gint row;
+       gint col;
 
        store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview));
        if (!vficon_find_position(vf, fd, &row, &col)) return FALSE;
-       if (!gtk_tree_model_iter_nth_child(store, iter, NULL, row)) return FALSE;
+       if (!gtk_tree_model_iter_nth_child(store, iter, nullptr, row)) return FALSE;
        if (column) *column = col;
 
        return TRUE;
@@ -247,22 +260,22 @@ static FileData *vficon_find_data(ViewFile *vf, gint row, gint col, GtkTreeIter
        GtkTreeModel *store;
        GtkTreeIter p;
 
-       if (row < 0 || col < 0) return NULL;
+       if (row < 0 || col < 0) return nullptr;
 
        store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview));
-       if (gtk_tree_model_iter_nth_child(store, &p, NULL, row))
+       if (gtk_tree_model_iter_nth_child(store, &p, nullptr, row))
                {
                GList *list;
 
                gtk_tree_model_get(store, &p, FILE_COLUMN_POINTER, &list, -1);
-               if (!list) return NULL;
+               if (!list) return nullptr;
 
                if (iter) *iter = p;
 
                return static_cast<FileData *>(g_list_nth_data(list, col));
                }
 
-       return NULL;
+       return nullptr;
 }
 
 static FileData *vficon_find_data_by_coord(ViewFile *vf, gint x, gint y, GtkTreeIter *iter)
@@ -271,7 +284,7 @@ static FileData *vficon_find_data_by_coord(ViewFile *vf, gint x, gint y, GtkTree
        GtkTreeViewColumn *column;
 
        if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vf->listview), x, y,
-                                         &tpath, &column, NULL, NULL))
+                                         &tpath, &column, nullptr, nullptr))
                {
                GtkTreeModel *store;
                GtkTreeIter row;
@@ -292,12 +305,12 @@ static FileData *vficon_find_data_by_coord(ViewFile *vf, gint x, gint y, GtkTree
                        }
                }
 
-       return NULL;
+       return nullptr;
 }
 
 static void vficon_mark_toggled_cb(GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
 {
-       auto vf = (ViewFile *)data;
+       auto vf = static_cast<ViewFile *>(data);
        GtkTreeModel *store;
        GtkTreePath *path = gtk_tree_path_new_from_string(path_str);
        GtkTreeIter row;
@@ -331,7 +344,8 @@ static void vficon_mark_toggled_cb(GtkCellRendererToggle *cell, gchar *path_str,
 static void tip_show(ViewFile *vf)
 {
        GtkWidget *label;
-       gint x, y;
+       gint x;
+       gint y;
        GdkDisplay *display;
        GdkSeat *seat;
        GdkDevice *device;
@@ -341,9 +355,9 @@ static void tip_show(ViewFile *vf)
        seat = gdk_display_get_default_seat(gdk_window_get_display(gtk_tree_view_get_bin_window(GTK_TREE_VIEW(vf->listview))));
        device = gdk_seat_get_pointer(seat);
        gdk_window_get_device_position(gtk_tree_view_get_bin_window(GTK_TREE_VIEW(vf->listview)),
-                                               device, &x, &y, NULL);
+                                               device, &x, &y, nullptr);
 
-       VFICON(vf)->tip_fd = vficon_find_data_by_coord(vf, x, y, NULL);
+       VFICON(vf)->tip_fd = vficon_find_data_by_coord(vf, x, y, nullptr);
        if (!VFICON(vf)->tip_fd) return;
 
        VFICON(vf)->tip_window = gtk_window_new(GTK_WINDOW_POPUP);
@@ -353,28 +367,28 @@ static void tip_show(ViewFile *vf)
        label = gtk_label_new(VFICON(vf)->tip_fd->name);
 
        g_object_set_data(G_OBJECT(VFICON(vf)->tip_window), "tip_label", label);
-       gtk_container_add(GTK_CONTAINER(VFICON(vf)->tip_window), label);
+       gq_gtk_container_add(GTK_WIDGET(VFICON(vf)->tip_window), label);
        gtk_widget_show(label);
 
        display = gdk_display_get_default();
        seat = gdk_display_get_default_seat(display);
        device = gdk_seat_get_pointer(seat);
-       gdk_device_get_position(device, NULL, &x, &y);
+       gdk_device_get_position(device, nullptr, &x, &y);
 
        if (!gtk_widget_get_realized(VFICON(vf)->tip_window)) gtk_widget_realize(VFICON(vf)->tip_window);
-       gtk_window_move(GTK_WINDOW(VFICON(vf)->tip_window), x + 16, y + 16);
+       gq_gtk_window_move(GTK_WINDOW(VFICON(vf)->tip_window), x + 16, y + 16);
        gtk_widget_show(VFICON(vf)->tip_window);
 }
 
 static void tip_hide(ViewFile *vf)
 {
-       if (VFICON(vf)->tip_window) gtk_widget_destroy(VFICON(vf)->tip_window);
-       VFICON(vf)->tip_window = NULL;
+       if (VFICON(vf)->tip_window) g_object_unref(VFICON(vf)->tip_window);
+       VFICON(vf)->tip_window = nullptr;
 }
 
 static gboolean tip_schedule_cb(gpointer data)
 {
-       auto vf = (ViewFile *)data;
+       auto vf = static_cast<ViewFile *>(data);
        GtkWidget *window;
 
        if (!VFICON(vf)->tip_delay_id) return FALSE;
@@ -426,11 +440,12 @@ static void tip_update(ViewFile *vf, FileData *fd)
 
        if (VFICON(vf)->tip_window)
                {
-               gint x, y;
+               gint x;
+               gint y;
 
-               gdk_device_get_position(device, NULL, &x, &y);
+               gdk_device_get_position(device, nullptr, &x, &y);
 
-               gtk_window_move(GTK_WINDOW(VFICON(vf)->tip_window), x + 16, y + 16);
+               gq_gtk_window_move(GTK_WINDOW(VFICON(vf)->tip_window), x + 16, y + 16);
 
                if (fd != VFICON(vf)->tip_fd)
                        {
@@ -461,12 +476,12 @@ static void tip_update(ViewFile *vf, FileData *fd)
  *-------------------------------------------------------------------
  */
 
-static void vficon_dnd_get(GtkWidget *UNUSED(widget), GdkDragContext *UNUSED(context),
-                          GtkSelectionData *selection_data, guint UNUSED(info),
-                          guint UNUSED(time), gpointer data)
+static void vficon_dnd_get(GtkWidget *, GdkDragContext *,
+                          GtkSelectionData *selection_data, guint,
+                          guint, gpointer data)
 {
-       auto vf = (ViewFile *)data;
-       GList *list = NULL;
+       auto vf = static_cast<ViewFile *>(data);
+       GList *list = nullptr;
 
        if (!VFICON(vf)->click_fd) return;
 
@@ -476,7 +491,7 @@ static void vficon_dnd_get(GtkWidget *UNUSED(widget), GdkDragContext *UNUSED(con
                }
        else
                {
-               list = g_list_append(NULL, file_data_ref(VFICON(vf)->click_fd));
+               list = g_list_append(nullptr, file_data_ref(VFICON(vf)->click_fd));
                }
 
        if (!list) return;
@@ -484,22 +499,22 @@ static void vficon_dnd_get(GtkWidget *UNUSED(widget), GdkDragContext *UNUSED(con
        filelist_free(list);
 }
 
-static void vficon_drag_data_received(GtkWidget *UNUSED(entry_widget), GdkDragContext *UNUSED(context),
+static void vficon_drag_data_received(GtkWidget *, GdkDragContext *,
                                      int x, int y, GtkSelectionData *selection,
-                                     guint info, guint UNUSED(time), gpointer data)
+                                     guint info, guint, gpointer data)
 {
-       auto vf = (ViewFile *)data;
+       auto vf = static_cast<ViewFile *>(data);
 
        if (info == TARGET_TEXT_PLAIN) {
-               FileData *fd = vficon_find_data_by_coord(vf, x, y, NULL);
+               FileData *fd = vficon_find_data_by_coord(vf, x, y, nullptr);
 
                if (fd) {
                        /* Add keywords to file */
-                       auto str = (gchar *) gtk_selection_data_get_text(selection);
+                       auto str = reinterpret_cast<gchar *>(gtk_selection_data_get_text(selection));
                        GList *kw_list = string_to_keywords_list(str);
 
                        metadata_append_list(fd, KEYWORD_KEY, kw_list);
-                       string_list_free(kw_list);
+                       g_list_free_full(kw_list, g_free);
                        g_free(str);
                }
        }
@@ -507,7 +522,7 @@ static void vficon_drag_data_received(GtkWidget *UNUSED(entry_widget), GdkDragCo
 
 static void vficon_dnd_begin(GtkWidget *widget, GdkDragContext *context, gpointer data)
 {
-       auto vf = (ViewFile *)data;
+       auto vf = static_cast<ViewFile *>(data);
 
        tip_unschedule(vf);
 
@@ -524,11 +539,11 @@ static void vficon_dnd_begin(GtkWidget *widget, GdkDragContext *context, gpointe
                }
 }
 
-static void vficon_dnd_end(GtkWidget *UNUSED(widget), GdkDragContext *context, gpointer data)
+static void vficon_dnd_end(GtkWidget *, GdkDragContext *context, gpointer data)
 {
-       auto vf = (ViewFile *)data;
+       auto vf = static_cast<ViewFile *>(data);
 
-       vficon_selection_remove(vf, VFICON(vf)->click_fd, SELECTION_PRELIGHT, NULL);
+       vficon_selection_remove(vf, VFICON(vf)->click_fd, SELECTION_PRELIGHT, nullptr);
 
        if (gdk_drag_context_get_selected_action(context) == GDK_ACTION_MOVE)
                {
@@ -583,7 +598,7 @@ static void vficon_selection_set(ViewFile *vf, FileData *fd, SelectionType value
                {
                GtkTreeIter row;
 
-               if (vficon_find_iter(vf, fd, &row, NULL))
+               if (vficon_find_iter(vf, fd, &row, nullptr))
                        {
                        gtk_tree_model_get(store, &row, FILE_COLUMN_POINTER, &list, -1);
                        if (list) gtk_list_store_set(GTK_LIST_STORE(store), &row, FILE_COLUMN_POINTER, list, -1);
@@ -605,14 +620,14 @@ static void vficon_selection_remove(ViewFile *vf, FileData *fd, SelectionType ma
        vficon_selection_set(vf, fd, static_cast<SelectionType>(fd->selected & ~mask), iter);
 }
 
-void vficon_marks_set(ViewFile *vf, gint UNUSED(enable))
+void vficon_marks_set(ViewFile *vf, gint)
 {
        GtkAllocation allocation;
        gtk_widget_get_allocation(vf->listview, &allocation);
        vficon_populate_at_new_size(vf, allocation.width, allocation.height, TRUE);
 }
 
-void vficon_star_rating_set(ViewFile *vf, gint UNUSED(enable))
+void vficon_star_rating_set(ViewFile *vf, gint)
 {
        GtkAllocation allocation;
        gtk_widget_get_allocation(vf->listview, &allocation);
@@ -632,7 +647,7 @@ static void vficon_verify_selections(ViewFile *vf)
        work = VFICON(vf)->selection;
        while (work)
                {
-               auto fd = (FileData *)work->data;
+               auto fd = static_cast<FileData *>(work->data);
                work = work->next;
 
                if (vficon_index_by_fd(vf, fd) >= 0) continue;
@@ -646,16 +661,16 @@ void vficon_select_all(ViewFile *vf)
        GList *work;
 
        g_list_free(VFICON(vf)->selection);
-       VFICON(vf)->selection = NULL;
+       VFICON(vf)->selection = nullptr;
 
        work = vf->list;
        while (work)
                {
-               auto fd = (FileData *)work->data;
+               auto fd = static_cast<FileData *>(work->data);
                work = work->next;
 
                VFICON(vf)->selection = g_list_append(VFICON(vf)->selection, fd);
-               vficon_selection_add(vf, fd, SELECTION_SELECTED, NULL);
+               vficon_selection_add(vf, fd, SELECTION_SELECTED, nullptr);
                }
 
        vf_send_update(vf);
@@ -668,14 +683,14 @@ void vficon_select_none(ViewFile *vf)
        work = VFICON(vf)->selection;
        while (work)
                {
-               auto fd = (FileData *)work->data;
+               auto fd = static_cast<FileData *>(work->data);
                work = work->next;
 
-               vficon_selection_remove(vf, fd, SELECTION_SELECTED, NULL);
+               vficon_selection_remove(vf, fd, SELECTION_SELECTED, nullptr);
                }
 
        g_list_free(VFICON(vf)->selection);
-       VFICON(vf)->selection = NULL;
+       VFICON(vf)->selection = nullptr;
 
        vf_send_update(vf);
 }
@@ -687,18 +702,18 @@ void vficon_select_invert(ViewFile *vf)
        work = vf->list;
        while (work)
                {
-               auto fd = (FileData *)work->data;
+               auto fd = static_cast<FileData *>(work->data);
                work = work->next;
 
                if (fd->selected & SELECTION_SELECTED)
                        {
                        VFICON(vf)->selection = g_list_remove(VFICON(vf)->selection, fd);
-                       vficon_selection_remove(vf, fd, SELECTION_SELECTED, NULL);
+                       vficon_selection_remove(vf, fd, SELECTION_SELECTED, nullptr);
                        }
                else
                        {
                        VFICON(vf)->selection = g_list_append(VFICON(vf)->selection, fd);
-                       vficon_selection_add(vf, fd, SELECTION_SELECTED, NULL);
+                       vficon_selection_add(vf, fd, SELECTION_SELECTED, nullptr);
                        }
                }
 
@@ -712,7 +727,7 @@ static void vficon_select(ViewFile *vf, FileData *fd)
        if (!fd || fd->selected & SELECTION_SELECTED) return;
 
        VFICON(vf)->selection = g_list_append(VFICON(vf)->selection, fd);
-       vficon_selection_add(vf, fd, SELECTION_SELECTED, NULL);
+       vficon_selection_add(vf, fd, SELECTION_SELECTED, nullptr);
 
        vf_send_update(vf);
 }
@@ -724,7 +739,7 @@ static void vficon_unselect(ViewFile *vf, FileData *fd)
        if (!fd || !(fd->selected & SELECTION_SELECTED) ) return;
 
        VFICON(vf)->selection = g_list_remove(VFICON(vf)->selection, fd);
-       vficon_selection_remove(vf, fd, SELECTION_SELECTED, NULL);
+       vficon_selection_remove(vf, fd, SELECTION_SELECTED, nullptr);
 
        vf_send_update(vf);
 }
@@ -743,10 +758,13 @@ static void vficon_select_util(ViewFile *vf, FileData *fd, gboolean select)
 
 static void vficon_select_region_util(ViewFile *vf, FileData *start, FileData *end, gboolean select)
 {
-       gint row1, col1;
-       gint row2, col2;
+       gint row1;
+       gint col1;
+       gint row2;
+       gint col2;
        gint t;
-       gint i, j;
+       gint i;
+       gint j;
 
        if (!vficon_find_position(vf, start, &row1, &col1) ||
            !vficon_find_position(vf, end, &row2, &col2) ) return;
@@ -767,13 +785,13 @@ static void vficon_select_region_util(ViewFile *vf, FileData *start, FileData *e
                work = g_list_find(vf->list, start);
                while (work)
                        {
-                       auto fd = (FileData *)work->data;
+                       auto fd = static_cast<FileData *>(work->data);
                        vficon_select_util(vf, fd, select);
 
                        if (work->data != end)
                                work = work->next;
                        else
-                               work = NULL;
+                               work = nullptr;
                        }
                return;
                }
@@ -798,20 +816,23 @@ static void vficon_select_region_util(ViewFile *vf, FileData *start, FileData *e
                {
                for (j = col1; j <= col2; j++)
                        {
-                       FileData *fd = vficon_find_data(vf, i, j, NULL);
+                       FileData *fd = vficon_find_data(vf, i, j, nullptr);
                        if (fd) vficon_select_util(vf, fd, select);
                        }
                }
 }
 
-//gboolean vficon_index_is_selected(ViewFile *vf, gint row)
-//{
-       //FileData *fd = g_list_nth_data(vf->list, row);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-function"
+gboolean vficon_index_is_selected_unused(ViewFile *vf, gint row)
+{
+       auto *fd = static_cast<FileData *>(g_list_nth_data(vf->list, row));
 
-       //if (!fd) return FALSE;
+       if (!fd) return FALSE;
 
-       //return (fd->selected & SELECTION_SELECTED);
-//}
+       return (fd->selected & SELECTION_SELECTED);
+}
+#pragma GCC diagnostic pop
 
 guint vficon_selection_count(ViewFile *vf, gint64 *bytes)
 {
@@ -823,7 +844,7 @@ guint vficon_selection_count(ViewFile *vf, gint64 *bytes)
                work = VFICON(vf)->selection;
                while (work)
                        {
-                       auto fd = (FileData *)work->data;
+                       auto fd = static_cast<FileData *>(work->data);
                        g_assert(fd->magick == FD_MAGICK);
                        b += fd->size;
 
@@ -838,36 +859,23 @@ guint vficon_selection_count(ViewFile *vf, gint64 *bytes)
 
 GList *vficon_selection_get_list(ViewFile *vf)
 {
-       GList *list = NULL;
-       GList *work, *work2;
+       GList *list = nullptr;
 
-       work = VFICON(vf)->selection;
-       while (work)
+       for (GList *work = g_list_last(VFICON(vf)->selection); work; work = work->prev)
                {
-               auto fd = (FileData *)work->data;
+               auto fd = static_cast<FileData *>(work->data);
                g_assert(fd->magick == FD_MAGICK);
 
+               list = g_list_concat(filelist_copy(fd->sidecar_files), list);
                list = g_list_prepend(list, file_data_ref(fd));
-
-               work2 = fd->sidecar_files;
-               while (work2)
-                       {
-                       fd = static_cast<FileData *>(work2->data);
-                       list = g_list_prepend(list, file_data_ref(fd));
-                       work2 = work2->next;
-                       }
-
-               work = work->next;
                }
 
-       list = g_list_reverse(list);
-
        return list;
 }
 
 GList *vficon_selection_get_list_by_index(ViewFile *vf)
 {
-       GList *list = NULL;
+       GList *list = nullptr;
        GList *work;
 
        work = VFICON(vf)->selection;
@@ -908,7 +916,7 @@ void vficon_select_list(ViewFile *vf, GList *list)
                if (g_list_find(vf->list, fd))
                        {
                        VFICON(vf)->selection = g_list_append(VFICON(vf)->selection, fd);
-                       vficon_selection_add(vf, fd, SELECTION_SELECTED, NULL);
+                       vficon_selection_add(vf, fd, SELECTION_SELECTED, nullptr);
                        }
                work = work->next;
                }
@@ -924,8 +932,9 @@ void vficon_mark_to_selection(ViewFile *vf, gint mark, MarkToSelectionMode mode)
        work = vf->list;
        while (work)
                {
-               auto fd = (FileData *)work->data;
-               gboolean mark_val, selected;
+               auto fd = static_cast<FileData *>(work->data);
+               gboolean mark_val;
+               gboolean selected;
 
                g_assert(fd->magick == FD_MAGICK);
 
@@ -962,7 +971,7 @@ void vficon_selection_to_mark(ViewFile *vf, gint mark, SelectionToMarkMode mode)
        work = slist;
        while (work)
                {
-               auto fd = (FileData *)work->data;
+               auto fd = static_cast<FileData *>(work->data);
 
                switch (mode)
                        {
@@ -981,7 +990,7 @@ void vficon_selection_to_mark(ViewFile *vf, gint mark, SelectionToMarkMode mode)
 static void vficon_select_closest(ViewFile *vf, FileData *sel_fd)
 {
        GList *work;
-       FileData *fd = NULL;
+       FileData *fd = nullptr;
 
        if (sel_fd->parent) sel_fd = sel_fd->parent;
        work = vf->list;
@@ -1092,13 +1101,14 @@ static void vficon_move_focus(ViewFile *vf, gint row, gint col, gboolean relativ
                if (new_col >= l) new_col = l - 1;
                }
 
-       vficon_set_focus(vf, vficon_find_data(vf, new_row, new_col, NULL));
+       vficon_set_focus(vf, vficon_find_data(vf, new_row, new_col, nullptr));
 }
 
 static void vficon_set_focus(ViewFile *vf, FileData *fd)
 {
        GtkTreeIter iter;
-       gint row, col;
+       gint row;
+       gint col;
 
        if (g_list_find(vf->list, VFICON(vf)->focus_fd))
                {
@@ -1111,19 +1121,19 @@ static void vficon_set_focus(ViewFile *vf, FileData *fd)
  * preserved when the icon view is refreshed. Caused by an unknown call from
  * the idle loop. This patch hides the problem.
  */
-                       if (vficon_find_iter(vf, VFICON(vf)->focus_fd, &iter, NULL))
+                       if (vficon_find_iter(vf, VFICON(vf)->focus_fd, &iter, nullptr))
                                {
                                tree_view_row_make_visible(GTK_TREE_VIEW(vf->listview), &iter, FALSE);
                                }
 
                        return;
                        }
-               vficon_selection_remove(vf, VFICON(vf)->focus_fd, SELECTION_FOCUS, NULL);
+               vficon_selection_remove(vf, VFICON(vf)->focus_fd, SELECTION_FOCUS, nullptr);
                }
 
        if (!vficon_find_position(vf, fd, &row, &col))
                {
-               VFICON(vf)->focus_fd = NULL;
+               VFICON(vf)->focus_fd = nullptr;
                VFICON(vf)->focus_row = -1;
                VFICON(vf)->focus_column = -1;
                return;
@@ -1132,9 +1142,9 @@ static void vficon_set_focus(ViewFile *vf, FileData *fd)
        VFICON(vf)->focus_fd = fd;
        VFICON(vf)->focus_row = row;
        VFICON(vf)->focus_column = col;
-       vficon_selection_add(vf, VFICON(vf)->focus_fd, SELECTION_FOCUS, NULL);
+       vficon_selection_add(vf, VFICON(vf)->focus_fd, SELECTION_FOCUS, nullptr);
 
-       if (vficon_find_iter(vf, VFICON(vf)->focus_fd, &iter, NULL))
+       if (vficon_find_iter(vf, VFICON(vf)->focus_fd, &iter, nullptr))
                {
                GtkTreePath *tpath;
                GtkTreeViewColumn *column;
@@ -1159,8 +1169,8 @@ static gint page_height(ViewFile *vf)
        gint row_height;
        gint ret;
 
-       adj = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(vf->listview));
-       page_size = (gint)gtk_adjustment_get_page_increment(adj);
+       adj = gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(vf->listview));
+       page_size = static_cast<gint>(gtk_adjustment_get_page_increment(adj));
 
        row_height = options->thumbnails.max_height + THUMB_BORDER_PADDING * 2;
        if (VFICON(vf)->show_text) row_height += options->thumbnails.max_height / 3;
@@ -1179,7 +1189,7 @@ static gint page_height(ViewFile *vf)
 
 gboolean vficon_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
 {
-       auto vf = (ViewFile *)data;
+       auto vf = static_cast<ViewFile *>(data);
        gint focus_row = 0;
        gint focus_col = 0;
        FileData *fd;
@@ -1215,7 +1225,7 @@ gboolean vficon_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer dat
                        focus_col = VFICON(vf)->columns - 1 - VFICON(vf)->focus_column;
                        break;
                case GDK_KEY_space:
-                       fd = vficon_find_data(vf, VFICON(vf)->focus_row, VFICON(vf)->focus_column, NULL);
+                       fd = vficon_find_data(vf, VFICON(vf)->focus_row, VFICON(vf)->focus_column, nullptr);
                        if (fd)
                                {
                                VFICON(vf)->click_fd = fd;
@@ -1243,14 +1253,14 @@ gboolean vficon_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer dat
                                }
                        break;
                case GDK_KEY_Menu:
-                       fd = vficon_find_data(vf, VFICON(vf)->focus_row, VFICON(vf)->focus_column, NULL);
+                       fd = vficon_find_data(vf, VFICON(vf)->focus_row, VFICON(vf)->focus_column, nullptr);
                        VFICON(vf)->click_fd = fd;
 
-                       vficon_selection_add(vf, VFICON(vf)->click_fd, SELECTION_PRELIGHT, NULL);
+                       vficon_selection_add(vf, VFICON(vf)->click_fd, SELECTION_PRELIGHT, nullptr);
                        tip_unschedule(vf);
 
                        vf->popup = vf_pop_menu(vf);
-                       gtk_menu_popup_at_widget(GTK_MENU(vf->popup), widget, GDK_GRAVITY_EAST, GDK_GRAVITY_CENTER, NULL);
+                       gtk_menu_popup_at_widget(GTK_MENU(vf->popup), widget, GDK_GRAVITY_EAST, GDK_GRAVITY_CENTER, nullptr);
                        break;
                default:
                        stop_signal = FALSE;
@@ -1262,9 +1272,9 @@ gboolean vficon_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer dat
                FileData *new_fd;
                FileData *old_fd;
 
-               old_fd = vficon_find_data(vf, VFICON(vf)->focus_row, VFICON(vf)->focus_column, NULL);
+               old_fd = vficon_find_data(vf, VFICON(vf)->focus_row, VFICON(vf)->focus_column, nullptr);
                vficon_move_focus(vf, focus_row, focus_col, TRUE);
-               new_fd = vficon_find_data(vf, VFICON(vf)->focus_row, VFICON(vf)->focus_column, NULL);
+               new_fd = vficon_find_data(vf, VFICON(vf)->focus_row, VFICON(vf)->focus_column, nullptr);
 
                if (new_fd != old_fd)
                        {
@@ -1309,57 +1319,60 @@ gboolean vficon_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer dat
  *-------------------------------------------------------------------
  */
 
-static gboolean vficon_motion_cb(GtkWidget *UNUSED(widget), GdkEventMotion *event, gpointer data)
+static gboolean vficon_motion_cb(GtkWidget *, GdkEventMotion *event, gpointer data)
 {
-       auto vf = (ViewFile *)data;
+       auto vf = static_cast<ViewFile *>(data);
        FileData *fd;
 
-       fd = vficon_find_data_by_coord(vf, (gint)event->x, (gint)event->y, NULL);
+       fd = vficon_find_data_by_coord(vf, static_cast<gint>(event->x), static_cast<gint>(event->y), nullptr);
        tip_update(vf, fd);
 
        return FALSE;
 }
 
-gboolean vficon_press_cb(GtkWidget *UNUSED(widget), GdkEventButton *bevent, gpointer data)
+gboolean vficon_press_cb(GtkWidget *, GdkEventButton *bevent, gpointer data)
 {
-       auto vf = (ViewFile *)data;
+       auto vf = static_cast<ViewFile *>(data);
        GtkTreeIter iter;
        FileData *fd;
 
        tip_unschedule(vf);
 
-       fd = vficon_find_data_by_coord(vf, (gint)bevent->x, (gint)bevent->y, &iter);
-
-       VFICON(vf)->click_fd = fd;
-       vficon_selection_add(vf, VFICON(vf)->click_fd, SELECTION_PRELIGHT, &iter);
+       fd = vficon_find_data_by_coord(vf, static_cast<gint>(bevent->x), static_cast<gint>(bevent->y), &iter);
 
-       switch (bevent->button)
+       if (fd)
                {
-               case MOUSE_BUTTON_LEFT:
-                       if (!gtk_widget_has_focus(vf->listview))
-                               {
-                               gtk_widget_grab_focus(vf->listview);
-                               }
+               VFICON(vf)->click_fd = fd;
+               vficon_selection_add(vf, VFICON(vf)->click_fd, SELECTION_PRELIGHT, &iter);
 
-                       if (bevent->type == GDK_2BUTTON_PRESS && vf->layout)
-                               {
-                               if (VFICON(vf)->click_fd->format_class == FORMAT_CLASS_COLLECTION)
+               switch (bevent->button)
+                       {
+                       case MOUSE_BUTTON_LEFT:
+                               if (!gtk_widget_has_focus(vf->listview))
                                        {
-                                       collection_window_new(VFICON(vf)->click_fd->path);
+                                       gtk_widget_grab_focus(vf->listview);
                                        }
-                               else
+
+                               if (bevent->type == GDK_2BUTTON_PRESS && vf->layout)
                                        {
-                                       vficon_selection_remove(vf, VFICON(vf)->click_fd, SELECTION_PRELIGHT, &iter);
-                                       layout_image_full_screen_start(vf->layout);
+                                       if (VFICON(vf)->click_fd->format_class == FORMAT_CLASS_COLLECTION)
+                                               {
+                                               collection_window_new(VFICON(vf)->click_fd->path);
+                                               }
+                                       else
+                                               {
+                                               vficon_selection_remove(vf, VFICON(vf)->click_fd, SELECTION_PRELIGHT, &iter);
+                                               layout_image_full_screen_start(vf->layout);
+                                               }
                                        }
-                               }
-                       break;
-               case MOUSE_BUTTON_RIGHT:
-                       vf->popup = vf_pop_menu(vf);
-                       gtk_menu_popup_at_pointer(GTK_MENU(vf->popup), NULL);
-                       break;
-               default:
-                       break;
+                               break;
+                       case MOUSE_BUTTON_RIGHT:
+                               vf->popup = vf_pop_menu(vf);
+                               gtk_menu_popup_at_pointer(GTK_MENU(vf->popup), nullptr);
+                               break;
+                       default:
+                               break;
+                       }
                }
 
        return FALSE;
@@ -1367,9 +1380,9 @@ gboolean vficon_press_cb(GtkWidget *UNUSED(widget), GdkEventButton *bevent, gpoi
 
 gboolean vficon_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
 {
-       auto vf = (ViewFile *)data;
+       auto vf = static_cast<ViewFile *>(data);
        GtkTreeIter iter;
-       FileData *fd = NULL;
+       FileData *fd = nullptr;
        gboolean was_selected;
 
        tip_schedule(vf);
@@ -1379,14 +1392,14 @@ gboolean vficon_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer d
                return TRUE;
                }
 
-       if ((gint)bevent->x != 0 || (gint)bevent->y != 0)
+       if (static_cast<gint>(bevent->x) != 0 || static_cast<gint>(bevent->y) != 0)
                {
-               fd = vficon_find_data_by_coord(vf, (gint)bevent->x, (gint)bevent->y, &iter);
+               fd = vficon_find_data_by_coord(vf, static_cast<gint>(bevent->x), static_cast<gint>(bevent->y), &iter);
                }
 
        if (VFICON(vf)->click_fd)
                {
-               vficon_selection_remove(vf, VFICON(vf)->click_fd, SELECTION_PRELIGHT, NULL);
+               vficon_selection_remove(vf, VFICON(vf)->click_fd, SELECTION_PRELIGHT, nullptr);
                }
 
        if (!fd || VFICON(vf)->click_fd != fd) return TRUE;
@@ -1446,9 +1459,9 @@ gboolean vficon_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer d
        return TRUE;
 }
 
-static gboolean vficon_leave_cb(GtkWidget *UNUSED(widget), GdkEventCrossing *UNUSED(event), gpointer data)
+static gboolean vficon_leave_cb(GtkWidget *, GdkEventCrossing *, gpointer data)
 {
-       auto vf = (ViewFile *)data;
+       auto vf = static_cast<ViewFile *>(data);
 
        tip_unschedule(vf);
        return FALSE;
@@ -1460,7 +1473,7 @@ static gboolean vficon_leave_cb(GtkWidget *UNUSED(widget), GdkEventCrossing *UNU
  *-------------------------------------------------------------------
  */
 
-static gboolean vficon_destroy_node_cb(GtkTreeModel *store, GtkTreePath *UNUSED(tpath), GtkTreeIter *iter, gpointer UNUSED(data))
+static gboolean vficon_destroy_node_cb(GtkTreeModel *store, GtkTreePath *, GtkTreeIter *iter, gpointer)
 {
        GList *list;
 
@@ -1479,7 +1492,7 @@ static void vficon_clear_store(ViewFile *vf)
        GtkTreeModel *store;
 
        store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview));
-       gtk_tree_model_foreach(store, vficon_destroy_node_cb, NULL);
+       gtk_tree_model_foreach(store, vficon_destroy_node_cb, nullptr);
 
        gtk_list_store_clear(GTK_LIST_STORE(store));
 }
@@ -1487,10 +1500,10 @@ static void vficon_clear_store(ViewFile *vf)
 static GList *vficon_add_row(ViewFile *vf, GtkTreeIter *iter)
 {
        GtkListStore *store;
-       GList *list = NULL;
+       GList *list = nullptr;
        gint i;
 
-       for (i = 0; i < VFICON(vf)->columns; i++) list = g_list_prepend(list, NULL);
+       for (i = 0; i < VFICON(vf)->columns; i++) list = g_list_prepend(list, nullptr);
 
        store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)));
        gtk_list_store_append(store, iter);
@@ -1504,8 +1517,9 @@ static void vficon_populate(ViewFile *vf, gboolean resize, gboolean keep_positio
        GtkTreeModel *store;
        GtkTreePath *tpath;
        GList *work;
-       FileData *visible_fd = NULL;
-       gint r, c;
+       FileData *visible_fd = nullptr;
+       gint r;
+       gint c;
        gboolean valid;
        GtkTreeIter iter;
 
@@ -1514,7 +1528,7 @@ static void vficon_populate(ViewFile *vf, gboolean resize, gboolean keep_positio
        store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview));
 
        if (keep_position && gtk_widget_get_realized(vf->listview) &&
-           gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vf->listview), 0, 0, &tpath, NULL, NULL, NULL))
+           gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vf->listview), 0, 0, &tpath, nullptr, nullptr, nullptr))
                {
                GtkTreeIter iter;
                GList *list;
@@ -1547,7 +1561,7 @@ static void vficon_populate(ViewFile *vf, gboolean resize, gboolean keep_positio
                        gtk_tree_view_column_set_fixed_width(column, thumb_width + (THUMB_BORDER_PADDING * 6));
 
                        list = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(column));
-                       cell = static_cast<GtkCellRenderer *>((list) ? list->data : NULL);
+                       cell = static_cast<GtkCellRenderer *>((list) ? list->data : nullptr);
                        g_list_free(list);
 
                        if (cell && GQV_IS_CELL_RENDERER_ICON(cell))
@@ -1566,7 +1580,7 @@ static void vficon_populate(ViewFile *vf, gboolean resize, gboolean keep_positio
        r = -1;
        c = 0;
 
-       valid = gtk_tree_model_iter_children(store, &iter, NULL);
+       valid = gtk_tree_model_iter_children(store, &iter, nullptr);
 
        work = vf->list;
        while (work)
@@ -1596,7 +1610,7 @@ static void vficon_populate(ViewFile *vf, gboolean resize, gboolean keep_positio
                                }
                        else
                                {
-                               fd = NULL;
+                               fd = nullptr;
                                }
 
                        list->data = fd;
@@ -1618,7 +1632,7 @@ static void vficon_populate(ViewFile *vf, gboolean resize, gboolean keep_positio
        VFICON(vf)->rows = r;
 
        if (visible_fd &&
-           gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vf->listview), 0, 0, &tpath, NULL, NULL, NULL))
+           gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vf->listview), 0, 0, &tpath, nullptr, nullptr, nullptr))
                {
                GtkTreeIter iter;
                GList *list;
@@ -1627,8 +1641,8 @@ static void vficon_populate(ViewFile *vf, gboolean resize, gboolean keep_positio
                gtk_tree_path_free(tpath);
 
                gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &list, -1);
-               if (g_list_find(list, visible_fd) == NULL &&
-                   vficon_find_iter(vf, visible_fd, &iter, NULL))
+               if (g_list_find(list, visible_fd) == nullptr &&
+                   vficon_find_iter(vf, visible_fd, &iter, nullptr))
                        {
                        tree_view_row_make_visible(GTK_TREE_VIEW(vf->listview), &iter, FALSE);
                        }
@@ -1640,7 +1654,7 @@ static void vficon_populate(ViewFile *vf, gboolean resize, gboolean keep_positio
        vf_star_update(vf);
 }
 
-static void vficon_populate_at_new_size(ViewFile *vf, gint w, gint UNUSED(h), gboolean force)
+static void vficon_populate_at_new_size(ViewFile *vf, gint w, gint, gboolean force)
 {
        gint new_cols;
        gint thumb_width;
@@ -1659,9 +1673,9 @@ static void vficon_populate_at_new_size(ViewFile *vf, gint w, gint UNUSED(h), gb
        DEBUG_1("col tab pop cols=%d rows=%d", VFICON(vf)->columns, VFICON(vf)->rows);
 }
 
-static void vficon_sized_cb(GtkWidget *UNUSED(widget), GtkAllocation *allocation, gpointer data)
+static void vficon_sized_cb(GtkWidget *, GtkAllocation *allocation, gpointer data)
 {
-       auto vf = (ViewFile *)data;
+       auto vf = static_cast<ViewFile *>(data);
 
        vficon_populate_at_new_size(vf, allocation->width, allocation->height, FALSE);
 }
@@ -1672,12 +1686,13 @@ static void vficon_sized_cb(GtkWidget *UNUSED(widget), GtkAllocation *allocation
  *-----------------------------------------------------------------------------
  */
 
-void vficon_sort_set(ViewFile *vf, SortType type, gboolean ascend)
+void vficon_sort_set(ViewFile *vf, SortType type, gboolean ascend, gboolean case_sensitive)
 {
-       if (vf->sort_method == type && vf->sort_ascend == ascend) return;
+       if (vf->sort_method == type && vf->sort_ascend == ascend && vf->sort_case == case_sensitive) return;
 
        vf->sort_method = type;
        vf->sort_ascend = ascend;
+       vf->sort_case = case_sensitive;
 
        if (!vf->list) return;
 
@@ -1695,7 +1710,7 @@ void vficon_thumb_progress_count(GList *list, gint *count, gint *done)
        GList *work = list;
        while (work)
                {
-               auto fd = (FileData *)work->data;
+               auto fd = static_cast<FileData *>(work->data);
                work = work->next;
 
                if (fd->thumb_pixbuf) (*done)++;
@@ -1708,7 +1723,7 @@ void vficon_read_metadata_progress_count(GList *list, gint *count, gint *done)
        GList *work = list;
        while (work)
                {
-               auto fd = (FileData *)work->data;
+               auto fd = static_cast<FileData *>(work->data);
                work = work->next;
 
                if (fd->metadata_in_idle_loaded) (*done)++;
@@ -1723,7 +1738,7 @@ void vficon_set_thumb_fd(ViewFile *vf, FileData *fd)
        GList *list;
 
        if (!g_list_find(vf->list, fd)) return;
-       if (!vficon_find_iter(vf, fd, &iter, NULL)) return;
+       if (!vficon_find_iter(vf, fd, &iter, nullptr)) return;
 
        store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview));
 
@@ -1737,7 +1752,7 @@ FileData *vficon_thumb_next_fd(ViewFile *vf)
        GtkTreePath *tpath;
 
        /* First see if there are visible files that don't have a loaded thumb... */
-       if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vf->listview), 0, 0, &tpath, NULL, NULL, NULL))
+       if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vf->listview), 0, 0, &tpath, nullptr, nullptr, nullptr))
                {
                GtkTreeModel *store;
                GtkTreeIter iter;
@@ -1746,7 +1761,7 @@ FileData *vficon_thumb_next_fd(ViewFile *vf)
                store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview));
                gtk_tree_model_get_iter(store, &iter, tpath);
                gtk_tree_path_free(tpath);
-               tpath = NULL;
+               tpath = nullptr;
 
                while (valid && tree_view_row_get_visibility(GTK_TREE_VIEW(vf->listview), &iter, FALSE) == 0)
                        {
@@ -1768,14 +1783,14 @@ FileData *vficon_thumb_next_fd(ViewFile *vf)
        GList *work;
        for (work = vf->list; work; work = work->next)
                {
-               auto fd = (FileData *)work->data;
+               auto fd = static_cast<FileData *>(work->data);
 
                // Note: This implementation differs from view-file-list.cc because sidecar files are not
                // distinct list elements here, as they are in the list view.
                if (!fd->thumb_pixbuf) return fd;
                }
 
-       return NULL;
+       return nullptr;
 }
 
 void vficon_set_star_fd(ViewFile *vf, FileData *fd)
@@ -1785,7 +1800,7 @@ void vficon_set_star_fd(ViewFile *vf, FileData *fd)
        GList *list;
 
        if (!g_list_find(vf->list, fd)) return;
-       if (!vficon_find_iter(vf, fd, &iter, NULL)) return;
+       if (!vficon_find_iter(vf, fd, &iter, nullptr)) return;
 
        store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview));
 
@@ -1799,7 +1814,7 @@ FileData *vficon_star_next_fd(ViewFile *vf)
 
        /* first check the visible files */
 
-       if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vf->listview), 0, 0, &tpath, NULL, NULL, NULL))
+       if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vf->listview), 0, 0, &tpath, nullptr, nullptr, nullptr))
                {
                GtkTreeModel *store;
                GtkTreeIter iter;
@@ -1808,7 +1823,7 @@ FileData *vficon_star_next_fd(ViewFile *vf)
                store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview));
                gtk_tree_model_get_iter(store, &iter, tpath);
                gtk_tree_path_free(tpath);
-               tpath = NULL;
+               tpath = nullptr;
 
                while (valid && tree_view_row_get_visibility(GTK_TREE_VIEW(vf->listview), &iter, FALSE) == 0)
                        {
@@ -1824,7 +1839,7 @@ FileData *vficon_star_next_fd(ViewFile *vf)
 
                                        if (vf->stars_id == 0)
                                                {
-                                               vf->stars_id = g_idle_add_full(G_PRIORITY_LOW, vf_stars_cb, vf, NULL);
+                                               vf->stars_id = g_idle_add_full(G_PRIORITY_LOW, vf_stars_cb, vf, nullptr);
                                                }
 
                                        return fd;
@@ -1840,7 +1855,7 @@ FileData *vficon_star_next_fd(ViewFile *vf)
        GList *work;
        for (work = vf->list; work; work = work->next)
                {
-               auto fd = (FileData *)work->data;
+               auto fd = static_cast<FileData *>(work->data);
 
                if (fd && fd->rating == STAR_RATING_NOT_READ)
                        {
@@ -1848,14 +1863,14 @@ FileData *vficon_star_next_fd(ViewFile *vf)
 
                        if (vf->stars_id == 0)
                                {
-                               vf->stars_id = g_idle_add_full(G_PRIORITY_LOW, vf_stars_cb, vf, NULL);
+                               vf->stars_id = g_idle_add_full(G_PRIORITY_LOW, vf_stars_cb, vf, nullptr);
                                }
 
                        return fd;
                        }
                }
 
-       return NULL;
+       return nullptr;
 }
 
 /*
@@ -1874,7 +1889,7 @@ gint vficon_index_by_fd(ViewFile *vf, FileData *in_fd)
        work = vf->list;
        while (work)
                {
-               auto fd = (FileData *)work->data;
+               auto fd = static_cast<FileData *>(work->data);
                if (fd == in_fd) return p;
                work = work->next;
                p++;
@@ -1892,19 +1907,20 @@ gint vficon_index_by_fd(ViewFile *vf, FileData *in_fd)
 static gboolean vficon_refresh_real(ViewFile *vf, gboolean keep_position)
 {
        gboolean ret = TRUE;
-       GList *work, *new_work;
-       FileData *first_selected = NULL;
-       GList *new_filelist = NULL;
-       GList *new_fd_list = NULL;
-       GList *old_selected = NULL;
-       GtkTreePath *end_path = NULL;
-       GtkTreePath *start_path = NULL;
+       GList *work;
+       GList *new_work;
+       FileData *first_selected = nullptr;
+       GList *new_filelist = nullptr;
+       GList *new_fd_list = nullptr;
+       GList *old_selected = nullptr;
+       GtkTreePath *end_path = nullptr;
+       GtkTreePath *start_path = nullptr;
 
        gtk_tree_view_get_visible_range(GTK_TREE_VIEW(vf->listview), &start_path, &end_path);
 
        if (vf->dir_fd)
                {
-               ret = filelist_read(vf->dir_fd, &new_filelist, NULL);
+               ret = filelist_read(vf->dir_fd, &new_filelist, nullptr);
                new_filelist = file_data_filter_marks_list(new_filelist, vf_marks_get_filter(vf));
                new_filelist = g_list_first(new_filelist);
                new_filelist = file_data_filter_file_filter_list(new_filelist, vf_file_filter_get_filter(vf));
@@ -1914,8 +1930,8 @@ static gboolean vficon_refresh_real(ViewFile *vf, gboolean keep_position)
 
                }
 
-       vf->list = filelist_sort(vf->list, vf->sort_method, vf->sort_ascend); /* the list might not be sorted if there were renames */
-       new_filelist = filelist_sort(new_filelist, vf->sort_method, vf->sort_ascend);
+       vf->list = filelist_sort(vf->list, vf->sort_method, vf->sort_ascend, vf->sort_case); /* the list might not be sorted if there were renames */
+       new_filelist = filelist_sort(new_filelist, vf->sort_method, vf->sort_ascend, vf->sort_case);
 
        if (VFICON(vf)->selection)
                {
@@ -1923,7 +1939,7 @@ static gboolean vficon_refresh_real(ViewFile *vf, gboolean keep_position)
                first_selected = static_cast<FileData *>(VFICON(vf)->selection->data);
                file_data_ref(first_selected);
                g_list_free(VFICON(vf)->selection);
-               VFICON(vf)->selection = NULL;
+               VFICON(vf)->selection = nullptr;
                }
 
        /* iterate old list and new list, looking for differences */
@@ -1931,8 +1947,8 @@ static gboolean vficon_refresh_real(ViewFile *vf, gboolean keep_position)
        new_work = new_filelist;
        while (work || new_work)
                {
-               FileData *fd = NULL;
-               FileData *new_fd = NULL;
+               FileData *fd = nullptr;
+               FileData *new_fd = nullptr;
                gint match;
 
                if (work && new_work)
@@ -1973,8 +1989,8 @@ static gboolean vficon_refresh_real(ViewFile *vf, gboolean keep_position)
                        /* file no longer exists, delete from vf->list */
                        GList *to_delete = work;
                        work = work->next;
-                       if (fd == VFICON(vf)->prev_selection) VFICON(vf)->prev_selection = NULL;
-                       if (fd == VFICON(vf)->click_fd) VFICON(vf)->click_fd = NULL;
+                       if (fd == VFICON(vf)->prev_selection) VFICON(vf)->prev_selection = nullptr;
+                       if (fd == VFICON(vf)->click_fd) VFICON(vf)->click_fd = nullptr;
                        file_data_unref(fd);
                        vf->list = g_list_delete_link(vf->list, to_delete);
                        }
@@ -2037,7 +2053,7 @@ static gboolean vficon_refresh_real(ViewFile *vf, gboolean keep_position)
 
        if (start_path)
                {
-               gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(vf->listview), start_path, NULL, FALSE, 0.0, 0.0);
+               gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(vf->listview), start_path, nullptr, FALSE, 0.0, 0.0);
                }
 
        gtk_tree_path_free(start_path);
@@ -2057,21 +2073,20 @@ gboolean vficon_refresh(ViewFile *vf)
  *-----------------------------------------------------------------------------
  */
 
-typedef struct _ColumnData ColumnData;
-struct _ColumnData
+struct ColumnData
 {
        ViewFile *vf;
        gint number;
 };
 
-static void vficon_cell_data_cb(GtkTreeViewColumn *UNUSED(tree_column), GtkCellRenderer *cell,
+static void vficon_cell_data_cb(GtkTreeViewColumn *, GtkCellRenderer *cell,
                                GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data)
 {
-       GList *list;
+       auto cd = static_cast<ColumnData *>(data);
        FileData *fd;
-       auto cd = (ColumnData *)data;
-       ViewFile *vf = cd->vf;
        gchar *star_rating;
+       GList *list;
+       ViewFile *vf = cd->vf;
 
        if (!GQV_IS_CELL_RENDERER_ICON(cell)) return;
 
@@ -2081,12 +2096,14 @@ static void vficon_cell_data_cb(GtkTreeViewColumn *UNUSED(tree_column), GtkCellR
 
        if (fd)
                {
-               GdkColor color_fg;
-               GdkColor color_bg;
-               GtkStyle *style;
-               gchar *name_sidecars = NULL;
                const gchar *link;
+               gchar *name_sidecars = nullptr;
+               GdkRGBA color_bg;
+               GdkRGBA color_fg;
+               GdkRGBA color_bg_style;
+               GdkRGBA color_fg_style;
                GtkStateType state = GTK_STATE_NORMAL;
+               GtkStyle *style;
 
                g_assert(fd->magick == FD_MAGICK);
 
@@ -2096,7 +2113,7 @@ static void vficon_cell_data_cb(GtkTreeViewColumn *UNUSED(tree_column), GtkCellR
                        }
                else
                        {
-                       star_rating = NULL;
+                       star_rating = nullptr;
                        }
 
                link = islink(fd->path) ? GQ_LINK_STR : "";
@@ -2141,21 +2158,24 @@ static void vficon_cell_data_cb(GtkTreeViewColumn *UNUSED(tree_column), GtkCellR
                        state = GTK_STATE_SELECTED;
                        }
 
-               memcpy(&color_fg, &style->text[state], sizeof(color_fg));
-               memcpy(&color_bg, &style->base[state], sizeof(color_bg));
+               convert_gdkcolor_to_gdkrgba(&style->text[state], &color_fg_style);
+               convert_gdkcolor_to_gdkrgba(&style->base[state], &color_bg_style);
+
+               memcpy(&color_fg, &color_fg_style, sizeof(color_fg));
+               memcpy(&color_bg, &color_bg_style, sizeof(color_bg));
 
                if (fd->selected & SELECTION_PRELIGHT)
                        {
                        shift_color(&color_bg, -1, 0);
                        }
 
-               g_object_set(cell,      "pixbuf", fd->thumb_pixbuf,
+               g_object_set(cell, "pixbuf", fd->thumb_pixbuf,
                                        "text", name_sidecars,
                                        "marks", file_data_get_marks(fd),
                                        "show_marks", vf->marks_enabled,
-                                       "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", (VFICON(vf)->focus_fd == fd), NULL);
                g_free(name_sidecars);
@@ -2173,7 +2193,6 @@ static void vficon_cell_data_cb(GtkTreeViewColumn *UNUSED(tree_column), GtkCellR
 
 static void vficon_append_column(ViewFile *vf, gint n)
 {
-       ColumnData *cd;
        GtkTreeViewColumn *column;
        GtkCellRenderer *renderer;
 
@@ -2192,7 +2211,7 @@ static void vficon_append_column(ViewFile *vf, gint n)
        g_object_set_data(G_OBJECT(column), "column_number", GINT_TO_POINTER(n));
        g_object_set_data(G_OBJECT(renderer), "column_number", GINT_TO_POINTER(n));
 
-       cd = g_new0(ColumnData, 1);
+       auto cd = g_new0(ColumnData, 1);
        cd->vf = vf;
        cd->number = n;
        gtk_tree_view_column_set_cell_data_func(column, renderer, vficon_cell_data_cb, cd, g_free);
@@ -2219,23 +2238,23 @@ gboolean vficon_set_fd(ViewFile *vf, FileData *dir_fd)
        vf->dir_fd = file_data_ref(dir_fd);
 
        g_list_free(VFICON(vf)->selection);
-       VFICON(vf)->selection = NULL;
+       VFICON(vf)->selection = nullptr;
 
        g_list_free(vf->list);
-       vf->list = NULL;
+       vf->list = nullptr;
 
        /* NOTE: populate will clear the store for us */
        ret = vficon_refresh_real(vf, FALSE);
 
-       VFICON(vf)->focus_fd = NULL;
+       VFICON(vf)->focus_fd = nullptr;
        vficon_move_focus(vf, 0, 0, FALSE);
 
        return ret;
 }
 
-void vficon_destroy_cb(GtkWidget *UNUSED(widget), gpointer data)
+void vficon_destroy_cb(GtkWidget *, gpointer data)
 {
-       auto vf = (ViewFile *)data;
+       auto vf = static_cast<ViewFile *>(data);
 
        vf_refresh_idle_cancel(vf);
 
@@ -2250,7 +2269,7 @@ void vficon_destroy_cb(GtkWidget *UNUSED(widget), gpointer data)
        g_list_free(VFICON(vf)->selection);
 }
 
-ViewFile *vficon_new(ViewFile *vf, FileData *UNUSED(dir_fd))
+ViewFile *vficon_new(ViewFile *vf, FileData *)
 {
        GtkListStore *store;
        GtkTreeSelection *selection;