[gnome-builder/wip/chergert/perspective] source-view: fix select-all when focus is not in source view



commit 650165c0cbd094b02d3a8eb88a89b3f619d3e4b6
Author: Christian Hergert <chergert redhat com>
Date:   Thu Dec 3 21:23:07 2015 -0800

    source-view: fix select-all when focus is not in source view

 libide/ide-source-view.c |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/libide/ide-source-view.c b/libide/ide-source-view.c
index 828e083..7f2ac7c 100644
--- a/libide/ide-source-view.c
+++ b/libide/ide-source-view.c
@@ -150,6 +150,7 @@ typedef struct
   guint                        enable_word_completion : 1;
   guint                        highlight_current_line : 1;
   guint                        in_replay_macro : 1;
+  guint                        insert_mark_cleared : 1;
   guint                        insert_matching_brace : 1;
   guint                        overwrite_braces : 1;
   guint                        recording_macro : 1;
@@ -3294,6 +3295,12 @@ ide_source_view_real_restore_insert_mark_full (IdeSourceView *self,
 
   g_assert (IDE_IS_SOURCE_VIEW (self));
 
+  if (priv->insert_mark_cleared)
+    {
+      priv->insert_mark_cleared = FALSE;
+      return;
+    }
+
   buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self));
   gtk_text_buffer_get_iter_at_line (buffer, &iter, priv->saved_line);
   gtk_text_buffer_get_iter_at_line (buffer, &selection, priv->saved_selection_line);
@@ -3343,6 +3350,8 @@ ide_source_view_real_save_insert_mark (IdeSourceView *self)
 
   g_assert (IDE_IS_SOURCE_VIEW (self));
 
+  priv->insert_mark_cleared = FALSE;
+
   buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self));
   insert = gtk_text_buffer_get_insert (buffer);
   selection_bound = gtk_text_buffer_get_selection_bound (buffer);
@@ -4922,6 +4931,19 @@ ide_source_view_real_delete_from_cursor (GtkTextView   *text_view,
 }
 
 static void
+ide_source_view_real_select_all (IdeSourceView *self,
+                                 gboolean       select_)
+{
+  IdeSourceViewPrivate *priv = ide_source_view_get_instance_private (self);
+
+  g_assert (IDE_IS_SOURCE_VIEW (self));
+
+  g_signal_chain_from_overridden_handler (self, select_);
+
+  priv->insert_mark_cleared = TRUE;
+}
+
+static void
 ide_source_view_dispose (GObject *object)
 {
   IdeSourceView *self = (IdeSourceView *)object;
@@ -5891,6 +5913,10 @@ ide_source_view_class_init (IdeSourceViewClass *klass)
                   G_TYPE_NONE,
                   0);
 
+  g_signal_override_class_handler ("select-all",
+                                   G_TYPE_FROM_CLASS (klass),
+                                   G_CALLBACK (ide_source_view_real_select_all));
+
   signals [SELECTION_THEATRIC] =
     g_signal_new ("selection-theatric",
                   G_TYPE_FROM_CLASS (klass),


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