[evolution] I#210 - Port from gtkspell to gspell
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] I#210 - Port from gtkspell to gspell
- Date: Mon, 11 Mar 2019 10:27:42 +0000 (UTC)
commit 358e51e38f58e36c47877f227371433cd6756ab1
Author: Milan Crha <mcrha redhat com>
Date: Mon Mar 11 11:28:28 2019 +0100
I#210 - Port from gtkspell to gspell
Closes https://gitlab.gnome.org/GNOME/evolution/issues/210
CMakeLists.txt | 14 ++++----
config.h.in | 4 +--
src/e-util/CMakeLists.txt | 12 +++----
src/e-util/e-spell-text-view.c | 73 ++++++++++++++++++------------------------
src/e-util/e-spell-text-view.h | 3 +-
5 files changed, 47 insertions(+), 59 deletions(-)
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9aae87ce04..c5e24687b5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -297,7 +297,7 @@ pkg_check_modules(LIBSOUP REQUIRED libsoup-2.4>=${soup_minimum_version})
pkg_check_modules(WEB_EXTENSION REQUIRED webkit2gtk-4.0>=${webkit2gtk_minimum_version})
# ******************************
-# Enchant - support both, but better to use the same as the dependencies (gtkspell3, webkitgtk+,...)
+# Enchant - support both, but better to use the same as the dependencies (gspell, webkitgtk+,...)
# ******************************
add_printable_option(WITH_ENCHANT_VERSION "Set Enchant version to use, values are: 'auto' (default), 1 or 2"
"auto")
@@ -633,15 +633,15 @@ unset(CMAKE_REQUIRED_INCLUDES)
unset(CMAKE_REQUIRED_LIBRARIES)
# ******************************
-# gtkspell
+# gspell
# ******************************
-add_printable_option(ENABLE_GTKSPELL "Enable gtkspell usage" ON)
+add_printable_option(ENABLE_GSPELL "Enable gspell usage" ON)
-if(ENABLE_GTKSPELL)
- pkg_check_modules_for_option(ENABLE_GTKSPELL "gtkspell usage" GTKSPELL gtkspell3-3.0)
- set(HAVE_GTKSPELL ON)
-endif(ENABLE_GTKSPELL)
+if(ENABLE_GSPELL)
+ pkg_check_modules_for_option(ENABLE_GSPELL "gspell usage" GSPELL gspell-1)
+ set(HAVE_GSPELL ON)
+endif(ENABLE_GSPELL)
# ******************************
# gnu_get_libc_version()
diff --git a/config.h.in b/config.h.in
index 0b94db4825..4a134f6b66 100644
--- a/config.h.in
+++ b/config.h.in
@@ -111,8 +111,8 @@
/* libical provides ICAL_COLOR_PROPERTY */
#cmakedefine HAVE_ICAL_COLOR_PROPERTY 1
-/* When defined spell checking is enabled */
-#cmakedefine HAVE_GTKSPELL 1
+/* When defined GSpell usage is enabled */
+#cmakedefine HAVE_GSPELL 1
/* Source code highlighting utility */
#cmakedefine HIGHLIGHT_COMMAND "@HIGHLIGHT_COMMAND@"
diff --git a/src/e-util/CMakeLists.txt b/src/e-util/CMakeLists.txt
index d58ee567c6..ceed0a45e2 100644
--- a/src/e-util/CMakeLists.txt
+++ b/src/e-util/CMakeLists.txt
@@ -622,7 +622,7 @@ target_compile_options(evolution-util PUBLIC
${EVOLUTION_DATA_SERVER_CFLAGS}
${GEO_CFLAGS}
${GNOME_PLATFORM_CFLAGS}
- ${GTKSPELL_CFLAGS}
+ ${GSPELL_CFLAGS}
)
target_include_directories(evolution-util PUBLIC
@@ -636,7 +636,7 @@ target_include_directories(evolution-util PUBLIC
${EVOLUTION_DATA_SERVER_INCLUDE_DIRS}
${GEO_INCLUDE_DIRS}
${GNOME_PLATFORM_INCLUDE_DIRS}
- ${GTKSPELL_INCLUDE_DIRS}
+ ${GSPELL_INCLUDE_DIRS}
)
target_link_libraries(evolution-util
@@ -646,7 +646,7 @@ target_link_libraries(evolution-util
${EVOLUTION_DATA_SERVER_LDFLAGS}
${GEO_LDFLAGS}
${GNOME_PLATFORM_LDFLAGS}
- ${GTKSPELL_LDFLAGS}
+ ${GSPELL_LDFLAGS}
${ICONV_LIBS}
${MATH_LDFLAGS}
)
@@ -755,7 +755,7 @@ macro(add_private_program _name _sources)
${EVOLUTION_DATA_SERVER_CFLAGS}
${GEO_CFLAGS}
${GNOME_PLATFORM_CFLAGS}
- ${GTKSPELL_CFLAGS}
+ ${GSPELL_CFLAGS}
)
target_include_directories(${_name} PUBLIC
@@ -768,7 +768,7 @@ macro(add_private_program _name _sources)
${EVOLUTION_DATA_SERVER_INCLUDE_DIRS}
${GEO_INCLUDE_DIRS}
${GNOME_PLATFORM_INCLUDE_DIRS}
- ${GTKSPELL_INCLUDE_DIRS}
+ ${GSPELL_INCLUDE_DIRS}
)
target_link_libraries(${_name}
@@ -778,7 +778,7 @@ macro(add_private_program _name _sources)
${EVOLUTION_DATA_SERVER_LDFLAGS}
${GEO_LDFLAGS}
${GNOME_PLATFORM_LDFLAGS}
- ${GTKSPELL_LDFLAGS}
+ ${GSPELL_LDFLAGS}
${ICONV_LIBS}
${MATH_LDFLAGS}
)
diff --git a/src/e-util/e-spell-text-view.c b/src/e-util/e-spell-text-view.c
index 81013419fc..d63a594ef0 100644
--- a/src/e-util/e-spell-text-view.c
+++ b/src/e-util/e-spell-text-view.c
@@ -21,8 +21,8 @@
#include <gtk/gtk.h>
-#ifdef HAVE_GTKSPELL
-#include <gtkspell/gtkspell.h>
+#ifdef HAVE_GSPELL
+#include <gspell/gspell.h>
#endif
#include "e-misc-utils.h"
@@ -41,11 +41,11 @@
gboolean
e_spell_text_view_is_supported (void)
{
-#ifdef HAVE_GTKSPELL
+#ifdef HAVE_GSPELL
return TRUE;
-#else /* HAVE_GTKSPELL */
+#else /* HAVE_GSPELL */
return FALSE;
-#endif /* HAVE_GTKSPELL */
+#endif /* HAVE_GSPELL */
}
/**
@@ -55,62 +55,51 @@ e_spell_text_view_is_supported (void)
* Attaches a spell checker into the @text_view, if spell-checking is
* enabled in Evolution.
*
- * Returns: Whether successfully attached the spell checker
- *
* Since: 3.12
**/
-gboolean
+void
e_spell_text_view_attach (GtkTextView *text_view)
{
-#ifdef HAVE_GTKSPELL
- GtkSpellChecker *spell;
+#ifdef HAVE_GSPELL
+ GspellTextView *spell_view;
+ GspellTextBuffer *spell_buffer;
+ GspellChecker *checker;
+ const GspellLanguage *language = NULL;
+ GtkTextBuffer *text_buffer;
GSettings *settings;
gchar **strv;
- gboolean success;
+
+ g_return_if_fail (GTK_IS_TEXT_VIEW (text_view));
settings = e_util_ref_settings ("org.gnome.evolution.mail");
/* do nothing, if spell-checking is disabled */
if (!g_settings_get_boolean (settings, "composer-inline-spelling")) {
g_object_unref (settings);
- return FALSE;
+ return;
}
strv = g_settings_get_strv (settings, "composer-spell-languages");
g_object_unref (settings);
- spell = gtk_spell_checker_new ();
- g_object_set (G_OBJECT (spell), "decode-language-codes", TRUE, NULL);
- if (strv)
- gtk_spell_checker_set_language (spell, strv[0], NULL);
- success = gtk_spell_checker_attach (spell, text_view);
+ if (strv) {
+ gint ii;
- g_strfreev (strv);
+ for (ii = 0; strv[ii] && !language; ii++) {
+ language = gspell_language_lookup (strv[ii]);
+ }
+ }
- return success;
-#else /* HAVE_GTKSPELL */
- return FALSE;
-#endif /* HAVE_GTKSPELL */
-}
+ g_strfreev (strv);
-/**
- * e_spell_text_view_recheck_all:
- * @text_view: a #GtkTextView with attached spell checker
- *
- * Checks whole content of the @text_view for spell-errors,
- * if it has previously attached spell-checker with
- * e_spell_text_view_attach().
- *
- * Since: 3.12
- **/
-void
-e_spell_text_view_recheck_all (GtkTextView *text_view)
-{
-#ifdef HAVE_GTKSPELL
- GtkSpellChecker *spell;
+ checker = gspell_checker_new (language);
+ text_buffer = gtk_text_view_get_buffer (text_view);
+ spell_buffer = gspell_text_buffer_get_from_gtk_text_buffer (text_buffer);
+ gspell_text_buffer_set_spell_checker (spell_buffer, checker);
+ g_object_unref (checker);
- spell = gtk_spell_checker_get_from_text_view (text_view);
- if (spell)
- gtk_spell_checker_recheck_all (spell);
-#endif /* HAVE_GTKSPELL */
+ spell_view = gspell_text_view_get_from_gtk_text_view (text_view);
+ gspell_text_view_set_inline_spell_checking (spell_view, TRUE);
+ gspell_text_view_set_enable_language_menu (spell_view, TRUE);
+#endif /* HAVE_GSPELL */
}
diff --git a/src/e-util/e-spell-text-view.h b/src/e-util/e-spell-text-view.h
index b7bbef4ab1..0d8788eca0 100644
--- a/src/e-util/e-spell-text-view.h
+++ b/src/e-util/e-spell-text-view.h
@@ -27,8 +27,7 @@
G_BEGIN_DECLS
gboolean e_spell_text_view_is_supported (void);
-gboolean e_spell_text_view_attach (GtkTextView *text_view);
-void e_spell_text_view_recheck_all (GtkTextView *text_view);
+void e_spell_text_view_attach (GtkTextView *text_view);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]