+ printf("allocate to: %dx%d\n", allocation->width, allocation->height);
+ GdkPixmap *oldmap;
+ gtk_image_get_pixmap( GTK_IMAGE(widget), &oldmap, NULL );
+ gint oldwidth = 0;
+ gint oldheight = 0;
+
+ /* Determine whether a pixmap exists with the correct size */
+ gboolean needs_resize = FALSE;
+ if(oldmap == NULL)
+ needs_resize = TRUE;
+ else {
+ gdk_drawable_get_size( GDK_DRAWABLE(oldmap), &oldwidth, &oldheight );
+ if(oldwidth != allocation->width || oldheight != allocation->height)
+ needs_resize = TRUE;
+ }
+
+ if(needs_resize) {
+ printf("needs resize\n");
+ /* Create a new pixmap */
+ GdkPixmap *newmap = gdk_pixmap_new(widget->window, allocation->width, allocation->height, -1);
+ gdk_draw_rectangle( GDK_DRAWABLE(newmap), widget->style->white_gc, TRUE, 0, 0, allocation->width, allocation->height);
+
+ /* Copy the contents of the old pixmap */
+ if(oldmap != NULL)
+ gdk_draw_drawable( GDK_DRAWABLE(newmap), widget->style->white_gc, GDK_DRAWABLE(oldmap), 0, 0, 0, 0, oldwidth, oldheight);
+
+ /* Use the new pixmap */
+ gtk_image_set_from_pixmap( GTK_IMAGE(widget), newmap, NULL );
+ g_object_unref(newmap);
+ }