[gnome-builder] source completion blocking



commit d12bc16f2ab17e32404cc80f5b2018c55c4a2f7c
Author: Christian Hergert <christian hergert me>
Date:   Thu Mar 19 01:03:22 2015 -0700

    source completion blocking

 libide/ide-source-view.c |   28 ++++++++++++++++++++++++++--
 1 files changed, 26 insertions(+), 2 deletions(-)
---
diff --git a/libide/ide-source-view.c b/libide/ide-source-view.c
index 9cb3c8f..6326b92 100644
--- a/libide/ide-source-view.c
+++ b/libide/ide-source-view.c
@@ -4186,6 +4186,7 @@ ide_source_view_focus_in_event (GtkWidget     *widget,
 {
   IdeSourceView *self = (IdeSourceView *)widget;
   IdeSourceViewPrivate *priv = ide_source_view_get_instance_private (self);
+  GtkSourceCompletion *completion;
   gboolean ret;
 
   g_assert (IDE_IS_SOURCE_VIEW (self));
@@ -4193,6 +4194,12 @@ ide_source_view_focus_in_event (GtkWidget     *widget,
   ret = GTK_WIDGET_CLASS (ide_source_view_parent_class)->focus_in_event (widget, event);
 
   /*
+   * Restore the completion window now that we have regained focus.
+   */
+  completion = gtk_source_view_get_completion (GTK_SOURCE_VIEW (self));
+  gtk_source_completion_unblock_interactive (completion);
+
+  /*
    * Restore the insert mark, but ignore selections (since we cant ensure they
    * will stay looking selected, as the other frame could be a view into our
    * own buffer).
@@ -4213,17 +4220,25 @@ ide_source_view_focus_out_event (GtkWidget     *widget,
                                  GdkEventFocus *event)
 {
   IdeSourceView *self = (IdeSourceView *)widget;
+  GtkSourceCompletion *completion;
   gboolean ret;
 
   g_assert (IDE_IS_SOURCE_VIEW (self));
 
-  ret = GTK_WIDGET_CLASS (ide_source_view_parent_class)->focus_out_event (widget, event);
-
   /* save our insert mark for when we focus back in. it could have moved if
    * another view into the same buffer has caused the insert mark to jump.
    */
   ide_source_view_real_save_insert_mark (self);
 
+  ret = GTK_WIDGET_CLASS (ide_source_view_parent_class)->focus_out_event (widget, event);
+
+  /*
+   * Block the completion window while we are not focused. It confuses text
+   * insertion and such.
+   */
+  completion = gtk_source_view_get_completion (GTK_SOURCE_VIEW (self));
+  gtk_source_completion_block_interactive (completion);
+
   /* We don't want highlight-current-line unless the widget is in focus, so
    * disable it until we get re-focused.
    */
@@ -5274,6 +5289,7 @@ static void
 ide_source_view_init (IdeSourceView *self)
 {
   IdeSourceViewPrivate *priv = ide_source_view_get_instance_private (self);
+  GtkSourceCompletion *completion;
   GtkTargetList *target_list;
 
   priv->target_line_offset = -1;
@@ -5286,6 +5302,14 @@ ide_source_view_init (IdeSourceView *self)
                     NULL);
 
   /*
+   * We block completion when we are not focused so that two SourceViews
+   * viewing the same GtkTextBuffer do not both show completion
+   * windows.
+   */
+  completion = gtk_source_view_get_completion (GTK_SOURCE_VIEW (self));
+  gtk_source_completion_block_interactive (completion);
+
+  /*
    * Drag and drop support
    */
   target_list = gtk_drag_dest_get_target_list (GTK_WIDGET (self));


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