[gthumb] grid view: redraw the focused item only once



commit 89c5c156feb5494a937695ac5444f986c2af41fc
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sun Sep 11 09:55:30 2016 +0200

    grid view: redraw the focused item only once

 gthumb/gth-grid-view.c |   22 ++++++++++++----------
 1 files changed, 12 insertions(+), 10 deletions(-)
---
diff --git a/gthumb/gth-grid-view.c b/gthumb/gth-grid-view.c
index e6db2a6..6acd38e 100644
--- a/gthumb/gth-grid-view.c
+++ b/gthumb/gth-grid-view.c
@@ -2498,25 +2498,27 @@ gth_grid_view_cursor_changed (GthFileView *file_view,
                              int          pos)
 {
        GthGridView     *self = GTH_GRID_VIEW (file_view);
-       GthGridViewItem *old_item;
        GList           *link;
        GthGridViewItem *new_item;
 
-       old_item = NULL;
-       if (self->priv->focused_item >= 0) {
-               link = g_list_nth (self->priv->items, self->priv->focused_item);
-               if (link != NULL)
-                       old_item = link->data;
+       if (pos != self->priv->focused_item) {
+               GthGridViewItem *old_item = NULL;
+
+               if (self->priv->focused_item >= 0) {
+                       link = g_list_nth (self->priv->items, self->priv->focused_item);
+                       if (link != NULL)
+                               old_item = link->data;
+               }
+               if (old_item != NULL) {
+                       old_item->state ^= GTK_STATE_FLAG_FOCUSED | GTK_STATE_FLAG_ACTIVE;
+                       _gth_grid_view_queue_draw_item (self, old_item);
+               }
        }
 
        link = g_list_nth (self->priv->items, pos);
        g_return_if_fail (link != NULL);
 
        self->priv->focused_item = pos;
-       if (old_item != NULL) {
-               old_item->state ^= GTK_STATE_FLAG_FOCUSED | GTK_STATE_FLAG_ACTIVE;
-               _gth_grid_view_queue_draw_item (self, old_item);
-       }
 
        new_item = link->data;
        new_item->state |= GTK_STATE_FLAG_FOCUSED | GTK_STATE_FLAG_ACTIVE;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]