? panel-menu.patch
Index: gnome-panel/menu.c
===================================================================
RCS file: /cvs/gnome/gnome-panel/gnome-panel/menu.c,v
retrieving revision 1.608
diff -u -r1.608 menu.c
--- gnome-panel/menu.c	21 Aug 2002 12:47:06 -0000	1.608
+++ gnome-panel/menu.c	25 Aug 2002 10:46:55 -0000
@@ -110,9 +110,16 @@
 	guint size;
 } IconToLoad;
 
+typedef struct {
+	GtkWidget *image;
+	const char *stock_id;
+	GdkPixbuf *pixbuf;
+} IconToAdd;
+
 static guint load_icons_id = 0;
 static GHashTable *loaded_icons = NULL;
 static GList *icons_to_load = NULL;
+static GList *icons_to_add = NULL;
 
 static GSList *image_menu_items = NULL;
 
@@ -878,6 +885,34 @@
 	return pb;
 }
 
+static void
+do_icons_to_add (void)
+{
+	while (icons_to_add) {
+		IconToAdd *icon_to_add = icons_to_add->data;
+
+		icons_to_add = g_list_delete_link (icons_to_add, icons_to_add);
+
+		if (icon_to_add->stock_id) {
+			gtk_image_set_from_stock (
+				GTK_IMAGE (icon_to_add->image),
+				icon_to_add->stock_id,
+				panel_menu_icon_get_size ());
+		}
+		else {
+			g_assert (icon_to_add->pixbuf);
+
+			gtk_image_set_from_pixbuf (
+				GTK_IMAGE (icon_to_add->image),
+				icon_to_add->pixbuf);
+
+			g_object_unref (G_OBJECT (icon_to_add->pixbuf));
+		}
+
+		g_free (icon_to_add);
+	}
+}
+
 static gboolean
 load_icons_handler (gpointer data)
 {
@@ -888,6 +923,8 @@
 
 	if (!icons_to_load) {
 		load_icons_id = 0;
+		do_icons_to_add ();
+
 		return FALSE;
 	}
 
@@ -904,12 +941,17 @@
 		goto load_icons_handler_again;
 	}
 
-	if (icon->stock_id)
-		gtk_image_set_from_stock (GTK_IMAGE (icon->pixmap),
-					  icon->stock_id,
-					  panel_menu_icon_get_size ());
+	if (icon->stock_id) {
+		IconToAdd *icon_to_add = g_new (IconToAdd, 1);
+
+		icon_to_add->image = icon->pixmap;
+		icon_to_add->stock_id = icon->stock_id;
+		icon_to_add->pixbuf = NULL;
 
+		icons_to_add = g_list_prepend (icons_to_add, icon_to_add);
+	}
 	else {
+		IconToAdd *icon_to_add;
 		GdkPixbuf *pb;
 
 		pb = panel_make_menu_icon (icon->image,
@@ -927,9 +969,13 @@
 				 * this is fun, don't go back to main loop */
 				goto load_icons_handler_again;
 		}
-	
-		gtk_image_set_from_pixbuf (GTK_IMAGE (icon->pixmap), pb);
-		g_object_unref (pb);
+
+		icon_to_add = g_new (IconToAdd, 1);
+		icon_to_add->image = icon->pixmap;
+		icon_to_add->stock_id = NULL;
+		icon_to_add->pixbuf = pb;
+
+		icons_to_add = g_list_prepend (icons_to_add, icon_to_add);
 	}
 
 	icon_to_load_free (icon);
