[latexila] Structure: disconnect the model from the view when parsing



commit c74911413784518d2c95290e7e0065ed7d793c02
Author: Sébastien Wilmet <sebastien wilmet gmail com>
Date:   Mon Jun 6 21:53:36 2011 +0200

    Structure: disconnect the model from the view when parsing
    
    Before, a flush was needed because when the model is connected, the
    parsing was not done. Now, we connect the model only when the parsing is
    done, so no flush is needed.

 src/document_structure.vala |    3 +++
 src/structure.vala          |   11 ++++++-----
 2 files changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/src/document_structure.vala b/src/document_structure.vala
index 2d8601e..ddfaf9d 100644
--- a/src/document_structure.vala
+++ b/src/document_structure.vala
@@ -38,6 +38,8 @@ public class DocumentStructure : GLib.Object
 
     private bool _measure_parsing_time = true;
 
+    public signal void parsing_done ();
+
     public DocumentStructure (TextBuffer doc)
     {
         _doc = doc;
@@ -140,6 +142,7 @@ public class DocumentStructure : GLib.Object
             stdout.printf ("Structure parsing took %f seconds\n", timer.elapsed ());
         }
 
+        parsing_done ();
         return false;
     }
 
diff --git a/src/structure.vala b/src/structure.vala
index 36d0aa2..a32d606 100644
--- a/src/structure.vala
+++ b/src/structure.vala
@@ -335,12 +335,17 @@ public class Structure : VBox
         if (doc == null)
             return;
 
+        _tree_view.set_model (null);
+
         DocumentStructure doc_struct = doc.get_structure ();
 
         if (force_parse)
             doc_struct.parse ();
 
-        set_model (doc_struct.get_model ());
+        doc_struct.parsing_done.connect (() =>
+        {
+            set_model (doc_struct.get_model ());
+        });
     }
 
     private void set_model (StructureModel model)
@@ -355,11 +360,7 @@ public class Structure : VBox
         });
 
         _tree_view.set_model (_tree_filter);
-
-        // the flush queue is needed because the expand_all doesn't work without
-        Utils.flush_queue ();
         _tree_view.expand_all ();
-
         _tree_view.columns_autosize ();
     }
 



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