changeset 16323:cf62255b0a74

merge of 'b2ed97746412540812181f94bcb3e2f077321052' and 'e3a16be06e623901a0b1943a8dd9fa206d02874f'
author Mark Doliner <mark@kingant.net>
date Mon, 23 Apr 2007 07:44:12 +0000
parents a32325c04158 (diff) 6349d702bab6 (current diff)
children ea82f4e6321e
files pidgin/gtkstatusbox.c
diffstat 3 files changed, 34 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkimhtml.c	Mon Apr 23 07:44:10 2007 +0000
+++ b/pidgin/gtkimhtml.c	Mon Apr 23 07:44:12 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);
 			}
 		}
 	}
--- a/pidgin/gtkimhtml.h	Mon Apr 23 07:44:10 2007 +0000
+++ b/pidgin/gtkimhtml.h	Mon Apr 23 07:44:12 2007 +0000
@@ -87,6 +87,8 @@
 	char *protocol_name;
 	guint scroll_src;
 	GTimer *scroll_time;
+	GQueue *animations;
+	int num_animations;
 
 	gboolean show_comments;
 
--- a/pidgin/gtkstatusbox.c	Mon Apr 23 07:44:10 2007 +0000
+++ b/pidgin/gtkstatusbox.c	Mon Apr 23 07:44:12 2007 +0000
@@ -1077,8 +1077,8 @@
 		add_popular_statuses(status_box);
 
 		pidgin_status_box_add_separator(PIDGIN_STATUS_BOX(status_box));
-		pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_CUSTOM, pixbuf, _("New..."), NULL, NULL);
-		pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_SAVED, pixbuf, _("Saved..."), NULL, NULL);
+		pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_CUSTOM, NULL, _("New..."), NULL, NULL);
+		pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_SAVED, NULL, _("Saved..."), NULL, NULL);
 		if (pixbuf)	g_object_unref(G_OBJECT(pixbuf));
 
 		status_menu_refresh_iter(status_box);