pidgin.custom_smiley: 6e7c4dd2: Patch from Masca to restrict the size of...

sadrul at pidgin.im sadrul at pidgin.im
Sun May 11 14:15:45 EDT 2008


-----------------------------------------------------------------
Revision: 6e7c4dd26da75349ba06490409bce8a1ccfbcb2a
Ancestor: cd3217cc55f69225b77f1573ded3dbcc5ee5c990
Author: sadrul at pidgin.im
Date: 2008-05-11T18:08:57
Branch: im.pidgin.pidgin.custom_smiley
URL: http://d.pidgin.im/viewmtn/revision/info/6e7c4dd26da75349ba06490409bce8a1ccfbcb2a

Modified files:
        pidgin/gtkimhtml.c

ChangeLog: 

Patch from Masca to restrict the size of incoming custom smileys to a
maximum of 96 pixels on either side. Closes #5231.

-------------- next part --------------
============================================================
--- pidgin/gtkimhtml.c	b1179768c210e928234d3ebf2b3bd41ee05d85b0
+++ pidgin/gtkimhtml.c	1f8dc40435a4c5fb4210c58d0950c3679fc166e8
@@ -5344,6 +5344,24 @@ static void gtk_custom_smiley_closed(Gdk
 	smiley->loader = NULL;
 }
 
+static void
+gtk_custom_smiley_size_prepared(GdkPixbufLoader *loader, gint width, gint height, gpointer data)
+{
+#define CUSTOM_SMILEY_SIZE 96	/* XXX: Should this be a theme setting? */
+	if (width <= CUSTOM_SMILEY_SIZE && height <= CUSTOM_SMILEY_SIZE)
+		return;
+
+	if (width >= height) {
+		height = height * CUSTOM_SMILEY_SIZE / width;
+		width = CUSTOM_SMILEY_SIZE;
+	} else {
+		width = width * CUSTOM_SMILEY_SIZE / height;
+		height = CUSTOM_SMILEY_SIZE;
+	}
+
+	gdk_pixbuf_loader_set_size(loader, width, height);
+}
+
 void
 gtk_imhtml_smiley_reload(GtkIMHtmlSmiley *smiley)
 {
@@ -5366,6 +5384,7 @@ gtk_imhtml_smiley_reload(GtkIMHtmlSmiley
 
 	g_signal_connect(smiley->loader, "area_prepared", G_CALLBACK(gtk_custom_smiley_allocated), smiley);
 	g_signal_connect(smiley->loader, "closed", G_CALLBACK(gtk_custom_smiley_closed), smiley);
+	g_signal_connect(smiley->loader, "size_prepared", G_CALLBACK(gtk_custom_smiley_size_prepared), smiley);
 }
 
 GtkIMHtmlSmiley *gtk_imhtml_smiley_create(const char *file, const char *shortcut, gboolean hide,


More information about the Commits mailing list