diff options
author | Milan Crha <mcrha@redhat.com> | 2013-11-29 19:59:09 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2013-11-29 19:59:09 +0800 |
commit | e607ae83d43972943b138915fb86b244498e8845 (patch) | |
tree | c080cef975bfa4c6724a62636f426f1099b4cdae | |
parent | c12a958aba0bac2b665cc8a5a3cae2f10d16dd71 (diff) | |
download | gsoc2013-evolution-e607ae83d43972943b138915fb86b244498e8845.tar gsoc2013-evolution-e607ae83d43972943b138915fb86b244498e8845.tar.gz gsoc2013-evolution-e607ae83d43972943b138915fb86b244498e8845.tar.bz2 gsoc2013-evolution-e607ae83d43972943b138915fb86b244498e8845.tar.lz gsoc2013-evolution-e607ae83d43972943b138915fb86b244498e8845.tar.xz gsoc2013-evolution-e607ae83d43972943b138915fb86b244498e8845.tar.zst gsoc2013-evolution-e607ae83d43972943b138915fb86b244498e8845.zip |
Bug #329616 - Spell checking for Event/Task/Memo editors
This is based on the work of Jan-Michael Brummer from bug #705338,
just a little extended to be reusable across whole evolution.
-rw-r--r-- | addressbook/gui/contact-editor/e-contact-editor.c | 5 | ||||
-rw-r--r-- | calendar/gui/dialogs/alarm-dialog.c | 3 | ||||
-rw-r--r-- | calendar/gui/dialogs/event-page.c | 4 | ||||
-rw-r--r-- | calendar/gui/dialogs/memo-page.c | 2 | ||||
-rw-r--r-- | calendar/gui/dialogs/task-page.c | 4 | ||||
-rw-r--r-- | configure.ac | 24 | ||||
-rw-r--r-- | e-util/Makefile.am | 4 | ||||
-rw-r--r-- | e-util/e-spell-text-view.c | 118 | ||||
-rw-r--r-- | e-util/e-spell-text-view.h | 36 | ||||
-rw-r--r-- | e-util/e-util.h | 1 |
10 files changed, 201 insertions, 0 deletions
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index 27c0f5b5c2..a0c3c8c593 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -37,6 +37,7 @@ #include <gdk-pixbuf/gdk-pixbuf.h> #include "shell/e-shell.h" +#include "e-util/e-util.h" #include "addressbook/printing/e-contact-print.h" #include "addressbook/gui/widgets/eab-gui-util.h" @@ -3111,6 +3112,10 @@ init_all (EContactEditor *editor) width + requisition.width, height + requisition.height); } + + widget = e_builder_get_widget (editor->builder, "text-comments"); + if (widget) + e_spell_text_view_attach (GTK_TEXT_VIEW (widget)); } static void diff --git a/calendar/gui/dialogs/alarm-dialog.c b/calendar/gui/dialogs/alarm-dialog.c index 0f96d2091e..77019b2d5a 100644 --- a/calendar/gui/dialogs/alarm-dialog.c +++ b/calendar/gui/dialogs/alarm-dialog.c @@ -1304,6 +1304,9 @@ alarm_dialog_run (GtkWidget *parent, return FALSE; } + e_spell_text_view_attach (GTK_TEXT_VIEW (dialog.dalarm_description)); + e_spell_text_view_attach (GTK_TEXT_VIEW (dialog.malarm_description)); + if (!setup_select_names (&dialog)) { g_object_unref (dialog.builder); return FALSE; diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c index f9184133bb..24cbf0906e 100644 --- a/calendar/gui/dialogs/event-page.c +++ b/calendar/gui/dialogs/event-page.c @@ -35,6 +35,8 @@ #include <glib/gi18n.h> #include <gdk/gdkkeysyms.h> +#include "e-util/e-util.h" + #include "../e-alarm-list.h" #include "../e-meeting-attendee.h" #include "../e-meeting-list-view.h" @@ -3612,6 +3614,8 @@ event_page_construct (EventPage *epage, return NULL; } + e_spell_text_view_attach (GTK_TEXT_VIEW (priv->description)); + /* Create entry completion and attach it to the entry */ priv->location_completion = gtk_entry_completion_new (); gtk_entry_set_completion ( diff --git a/calendar/gui/dialogs/memo-page.c b/calendar/gui/dialogs/memo-page.c index 0e06d19316..e6954a11bd 100644 --- a/calendar/gui/dialogs/memo-page.c +++ b/calendar/gui/dialogs/memo-page.c @@ -1241,6 +1241,8 @@ memo_page_construct (MemoPage *mpage) return NULL; } + e_spell_text_view_attach (GTK_TEXT_VIEW (priv->memo_content)); + if (flags & COMP_EDITOR_IS_SHARED) { GtkComboBox *combo_box; GtkListStore *list_store; diff --git a/calendar/gui/dialogs/task-page.c b/calendar/gui/dialogs/task-page.c index 3294d08d61..822cf51b7c 100644 --- a/calendar/gui/dialogs/task-page.c +++ b/calendar/gui/dialogs/task-page.c @@ -34,6 +34,8 @@ #include <glib/gi18n.h> #include <gdk/gdkkeysyms.h> +#include "e-util/e-util.h" + #include "../e-meeting-attendee.h" #include "../e-meeting-list-view.h" #include "../e-meeting-store.h" @@ -2682,6 +2684,8 @@ task_page_construct (TaskPage *tpage, return NULL; } + e_spell_text_view_attach (GTK_TEXT_VIEW (priv->description)); + combo_box = GTK_COMBO_BOX (priv->organizer); model = gtk_combo_box_get_model (combo_box); list_store = GTK_LIST_STORE (model); diff --git a/configure.ac b/configure.ac index c0f5c8f7fc..ae7fb24b2e 100644 --- a/configure.ac +++ b/configure.ac @@ -1087,6 +1087,30 @@ CFLAGS=$save_cflags LIBS=$save_libs AC_MSG_RESULT([$ac_cv_have_iuth]) +dnl **************************** +dnl Check for gtkspell +dnl **************************** +AC_ARG_ENABLE([gtkspell], + [AS_HELP_STRING([--enable-gtkspell], + [Enable gtkspell @<:@default=yes@:>@])], + [enable_gtkspell="$enableval"], [enable_gtkspell="yes"]) + +if test "x$enable_gtkspell" = "xyes"; then + PKG_CHECK_MODULES( + [GTKSPELL], + [gtkspell3-3.0],, + [AC_MSG_ERROR([ + + gtkspell3-3.0 not found + + If you want to disable the gtkspell feature, + please append --disable-gtkspell to configure. + + ])]) + + AC_DEFINE(WITH_GTKSPELL, 1, [When defined spell checking is enabled]) +fi + dnl ******************* dnl Special directories dnl ******************* diff --git a/e-util/Makefile.am b/e-util/Makefile.am index 54ef384000..cf13b394d6 100644 --- a/e-util/Makefile.am +++ b/e-util/Makefile.am @@ -100,6 +100,7 @@ libevolution_util_la_CPPFLAGS = \ $(GNOME_PLATFORM_CFLAGS) \ $(GEO_CFLAGS) \ $(GTKHTML_CFLAGS) \ + $(GTKSPELL_CFLAGS) \ $(NULL) evolution_util_include_HEADERS = \ @@ -251,6 +252,7 @@ evolution_util_include_HEADERS = \ e-source-selector.h \ e-source-util.h \ e-spell-entry.h \ + e-spell-text-view.h \ e-stock-request.h \ e-table-click-to-add.h \ e-table-col-dnd.h \ @@ -494,6 +496,7 @@ libevolution_util_la_SOURCES = \ e-source-selector.c \ e-source-util.c \ e-spell-entry.c \ + e-spell-text-view.c \ e-stock-request.c \ e-table-click-to-add.c \ e-table-col.c \ @@ -585,6 +588,7 @@ libevolution_util_la_LIBADD = \ $(GNOME_PLATFORM_LIBS) \ $(GEO_LIBS) \ $(GTKHTML_LIBS) \ + $(GTKSPELL_LIBS) \ $(INTLLIBS) \ $(MATH_LIB) \ $(NULL) diff --git a/e-util/e-spell-text-view.c b/e-util/e-spell-text-view.c new file mode 100644 index 0000000000..283b674d5a --- /dev/null +++ b/e-util/e-spell-text-view.c @@ -0,0 +1,118 @@ +/* + * e-spell-text-view.c + * + * 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 License, or (at your option) version 3. + * + * This program 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 the program; if not, see <http://www.gnu.org/licenses/> + * + */ + +/* Just a proxy for GtkSpell Text View spell checker */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <gtk/gtk.h> + +#ifdef WITH_GTKSPELL +#include <gtkspell/gtkspell.h> +#endif + +#include "e-spell-text-view.h" + +/** + * e_spell_text_view_is_supported: + * + * Returns whether evolution was compiled with GtkSpell3. If it returns + * %FALSE, all the other e_spell_text_view_... functions do nothing. + * + * Returns: Whether evolution was compiled with GtkSpell3 + * + * Since: 3.12 + **/ +gboolean +e_spell_text_view_is_supported (void) +{ +#ifdef WITH_GTKSPELL + return TRUE; +#else /* WITH_GTKSPELL */ + return FALSE; +#endif /* WITH_GTKSPELL */ +} + +/** + * e_spell_text_view_attach: + * @text_view: a #GtkTextView + * + * 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 +e_spell_text_view_attach (GtkTextView *text_view) +{ +#ifdef WITH_GTKSPELL + GtkSpellChecker *spell; + GSettings *settings; + gchar **strv; + gboolean success; + + settings = g_settings_new ("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; + } + + 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); + + g_strfreev (strv); + + return success; +#else /* WITH_GTKSPELL */ + return FALSE; +#endif /* WITH_GTKSPELL */ +} + +/** + * 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 WITH_GTKSPELL + GtkSpellChecker *spell; + + spell = gtk_spell_checker_get_from_text_view (text_view); + if (spell) + gtk_spell_checker_recheck_all (spell); +#endif /* WITH_GTKSPELL */ +} diff --git a/e-util/e-spell-text-view.h b/e-util/e-spell-text-view.h new file mode 100644 index 0000000000..08d2628c95 --- /dev/null +++ b/e-util/e-spell-text-view.h @@ -0,0 +1,36 @@ +/* + * e-spell-text-view.h + * + * 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 License, or (at your option) version 3. + * + * This program 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 the program; if not, see <http://www.gnu.org/licenses/> + * + */ + +#if !defined (__E_UTIL_H_INSIDE__) && !defined (LIBEUTIL_COMPILATION) +#error "Only <e-util/e-util.h> should be included directly." +#endif + +#ifndef E_SPELL_TEXT_VIEW_H +#define E_SPELL_TEXT_VIEW_H + +#include <gtk/gtk.h> + +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); + +G_END_DECLS + +#endif /* E_SPELL_TEXT_VIEW_H */ diff --git a/e-util/e-util.h b/e-util/e-util.h index f2022ff879..ab2a64500a 100644 --- a/e-util/e-util.h +++ b/e-util/e-util.h @@ -169,6 +169,7 @@ #include <e-util/e-source-selector.h> #include <e-util/e-source-util.h> #include <e-util/e-spell-entry.h> +#include <e-util/e-spell-text-view.h> #include <e-util/e-stock-request.h> #include <e-util/e-table-click-to-add.h> #include <e-util/e-table-col-dnd.h> |