[gnome-text-editor] document: add helper to swap to admin:// URI
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-text-editor] document: add helper to swap to admin:// URI
- Date: Tue, 11 Jan 2022 00:08:50 +0000 (UTC)
commit a248d63c72b742d4efe7e31e07e90e41ce32a62a
Author: Christian Hergert <chergert redhat com>
Date: Mon Jan 10 16:08:41 2022 -0800
document: add helper to swap to admin:// URI
src/editor-document-private.h | 1 +
src/editor-document.c | 25 +++++++++++++++++++++++++
2 files changed, 26 insertions(+)
---
diff --git a/src/editor-document-private.h b/src/editor-document-private.h
index 388d835..9666a20 100644
--- a/src/editor-document-private.h
+++ b/src/editor-document-private.h
@@ -85,5 +85,6 @@ 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);
G_END_DECLS
diff --git a/src/editor-document.c b/src/editor-document.c
index 39bc386..7c81be0 100644
--- a/src/editor-document.c
+++ b/src/editor-document.c
@@ -2035,3 +2035,28 @@ _editor_document_get_spelling_tag (EditorDocument *self)
return editor_text_buffer_spell_adapter_get_tag (self->spell_adapter);
}
+
+void
+_editor_document_use_admin (EditorDocument *self)
+{
+ GFile *file;
+ g_autofree char *uri = NULL;
+ g_autofree char *admin_uri = NULL;
+ g_autoptr(GFile) admin_file = NULL;
+
+ g_return_if_fail (EDITOR_IS_DOCUMENT (self));
+
+ if (!(file = editor_document_get_file (self)))
+ return;
+
+ uri = g_file_get_uri (file);
+ if (!g_str_has_prefix (uri, "file:///"))
+ return;
+
+ admin_uri = g_strdup_printf ("admin://%s", g_file_get_path (file));
+ admin_file = g_file_new_for_uri (admin_uri);
+
+ gtk_source_file_set_location (self->file, admin_file);
+
+ g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_FILE]);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]