[gspell: 6/6] navigator-gtv: remove :spell-checker property
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gspell: 6/6] navigator-gtv: remove :spell-checker property
- Date: Tue, 29 Dec 2015 13:42:04 +0000 (UTC)
commit 73be5e2fa46edf4c33557b687309db371d6eed62
Author: Sébastien Wilmet <swilmet gnome org>
Date: Tue Dec 29 12:04:21 2015 +0100
navigator-gtv: remove :spell-checker property
gspell/gspell-navigator-gtv.c | 66 ++++++++++------------------------------
gspell/gspell-navigator-gtv.h | 3 +-
tests/test-spell.c | 4 +--
3 files changed, 19 insertions(+), 54 deletions(-)
---
diff --git a/gspell/gspell-navigator-gtv.c b/gspell/gspell-navigator-gtv.c
index 9b53902..65d0a6a 100644
--- a/gspell/gspell-navigator-gtv.c
+++ b/gspell/gspell-navigator-gtv.c
@@ -20,6 +20,7 @@
#include "config.h"
#include "gspell-navigator-gtv.h"
#include <glib/gi18n-lib.h>
+#include "gspell-text-buffer.h"
#include "gspell-utils.h"
/**
@@ -41,6 +42,9 @@
*
* The implementation of gspell_navigator_goto_next() selects the
* misspelled word and scrolls to it.
+ *
+ * You need to call gspell_text_buffer_set_spell_checker() to associate a
+ * #GspellChecker to the #GtkTextBuffer.
*/
typedef struct _GspellNavigatorGtvPrivate GspellNavigatorGtvPrivate;
@@ -49,7 +53,6 @@ struct _GspellNavigatorGtvPrivate
{
GtkTextView *view;
GtkTextBuffer *buffer;
- GspellChecker *spell_checker;
/* Delimit the region to spell check. */
GtkTextMark *start_boundary;
@@ -64,7 +67,6 @@ enum
{
PROP_0,
PROP_VIEW,
- PROP_SPELL_CHECKER,
};
static void gspell_navigator_iface_init (gpointer g_iface, gpointer iface_data);
@@ -129,20 +131,6 @@ set_view (GspellNavigatorGtv *navigator,
}
static void
-set_spell_checker (GspellNavigatorGtv *navigator,
- GspellChecker *spell_checker)
-{
- GspellNavigatorGtvPrivate *priv;
-
- priv = gspell_navigator_gtv_get_instance_private (navigator);
-
- if (g_set_object (&priv->spell_checker, spell_checker))
- {
- g_object_notify (G_OBJECT (navigator), "spell-checker");
- }
-}
-
-static void
gspell_navigator_gtv_get_property (GObject *object,
guint prop_id,
GValue *value,
@@ -158,10 +146,6 @@ gspell_navigator_gtv_get_property (GObject *object,
g_value_set_object (value, priv->view);
break;
- case PROP_SPELL_CHECKER:
- g_value_set_object (value, priv->spell_checker);
- break;
-
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -182,10 +166,6 @@ gspell_navigator_gtv_set_property (GObject *object,
set_view (navigator, g_value_get_object (value));
break;
- case PROP_SPELL_CHECKER:
- set_spell_checker (navigator, g_value_get_object (value));
- break;
-
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -200,7 +180,6 @@ gspell_navigator_gtv_dispose (GObject *object)
priv = gspell_navigator_gtv_get_instance_private (GSPELL_NAVIGATOR_GTV (object));
g_clear_object (&priv->view);
- g_clear_object (&priv->spell_checker);
if (priv->buffer != NULL)
{
@@ -259,21 +238,6 @@ gspell_navigator_gtv_class_init (GspellNavigatorGtvClass *klass)
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
-
- /**
- * GspellNavigatorGtv:spell-checker:
- *
- * The #GspellChecker to use.
- */
- g_object_class_install_property (object_class,
- PROP_SPELL_CHECKER,
- g_param_spec_object ("spell-checker",
- "Spell Checker",
- "",
- GSPELL_TYPE_CHECKER,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
}
static void
@@ -312,6 +276,7 @@ gspell_navigator_gtv_goto_next (GspellNavigator *navigator,
GError **error_p)
{
GspellNavigatorGtvPrivate *priv;
+ GspellChecker *spell_checker;
GtkTextIter word_start;
GtkTextIter end;
GtkTextTag *no_spell_check_tag;
@@ -321,11 +286,18 @@ gspell_navigator_gtv_goto_next (GspellNavigator *navigator,
g_assert ((priv->word_start == NULL && priv->word_end == NULL) ||
(priv->word_start != NULL && priv->word_end != NULL));
- if (gspell_checker_get_language (priv->spell_checker) == NULL)
+ spell_checker = gspell_text_buffer_get_spell_checker (priv->buffer);
+
+ if (spell_checker == NULL)
+ {
+ return FALSE;
+ }
+
+ if (gspell_checker_get_language (spell_checker) == NULL)
{
if (spell_checker_p != NULL)
{
- *spell_checker_p = g_object_ref (priv->spell_checker);
+ *spell_checker_p = g_object_ref (spell_checker);
}
g_set_error (error_p,
@@ -407,7 +379,7 @@ gspell_navigator_gtv_goto_next (GspellNavigator *navigator,
word = gtk_text_buffer_get_text (priv->buffer, &word_start, &word_end, FALSE);
- correctly_spelled = gspell_checker_check_word (priv->spell_checker, word, -1, &error);
+ correctly_spelled = gspell_checker_check_word (spell_checker, word, -1, &error);
if (error != NULL)
{
@@ -426,7 +398,7 @@ gspell_navigator_gtv_goto_next (GspellNavigator *navigator,
if (spell_checker_p != NULL)
{
- *spell_checker_p = g_object_ref (priv->spell_checker);
+ *spell_checker_p = g_object_ref (spell_checker);
}
if (word_p != NULL)
@@ -545,20 +517,16 @@ gspell_navigator_iface_init (gpointer g_iface,
/**
* gspell_navigator_gtv_new:
* @view: a #GtkTextView.
- * @spell_checker: a #GspellChecker.
*
* Returns: (transfer full): a new #GspellNavigatorGtv object.
*/
GspellNavigator *
-gspell_navigator_gtv_new (GtkTextView *view,
- GspellChecker *spell_checker)
+gspell_navigator_gtv_new (GtkTextView *view)
{
g_return_val_if_fail (GTK_IS_TEXT_VIEW (view), NULL);
- g_return_val_if_fail (GSPELL_IS_CHECKER (spell_checker), NULL);
return g_object_new (GSPELL_TYPE_NAVIGATOR_GTV,
"view", view,
- "spell-checker", spell_checker,
NULL);
}
diff --git a/gspell/gspell-navigator-gtv.h b/gspell/gspell-navigator-gtv.h
index 7d5caf9..451b7e1 100644
--- a/gspell/gspell-navigator-gtv.h
+++ b/gspell/gspell-navigator-gtv.h
@@ -43,8 +43,7 @@ struct _GspellNavigatorGtvClass
gpointer padding[8];
};
-GspellNavigator * gspell_navigator_gtv_new (GtkTextView *view,
- GspellChecker *spell_checker);
+GspellNavigator * gspell_navigator_gtv_new (GtkTextView *view);
G_END_DECLS
diff --git a/tests/test-spell.c b/tests/test-spell.c
index 57f2489..7a639a0 100644
--- a/tests/test-spell.c
+++ b/tests/test-spell.c
@@ -73,9 +73,7 @@ checker_button_clicked_cb (GtkButton *checker_button,
g_return_if_reached ();
}
- navigator = gspell_navigator_gtv_new (spell->view,
- get_spell_checker (spell));
-
+ navigator = gspell_navigator_gtv_new (spell->view);
checker_dialog = gspell_checker_dialog_new (GTK_WINDOW (window), navigator);
g_object_unref (navigator);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]