xed-spell-checker.c: Clean up the code formatting
This commit is contained in:
parent
a13a573228
commit
a5af28a95d
|
@ -120,16 +120,20 @@ xed_spell_checker_finalize (GObject *object)
|
|||
spell_checker = XED_SPELL_CHECKER (object);
|
||||
|
||||
if (spell_checker->dict != NULL)
|
||||
{
|
||||
enchant_broker_free_dict (spell_checker->broker, spell_checker->dict);
|
||||
}
|
||||
|
||||
if (spell_checker->broker != NULL)
|
||||
{
|
||||
enchant_broker_free (spell_checker->broker);
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (xed_spell_checker_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
xed_spell_checker_class_init (XedSpellCheckerClass * klass)
|
||||
xed_spell_checker_class_init (XedSpellCheckerClass *klass)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
|
||||
|
@ -206,8 +210,7 @@ xed_spell_checker_new (void)
|
|||
{
|
||||
XedSpellChecker *spell;
|
||||
|
||||
spell = XED_SPELL_CHECKER (
|
||||
g_object_new (XED_TYPE_SPELL_CHECKER, NULL));
|
||||
spell = XED_SPELL_CHECKER (g_object_new (XED_TYPE_SPELL_CHECKER, NULL));
|
||||
|
||||
g_return_val_if_fail (spell != NULL, NULL);
|
||||
|
||||
|
@ -219,7 +222,9 @@ lazy_init (XedSpellChecker *spell,
|
|||
const XedSpellCheckerLanguage *language)
|
||||
{
|
||||
if (spell->dict != NULL)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
g_return_val_if_fail (spell->broker != NULL, FALSE);
|
||||
|
||||
|
@ -252,7 +257,9 @@ lazy_init (XedSpellChecker *spell,
|
|||
|
||||
/* Second try to get a default language */
|
||||
if (spell->active_lang == NULL)
|
||||
{
|
||||
spell->active_lang = xed_spell_checker_language_from_key ("en_US");
|
||||
}
|
||||
|
||||
/* Last try to get a default language */
|
||||
if (spell->active_lang == NULL)
|
||||
|
@ -260,8 +267,10 @@ lazy_init (XedSpellChecker *spell,
|
|||
const GSList *langs;
|
||||
langs = xed_spell_checker_get_available_languages ();
|
||||
if (langs != NULL)
|
||||
{
|
||||
spell->active_lang = (const XedSpellCheckerLanguage *)langs->data;
|
||||
}
|
||||
}
|
||||
|
||||
if (spell->active_lang != NULL)
|
||||
{
|
||||
|
@ -269,8 +278,7 @@ lazy_init (XedSpellChecker *spell,
|
|||
|
||||
key = xed_spell_checker_language_to_key (spell->active_lang);
|
||||
|
||||
spell->dict = enchant_broker_request_dict (spell->broker,
|
||||
key);
|
||||
spell->dict = enchant_broker_request_dict (spell->broker, key);
|
||||
}
|
||||
|
||||
if (spell->dict == NULL)
|
||||
|
@ -278,7 +286,9 @@ lazy_init (XedSpellChecker *spell,
|
|||
spell->active_lang = NULL;
|
||||
|
||||
if (language != NULL)
|
||||
{
|
||||
g_warning ("Spell checker plugin: cannot select a default language.");
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -303,10 +313,13 @@ xed_spell_checker_set_language (XedSpellChecker *spell,
|
|||
ret = lazy_init (spell, language);
|
||||
|
||||
if (ret)
|
||||
{
|
||||
g_signal_emit (G_OBJECT (spell), signals[SET_LANGUAGE], 0, language);
|
||||
}
|
||||
else
|
||||
g_warning ("Spell checker plugin: cannot use language %s.",
|
||||
xed_spell_checker_language_to_string (language));
|
||||
{
|
||||
g_warning ("Spell checker plugin: cannot use language %s.", xed_spell_checker_language_to_string (language));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -317,7 +330,9 @@ xed_spell_checker_get_language (XedSpellChecker *spell)
|
|||
g_return_val_if_fail (XED_IS_SPELL_CHECKER (spell), NULL);
|
||||
|
||||
if (!lazy_init (spell, spell->active_lang))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return spell->active_lang;
|
||||
}
|
||||
|
@ -334,16 +349,24 @@ xed_spell_checker_check_word (XedSpellChecker *spell,
|
|||
g_return_val_if_fail (word != NULL, FALSE);
|
||||
|
||||
if (!lazy_init (spell, spell->active_lang))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (len < 0)
|
||||
{
|
||||
len = strlen (word);
|
||||
}
|
||||
|
||||
if (strcmp (word, "xed") == 0)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (xed_spell_utils_is_digit (word, len))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
g_return_val_if_fail (spell->dict != NULL, FALSE);
|
||||
enchant_result = enchant_dict_check (spell->dict, word, len);
|
||||
|
@ -389,24 +412,29 @@ xed_spell_checker_get_suggestions (XedSpellChecker *spell,
|
|||
g_return_val_if_fail (word != NULL, NULL);
|
||||
|
||||
if (!lazy_init (spell, spell->active_lang))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
g_return_val_if_fail (spell->dict != NULL, NULL);
|
||||
|
||||
if (len < 0)
|
||||
{
|
||||
len = strlen (word);
|
||||
}
|
||||
|
||||
suggestions = enchant_dict_suggest (spell->dict, word, len, &n_suggestions);
|
||||
|
||||
if (n_suggestions == 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
g_return_val_if_fail (suggestions != NULL, NULL);
|
||||
|
||||
for (i = 0; i < (gint)n_suggestions; i++)
|
||||
{
|
||||
suggestions_list = g_slist_prepend (suggestions_list,
|
||||
suggestions[i]);
|
||||
suggestions_list = g_slist_prepend (suggestions_list, suggestions[i]);
|
||||
}
|
||||
|
||||
/* The single suggestions will be freed by the caller */
|
||||
|
@ -426,12 +454,16 @@ xed_spell_checker_add_word_to_personal (XedSpellChecker *spell,
|
|||
g_return_val_if_fail (word != NULL, FALSE);
|
||||
|
||||
if (!lazy_init (spell, spell->active_lang))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_return_val_if_fail (spell->dict != NULL, FALSE);
|
||||
|
||||
if (len < 0)
|
||||
{
|
||||
len = strlen (word);
|
||||
}
|
||||
|
||||
enchant_dict_add_to_pwl (spell->dict, word, len);
|
||||
|
||||
|
@ -449,12 +481,16 @@ xed_spell_checker_add_word_to_session (XedSpellChecker *spell,
|
|||
g_return_val_if_fail (word != NULL, FALSE);
|
||||
|
||||
if (!lazy_init (spell, spell->active_lang))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_return_val_if_fail (spell->dict != NULL, FALSE);
|
||||
|
||||
if (len < 0)
|
||||
{
|
||||
len = strlen (word);
|
||||
}
|
||||
|
||||
enchant_dict_add_to_session (spell->dict, word, len);
|
||||
|
||||
|
@ -476,7 +512,9 @@ xed_spell_checker_clear_session (XedSpellChecker *spell)
|
|||
}
|
||||
|
||||
if (!lazy_init (spell, spell->active_lang))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_signal_emit (G_OBJECT (spell), signals[CLEAR_SESSION], 0);
|
||||
|
||||
|
@ -499,15 +537,21 @@ xed_spell_checker_set_correction (XedSpellChecker *spell,
|
|||
g_return_val_if_fail (replacement != NULL, FALSE);
|
||||
|
||||
if (!lazy_init (spell, spell->active_lang))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_return_val_if_fail (spell->dict != NULL, FALSE);
|
||||
|
||||
if (w_len < 0)
|
||||
{
|
||||
w_len = strlen (word);
|
||||
}
|
||||
|
||||
if (r_len < 0)
|
||||
{
|
||||
r_len = strlen (replacement);
|
||||
}
|
||||
|
||||
enchant_dict_store_replacement (spell->dict,
|
||||
word,
|
||||
|
|
Loading…
Reference in New Issue