[gtksourceview] Completion: fix the update of the window position



commit 69f7d1dfa981e1e86b0f02e8c5149cf5493ee834
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sat Mar 16 21:53:20 2013 +0100

    Completion: fix the update of the window position
    
    The window position was updated too many times. In some situations, we
    could see the intermediate positions, if these intermediate positions
    were not the same as the final position. So when typing characters at a
    certain speed, the completion window was shaking. Although it's quite
    funny, it's better if it is fixed :)

 gtksourceview/gtksourcecompletion.c |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/gtksourceview/gtksourcecompletion.c b/gtksourceview/gtksourcecompletion.c
index 667fbfd..f74ba68 100644
--- a/gtksourceview/gtksourcecompletion.c
+++ b/gtksourceview/gtksourcecompletion.c
@@ -255,7 +255,8 @@ get_selected_proposal (GtkSourceCompletion          *completion,
        return TRUE;
 }
 
-static void
+/* Returns %TRUE if the first proposal is selected. */
+static gboolean
 check_first_selected (GtkSourceCompletion *completion)
 {
        GtkTreeSelection *selection;
@@ -264,17 +265,19 @@ check_first_selected (GtkSourceCompletion *completion)
        if (get_selected_proposal (completion, NULL, NULL) ||
            !completion->priv->select_on_show)
        {
-               return;
+               return FALSE;
        }
 
        if (!gtk_source_completion_model_first_proposal (completion->priv->model_proposals, &iter))
        {
-               return;
+               return FALSE;
        }
 
        selection = gtk_tree_view_get_selection (completion->priv->tree_view_proposals);
        gtk_tree_selection_select_iter (selection, &iter);
        scroll_to_iter (completion, &iter);
+
+       return TRUE;
 }
 
 static void
@@ -1063,7 +1066,11 @@ selection_changed_cb (GtkTreeSelection    *selection,
                      GtkSourceCompletion *completion)
 {
        update_proposal_info (completion);
-       update_window_position (completion);
+
+       if (get_selected_proposal (completion, NULL, NULL))
+       {
+               update_window_position (completion);
+       }
 }
 
 static gboolean
@@ -1363,8 +1370,10 @@ populating_done (GtkSourceCompletion        *completion,
                g_signal_emit (completion, signals[SHOW], 0);
        }
 
-       check_first_selected (completion);
-       update_window_position (completion);
+       if (!check_first_selected (completion))
+       {
+               update_window_position (completion);
+       }
 }
 
 static void


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