/dev/tomkiewicz/new-smileys: cb9acfd6fa1e: Smileys: hide hidden ...

Tomasz Wasilczyk twasilczyk at pidgin.im
Thu Apr 3 19:06:12 EDT 2014


Changeset: cb9acfd6fa1e5c1f2800b4ef9c53792b1d24b19d
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-04-04 01:06 +0200
Branch:	 default
URL: https://hg.pidgin.im/dev/tomkiewicz/new-smileys/rev/cb9acfd6fa1e

Description:

Smileys: hide hidden smileys

diffstat:

 libpurple/smiley-parser.c  |   2 ++
 pidgin/gtksmiley-theme.c   |  10 +++++++---
 pidgin/gtkwebviewtoolbar.c |  19 +++++++++++++++----
 3 files changed, 24 insertions(+), 7 deletions(-)

diffs (93 lines):

diff --git a/libpurple/smiley-parser.c b/libpurple/smiley-parser.c
--- a/libpurple/smiley-parser.c
+++ b/libpurple/smiley-parser.c
@@ -101,6 +101,8 @@ purple_smiley_parse(const gchar *message
 	 * if protocol doesn't support it? */
 
 	/* TODO: don't replace text within tags, ie. <span style=":)"> */
+	/* TODO: parse greedily (as much as possible) when PurpleTrie
+	 * provides support for it. */
 	return purple_trie_multi_replace(tries, message,
 		purple_smiley_parse_cb, NULL);
 }
diff --git a/pidgin/gtksmiley-theme.c b/pidgin/gtksmiley-theme.c
--- a/pidgin/gtksmiley-theme.c
+++ b/pidgin/gtksmiley-theme.c
@@ -420,7 +420,7 @@ pidgin_smiley_theme_get_author(PidginSmi
 PurpleSmileyList *
 pidgin_smiley_theme_for_conv(PurpleConversation *conv)
 {
-	PurpleAccount *acc;
+	PurpleAccount *acc = NULL;
 	PurpleSmileyTheme *theme;
 	const gchar *proto_name = NULL;
 
@@ -485,6 +485,9 @@ pidgin_smiley_theme_activate_impl(Purple
 
 				smiley = purple_smiley_new(
 					shortcut, smiley_path);
+				g_object_set_data(G_OBJECT(smiley),
+					"pidgin-smiley-hidden",
+					GINT_TO_POINTER(smiley_idx->hidden));
 				purple_smiley_list_add(proto_smileys, smiley);
 				g_object_unref(smiley);
 			}
@@ -498,11 +501,12 @@ static PurpleSmileyList *
 pidgin_smiley_theme_get_smileys_impl(PurpleSmileyTheme *theme, gpointer ui_data)
 {
 	PidginSmileyThemePrivate *priv = PIDGIN_SMILEY_THEME_GET_PRIVATE(theme);
-	PurpleSmileyList *smileys;
+	PurpleSmileyList *smileys = NULL;
 
 	pidgin_smiley_theme_activate_impl(theme);
 
-	smileys = g_hash_table_lookup(priv->smiley_lists_map, ui_data);
+	if (ui_data)
+		smileys = g_hash_table_lookup(priv->smiley_lists_map, ui_data);
 	if (smileys != NULL)
 		return smileys;
 
diff --git a/pidgin/gtkwebviewtoolbar.c b/pidgin/gtkwebviewtoolbar.c
--- a/pidgin/gtkwebviewtoolbar.c
+++ b/pidgin/gtkwebviewtoolbar.c
@@ -825,7 +825,7 @@ insert_smiley_cb(GtkAction *smiley, Pidg
 	PidginWebViewToolbarPriv *priv =
 		PIDGIN_WEBVIEWTOOLBAR_GET_PRIVATE(toolbar);
 	PurpleSmileyList *smileys_from_theme, *smileys_from_custom = NULL;
-	GList *theme_smileys = NULL, *custom_smileys = NULL;
+	GList *theme_smileys = NULL, *custom_smileys = NULL, *it, *it_next;
 	PidginWebViewButtons webview_format;
 
 	GtkWidget *dialog, *vbox;
@@ -848,7 +848,20 @@ insert_smiley_cb(GtkAction *smiley, Pidg
 		theme_smileys = purple_smiley_list_get_unique(
 			smileys_from_theme);
 	}
-	/* TODO: remove hidden */
+
+	/* remove hidden theme smileys */
+	for (it = theme_smileys; it; it = it_next) {
+		PurpleSmiley *smiley = it->data;
+		it_next = g_list_next(it);
+
+		if (!g_object_get_data(G_OBJECT(smiley),
+			"pidgin-smiley-hidden"))
+		{
+			continue;
+		}
+
+		theme_smileys = g_list_delete_link(theme_smileys, it);
+	}
 
 	supports_custom = (webview_format & PIDGIN_WEBVIEW_CUSTOM_SMILEY);
 	if (supports_custom) {
@@ -888,9 +901,7 @@ insert_smiley_cb(GtkAction *smiley, Pidg
 		/* create list of smileys sorted by height */
 		while (theme_smileys) {
 			PidginWebViewSmiley *smiley = (PidginWebViewSmiley *)theme_smileys->data;
-			if (!pidgin_webview_smiley_get_hidden(smiley)) {
 				ls = sort_smileys(ls, toolbar, &max_line_width, smiley);
-			}
 			theme_smileys = g_slist_delete_link(theme_smileys, theme_smileys);
 		}
 #else



More information about the Commits mailing list