[gnome-text-editor] spellcheck: allow disabling spellcheck globally
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-text-editor] spellcheck: allow disabling spellcheck globally
- Date: Thu, 1 Jul 2021 22:29:51 +0000 (UTC)
commit 7e454e0bfe6e71bfb6e3ecd635578d1f4dbbd06e
Author: Christian Hergert <chergert redhat com>
Date: Thu Jul 1 15:29:33 2021 -0700
spellcheck: allow disabling spellcheck globally
This still allows for you to enable/disable it on a per-page basis with
the context menu.
data/org.gnome.TextEditor.gschema.xml | 5 +++++
src/editor-document.c | 8 ++++++++
src/editor-window-actions.c | 1 +
src/menus.ui | 4 ++++
4 files changed, 18 insertions(+)
---
diff --git a/data/org.gnome.TextEditor.gschema.xml b/data/org.gnome.TextEditor.gschema.xml
index 7195118..7f3bc1b 100644
--- a/data/org.gnome.TextEditor.gschema.xml
+++ b/data/org.gnome.TextEditor.gschema.xml
@@ -86,5 +86,10 @@
<summary>Discover File Settings</summary>
<description>If enabled then Text Editor will try to discover file settings from modelines,
editorconfig, or per-language defaults.</description>
</key>
+ <key name="spellcheck" type="b">
+ <default>true</default>
+ <summary>Automatically check spelling</summary>
+ <description>If enabled, then Text Editor will check spelling as you type.</description>
+ </key>
</schema>
</schemalist>
diff --git a/src/editor-document.c b/src/editor-document.c
index 3359086..11a961c 100644
--- a/src/editor-document.c
+++ b/src/editor-document.c
@@ -95,6 +95,7 @@ enum {
};
static GParamSpec *properties [N_PROPS];
+static GSettings *shared_settings;
static void
load_free (Load *load)
@@ -367,10 +368,17 @@ editor_document_constructed (GObject *object)
{
EditorDocument *self = (EditorDocument *)object;
+ if (shared_settings == NULL)
+ shared_settings = g_settings_new ("org.gnome.TextEditor");
+
G_OBJECT_CLASS (editor_document_parent_class)->constructed (object);
self->spell_adapter = editor_text_buffer_spell_adapter_new (GTK_TEXT_BUFFER (self),
self->spell_checker);
+ g_settings_bind (shared_settings, "spellcheck",
+ self->spell_adapter, "enabled",
+ G_SETTINGS_BIND_GET);
+
self->line_spacing_tag = gtk_text_buffer_create_tag (GTK_TEXT_BUFFER (self),
NULL,
"pixels-below-lines", 2,
diff --git a/src/editor-window-actions.c b/src/editor-window-actions.c
index 21bdda3..28f53d6 100644
--- a/src/editor-window-actions.c
+++ b/src/editor-window-actions.c
@@ -602,6 +602,7 @@ _editor_window_actions_init (EditorWindow *self)
"indent-style",
"show-line-numbers",
"show-right-margin",
+ "spellcheck",
"tab-width",
"wrap-text",
};
diff --git a/src/menus.ui b/src/menus.ui
index 91eb273..a2edf9b 100644
--- a/src/menus.ui
+++ b/src/menus.ui
@@ -106,6 +106,10 @@
<attribute name="label" translatable="yes">_Automatic Margin Position</attribute>
<attribute name="action">settings.discover-settings</attribute>
</item>
+ <item>
+ <attribute name="label" translatable="yes">Chec_k Spelling</attribute>
+ <attribute name="action">settings.spellcheck</attribute>
+ </item>
<item>
<attribute name="label" translatable="yes">_Highlight Mode</attribute>
<attribute name="action">page.change-language</attribute>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]