[gedit] Do not include the empty string.



commit 0fbbcc2b28b8ca7046cdb3aaac8c35c8cb1112cb
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Sun May 9 17:03:51 2010 +0200

    Do not include the empty string.
    
    Now the default value is '' instead of NULL so we must check for the
    empty string to not include it in the dropdown list.

 gedit/gedit-history-entry.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/gedit/gedit-history-entry.c b/gedit/gedit-history-entry.c
index cfd45bc..9accc46 100644
--- a/gedit/gedit-history-entry.c
+++ b/gedit/gedit-history-entry.c
@@ -202,7 +202,7 @@ get_history_items (GeditHistoryEntry *entry,
 	valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store),
 					       &iter);
 	n_children = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store),
-						     &iter);
+						     NULL);
 
 	*len = n_children;
 	array = g_ptr_array_sized_new (*len + 1);
@@ -373,19 +373,22 @@ gedit_history_entry_load_history (GeditHistoryEntry *entry)
 	items = g_settings_get_strv (entry->priv->settings,
 				     entry->priv->history_id,
 				     &i);
+	i = 0;
 
 	gtk_list_store_clear (store);
 
-	for (i = 0;
-	     items[i] != NULL && i < entry->priv->history_length;
-	     i++)
+	/* Now the default value is an empty string so we have to take care
+	   of it to not add the empty string in the search list */
+	while (items[i] != NULL && *items[i] != '\0' &&
+	       i < entry->priv->history_length)
 	{
 		gtk_list_store_append (store, &iter);
-		gtk_list_store_set (store, 
+		gtk_list_store_set (store,
 				    &iter,
 				    0,
 				    items[i],
 				    -1);
+		i++;
 	}
 
 	g_strfreev (items);



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