* 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,
};
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);
*-----------------------------------------------------------------------------
*/
-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)
{
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;
}
}
-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);
}
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;
}
/*
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;
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);
}
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;
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)
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;
}
}
- 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;
static void tip_show(ViewFile *vf)
{
GtkWidget *label;
- gint x, y;
+ gint x;
+ gint y;
GdkDisplay *display;
GdkSeat *seat;
GdkDevice *device;
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);
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;
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)
{
*-------------------------------------------------------------------
*/
-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;
}
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;
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);
}
}
static void vficon_dnd_begin(GtkWidget *widget, GdkDragContext *context, gpointer data)
{
- auto vf = (ViewFile *)data;
+ auto vf = static_cast<ViewFile *>(data);
tip_unschedule(vf);
}
}
-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)
{
{
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);
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);
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;
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);
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);
}
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);
}
}
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);
}
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);
}
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;
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;
}
{
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)
{
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;
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;
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;
}
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);
work = slist;
while (work)
{
- auto fd = (FileData *)work->data;
+ auto fd = static_cast<FileData *>(work->data);
switch (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;
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))
{
* 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;
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;
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;
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;
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;
}
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;
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)
{
*-------------------------------------------------------------------
*/
-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;
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);
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;
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;
*-------------------------------------------------------------------
*/
-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;
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));
}
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);
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;
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;
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))
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)
}
else
{
- fd = NULL;
+ fd = nullptr;
}
list->data = fd;
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;
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);
}
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;
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);
}
*-----------------------------------------------------------------------------
*/
-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;
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)++;
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)++;
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));
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;
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)
{
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)
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));
/* 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;
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)
{
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;
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)
{
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;
}
/*
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++;
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));
}
- 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)
{
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 */
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)
/* 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);
}
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);
*-----------------------------------------------------------------------------
*/
-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;
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);
}
else
{
- star_rating = NULL;
+ star_rating = nullptr;
}
link = islink(fd->path) ? GQ_LINK_STR : "";
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);
static void vficon_append_column(ViewFile *vf, gint n)
{
- ColumnData *cd;
GtkTreeViewColumn *column;
GtkCellRenderer *renderer;
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);
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);
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;