From 3f31751d69ee114076e055468fc42cba3e420a85 Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Sun, 18 Aug 2013 12:33:55 +0200 Subject: Restructured code. Most non-GUI code was moved out of mapwidget.go --- emptyPixmap.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 emptyPixmap.go (limited to 'emptyPixmap.go') diff --git a/emptyPixmap.go b/emptyPixmap.go new file mode 100644 index 0000000..7635225 --- /dev/null +++ b/emptyPixmap.go @@ -0,0 +1,13 @@ +package main + +import ( + "github.com/mattn/go-gtk/gdk" +) + +// emptyPixmap creates an empty pixmap. +func emptyPixmap(w, h, depth int) *gdk.Pixmap { + // The underlying C function would create an empty, unbound pixmap, if the drawable paramater was a NULL pointer. + // Since simply passing a nil value would result in a panic (dereferencing a nil pointer), we use a new gdk.Drawable. + // gdk.Drawable contains a C pointer which is NULL by default. So passing a new(gdk.Drawable) does the trick. + return gdk.NewPixmap(new(gdk.Drawable), w, h, depth) +} -- cgit v1.2.3-70-g09d2