[evolution/wip/webkit-composer: 113/262] Rename e_spell_checker_lookup_dictionary().



commit a31e4859ffebec73ebf2062e3cb2c6e910a891d8
Author: Matthew Barnes <mbarnes redhat com>
Date:   Tue Jan 15 22:54:35 2013 -0500

    Rename e_spell_checker_lookup_dictionary().
    
    Rename to e_spell_checker_ref_dictionary() to clarify ownership of the
    returned ESpellDictionary.

 composer/e-msg-composer.c                          |    4 +-
 .../evolution-util/evolution-util-sections.txt     |    2 +-
 e-util/e-editor-actions.c                          |    2 +-
 e-util/e-spell-checker.c                           |   40 ++++++++++----------
 e-util/e-spell-checker.h                           |    3 +-
 e-util/e-spell-entry.c                             |    6 +-
 6 files changed, 28 insertions(+), 29 deletions(-)
---
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index e7d88f2..b5fcf5d 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -5009,7 +5009,7 @@ e_load_spell_languages (ESpellChecker *spell_checker)
                gchar *language_code = strv[ii];
                ESpellDictionary *dict;
 
-               dict = e_spell_checker_lookup_dictionary (
+               dict = e_spell_checker_ref_dictionary (
                        spell_checker, language_code);
                if (dict != NULL)
                        spell_dicts = g_list_prepend (spell_dicts, dict);
@@ -5023,7 +5023,7 @@ e_load_spell_languages (ESpellChecker *spell_checker)
        if (spell_dicts == NULL) {
                ESpellDictionary *dict;
 
-               dict = e_spell_checker_lookup_dictionary (spell_checker, NULL);
+               dict = e_spell_checker_ref_dictionary (spell_checker, NULL);
 
                if (dict != NULL)
                        spell_dicts = g_list_prepend (spell_dicts, dict);
diff --git a/doc/reference/evolution-util/evolution-util-sections.txt 
b/doc/reference/evolution-util/evolution-util-sections.txt
index 44aa43d..7e3b9e3 100644
--- a/doc/reference/evolution-util/evolution-util-sections.txt
+++ b/doc/reference/evolution-util/evolution-util-sections.txt
@@ -3912,7 +3912,7 @@ e_source_util_remote_delete
 ESpellChecker
 e_spell_checker_instance
 e_spell_checker_list_available_dicts
-e_spell_checker_lookup_dictionary
+e_spell_checker_ref_dictionary
 e_spell_checker_set_active_dictionaries
 e_spell_checker_get_active_dictionaries
 e_spell_checker_free_dict
diff --git a/e-util/e-editor-actions.c b/e-util/e-editor-actions.c
index 3d4ffd5..e077ad1 100644
--- a/e-util/e-editor-actions.c
+++ b/e-util/e-editor-actions.c
@@ -588,7 +588,7 @@ action_language_cb (GtkToggleAction *action,
        checker = e_editor_widget_get_spell_checker (editor->priv->editor_widget);
        active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
        language_code = gtk_action_get_name (GTK_ACTION (action));
-       dictionary = e_spell_checker_lookup_dictionary (checker, language_code);
+       dictionary = e_spell_checker_ref_dictionary (checker, language_code);
 
        /* Update the list of active dictionaries */
        list = editor->priv->active_dictionaries;
diff --git a/e-util/e-spell-checker.c b/e-util/e-spell-checker.c
index 652d405..b14504b 100644
--- a/e-util/e-spell-checker.c
+++ b/e-util/e-spell-checker.c
@@ -244,7 +244,7 @@ wksc_update_languages (WebKitSpellChecker *webkit_checker,
                for (ii = 0; langs[ii] != NULL; ii++) {
                        ESpellDictionary *dict;
 
-                       dict = e_spell_checker_lookup_dictionary (checker, langs[ii]);
+                       dict = e_spell_checker_ref_dictionary (checker, langs[ii]);
                        dictionaries = g_list_append (dictionaries, dict);
                }
                g_strfreev (langs);
@@ -253,7 +253,7 @@ wksc_update_languages (WebKitSpellChecker *webkit_checker,
                ESpellDictionary *dict;
 
                language = pango_language_to_string (gtk_get_default_language ());
-               dict = e_spell_checker_lookup_dictionary (checker, language);
+               dict = e_spell_checker_ref_dictionary (checker, language);
                if (dict) {
                        dictionaries = g_list_append (dictionaries, dict);
                } else {
@@ -434,9 +434,9 @@ e_spell_checker_list_available_dicts (ESpellChecker *checker)
 }
 
 /**
- * e_spell_checker_lookup_dictionary:
+ * e_spell_checker_ref_dictionary:
  * @checker: an #ESpellChecker
- * @language_code: (allow-none) language code for which to lookup the dictionary
+ * @language_code: (allow-none): language code of a dictionary, or %NULL
  *
  * Tries to find an #ESpellDictionary for given @language_code.
  * If @language_code is %NULL, the function will return a default
@@ -445,32 +445,32 @@ e_spell_checker_list_available_dicts (ESpellChecker *checker)
  * Returns: an #ESpellDictionary for @language_code
  */
 ESpellDictionary *
-e_spell_checker_lookup_dictionary (ESpellChecker *checker,
-                                   const gchar *language_code)
+e_spell_checker_ref_dictionary (ESpellChecker *checker,
+                                const gchar *language_code)
 {
-       ESpellDictionary *e_dict = NULL;
-       GList *dicts;
+       ESpellDictionary *dictionary;
+       GList *list;
 
        g_return_val_if_fail (E_IS_SPELL_CHECKER (checker), NULL);
 
        /* If the cache has not yet been initialized, do so - we will need
         * it anyway, Otherwise is this call very cheap */
-       dicts = e_spell_checker_list_available_dicts (checker);
+       list = e_spell_checker_list_available_dicts (checker);
 
-       if (!language_code) {
-               if (dicts) {
-                       e_dict = g_object_ref (dicts->data);
-               }
+       if (language_code == NULL) {
+               dictionary = (list != NULL) ? list->data : NULL;
        } else {
-               e_dict = g_hash_table_lookup (
-                       checker->priv->dictionaries_cache, language_code);
-               if (e_dict) {
-                       g_object_ref (e_dict);
-               }
+               dictionary = g_hash_table_lookup (
+                       checker->priv->dictionaries_cache,
+                       language_code);
        }
 
-       g_list_free (dicts);
-       return e_dict;
+       if (dictionary != NULL)
+               g_object_ref (dictionary);
+
+       g_list_free (list);
+
+       return dictionary;
 }
 
 /**
diff --git a/e-util/e-spell-checker.h b/e-util/e-spell-checker.h
index 3b0737d..66d1f1a 100644
--- a/e-util/e-spell-checker.h
+++ b/e-util/e-spell-checker.h
@@ -65,8 +65,7 @@ ESpellChecker *       e_spell_checker_instance        (void);
 GList *                e_spell_checker_list_available_dicts
                                                (ESpellChecker *checker);
 ESpellDictionary *
-               e_spell_checker_lookup_dictionary
-                                               (ESpellChecker *checker,
+               e_spell_checker_ref_dictionary  (ESpellChecker *checker,
                                                 const gchar *language_code);
 void           e_spell_checker_set_active_dictionaries
                                                (ESpellChecker *checker,
diff --git a/e-util/e-spell-entry.c b/e-util/e-spell-entry.c
index 917037b..d62fcd5 100644
--- a/e-util/e-spell-entry.c
+++ b/e-util/e-spell-entry.c
@@ -644,7 +644,7 @@ spell_entry_load_spell_languages (ESpellEntry *entry)
                ESpellDictionary *dictionary;
                gchar *language_code = strv[ii];
 
-               dictionary = e_spell_checker_lookup_dictionary (
+               dictionary = e_spell_checker_ref_dictionary (
                        spell_checker, language_code);
                if (dictionary != NULL)
                        list = g_list_prepend (list, dictionary);
@@ -658,7 +658,7 @@ spell_entry_load_spell_languages (ESpellEntry *entry)
        if (list == NULL) {
                ESpellDictionary *dictionary;
 
-               dictionary = e_spell_checker_lookup_dictionary (
+               dictionary = e_spell_checker_ref_dictionary (
                        spell_checker, NULL);
                if (dictionary != NULL)
                        list = g_list_prepend (list, dictionary);
@@ -683,7 +683,7 @@ spell_entry_settings_changed (ESpellEntry *spell_entry,
 
        languages = spell_entry_load_spell_languages (spell_entry);
        e_spell_entry_set_languages (spell_entry, languages);
-       g_list_free (languages);
+       g_list_free_full (languages, (GDestroyNotify) g_object_unref);
 
        spell_entry->priv->custom_checkers = FALSE;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]