[gspell/wip/buffer: 2/3] Create private GspellBufferNotifier class
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gspell/wip/buffer: 2/3] Create private GspellBufferNotifier class
- Date: Mon, 28 Dec 2015 18:21:34 +0000 (UTC)
commit 9773832b48e66b98da04dd12b291c423893e809f
Author: Sébastien Wilmet <swilmet gnome org>
Date: Mon Dec 28 19:01:52 2015 +0100
Create private GspellBufferNotifier class
docs/reference/Makefile.am | 7 ++-
gspell/Makefile.am | 14 +++---
gspell/gspell-buffer-notifier.c | 95 +++++++++++++++++++++++++++++++++++++++
gspell/gspell-buffer-notifier.h | 47 +++++++++++++++++++
po/POTFILES.in | 1 +
5 files changed, 155 insertions(+), 9 deletions(-)
---
diff --git a/docs/reference/Makefile.am b/docs/reference/Makefile.am
index d6bc321..9b9aab8 100644
--- a/docs/reference/Makefile.am
+++ b/docs/reference/Makefile.am
@@ -19,9 +19,10 @@ 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-osx.h \
- gspell-utils.h \
+IGNORE_HFILES = \
+ gspell-buffer-notifier.h \
+ gspell-osx.h \
+ gspell-utils.h \
gtktextregion.h
# Extra options to supply to gtkdoc-mkdb
diff --git a/gspell/Makefile.am b/gspell/Makefile.am
index b7b9ba6..8041ec7 100644
--- a/gspell/Makefile.am
+++ b/gspell/Makefile.am
@@ -40,14 +40,16 @@ gspell_public_c_files = \
gspell-navigator-gtv.c \
gspell-text-buffer.c
-gspell_private_headers = \
- gconstructor.h \
- gspell-utils.h \
+gspell_private_headers = \
+ gconstructor.h \
+ gspell-buffer-notifier.h \
+ gspell-utils.h \
gtktextregion.h
-gspell_private_c_files = \
- gspell-init.c \
- gspell-utils.c \
+gspell_private_c_files = \
+ gspell-buffer-notifier.c \
+ gspell-init.c \
+ gspell-utils.c \
gtktextregion.c
lib_LTLIBRARIES = libgspell-1.la
diff --git a/gspell/gspell-buffer-notifier.c b/gspell/gspell-buffer-notifier.c
new file mode 100644
index 0000000..ed16115
--- /dev/null
+++ b/gspell/gspell-buffer-notifier.c
@@ -0,0 +1,95 @@
+/*
+ * 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);
+ }
+
+ 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: */
diff --git a/gspell/gspell-buffer-notifier.h b/gspell/gspell-buffer-notifier.h
new file mode 100644
index 0000000..e41c63e
--- /dev/null
+++ b/gspell/gspell-buffer-notifier.h
@@ -0,0 +1,47 @@
+/*
+ * 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: */
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 8b89470..f0e1ef7 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,4 +1,5 @@
# 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-gtv.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]