2014-07-08 15:47:28 -05:00
|
|
|
// +build !darwin
|
|
|
|
|
2014-07-07 09:44:46 -05:00
|
|
|
// 7 july 2014
|
|
|
|
|
|
|
|
package ui
|
|
|
|
|
|
|
|
import (
|
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
|
|
|
// #include "gtk_unix.h"
|
|
|
|
import "C"
|
|
|
|
|
|
|
|
type widgetbase struct {
|
|
|
|
widget *C.GtkWidget
|
|
|
|
}
|
|
|
|
|
2014-07-07 21:46:23 -05:00
|
|
|
func newWidget(w *C.GtkWidget) *widgetbase {
|
|
|
|
return &widgetbase{
|
2014-07-07 09:44:46 -05:00
|
|
|
widget: w,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type button struct {
|
|
|
|
*widgetbase
|
2014-07-07 21:46:23 -05:00
|
|
|
button *C.GtkButton
|
2014-07-07 09:44:46 -05:00
|
|
|
}
|
|
|
|
|
2014-07-07 14:30:55 -05:00
|
|
|
func newButton(text string) *Request {
|
|
|
|
c := make(chan interface{})
|
|
|
|
return &Request{
|
|
|
|
op: func() {
|
|
|
|
ctext := togstr(text)
|
|
|
|
defer freegstr(ctext)
|
|
|
|
widget := C.gtk_button_new_with_label(ctext)
|
|
|
|
c <- &button{
|
2014-07-07 21:46:23 -05:00
|
|
|
widgetbase: newWidget(widget),
|
|
|
|
button: (*C.GtkButton)(unsafe.Pointer(widget)),
|
2014-07-07 14:30:55 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
resp: c,
|
2014-07-07 09:44:46 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-07 21:46:23 -05:00
|
|
|
func (b *button) OnClicked(e func(c Doer)) *Request {
|
2014-07-07 15:51:17 -05:00
|
|
|
// TODO
|
|
|
|
return nil
|
|
|
|
}
|
2014-07-07 09:44:46 -05:00
|
|
|
|
|
|
|
func (b *button) Text() *Request {
|
|
|
|
c := make(chan interface{})
|
|
|
|
return &Request{
|
|
|
|
op: func() {
|
|
|
|
c <- fromgstr(C.gtk_button_get_label(b.button))
|
|
|
|
},
|
|
|
|
resp: c,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *button) SetText(text string) *Request {
|
|
|
|
c := make(chan interface{})
|
|
|
|
return &Request{
|
|
|
|
op: func() {
|
|
|
|
ctext := togstr(text)
|
|
|
|
defer freegstr(ctext)
|
|
|
|
C.gtk_button_set_label(b.button, ctext)
|
|
|
|
c <- struct{}{}
|
|
|
|
},
|
|
|
|
resp: c,
|
|
|
|
}
|
|
|
|
}
|