Commit 358e51e3 authored by Milan Crha's avatar Milan Crha

I#210 - Port from gtkspell to gspell

Closes #210
parent d3addc69
......@@ -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()
......
......@@ -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@"
......
......@@ -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}
)
......
......@@ -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 */
}
......@@ -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
......
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