[gnome-builder] symbol-tree: only reload symbol tree if document or change-count changed



commit 6cf72e2c5e7f0d26c0d726a7a81d1829f02aa972
Author: Christian Hergert <chergert redhat com>
Date:   Mon Oct 12 22:19:29 2015 -0400

    symbol-tree: only reload symbol tree if document or change-count changed
    
    This should help with flicker a bit in the symbol tree, also, over active
    reloading.

 plugins/symbol-tree/symbol-tree.c |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/plugins/symbol-tree/symbol-tree.c b/plugins/symbol-tree/symbol-tree.c
index 88f19e3..2d9ec6d 100644
--- a/plugins/symbol-tree/symbol-tree.c
+++ b/plugins/symbol-tree/symbol-tree.c
@@ -42,6 +42,9 @@ struct _SymbolTree
   GbTree         *tree;
   GtkSearchEntry *search_entry;
 
+  GbDocument     *last_document;
+  gsize           last_change_count;
+
   guint           refresh_tree_timeout;
 };
 
@@ -119,21 +122,26 @@ refresh_tree (SymbolTree *self)
   GtkWidget *active_view;
   GbWorkbench *workbench;
   GbDocument *document = NULL;
-  GbTreeNode *root;
+  gsize change_count = 0;
 
   g_assert (SYMBOL_IS_TREE (self));
 
   workbench = gb_widget_get_workbench (GTK_WIDGET (self));
 
   if ((active_view = gb_workbench_get_active_view (workbench)) && GB_IS_EDITOR_VIEW (active_view))
-    document = gb_view_get_document (GB_VIEW (active_view));
-
-  root = gb_tree_get_root (self->tree);
+    {
+      document = gb_view_get_document (GB_VIEW (active_view));
+      if (IDE_IS_BUFFER (document))
+        change_count = ide_buffer_get_change_count (IDE_BUFFER (document));
+    }
 
-  if ((GObject *)document != gb_tree_node_get_item (root))
+  if ((document != self->last_document) || (self->last_change_count < change_count))
     {
       ide_clear_source (&self->refresh_tree_timeout);
 
+      self->last_document = document;
+      self->last_change_count = change_count;
+
       /*
        * Clear the old tree items.
        *
@@ -175,6 +183,7 @@ notify_active_view_cb (SymbolTree  *self,
   g_assert (GB_IS_WORKBENCH (workbench));
 
   refresh_tree (self);
+  gtk_entry_set_text (GTK_ENTRY (self->search_entry), "");
 }
 
 static void


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