/pidgin/main: 04b439a886e6: Smileys: don't shuffle smileys when ...

Tomasz Wasilczyk twasilczyk at pidgin.im
Tue Apr 8 16:05:22 EDT 2014


Changeset: 04b439a886e6daca20af2b79b7e858dd3a82c4f1
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-04-08 22:05 +0200
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/04b439a886e6

Description:

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

diffstat:

 libpurple/smiley-list.c  |  22 +++++++++++++++++++++-
 pidgin/gtksmiley-theme.c |   6 ++++++
 2 files changed, 27 insertions(+), 1 deletions(-)

diffs (59 lines):

diff --git a/libpurple/smiley-list.c b/libpurple/smiley-list.c
--- a/libpurple/smiley-list.c
+++ b/libpurple/smiley-list.c
@@ -249,11 +249,31 @@ purple_smiley_list_get_trie(PurpleSmiley
 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 *
diff --git a/pidgin/gtksmiley-theme.c b/pidgin/gtksmiley-theme.c
--- a/pidgin/gtksmiley-theme.c
+++ b/pidgin/gtksmiley-theme.c
@@ -177,6 +177,9 @@ pidgin_smiley_theme_index_parse(const gc
 				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 @@ pidgin_smiley_theme_index_parse(const gc
 		smiley->shortcuts = g_list_reverse(smiley->shortcuts);
 	}
 
+	if (proto)
+		proto->smileys = g_list_reverse(proto->smileys);
+
 	fclose(file);
 
 	if (inv_frm) {



More information about the Commits mailing list