* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include "main.h"
#include "view-file-icon.h"
+#include <cstring>
+#include <utility>
+
+#include <glib-object.h>
+
#include "cellrenderericon.h"
#include "collect.h"
+#include "compat.h"
+#include "debug.h"
#include "dnd.h"
+#include "filedata.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"
+namespace
+{
+
/* between these, the icon width is increased by thumb_max_width / 2 */
-#define THUMB_MIN_ICON_WIDTH 128
-#define THUMB_MAX_ICON_WIDTH 160
-#define THUMB_MIN_ICON_WIDTH_WITH_MARKS TOGGLE_SPACING * FILEDATA_MARKS_SIZE
+constexpr gint THUMB_MIN_ICON_WIDTH = 128;
+constexpr gint THUMB_MAX_ICON_WIDTH = 160;
-#define VFICON_MAX_COLUMNS 32
-#define THUMB_BORDER_PADDING 2
+constexpr gint THUMB_MIN_ICON_WIDTH_WITH_MARKS = TOGGLE_SPACING * FILEDATA_MARKS_SIZE;
-#define VFICON_TIP_DELAY 500
+constexpr gint VFICON_MAX_COLUMNS = 32;
+
+constexpr gint THUMB_BORDER_PADDING = 2;
+
+constexpr gint VFICON_TIP_DELAY = 500;
enum {
- FILE_COLUMN_POINTER = 0,
+ FILE_COLUMN_POINTER = VIEW_FILE_COLUMN_POINTER,
FILE_COLUMN_COUNT
};
+struct ColumnData
+{
+ ViewFile *vf;
+ gint number;
+};
+
+} // namespace
+
static void vficon_toggle_filenames(ViewFile *vf);
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 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;
static void tip_show(ViewFile *vf)
{
GtkWidget *label;
- gint x, y;
+ gint x;
+ gint y;
GdkDisplay *display;
GdkSeat *seat;
GdkDevice *device;
static void tip_hide(ViewFile *vf)
{
- if (VFICON(vf)->tip_window) g_object_unref(VFICON(vf)->tip_window);
+ if (VFICON(vf)->tip_window) gq_gtk_widget_destroy(VFICON(vf)->tip_window);
VFICON(vf)->tip_window = nullptr;
}
if (VFICON(vf)->tip_window)
{
- gint x, y;
+ gint x;
+ gint y;
gdk_device_get_position(device, nullptr, &x, &y);
static void vficon_select_region_util(ViewFile *vf, FileData *start, FileData *end, gboolean select)
{
- gint row1, col1;
- gint row2, col2;
- gint t;
- gint i, j;
+ gint row1;
+ gint col1;
+ gint row2;
+ gint col2;
+ gint i;
+ gint j;
if (!vficon_find_position(vf, start, &row1, &col1) ||
!vficon_find_position(vf, end, &row2, &col2) ) return;
if (g_list_index(vf->list, start) > g_list_index(vf->list, end))
{
- FileData *tmp = start;
- start = end;
- end = tmp;
+ std::swap(start, end);
}
work = g_list_find(vf->list, start);
// rectangular_selection==true.
if (row2 < row1)
{
- t = row1;
- row1 = row2;
- row2 = t;
+ std::swap(row1, row2);
}
if (col2 < col1)
{
- t = col1;
- col1 = col2;
- col2 = t;
+ std::swap(col1, col2);
}
DEBUG_1("table: %d x %d to %d x %d", row1, col1, row2, col2);
while (work)
{
auto fd = static_cast<FileData *>(work->data);
- gboolean mark_val, selected;
+ gboolean mark_val;
+ gboolean selected;
g_assert(fd->magick == FD_MAGICK);
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))
{
GtkTreePath *tpath;
GList *work;
FileData *visible_fd = nullptr;
- gint r, c;
+ gint r;
gboolean valid;
GtkTreeIter iter;
}
r = -1;
- c = 0;
valid = gtk_tree_model_iter_children(store, &iter, nullptr);
{
GList *list;
r++;
- c = 0;
if (valid)
{
gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &list, -1);
{
fd = static_cast<FileData *>(work->data);
work = work->next;
- c++;
}
else
{
static gboolean vficon_refresh_real(ViewFile *vf, gboolean keep_position)
{
gboolean ret = TRUE;
- GList *work, *new_work;
+ GList *work;
+ GList *new_work;
FileData *first_selected = nullptr;
GList *new_filelist = nullptr;
GList *new_fd_list = nullptr;
*-----------------------------------------------------------------------------
*/
-struct ColumnData
-{
- ViewFile *vf;
- gint number;
-};
-
static void vficon_cell_data_cb(GtkTreeViewColumn *, GtkCellRenderer *cell,
GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data)
{
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;
state = GTK_STATE_SELECTED;
}
- 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));
+ convert_gdkcolor_to_gdkrgba(&style->text[state], &color_fg);
+ convert_gdkcolor_to_gdkrgba(&style->base[state], &color_bg);
if (fd->selected & SELECTION_PRELIGHT)
{