[evolution/wip/webkit2] Compile spell-related code again, without composer body
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip/webkit2] Compile spell-related code again, without composer body
- Date: Fri, 4 Mar 2016 10:57:42 +0000 (UTC)
commit 7ff177a4fc13f4952d40f601614a98cba86f22c1
Author: Milan Crha <mcrha redhat com>
Date: Fri Mar 4 11:57:14 2016 +0100
Compile spell-related code again, without composer body
calendar/gui/e-comp-editor-property-parts.c | 2 +-
composer/e-composer-spell-header.c | 3 +-
e-util/Makefile.am | 6 +
e-util/e-spell-checker.c | 294 +++------------------------
e-util/e-util.h | 2 +
modules/mail/em-composer-prefs.c | 8 +-
modules/settings/e-settings-spell-checker.c | 16 +-
modules/settings/e-settings-spell-entry.c | 3 +-
shell/main.c | 3 +-
9 files changed, 54 insertions(+), 283 deletions(-)
---
diff --git a/calendar/gui/e-comp-editor-property-parts.c b/calendar/gui/e-comp-editor-property-parts.c
index 91d805a..53ebeb6 100644
--- a/calendar/gui/e-comp-editor-property-parts.c
+++ b/calendar/gui/e-comp-editor-property-parts.c
@@ -103,7 +103,7 @@ e_comp_editor_property_part_summary_class_init (ECompEditorPropertyPartSummaryCl
ECompEditorPropertyPartClass *part_class;
part_string_class = E_COMP_EDITOR_PROPERTY_PART_STRING_CLASS (klass);
- /* FIXME WK2 part_string_class->entry_type = E_TYPE_SPELL_ENTRY; */
+ part_string_class->entry_type = E_TYPE_SPELL_ENTRY;
part_string_class->ical_prop_kind = ICAL_SUMMARY_PROPERTY;
part_string_class->ical_new_func = icalproperty_new_summary;
part_string_class->ical_set_func = icalproperty_set_summary;
diff --git a/composer/e-composer-spell-header.c b/composer/e-composer-spell-header.c
index c02cfd1..b2d2dfa 100644
--- a/composer/e-composer-spell-header.c
+++ b/composer/e-composer-spell-header.c
@@ -31,8 +31,7 @@ e_composer_spell_header_class_init (EComposerSpellHeaderClass *class)
EComposerTextHeaderClass *composer_text_header_class;
composer_text_header_class = E_COMPOSER_TEXT_HEADER_CLASS (class);
-/* FIXME WK2
- composer_text_header_class->entry_type = E_TYPE_SPELL_ENTRY;*/
+ composer_text_header_class->entry_type = E_TYPE_SPELL_ENTRY;
}
static void
diff --git a/e-util/Makefile.am b/e-util/Makefile.am
index 449308b..9281a06 100644
--- a/e-util/Makefile.am
+++ b/e-util/Makefile.am
@@ -282,6 +282,9 @@ evolution_util_include_HEADERS = \
e-source-selector-dialog.h \
e-source-selector.h \
e-source-util.h \
+ e-spell-checker.h \
+ e-spell-dictionary.h \
+ e-spell-entry.h \
e-spell-text-view.h \
e-spinner.h \
e-stock-request.h \
@@ -554,6 +557,9 @@ libevolution_util_la_SOURCES = \
e-source-selector-dialog.c \
e-source-selector.c \
e-source-util.c \
+ e-spell-checker.c \
+ e-spell-dictionary.c \
+ e-spell-entry.c \
e-spell-text-view.c \
e-spinner.c \
e-stock-request.c \
diff --git a/e-util/e-spell-checker.c b/e-util/e-spell-checker.c
index c8b3a9e..5b02795 100644
--- a/e-util/e-spell-checker.c
+++ b/e-util/e-spell-checker.c
@@ -24,7 +24,6 @@
#include "e-spell-dictionary.h"
#include <libebackend/libebackend.h>
-#include <webkit/webkitspellchecker.h>
#include <pango/pango.h>
#include <gtk/gtk.h>
#include <string.h>
@@ -45,27 +44,19 @@ enum {
PROP_ACTIVE_LANGUAGES
};
-/* Forward Declarations */
-static void e_spell_checker_init_webkit_checker
- (WebKitSpellCheckerInterface *interface);
-
G_DEFINE_TYPE_EXTENDED (
ESpellChecker,
e_spell_checker,
G_TYPE_OBJECT,
0,
G_IMPLEMENT_INTERFACE (
- E_TYPE_EXTENSIBLE, NULL)
- G_IMPLEMENT_INTERFACE (
- WEBKIT_TYPE_SPELL_CHECKER,
- e_spell_checker_init_webkit_checker))
+ E_TYPE_EXTENSIBLE, NULL))
/**
* ESpellChecker:
*
* #ESpellChecker represents a spellchecker in Evolution. It can be used as a
- * provider for dictionaries. It also implements #WebKitSpellCheckerInterface,
- * so it can be set as a default spell-checker to WebKit editors
+ * provider for dictionaries.
*/
@@ -92,237 +83,6 @@ spell_checker_enchant_dicts_foreach_cb (gpointer key,
}
static void
-wksc_check_spelling (WebKitSpellChecker *webkit_checker,
- const gchar *word,
- gint *misspelling_location,
- gint *misspelling_length)
-{
- ESpellChecker *checker = E_SPELL_CHECKER (webkit_checker);
- GHashTable *active_dictionaries;
- PangoLanguage *language;
- PangoLogAttr *attrs;
- gint length, ii;
-
- active_dictionaries = checker->priv->active_dictionaries;
- if (g_hash_table_size (active_dictionaries) == 0)
- return;
-
- length = g_utf8_strlen (word, -1);
-
- language = pango_language_get_default ();
- attrs = g_new (PangoLogAttr, length + 1);
-
- pango_get_log_attrs (word, -1, -1, language, attrs, length + 1);
-
- for (ii = 0; ii < length + 1; ii++) {
- /* We go through each character until we find an is_word_start,
- * then we get into an inner loop to find the is_word_end
- * corresponding */
- if (attrs[ii].is_word_start) {
- gboolean word_recognized;
- gint start = ii;
- gint end = ii;
- gint word_length;
- gchar *cstart;
- gint bytes;
- gchar *new_word;
-
- while (attrs[end].is_word_end < 1)
- end++;
-
- word_length = end - start;
- /* Set the iterator to be at the current word
- * end, so we don't check characters twice. */
- ii = end;
-
- cstart = g_utf8_offset_to_pointer (word, start);
- bytes = g_utf8_offset_to_pointer (word, end) - cstart;
- new_word = g_new0 (gchar, bytes + 1);
-
- g_utf8_strncpy (new_word, cstart, word_length);
-
- word_recognized = e_spell_checker_check_word (
- checker, new_word, strlen (new_word));
-
- if (word_recognized) {
- if (misspelling_location != NULL)
- *misspelling_location = -1;
- if (misspelling_length != NULL)
- *misspelling_length = 0;
- } else {
- if (misspelling_location != NULL)
- *misspelling_location = start;
- if (misspelling_length != NULL)
- *misspelling_length = word_length;
- }
-
- g_free (new_word);
- }
- }
-
- g_free (attrs);
-}
-
-static gchar **
-wksc_get_guesses (WebKitSpellChecker *webkit_checker,
- const gchar *word,
- const gchar *context)
-{
- ESpellChecker *checker = E_SPELL_CHECKER (webkit_checker);
- GHashTable *active_dictionaries;
- GList *list, *link;
- gchar ** guesses;
- gint ii = 0;
-
- guesses = g_new0 (gchar *, MAX_SUGGESTIONS + 1);
-
- active_dictionaries = checker->priv->active_dictionaries;
- list = g_hash_table_get_keys (active_dictionaries);
-
- for (link = list; link != NULL; link = g_list_next (link)) {
- ESpellDictionary *dictionary;
- GList *suggestions;
-
- dictionary = E_SPELL_DICTIONARY (link->data);
- suggestions = e_spell_dictionary_get_suggestions (
- dictionary, word, -1);
-
- while (suggestions != NULL && ii < MAX_SUGGESTIONS) {
- guesses[ii++] = suggestions->data;
- suggestions->data = NULL;
-
- suggestions = g_list_delete_link (
- suggestions, suggestions);
- }
-
- g_list_free_full (suggestions, (GDestroyNotify) g_free);
-
- if (ii >= MAX_SUGGESTIONS)
- break;
- }
-
- g_list_free (list);
-
- return guesses;
-}
-
-static gchar *
-wksc_get_autocorrect_suggestions (WebKitSpellChecker *webkit_checker,
- const gchar *word)
-{
- /* Not supported/needed */
- return NULL;
-}
-
-static void
-spell_checker_learn_word (WebKitSpellChecker *webkit_checker,
- const gchar *word)
-{
- /* Carefully, this will add the word to all active dictionaries! */
-
- ESpellChecker *checker;
- GHashTable *active_dictionaries;
- GList *list, *link;
-
- checker = E_SPELL_CHECKER (webkit_checker);
- active_dictionaries = checker->priv->active_dictionaries;
- list = g_hash_table_get_keys (active_dictionaries);
-
- for (link = list; link != NULL; link = g_list_next (link)) {
- ESpellDictionary *dictionary;
-
- dictionary = E_SPELL_DICTIONARY (link->data);
- e_spell_dictionary_learn_word (dictionary, word, -1);
- }
-
- g_list_free (list);
-}
-
-static void
-spell_checker_ignore_word (WebKitSpellChecker *webkit_checker,
- const gchar *word)
-{
- /* Carefully, this will add the word to all active dictionaries */
-
- ESpellChecker *checker;
- GHashTable *active_dictionaries;
- GList *list, *link;
-
- checker = E_SPELL_CHECKER (webkit_checker);
- active_dictionaries = checker->priv->active_dictionaries;
- list = g_hash_table_get_keys (active_dictionaries);
-
- for (link = list; link != NULL; link = g_list_next (link)) {
- ESpellDictionary *dictionary;
-
- dictionary = E_SPELL_DICTIONARY (link->data);
- e_spell_dictionary_ignore_word (dictionary, word, -1);
- }
-
- g_list_free (list);
-}
-
-static void
-wksc_update_languages (WebKitSpellChecker *webkit_checker,
- const gchar *languages)
-{
- ESpellChecker *checker;
- GHashTable *active_dictionaries;
- GQueue queue = G_QUEUE_INIT;
-
- checker = E_SPELL_CHECKER (webkit_checker);
- active_dictionaries = checker->priv->active_dictionaries;
-
- if (languages != NULL) {
- gchar **langs;
- gint ii;
-
- langs = g_strsplit (languages, ",", -1);
- for (ii = 0; langs[ii] != NULL; ii++) {
- ESpellDictionary *dictionary;
-
- dictionary = e_spell_checker_ref_dictionary (
- checker, langs[ii]);
- if (dictionary != NULL)
- g_queue_push_tail (&queue, dictionary);
- }
- g_strfreev (langs);
- } else {
- ESpellDictionary *dictionary;
- PangoLanguage *pango_language;
- const gchar *language;
-
- pango_language = gtk_get_default_language ();
- language = pango_language_to_string (pango_language);
- dictionary = e_spell_checker_ref_dictionary (checker, language);
-
- if (dictionary == NULL) {
- GList *list;
-
- list = e_spell_checker_list_available_dicts (checker);
- if (list != NULL) {
- dictionary = g_object_ref (list->data);
- g_list_free (list);
- }
- }
-
- if (dictionary != NULL)
- g_queue_push_tail (&queue, dictionary);
- }
-
- g_hash_table_remove_all (active_dictionaries);
-
- while (!g_queue_is_empty (&queue)) {
- ESpellDictionary *dictionary;
-
- dictionary = g_queue_pop_head (&queue);
- g_hash_table_add (active_dictionaries, dictionary);
- }
-
- g_object_notify (G_OBJECT (checker), "active-languages");
-}
-
-static void
spell_checker_get_property (GObject *object,
guint property_id,
GValue *value,
@@ -374,7 +134,7 @@ spell_checker_constructed (GObject *object)
/* Chain up to parent's constructed() method. */
G_OBJECT_CLASS (e_spell_checker_parent_class)->constructed (object);
- e_extensible_load_extension (E_EXTENSIBLE (object));
+ e_extensible_load_extensions (E_EXTENSIBLE (object));
}
static void
@@ -403,18 +163,6 @@ e_spell_checker_class_init (ESpellCheckerClass *class)
}
static void
-e_spell_checker_init_webkit_checker (WebKitSpellCheckerInterface *interface)
-{
- interface->check_spelling_of_string = wksc_check_spelling;
- interface->get_autocorrect_suggestions_for_misspelled_word =
- wksc_get_autocorrect_suggestions;
- interface->get_guesses_for_word = wksc_get_guesses;
- interface->ignore_word = spell_checker_ignore_word;
- interface->learn_word = spell_checker_learn_word;
- interface->update_spell_checking_languages = wksc_update_languages;
-}
-
-static void
e_spell_checker_init (ESpellChecker *checker)
{
GHashTable *active_dictionaries;
@@ -816,12 +564,24 @@ void
e_spell_checker_ignore_word (ESpellChecker *checker,
const gchar *word)
{
- WebKitSpellCheckerInterface *interface;
+ /* Carefully, this will add the word to all active dictionaries */
+
+ GHashTable *active_dictionaries;
+ GList *list, *link;
g_return_if_fail (E_IS_SPELL_CHECKER (checker));
- interface = WEBKIT_SPELL_CHECKER_GET_IFACE (checker);
- interface->ignore_word (WEBKIT_SPELL_CHECKER (checker), word);
+ active_dictionaries = checker->priv->active_dictionaries;
+ list = g_hash_table_get_keys (active_dictionaries);
+
+ for (link = list; link != NULL; link = g_list_next (link)) {
+ ESpellDictionary *dictionary;
+
+ dictionary = E_SPELL_DICTIONARY (link->data);
+ e_spell_dictionary_ignore_word (dictionary, word, -1);
+ }
+
+ g_list_free (list);
}
/**
@@ -836,10 +596,22 @@ void
e_spell_checker_learn_word (ESpellChecker *checker,
const gchar *word)
{
- WebKitSpellCheckerInterface *interface;
+ /* Carefully, this will add the word to all active dictionaries! */
+
+ GHashTable *active_dictionaries;
+ GList *list, *link;
g_return_if_fail (E_IS_SPELL_CHECKER (checker));
- interface = WEBKIT_SPELL_CHECKER_GET_IFACE (checker);
- interface->learn_word (WEBKIT_SPELL_CHECKER (checker), word);
+ active_dictionaries = checker->priv->active_dictionaries;
+ list = g_hash_table_get_keys (active_dictionaries);
+
+ for (link = list; link != NULL; link = g_list_next (link)) {
+ ESpellDictionary *dictionary;
+
+ dictionary = E_SPELL_DICTIONARY (link->data);
+ e_spell_dictionary_learn_word (dictionary, word, -1);
+ }
+
+ g_list_free (list);
}
diff --git a/e-util/e-util.h b/e-util/e-util.h
index f30cd0b..82656df 100644
--- a/e-util/e-util.h
+++ b/e-util/e-util.h
@@ -193,6 +193,8 @@
#include <e-util/e-source-selector-dialog.h>
#include <e-util/e-source-selector.h>
#include <e-util/e-source-util.h>
+#include <e-util/e-spell-checker.h>
+#include <e-util/e-spell-dictionary.h>
#include <e-util/e-spell-entry.h>
#include <e-util/e-spell-text-view.h>
#include <e-util/e-spinner.h>
diff --git a/modules/mail/em-composer-prefs.c b/modules/mail/em-composer-prefs.c
index 9657dd7..ecdcf40 100644
--- a/modules/mail/em-composer-prefs.c
+++ b/modules/mail/em-composer-prefs.c
@@ -145,7 +145,6 @@ spell_setup (EMComposerPrefs *prefs)
GtkListStore *store;
store = GTK_LIST_STORE (prefs->language_model);
-#if 0 /* FIXME WK2 */
list = e_spell_checker_list_available_dicts (prefs->spell_checker);
/* Populate the GtkListStore. */
@@ -169,7 +168,7 @@ spell_setup (EMComposerPrefs *prefs)
store, &tree_iter,
0, active, 1, name, 2, dictionary, -1);
}
-#endif
+
g_list_free (list);
}
@@ -1077,9 +1076,8 @@ em_composer_prefs_construct (EMComposerPrefs *prefs,
prefs->builder = gtk_builder_new ();
e_load_ui_builder_definition (prefs->builder, "mail-config.ui");
-/* FIXME WK2
- prefs->spell_checker = e_spell_checker_new ();*/
- prefs->spell_checker = NULL;
+
+ prefs->spell_checker = e_spell_checker_new ();
/** @HookPoint-EMConfig: Mail Composer Preferences
* @Id: org.gnome.evolution.mail.composerPrefs
diff --git a/modules/settings/e-settings-spell-checker.c b/modules/settings/e-settings-spell-checker.c
index 4e81609..812e3b0 100644
--- a/modules/settings/e-settings-spell-checker.c
+++ b/modules/settings/e-settings-spell-checker.c
@@ -39,9 +39,8 @@ settings_spell_checker_get_extensible (ESettingsSpellChecker *extension)
EExtensible *extensible;
extensible = e_extension_get_extensible (E_EXTENSION (extension));
-/* FIXME WK2
- return E_SPELL_CHECKER (extensible);*/
- return NULL;
+
+ return E_SPELL_CHECKER (extensible);
}
static void
@@ -63,20 +62,18 @@ settings_spell_checker_constructed (GObject *object)
E_SETTINGS_SPELL_CHECKER (object));
/* Make sure there are no active languages at this point. */
-/* FIXME WK2
- g_warn_if_fail (
- e_spell_checker_count_active_languages (spell_checker) == 0);*/
+ g_warn_if_fail (e_spell_checker_count_active_languages (spell_checker) == 0);
settings = e_util_ref_settings ("org.gnome.evolution.mail");
strv = g_settings_get_strv (settings, "composer-spell-languages");
g_object_unref (settings);
g_return_if_fail (strv != NULL);
-/* FIXME WK2
+
for (ii = 0; strv[ii] != NULL; ii++)
e_spell_checker_set_language_active (
spell_checker, strv[ii], TRUE);
-*/
+
g_strfreev (strv);
}
@@ -93,8 +90,7 @@ e_settings_spell_checker_class_init (ESettingsSpellCheckerClass *class)
object_class->constructed = settings_spell_checker_constructed;
extension_class = E_EXTENSION_CLASS (class);
-/* FIXME WK2
- extension_class->extensible_type = E_TYPE_SPELL_CHECKER; */
+ extension_class->extensible_type = E_TYPE_SPELL_CHECKER;
}
static void
diff --git a/modules/settings/e-settings-spell-entry.c b/modules/settings/e-settings-spell-entry.c
index b84348f..8fd3a63 100644
--- a/modules/settings/e-settings-spell-entry.c
+++ b/modules/settings/e-settings-spell-entry.c
@@ -67,8 +67,7 @@ e_settings_spell_entry_class_init (ESettingsSpellEntryClass *class)
object_class->constructed = settings_spell_entry_constructed;
extension_class = E_EXTENSION_CLASS (class);
-/* FIXME WK2
- extension_class->extensible_type = E_TYPE_SPELL_ENTRY;*/
+ extension_class->extensible_type = E_TYPE_SPELL_ENTRY;
}
static void
diff --git a/shell/main.c b/shell/main.c
index 7999ec1..8b898b5 100644
--- a/shell/main.c
+++ b/shell/main.c
@@ -682,8 +682,7 @@ exit:
gtk_accel_map_save (e_get_accels_filename ());
e_util_cleanup_settings ();
-/* FIXME WK2
- e_spell_checker_free_global_memory ();*/
+ e_spell_checker_free_global_memory ();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]