summaryrefslogtreecommitdiff
path: root/gtkcasts_unix.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-07-02 22:53:03 -0400
committerPietro Gagliardi <[email protected]>2014-07-02 22:53:03 -0400
commit8a81650b3da7ce00725336df9e03b38e935c5a65 (patch)
tree08af843f0460e7226f305cf7162021ef54e8c3f7 /gtkcasts_unix.go
parent4dd5ceb11d62bd6b9af4847936314a9d8c45707f (diff)
Moved it all back; the preemptive multitaksing during an event handler kills us on all platforms. Going to have to restrict ALL GUI accss to happening from one t hread, so going to need to drop uitask entirely and have just a start() callback for startup code and a post() function for posting requests to windows (like channel sends but into a perpetual buffer).
Diffstat (limited to 'gtkcasts_unix.go')
-rw-r--r--gtkcasts_unix.go109
1 files changed, 109 insertions, 0 deletions
diff --git a/gtkcasts_unix.go b/gtkcasts_unix.go
new file mode 100644
index 0000000..5c02223
--- /dev/null
+++ b/gtkcasts_unix.go
@@ -0,0 +1,109 @@
+// +build !windows,!darwin,!plan9
+
+// 17 february 2014
+
+package ui
+
+import (
+ "unsafe"
+)
+
+// this file contains functions that wrap around complex pointer casts to satisfy GTK+'s dumb type aliasing system
+// fromxxx() converts from GTK+ type to Go type
+// toxxxx() converts from Go type to GTK+ type
+// Listbox casts are stored in listbox_unix.go
+
+// #include "gtk_unix.h"
+import "C"
+
+func fromgbool(b C.gboolean) bool {
+ return b != C.FALSE
+}
+
+func togbool(b bool) C.gboolean {
+ if b {
+ return C.TRUE
+ }
+ return C.FALSE
+}
+
+func fromgstr(what *C.gchar) string {
+ cstr := (*C.char)(unsafe.Pointer(what))
+ return C.GoString(cstr)
+}
+
+func togstr(what *C.char) *C.gchar {
+ return (*C.gchar)(unsafe.Pointer(what))
+}
+
+func fromgtkwindow(x *C.GtkWindow) *C.GtkWidget {
+ return (*C.GtkWidget)(unsafe.Pointer(x))
+}
+
+func togtkwindow(what *C.GtkWidget) *C.GtkWindow {
+ return (*C.GtkWindow)(unsafe.Pointer(what))
+}
+
+func fromgtkcontainer(x *C.GtkContainer) *C.GtkWidget {
+ return (*C.GtkWidget)(unsafe.Pointer(x))
+}
+
+func togtkcontainer(what *C.GtkWidget) *C.GtkContainer {
+ return (*C.GtkContainer)(unsafe.Pointer(what))
+}
+
+func fromgtklayout(x *C.GtkLayout) *C.GtkWidget {
+ return (*C.GtkWidget)(unsafe.Pointer(x))
+}
+
+func togtklayout(what *C.GtkWidget) *C.GtkLayout {
+ return (*C.GtkLayout)(unsafe.Pointer(what))
+}
+
+func fromgtkbutton(x *C.GtkButton) *C.GtkWidget {
+ return (*C.GtkWidget)(unsafe.Pointer(x))
+}
+
+func togtkbutton(what *C.GtkWidget) *C.GtkButton {
+ return (*C.GtkButton)(unsafe.Pointer(what))
+}
+
+func fromgtktogglebutton(x *C.GtkToggleButton) *C.GtkWidget {
+ return (*C.GtkWidget)(unsafe.Pointer(x))
+}
+
+func togtktogglebutton(what *C.GtkWidget) *C.GtkToggleButton {
+ return (*C.GtkToggleButton)(unsafe.Pointer(what))
+}
+
+func fromgtkcombobox(x *C.GtkComboBoxText) *C.GtkWidget {
+ return (*C.GtkWidget)(unsafe.Pointer(x))
+}
+
+func togtkcombobox(what *C.GtkWidget) *C.GtkComboBoxText {
+ return (*C.GtkComboBoxText)(unsafe.Pointer(what))
+}
+
+func fromgtkentry(x *C.GtkEntry) *C.GtkWidget {
+ return (*C.GtkWidget)(unsafe.Pointer(x))
+}
+
+func togtkentry(what *C.GtkWidget) *C.GtkEntry {
+ return (*C.GtkEntry)(unsafe.Pointer(what))
+}
+
+func fromgtklabel(x *C.GtkLabel) *C.GtkWidget {
+ return (*C.GtkWidget)(unsafe.Pointer(x))
+}
+
+func togtklabel(what *C.GtkWidget) *C.GtkLabel {
+ return (*C.GtkLabel)(unsafe.Pointer(what))
+}
+
+func fromgtkprogressbar(x *C.GtkProgressBar) *C.GtkWidget {
+ return (*C.GtkWidget)(unsafe.Pointer(x))
+}
+
+func togtkprogressbar(what *C.GtkWidget) *C.GtkProgressBar {
+ return (*C.GtkProgressBar)(unsafe.Pointer(what))
+}