[latexila] Completion: use (un)block_interactive()



commit d88bbff96fec5a5bbe413cfdbad17e9fb995c44d
Author: SÃbastien Wilmet <swilmet src gnome org>
Date:   Tue Aug 16 23:20:51 2011 +0200

    Completion: use (un)block_interactive()
    
    Instead of a dirty "locked" variable.

 src/completion.vala |   10 ----------
 src/document.vala   |   11 +++++++----
 2 files changed, 7 insertions(+), 14 deletions(-)
---
diff --git a/src/completion.vala b/src/completion.vala
index cc42ab5..1828f64 100644
--- a/src/completion.vala
+++ b/src/completion.vala
@@ -69,10 +69,6 @@ public class CompletionProvider : GLib.Object, SourceCompletionProvider
     // character is typed (and also just after match () was called).
     private bool first_populate = true;
 
-    // useful when text is inserted by the program, not the user
-    // TODO use (un)block_interactive ().
-    public bool locked = false;
-
     /* CompletionProvider is a singleton */
     private CompletionProvider ()
     {
@@ -131,9 +127,6 @@ public class CompletionProvider : GLib.Object, SourceCompletionProvider
     {
         first_populate = true;
 
-        if (locked)
-            return false;
-
         bool in_argument = false;
         bool valid_arg_contents = false;
         show_all_proposals = false;
@@ -173,9 +166,6 @@ public class CompletionProvider : GLib.Object, SourceCompletionProvider
 
     public void populate (SourceCompletionContext context)
     {
-        if (locked)
-            return;
-
         TextIter iter = {};
         context.get_iter (iter);
         string? cmd = get_latex_command_at_iter (iter);
diff --git a/src/document.vala b/src/document.vala
index c35c53a..ca2f301 100644
--- a/src/document.vala
+++ b/src/document.vala
@@ -93,19 +93,22 @@ public class Document : Gtk.SourceBuffer
     {
         if (new_file)
             return false;
+
         return base.get_modified ();
     }
 
     public new void insert (TextIter iter, string text, int len)
     {
-        CompletionProvider provider = CompletionProvider.get_default ();
-        provider.locked = true;
+        Gtk.SourceCompletion completion = tab.view.completion;
+        completion.block_interactive ();
+
         base.insert (iter, text, len);
 
-        // HACK: wait one second before delocking completion
+        // HACK: wait one second before delocking completion, it's better than doing a
+        // Utils.flush_queue ().
         Timeout.add_seconds (1, () =>
         {
-            provider.locked = false;
+            completion.unblock_interactive ();
             return false;
         });
     }



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