Esempio n. 1
0
File: button.go Progetto: ziutek/gtk
func NewButtonFromStock(stock string) *Button {
	b := new(Button)
	b.SetPtr(
		glib.Pointer(C.gtk_button_new_from_stock((*C.gchar)(C.CString(stock)))),
	)
	return b
}
// ButtonNewFromStock is a wrapper around gtk_button_new_from_stock().
func ButtonNewFromStock(stock Stock) (*Button, error) {
	cstr := C.CString(string(stock))
	defer C.free(unsafe.Pointer(cstr))
	c := C.gtk_button_new_from_stock((*C.gchar)(cstr))
	if c == nil {
		return nil, nilPtrErr
	}
	return wrapButton(wrapObject(unsafe.Pointer(c))), nil
}
Esempio n. 3
0
// GtkWidget*     gtk_button_new_from_stock    (const gchar    *stock_id);
func NewButtonFromStock(stock_id string) *Button {
	s := _GString(stock_id)
	defer _GFree(unsafe.Pointer(s))

	ret := C.gtk_button_new_from_stock(s)
	if ret != nil {
		return ToButton(unsafe.Pointer(ret))
	}

	return nil
}
Esempio n. 4
0
// ButtonNewFromStock is a wrapper around gtk_button_new_from_stock().
func ButtonNewFromStock(stock Stock) (*Button, error) {
	cstr := C.CString(string(stock))
	defer C.free(unsafe.Pointer(cstr))
	c := C.gtk_button_new_from_stock((*C.gchar)(cstr))
	if c == nil {
		return nil, nilPtrErr
	}
	obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))}
	b := wrapButton(obj)
	obj.RefSink()
	runtime.SetFinalizer(obj, (*glib.Object).Unref)
	return b, nil
}