summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2018-08-12 11:07:33 -0400
committerPietro Gagliardi <[email protected]>2018-08-12 11:07:33 -0400
commit925adc0782c4dd9b978a712b1b5645b5f31bf802 (patch)
tree66590ea495c0c680c3dfcd22a55896c864ad35a7
parentcfea745dc745dcb0af8704d7cdb50d9725714b04 (diff)
Fixed build errors.
-rw-r--r--button.go4
-rw-r--r--checkbox.go4
-rw-r--r--combobox.go4
-rw-r--r--control.go8
-rw-r--r--datetimepicker.go10
-rw-r--r--editablecombobox.go8
-rw-r--r--entry.go4
-rw-r--r--main.go8
-rw-r--r--radiobuttons.go4
-rw-r--r--slider.go4
-rw-r--r--spinbox.go4
-rw-r--r--window.go4
12 files changed, 46 insertions, 20 deletions
diff --git a/button.go b/button.go
index a0c4e67..630c684 100644
--- a/button.go
+++ b/button.go
@@ -8,6 +8,8 @@ import (
// #include "ui.h"
// extern void doButtonOnClicked(uiButton *, void *);
+// // see golang/go#19835
+// typedef void (*buttonCallback)(uiButton *, void *);
import "C"
// Button is a Control that represents a button that the user can
@@ -27,7 +29,7 @@ func NewButton(text string) *Button {
b.b = C.uiNewButton(ctext)
freestr(ctext)
- C.uiButtonOnClicked(b.b, C.doButtonOnClicked, nil)
+ C.uiButtonOnClicked(b.b, C.buttonCallback(C.doButtonOnClicked), nil)
b.ControlBase = NewControlBase(b, uintptr(unsafe.Pointer(b.b)))
return b
diff --git a/checkbox.go b/checkbox.go
index d7fd949..8177226 100644
--- a/checkbox.go
+++ b/checkbox.go
@@ -8,6 +8,8 @@ import (
// #include "ui.h"
// extern void doCheckboxOnToggled(uiCheckbox *, void *);
+// // see golang/go#19835
+// typedef void (*checkboxCallback)(uiCheckbox *, void *);
import "C"
// Checkbox is a Control that represents a box with a text label at its
@@ -28,7 +30,7 @@ func NewCheckbox(text string) *Checkbox {
c.c = C.uiNewCheckbox(ctext)
freestr(ctext)
- C.uiCheckboxOnToggled(c.c, C.doCheckboxOnToggled, nil)
+ C.uiCheckboxOnToggled(c.c, C.checkboxCallback(C.doCheckboxOnToggled), nil)
c.ControlBase = NewControlBase(c, uintptr(unsafe.Pointer(c.c)))
return c
diff --git a/combobox.go b/combobox.go
index 059422d..1e381de 100644
--- a/combobox.go
+++ b/combobox.go
@@ -8,6 +8,8 @@ import (
// #include "ui.h"
// extern void doComboboxOnSelected(uiCombobox *, void *);
+// // see golang/go#19835
+// typedef void (*comboboxCallback)(uiCombobox *, void *);
import "C"
// Combobox is a Control that represents a drop-down list of strings
@@ -25,7 +27,7 @@ func NewCombobox() *Combobox {
c.c = C.uiNewCombobox()
- C.uiComboboxOnSelected(c.c, C.doComboboxOnSelected, nil)
+ C.uiComboboxOnSelected(c.c, C.comboboxCallback(C.doComboboxOnSelected), nil)
c.ControlBase = NewControlBase(c, uintptr(unsafe.Pointer(c.c)))
return c
diff --git a/control.go b/control.go
index 03cf181..23a8ddf 100644
--- a/control.go
+++ b/control.go
@@ -130,8 +130,12 @@ func (c *ControlBase) Disable() {
// This function only works on Controls that use ControlBase.
func ControlFromLibui(c uintptr) Control {
// comma-ok form to avoid creating nil entries
- c, _ := controls[(*C.uiControl)(unsafe.Pointer(c))]
- return c
+ cc, _ := controls[(*C.uiControl)(unsafe.Pointer(c))]
+ return cc
+}
+
+func touiControl(c uintptr) *C.uiControl {
+ return (*C.uiControl)(unsafe.Pointer(c))
}
// LibuiFreeText allows implementations of Control
diff --git a/datetimepicker.go b/datetimepicker.go
index 6e64e34..3436b3c 100644
--- a/datetimepicker.go
+++ b/datetimepicker.go
@@ -16,6 +16,8 @@ import (
// return (struct tm *) pkguiAlloc(sizeof (struct tm));
// }
// extern void doDateTimePickerOnChanged(uiDateTimePicker *, void *);
+// // see golang/go#19835
+// typedef void (*dtpCallback)(uiDateTimePicker *, void *);
import "C"
// DateTimePicker is a Control that represents a field where the user
@@ -31,7 +33,7 @@ func finishNewDateTimePicker(dd *C.uiDateTimePicker) *DateTimePicker {
d.d = dd
- C.uiDateTimePickerOnChanged(d.d, C.doDateTimePickerOnChanged, nil)
+ C.uiDateTimePickerOnChanged(d.d, C.dtpCallback(C.doDateTimePickerOnChanged), nil)
d.ControlBase = NewControlBase(d, uintptr(unsafe.Pointer(d.d)))
return d
@@ -40,7 +42,7 @@ func finishNewDateTimePicker(dd *C.uiDateTimePicker) *DateTimePicker {
// NewDateTimePicker creates a new DateTimePicker that shows
// both a date and a time.
func NewDateTimePicker() *DateTimePicker {
- return finishNewDateTImePicker(C.uiNewDateTimePicker())
+ return finishNewDateTimePicker(C.uiNewDateTimePicker())
}
// NewDatePicker creates a new DateTimePicker that shows
@@ -72,7 +74,7 @@ func (d *DateTimePicker) Time() time.Time {
}
// SetTime sets the time in the DateTimePicker to t.
-// t's components are read as-is via t.Date() and t.Time();
+// t's components are read as-is via t.Date() and t.Clock();
// no time zone manipulations are done.
func (d *DateTimePicker) SetTime(t time.Time) {
tm := C.allocTimeStruct()
@@ -81,7 +83,7 @@ func (d *DateTimePicker) SetTime(t time.Time) {
tm.tm_year = C.int(year - 1900)
tm.tm_mon = C.int(mon - 1)
tm.tm_mday = C.int(mday)
- hour, min, sec := t.Time()
+ hour, min, sec := t.Clock()
tm.tm_hour = C.int(hour)
tm.tm_min = C.int(min)
tm.tm_sec = C.int(sec)
diff --git a/editablecombobox.go b/editablecombobox.go
index 31db150..1242928 100644
--- a/editablecombobox.go
+++ b/editablecombobox.go
@@ -8,6 +8,8 @@ import (
// #include "ui.h"
// extern void doEditableComboboxOnChanged(uiEditableCombobox *, void *);
+// // see golang/go#19835
+// typedef void (*editableComboboxCallback)(uiEditableCombobox *, void *);
import "C"
// EditableCombobox is a Control that represents a drop-down list
@@ -25,7 +27,7 @@ func NewEditableCombobox() *EditableCombobox {
c.c = C.uiNewEditableCombobox()
- C.uiEditableComboboxOnChanged(c.c, C.doEditableComboboxOnChanged, nil)
+ C.uiEditableComboboxOnChanged(c.c, C.editableComboboxCallback(C.doEditableComboboxOnChanged), nil)
c.ControlBase = NewControlBase(c, uintptr(unsafe.Pointer(c.c)))
return c
@@ -48,7 +50,7 @@ func (e *EditableCombobox) Text() string {
}
// SetText sets the text in the entry of the EditableCombobox.
-func (e *EditableCombobox) SetText(index int) {
+func (e *EditableCombobox) SetText(text string) {
ctext := C.CString(text)
C.uiEditableComboboxSetText(e.c, ctext)
freestr(ctext)
@@ -58,7 +60,7 @@ func (e *EditableCombobox) SetText(index int) {
// item or changes the text in the EditableCombobox. Only one
// function can be registered at a time.
func (e *EditableCombobox) OnChanged(f func(*EditableCombobox)) {
- c.onChanged = f
+ e.onChanged = f
}
//export doEditableComboboxOnChanged
diff --git a/entry.go b/entry.go
index 2b6cc11..52da537 100644
--- a/entry.go
+++ b/entry.go
@@ -12,6 +12,8 @@ import (
// #include "ui.h"
// extern void doEntryOnChanged(uiEntry *, void *);
+// // see golang/go#19835
+// typedef void (*entryCallback)(uiEntry *, void *);
import "C"
// Entry is a Control that represents a space that the user can
@@ -27,7 +29,7 @@ func finishNewEntry(ee *C.uiEntry) *Entry {
e.e = ee
- C.uiEntryOnChanged(e.e, C.doEntryOnChanged, nil)
+ C.uiEntryOnChanged(e.e, C.entryCallback(C.doEntryOnChanged), nil)
e.ControlBase = NewControlBase(e, uintptr(unsafe.Pointer(e.e)))
return e
diff --git a/main.go b/main.go
index 1ba6d05..6500345 100644
--- a/main.go
+++ b/main.go
@@ -12,7 +12,9 @@ import (
// #include "ui.h"
// extern void doQueueMain(void *);
// extern int doOnShouldQuit(void *);
-// extern int doOnTimer(void *);
+// // see golang/go#19835
+// typedef void (*queueMainCallback)(void *);
+// typedef int (*onShouldQuitCallback)(void *);
import "C"
// make sure main() runs on the first thread created by the OS
@@ -39,7 +41,7 @@ func Main(f func()) error {
C.uiFreeInitError(estr)
return err
}
- C.uiOnShouldQuit(C.doOnShouldQuit, nil)
+ C.uiOnShouldQuit(C.onShouldQuitCallback(C.doOnShouldQuit), nil)
QueueMain(f)
C.uiMain()
return nil
@@ -88,7 +90,7 @@ func QueueMain(f func()) {
}
}
qmmap[n] = f
- C.uiQueueMain(C.doQueueMain, unsafe.Pointer(n))
+ C.uiQueueMain(C.queueMainCallback(C.doQueueMain), unsafe.Pointer(n))
}
//export doQueueMain
diff --git a/radiobuttons.go b/radiobuttons.go
index 59b5665..5f7505d 100644
--- a/radiobuttons.go
+++ b/radiobuttons.go
@@ -8,6 +8,8 @@ import (
// #include "ui.h"
// extern void doRadioButtonsOnSelected(uiRadioButtons *, void *);
+// // see golang/go#19835
+// typedef void (*radioButtonsCallback)(uiRadioButtons *, void *);
import "C"
// RadioButtons is a Control that represents a set of checkable
@@ -24,7 +26,7 @@ func NewRadioButtons() *RadioButtons {
r.r = C.uiNewRadioButtons()
- C.uiRadioButtonsOnSelected(r.r, C.doRadioButtonsOnSelected, nil)
+ C.uiRadioButtonsOnSelected(r.r, C.radioButtonsCallback(C.doRadioButtonsOnSelected), nil)
r.ControlBase = NewControlBase(r, uintptr(unsafe.Pointer(r.r)))
return r
diff --git a/slider.go b/slider.go
index 68218bc..91656cf 100644
--- a/slider.go
+++ b/slider.go
@@ -8,6 +8,8 @@ import (
// #include "ui.h"
// extern void doSliderOnChanged(uiSlider *, void *);
+// // see golang/go#19835
+// typedef void (*sliderCallback)(uiSlider *, void *);
import "C"
// Slider is a Control that represents a horizontal bar that represents
@@ -25,7 +27,7 @@ func NewSlider(min int, max int) *Slider {
s.s = C.uiNewSlider(C.int(min), C.int(max))
- C.uiSliderOnChanged(s.s, C.doSliderOnChanged, nil)
+ C.uiSliderOnChanged(s.s, C.sliderCallback(C.doSliderOnChanged), nil)
s.ControlBase = NewControlBase(s, uintptr(unsafe.Pointer(s.s)))
return s
diff --git a/spinbox.go b/spinbox.go
index a1dfc3b..27dd287 100644
--- a/spinbox.go
+++ b/spinbox.go
@@ -8,6 +8,8 @@ import (
// #include "ui.h"
// extern void doSpinboxOnChanged(uiSpinbox *, void *);
+// // see golang/go#19835
+// typedef void (*spinboxCallback)(uiSpinbox *, void *);
import "C"
// Spinbox is a Control that represents a space where the user can
@@ -25,7 +27,7 @@ func NewSpinbox(min int, max int) *Spinbox {
s.s = C.uiNewSpinbox(C.int(min), C.int(max))
- C.uiSpinboxOnChanged(s.s, C.doSpinboxOnChanged, nil)
+ C.uiSpinboxOnChanged(s.s, C.spinboxCallback(C.doSpinboxOnChanged), nil)
s.ControlBase = NewControlBase(s, uintptr(unsafe.Pointer(s.s)))
return s
diff --git a/window.go b/window.go
index 784d485..a40ddd9 100644
--- a/window.go
+++ b/window.go
@@ -8,6 +8,8 @@ import (
// #include "ui.h"
// extern int doWindowOnClosing(uiWindow *, void *);
+// // see golang/go#19835
+// typedef int (*windowOnClosingCallback)(uiWindow *, void *);
import "C"
// Window is a Control that represents a top-level window.
@@ -29,7 +31,7 @@ func NewWindow(title string, width int, height int, hasMenubar bool) *Window {
w.w = C.uiNewWindow(ctitle, C.int(width), C.int(height), frombool(hasMenubar))
freestr(ctitle)
- C.uiWindowOnClosing(w.w, C.doWindowOnClosing, nil)
+ C.uiWindowOnClosing(w.w, C.windowOnClosingCallback(C.doWindowOnClosing), nil)
w.ControlBase = NewControlBase(w, uintptr(unsafe.Pointer(w.w)))
return w