Commit 9d4a85a1 authored by Sébastien Wilmet's avatar Sébastien Wilmet

Rename GspellInlineCheckerTextView -> GspellTextView

parent 8e1dd019
......@@ -51,15 +51,15 @@ GSPELL_TYPE_TEXT_BUFFER
</SECTION>
<SECTION>
<FILE>inline-checker-text-view</FILE>
<TITLE>GspellInlineCheckerTextView</TITLE>
GspellInlineCheckerTextView
<FILE>text-view</FILE>
<TITLE>GspellTextView</TITLE>
GspellTextView
gspell_text_view_get_inline_checker
gspell_inline_checker_text_view_set_enabled
gspell_inline_checker_text_view_get_enabled
gspell_text_view_get_enabled
gspell_text_view_set_enabled
<SUBSECTION Standard>
GSPELL_TYPE_INLINE_CHECKER_TEXT_VIEW
GspellInlineCheckerTextViewClass
GSPELL_TYPE_TEXT_VIEW
GspellTextViewClass
</SECTION>
<SECTION>
......
......@@ -28,7 +28,7 @@
<chapter>
<title>Inline Checkers</title>
<xi:include href="xml/inline-checker-text-view.xml"/>
<xi:include href="xml/text-view.xml"/>
</chapter>
<chapter>
......
......@@ -20,26 +20,26 @@ gspell_public_headers = \
gspell.h \
gspell-checker.h \
gspell-checker-dialog.h \
gspell-inline-checker-text-view.h \
gspell-language.h \
gspell-language-chooser.h \
gspell-language-chooser-button.h \
gspell-language-chooser-dialog.h \
gspell-navigator.h \
gspell-navigator-text-view.h \
gspell-text-buffer.h
gspell-text-buffer.h \
gspell-text-view.h
gspell_public_c_files = \
gspell-checker.c \
gspell-checker-dialog.c \
gspell-inline-checker-text-view.c \
gspell-language.c \
gspell-language-chooser.c \
gspell-language-chooser-button.c \
gspell-language-chooser-dialog.c \
gspell-navigator.c \
gspell-navigator-text-view.c \
gspell-text-buffer.c
gspell-text-buffer.c \
gspell-text-view.c
gspell_private_headers = \
gconstructor.h \
......
......@@ -24,8 +24,8 @@
* @Title: GspellTextBuffer
* @Short_description: Spell checking support for GtkTextBuffer
*
* #GspellTextBuffer extends the #GtkTextBuffer class without subclassing it,
* because the GtkSourceView library has already a #GtkTextBuffer subclass.
* #GspellTextBuffer extends the #GtkTextBuffer class but without subclassing
* it, because the GtkSourceView library has already a #GtkTextBuffer subclass.
*/
struct _GspellTextBuffer
......
......@@ -17,21 +17,20 @@
* along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include "gspell-inline-checker-text-view.h"
#include "gspell-text-view.h"
#include "gspell-inline-checker-text-buffer.h"
/**
* SECTION:inline-checker-text-view
* @Short_description: Inline spell checker for GtkTextView
* @Title: GspellInlineCheckerTextView
* SECTION:text-view
* @Title: GspellTextView
* @Short_description: Spell checking support for GtkTextView
*
* The #GspellInlineCheckerTextView is an inline spell checker for the
* #GtkTextView widget. Misspelled words are highlighted with a
* %PANGO_UNDERLINE_ERROR, usually a red wavy underline. Right-clicking a
* misspelled word pops up a context menu of suggested replacements. The context
* menu also contains an “Ignore All” item to add the misspelled word to the
* session dictionary. And an “Add” item to add the word to the personal
* dictionary.
* #GspellTextView extends the #GtkTextView class with inline spell checking.
* Misspelled words are highlighted with a %PANGO_UNDERLINE_ERROR, usually a red
* wavy underline. Right-clicking a misspelled word pops up a context menu of
* suggested replacements. The context menu also contains an “Ignore All” item
* to add the misspelled word to the session dictionary. And an “Add” item to
* add the word to the personal dictionary.
*
* The spell is checked only on the visible region of the #GtkTextView. Note
* that if a same #GtkTextBuffer is used for several views, the misspelled words
......@@ -41,14 +40,18 @@
* You need to call gspell_text_buffer_set_spell_checker() to associate a
* #GspellChecker to the #GtkTextBuffer. #GtkTextView:buffer changes are
* handled, as well as #GspellChecker changes.
*
* Note that #GspellTextView extends the #GtkTextView class but without
* subclassing it, because the GtkSourceView library has already a #GtkTextView
* subclass.
*/
typedef struct _GspellInlineCheckerTextViewPrivate GspellInlineCheckerTextViewPrivate;
typedef struct _GspellTextViewPrivate GspellTextViewPrivate;
struct _GspellInlineCheckerTextViewPrivate
struct _GspellTextViewPrivate
{
GtkTextView *view;
GspellInlineCheckerTextBuffer *buffer_checker;
GspellInlineCheckerTextBuffer *inline_checker;
};
enum
......@@ -58,97 +61,97 @@ enum
PROP_ENABLED,
};
#define INLINE_CHECKER_KEY "gspell-inline-checker-text-view-key"
#define GSPELL_TEXT_VIEW_KEY "gspell-text-view-key"
G_DEFINE_TYPE_WITH_PRIVATE (GspellInlineCheckerTextView, gspell_inline_checker_text_view, G_TYPE_OBJECT)
G_DEFINE_TYPE_WITH_PRIVATE (GspellTextView, gspell_text_view, G_TYPE_OBJECT)
static void
create_buffer_checker (GspellInlineCheckerTextView *inline_checker)
create_inline_checker (GspellTextView *gspell_view)
{
GspellInlineCheckerTextViewPrivate *priv;
GspellTextViewPrivate *priv;
GtkTextBuffer *buffer;
priv = gspell_inline_checker_text_view_get_instance_private (inline_checker);
priv = gspell_text_view_get_instance_private (gspell_view);
if (priv->buffer_checker != NULL)
if (priv->inline_checker != NULL)
{
return;
}
buffer = gtk_text_view_get_buffer (priv->view);
priv->buffer_checker = _gspell_inline_checker_text_buffer_new (buffer);
_gspell_inline_checker_text_buffer_attach_view (priv->buffer_checker,
priv->inline_checker = _gspell_inline_checker_text_buffer_new (buffer);
_gspell_inline_checker_text_buffer_attach_view (priv->inline_checker,
priv->view);
}
static void
destroy_buffer_checker (GspellInlineCheckerTextView *inline_checker)
destroy_inline_checker (GspellTextView *gspell_view)
{
GspellInlineCheckerTextViewPrivate *priv;
GspellTextViewPrivate *priv;
priv = gspell_inline_checker_text_view_get_instance_private (inline_checker);
priv = gspell_text_view_get_instance_private (gspell_view);
if (priv->view == NULL || priv->buffer_checker == NULL)
if (priv->view == NULL || priv->inline_checker == NULL)
{
return;
}
_gspell_inline_checker_text_buffer_detach_view (priv->buffer_checker,
_gspell_inline_checker_text_buffer_detach_view (priv->inline_checker,
priv->view);
g_clear_object (&priv->buffer_checker);
g_clear_object (&priv->inline_checker);
}
static void
notify_buffer_cb (GtkTextView *view,
GParamSpec *pspec,
GspellInlineCheckerTextView *inline_checker)
notify_buffer_cb (GtkTextView *gtk_view,
GParamSpec *pspec,
GspellTextView *gspell_view)
{
GspellInlineCheckerTextViewPrivate *priv;
GspellTextViewPrivate *priv;
priv = gspell_inline_checker_text_view_get_instance_private (inline_checker);
priv = gspell_text_view_get_instance_private (gspell_view);
if (priv->buffer_checker == NULL)
if (priv->inline_checker == NULL)
{
return;
}
destroy_buffer_checker (inline_checker);
create_buffer_checker (inline_checker);
destroy_inline_checker (gspell_view);
create_inline_checker (gspell_view);
}
static void
set_view (GspellInlineCheckerTextView *inline_checker,
GtkTextView *view)
set_view (GspellTextView *gspell_view,
GtkTextView *gtk_view)
{
GspellInlineCheckerTextViewPrivate *priv;
GspellTextViewPrivate *priv;
g_return_if_fail (GTK_IS_TEXT_VIEW (view));
g_return_if_fail (GTK_IS_TEXT_VIEW (gtk_view));
priv = gspell_inline_checker_text_view_get_instance_private (inline_checker);
priv = gspell_text_view_get_instance_private (gspell_view);
g_assert (priv->view == NULL);
g_assert (priv->buffer_checker == NULL);
g_assert (priv->inline_checker == NULL);
priv->view = view;
priv->view = gtk_view;
g_signal_connect_object (priv->view,
"notify::buffer",
G_CALLBACK (notify_buffer_cb),
inline_checker,
gspell_view,
0);
}
static void
gspell_inline_checker_text_view_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
gspell_text_view_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GspellInlineCheckerTextView *inline_checker;
GspellInlineCheckerTextViewPrivate *priv;
GspellTextView *gspell_view;
GspellTextViewPrivate *priv;
inline_checker = GSPELL_INLINE_CHECKER_TEXT_VIEW (object);
priv = gspell_inline_checker_text_view_get_instance_private (inline_checker);
gspell_view = GSPELL_TEXT_VIEW (object);
priv = gspell_text_view_get_instance_private (gspell_view);
switch (prop_id)
{
......@@ -157,7 +160,7 @@ gspell_inline_checker_text_view_get_property (GObject *object,
break;
case PROP_ENABLED:
g_value_set_boolean (value, gspell_inline_checker_text_view_get_enabled (inline_checker));
g_value_set_boolean (value, gspell_text_view_get_enabled (gspell_view));
break;
default:
......@@ -167,22 +170,21 @@ gspell_inline_checker_text_view_get_property (GObject *object,
}
static void
gspell_inline_checker_text_view_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
gspell_text_view_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GspellInlineCheckerTextView *inline_checker = GSPELL_INLINE_CHECKER_TEXT_VIEW (object);
GspellTextView *gspell_view = GSPELL_TEXT_VIEW (object);
switch (prop_id)
{
case PROP_VIEW:
set_view (inline_checker, g_value_get_object (value));
set_view (gspell_view, g_value_get_object (value));
break;
case PROP_ENABLED:
gspell_inline_checker_text_view_set_enabled (inline_checker,
g_value_get_boolean (value));
gspell_text_view_set_enabled (gspell_view, g_value_get_boolean (value));
break;
default:
......@@ -192,35 +194,35 @@ gspell_inline_checker_text_view_set_property (GObject *object,
}
static void
gspell_inline_checker_text_view_dispose (GObject *object)
gspell_text_view_dispose (GObject *object)
{
GspellInlineCheckerTextViewPrivate *priv;
GspellTextViewPrivate *priv;
priv = gspell_inline_checker_text_view_get_instance_private (GSPELL_INLINE_CHECKER_TEXT_VIEW (object));
priv = gspell_text_view_get_instance_private (GSPELL_TEXT_VIEW (object));
if (priv->view != NULL && priv->buffer_checker != NULL)
if (priv->view != NULL && priv->inline_checker != NULL)
{
_gspell_inline_checker_text_buffer_detach_view (priv->buffer_checker,
_gspell_inline_checker_text_buffer_detach_view (priv->inline_checker,
priv->view);
}
priv->view = NULL;
g_clear_object (&priv->buffer_checker);
g_clear_object (&priv->inline_checker);
G_OBJECT_CLASS (gspell_inline_checker_text_view_parent_class)->dispose (object);
G_OBJECT_CLASS (gspell_text_view_parent_class)->dispose (object);
}
static void
gspell_inline_checker_text_view_class_init (GspellInlineCheckerTextViewClass *klass)
gspell_text_view_class_init (GspellTextViewClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->get_property = gspell_inline_checker_text_view_get_property;
object_class->set_property = gspell_inline_checker_text_view_set_property;
object_class->dispose = gspell_inline_checker_text_view_dispose;
object_class->get_property = gspell_text_view_get_property;
object_class->set_property = gspell_text_view_set_property;
object_class->dispose = gspell_text_view_dispose;
/**
* GspellInlineCheckerTextView:view:
* GspellTextView:view:
*
* The #GtkTextView.
*/
......@@ -235,9 +237,9 @@ gspell_inline_checker_text_view_class_init (GspellInlineCheckerTextViewClass *kl
G_PARAM_STATIC_STRINGS));
/**
* GspellInlineCheckerTextView:enabled:
* GspellTextView:enabled:
*
* Whether the inline spell checker is enabled.
* Whether the inline spell checking is enabled.
*/
g_object_class_install_property (object_class,
PROP_ENABLED,
......@@ -250,91 +252,92 @@ gspell_inline_checker_text_view_class_init (GspellInlineCheckerTextViewClass *kl
}
static void
gspell_inline_checker_text_view_init (GspellInlineCheckerTextView *inline_checker)
gspell_text_view_init (GspellTextView *gspell_view)
{
}
/**
* gspell_text_view_get_inline_checker:
* @view: a #GtkTextView.
* @gtk_view: a #GtkTextView.
*
* Returns the #GspellInlineCheckerTextView of @view. The returned object is
* guaranteed to be the same for the lifetime of @view.
* Returns the #GspellTextView of @gtk_view. The returned object is guaranteed
* to be the same for the lifetime of @gtk_view.
*
* Returns: (transfer none): the #GspellInlineCheckerTextView of @view.
* Returns: (transfer none): the #GspellTextView of @gtk_view.
*/
GspellInlineCheckerTextView *
gspell_text_view_get_inline_checker (GtkTextView *view)
GspellTextView *
gspell_text_view_get_inline_checker (GtkTextView *gtk_view)
{
GspellInlineCheckerTextView *inline_checker;
GspellTextView *gspell_view;
g_return_val_if_fail (GTK_IS_TEXT_VIEW (view), NULL);
g_return_val_if_fail (GTK_IS_TEXT_VIEW (gtk_view), NULL);
inline_checker = g_object_get_data (G_OBJECT (view), INLINE_CHECKER_KEY);
gspell_view = g_object_get_data (G_OBJECT (gtk_view), GSPELL_TEXT_VIEW_KEY);
if (inline_checker == NULL)
if (gspell_view == NULL)
{
inline_checker = g_object_new (GSPELL_TYPE_INLINE_CHECKER_TEXT_VIEW,
"view", view,
NULL);
gspell_view = g_object_new (GSPELL_TYPE_TEXT_VIEW,
"view", gtk_view,
NULL);
g_object_set_data_full (G_OBJECT (view),
INLINE_CHECKER_KEY,
inline_checker,
g_object_set_data_full (G_OBJECT (gtk_view),
GSPELL_TEXT_VIEW_KEY,
gspell_view,
g_object_unref);
}
return inline_checker;
g_return_val_if_fail (GSPELL_IS_TEXT_VIEW (gspell_view), NULL);
return gspell_view;
}
/**
* gspell_inline_checker_text_view_set_enabled:
* @inline_checker: a #GspellInlineCheckerTextView.
* gspell_text_view_set_enabled:
* @gspell_view: a #GspellTextView.
* @enabled: the new state.
*
* Enables or disables the inline spell checker.
* Enables or disables the inline spell checking.
*/
void
gspell_inline_checker_text_view_set_enabled (GspellInlineCheckerTextView *inline_checker,
gboolean enabled)
gspell_text_view_set_enabled (GspellTextView *gspell_view,
gboolean enabled)
{
g_return_if_fail (GSPELL_IS_INLINE_CHECKER_TEXT_VIEW (inline_checker));
g_return_if_fail (GSPELL_IS_TEXT_VIEW (gspell_view));
enabled = enabled != FALSE;
if (enabled == gspell_inline_checker_text_view_get_enabled (inline_checker))
if (enabled == gspell_text_view_get_enabled (gspell_view))
{
return;
}
if (enabled)
{
create_buffer_checker (inline_checker);
create_inline_checker (gspell_view);
}
else
{
destroy_buffer_checker (inline_checker);
destroy_inline_checker (gspell_view);
}
g_object_notify (G_OBJECT (inline_checker), "enabled");
g_object_notify (G_OBJECT (gspell_view), "enabled");
}
/**
* gspell_inline_checker_text_view_get_enabled:
* @inline_checker: a #GspellInlineCheckerTextView.
* gspell_text_view_get_enabled:
* @gspell_view: a #GspellTextView.
*
* Returns: whether the inline spell checker is enabled.
* Returns: whether the inline spell checking is enabled.
*/
gboolean
gspell_inline_checker_text_view_get_enabled (GspellInlineCheckerTextView *inline_checker)
gspell_text_view_get_enabled (GspellTextView *gspell_view)
{
GspellInlineCheckerTextViewPrivate *priv;
GspellTextViewPrivate *priv;
g_return_val_if_fail (GSPELL_IS_INLINE_CHECKER_TEXT_VIEW (inline_checker), FALSE);
g_return_val_if_fail (GSPELL_IS_TEXT_VIEW (gspell_view), FALSE);
priv = gspell_inline_checker_text_view_get_instance_private (inline_checker);
priv = gspell_text_view_get_instance_private (gspell_view);
return priv->buffer_checker != NULL;
return priv->inline_checker != NULL;
}
/* ex:set ts=8 noet: */
......@@ -17,8 +17,8 @@
* along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GSPELL_INLINE_CHECKER_TEXT_VIEW_H__
#define __GSPELL_INLINE_CHECKER_TEXT_VIEW_H__
#ifndef __GSPELL_TEXT_VIEW_H__
#define __GSPELL_TEXT_VIEW_H__
#if !defined (__GSPELL_H_INSIDE__) && !defined (GSPELL_COMPILATION)
#error "Only <gspell/gspell.h> can be included directly."
......@@ -28,12 +28,12 @@
G_BEGIN_DECLS
#define GSPELL_TYPE_INLINE_CHECKER_TEXT_VIEW (gspell_inline_checker_text_view_get_type ())
G_DECLARE_DERIVABLE_TYPE (GspellInlineCheckerTextView, gspell_inline_checker_text_view,
GSPELL, INLINE_CHECKER_TEXT_VIEW,
#define GSPELL_TYPE_TEXT_VIEW (gspell_text_view_get_type ())
G_DECLARE_DERIVABLE_TYPE (GspellTextView, gspell_text_view,
GSPELL, TEXT_VIEW,
GObject)
struct _GspellInlineCheckerTextViewClass
struct _GspellTextViewClass
{
GObjectClass parent_class;
......@@ -41,16 +41,15 @@ struct _GspellInlineCheckerTextViewClass
gpointer padding[8];
};
GspellInlineCheckerTextView *
gspell_text_view_get_inline_checker (GtkTextView *view);
GspellTextView * gspell_text_view_get_inline_checker (GtkTextView *gtk_view);
void gspell_inline_checker_text_view_set_enabled (GspellInlineCheckerTextView *inline_checker,
gboolean enabled);
void gspell_text_view_set_enabled (GspellTextView *gspell_view,
gboolean enabled);
gboolean gspell_inline_checker_text_view_get_enabled (GspellInlineCheckerTextView *inline_checker);
gboolean gspell_text_view_get_enabled (GspellTextView *gspell_view);
G_END_DECLS
#endif /* __GSPELL_INLINE_CHECKER_TEXT_VIEW_H__ */
#endif /* __GSPELL_TEXT_VIEW_H__ */
/* ex:set ts=8 noet: */
......@@ -24,7 +24,6 @@
#include <gspell/gspell-checker.h>
#include <gspell/gspell-checker-dialog.h>
#include <gspell/gspell-inline-checker-text-view.h>
#include <gspell/gspell-language.h>
#include <gspell/gspell-language-chooser.h>
#include <gspell/gspell-language-chooser-button.h>
......@@ -32,6 +31,7 @@
#include <gspell/gspell-navigator.h>
#include <gspell/gspell-navigator-text-view.h>
#include <gspell/gspell-text-buffer.h>
#include <gspell/gspell-text-view.h>
#undef __GSPELL_H_INSIDE__
......
......@@ -2,7 +2,6 @@
gspell/gspell-checker.c
gspell/gspell-checker-dialog.c
gspell/gspell-inline-checker-text-buffer.c
gspell/gspell-inline-checker-text-view.c
gspell/gspell-language.c
gspell/gspell-language-chooser.c
gspell/gspell-language-chooser-button.c
......@@ -12,6 +11,7 @@ gspell/gspell-navigator-text-view.c
gspell/gspell-osx.c
gspell/gspell-text-buffer.c
gspell/gspell-text-iter.c
gspell/gspell-text-view.c
gspell/gspell-utils.c
gspell/resources/checker-dialog.ui
gspell/resources/language-dialog.ui
......@@ -103,7 +103,7 @@ get_sidebar (TestSpell *spell)
GtkWidget *change_buffer_button;
GspellChecker *checker;
const GspellLanguage *language;
GspellInlineCheckerTextView *inline_checker;
GspellTextView *inline_checker;
sidebar = gtk_grid_new ();
......
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