changeset 23141:55e42ccdca4c

Patch from Masca to restrict the size of incoming custom smileys to a maximum of 96 pixels on either side. Closes #5231.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sun, 11 May 2008 18:08:57 +0000
parents b37b9e53a31b
children a372713e405c
files pidgin/gtkimhtml.c
diffstat 1 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkimhtml.c	Sun May 11 04:08:06 2008 +0000
+++ b/pidgin/gtkimhtml.c	Sun May 11 18:08:57 2008 +0000
@@ -5344,6 +5344,24 @@
 	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 @@
 
 	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,