summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorinfirit <[email protected]>2014-07-28 13:03:02 +0200
committerinfirit <[email protected]>2014-07-28 13:03:02 +0200
commit75b1c89f03f798dfaeaccf21af77e45bae13ff9c (patch)
tree609cbbb4d10ac4a39d9f093a0daf24b508191394
parent8d2169d463ad00cf3e8ef74ec35b1651ea1dd634 (diff)
downloadeom-75b1c89f03f798dfaeaccf21af77e45bae13ff9c.tar.bz2
eom-75b1c89f03f798dfaeaccf21af77e45bae13ff9c.tar.xz
Update the thumbview visible range in an idle callback
This avoids entering in an infinite loop of unsetting a thumbnail, relayouting the iconview, updating the adjustment, setting the thumbnail, relayouting the iconview, updating the adjustment, unsetting the thumbnail, and so on. Bug https://bugzilla.gnome.org/show_bug.cgi?id=639312 Based on eog commit a395e95c5df2c4cbae9ce749544ec62820746e40 From Claudio Saavedra <[email protected]>
-rw-r--r--src/eom-thumb-view.c69
1 files changed, 39 insertions, 30 deletions
diff --git a/src/eom-thumb-view.c b/src/eom-thumb-view.c
index 0c35382..4874f53 100644
--- a/src/eom-thumb-view.c
+++ b/src/eom-thumb-view.c
@@ -80,6 +80,7 @@ struct _EomThumbViewPrivate {
gint end_thumb; /* the last visible thumbnail */
GtkWidget *menu; /* a contextual menu for thumbnails */
GtkCellRenderer *pixbuf_cell;
+ gint visible_range_changed_id;
};
/* Drag 'n Drop */
@@ -146,6 +147,19 @@ eom_thumb_view_constructed (GObject *object)
}
static void
+eom_thumb_view_dispose (GObject *object)
+{
+ EomThumbViewPrivate *priv = EOM_THUMB_VIEW (object)->priv;
+
+ if (priv->visible_range_changed_id != 0) {
+ g_source_remove (priv->visible_range_changed_id);
+ priv->visible_range_changed_id = 0;
+ }
+
+ G_OBJECT_CLASS (eom_thumb_view_parent_class)->dispose (object);
+}
+
+static void
eom_thumb_view_finalize (GObject *object)
{
EomThumbView *thumbview;
@@ -183,6 +197,7 @@ eom_thumb_view_class_init (EomThumbViewClass *class)
GtkObjectClass *object_class = GTK_OBJECT_CLASS (class);
#endif
gobject_class->constructed = eom_thumb_view_constructed;
+ gobject_class->dispose = eom_thumb_view_dispose;
gobject_class->finalize = eom_thumb_view_finalize;
#if GTK_CHECK_VERSION(3, 0, 0)
widget_class->destroy = eom_thumb_view_destroy;
@@ -265,14 +280,15 @@ eom_thumb_view_update_visible_range (EomThumbView *thumbview,
priv->end_thumb = end_thumb;
}
-static void
-thumbview_on_visible_range_changed_cb (EomThumbView *thumbview,
- gpointer user_data)
+static gboolean
+visible_range_changed_cb (EomThumbView *thumbview)
{
GtkTreePath *path1, *path2;
+ thumbview->priv->visible_range_changed_id = 0;
+
if (!gtk_icon_view_get_visible_range (GTK_ICON_VIEW (thumbview), &path1, &path2)) {
- return;
+ return FALSE;
}
if (path1 == NULL) {
@@ -288,40 +304,31 @@ thumbview_on_visible_range_changed_cb (EomThumbView *thumbview,
gtk_tree_path_free (path1);
gtk_tree_path_free (path2);
+
+ return FALSE;
}
static void
-thumbview_on_adjustment_changed_cb (EomThumbView *thumbview,
- gpointer user_data)
+eom_thumb_view_visible_range_changed (EomThumbView *thumbview)
{
- GtkTreePath *path1, *path2;
- gint start_thumb, end_thumb;
-
- if (!gtk_icon_view_get_visible_range (GTK_ICON_VIEW (thumbview), &path1, &path2)) {
- return;
- }
-
- if (path1 == NULL) {
- path1 = gtk_tree_path_new_first ();
- }
- if (path2 == NULL) {
- gint n_items = gtk_tree_model_iter_n_children (gtk_icon_view_get_model (GTK_ICON_VIEW (thumbview)), NULL);
- path2 = gtk_tree_path_new_from_indices (n_items - 1 , -1);
+ if (thumbview->priv->visible_range_changed_id == 0) {
+ g_idle_add ((GSourceFunc)visible_range_changed_cb, thumbview);
}
- start_thumb = gtk_tree_path_get_indices (path1) [0];
- end_thumb = gtk_tree_path_get_indices (path2) [0];
-
- eom_thumb_view_add_range (thumbview, start_thumb, end_thumb);
-
- /* case we added an image, we need to make sure that the shifted thumbnail is cleared */
- eom_thumb_view_clear_range (thumbview, end_thumb + 1, end_thumb + 1);
+}
- thumbview->priv->start_thumb = start_thumb;
- thumbview->priv->end_thumb = end_thumb;
+static void
+thumbview_on_visible_range_changed_cb (EomThumbView *thumbview,
+ gpointer user_data)
+{
+ eom_thumb_view_visible_range_changed (thumbview);
+}
- gtk_tree_path_free (path1);
- gtk_tree_path_free (path2);
+static void
+thumbview_on_adjustment_changed_cb (EomThumbView *thumbview,
+ gpointer user_data)
+{
+ eom_thumb_view_visible_range_changed (thumbview);
}
static void
@@ -604,6 +611,8 @@ static void
eom_thumb_view_init (EomThumbView *thumbview)
{
thumbview->priv = EOM_THUMB_VIEW_GET_PRIVATE (thumbview);
+
+ thumbview->priv->visible_range_changed_id = 0;
}
/**