diff options
| author | Pietro Gagliardi <[email protected]> | 2014-07-07 10:44:46 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-07-07 10:44:46 -0400 |
| commit | 409ecf8ca73754a7987d87dac9057fbac9349f24 (patch) | |
| tree | b8ea2cf17310465bf6b11d4680da53418f548777 /redo/controls_unix.go | |
| parent | bf8d2d7efd79b095f2d8ca5dca5261c70193e628 (diff) | |
Added beginning of Unix Control reimplementation.
Diffstat (limited to 'redo/controls_unix.go')
| -rw-r--r-- | redo/controls_unix.go | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/redo/controls_unix.go b/redo/controls_unix.go new file mode 100644 index 0000000..1fc76c0 --- /dev/null +++ b/redo/controls_unix.go @@ -0,0 +1,60 @@ +// 7 july 2014 + +package ui + +import ( + "unsafe" +) + +// #include "gtk_unix.h" +import "C" + +type widgetbase struct { + widget *C.GtkWidget +} + +func newWidget(w *C.GtkWidget) *widget { + return &widget{ + widget: w, + } +} + +type button struct { + *widgetbase + button *C.GtkButton +} + +func newButton(text string) Button { + ctext := togstr(text) + defer freegstr(ctext) + widget := C.gtk_button_new_with_label(ctext) + return &button{ + widget: newWidget(widget), + button: (*C.GtkButton)(unsafe.Pointer(widget)), + } +} + +// TODO OnClicked + +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, + } +} |
