/
button.go
64 lines (52 loc) · 1.09 KB
/
button.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package gtk
/*
#include <gtk/gtk.h>
*/
import "C"
import (
"github.com/ziutek/glib"
)
type Button struct {
Bin
}
func (b *Button) g() *C.GtkButton {
return (*C.GtkButton)(b.GetPtr())
}
func (b *Button) AsButton() *Button {
return b
}
func (b *Button) SetLabel(label string) {
C.gtk_button_set_label(b.g(), (*C.gchar)(C.CString(label)))
}
func (b *Button) GetLabel() string {
return C.GoString((*C.char)(C.gtk_button_get_label(b.g())))
}
func (b *Button) SetUseStock(use_stock bool) {
var us C.gboolean
if use_stock {
us = 1
}
C.gtk_button_set_use_stock(b.g(), us)
}
func (b *Button) GetUseStock() bool {
return C.gtk_button_get_use_stock(b.g()) != 0
}
func NewButton() *Button {
b := new(Button)
b.SetPtr(glib.Pointer(C.gtk_button_new()))
return b
}
func NewButtonWithLabel(label string) *Button {
b := new(Button)
b.SetPtr(
glib.Pointer(C.gtk_button_new_with_label((*C.gchar)(C.CString(label)))),
)
return b
}
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
}