changeset 13673:5948086807cd

[gaim-migrate @ 16075] Don't show the current status in the list of popular statuses in the gtkstatusbox and in the system tray committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Fri, 21 Apr 2006 03:06:19 +0000
parents e5c3bfc208a9
children 183c177d8cdd
files src/savedstatuses.c src/savedstatuses.h
diffstat 2 files changed, 19 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/savedstatuses.c	Fri Apr 21 02:48:58 2006 +0000
+++ b/src/savedstatuses.c	Fri Apr 21 03:06:19 2006 +0000
@@ -684,18 +684,30 @@
 GList *
 gaim_savedstatuses_get_popular(unsigned int how_many)
 {
-	GList *truncated = NULL;
+	GList *popular = NULL;
 	GList *cur;
 	int i;
+	GaimSavedStatus *current;
+
+	/* We don't want the current status to be in the GList */
+	current = gaim_savedstatus_get_current();
 
 	/* Copy 'how_many' elements to a new list */
-	for (i = 0, cur = saved_statuses; (i < how_many) && (cur != NULL); i++)
+	i = 0;
+	cur = saved_statuses;
+	while ((i < how_many) && (cur != NULL))
 	{
-		truncated = g_list_append(truncated, cur->data);
+		if (cur->data != current)
+		{
+			popular = g_list_prepend(popular, cur->data);
+			i++;
+		}
 		cur = cur->next;
 	}
 
-	return truncated;
+	popular = g_list_reverse(popular);
+
+	return popular;
 }
 
 GaimSavedStatus *
--- a/src/savedstatuses.h	Fri Apr 21 02:48:58 2006 +0000
+++ b/src/savedstatuses.h	Fri Apr 21 03:06:19 2006 +0000
@@ -154,7 +154,9 @@
 /**
  * Returns the n most popular saved statuses.  "Popularity" is
  * determined by when the last time a saved_status was used and
- * how many times it has been used.
+ * how many times it has been used.  If the current status would
+ * normally show up in this list, then it is omited and instead
+ * the "how_many+1" saved status will appear in the list.
  *
  * @param how_many The maximum number of saved statuses
  *                 to return, or '0' to get all saved