[gnome-text-editor] document: try to reload after switching to admin://
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-text-editor] document: try to reload after switching to admin://
- Date: Sat, 17 Sep 2022 20:47:16 +0000 (UTC)
commit ca98248c4a7bb548aa00a440280810748c759e43
Author: Christian Hergert <chergert redhat com>
Date: Sat Sep 17 13:40:54 2022 -0700
document: try to reload after switching to admin://
It doesn't make sense to require the user to force the reload, just reload
the document when transitioning from file:// to admin://.
Fixes #464
src/editor-document-private.h | 3 ++-
src/editor-document.c | 18 ++++++++++++++----
src/editor-info-bar.c | 6 +++++-
3 files changed, 21 insertions(+), 6 deletions(-)
---
diff --git a/src/editor-document-private.h b/src/editor-document-private.h
index be1319b..61c2ceb 100644
--- a/src/editor-document-private.h
+++ b/src/editor-document-private.h
@@ -86,7 +86,8 @@ void _editor_document_add_spelling (EditorDocume
void _editor_document_ignore_spelling (EditorDocument *self,
const char *word);
GtkTextTag *_editor_document_get_spelling_tag (EditorDocument *self);
-void _editor_document_use_admin (EditorDocument *self);
+void _editor_document_use_admin (EditorDocument *self,
+ EditorWindow *window);
gboolean _editor_document_had_error (EditorDocument *self);
void _editor_document_persist_syntax_language (EditorDocument *self,
const char *language_id);
diff --git a/src/editor-document.c b/src/editor-document.c
index d61ca0a..2359575 100644
--- a/src/editor-document.c
+++ b/src/editor-document.c
@@ -2230,7 +2230,8 @@ _editor_document_get_spelling_tag (EditorDocument *self)
}
void
-_editor_document_use_admin (EditorDocument *self)
+_editor_document_use_admin (EditorDocument *self,
+ EditorWindow *window)
{
GFile *file;
g_autofree char *uri = NULL;
@@ -2240,18 +2241,27 @@ _editor_document_use_admin (EditorDocument *self)
g_return_if_fail (EDITOR_IS_DOCUMENT (self));
if (!(file = editor_document_get_file (self)))
- return;
+ {
+ g_warning ("No file, cannot change to admin:// protocol");
+ return;
+ }
uri = g_file_get_uri (file);
+
if (!g_str_has_prefix (uri, "file:///"))
- return;
+ {
+ g_warning ("URI \"%s\" does not start with \"file:///\"", uri);
+ return;
+ }
admin_uri = g_strdup_printf ("admin://%s", g_file_get_path (file));
admin_file = g_file_new_for_uri (admin_uri);
+ g_debug ("Changing URI from \"%s\" to \"%s\"", uri, admin_uri);
gtk_source_file_set_location (self->file, admin_file);
-
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_FILE]);
+
+ _editor_document_load_async (self, window, NULL, NULL, NULL);
}
gboolean
diff --git a/src/editor-info-bar.c b/src/editor-info-bar.c
index c0afd34..bc3491b 100644
--- a/src/editor-info-bar.c
+++ b/src/editor-info-bar.c
@@ -153,10 +153,14 @@ static void
on_try_admin_cb (EditorInfoBar *self,
GtkButton *button)
{
+ GtkRoot *root;
+
g_assert (EDITOR_IS_INFO_BAR (self));
g_assert (GTK_IS_BUTTON (button));
- _editor_document_use_admin (self->document);
+ root = gtk_widget_get_root (GTK_WIDGET (self));
+
+ _editor_document_use_admin (self->document, EDITOR_WINDOW (root));
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]