file->rating = atoi(rating_str);
g_free(rating_str);
}
+ else
+ {
+ file->rating = 0;
+ }
}
void set_exif_time_data(GList *files)
gint active_mark;
gint clicked_mark;
+ /* stars */
+ FileData *stars_filedata;
+ guint stars_id;
+
/* refresh */
guint refresh_idle_id; /* event source id */
time_t time_refresh_set; /* time when refresh_idle_id was set */
void vf_read_metadata_in_idle(ViewFile *vf);
void vf_file_filter_set(ViewFile *vf, gboolean enable);
GRegex *vf_file_filter_get_filter(ViewFile *vf);
+
+void vf_star_update(ViewFile *vf);
+gboolean vf_stars_cb(gpointer data);
+void vf_star_stop(ViewFile *vf);
+void vf_star_cleanup(ViewFile *vf);
+
#endif /* VIEW_FILE_H */
/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
while (vf_thumb_next(vf));
}
+void vf_star_cleanup(ViewFile *vf)
+{
+ if (vf->stars_id != 0)
+ {
+ g_source_remove(vf->stars_id);
+ }
+
+ vf->stars_id = 0;
+ vf->stars_filedata = NULL;
+}
+
+void vf_star_stop(ViewFile *vf)
+{
+ vf_star_cleanup(vf);
+}
+
+static void vf_set_star_fd(ViewFile *vf, FileData *fd)
+{
+ switch (vf->type)
+ {
+ case FILEVIEW_LIST: vflist_set_star_fd(vf, fd); break;
+ case FILEVIEW_ICON: vficon_set_star_fd(vf, fd); break;
+ default: break;
+ }
+}
+
+static void vf_star_do(ViewFile *vf, FileData *fd)
+{
+ if (!fd) return;
+
+ vf_set_star_fd(vf, fd);
+}
+
+static gboolean vf_star_next(ViewFile *vf)
+{
+ FileData *fd = NULL;
+
+ switch (vf->type)
+ {
+ case FILEVIEW_LIST: fd = vflist_star_next_fd(vf); break;
+ case FILEVIEW_ICON: fd = vficon_star_next_fd(vf); break;
+ default: break;
+ }
+
+ if (!fd)
+ {
+ /* done */
+ vf_star_cleanup(vf);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+gboolean vf_stars_cb(gpointer data)
+{
+ ViewFile *vf = data;
+ FileData *fd = vf->stars_filedata;
+
+ if (fd)
+ {
+ read_rating_data(fd);
+
+ vf_star_do(vf, fd);
+
+ if (vf_star_next(vf))
+ {
+ return TRUE;
+ }
+ else
+ {
+ vf->stars_filedata = NULL;
+ vf->stars_id = 0;
+ return FALSE;
+ }
+ }
+
+ return FALSE;
+}
+
+void vf_star_update(ViewFile *vf)
+{
+ vf_star_stop(vf);
+
+ if (!options->show_star_rating)
+ {
+ return;
+ }
+
+ vf_star_next(vf);
+}
void vf_marks_set(ViewFile *vf, gboolean enable)
{
#include "layout_image.h"
#include "menu.h"
#include "metadata.h"
+#include "misc.h"
#include "thumb.h"
#include "utilops.h"
#include "ui_fileops.h"
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)
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
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);
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);
+
#endif
/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
#include "layout_image.h"
#include "menu.h"
#include "metadata.h"
+#include "misc.h"
#include "thumb.h"
#include "utilops.h"
#include "ui_fileops.h"
g_free(sidecars);
g_free(name);
g_free(formatted);
+ g_free(formatted_with_stars);
}
static void vflist_setup_iter(ViewFile *vf, GtkTreeStore *store, GtkTreeIter *iter, FileData *fd)
gboolean expanded = FALSE;
gchar *star_rating;
- 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
{
return fd;
}
+void vflist_set_star_fd(ViewFile *vf, FileData *fd)
+{
+ GtkTreeStore *store;
+ GtkTreeIter iter;
+ gchar *name;
+ gchar *sidecars;
+ gchar *size;
+ gchar *time;
+ gchar *star_rating;
+ gchar *formatted_with_stars;
+ gboolean expanded;
+
+ if (!fd || vflist_find_row(vf, fd, &iter) < 0) return;
+
+ star_rating = metadata_read_rating_stars(fd);
+
+ store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)));
+ gtk_tree_store_set(store, &iter, FILE_COLUMN_STAR_RATING, star_rating, -1);
+
+ gtk_tree_model_get(GTK_TREE_MODEL(store), &iter,
+ FILE_COLUMN_NAME, &name,
+ FILE_COLUMN_SIDECARS, &sidecars,
+ FILE_COLUMN_SIZE, &size,
+ FILE_COLUMN_DATE, &time,
+ FILE_COLUMN_EXPANDED, &expanded,
+ -1);
+
+ formatted_with_stars = vflist_get_formatted(vf, name, sidecars, size, time, expanded, TRUE, star_rating);
+
+ gtk_tree_store_set(store, &iter, FILE_COLUMN_FORMATTED_WITH_STARS, formatted_with_stars,
+ FILE_COLUMN_EXPANDED, expanded,
+ -1);
+
+ g_free(star_rating);
+ g_free(formatted_with_stars);
+}
+
+FileData *vflist_star_next_fd(ViewFile *vf)
+{
+ GtkTreePath *tpath;
+ FileData *fd = NULL;
+ FileData *nfd = NULL;
+
+ /* 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 (!fd && valid && tree_view_row_get_visibility(GTK_TREE_VIEW(vf->listview), &iter, FALSE) == 0)
+ {
+ GList *work;
+
+ gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &nfd, -1);
+
+ if (nfd && nfd->rating == STAR_RATING_NOT_READ)
+ {
+ fd = nfd;
+ }
+
+ valid = gtk_tree_model_iter_next(store, &iter);
+ }
+
+ if (fd)
+ {
+ vf->stars_filedata = fd;
+
+ if (vf->stars_id == 0)
+ {
+ vf->stars_id = g_idle_add_full(G_PRIORITY_LOW, vf_stars_cb, vf, NULL);
+ }
+ }
+ }
+
+ /* then find first undone */
+
+ if (!fd)
+ {
+ GList *work = vf->list;
+
+ while (work && !fd)
+ {
+ FileData *fd_p = work->data;
+
+ if (fd_p && fd_p->rating == STAR_RATING_NOT_READ)
+ {
+ fd = fd_p;
+ }
+ else
+ {
+ fd = NULL;
+ }
+
+ work = work->next;
+ }
+
+ if (fd)
+ {
+ 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;
+}
+
/*
*-----------------------------------------------------------------------------
* row stuff
store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)));
vf_thumb_stop(vf);
+ vf_star_stop(vf);
if (!vf->list)
{
vf_send_update(vf);
vf_thumb_update(vf);
+ vf_star_update(vf);
}
gboolean vflist_refresh(ViewFile *vf)
vflist_select_idle_cancel(vf);
vf_refresh_idle_cancel(vf);
vf_thumb_stop(vf);
+ vf_star_stop(vf);
filelist_free(vf->list);
}
FileData *vflist_thumb_next_fd(ViewFile *vf);
void vflist_thumb_reset_all(ViewFile *vf);
void vflist_pop_menu_show_star_rating_cb(GtkWidget *widget, gpointer data);
+
+FileData *vflist_star_next_fd(ViewFile *vf);
+void vflist_set_star_fd(ViewFile *vf, FileData *fd);
+
#endif
/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */