[glib/wip/spell-checking: 1/2] GSpellChecker class
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/spell-checking: 1/2] GSpellChecker class
- Date: Tue, 12 Nov 2013 00:41:22 +0000 (UTC)
commit 8425d284abbb172c8bbd965a00db9e767c1559a1
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sun Oct 20 19:42:54 2013 +0200
GSpellChecker class
docs/reference/gio/gio-sections.txt | 16 ++++
docs/reference/gio/gio.types | 1 +
gio/Makefile.am | 2 +
gio/gio.h | 1 +
gio/giotypes.h | 2 +
gio/gspellchecker.c | 144 +++++++++++++++++++++++++++++++++++
gio/gspellchecker.h | 63 +++++++++++++++
7 files changed, 229 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gio/gio-sections.txt b/docs/reference/gio/gio-sections.txt
index 22dc8fd..d259659 100644
--- a/docs/reference/gio/gio-sections.txt
+++ b/docs/reference/gio/gio-sections.txt
@@ -4219,3 +4219,19 @@ G_TYPE_NOTIFICATION
G_TYPE_NOTIFICATION_BACKEND
g_notification_get_type
</SECTION>
+
+<SECTION>
+<FILE>gspellchecker</FILE>
+<TITLE>GSpellChecker</TITLE>
+GSpellChecker
+g_spell_checker_get_available
+g_spell_checker_get_language_code
+<SUBSECTION Standard>
+G_IS_SPELL_CHECKER
+G_IS_SPELL_CHECKER_CLASS
+G_SPELL_CHECKER
+G_SPELL_CHECKER_CLASS
+G_SPELL_CHECKER_GET_CLASS
+G_TYPE_SPELL_CHECKER
+g_spell_checker_get_type
+</SECTION>
diff --git a/docs/reference/gio/gio.types b/docs/reference/gio/gio.types
index 9d43905..b319490 100644
--- a/docs/reference/gio/gio.types
+++ b/docs/reference/gio/gio.types
@@ -140,3 +140,4 @@ g_test_dbus_flags_get_type
g_task_get_type
g_simple_proxy_resolver_get_type
g_subprocess_get_type
+g_spell_checker_get_type
diff --git a/gio/Makefile.am b/gio/Makefile.am
index 3e80e06..b8d90cf 100644
--- a/gio/Makefile.am
+++ b/gio/Makefile.am
@@ -442,6 +442,7 @@ libgio_2_0_la_SOURCES = \
gsubprocess.c \
gsubprocesslauncher-private.h \
gsocketservice.c \
+ gspellchecker.c \
gsrvtarget.c \
gsimpleproxyresolver.c \
gtask.c \
@@ -601,6 +602,7 @@ gio_headers = \
gsocketcontrolmessage.h \
gsocketlistener.h \
gsocketservice.h \
+ gspellchecker.h \
gsrvtarget.h \
gsimpleproxyresolver.h \
gtask.h \
diff --git a/gio/gio.h b/gio/gio.h
index a1c6804..e6cc48b 100644
--- a/gio/gio.h
+++ b/gio/gio.h
@@ -123,6 +123,7 @@
#include <gio/gsocket.h>
#include <gio/gsocketlistener.h>
#include <gio/gsocketservice.h>
+#include <gio/gspellchecker.h>
#include <gio/gsrvtarget.h>
#include <gio/gsimpleproxyresolver.h>
#include <gio/gtask.h>
diff --git a/gio/giotypes.h b/gio/giotypes.h
index 61f78a0..1096f85 100644
--- a/gio/giotypes.h
+++ b/gio/giotypes.h
@@ -532,6 +532,8 @@ typedef struct _GSubprocess GSubprocess;
*/
typedef struct _GSubprocessLauncher GSubprocessLauncher;
+typedef struct _GSpellChecker GSpellChecker;
+
G_END_DECLS
#endif /* __GIO_TYPES_H__ */
diff --git a/gio/gspellchecker.c b/gio/gspellchecker.c
new file mode 100644
index 0000000..1371169
--- /dev/null
+++ b/gio/gspellchecker.c
@@ -0,0 +1,144 @@
+/*
+ * Copyright © 2013 - Sébastien Wilmet
+ *
+ * This program 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 of the licence 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, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Sébastien Wilmet <swilmet gnome org>
+ */
+
+#include "config.h"
+#include "gspellchecker.h"
+#include "glibintl.h"
+
+enum
+{
+ PROP_0,
+ PROP_LANGUAGE_CODE
+};
+
+typedef struct
+{
+ gchar *language_code;
+} GSpellCheckerPrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GSpellChecker, g_spell_checker, G_TYPE_OBJECT)
+
+static void
+g_spell_checker_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GSpellChecker *spell_checker = G_SPELL_CHECKER (object);
+
+ switch (prop_id)
+ {
+ case PROP_LANGUAGE_CODE:
+ g_value_set_string (value, g_spell_checker_get_language_code (spell_checker));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+g_spell_checker_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GSpellCheckerPrivate *priv = g_spell_checker_get_instance_private (G_SPELL_CHECKER (object));
+
+ switch (prop_id)
+ {
+ case PROP_LANGUAGE_CODE:
+ g_assert (priv->language_code == NULL);
+ priv->language_code = g_value_dup_string (value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+g_spell_checker_finalize (GObject *object)
+{
+ GSpellCheckerPrivate *priv = g_spell_checker_get_instance_private (G_SPELL_CHECKER (object));
+
+ g_free (priv->language_code);
+
+ G_OBJECT_CLASS (g_spell_checker_parent_class)->finalize (object);
+}
+
+static void
+g_spell_checker_class_init (GSpellCheckerClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->get_property = g_spell_checker_get_property;
+ object_class->set_property = g_spell_checker_set_property;
+ object_class->finalize = g_spell_checker_finalize;
+
+ g_object_class_install_property (object_class,
+ PROP_LANGUAGE_CODE,
+ g_param_spec_string ("language-code",
+ P_("Language Code"),
+ P_("Language Code"),
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
+}
+
+static void
+g_spell_checker_init (GSpellChecker *spell_checker)
+{
+}
+
+/**
+ * g_spell_checker_get_available:
+ *
+ * Returns: the list of available spell checkers.
+ * Since: 2.40
+ */
+GList *
+g_spell_checker_get_available (void)
+{
+ GSpellChecker *spell_checker = g_object_new (G_TYPE_SPELL_CHECKER,
+ "language-code", "fr_BE",
+ NULL);
+
+ return g_list_prepend (NULL, spell_checker);
+}
+
+/**
+ * g_spell_checker_get_language_code:
+ * @spell_checker: a #GSpellChecker
+ *
+ * Returns: the language code of the spell checker.
+ * Since: 2.40
+ */
+const gchar *
+g_spell_checker_get_language_code (GSpellChecker *spell_checker)
+{
+ GSpellCheckerPrivate *priv = g_spell_checker_get_instance_private (spell_checker);
+
+ return priv->language_code;
+}
diff --git a/gio/gspellchecker.h b/gio/gspellchecker.h
new file mode 100644
index 0000000..6f54ef8
--- /dev/null
+++ b/gio/gspellchecker.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright © 2013 - Sébastien Wilmet
+ *
+ * This program 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 of the licence 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, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Sébastien Wilmet <swilmet gnome org>
+ */
+
+#ifndef __G_SPELL_CHECKER_H__
+#define __G_SPELL_CHECKER_H__
+
+#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
+#error "Only <gio/gio.h> can be included directly."
+#endif
+
+#include <gio/giotypes.h>
+
+G_BEGIN_DECLS
+
+#define G_TYPE_SPELL_CHECKER (g_spell_checker_get_type ())
+#define G_SPELL_CHECKER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_SPELL_CHECKER,
GSpellChecker))
+#define G_SPELL_CHECKER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), G_TYPE_SPELL_CHECKER,
GSpellCheckerClass))
+#define G_IS_SPELL_CHECKER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_SPELL_CHECKER))
+#define G_IS_SPELL_CHECKER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), G_TYPE_SPELL_CHECKER))
+#define G_SPELL_CHECKER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), G_TYPE_SPELL_CHECKER,
GSpellCheckerClass))
+
+typedef struct _GSpellCheckerClass GSpellCheckerClass;
+
+struct _GSpellChecker
+{
+ GObject parent_instance;
+};
+
+struct _GSpellCheckerClass
+{
+ GObjectClass parent_class;
+};
+
+GLIB_AVAILABLE_IN_2_40
+GType g_spell_checker_get_type (void) G_GNUC_CONST;
+
+GLIB_AVAILABLE_IN_2_40
+GList *g_spell_checker_get_available (void);
+
+GLIB_AVAILABLE_IN_2_40
+const gchar *g_spell_checker_get_language_code (GSpellChecker *spell_checker);
+
+G_END_DECLS
+
+#endif /* __G_SPELL_CHECKER_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]