summaryrefslogtreecommitdiff
path: root/emptyPixmap.go
blob: 763522544cf0e6de37874ad7d4a8ea1e5bbac567 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
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)
}