[gedit/wip/spell-checking] Add SpellNavigator interface



commit 1769b91cd3fb51ae5e1bed4f31f17ebf399c81c7
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sat Aug 1 20:00:33 2015 +0200

    Add SpellNavigator interface

 plugins/spell/Makefile.am             |    2 +
 plugins/spell/gedit-spell-navigator.c |   87 +++++++++++++++++++++++++++++++++
 plugins/spell/gedit-spell-navigator.h |   62 +++++++++++++++++++++++
 3 files changed, 151 insertions(+), 0 deletions(-)
---
diff --git a/plugins/spell/Makefile.am b/plugins/spell/Makefile.am
index c80ef77..0b4950d 100644
--- a/plugins/spell/Makefile.am
+++ b/plugins/spell/Makefile.am
@@ -34,6 +34,8 @@ plugins_spell_libspell_la_SOURCES =                   \
        plugins/spell/gedit-spell-checker-language.h    \
        plugins/spell/gedit-spell-language-dialog.c     \
        plugins/spell/gedit-spell-language-dialog.h     \
+       plugins/spell/gedit-spell-navigator.c           \
+       plugins/spell/gedit-spell-navigator.h           \
        plugins/spell/gedit-automatic-spell-checker.c   \
        plugins/spell/gedit-automatic-spell-checker.h   \
        plugins/spell/gedit-spell-utils.c               \
diff --git a/plugins/spell/gedit-spell-navigator.c b/plugins/spell/gedit-spell-navigator.c
new file mode 100644
index 0000000..93ee3e6
--- /dev/null
+++ b/plugins/spell/gedit-spell-navigator.c
@@ -0,0 +1,87 @@
+/*
+ * gedit-spell-navigator.c
+ * This file is part of gedit
+ *
+ * Copyright (C) 2015 - Sébastien Wilmet <swilmet gnome org>
+ *
+ * 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 2 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/>.
+ */
+
+#include "gedit-spell-navigator.h"
+
+G_DEFINE_INTERFACE (GeditSpellNavigator, gedit_spell_navigator, G_TYPE_OBJECT)
+
+static gchar *
+gedit_spell_navigator_get_next_misspelled_word_default (GeditSpellNavigator *navigator)
+{
+       return NULL;
+}
+
+static void
+gedit_spell_navigator_change_default (GeditSpellNavigator *navigator,
+                                     const gchar         *word,
+                                     const gchar         *change_to)
+{
+}
+
+static void
+gedit_spell_navigator_change_all_default (GeditSpellNavigator *navigator,
+                                         const gchar         *word,
+                                         const gchar         *change_to)
+{
+}
+
+static void
+gedit_spell_navigator_default_init (GeditSpellNavigatorInterface *iface)
+{
+       iface->get_next_misspelled_word = gedit_spell_navigator_get_next_misspelled_word_default;
+       iface->change = gedit_spell_navigator_change_default;
+       iface->change_all = gedit_spell_navigator_change_all_default;
+}
+
+/**
+ * gedit_spell_navigator_get_next_misspelled_word:
+ * @navigator: a #GeditSpellNavigator.
+ *
+ * Returns: the next misspelled word, or %NULL if finished.
+ */
+gchar *
+gedit_spell_navigator_get_next_misspelled_word (GeditSpellNavigator *navigator)
+{
+       g_return_val_if_fail (GEDIT_IS_SPELL_NAVIGATOR (navigator), NULL);
+
+       return GEDIT_SPELL_NAVIGATOR_GET_IFACE (navigator)->get_next_misspelled_word (navigator);
+}
+
+void
+gedit_spell_navigator_change (GeditSpellNavigator *navigator,
+                             const gchar         *word,
+                             const gchar         *change_to)
+{
+       g_return_if_fail (GEDIT_IS_SPELL_NAVIGATOR (navigator));
+
+       GEDIT_SPELL_NAVIGATOR_GET_IFACE (navigator)->change (navigator, word, change_to);
+}
+
+void
+gedit_spell_navigator_change_all (GeditSpellNavigator *navigator,
+                                 const gchar         *word,
+                                 const gchar         *change_to)
+{
+       g_return_if_fail (GEDIT_IS_SPELL_NAVIGATOR (navigator));
+
+       GEDIT_SPELL_NAVIGATOR_GET_IFACE (navigator)->change_all (navigator, word, change_to);
+}
+
+/* ex:set ts=8 noet: */
diff --git a/plugins/spell/gedit-spell-navigator.h b/plugins/spell/gedit-spell-navigator.h
new file mode 100644
index 0000000..87d394b
--- /dev/null
+++ b/plugins/spell/gedit-spell-navigator.h
@@ -0,0 +1,62 @@
+/*
+ * gedit-spell-navigator.h
+ * This file is part of gedit
+ *
+ * Copyright (C) 2015 - Sébastien Wilmet <swilmet gnome org>
+ *
+ * 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 2 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/>.
+ */
+
+#ifndef __GEDIT_SPELL_NAVIGATOR_H__
+#define __GEDIT_SPELL_NAVIGATOR_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GEDIT_TYPE_SPELL_NAVIGATOR (gedit_spell_navigator_get_type ())
+G_DECLARE_INTERFACE (GeditSpellNavigator, gedit_spell_navigator,
+                    GEDIT, SPELL_NAVIGATOR,
+                    GObject)
+
+struct _GeditSpellNavigatorInterface
+{
+       GTypeInterface parent_interface;
+
+       gchar *         (* get_next_misspelled_word)    (GeditSpellNavigator *navigator);
+
+       void            (* change)                      (GeditSpellNavigator *navigator,
+                                                        const gchar         *word,
+                                                        const gchar         *change_to);
+
+       void            (* change_all)                  (GeditSpellNavigator *navigator,
+                                                        const gchar         *word,
+                                                        const gchar         *change_to);
+};
+
+gchar *                gedit_spell_navigator_get_next_misspelled_word  (GeditSpellNavigator *navigator);
+
+void           gedit_spell_navigator_change                    (GeditSpellNavigator *navigator,
+                                                                const gchar         *word,
+                                                                const gchar         *change_to);
+
+void           gedit_spell_navigator_change_all                (GeditSpellNavigator *navigator,
+                                                                const gchar         *word,
+                                                                const gchar         *change_to);
+
+G_END_DECLS
+
+#endif /* __GEDIT_SPELL_NAVIGATOR_H__ */
+
+/* ex:set ts=8 noet: */



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