[gtk/wip/chergert/spellcheck] spellcheck: stub out spellcheck API




commit 404da89e4d12e5a018b14419a88c79273adf638c
Author: Christian Hergert <chergert redhat com>
Date:   Thu Mar 11 15:29:36 2021 -0800

    spellcheck: stub out spellcheck API

 gtk/gtkspellchecker.c           | 213 ++++++++++++++++++++++++++++++++++++++++
 gtk/gtkspellchecker.h           |  70 +++++++++++++
 gtk/gtkspellcorrection.c        | 143 +++++++++++++++++++++++++++
 gtk/gtkspellcorrection.h        |  37 +++++++
 gtk/gtkspellcorrectionprivate.h |  31 ++++++
 gtk/gtkspelllanguage.c          | 149 ++++++++++++++++++++++++++++
 gtk/gtkspelllanguageprivate.h   |  53 ++++++++++
 gtk/meson.build                 |   3 +
 8 files changed, 699 insertions(+)
---
diff --git a/gtk/gtkspellchecker.c b/gtk/gtkspellchecker.c
new file mode 100644
index 0000000000..bf9bd69316
--- /dev/null
+++ b/gtk/gtkspellchecker.c
@@ -0,0 +1,213 @@
+/*
+ * Copyright 2021 Christian Hergert <chergert redhat com>
+ *
+ * This library is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * licence or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#include "config.h"
+
+#include "gtkspellchecker.h"
+#include "gtkspelllanguageprivate.h"
+
+struct _GtkSpellChecker
+{
+  GObject    parent_instance;
+  GPtrArray *languages;
+};
+
+enum {
+  PROP_0,
+  PROP_LANGUAGES,
+  N_PROPS
+};
+
+G_DEFINE_TYPE (GtkSpellChecker, gtk_spell_checker, G_TYPE_OBJECT)
+
+static GParamSpec *properties [N_PROPS];
+
+static void
+_gtk_spell_checker_set_languages (GtkSpellChecker    *self,
+                                  const char * const *languages)
+{
+  g_assert (GTK_IS_SPELL_CHECKER (self));
+
+  if (languages == NULL)
+    return;
+
+  for (guint i = 0; languages[i]; i++)
+    {
+      GtkSpellLanguage *language = _gtk_spell_language_new_from_code (languages[i]);
+
+      if (language != NULL)
+        g_ptr_array_add (self->languages, g_steal_pointer (&language));
+    }
+}
+
+static char **
+_gtk_spell_checker_get_languages (GtkSpellChecker *self)
+{
+  GPtrArray *ar;
+
+  g_assert (GTK_IS_SPELL_CHECKER (self));
+
+  ar = g_ptr_array_new ();
+  for (guint i = 0; i < self->languages->len; i++)
+    {
+      GtkSpellLanguage *language = g_ptr_array_index (self->languages, i);
+      const char *code = _gtk_spell_language_get_code (language);
+
+      g_ptr_array_add (ar, g_strdup (code));
+    }
+  g_ptr_array_add (ar, NULL);
+
+  return (char **)g_ptr_array_free (ar, FALSE);
+}
+
+static void
+gtk_spell_checker_finalize (GObject *object)
+{
+  GtkSpellChecker *self = (GtkSpellChecker *)object;
+
+  g_clear_pointer (&self->languages, g_ptr_array_unref);
+
+  G_OBJECT_CLASS (gtk_spell_checker_parent_class)->finalize (object);
+}
+
+static void
+gtk_spell_checker_get_property (GObject    *object,
+                                guint       prop_id,
+                                GValue     *value,
+                                GParamSpec *pspec)
+{
+  GtkSpellChecker *self = GTK_SPELL_CHECKER (object);
+
+  switch (prop_id)
+    {
+    case PROP_LANGUAGES:
+      g_value_take_boxed (value, _gtk_spell_checker_get_languages (self));
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+gtk_spell_checker_set_property (GObject      *object,
+                                guint         prop_id,
+                                const GValue *value,
+                                GParamSpec   *pspec)
+{
+  GtkSpellChecker *self = GTK_SPELL_CHECKER (object);
+
+  switch (prop_id)
+    {
+    case PROP_LANGUAGES:
+      _gtk_spell_checker_set_languages (self, g_value_get_boxed (value));
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+gtk_spell_checker_class_init (GtkSpellCheckerClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->finalize = gtk_spell_checker_finalize;
+  object_class->get_property = gtk_spell_checker_get_property;
+  object_class->set_property = gtk_spell_checker_set_property;
+
+  properties [PROP_LANGUAGES] =
+    g_param_spec_boxed ("languages",
+                        "Languages",
+                        "Languages supported by spell checker",
+                        G_TYPE_STRV,
+                        (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_properties (object_class, N_PROPS, properties);
+}
+
+static void
+gtk_spell_checker_init (GtkSpellChecker *self)
+{
+}
+
+/**
+ * gtk_spell_checker_get_default:
+ *
+ * Gets the default #GtkSpellChecker for the application.
+ *
+ * Returns: (transfer none): a #GtkSpellChecker
+ */
+GtkSpellChecker *
+gtk_spell_checker_get_default (void)
+{
+  static GtkSpellChecker *checker;
+
+  if (checker == NULL)
+    checker = gtk_spell_checker_new_for_languages (_gtk_spell_language_get_defaults ());
+
+  return checker;
+}
+
+/**
+ * gtk_spell_checker_new_for_languages:
+ * @languages: (nullable): a languages from gtk_spell_checker_list_languages()
+ *
+ * Creates a new instance of #GtkSpellChecker using the requested languages.
+ *
+ * This may be useful in situations where you want to support more than one
+ * language at a time, particularly for multilingual users.
+ *
+ * If @languages is %NULL or empty, then the default spell checker is returned.
+ *
+ * Returns: (transfer full): a #GtkSpellChecker
+ *
+ * Since: 4.2
+ */
+GtkSpellChecker *
+gtk_spell_checker_new_for_languages (const char * const *languages)
+{
+  if (languages == NULL || languages[0] == NULL)
+    return g_object_ref (gtk_spell_checker_get_default ());
+
+  return g_object_new (GTK_TYPE_SPELL_CHECKER,
+                       "languages", languages,
+                       NULL);
+}
+
+/**
+ * gtk_spell_checker_new_for_language:
+ * @language: (nullable): a language from gtk_spell_checker_list_languages()
+ *
+ * Creates a new instance of #GtkSpellChecker using the requested language.
+ *
+ * If @language is %NULL, then the default spell checker is returned.
+ *
+ * Returns: (transfer full): a #GtkSpellChecker
+ *
+ * Since: 4.2
+ */
+GtkSpellChecker *
+gtk_spell_checker_new_for_language (const char *language)
+{
+  const char *languages[] = { language, NULL };
+
+  return gtk_spell_checker_new_for_languages (languages);
+}
diff --git a/gtk/gtkspellchecker.h b/gtk/gtkspellchecker.h
new file mode 100644
index 0000000000..356b29b414
--- /dev/null
+++ b/gtk/gtkspellchecker.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2021 Christian Hergert <chergert redhat com>
+ *
+ * This library is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * licence or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#ifndef __GTK_SPELL_CHECKER_H__
+#define __GTK_SPELL_CHECKER_H__
+
+#include <gdk/gdk.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_SPELL_CHECKER (gtk_spell_checker_get_type())
+
+typedef enum _GtkSpellDictionary
+{
+  GTK_SPELL_DICTIONARY_SESSION,
+  GTK_SPELL_DICTIONARY_PERSONAL,
+} GtkSpellDictionary;
+
+GDK_AVAILABLE_IN_4_2
+G_DECLARE_FINAL_TYPE (GtkSpellChecker, gtk_spell_checker, GTK, SPELL_CHECKER, GObject)
+
+GDK_AVAILABLE_IN_4_2
+GtkSpellChecker    *gtk_spell_checker_get_default       (void);
+GDK_AVAILABLE_IN_4_2
+GtkSpellChecker    *gtk_spell_checker_new_for_language  (const char         *language);
+GDK_AVAILABLE_IN_4_2
+GtkSpellChecker    *gtk_spell_checker_new_for_languages (const char * const *languages);
+GDK_AVAILABLE_IN_4_2
+const char * const *gtk_spell_checker_list_languages    (void);
+GDK_AVAILABLE_IN_4_2
+gboolean            gtk_spell_checker_check_word        (GtkSpellChecker    *self,
+                                                         const char         *word,
+                                                         gssize              word_length);
+GDK_AVAILABLE_IN_4_2
+GListModel         *gtk_spell_checker_list_corrections  (GtkSpellChecker    *self,
+                                                         const char         *word,
+                                                         gssize              word_length);
+GDK_AVAILABLE_IN_4_2
+void                gtk_spell_checker_add_word          (GtkSpellChecker    *self,
+                                                         GtkSpellDictionary  dictionary,
+                                                         const char         *word,
+                                                         gssize              word_length);
+GDK_AVAILABLE_IN_4_2
+void                gtk_spell_checker_set_correction    (GtkSpellChecker    *self,
+                                                         GtkSpellDictionary  dictionary,
+                                                         const char         *word,
+                                                         gssize              word_length,
+                                                         const char         *correction,
+                                                         gssize              correction_length);
+
+
+G_END_DECLS
+
+#endif /* __GTK_SPELL_CHECKER_H__ */
diff --git a/gtk/gtkspellcorrection.c b/gtk/gtkspellcorrection.c
new file mode 100644
index 0000000000..6c672b7f54
--- /dev/null
+++ b/gtk/gtkspellcorrection.c
@@ -0,0 +1,143 @@
+/*
+ * Copyright 2021 Christian Hergert <chergert redhat com>
+ *
+ * This library is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * licence or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#include "config.h"
+
+#include "gtkspellcorrectionprivate.h"
+
+struct _GtkSpellCorrection
+{
+  GObject parent_instance;
+  char *text;
+};
+
+enum {
+  PROP_0,
+  PROP_TEXT,
+  N_PROPS
+};
+
+G_DEFINE_TYPE (GtkSpellCorrection, gtk_spell_correction, G_TYPE_OBJECT)
+
+static GParamSpec *properties [N_PROPS];
+
+static void
+gtk_spell_correction_finalize (GObject *object)
+{
+  GtkSpellCorrection *self = (GtkSpellCorrection *)object;
+
+  g_clear_pointer (&self->text, g_free);
+
+  G_OBJECT_CLASS (gtk_spell_correction_parent_class)->finalize (object);
+}
+
+static void
+gtk_spell_correction_get_property (GObject    *object,
+                                   guint       prop_id,
+                                   GValue     *value,
+                                   GParamSpec *pspec)
+{
+  GtkSpellCorrection *self = GTK_SPELL_CORRECTION (object);
+
+  switch (prop_id)
+    {
+    case PROP_TEXT:
+      g_value_set_string (value, gtk_spell_correction_get_text (self));
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+gtk_spell_correction_set_property (GObject      *object,
+                                   guint         prop_id,
+                                   const GValue *value,
+                                   GParamSpec   *pspec)
+{
+  GtkSpellCorrection *self = GTK_SPELL_CORRECTION (object);
+
+  switch (prop_id)
+    {
+    case PROP_TEXT:
+      self->text = g_value_dup_string (value);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+gtk_spell_correction_class_init (GtkSpellCorrectionClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->finalize = gtk_spell_correction_finalize;
+  object_class->get_property = gtk_spell_correction_get_property;
+  object_class->set_property = gtk_spell_correction_set_property;
+
+  /**
+   * GtkSpellCorrection:text:
+   *
+   * The "text" property contains the text replacement to apply.
+   *
+   * Since: 4.2
+   */
+  properties [PROP_TEXT] =
+    g_param_spec_string ("text",
+                         "Text",
+                         "The text for the correction",
+                         NULL,
+                         (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_properties (object_class, N_PROPS, properties);
+}
+
+static void
+gtk_spell_correction_init (GtkSpellCorrection *self)
+{
+}
+
+GtkSpellCorrection *
+_gtk_spell_correction_new (const char *text)
+{
+  return g_object_new (GTK_TYPE_SPELL_CORRECTION,
+                       "text", text,
+                       NULL);
+}
+
+/**
+ * gtk_spell_correction_get_text:
+ * @self: a #GtkSpellCorrection
+ *
+ * Gets the #GtkSpellCorrection:text property.
+ *
+ * Returns: the replacement text
+ *
+ * Since: 4.2
+ */
+const char *
+gtk_spell_correction_get_text (GtkSpellCorrection *self)
+{
+  g_return_val_if_fail (GTK_IS_SPELL_CORRECTION (self), NULL);
+
+  return self->text;
+}
diff --git a/gtk/gtkspellcorrection.h b/gtk/gtkspellcorrection.h
new file mode 100644
index 0000000000..85ce6946e8
--- /dev/null
+++ b/gtk/gtkspellcorrection.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2021 Christian Hergert <chergert redhat com>
+ *
+ * This library is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * licence or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#ifndef __GTK_SPELL_CORRECTION_H__
+#define __GTK_SPELL_CORRECTION_H__
+
+#include <gdk/gdk.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_SPELL_CORRECTION (gtk_spell_correction_get_type())
+
+GDK_AVAILABLE_IN_4_2
+G_DECLARE_FINAL_TYPE (GtkSpellCorrection, gtk_spell_correction, GTK, SPELL_CORRECTION, GObject)
+
+GDK_AVAILABLE_IN_4_2
+const char *gtk_spell_correction_get_text (GtkSpellCorrection *self);
+
+G_END_DECLS
+
+#endif /* __GTK_SPELL_CORRECTION_H__ */
diff --git a/gtk/gtkspellcorrectionprivate.h b/gtk/gtkspellcorrectionprivate.h
new file mode 100644
index 0000000000..fc1b77a209
--- /dev/null
+++ b/gtk/gtkspellcorrectionprivate.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2021 Christian Hergert <chergert redhat com>
+ *
+ * This library is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * licence or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#ifndef __GTK_SPELL_CORRECTION_PRIVATE_H__
+#define __GTK_SPELL_CORRECTION_PRIVATE_H__
+
+#include "gtkspellcorrection.h"
+
+G_BEGIN_DECLS
+
+GtkSpellCorrection *_gtk_spell_correction_new (const char *text);
+
+G_END_DECLS
+
+#endif /* __GTK_SPELL_CORRECTION_PRIVATE_H__ */
diff --git a/gtk/gtkspelllanguage.c b/gtk/gtkspelllanguage.c
new file mode 100644
index 0000000000..350886ec24
--- /dev/null
+++ b/gtk/gtkspelllanguage.c
@@ -0,0 +1,149 @@
+/*
+ * Copyright 2021 Christian Hergert <chergert redhat com>
+ *
+ * This library is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * licence or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#include "config.h"
+
+#include "gtkspelllanguageprivate.h"
+
+struct _GtkSpellLanguage
+{
+  GObject parent_instance;
+  char *code;
+};
+
+enum {
+  PROP_0,
+  PROP_CODE,
+  N_PROPS
+};
+
+G_DEFINE_TYPE (GtkSpellLanguage, gtk_spell_language, G_TYPE_OBJECT)
+
+static GParamSpec *properties [N_PROPS];
+
+static void
+gtk_spell_language_finalize (GObject *object)
+{
+  GtkSpellLanguage *self = (GtkSpellLanguage *)object;
+
+  g_clear_pointer (&self->code, g_free);
+
+  G_OBJECT_CLASS (gtk_spell_language_parent_class)->finalize (object);
+}
+
+static void
+gtk_spell_language_get_property (GObject    *object,
+                               guint       prop_id,
+                               GValue     *value,
+                               GParamSpec *pspec)
+{
+  GtkSpellLanguage *self = GTK_SPELL_LANGUAGE (object);
+
+  switch (prop_id)
+    {
+    case PROP_CODE:
+      g_value_set_string (value, _gtk_spell_language_get_code (self));
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+gtk_spell_language_set_property (GObject      *object,
+                                 guint         prop_id,
+                                 const GValue *value,
+                                 GParamSpec   *pspec)
+{
+  GtkSpellLanguage *self = GTK_SPELL_LANGUAGE (object);
+
+  switch (prop_id)
+    {
+    case PROP_CODE:
+      self->code = g_value_dup_string (value);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+gtk_spell_language_class_init (GtkSpellLanguageClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->finalize = gtk_spell_language_finalize;
+  object_class->get_property = gtk_spell_language_get_property;
+  object_class->set_property = gtk_spell_language_set_property;
+
+  properties [PROP_CODE] =
+    g_param_spec_string ("code",
+                         "Code",
+                         "The language code",
+                         NULL,
+                         (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_properties (object_class, N_PROPS, properties);
+}
+
+static void
+gtk_spell_language_init (GtkSpellLanguage *self)
+{
+}
+
+const char *
+_gtk_spell_language_get_code (GtkSpellLanguage *self)
+{
+  g_return_val_if_fail (GTK_IS_SPELL_LANGUAGE (self), NULL);
+
+  return self->code;
+}
+
+GtkSpellLanguage *
+_gtk_spell_language_new_from_code (const char *code)
+{
+  g_return_val_if_fail (code != NULL, NULL);
+
+  return g_object_new (GTK_TYPE_SPELL_LANGUAGE,
+                       "code", code,
+                       NULL);
+}
+
+/*
+ * _gtk_spell_language_get_defaults:
+ *
+ * Discovers the default languages for the user.
+ *
+ * If we discover a multilingual system, we might return multiple
+ * language codes.
+ */
+const char * const *
+_gtk_spell_language_get_defaults (void)
+{
+  static char **defaults;
+
+  if (defaults == NULL)
+    {
+      /* TODO: guess defaults */
+    }
+
+  return (const char * const *)defaults;
+}
diff --git a/gtk/gtkspelllanguageprivate.h b/gtk/gtkspelllanguageprivate.h
new file mode 100644
index 0000000000..300dc28f1c
--- /dev/null
+++ b/gtk/gtkspelllanguageprivate.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2021 Christian Hergert <chergert redhat com>
+ *
+ * This library is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * licence or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#ifndef __GTK_SPELL_LANGUAGE_PRIVATE_H__
+#define __GTK_SPELL_LANGUAGE_PRIVATE_H__
+
+#include "gtkspellchecker.h"
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_SPELL_LANGUAGE (gtk_spell_language_get_type())
+
+G_DECLARE_FINAL_TYPE (GtkSpellLanguage, gtk_spell_language, GTK, SPELL_LANGUAGE, GObject)
+
+const char * const *_gtk_spell_language_get_defaults     (void);
+GtkSpellLanguage   *_gtk_spell_language_new_from_code    (const char         *code);
+const char         *_gtk_spell_language_get_code         (GtkSpellLanguage   *self);
+gboolean            _gtk_spell_language_check_word       (GtkSpellLanguage   *self,
+                                                          const char         *word,
+                                                          gssize              word_length);
+GListModel         *_gtk_spell_language_list_corrections (GtkSpellLanguage   *self,
+                                                          const char         *word,
+                                                          gssize              word_length);
+void                _gtk_spell_language_add_word         (GtkSpellLanguage   *self,
+                                                          GtkSpellDictionary  dictionary,
+                                                          const char         *word,
+                                                          gssize              word_length);
+void                _gtk_spell_language_set_correction   (GtkSpellLanguage   *self,
+                                                          GtkSpellDictionary  dictionary,
+                                                          const char         *word,
+                                                          gssize              word_length,
+                                                          const char         *correction,
+                                                          gssize              correction_length);
+
+G_END_DECLS
+
+#endif /* __GTK_SPELL_LANGUAGE_PRIVATE_H__ */
diff --git a/gtk/meson.build b/gtk/meson.build
index fe0ec456d9..e77ef1fdbe 100644
--- a/gtk/meson.build
+++ b/gtk/meson.build
@@ -140,6 +140,7 @@ gtk_private_sources = files([
   'gtksecurememory.c',
   'gtksizerequestcache.c',
   'gtksortkeys.c',
+  'gtkspelllanguage.c',
   'gtkstyleanimation.c',
   'gtkstylecascade.c',
   'gtkstyleproperty.c',
@@ -377,6 +378,8 @@ gtk_public_sources = files([
   'gtksnapshot.c',
   'gtksorter.c',
   'gtksortlistmodel.c',
+  'gtkspellchecker.c',
+  'gtkspellcorrection.c',
   'gtkspinbutton.c',
   'gtkspinner.c',
   'gtkstack.c',


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]