[evolution/webkit-composer: 138/182] em-composer-prefs.c cleanups.



commit e4c197f4a0fca530a771acebefd05d1a576ee9b8
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sun Jan 20 11:10:31 2013 -0500

    em-composer-prefs.c cleanups.
    
    In spell_setup(), use e_spell_checker_get_language_active() instead of
    e_load_spell_languages().  Also fix a memory leak from not freeing the
    GList returned by e_spell_checker_list_available_dicts().

 modules/mail/em-composer-prefs.c |   28 +++++++++++++---------------
 1 files changed, 13 insertions(+), 15 deletions(-)
---
diff --git a/modules/mail/em-composer-prefs.c b/modules/mail/em-composer-prefs.c
index 902dad3..c501ca3 100644
--- a/modules/mail/em-composer-prefs.c
+++ b/modules/mail/em-composer-prefs.c
@@ -136,38 +136,36 @@ spell_language_save (EMComposerPrefs *prefs)
 static void
 spell_setup (EMComposerPrefs *prefs)
 {
-       const GList *available_languages;
-       GList *active_languages;
+       GList *list, *link;
        GtkListStore *store;
 
        store = GTK_LIST_STORE (prefs->language_model);
 
-       available_languages =
-               e_spell_checker_list_available_dicts (prefs->spell_checker);
-
-       active_languages = e_load_spell_languages (prefs->spell_checker);
+       list = e_spell_checker_list_available_dicts (prefs->spell_checker);
 
        /* Populate the GtkListStore. */
-       while (available_languages != NULL) {
-               ESpellDictionary *language;
+       for (link = list; link != NULL; link = g_list_next (link)) {
+               ESpellDictionary *dictionary;
                GtkTreeIter tree_iter;
                const gchar *name;
+               const gchar *code;
                gboolean active;
 
-               language = available_languages->data;
-               name = e_spell_dictionary_get_name (language);
-               active = (g_list_find (active_languages, language) != NULL);
+               dictionary = E_SPELL_DICTIONARY (link->data);
+               name = e_spell_dictionary_get_name (dictionary);
+               code = e_spell_dictionary_get_code (dictionary);
+
+               active = e_spell_checker_get_language_active (
+                       prefs->spell_checker, code);
 
                gtk_list_store_append (store, &tree_iter);
 
                gtk_list_store_set (
                        store, &tree_iter,
-                       0, active, 1, name, 2, language, -1);
-
-               available_languages = available_languages->next;
+                       0, active, 1, name, 2, dictionary, -1);
        }
 
-       g_list_free_full (active_languages, g_object_unref);
+       g_list_free (list);
 }
 
 static GtkWidget *


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