[gtksourceview] Completion: select first proposal on "move-page"



commit a1383013a099b3fae73c116cfa0e7231cd0513df
Author: SÃbastien Wilmet <swilmet gnome org>
Date:   Tue Jan 22 14:33:29 2013 +0100

    Completion: select first proposal on "move-page"
    
    When we select another provider with Ctrl+left/right, the first proposal
    is selected if needed.

 gtksourceview/gtksourcecompletion.c |   72 ++++++++++++++++++-----------------
 1 files changed, 37 insertions(+), 35 deletions(-)
---
diff --git a/gtksourceview/gtksourcecompletion.c b/gtksourceview/gtksourcecompletion.c
index 42f5acb..bf00d5c 100644
--- a/gtksourceview/gtksourcecompletion.c
+++ b/gtksourceview/gtksourcecompletion.c
@@ -1376,6 +1376,41 @@ gtk_source_completion_move_cursor (GtkSourceCompletion *completion,
 }
 
 static void
+check_first_selected (GtkSourceCompletion *completion)
+{
+	GtkTreeSelection *selection;
+	GtkTreeIter piter;
+	GtkTreeIter first;
+	GtkTreeModel *model;
+
+	model = GTK_TREE_MODEL (completion->priv->model_proposals);
+	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (completion->priv->tree_view_proposals));
+
+	if (!completion->priv->select_first)
+	{
+		return;
+	}
+
+	if (!gtk_tree_model_get_iter_first (model, &first))
+	{
+		return;
+	}
+
+	piter = first;
+
+	while (gtk_source_completion_model_iter_is_header (completion->priv->model_proposals, &piter))
+	{
+		if (!gtk_tree_model_iter_next (model, &piter))
+		{
+			return;
+		}
+	}
+
+	gtk_tree_selection_select_iter (selection, &piter);
+	scroll_to_iter (completion, &first);
+}
+
+static void
 gtk_source_completion_move_page (GtkSourceCompletion *completion,
                                  GtkScrollStep        step,
                                  gint                 num)
@@ -1407,6 +1442,8 @@ gtk_source_completion_move_page (GtkSourceCompletion *completion,
 			select_previous_provider (completion, -1 * num);
 		}
 	}
+
+	check_first_selected (completion);
 }
 
 static gboolean
@@ -2103,41 +2140,6 @@ gtk_source_completion_set_property (GObject      *object,
 }
 
 static void
-check_first_selected (GtkSourceCompletion *completion)
-{
-	GtkTreeSelection *selection;
-	GtkTreeIter piter;
-	GtkTreeIter first;
-	GtkTreeModel *model;
-
-	model = GTK_TREE_MODEL (completion->priv->model_proposals);
-	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (completion->priv->tree_view_proposals));
-
-	if (!completion->priv->select_first)
-	{
-		return;
-	}
-
-	if (!gtk_tree_model_get_iter_first (model, &first))
-	{
-		return;
-	}
-
-	piter = first;
-
-	while (gtk_source_completion_model_iter_is_header (completion->priv->model_proposals, &piter))
-	{
-		if (!gtk_tree_model_iter_next (model, &piter))
-		{
-			return;
-		}
-	}
-
-	gtk_tree_selection_select_iter (selection, &piter);
-	scroll_to_iter (completion, &first);
-}
-
-static void
 gtk_source_completion_hide_default (GtkSourceCompletion *completion)
 {
 	gtk_label_set_markup (GTK_LABEL (completion->priv->default_info), "");



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