#include "misc.h"
#include "options.h"
#include "ui-fileops.h"
+#include "ui-menu.h"
#include "ui-misc.h"
#include "ui-tree-edit.h"
#include "uri-utils.h"
constexpr gint VFICON_TIP_DELAY = 500;
enum {
- FILE_COLUMN_POINTER = VIEW_FILE_COLUMN_POINTER,
+ FILE_COLUMN_POINTER = 0,
FILE_COLUMN_COUNT
};
return vficon_selection_get_one(vf, vf->click_fd);
}
-void vficon_pop_menu_view_cb(GtkWidget *, gpointer data)
+void vficon_pop_menu_view_cb(ViewFile *vf)
{
- auto vf = static_cast<ViewFile *>(data);
-
if (!vf->click_fd) return;
if (vf->click_fd->selected & SELECTION_SELECTED)
}
}
-void vficon_pop_menu_rename_cb(GtkWidget *, gpointer data)
+void vficon_pop_menu_rename_cb(ViewFile *vf)
{
- auto vf = static_cast<ViewFile *>(data);
-
file_util_rename(nullptr, vf_pop_menu_file_list(vf), vf->listview);
}
-void vficon_pop_menu_show_names_cb(GtkWidget *, gpointer data)
+static void vficon_pop_menu_show_names_cb(GtkWidget *, gpointer data)
{
auto vf = static_cast<ViewFile *>(data);
vficon_toggle_filenames(vf);
}
+void vficon_pop_menu_add_items(ViewFile *vf, GtkWidget *menu)
+{
+ menu_item_add_check(menu, _("Show filename _text"), VFICON(vf)->show_text,
+ G_CALLBACK(vficon_pop_menu_show_names_cb), vf);
+}
+
void vficon_pop_menu_show_star_rating_cb(ViewFile *vf)
{
GtkAllocation allocation;
vficon_populate_at_new_size(vf, allocation.width, allocation.height, TRUE);
}
-void vficon_pop_menu_refresh_cb(GtkWidget *, gpointer data)
+void vficon_pop_menu_refresh_cb(ViewFile *vf)
{
- auto vf = static_cast<ViewFile *>(data);
-
vf_refresh(vf);
}
-void vficon_popup_destroy_cb(GtkWidget *, gpointer data)
+void vficon_popup_destroy_cb(ViewFile *vf)
{
- auto vf = static_cast<ViewFile *>(data);
vficon_selection_remove(vf, vf->click_fd, SELECTION_PRELIGHT, nullptr);
- vf->click_fd = nullptr;
- vf->popup = nullptr;
}
/*
return g_list_reverse(list);
}
+void vficon_selection_foreach(ViewFile *vf, const ViewFile::SelectionCallback &func)
+{
+ for (GList *work = VFICON(vf)->selection; work; work = work->next)
+ {
+ auto *fd_n = static_cast<FileData *>(work->data);
+
+ func(fd_n);
+ }
+}
+
void vficon_select_by_fd(ViewFile *vf, FileData *fd)
{
if (!fd) return;
*-------------------------------------------------------------------
*/
-gboolean vficon_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
+gboolean vficon_press_key_cb(ViewFile *vf, GtkWidget *widget, GdkEventKey *event)
{
- auto vf = static_cast<ViewFile *>(data);
gint focus_row = 0;
gint focus_col = 0;
FileData *fd;
return FALSE;
}
-gboolean vficon_press_cb(GtkWidget *, GdkEventButton *bevent, gpointer data)
+gboolean vficon_press_cb(ViewFile *vf, GtkWidget *, GdkEventButton *bevent)
{
- auto vf = static_cast<ViewFile *>(data);
GtkTreeIter iter;
FileData *fd;
return FALSE;
}
-gboolean vficon_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
+gboolean vficon_release_cb(ViewFile *vf, GtkWidget *widget, GdkEventButton *bevent)
{
- auto vf = static_cast<ViewFile *>(data);
GtkTreeIter iter;
FileData *fd = nullptr;
gboolean was_selected;
*-----------------------------------------------------------------------------
*/
-void vficon_thumb_progress_count(GList *list, gint *count, gint *done)
+void vficon_thumb_progress_count(const GList *list, gint &count, gint &done)
{
- GList *work = list;
- while (work)
+ for (const GList *work = list; work; work = work->next)
{
auto fd = static_cast<FileData *>(work->data);
- work = work->next;
- if (fd->thumb_pixbuf) (*done)++;
- (*count)++;
+ if (fd->thumb_pixbuf) done++;
+ count++;
}
}
-void vficon_read_metadata_progress_count(GList *list, gint *count, gint *done)
+void vficon_read_metadata_progress_count(const GList *list, gint &count, gint &done)
{
- GList *work = list;
- while (work)
+ for (const GList *work = list; work; work = work->next)
{
auto fd = static_cast<FileData *>(work->data);
- work = work->next;
- if (fd->metadata_in_idle_loaded) (*done)++;
- (*count)++;
+ if (fd->metadata_in_idle_loaded) done++;
+ count++;
}
}
*-----------------------------------------------------------------------------
*/
-gint vficon_index_by_fd(ViewFile *vf, FileData *in_fd)
+gint vficon_index_by_fd(const ViewFile *vf, const FileData *fd)
{
- gint p = 0;
- GList *work;
+ if (!fd) return -1;
- if (!in_fd) return -1;
-
- work = vf->list;
- while (work)
- {
- auto fd = static_cast<FileData *>(work->data);
- if (fd == in_fd) return p;
- work = work->next;
- p++;
- }
-
- return -1;
+ return g_list_index(vf->list, fd);
}
/*
return ret;
}
-void vficon_destroy_cb(GtkWidget *, gpointer data)
+void vficon_destroy_cb(ViewFile *vf)
{
- auto vf = static_cast<ViewFile *>(data);
-
vf_refresh_idle_cancel(vf);
file_data_unregister_notify_func(vf_notify_cb, vf);
g_list_free(VFICON(vf)->selection);
}
-ViewFile *vficon_new(ViewFile *vf, FileData *)
+ViewFile *vficon_new(ViewFile *vf)
{
GtkListStore *store;
GtkTreeSelection *selection;