#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;