Remove unused declarations.
Add vf*_pop_menu_add_items().
Split vf_selection_foreach().
Move ViewFileInfo* structs to submodules.
GList *editmenu_fd_list; /**< file list for edit menu */
guint read_metadata_in_idle_id;
-};
-
-struct ViewFileInfoList
-{
- FileData *select_fd;
-
- gboolean thumbs_enabled;
- guint select_idle_id; /**< event source id */
+ using SelectionCallback = std::function<void(FileData *)>;
};
-struct ViewFileInfoIcon
-{
- /* table stuff */
- gint columns;
- gint rows;
-
- GList *selection;
- FileData *prev_selection;
-
- GtkWidget *tip_window;
- guint tip_delay_id; /**< event source id */
- FileData *tip_fd;
-
- FileData *focus_fd;
- gint focus_row;
- gint focus_column;
-
- gboolean show_text;
-};
-
-#define VFLIST(_vf_) ((ViewFileInfoList *)(_vf_->info))
-#define VFICON(_vf_) ((ViewFileInfoIcon *)(_vf_->info))
-
-const gint VIEW_FILE_COLUMN_POINTER = 0; // @todo Use inline constexpr in C++17
-
void vf_send_update(ViewFile *vf);
ViewFile *vf_new(FileViewType type, FileData *dir_fd);
guint vf_selection_count(ViewFile *vf, gint64 *bytes);
GList *vf_selection_get_list(ViewFile *vf);
GList *vf_selection_get_list_by_index(ViewFile *vf);
-using ViewFileSelectionCallback = std::function<void(FileData *)>;
-void vf_selection_foreach(ViewFile *vf, const ViewFileSelectionCallback &func);
+void vf_selection_foreach(ViewFile *vf, const ViewFile::SelectionCallback &func);
void vf_select_all(ViewFile *vf);
void vf_select_none(ViewFile *vf);
#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;
#include <gtk/gtk.h>
#include "typedefs.h"
+#include "view-file.h"
struct FileData;
-struct ViewFile;
-gboolean vficon_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data);
-gboolean vficon_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data);
-gboolean vficon_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data);
+struct ViewFileInfoIcon
+{
+ /* table stuff */
+ gint columns;
+ gint rows;
+
+ GList *selection;
+ FileData *prev_selection;
+
+ GtkWidget *tip_window;
+ guint tip_delay_id; /**< event source id */
+ FileData *tip_fd;
+
+ FileData *focus_fd;
+ gint focus_row;
+ gint focus_column;
+
+ gboolean show_text;
+};
+
+#define VFICON(_vf_) ((ViewFileInfoIcon *)((_vf_)->info))
+
+gboolean vficon_press_key_cb(ViewFile *vf, GtkWidget *widget, GdkEventKey *event);
+gboolean vficon_press_cb(ViewFile *vf, GtkWidget *widget, GdkEventButton *bevent);
+gboolean vficon_release_cb(ViewFile *vf, GtkWidget *widget, GdkEventButton *bevent);
void vficon_dnd_init(ViewFile *vf);
-void vficon_destroy_cb(GtkWidget *widget, gpointer data);
-ViewFile *vficon_new(ViewFile *vf, FileData *dir_fd);
+void vficon_destroy_cb(ViewFile *vf);
+ViewFile *vficon_new(ViewFile *vf);
gboolean vficon_set_fd(ViewFile *vf, FileData *dir_fd);
gboolean vficon_refresh(ViewFile *vf);
-void vficon_sort_set(ViewFile *vf, SortType type, gboolean ascend, gboolean case_sensitive);
void vficon_marks_set(ViewFile *vf, gboolean enable);
void vficon_star_rating_set(ViewFile *vf, gboolean enable);
+void vficon_sort_set(ViewFile *vf, SortType type, gboolean ascend, gboolean case_sensitive);
GList *vficon_selection_get_one(ViewFile *vf, FileData *fd);
GList *vficon_pop_menu_file_list(ViewFile *vf);
-void vficon_pop_menu_view_cb(GtkWidget *widget, gpointer data);
-void vficon_pop_menu_rename_cb(GtkWidget *widget, gpointer data);
+void vficon_pop_menu_view_cb(ViewFile *vf);
+void vficon_pop_menu_rename_cb(ViewFile *vf);
+void vficon_pop_menu_add_items(ViewFile *vf, GtkWidget *menu);
void vficon_pop_menu_show_star_rating_cb(ViewFile *vf);
-void vficon_pop_menu_refresh_cb(GtkWidget *widget, gpointer data);
-void vficon_popup_destroy_cb(GtkWidget *widget, gpointer data);
-void vficon_pop_menu_show_names_cb(GtkWidget *widget, gpointer data);
+void vficon_pop_menu_refresh_cb(ViewFile *vf);
+void vficon_popup_destroy_cb(ViewFile *vf);
-FileData *vficon_index_get_data(ViewFile *vf, gint row);
-gint vficon_index_by_fd(ViewFile *vf, FileData *in_fd);
-guint vficon_count(ViewFile *vf, gint64 *bytes);
-GList *vficon_get_list(ViewFile *vf);
+gint vficon_index_by_fd(const ViewFile *vf, const FileData *fd);
guint vficon_selection_count(ViewFile *vf, gint64 *bytes);
GList *vficon_selection_get_list(ViewFile *vf);
GList *vficon_selection_get_list_by_index(ViewFile *vf);
+void vficon_selection_foreach(ViewFile *vf, const ViewFile::SelectionCallback &func);
void vficon_select_all(ViewFile *vf);
void vficon_select_none(ViewFile *vf);
void vficon_selection_to_mark(ViewFile *vf, gint mark, SelectionToMarkMode mode);
-void vficon_thumb_progress_count(GList *list, gint *count, gint *done);
-void vficon_read_metadata_progress_count(GList *list, gint *count, gint *done);
+void vficon_thumb_progress_count(const GList *list, gint &count, gint &done);
+void vficon_read_metadata_progress_count(const GList *list, gint &count, gint &done);
void vficon_set_thumb_fd(ViewFile *vf, FileData *fd);
FileData *vficon_thumb_next_fd(ViewFile *vf);
-void vficon_thumb_reset_all(ViewFile *vf);
FileData *vficon_star_next_fd(ViewFile *vf);
void vficon_set_star_fd(ViewFile *vf, FileData *fd);
#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"
/* Index to tree store */
enum {
- FILE_COLUMN_POINTER = VIEW_FILE_COLUMN_POINTER,
+ FILE_COLUMN_POINTER = 0,
FILE_COLUMN_VERSION,
FILE_COLUMN_THUMB,
FILE_COLUMN_FORMATTED,
}
-void vflist_pop_menu_view_cb(GtkWidget *, gpointer data)
+void vflist_pop_menu_view_cb(ViewFile *vf)
{
- auto vf = static_cast<ViewFile *>(data);
-
if (vflist_row_is_selected(vf, vf->click_fd))
{
GList *list;
}
}
-void vflist_pop_menu_rename_cb(GtkWidget *, gpointer data)
+void vflist_pop_menu_rename_cb(ViewFile *vf)
{
- auto vf = static_cast<ViewFile *>(data);
GList *list;
list = vf_pop_menu_file_list(vf);
file_util_rename(nullptr, list, vf->listview);
}
-void vflist_pop_menu_thumbs_cb(GtkWidget *, gpointer data)
+static void vflist_pop_menu_thumbs_cb(GtkWidget *, gpointer data)
{
auto vf = static_cast<ViewFile *>(data);
}
}
+void vflist_pop_menu_add_items(ViewFile *vf, GtkWidget *menu)
+{
+ menu_item_add_check(menu, _("Show _thumbnails"), VFLIST(vf)->thumbs_enabled,
+ G_CALLBACK(vflist_pop_menu_thumbs_cb), vf);
+}
+
void vflist_star_rating_set(ViewFile *vf, gboolean enable)
{
GList *columns;
vflist_star_rating_set(vf, options->show_star_rating);
}
-void vflist_pop_menu_refresh_cb(GtkWidget *, gpointer data)
+void vflist_pop_menu_refresh_cb(ViewFile *vf)
{
- auto vf = static_cast<ViewFile *>(data);
-
vflist_color_set(vf, vf->click_fd, FALSE);
vf_refresh(vf);
gtk_tree_view_columns_autosize(GTK_TREE_VIEW(vf->listview));
}
-void vflist_popup_destroy_cb(GtkWidget *, gpointer data)
+void vflist_popup_destroy_cb(ViewFile *vf)
{
- auto vf = static_cast<ViewFile *>(data);
vflist_color_set(vf, vf->click_fd, FALSE);
- vf->click_fd = nullptr;
- vf->popup = nullptr;
}
return FALSE;
}
-gboolean vflist_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
+gboolean vflist_press_key_cb(ViewFile *vf, GtkWidget *widget, GdkEventKey *event)
{
- auto vf = static_cast<ViewFile *>(data);
GtkTreePath *tpath;
if (event->keyval != GDK_KEY_Menu) return FALSE;
return TRUE;
}
-gboolean vflist_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
+gboolean vflist_press_cb(ViewFile *vf, GtkWidget *widget, GdkEventButton *bevent)
{
- auto vf = static_cast<ViewFile *>(data);
GtkTreePath *tpath;
GtkTreeIter iter;
FileData *fd = nullptr;
return FALSE;
}
-gboolean vflist_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
+gboolean vflist_release_cb(ViewFile *vf, GtkWidget *widget, GdkEventButton *bevent)
{
- auto vf = static_cast<ViewFile *>(data);
GtkTreePath *tpath;
GtkTreeIter iter;
FileData *fd = nullptr;
*/
-void vflist_thumb_progress_count(GList *list, gint *count, gint *done)
+void vflist_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)++;
+ if (fd->thumb_pixbuf) done++;
if (fd->sidecar_files)
{
vflist_thumb_progress_count(fd->sidecar_files, count, done);
}
- (*count)++;
+ count++;
}
}
-void vflist_read_metadata_progress_count(GList *list, gint *count, gint *done)
+void vflist_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)++;
+ if (fd->metadata_in_idle_loaded) done++;
if (fd->sidecar_files)
{
vflist_read_metadata_progress_count(fd->sidecar_files, count, done);
}
- (*count)++;
+ count++;
}
}
*-----------------------------------------------------------------------------
*/
-gint vflist_index_by_fd(ViewFile *vf, FileData *fd)
+gint vflist_index_by_fd(const ViewFile *vf, const FileData *fd)
{
gint p = 0;
- GList *work;
- GList *work2;
- work = vf->list;
- while (work)
+ for (const GList *work = vf->list; work; work = work->next)
{
auto list_fd = static_cast<FileData *>(work->data);
if (list_fd == fd) return p;
- work2 = list_fd->sidecar_files;
- while (work2)
- {
- /** @FIXME return the same index also for sidecars
- it is sufficient for next/prev navigation but it should be rewritten
- without using indexes at all
- */
- auto sidecar_fd = static_cast<FileData *>(work2->data);
- if (sidecar_fd == fd) return p;
- work2 = work2->next;
- }
+ /** @FIXME return the same index also for sidecars
+ it is sufficient for next/prev navigation but it should be rewritten
+ without using indexes at all
+ */
+ if (g_list_find(list_fd->sidecar_files, fd)) return p;
- work = work->next;
p++;
}
return g_list_reverse(list);
}
+void vflist_selection_foreach(ViewFile *vf, const ViewFile::SelectionCallback &func)
+{
+ GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview));
+ GtkTreeModel *store;
+ GtkTreeIter iter;
+ FileData *fd_n;
+
+ for (GList *work = gtk_tree_selection_get_selected_rows(selection, &store); work; work = work->next)
+ {
+ auto *tpath = static_cast<GtkTreePath *>(work->data);
+
+ gtk_tree_model_get_iter(store, &iter, tpath);
+ gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd_n, -1);
+
+ func(fd_n);
+ }
+}
+
void vflist_select_all(ViewFile *vf)
{
GtkTreeSelection *selection;
return ret;
}
-void vflist_destroy_cb(GtkWidget *, gpointer data)
+void vflist_destroy_cb(ViewFile *vf)
{
- auto vf = static_cast<ViewFile *>(data);
-
file_data_unregister_notify_func(vf_notify_cb, vf);
vflist_select_idle_cancel(vf);
filelist_free(vf->list);
}
-ViewFile *vflist_new(ViewFile *vf, FileData *)
+ViewFile *vflist_new(ViewFile *vf)
{
GtkTreeStore *store;
GtkTreeSelection *selection;
#include <gtk/gtk.h>
#include "typedefs.h"
+#include "view-file.h"
struct FileData;
-struct ViewFile;
-gboolean vflist_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data);
-gboolean vflist_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data);
-gboolean vflist_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data);
+struct ViewFileInfoList
+{
+ FileData *select_fd;
+
+ gboolean thumbs_enabled;
+
+ guint select_idle_id; /**< event source id */
+};
+
+#define VFLIST(_vf_) ((ViewFileInfoList *)((_vf_)->info))
+
+gboolean vflist_press_key_cb(ViewFile *vf, GtkWidget *widget, GdkEventKey *event);
+gboolean vflist_press_cb(ViewFile *vf, GtkWidget *widget, GdkEventButton *bevent);
+gboolean vflist_release_cb(ViewFile *vf, GtkWidget *widget, GdkEventButton *bevent);
void vflist_dnd_init(ViewFile *vf);
-void vflist_destroy_cb(GtkWidget *widget, gpointer data);
-ViewFile *vflist_new(ViewFile *vf, FileData *dir_fd);
+void vflist_destroy_cb(ViewFile *vf);
+ViewFile *vflist_new(ViewFile *vf);
gboolean vflist_set_fd(ViewFile *vf, FileData *dir_fd);
gboolean vflist_refresh(ViewFile *vf);
GList *vflist_selection_get_one(ViewFile *vf, FileData *fd);
GList *vflist_pop_menu_file_list(ViewFile *vf);
-void vflist_pop_menu_view_cb(GtkWidget *widget, gpointer data);
-void vflist_pop_menu_rename_cb(GtkWidget *widget, gpointer data);
+void vflist_pop_menu_view_cb(ViewFile *vf);
+void vflist_pop_menu_rename_cb(ViewFile *vf);
+void vflist_pop_menu_add_items(ViewFile *vf, GtkWidget *menu);
void vflist_pop_menu_show_star_rating_cb(ViewFile *vf);
-void vflist_pop_menu_refresh_cb(GtkWidget *widget, gpointer data);
-void vflist_popup_destroy_cb(GtkWidget *widget, gpointer data);
-void vflist_pop_menu_thumbs_cb(GtkWidget *widget, gpointer data);
+void vflist_pop_menu_refresh_cb(ViewFile *vf);
+void vflist_popup_destroy_cb(ViewFile *vf);
-FileData *vflist_index_get_data(ViewFile *vf, gint row);
-gint vflist_index_by_fd(ViewFile *vf, FileData *fd);
-guint vflist_count(ViewFile *vf, gint64 *bytes);
-GList *vflist_get_list(ViewFile *vf);
+gint vflist_index_by_fd(const ViewFile *vf, const FileData *fd);
guint vflist_selection_count(ViewFile *vf, gint64 *bytes);
GList *vflist_selection_get_list(ViewFile *vf);
GList *vflist_selection_get_list_by_index(ViewFile *vf);
+void vflist_selection_foreach(ViewFile *vf, const ViewFile::SelectionCallback &func);
void vflist_select_all(ViewFile *vf);
void vflist_select_none(ViewFile *vf);
void vflist_color_set(ViewFile *vf, FileData *fd, gboolean color_set);
-void vflist_thumb_progress_count(GList *list, gint *count, gint *done);
-void vflist_read_metadata_progress_count(GList *list, gint *count, gint *done);
+void vflist_thumb_progress_count(const GList *list, gint &count, gint &done);
+void vflist_read_metadata_progress_count(const GList *list, gint &count, gint &done);
void vflist_set_thumb_fd(ViewFile *vf, FileData *fd);
FileData *vflist_thumb_next_fd(ViewFile *vf);
-void vflist_thumb_reset_all(ViewFile *vf);
FileData *vflist_star_next_fd(ViewFile *vf);
void vflist_set_star_fd(ViewFile *vf, FileData *fd);
switch (vf->type)
{
- case FILEVIEW_LIST: ret = vflist_press_key_cb(widget, event, data); break;
- case FILEVIEW_ICON: ret = vficon_press_key_cb(widget, event, data); break;
+ case FILEVIEW_LIST: ret = vflist_press_key_cb(vf, widget, event); break;
+ case FILEVIEW_ICON: ret = vficon_press_key_cb(vf, widget, event); break;
default: ret = FALSE;
}
switch (vf->type)
{
- case FILEVIEW_LIST: ret = vflist_press_cb(widget, bevent, data); break;
- case FILEVIEW_ICON: ret = vficon_press_cb(widget, bevent, data); break;
+ case FILEVIEW_LIST: ret = vflist_press_cb(vf, widget, bevent); break;
+ case FILEVIEW_ICON: ret = vficon_press_cb(vf, widget, bevent); break;
default: ret = FALSE;
}
switch (vf->type)
{
- case FILEVIEW_LIST: ret = vflist_release_cb(widget, bevent, data); break;
- case FILEVIEW_ICON: ret = vficon_release_cb(widget, bevent, data); break;
+ case FILEVIEW_LIST: ret = vflist_release_cb(vf, widget, bevent); break;
+ case FILEVIEW_ICON: ret = vficon_release_cb(vf, widget, bevent); break;
default: ret = FALSE;
}
return ret;
}
-void vf_selection_foreach(ViewFile *vf, const ViewFileSelectionCallback &func)
+void vf_selection_foreach(ViewFile *vf, const ViewFile::SelectionCallback &func)
{
- GtkTreeModel *store;
- GList *work;
- FileData *fd_n;
- GtkTreeIter iter;
-
if (!vf) return;
- if (vf->type == FILEVIEW_ICON)
- {
- if (!VFICON(vf)->selection) return;
- work = VFICON(vf)->selection;
- }
- else
- {
- GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview));
- work = gtk_tree_selection_get_selected_rows(selection, &store);
- }
-
- for (; work; work = work->next)
- {
- if (vf->type == FILEVIEW_ICON)
- {
- fd_n = static_cast<FileData *>(work->data);
- }
- else
- {
- auto *tpath = static_cast<GtkTreePath *>(work->data);
- gtk_tree_model_get_iter(store, &iter, tpath);
- gtk_tree_model_get(store, &iter, VIEW_FILE_COLUMN_POINTER, &fd_n, -1);
- }
-
- func(fd_n);
- }
+ switch (vf->type)
+ {
+ case FILEVIEW_LIST: vflist_selection_foreach(vf, func); break;
+ case FILEVIEW_ICON: vficon_selection_foreach(vf, func); break;
+ }
}
void vf_select_all(ViewFile *vf)
file_util_start_editor_from_filelist(key, vf_pop_menu_file_list(vf), vf->dir_fd->path, vf->listview);
}
-static void vf_pop_menu_view_cb(GtkWidget *widget, gpointer data)
+static void vf_pop_menu_view_cb(GtkWidget *, gpointer data)
{
auto vf = static_cast<ViewFile *>(data);
switch (vf->type)
{
- case FILEVIEW_LIST: vflist_pop_menu_view_cb(widget, data); break;
- case FILEVIEW_ICON: vficon_pop_menu_view_cb(widget, data); break;
+ case FILEVIEW_LIST: vflist_pop_menu_view_cb(vf); break;
+ case FILEVIEW_ICON: vficon_pop_menu_view_cb(vf); break;
}
}
file_util_move(nullptr, vf_pop_menu_file_list(vf), nullptr, vf->listview);
}
-static void vf_pop_menu_rename_cb(GtkWidget *widget, gpointer data)
+static void vf_pop_menu_rename_cb(GtkWidget *, gpointer data)
{
auto vf = static_cast<ViewFile *>(data);
switch (vf->type)
{
- case FILEVIEW_LIST: vflist_pop_menu_rename_cb(widget, data); break;
- case FILEVIEW_ICON: vficon_pop_menu_rename_cb(widget, data); break;
+ case FILEVIEW_LIST: vflist_pop_menu_rename_cb(vf); break;
+ case FILEVIEW_ICON: vficon_pop_menu_rename_cb(vf); break;
}
}
layout_views_set(vf->layout, vf->layout->options.dir_view_type, new_type);
}
-static void vf_pop_menu_refresh_cb(GtkWidget *widget, gpointer data)
+static void vf_pop_menu_refresh_cb(GtkWidget *, gpointer data)
{
auto vf = static_cast<ViewFile *>(data);
switch (vf->type)
{
- case FILEVIEW_LIST: vflist_pop_menu_refresh_cb(widget, data); break;
- case FILEVIEW_ICON: vficon_pop_menu_refresh_cb(widget, data); break;
+ case FILEVIEW_LIST: vflist_pop_menu_refresh_cb(vf); break;
+ case FILEVIEW_ICON: vficon_pop_menu_refresh_cb(vf); break;
}
}
-static void vf_popup_destroy_cb(GtkWidget *widget, gpointer data)
+static void vf_popup_destroy_cb(GtkWidget *, gpointer data)
{
auto vf = static_cast<ViewFile *>(data);
switch (vf->type)
{
- case FILEVIEW_LIST: vflist_popup_destroy_cb(widget, data); break;
- case FILEVIEW_ICON: vficon_popup_destroy_cb(widget, data); break;
+ case FILEVIEW_LIST: vflist_popup_destroy_cb(vf); break;
+ case FILEVIEW_ICON: vficon_popup_destroy_cb(vf); break;
}
+ vf->click_fd = nullptr;
+ vf->popup = nullptr;
+
filelist_free(vf->editmenu_fd_list);
vf->editmenu_fd_list = nullptr;
}
switch (vf->type)
{
- case FILEVIEW_LIST:
- menu_item_add_check(menu, _("Show _thumbnails"), VFLIST(vf)->thumbs_enabled,
- G_CALLBACK(vflist_pop_menu_thumbs_cb), vf);
- break;
- case FILEVIEW_ICON:
- menu_item_add_check(menu, _("Show filename _text"), VFICON(vf)->show_text,
- G_CALLBACK(vficon_pop_menu_show_names_cb), vf);
- break;
+ case FILEVIEW_LIST: vflist_pop_menu_add_items(vf, menu); break;
+ case FILEVIEW_ICON: vficon_pop_menu_add_items(vf, menu); break;
}
menu_item_add_check(menu, _("Show star rating"), options->show_star_rating,
return ret;
}
-static void vf_destroy_cb(GtkWidget *widget, gpointer data)
+static void vf_destroy_cb(GtkWidget *, gpointer data)
{
auto vf = static_cast<ViewFile *>(data);
switch (vf->type)
{
- case FILEVIEW_LIST: vflist_destroy_cb(widget, data); break;
- case FILEVIEW_ICON: vficon_destroy_cb(widget, data); break;
+ case FILEVIEW_LIST: vflist_destroy_cb(vf); break;
+ case FILEVIEW_ICON: vficon_destroy_cb(vf); break;
}
if (vf->popup)
switch (type)
{
- case FILEVIEW_LIST: vf = vflist_new(vf, dir_fd); break;
- case FILEVIEW_ICON: vf = vficon_new(vf, dir_fd); break;
+ case FILEVIEW_LIST: vf = vflist_new(vf); break;
+ case FILEVIEW_ICON: vf = vficon_new(vf); break;
}
vf_dnd_init(vf);
switch (vf->type)
{
- case FILEVIEW_LIST: vflist_thumb_progress_count(vf->list, &count, &done); break;
- case FILEVIEW_ICON: vficon_thumb_progress_count(vf->list, &count, &done); break;
+ case FILEVIEW_LIST: vflist_thumb_progress_count(vf->list, count, done); break;
+ case FILEVIEW_ICON: vficon_thumb_progress_count(vf->list, count, done); break;
}
DEBUG_1("thumb progress: %d of %d", done, count);
gint done = 0;
switch (vf->type)
- {
- case FILEVIEW_LIST: vflist_read_metadata_progress_count(vf->list, &count, &done); break;
- case FILEVIEW_ICON: vficon_read_metadata_progress_count(vf->list, &count, &done); break;
- }
+ {
+ case FILEVIEW_LIST: vflist_read_metadata_progress_count(vf->list, count, done); break;
+ case FILEVIEW_ICON: vficon_read_metadata_progress_count(vf->list, count, done); break;
+ }
return static_cast<gdouble>(done) / count;
}