[gtksourceview] BufferOutputStream: only one user action for the whole file loading



commit e9cfcd885ca8b8567a317ca7450f7759eb407ca9
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Tue May 17 14:08:24 2016 +0200

    BufferOutputStream: only one user action for the whole file loading
    
    Some applications or higher-level libraries have a ::cursor-moved
    signal, that is emitted only when the number of nested user actions is
    0. So begin/end a user action for the whole file loading prevents
    useless signal emissions.
    
    And as the comment says in the code, a file loading should be seen as
    only one user action.

 gtksourceview/gtksourcebufferoutputstream.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/gtksourceview/gtksourcebufferoutputstream.c b/gtksourceview/gtksourcebufferoutputstream.c
index 81d7149..8bd8736 100644
--- a/gtksourceview/gtksourcebufferoutputstream.c
+++ b/gtksourceview/gtksourcebufferoutputstream.c
@@ -768,6 +768,7 @@ end_append_text_to_document (GtkSourceBufferOutputStream *stream)
        gtk_text_buffer_set_modified (GTK_TEXT_BUFFER (stream->priv->source_buffer),
                                      FALSE);
 
+       gtk_text_buffer_end_user_action (GTK_TEXT_BUFFER (stream->priv->source_buffer));
        gtk_source_buffer_end_not_undoable_action (stream->priv->source_buffer);
 }
 
@@ -945,8 +946,13 @@ gtk_source_buffer_output_stream_write (GOutputStream  *stream,
                        g_free (from_charset);
                }
 
-               /* Init the undoable action */
+               /* Begin not undoable action. Begin also a normal user action,
+                * since we load the file chunk by chunk and it should be seen
+                * as only one action, for the features that rely on the user
+                * action.
+                */
                gtk_source_buffer_begin_not_undoable_action (ostream->priv->source_buffer);
+               gtk_text_buffer_begin_user_action (GTK_TEXT_BUFFER (ostream->priv->source_buffer));
 
                gtk_text_buffer_get_start_iter (GTK_TEXT_BUFFER (ostream->priv->source_buffer),
                                                &ostream->priv->pos);


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