[gedit/wip/spell-checking: 2/2] spell-checker-dialog: various code improvements



commit 743611dba4696a72504f36f9c45119f1dc1b3be4
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sat Jul 25 05:13:11 2015 +0200

    spell-checker-dialog: various code improvements

 plugins/spell/gedit-spell-checker-dialog.c |   24 +++++++++++-------------
 1 files changed, 11 insertions(+), 13 deletions(-)
---
diff --git a/plugins/spell/gedit-spell-checker-dialog.c b/plugins/spell/gedit-spell-checker-dialog.c
index 2620ae3..0662492 100644
--- a/plugins/spell/gedit-spell-checker-dialog.c
+++ b/plugins/spell/gedit-spell-checker-dialog.c
@@ -438,10 +438,9 @@ update_suggestions_model (GeditSpellCheckerDialog *dialog,
 {
        GtkListStore *store;
        GtkTreeIter iter;
-       GtkTreeSelection *sel;
-
-       g_return_if_fail (GEDIT_IS_SPELL_CHECKER_DIALOG (dialog));
-       g_return_if_fail (GTK_IS_LIST_STORE (dialog->suggestions_model));
+       GtkTreeSelection *selection;
+       const gchar *first_suggestion;
+       GSList *l;
 
        store = GTK_LIST_STORE (dialog->suggestions_model);
        gtk_list_store_clear (store);
@@ -458,29 +457,28 @@ update_suggestions_model (GeditSpellCheckerDialog *dialog,
                                    -1);
 
                gtk_entry_set_text (GTK_ENTRY (dialog->word_entry), "");
-
                gtk_widget_set_sensitive (GTK_WIDGET (dialog->suggestions_view), FALSE);
-
                return;
        }
 
        gtk_widget_set_sensitive (GTK_WIDGET (dialog->suggestions_view), TRUE);
 
-       gtk_entry_set_text (GTK_ENTRY (dialog->word_entry), (gchar*)suggestions->data);
+       first_suggestion = suggestions->data;
+       gtk_entry_set_text (GTK_ENTRY (dialog->word_entry), first_suggestion);
 
-       while (suggestions != NULL)
+       for (l = suggestions; l != NULL; l = l->next)
        {
+               const gchar *suggestion = l->data;
+
                gtk_list_store_append (store, &iter);
                gtk_list_store_set (store, &iter,
-                                   COLUMN_SUGGESTIONS, (gchar*)suggestions->data,
+                                   COLUMN_SUGGESTIONS, suggestion,
                                    -1);
-
-               suggestions = g_slist_next (suggestions);
        }
 
-       sel = gtk_tree_view_get_selection (dialog->suggestions_view);
+       selection = gtk_tree_view_get_selection (dialog->suggestions_view);
        gtk_tree_model_get_iter_first (dialog->suggestions_model, &iter);
-       gtk_tree_selection_select_iter (sel, &iter);
+       gtk_tree_selection_select_iter (selection, &iter);
 }
 
 static void


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