[gnome-text-editor] page: avoid property emission while loading
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-text-editor] page: avoid property emission while loading
- Date: Mon, 1 Aug 2022 19:05:33 +0000 (UTC)
commit 4d8a06715afceaa8a58130776eca8d5ed860e67d
Author: Christian Hergert <chergert redhat com>
Date: Mon Aug 1 12:05:18 2022 -0700
page: avoid property emission while loading
We don't want to spam the consumers while loading the document, but
additionally we don't want to do this when we are in failure cases like
inserting iconv data byte by byte.
Related #444
src/editor-document-private.h | 1 +
src/editor-document.c | 16 ++++++++++++----
src/editor-page.c | 7 ++++++-
3 files changed, 19 insertions(+), 5 deletions(-)
---
diff --git a/src/editor-document-private.h b/src/editor-document-private.h
index c934fc4..be1319b 100644
--- a/src/editor-document-private.h
+++ b/src/editor-document-private.h
@@ -31,6 +31,7 @@ void _editor_document_set_draft_id (EditorDocume
const gchar *draft_id);
GFile *_editor_document_get_draft_file (EditorDocument *self);
gchar *_editor_document_dup_uri (EditorDocument *self);
+gboolean _editor_document_get_loading (EditorDocument *self);
void _editor_document_mark_busy (EditorDocument *self);
void _editor_document_unmark_busy (EditorDocument *self);
void _editor_document_set_externally_modified (EditorDocument *self,
diff --git a/src/editor-document.c b/src/editor-document.c
index 974372c..5abafd1 100644
--- a/src/editor-document.c
+++ b/src/editor-document.c
@@ -283,8 +283,6 @@ editor_document_load_notify_completed_cb (EditorDocument *self,
GParamSpec *pspec,
GTask *task)
{
- EditorSession *session;
-
g_assert (EDITOR_IS_DOCUMENT (self));
g_assert (G_IS_TASK (task));
@@ -293,8 +291,10 @@ editor_document_load_notify_completed_cb (EditorDocument *self,
if (!g_task_had_error (task))
editor_document_track_error (self, NULL);
- session = editor_application_get_session (EDITOR_APPLICATION_DEFAULT);
- _editor_session_document_seen (session, self);
+ _editor_session_document_seen (EDITOR_SESSION_DEFAULT, self);
+
+ /* Notify position so that consumers update */
+ g_signal_emit_by_name (self, "cursor-moved");
}
static void
@@ -1244,6 +1244,14 @@ _editor_document_unmark_busy (EditorDocument *self)
}
}
+gboolean
+_editor_document_get_loading (EditorDocument *self)
+{
+ g_return_val_if_fail (EDITOR_IS_DOCUMENT (self), FALSE);
+
+ return self->loading;
+}
+
gboolean
editor_document_get_busy (EditorDocument *self)
{
diff --git a/src/editor-page.c b/src/editor-page.c
index 1167bbd..0cc3120 100644
--- a/src/editor-page.c
+++ b/src/editor-page.c
@@ -27,6 +27,7 @@
#include <unistd.h>
#include "editor-application-private.h"
+#include "editor-document-private.h"
#include "editor-info-bar-private.h"
#include "editor-page-private.h"
#include "editor-sidebar-model-private.h"
@@ -189,7 +190,8 @@ editor_page_document_cursor_moved_cb (EditorPage *self,
g_assert (EDITOR_IS_PAGE (self));
g_assert (EDITOR_IS_DOCUMENT (document));
- g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_POSITION_LABEL]);
+ if (!_editor_document_get_loading (document))
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_POSITION_LABEL]);
}
static void
@@ -1305,6 +1307,9 @@ editor_page_dup_position_label (EditorPage *self)
g_return_val_if_fail (EDITOR_IS_PAGE (self), NULL);
+ if (_editor_document_get_loading (self->document))
+ return NULL;
+
editor_page_get_visual_position (self, &line, &column);
return g_strdup_printf (_("Ln %u, Col %u"), line + 1, column + 1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]