summaryrefslogtreecommitdiff
path: root/redo/button_unix.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-08-03 16:28:21 -0400
committerPietro Gagliardi <[email protected]>2014-08-03 16:28:21 -0400
commitb6d07237b423b690570e105e5f0810d35693b0d0 (patch)
treefdf2f0ec2a66f217080dfeb0b60de9e763a9bd95 /redo/button_unix.go
parentfd48be68ee957e936c272348d3f0b0bddaba5c92 (diff)
Migrated the GTK+ backend to the new Control system. Added controlParent to deal with interface issues; need to apply this to the Windows backend too.
Diffstat (limited to 'redo/button_unix.go')
-rw-r--r--redo/button_unix.go65
1 files changed, 46 insertions, 19 deletions
diff --git a/redo/button_unix.go b/redo/button_unix.go
index 9811bda..73514b8 100644
--- a/redo/button_unix.go
+++ b/redo/button_unix.go
@@ -10,41 +10,46 @@ import (
// #include "gtk_unix.h"
// extern void buttonClicked(GtkButton *, gpointer);
-// extern void checkboxToggled(GtkToggleButton *, gpointer);
import "C"
type button struct {
- *controlbase
+ _widget *C.GtkWidget
button *C.GtkButton
clicked *event
}
// shared code for setting up buttons, check boxes, etc.
-func finishNewButton(widget *C.GtkWidget, event string, handler unsafe.Pointer) *button {
+func newButton(text string) *button {
+ ctext := togstr(text)
+ defer freegstr(ctext)
+ widget := C.gtk_button_new_with_label(ctext)
b := &button{
- controlbase: newControl(widget),
+ _widget: widget,
button: (*C.GtkButton)(unsafe.Pointer(widget)),
clicked: newEvent(),
}
g_signal_connect(
C.gpointer(unsafe.Pointer(b.button)),
- event,
- C.GCallback(handler),
+ "clicked",
+ C.GCallback(C.buttonClicked),
C.gpointer(unsafe.Pointer(b)))
return b
}
-func newButton(text string) *button {
- ctext := togstr(text)
- defer freegstr(ctext)
- widget := C.gtk_button_new_with_label(ctext)
- return finishNewButton(widget, "clicked", C.buttonClicked)
-}
-
func (b *button) OnClicked(e func()) {
b.clicked.set(e)
}
+func (b *button) Text() string {
+ return fromgstr(C.gtk_button_get_label(b.button))
+}
+
+func (b *button) SetText(text string) {
+ ctext := togstr(text)
+ defer freegstr(ctext)
+ C.gtk_button_set_label(b.button, ctext)
+}
+
//export buttonClicked
func buttonClicked(bwid *C.GtkButton, data C.gpointer) {
b := (*button)(unsafe.Pointer(data))
@@ -52,12 +57,34 @@ func buttonClicked(bwid *C.GtkButton, data C.gpointer) {
println("button clicked")
}
-func (b *button) Text() string {
- return fromgstr(C.gtk_button_get_label(b.button))
+func (b *button) widget() *C.GtkWidget {
+ return b._widget
}
-func (b *button) SetText(text string) {
- ctext := togstr(text)
- defer freegstr(ctext)
- C.gtk_button_set_label(b.button, ctext)
+func (b *button) setParent(p *controlParent) {
+ basesetParent(b, p)
+}
+
+func (b *button) containerShow() {
+ basecontainerShow(b)
+}
+
+func (b *button) containerHide() {
+ basecontainerHide(b)
+}
+
+func (b *button) allocate(x int, y int, width int, height int, d *sizing) []*allocation {
+ return baseallocate(b, x, y, width, height, d)
+}
+
+func (b *button) preferredSize(d *sizing) (width, height int) {
+ return basepreferredSize(b, d)
+}
+
+func (b *button) commitResize(a *allocation, d *sizing) {
+ basecommitResize(b, a, d)
+}
+
+func (b *button) getAuxResizeInfo(d *sizing) {
+ basegetAuxResizeInfo(d)
}