[gnome-text-editor] spellcheck: use def:misspelled-word style
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-text-editor] spellcheck: use def:misspelled-word style
- Date: Thu, 30 Dec 2021 20:33:32 +0000 (UTC)
commit f3bf8fe22aaff45989da5bb5c62e13a62c7e8330
Author: Christian Hergert <chergert redhat com>
Date: Thu Dec 30 12:32:59 2021 -0800
spellcheck: use def:misspelled-word style
This will allow style schemes to override the styling a bit for misspelled
words.
src/editor-text-buffer-spell-adapter.c | 36 ++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
---
diff --git a/src/editor-text-buffer-spell-adapter.c b/src/editor-text-buffer-spell-adapter.c
index 2933370..e2cde23 100644
--- a/src/editor-text-buffer-spell-adapter.c
+++ b/src/editor-text-buffer-spell-adapter.c
@@ -379,6 +379,35 @@ invalidate_tag_region_cb (EditorTextBufferSpellAdapter *self,
}
}
+static void
+apply_error_style_cb (GtkSourceBuffer *buffer,
+ GParamSpec *pspec,
+ GtkTextTag *tag)
+{
+ GtkSourceStyleScheme *scheme;
+ GtkSourceStyle *style;
+
+ g_assert (GTK_SOURCE_IS_BUFFER (buffer));
+ g_assert (GTK_IS_TEXT_TAG (tag));
+
+ g_object_set (tag,
+ "underline", PANGO_UNDERLINE_ERROR,
+ "background-set", FALSE,
+ "foreground-set", FALSE,
+ "weight-set", FALSE,
+ "variant-set", FALSE,
+ "style-set", FALSE,
+ "indent-set", FALSE,
+ "size-set", FALSE,
+ NULL);
+
+ if ((scheme = gtk_source_buffer_get_style_scheme (buffer)))
+ {
+ if ((style = gtk_source_style_scheme_get_style (scheme, "def:misspelled-word")))
+ gtk_source_style_apply (style, tag);
+ }
+}
+
static void
editor_text_buffer_spell_adapter_set_buffer (EditorTextBufferSpellAdapter *self,
GtkTextBuffer *buffer)
@@ -404,6 +433,13 @@ editor_text_buffer_spell_adapter_set_buffer (EditorTextBufferSpellAdapter *self,
"underline", PANGO_UNDERLINE_ERROR,
NULL);
+ g_signal_connect_object (buffer,
+ "notify::style-scheme",
+ G_CALLBACK (apply_error_style_cb),
+ self->tag,
+ 0);
+ apply_error_style_cb (GTK_SOURCE_BUFFER (buffer), NULL, self->tag);
+
/* Track tag changes from the tag table and extract "no-spell-check"
* tag from GtkSourceView so that we can avoid words with that tag.
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]