#include "layout_image.h"
#include "menu.h"
#include "metadata.h"
+#include "misc.h"
#include "thumb.h"
#include "utilops.h"
#include "ui_fileops.h"
vficon_set_focus(vf, fd);
}
+void vficon_select_list(ViewFile *vf, GList *list)
+{
+ GList *work;
+ FileData *fd;
+
+ if (!list) return;
+
+ work = list;
+ while (work)
+ {
+ fd = work->data;
+ 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);
+ }
+ work = work->next;
+ }
+}
+
void vficon_mark_to_selection(ViewFile *vf, gint mark, MarkToSelectionMode mode)
{
GList *work;
/* ensure focus row col are correct */
vficon_find_position(vf, VFICON(vf)->focus_fd, &VFICON(vf)->focus_row, &VFICON(vf)->focus_column);
#if GTK_CHECK_VERSION(3,0,0)
-/* FIXME: Refer to issue #467 on Github. The thumbnail position is not
+/** @FIXME Refer to issue #467 on Github. The thumbnail position is not
* preserved when the icon view is refreshed. Caused by an unknown call from
* the idle loop. This patch hides the problem.
*/
vf_send_update(vf);
vf_thumb_update(vf);
+ vf_star_update(vf);
}
static void vficon_populate_at_new_size(ViewFile *vf, gint w, gint h, gboolean force)
GList *list;
gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &list, -1);
- // TODO(xsdg): for loop here.
+ /** @todo (xsdg): for loop here. */
for (; list; list = list->next)
{
FileData *fd = list->data;
return NULL;
}
+void vficon_set_star_fd(ViewFile *vf, FileData *fd)
+{
+ GtkTreeModel *store;
+ GtkTreeIter iter;
+ GList *list;
+
+ if (!g_list_find(vf->list, fd)) return;
+ if (!vficon_find_iter(vf, fd, &iter, NULL)) return;
+
+ store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview));
+
+ gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &list, -1);
+ gtk_list_store_set(GTK_LIST_STORE(store), &iter, FILE_COLUMN_POINTER, list, -1);
+}
+
+FileData *vficon_star_next_fd(ViewFile *vf)
+{
+ GtkTreePath *tpath;
+
+ /* first check the visible files */
+
+ if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vf->listview), 0, 0, &tpath, NULL, NULL, NULL))
+ {
+ GtkTreeModel *store;
+ GtkTreeIter iter;
+ gboolean valid = TRUE;
+
+ 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;
+
+ while (valid && tree_view_row_get_visibility(GTK_TREE_VIEW(vf->listview), &iter, FALSE) == 0)
+ {
+ GList *list;
+ gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &list, -1);
+
+ for (; list; list = list->next)
+ {
+ FileData *fd = list->data;
+ if (fd && fd->rating == STAR_RATING_NOT_READ)
+ {
+ vf->stars_filedata = fd;
+
+ if (vf->stars_id == 0)
+ {
+ vf->stars_id = g_idle_add_full(G_PRIORITY_LOW, vf_stars_cb, vf, NULL);
+ }
+
+ return fd;
+ }
+ }
+
+ valid = gtk_tree_model_iter_next(store, &iter);
+ }
+ }
+
+ /* Then iterate through the entire list to load all of them. */
+
+ GList *work;
+ for (work = vf->list; work; work = work->next)
+ {
+ FileData *fd = work->data;
+
+ if (fd && fd->rating == STAR_RATING_NOT_READ)
+ {
+ vf->stars_filedata = fd;
+
+ if (vf->stars_id == 0)
+ {
+ vf->stars_id = g_idle_add_full(G_PRIORITY_LOW, vf_stars_cb, vf, NULL);
+ }
+
+ return fd;
+ }
+ }
+
+ return NULL;
+}
+
/*
*-----------------------------------------------------------------------------
* row stuff
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;
focus_fd = VFICON(vf)->focus_fd;
+ 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);
if (VFICON(vf)->selection)
{
+ old_selected = g_list_copy(VFICON(vf)->selection);
first_selected = VFICON(vf)->selection->data;
file_data_ref(first_selected);
g_list_free(VFICON(vf)->selection);
VFICON(vf)->selection = g_list_reverse(VFICON(vf)->selection);
+ /* Preserve the original selection order */
+ if (old_selected)
+ {
+ GList *reversed_old_selected;
+
+ reversed_old_selected = g_list_reverse(old_selected);
+ while (reversed_old_selected)
+ {
+ GList *tmp;
+ tmp = g_list_find(VFICON(vf)->selection, reversed_old_selected->data);
+ if (tmp)
+ {
+ VFICON(vf)->selection = g_list_remove_link(VFICON(vf)->selection, tmp);
+ VFICON(vf)->selection = g_list_concat(tmp, VFICON(vf)->selection);
+ }
+ reversed_old_selected = reversed_old_selected->next;
+ }
+ g_list_free(old_selected);
+ }
+
filelist_free(new_filelist);
vficon_populate(vf, TRUE, keep_position);
}
file_data_unref(first_selected);
- /* attempt to keep focus on same icon when refreshing */
- if (focus_fd && g_list_find(vf->list, focus_fd))
+ if (start_path)
{
- vficon_set_focus(vf, focus_fd);
+ gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(vf->listview), start_path, NULL, FALSE, 0.0, 0.0);
}
+ gtk_tree_path_free(start_path);
+ gtk_tree_path_free(end_path);
+
return ret;
}
g_assert(fd->magick == FD_MAGICK);
- if (options->show_star_rating)
+ if (options->show_star_rating && fd->rating != STAR_RATING_NOT_READ)
{
- star_rating = metadata_read_rating_stars(fd);
+ star_rating = convert_rating_to_stars(fd->rating);
}
else
{
tip_unschedule(vf);
vf_thumb_cleanup(vf);
+ vf_star_cleanup(vf);
g_list_free(vf->list);
g_list_free(VFICON(vf)->selection);