Smileys: don't shuffle smileys when displaying smiley toolbar window

Tue, 08 Apr 2014 22:05:13 +0200

author
Tomasz Wasilczyk <twasilczyk@pidgin.im>
date
Tue, 08 Apr 2014 22:05:13 +0200
changeset 35799
04b439a886e6
parent 35798
42dbd9f39583
child 35800
2c21828e7442

Smileys: don't shuffle smileys when displaying smiley toolbar window

libpurple/smiley-list.c file | annotate | diff | comparison | revisions
pidgin/gtksmiley-theme.c file | annotate | diff | comparison | revisions
--- a/libpurple/smiley-list.c	Tue Apr 08 19:10:53 2014 +0200
+++ b/libpurple/smiley-list.c	Tue Apr 08 22:05:13 2014 +0200
@@ -249,11 +249,31 @@
 GList *
 purple_smiley_list_get_unique(PurpleSmileyList *list)
 {
+	GList *unique = NULL, *it;
+	GHashTable *unique_map;
 	PurpleSmileyListPrivate *priv = PURPLE_SMILEY_LIST_GET_PRIVATE(list);
 
 	g_return_val_if_fail(priv != NULL, NULL);
 
-	return g_hash_table_get_values(priv->path_map);
+	/* We could just return g_hash_table_get_values(priv->path_map) here,
+	 * but it won't be in order. */
+
+	unique_map = g_hash_table_new(g_str_hash, g_str_equal);
+
+	for (it = priv->smileys; it; it = g_list_next(it)) {
+		PurpleSmiley *smiley = it->data;
+		const gchar *path = purple_smiley_get_path(smiley);
+
+		if (g_hash_table_lookup(unique_map, path))
+			continue;
+
+		unique = g_list_prepend(unique, smiley);
+		g_hash_table_insert(unique_map, (gpointer)path, smiley);
+	}
+
+	g_hash_table_destroy(unique_map);
+
+	return g_list_reverse(unique);
 }
 
 GList *
--- a/pidgin/gtksmiley-theme.c	Tue Apr 08 19:10:53 2014 +0200
+++ b/pidgin/gtksmiley-theme.c	Tue Apr 08 22:05:13 2014 +0200
@@ -177,6 +177,9 @@
 				break;
 			}
 
+			if (proto)
+				proto->smileys = g_list_reverse(proto->smileys);
+
 			proto = g_new0(PidginSmileyThemeIndexProtocol, 1);
 			proto->name = g_strndup(line, end - line);
 
@@ -250,6 +253,9 @@
 		smiley->shortcuts = g_list_reverse(smiley->shortcuts);
 	}
 
+	if (proto)
+		proto->smileys = g_list_reverse(proto->smileys);
+
 	fclose(file);
 
 	if (inv_frm) {

mercurial