[gthumb] Fixed flashing of the file list when setting the thumbnails
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] Fixed flashing of the file list when setting the thumbnails
- Date: Thu, 3 Nov 2011 17:07:14 +0000 (UTC)
commit 4587d3031933cd264c7c6705c2d9da0446a13c99
Author: Paolo Bacchilega <paobac src gnome org>
Date: Thu Nov 3 17:39:15 2011 +0100
Fixed flashing of the file list when setting the thumbnails
gthumb/gth-file-list.c | 13 ++++++++++
gthumb/gth-file-store.c | 59 ++++++++++++++++++++++++++++++++--------------
gthumb/gth-file-store.h | 1 +
3 files changed, 55 insertions(+), 18 deletions(-)
---
diff --git a/gthumb/gth-file-list.c b/gthumb/gth-file-list.c
index 3e3d819..8396223 100644
--- a/gthumb/gth-file-list.c
+++ b/gthumb/gth-file-list.c
@@ -617,6 +617,15 @@ file_store_rows_reordered_cb (GtkTreeModel *tree_model,
static void
+file_store_thumnail_changed_cb (GthFileStore *file_store,
+ gpointer user_data)
+{
+ GthFileList *file_list = user_data;
+ gtk_widget_queue_draw (file_list->priv->view);
+}
+
+
+static void
gth_file_list_construct (GthFileList *file_list,
GtkWidget *file_view,
GthFileListType list_type,
@@ -669,6 +678,10 @@ gth_file_list_construct (GthFileList *file_list,
"rows-reordered",
G_CALLBACK (file_store_rows_reordered_cb),
file_list);
+ g_signal_connect (model,
+ "thumbnail-changed",
+ G_CALLBACK (file_store_thumnail_changed_cb),
+ file_list);
if (enable_drag_drop) {
GtkTargetList *target_list;
diff --git a/gthumb/gth-file-store.c b/gthumb/gth-file-store.c
index f182add..9157222 100644
--- a/gthumb/gth-file-store.c
+++ b/gthumb/gth-file-store.c
@@ -33,6 +33,7 @@
enum {
CHECK_CHANGED,
VISIBILITY_CHANGED,
+ THUMBNAIL_CHANGED,
LAST_SIGNAL
};
@@ -239,6 +240,15 @@ gth_file_store_class_init (GthFileStoreClass *klass)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
+ gth_file_store_signals[THUMBNAIL_CHANGED] =
+ g_signal_new ("thumbnail-changed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GthFileStoreClass, thumbnail_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
}
@@ -658,23 +668,6 @@ _gth_file_store_get_files (GthFileStore *file_store)
}
-static void
-_gth_file_store_row_changed (GthFileStore *file_store,
- GthFileRow *row)
-{
- GtkTreePath *path;
- GtkTreeIter iter;
-
- path = gtk_tree_path_new ();
- gtk_tree_path_append_index (path, row->pos);
- gth_file_store_get_iter (GTK_TREE_MODEL (file_store), &iter, path);
-
- gtk_tree_model_row_changed (GTK_TREE_MODEL (file_store), path, &iter);
-
- gtk_tree_path_free (path);
-}
-
-
static int
campare_row_func (gconstpointer a,
gconstpointer b,
@@ -1507,6 +1500,25 @@ gth_file_store_queue_set (GthFileStore *file_store,
static void
+_gth_file_store_row_changed (GthFileStore *file_store,
+ GthFileRow *row)
+{
+ GtkTreePath *path;
+ GtkTreeIter iter;
+
+ path = gtk_tree_path_new ();
+ gtk_tree_path_append_index (path, row->pos);
+
+ iter.stamp = file_store->priv->stamp;
+ iter.user_data = row;
+
+ gtk_tree_model_row_changed (GTK_TREE_MODEL (file_store), path, &iter);
+
+ gtk_tree_path_free (path);
+}
+
+
+static void
_gth_file_store_list_changed (GthFileStore *file_store)
{
int i;
@@ -1524,8 +1536,19 @@ _gth_file_store_list_changed (GthFileStore *file_store)
void
gth_file_store_exec_set (GthFileStore *file_store)
{
- _gth_file_store_list_changed (file_store);
+ /* This is an speed optimization. When the thumbnails are updated in
+ * the store the visibility doesn't need to be updated, so we avoid to
+ * emit the 'row-changed' signal for each row, which causes the
+ * GtkIconView to invalidate the size of all the items, and instead
+ * emit a single 'thumbnail-changed' signal that can be used to just
+ * redraw GtkIconView (as done in gth-file-list.c). */
+ if (file_store->priv->update_filter || file_store->priv->check_changed)
+ _gth_file_store_list_changed (file_store);
+ else
+ g_signal_emit (file_store, gth_file_store_signals[THUMBNAIL_CHANGED], 0, NULL);
+
_gth_file_store_clear_queue (file_store);
+
if (file_store->priv->update_filter) {
_gth_file_store_update_visibility (file_store, NULL, -1);
file_store->priv->update_filter = FALSE;
diff --git a/gthumb/gth-file-store.h b/gthumb/gth-file-store.h
index 564eff5..6500923 100644
--- a/gthumb/gth-file-store.h
+++ b/gthumb/gth-file-store.h
@@ -62,6 +62,7 @@ struct _GthFileStoreClass
void (*visibility_changed) (GthFileStore *self);
void (*check_changed) (GthFileStore *self);
+ void (*thumbnail_changed) (GthFileStore *self);
};
GType gth_file_store_get_type (void) G_GNUC_CONST;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]