diff options
Diffstat (limited to 'emptyPixmap.go')
-rw-r--r-- | emptyPixmap.go | 13 |
1 files changed, 13 insertions, 0 deletions
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) +} |