From 2e4c2783012cb386b29b04237e2a198fbcfe5e4d Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Tue, 17 Feb 2015 23:26:46 -0500 Subject: [PATCH] Started migrating the GTK+ Table to the new ImageList-less design. Migrated the ImageList code itself. --- imagelist_unix.go => image_unix.go | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) rename imagelist_unix.go => image_unix.go (81%) diff --git a/imagelist_unix.go b/image_unix.go similarity index 81% rename from imagelist_unix.go rename to image_unix.go index 1729705..3f13d2a 100644 --- a/imagelist_unix.go +++ b/image_unix.go @@ -13,19 +13,11 @@ import ( // #include "gtk_unix.h" import "C" -type imagelist struct { - list []*C.GdkPixbuf -} - -func newImageList() ImageList { - return new(imagelist) -} - // this is what GtkFileChooserWidget uses // technically it uses max(width from that, height from that) if the call below fails and 16x16 otherwise, but we won't worry about that here (yet?) const scaleTo = C.GTK_ICON_SIZE_MENU -func (i *imagelist) Append(img *image.RGBA) { +func toIconSizedGdkPixbuf(img *image.RGBA) *C.GdkPixbuf { var width, height C.gint surface := C.cairo_image_surface_create(C.CAIRO_FORMAT_ARGB32, @@ -59,20 +51,7 @@ func (i *imagelist) Append(img *image.RGBA) { panic(fmt.Errorf("gdk_pixbuf_scale_simple() failed in ImageList.Append() (no reason available)")) } - i.list = append(i.list, pixbuf) C.g_object_unref(C.gpointer(unsafe.Pointer(basepixbuf))) C.cairo_surface_destroy(surface) -} - -func (i *imagelist) Len() ImageIndex { - return ImageIndex(len(i.list)) -} - -type imageListApply interface { - apply(*[]*C.GdkPixbuf) -} - -func (i *imagelist) apply(out *[]*C.GdkPixbuf) { - *out = make([]*C.GdkPixbuf, len(i.list)) - copy(*out, i.list) + return pixbuf }