[evolution/webkit-composer: 115/130] Rename e_spell_checker_lookup_dictionary().



commit e99f1c6bf01b1596648f34060df89cec236d78ad
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 +-
 doc/reference/libeutil/libeutil-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 0932c03..81c9f64 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -4988,7 +4988,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);
@@ -5002,7 +5002,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/libeutil/libeutil-sections.txt b/doc/reference/libeutil/libeutil-sections.txt
index e631272..c9dd113 100644
--- a/doc/reference/libeutil/libeutil-sections.txt
+++ b/doc/reference/libeutil/libeutil-sections.txt
@@ -3658,7 +3658,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 9e13e71..09690f0 100644
--- a/e-util/e-spell-entry.c
+++ b/e-util/e-spell-entry.c
@@ -594,7 +594,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);
@@ -608,7 +608,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);
@@ -633,7 +633,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]