[gnome-text-editor] page: remove focusability while loading



commit 849b5b0d90787824fcd149dfa6b8cf159662a9c9
Author: Christian Hergert <chergert redhat com>
Date:   Mon Aug 1 12:43:44 2022 -0700

    page: remove focusability while loading
    
    This might make things a bit tricky for initial display scenarios, but its
    best if you can't focus (or edit) the view while we are loading as it can
    cause GTK a11y to update state heavily to sync with the display server.
    
    Related #444

 src/editor-page.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
---
diff --git a/src/editor-page.c b/src/editor-page.c
index 1ad4781..d211532 100644
--- a/src/editor-page.c
+++ b/src/editor-page.c
@@ -138,6 +138,23 @@ editor_page_document_modified_changed_cb (EditorPage     *self,
   g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TITLE]);
 }
 
+static void
+editor_page_document_notify_loading_cb (EditorPage     *self,
+                                        GParamSpec     *pspec,
+                                        EditorDocument *document)
+{
+  gboolean loading;
+
+  g_assert (EDITOR_IS_PAGE (self));
+  g_assert (EDITOR_IS_DOCUMENT (document));
+
+  /* Don't allow focus on the textview while loading as it can
+   * cause GTK to try to keep a11y operations up to date.
+   */
+  loading = _editor_document_get_loading (document);
+  gtk_widget_set_can_focus (GTK_WIDGET (self), !loading);
+}
+
 static void
 editor_page_document_notify_title_cb (EditorPage     *self,
                                       GParamSpec     *pspec,
@@ -268,6 +285,11 @@ editor_page_set_document (EditorPage     *self,
       gtk_text_view_set_buffer (GTK_TEXT_VIEW (self->view),
                                 GTK_TEXT_BUFFER (document));
 
+      g_signal_connect_object (document,
+                               "notify::loading",
+                               G_CALLBACK (editor_page_document_notify_loading_cb),
+                               self,
+                               G_CONNECT_SWAPPED);
       g_signal_connect_object (document,
                                "notify::title",
                                G_CALLBACK (editor_page_document_notify_title_cb),


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