# HG changeset patch # User Sean Egan # Date 1177311833 0 # Node ID a32325c041581d1064ff05c2218b7b3666b49d02 # Parent 2149a071e8d230a58688581c538d76714397c974 Fixes #213 This allows only 20 animated smileys to be animnating at a time diff -r 2149a071e8d2 -r a32325c04158 pidgin/gtkimhtml.c --- a/pidgin/gtkimhtml.c Sun Apr 22 19:10:00 2007 +0000 +++ b/pidgin/gtkimhtml.c Mon Apr 23 07:03:53 2007 +0000 @@ -1217,6 +1217,7 @@ g_list_free(imhtml->scalables); g_slist_free(imhtml->im_images); + g_queue_free(imhtml->animations); g_free(imhtml->protocol_name); g_free(imhtml->search_string); G_OBJECT_CLASS(parent_class)->finalize (object); @@ -1398,7 +1399,7 @@ imhtml->scalables = NULL; - + imhtml->animations = g_queue_new(); gtk_imhtml_set_editable(imhtml, FALSE); g_signal_connect(G_OBJECT(imhtml), "populate-popup", G_CALLBACK(hijack_menu_cb), NULL); @@ -4356,6 +4357,22 @@ return TRUE; } +/* In case the smiley gets removed from the imhtml before it gets removed from the queue */ +static void animated_smiley_destroy_cb(GtkObject *widget, GtkIMHtml *imhtml) +{ + GList *l = imhtml->animations->head; + while (l) { + GList *next = l->next; + if (l->data == widget) { + if (l == imhtml->animations->tail) + imhtml->animations->tail = imhtml->animations->tail->prev; + imhtml->animations->head = g_list_delete_link(imhtml->animations->head, l); + imhtml->num_animations--; + } + l = next; + } +} + void gtk_imhtml_insert_smiley_at_iter(GtkIMHtml *imhtml, const char *sml, char *smiley, GtkTextIter *iter) { GdkPixbuf *pixbuf = NULL; @@ -4374,6 +4391,18 @@ icon = gtk_image_new_from_pixbuf(pixbuf); } else { icon = gtk_image_new_from_animation(annipixbuf); + if (imhtml->num_animations == 20) { + GtkImage *image = GTK_IMAGE(g_queue_pop_head(imhtml->animations)); + GdkPixbufAnimation *anim = gtk_image_get_animation(image); + if (anim) { + GdkPixbuf *pb = gdk_pixbuf_animation_get_static_image(anim); + gtk_image_set_from_pixbuf(image, pb); + } + } else { + imhtml->num_animations++; + } + g_signal_connect(G_OBJECT(icon), "destroy", G_CALLBACK(animated_smiley_destroy_cb), imhtml); + g_queue_push_tail(imhtml->animations, icon); } } } diff -r 2149a071e8d2 -r a32325c04158 pidgin/gtkimhtml.h --- a/pidgin/gtkimhtml.h Sun Apr 22 19:10:00 2007 +0000 +++ b/pidgin/gtkimhtml.h Mon Apr 23 07:03:53 2007 +0000 @@ -87,6 +87,8 @@ char *protocol_name; guint scroll_src; GTimer *scroll_time; + GQueue *animations; + int num_animations; gboolean show_comments;