[gnome-builder/wip/gtk4-port] plugins/spellcheck: add preference toggle for spellcheck



commit 4d2f7522d38654cc2bc9b0f7dc39327efa1a4fe6
Author: Christian Hergert <chergert redhat com>
Date:   Mon Apr 11 13:35:44 2022 -0700

    plugins/spellcheck: add preference toggle for spellcheck

 .../spellcheck/gbp-spell-preferences-addin.c       | 96 ++++++++++++++++++++++
 .../spellcheck/gbp-spell-preferences-addin.h       | 31 +++++++
 src/plugins/spellcheck/meson.build                 |  1 +
 src/plugins/spellcheck/spellcheck-plugin.c         |  4 +
 4 files changed, 132 insertions(+)
---
diff --git a/src/plugins/spellcheck/gbp-spell-preferences-addin.c 
b/src/plugins/spellcheck/gbp-spell-preferences-addin.c
new file mode 100644
index 000000000..6fc5c604d
--- /dev/null
+++ b/src/plugins/spellcheck/gbp-spell-preferences-addin.c
@@ -0,0 +1,96 @@
+/* gbp-spell-preferences-addin.c
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define G_LOG_DOMAIN "gbp-spell-preferences-addin"
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+
+#include <libide-gui.h>
+
+#include "gbp-spell-preferences-addin.h"
+
+struct _GbpSpellPreferencesAddin
+{
+  GObject parent_instance;
+};
+
+static const IdePreferenceGroupEntry groups[] = {
+  { "editing", "spelling",      0, N_("Spelling") },
+};
+
+static const IdePreferenceItemEntry items[] = {
+  { "editing", "spelling", "enable-spellcheck", 0, ide_preferences_window_toggle,
+    N_("Check Spelling"),
+    N_("Automatically check spelling as you type"),
+    "org.gnome.builder.spelling", NULL, "check-spelling" },
+};
+
+static void
+gbp_spell_preferences_addin_load (IdePreferencesAddin  *addin,
+                                  IdePreferencesWindow *window)
+{
+  GbpSpellPreferencesAddin *self = (GbpSpellPreferencesAddin *)addin;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_SPELL_PREFERENCES_ADDIN (self));
+  g_assert (IDE_IS_PREFERENCES_WINDOW (window));
+
+  ide_preferences_window_add_groups (window, groups, G_N_ELEMENTS (groups), NULL);
+  ide_preferences_window_add_items (window, items, G_N_ELEMENTS (items), window, NULL);
+
+  IDE_EXIT;
+}
+
+static void
+gbp_spell_preferences_addin_unload (IdePreferencesAddin  *addin,
+                                    IdePreferencesWindow *window)
+{
+  GbpSpellPreferencesAddin *self = (GbpSpellPreferencesAddin *)addin;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_SPELL_PREFERENCES_ADDIN (self));
+  g_assert (IDE_IS_PREFERENCES_WINDOW (window));
+
+  IDE_EXIT;
+}
+
+static void
+preferences_addin_iface_init (IdePreferencesAddinInterface *iface)
+{
+  iface->load = gbp_spell_preferences_addin_load;
+  iface->unload = gbp_spell_preferences_addin_unload;
+}
+
+G_DEFINE_FINAL_TYPE_WITH_CODE (GbpSpellPreferencesAddin, gbp_spell_preferences_addin, G_TYPE_OBJECT,
+                               G_IMPLEMENT_INTERFACE (IDE_TYPE_PREFERENCES_ADDIN, 
preferences_addin_iface_init))
+
+static void
+gbp_spell_preferences_addin_class_init (GbpSpellPreferencesAddinClass *klass)
+{
+}
+
+static void
+gbp_spell_preferences_addin_init (GbpSpellPreferencesAddin *self)
+{
+}
diff --git a/src/plugins/spellcheck/gbp-spell-preferences-addin.h 
b/src/plugins/spellcheck/gbp-spell-preferences-addin.h
new file mode 100644
index 000000000..88855ad91
--- /dev/null
+++ b/src/plugins/spellcheck/gbp-spell-preferences-addin.h
@@ -0,0 +1,31 @@
+/* gbp-spell-preferences-addin.h
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GBP_TYPE_SPELL_PREFERENCES_ADDIN (gbp_spell_preferences_addin_get_type())
+
+G_DECLARE_FINAL_TYPE (GbpSpellPreferencesAddin, gbp_spell_preferences_addin, GBP, SPELL_PREFERENCES_ADDIN, 
GObject)
+
+G_END_DECLS
diff --git a/src/plugins/spellcheck/meson.build b/src/plugins/spellcheck/meson.build
index 48794211d..c55667e2e 100644
--- a/src/plugins/spellcheck/meson.build
+++ b/src/plugins/spellcheck/meson.build
@@ -14,6 +14,7 @@ plugins_sources += files([
   'editor-text-buffer-spell-adapter.c',
   'gbp-spell-buffer-addin.c',
   'gbp-spell-editor-page-addin.c',
+  'gbp-spell-preferences-addin.c',
   'spellcheck-plugin.c',
 ])
 
diff --git a/src/plugins/spellcheck/spellcheck-plugin.c b/src/plugins/spellcheck/spellcheck-plugin.c
index e07005f4c..e6605c76f 100644
--- a/src/plugins/spellcheck/spellcheck-plugin.c
+++ b/src/plugins/spellcheck/spellcheck-plugin.c
@@ -27,6 +27,7 @@
 
 #include "gbp-spell-buffer-addin.h"
 #include "gbp-spell-editor-page-addin.h"
+#include "gbp-spell-preferences-addin.h"
 
 _IDE_EXTERN void
 _gbp_spellcheck_register_types (PeasObjectModule *module)
@@ -37,4 +38,7 @@ _gbp_spellcheck_register_types (PeasObjectModule *module)
   peas_object_module_register_extension_type (module,
                                               IDE_TYPE_EDITOR_PAGE_ADDIN,
                                               GBP_TYPE_SPELL_EDITOR_PAGE_ADDIN);
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_PREFERENCES_ADDIN,
+                                              GBP_TYPE_SPELL_PREFERENCES_ADDIN);
 }


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