# HG changeset patch # User Sadrul Habib Chowdhury # Date 1210529337 0 # Node ID 55e42ccdca4c56fd99a90f9bae3dd20286eeb552 # Parent b37b9e53a31b79399efe1cefac1f699a89d065bf Patch from Masca to restrict the size of incoming custom smileys to a maximum of 96 pixels on either side. Closes #5231. diff -r b37b9e53a31b -r 55e42ccdca4c pidgin/gtkimhtml.c --- 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,