Commit 69a6992f authored by Sébastien Wilmet's avatar Sébastien Wilmet

text-buffer: have a real class

The API will be better with a real class. And having the spell-checker
property (with the notify signal) is cleaner than the BufferNotifier
singleton hack. (and the notify signal is available to apps, while the
BufferNotifier was private).
parent 7bb05658
......@@ -20,7 +20,6 @@ CFILE_GLOB = $(top_srcdir)/gspell/*.c
# Header files or dirs to ignore when scanning. Use base file/dir names
# e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h private_code
IGNORE_HFILES = \
gspell-buffer-notifier.h \
gspell-inline-checker-text-buffer.h \
gspell-osx.h \
gspell-text-iter.h \
......
......@@ -40,9 +40,14 @@ gspell_language_get_type
<SECTION>
<FILE>text-buffer</FILE>
<TITLE>GtkTextBuffer support</TITLE>
gspell_text_buffer_set_spell_checker
<TITLE>GspellTextBuffer</TITLE>
GspellTextBuffer
gspell_text_buffer_get_from_gtk_text_buffer
gspell_text_buffer_get_buffer
gspell_text_buffer_get_spell_checker
gspell_text_buffer_set_spell_checker
<SUBSECTION Standard>
GSPELL_TYPE_TEXT_BUFFER
</SECTION>
<SECTION>
......
......@@ -43,14 +43,12 @@ gspell_public_c_files = \
gspell_private_headers = \
gconstructor.h \
gspell-buffer-notifier.h \
gspell-inline-checker-text-buffer.h \
gspell-text-iter.h \
gspell-text-region.h \
gspell-utils.h
gspell_private_c_files = \
gspell-buffer-notifier.c \
gspell-init.c \
gspell-inline-checker-text-buffer.c \
gspell-text-iter.c \
......
/*
* This file is part of gspell, a spell-checking library.
*
* Copyright 2015 - Sébastien Wilmet
*
* 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.1 of the License, 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/>.
*/
#include "gspell-buffer-notifier.h"
struct _GspellBufferNotifier
{
GObject parent;
};
enum
{
SIGNAL_TEXT_BUFFER_CHECKER_CHANGED,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE (GspellBufferNotifier, _gspell_buffer_notifier, G_TYPE_OBJECT)
static void
_gspell_buffer_notifier_class_init (GspellBufferNotifierClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
/**
* GspellBufferNotifier::text-buffer-checker-changed:
* @notifier: the #GspellBufferNotifier singleton.
* @buffer: the #GtkTextBuffer.
* @new_checker: (nullable): the new #GspellChecker, or %NULL.
*
* Emitted when a different spell checker is associated to @buffer.
*/
signals[SIGNAL_TEXT_BUFFER_CHECKER_CHANGED] =
g_signal_new ("text-buffer-checker-changed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL, NULL,
G_TYPE_NONE,
2,
GTK_TYPE_TEXT_BUFFER,
GSPELL_TYPE_CHECKER);
}
static void
_gspell_buffer_notifier_init (GspellBufferNotifier *notifier)
{
}
GspellBufferNotifier *
_gspell_buffer_notifier_get_instance (void)
{
static GspellBufferNotifier *instance = NULL;
if (instance == NULL)
{
instance = g_object_new (GSPELL_TYPE_BUFFER_NOTIFIER, NULL);
/* In case the caller unrefs the instance. */
g_object_add_weak_pointer (G_OBJECT (instance),
(gpointer *) &instance);
}
return instance;
}
void
_gspell_buffer_notifier_text_buffer_checker_changed (GspellBufferNotifier *notifier,
GtkTextBuffer *buffer,
GspellChecker *new_checker)
{
g_return_if_fail (GSPELL_IS_BUFFER_NOTIFIER (notifier));
g_return_if_fail (GTK_IS_TEXT_BUFFER (buffer));
g_return_if_fail (new_checker == NULL || GSPELL_IS_CHECKER (new_checker));
g_signal_emit (notifier,
signals[SIGNAL_TEXT_BUFFER_CHECKER_CHANGED], 0,
buffer,
new_checker);
}
/* ex:set ts=8 noet: */
/*
* This file is part of gspell, a spell-checking library.
*
* Copyright 2015 - Sébastien Wilmet
*
* 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.1 of the License, 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/>.
*/
#ifndef __GSPELL_BUFFER_NOTIFIER_H__
#define __GSPELL_BUFFER_NOTIFIER_H__
#include <gtk/gtk.h>
#include "gspell-checker.h"
G_BEGIN_DECLS
#define GSPELL_TYPE_BUFFER_NOTIFIER (_gspell_buffer_notifier_get_type ())
G_GNUC_INTERNAL
G_DECLARE_FINAL_TYPE (GspellBufferNotifier, _gspell_buffer_notifier,
GSPELL, BUFFER_NOTIFIER,
GObject)
G_GNUC_INTERNAL
GspellBufferNotifier * _gspell_buffer_notifier_get_instance (void);
G_GNUC_INTERNAL
void _gspell_buffer_notifier_text_buffer_checker_changed (GspellBufferNotifier *notifier,
GtkTextBuffer *buffer,
GspellChecker *new_checker);
G_END_DECLS
#endif /* __GSPELL_BUFFER_NOTIFIER_H__ */
/* ex:set ts=8 noet: */
......@@ -27,7 +27,6 @@
#include <glib.h>
#include <glib/gi18n-lib.h>
#include "gconstructor.h"
#include "gspell-buffer-notifier.h"
#ifdef G_OS_WIN32
#define WIN32_LEAN_AND_MEAN
......@@ -123,18 +122,6 @@ gspell_init (void)
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
}
static void
gspell_finalize (void)
{
GspellBufferNotifier *notifier;
/* Destroy singleton, to have less garbage in the output of memory
* debugging tools.
*/
notifier = _gspell_buffer_notifier_get_instance ();
g_object_unref (notifier);
}
#if defined (G_OS_WIN32)
BOOL WINAPI DllMain (HINSTANCE hinstDLL,
......@@ -154,9 +141,6 @@ DllMain (HINSTANCE hinstDLL,
break;
case DLL_THREAD_DETACH:
gspell_finalize ();
break;
default:
/* do nothing */
break;
......@@ -178,17 +162,6 @@ gspell_constructor (void)
gspell_init ();
}
# ifdef G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA
# pragma G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(gspell_destructor)
# endif
G_DEFINE_DESTRUCTOR (gspell_destructor)
static void
gspell_destructor (void)
{
gspell_finalize ();
}
#else
# error Your platform/compiler is missing constructor support
#endif
......
......@@ -27,7 +27,6 @@
#include <string.h>
#include <glib/gi18n-lib.h>
#include "gspell-checker.h"
#include "gspell-buffer-notifier.h"
#include "gspell-text-buffer.h"
#include "gspell-text-iter.h"
#include "gspell-text-region.h"
......@@ -1172,16 +1171,16 @@ set_spell_checker (GspellInlineCheckerTextBuffer *spell,
}
static void
text_buffer_checker_changed_cb (GspellBufferNotifier *notifier,
GtkTextBuffer *buffer,
GspellChecker *new_checker,
GspellInlineCheckerTextBuffer *spell)
spell_checker_notify_cb (GspellTextBuffer *gspell_buffer,
GParamSpec *pspec,
GspellInlineCheckerTextBuffer *spell)
{
if (spell->buffer == buffer)
{
set_spell_checker (spell, new_checker);
recheck_all (spell);
}
GspellChecker *new_checker;
new_checker = gspell_text_buffer_get_spell_checker (gspell_buffer);
set_spell_checker (spell, new_checker);
recheck_all (spell);
}
static void
......@@ -1190,8 +1189,8 @@ set_buffer (GspellInlineCheckerTextBuffer *spell,
{
GtkTextTagTable *tag_table;
GtkTextIter start;
GspellTextBuffer *gspell_buffer;
GspellChecker *checker;
GspellBufferNotifier *notifier;
g_return_if_fail (GTK_IS_TEXT_BUFFER (buffer));
g_return_if_fail (spell->buffer == NULL);
......@@ -1278,13 +1277,13 @@ set_buffer (GspellInlineCheckerTextBuffer *spell,
gtk_text_buffer_get_start_iter (spell->buffer, &start);
spell->mark_click = gtk_text_buffer_create_mark (spell->buffer, NULL, &start, TRUE);
checker = gspell_text_buffer_get_spell_checker (spell->buffer);
gspell_buffer = gspell_text_buffer_get_from_gtk_text_buffer (spell->buffer);
checker = gspell_text_buffer_get_spell_checker (gspell_buffer);
set_spell_checker (spell, checker);
notifier = _gspell_buffer_notifier_get_instance ();
g_signal_connect_object (notifier,
"text-buffer-checker-changed",
G_CALLBACK (text_buffer_checker_changed_cb),
g_signal_connect_object (gspell_buffer,
"notify::spell-checker",
G_CALLBACK (spell_checker_notify_cb),
spell,
0);
......
......@@ -276,6 +276,7 @@ gspell_navigator_text_view_goto_next (GspellNavigator *navigator,
GError **error_p)
{
GspellNavigatorTextViewPrivate *priv;
GspellTextBuffer *gspell_buffer;
GspellChecker *spell_checker;
GtkTextIter word_start;
GtkTextIter end;
......@@ -286,7 +287,8 @@ gspell_navigator_text_view_goto_next (GspellNavigator *navigator,
g_assert ((priv->word_start == NULL && priv->word_end == NULL) ||
(priv->word_start != NULL && priv->word_end != NULL));
spell_checker = gspell_text_buffer_get_spell_checker (priv->buffer);
gspell_buffer = gspell_text_buffer_get_from_gtk_text_buffer (priv->buffer);
spell_checker = gspell_text_buffer_get_spell_checker (gspell_buffer);
if (spell_checker == NULL)
{
......
/*
* This file is part of gspell, a spell-checking library.
*
* Copyright 2015 - Sébastien Wilmet
* Copyright 2015, 2016 - Sébastien Wilmet
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -18,77 +18,235 @@
*/
#include "gspell-text-buffer.h"
#include "gspell-buffer-notifier.h"
/**
* SECTION:text-buffer
* @Title: GtkTextBuffer support
* @See_also: #GspellChecker
* @Title: GspellTextBuffer
*
* Spell checking support for #GtkTextBuffer.
* #GspellTextBuffer extends the #GtkTextBuffer class without subclassing it,
* because the GtkSourceView library has already a #GtkTextBuffer subclass.
*/
#define SPELL_CHECKER_KEY "gspell-text-buffer-spell-checker-key"
struct _GspellTextBuffer
{
GObject parent;
GtkTextBuffer *buffer;
GspellChecker *spell_checker;
};
enum
{
PROP_0,
PROP_BUFFER,
PROP_SPELL_CHECKER,
};
#define GSPELL_TEXT_BUFFER_KEY "gspell-text-buffer-key"
G_DEFINE_TYPE (GspellTextBuffer, gspell_text_buffer, G_TYPE_OBJECT)
static void
gspell_text_buffer_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GspellTextBuffer *gspell_buffer = GSPELL_TEXT_BUFFER (object);
switch (prop_id)
{
case PROP_BUFFER:
g_value_set_object (value, gspell_text_buffer_get_buffer (gspell_buffer));
break;
case PROP_SPELL_CHECKER:
g_value_set_object (value, gspell_text_buffer_get_spell_checker (gspell_buffer));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gspell_text_buffer_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GspellTextBuffer *gspell_buffer = GSPELL_TEXT_BUFFER (object);
switch (prop_id)
{
case PROP_BUFFER:
g_assert (gspell_buffer->buffer == NULL);
gspell_buffer->buffer = g_value_get_object (value);
break;
case PROP_SPELL_CHECKER:
gspell_text_buffer_set_spell_checker (gspell_buffer, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gspell_text_buffer_dispose (GObject *object)
{
GspellTextBuffer *gspell_buffer = GSPELL_TEXT_BUFFER (object);
gspell_buffer->buffer = NULL;
g_clear_object (&gspell_buffer->spell_checker);
G_OBJECT_CLASS (gspell_text_buffer_parent_class)->dispose (object);
}
static void
gspell_text_buffer_class_init (GspellTextBufferClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->get_property = gspell_text_buffer_get_property;
object_class->set_property = gspell_text_buffer_set_property;
object_class->dispose = gspell_text_buffer_dispose;
/**
* GspellTextBuffer:buffer:
*
* The #GtkTextBuffer.
*/
g_object_class_install_property (object_class,
PROP_BUFFER,
g_param_spec_object ("buffer",
"Buffer",
"",
GTK_TYPE_TEXT_BUFFER,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
/**
* GspellTextBuffer:spell-checker:
*
* The #GspellChecker.
*/
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_STATIC_STRINGS));
}
static void
gspell_text_buffer_init (GspellTextBuffer *gspell_buffer)
{
}
static GspellTextBuffer *
gspell_text_buffer_new (GtkTextBuffer *gtk_buffer)
{
g_return_val_if_fail (GTK_IS_TEXT_BUFFER (gtk_buffer), NULL);
return g_object_new (GSPELL_TYPE_TEXT_BUFFER,
"buffer", gtk_buffer,
NULL);
}
/**
* gspell_text_buffer_set_spell_checker:
* @buffer: a #GtkTextBuffer.
* @checker: (nullable): a #GspellChecker, or %NULL to unset the spell checker.
* gspell_text_buffer_get_from_gtk_text_buffer:
* @gtk_buffer: a #GtkTextBuffer.
*
* Associates a spell checker to a #GtkTextBuffer. The @buffer will own a
* reference to @checker, so you can release your reference to @checker if you
* no longer need it.
* Returns the #GspellTextBuffer of @gtk_buffer. The returned object is
* guaranteed to be the same for the lifetime of @gtk_buffer.
*
* Returns: (transfer none): the #GspellTextBuffer of @gtk_buffer.
*/
void
gspell_text_buffer_set_spell_checker (GtkTextBuffer *buffer,
GspellChecker *checker)
/* Yes I know, the function name is a bit long. But at least there is no
* possible confusions. Other names that came to my mind:
* - get_from_buffer(), but it's confusing: which buffer is it?
* - get_from_sibling(): less clear.
*/
GspellTextBuffer *
gspell_text_buffer_get_from_gtk_text_buffer (GtkTextBuffer *gtk_buffer)
{
GspellBufferNotifier *notifier;
GspellTextBuffer *gspell_buffer;
g_return_if_fail (GTK_IS_TEXT_BUFFER (buffer));
g_return_if_fail (checker == NULL || GSPELL_IS_CHECKER (checker));
g_return_val_if_fail (GTK_IS_TEXT_BUFFER (gtk_buffer), NULL);
if (checker != NULL)
{
g_object_set_data_full (G_OBJECT (buffer),
SPELL_CHECKER_KEY,
g_object_ref (checker),
g_object_unref);
}
else
gspell_buffer = g_object_get_data (G_OBJECT (gtk_buffer), GSPELL_TEXT_BUFFER_KEY);
if (gspell_buffer != NULL)
{
g_object_set_data (G_OBJECT (buffer),
SPELL_CHECKER_KEY,
NULL);
g_return_val_if_fail (GSPELL_IS_TEXT_BUFFER (gspell_buffer), NULL);
return gspell_buffer;
}
notifier = _gspell_buffer_notifier_get_instance ();
_gspell_buffer_notifier_text_buffer_checker_changed (notifier, buffer, checker);
gspell_buffer = gspell_text_buffer_new (gtk_buffer);
g_object_set_data_full (G_OBJECT (gtk_buffer),
GSPELL_TEXT_BUFFER_KEY,
gspell_buffer,
g_object_unref);
return gspell_buffer;
}
/**
* gspell_text_buffer_get_buffer:
* @gspell_buffer: a #GspellTextBuffer.
*
* Returns: (transfer none): the #GtkTextBuffer of @gspell_buffer.
*/
GtkTextBuffer *
gspell_text_buffer_get_buffer (GspellTextBuffer *gspell_buffer)
{
g_return_val_if_fail (GSPELL_IS_TEXT_BUFFER (gspell_buffer), NULL);
return gspell_buffer->buffer;
}
/**
* gspell_text_buffer_get_spell_checker:
* @buffer: a #GtkTextBuffer.
* @gspell_buffer: a #GspellTextBuffer.
*
* Returns: (nullable) (transfer none): the associated #GspellChecker if one has
* been set, or %NULL.
* Returns: (nullable) (transfer none): the #GspellChecker if one has been set,
* or %NULL.
*/
GspellChecker *
gspell_text_buffer_get_spell_checker (GtkTextBuffer *buffer)
gspell_text_buffer_get_spell_checker (GspellTextBuffer *gspell_buffer)
{
gpointer data;
g_return_val_if_fail (GSPELL_IS_TEXT_BUFFER (gspell_buffer), NULL);
g_return_val_if_fail (GTK_IS_TEXT_BUFFER (buffer), NULL);
return gspell_buffer->spell_checker;
}
data = g_object_get_data (G_OBJECT (buffer), SPELL_CHECKER_KEY);
/**
* gspell_text_buffer_set_spell_checker:
* @gspell_buffer: a #GspellTextBuffer.
* @spell_checker: (nullable): a #GspellChecker, or %NULL to unset the spell
* checker.
*
* Sets a #GspellChecker to a #GspellTextBuffer. The @gspell_buffer will own a
* reference to @spell_checker, so you can release your reference to
* @spell_checker if you no longer need it.
*/
void
gspell_text_buffer_set_spell_checker (GspellTextBuffer *gspell_buffer,
GspellChecker *spell_checker)
{
g_return_if_fail (GSPELL_IS_TEXT_BUFFER (gspell_buffer));
g_return_if_fail (spell_checker == NULL || GSPELL_IS_CHECKER (spell_checker));
if (data == NULL)
if (g_set_object (&gspell_buffer->spell_checker, spell_checker))
{
return NULL;
g_object_notify (G_OBJECT (gspell_buffer), "spell-checker");
}
g_return_val_if_fail (GSPELL_IS_CHECKER (data), NULL);
return data;
}
/* ex:set ts=8 noet: */
/*
* This file is part of gspell, a spell-checking library.
*
* Copyright 2015 - Sébastien Wilmet
* Copyright 2015, 2016 - Sébastien Wilmet
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -27,10 +27,23 @@
#include <gspell/gspell-checker.h>
#include <gtk/gtk.h>
void gspell_text_buffer_set_spell_checker (GtkTextBuffer *buffer,
GspellChecker *checker);
G_BEGIN_DECLS
GspellChecker * gspell_text_buffer_get_spell_checker (GtkTextBuffer *buffer);
#define GSPELL_TYPE_TEXT_BUFFER (gspell_text_buffer_get_type ())
G_DECLARE_FINAL_TYPE (GspellTextBuffer, gspell_text_buffer,
GSPELL, TEXT_BUFFER,
GObject)
GspellTextBuffer * gspell_text_buffer_get_from_gtk_text_buffer (GtkTextBuffer *gtk_buffer);
GtkTextBuffer * gspell_text_buffer_get_buffer (GspellTextBuffer *gspell_buffer);
GspellChecker * gspell_text_buffer_get_spell_checker (GspellTextBuffer *gspell_buffer);
void gspell_text_buffer_set_spell_checker (GspellTextBuffer *gspell_buffer,
GspellChecker *spell_checker);
G_END_DECLS
#endif /* __GSPELL_TEXT_BUFFER_H__ */
......
# List of source files containing translatable strings.
gspell/gspell-buffer-notifier.c
gspell/gspell-checker.c
gspell/gspell-checker-dialog.c
gspell/gspell-inline-checker-text-buffer.c
......
......@@ -36,8 +36,13 @@ G_DEFINE_TYPE (TestSpell, test_spell, GTK_TYPE_GRID)
static GspellChecker *
get_spell_checker (TestSpell *spell)
{
GtkTextBuffer *buffer = gtk_text_view_get_buffer (spell->view);
return gspell_text_buffer_get_spell_checker (buffer);
GtkTextBuffer *gtk_buffer;
GspellTextBuffer *gspell_buffer;
gtk_buffer = gtk_text_view_get_buffer (spell->view);
gspell_buffer = gspell_text_buffer_get_from_gtk_text_buffer (gtk_buffer);
return gspell_text_buffer_get_spell_checker (gspell_buffer);
}
static void
......@@ -70,18 +75,22 @@ static void
change_buffer_button_clicked_cb (GtkButton *change_buffer_button,
TestSpell *spell)
{
GtkTextBuffer *old_buffer;
GtkTextBuffer *new_buffer;
GtkTextBuffer *old_gtk_buffer;
GtkTextBuffer *new_gtk_buffer;
GspellTextBuffer *old_gspell_buffer;
GspellTextBuffer *new_gspell_buffer;
GspellChecker *checker;
old_buffer = gtk_text_view_get_buffer (spell->view);
checker = gspell_text_buffer_get_spell_checker (old_buffer);
old_gtk_buffer = gtk_text_view_get_buffer (spell->view);
old_gspell_buffer = gspell_text_buffer_get_from_gtk_text_buffer (old_gtk_buffer);
checker = gspell_text_buffer_get_spell_checker (old_gspell_buffer);
new_buffer = gtk_text_buffer_new (NULL);
gspell_text_buffer_set_spell_checker (new_buffer, checker);
new_gtk_buffer = gtk_text_buffer_new (NULL);
new_gspell_buffer = gspell_text_buffer_get_from_gtk_text_buffer (new_gtk_buffer);
gspell_text_buffer_set_spell_checker (new_gspell_buffer, checker);
gtk_text_view_set_buffer (spell->view, new_buffer);
g_object_unref (new_buffer);
gtk_text_view_set_buffer (spell->view, new_gtk_buffer);
g_object_unref (new_gtk_buffer);
}
static GtkWidget *
......@@ -157,14 +166,16 @@ static void
test_spell_init (TestSpell *spell)
{
GtkWidget *scrolled_window;
GtkTextBuffer *buffer;
GtkTextBuffer *gtk_buffer;
GspellTextBuffer *gspell_buffer;
GspellChecker *checker;
spell->view = GTK_TEXT_VIEW (gtk_text_view_new ());
buffer = gtk_text_view_get_buffer (spell->view);
gtk_buffer = gtk_text_view_get_buffer (spell->view);
checker = gspell_checker_new (NULL);
gspell_text_buffer_set_spell_checker (buffer, checker);
gspell_buffer = gspell_text_buffer_get_from_gtk_text_buffer (gtk_buffer);
gspell_text_buffer_set_spell_checker (gspell_buffer, checker);
g_object_unref (checker);
gtk_orientable_set_orientation (GTK_ORIENTABLE (spell),
......
......@@ -23,20 +23,22 @@
static GtkTextBuffer *
create_buffer (void)
{
GtkTextBuffer *buffer;
GtkTextBuffer *gtk_buffer;
GspellTextBuffer *gspell_buffer;
const GspellLanguage *lang;
GspellChecker *checker;
buffer = gtk_text_buffer_new (NULL);
gtk_buffer = gtk_text_buffer_new (NULL);
gspell_buffer = gspell_text_buffer_get_from_gtk_text_buffer (gtk_buffer);
lang = gspell_language_lookup ("en_US");
g_assert (lang != NULL);
checker = gspell_checker_new (lang);
gspell_text_buffer_set_spell_checker (buffer, checker);
gspell_text_buffer_set_spell_checker (gspell_buffer, checker);
g_object_unref (checker);
return buffer;
return gtk_buffer;
}
static void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment