pidgin: 4332f4fc: Closes #6057.

sadrul at pidgin.im sadrul at pidgin.im
Mon Jun 9 15:35:43 EDT 2008


-----------------------------------------------------------------
Revision: 4332f4fcb2cf764aa2534891346eb29c326ab57a
Ancestor: 329e176fb12d63a4d133f0e832fb9400f4991235
Author: ml at update.uu.se
Date: 2008-06-09T19:31:43
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/4332f4fcb2cf764aa2534891346eb29c326ab57a

Modified files:
        pidgin/gtkimhtmltoolbar.c

ChangeLog: 

Closes #6057.
ChangeLog: 

Do not disable default smileys with dupliate shortcuts if custom smileys
are not supported by the prpl. Also, show the text of the disabled smiley
in the tooltip.
And use _prepend and _reverse, instead of _append for GLists, since some
people apparently have hundreds of custom smileys.

-------------- next part --------------
============================================================
--- pidgin/gtkimhtmltoolbar.c	b9753aad4bcacff9c60798aec69e3e4d47c000b2
+++ pidgin/gtkimhtmltoolbar.c	f83557d6d6b55a3e8a642ccfc4fadb19ac8fd1fd
@@ -614,8 +614,7 @@ sort_smileys(struct smiley_button_list *
 
 static struct smiley_button_list *
 sort_smileys(struct smiley_button_list *ls, GtkIMHtmlToolbar *toolbar,
-			 int *width, const GtkIMHtmlSmiley *smiley,
-			 const GSList *custom_smileys)
+			 int *width, const GtkIMHtmlSmiley *smiley)
 {
 	GtkWidget *image;
 	GtkWidget *button;
@@ -625,6 +624,7 @@ sort_smileys(struct smiley_button_list *
 	const gchar *filename = smiley->file;
 	gchar *face = smiley->smile;
 	PurpleSmiley *psmiley = NULL;
+	gboolean supports_custom = (gtk_imhtml_get_format_functions(GTK_IMHTML(toolbar->imhtml)) & GTK_IMHTML_CUSTOM_SMILEY);
 
 	cur = g_new0(struct smiley_button_list, 1);
 	it = ls;
@@ -678,10 +678,12 @@ sort_smileys(struct smiley_button_list *
 	/* If this is a "non-custom" smiley, check to see if its shortcut is
 	  "shadowed" by any custom smiley. This can only happen if the connection
 	  is custom smiley-enabled */
-	if (psmiley && !(smiley->flags & GTK_IMHTML_SMILEY_CUSTOM)) {
-		gtk_tooltips_set_tip(toolbar->tooltips, button,
-				_("This smiley is disabled because a custom smiley exists for this shortcut."),
-				NULL);
+	if (supports_custom && psmiley && !(smiley->flags & GTK_IMHTML_SMILEY_CUSTOM)) {
+		gchar tip[128];
+		g_snprintf(tip, sizeof(tip), 
+			_("This smiley is disabled because a custom smiley exists for this shortcut:\n %s"),
+			face);
+		gtk_tooltips_set_tip(toolbar->tooltips, button, tip, NULL);
 		gtk_widget_set_sensitive(button, FALSE);
 	} else if (psmiley) {
 		/* Remove the button if the smiley is destroyed */
@@ -783,11 +785,14 @@ insert_smiley_cb(GtkWidget *smiley, GtkI
 	else
 		smileys = pidgin_themes_get_proto_smileys(NULL);
 
+	/* Note: prepend smileys to list to avoid O(n^2) overhead when there is
+	  a large number of smileys... need to revers the list after for the dialog
+	  work... */
 	while(smileys) {
 		GtkIMHtmlSmiley *smiley = (GtkIMHtmlSmiley *) smileys->data;
 		if(!smiley->hidden) {
 			if(smiley_is_unique(unique_smileys, smiley)) {
-				unique_smileys = g_slist_append(unique_smileys, smiley);
+				unique_smileys = g_slist_prepend(unique_smileys, smiley);
 			}
 		}
 		smileys = smileys->next;
@@ -800,9 +805,12 @@ insert_smiley_cb(GtkWidget *smiley, GtkI
 		for (iterator = custom_smileys ; iterator ;
 			 iterator = g_slist_next(iterator)) {
 			GtkIMHtmlSmiley *smiley = (GtkIMHtmlSmiley *) iterator->data;
-			unique_smileys = g_slist_append(unique_smileys, smiley);
+			unique_smileys = g_slist_prepend(unique_smileys, smiley);
 		}
 	}
+	
+	/* we need to reverse the list to get the smileys in the correct order */
+	unique_smileys = g_slist_reverse(unique_smileys);
 
 	dialog = pidgin_create_dialog(_("Smile!"), 0, "smiley_dialog", FALSE);
 	gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_MOUSE);
@@ -834,7 +842,7 @@ insert_smiley_cb(GtkWidget *smiley, GtkI
 		while (unique_smileys) {
 			GtkIMHtmlSmiley *smiley = (GtkIMHtmlSmiley *) unique_smileys->data;
 			if (!smiley->hidden) {
-				ls = sort_smileys(ls, toolbar, &max_line_width, smiley, custom_smileys);
+				ls = sort_smileys(ls, toolbar, &max_line_width, smiley);
 			}
 			unique_smileys = g_slist_delete_link(unique_smileys, unique_smileys);
 		}


More information about the Commits mailing list