summaryrefslogtreecommitdiff
path: root/gtkcasts_unix.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-02-17 15:45:26 -0500
committerPietro Gagliardi <[email protected]>2014-02-17 15:45:26 -0500
commitc92a370f08433596dc1b33fd788f1eb0fb570d23 (patch)
tree55740356a90121948daaf782fe85e87b9d071de0 /gtkcasts_unix.go
parente395ea105b7329b0de8f3bddc7e04ad191295675 (diff)
Isolated all the non-listbox-related GTK+ type conversions into their own file with functions to reduce the amount of code noise in gtkcalls_unix.go.
Diffstat (limited to 'gtkcasts_unix.go')
-rw-r--r--gtkcasts_unix.go108
1 files changed, 108 insertions, 0 deletions
diff --git a/gtkcasts_unix.go b/gtkcasts_unix.go
new file mode 100644
index 0000000..9bfdd4a
--- /dev/null
+++ b/gtkcasts_unix.go
@@ -0,0 +1,108 @@
+// +build !windows,!darwin,!plan9
+
+// 17 february 2014
+package main
+
+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
+
+// #cgo pkg-config: gtk+-3.0
+// #include <gtk/gtk.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 fromgtkwidget(x *C.GtkWidget) *gtkWidget {
+ return (*gtkWidget)(unsafe.Pointer(x))
+}
+
+func togtkwidget(what *gtkWidget) *C.GtkWidget {
+ return (*C.GtkWidget)(unsafe.Pointer(what))
+}
+
+// TODO wrap in C.GoString()?
+func fromgchar(what *C.gchar) *C.char {
+ return (*C.char)(unsafe.Pointer(what))
+}
+
+func togchar(what *C.char) *C.gchar {
+ return (*C.gchar)(unsafe.Pointer(what))
+}
+
+func fromgtkwindow(x *C.GtkWindow) *gtkWidget {
+ return (*gtkWidget)(unsafe.Pointer(x))
+}
+
+func togtkwindow(what *gtkWidget) *C.GtkWindow {
+ return (*C.GtkWindow)(unsafe.Pointer(what))
+}
+
+func fromgtkcontainer(x *C.GtkContainer) *gtkWidget {
+ return (*gtkWidget)(unsafe.Pointer(x))
+}
+
+func togtkcontainer(what *gtkWidget) *C.GtkContainer {
+ return (*C.GtkContainer)(unsafe.Pointer(what))
+}
+
+func fromgtkfixed(x *C.GtkFixed) *gtkWidget {
+ return (*gtkWidget)(unsafe.Pointer(x))
+}
+
+func togtkfixed(what *gtkWidget) *C.GtkFixed {
+ return (*C.GtkFixed)(unsafe.Pointer(what))
+}
+
+func fromgtkbutton(x *C.GtkButton) *gtkWidget {
+ return (*gtkWidget)(unsafe.Pointer(x))
+}
+
+func togtkbutton(what *gtkWidget) *C.GtkButton {
+ return (*C.GtkButton)(unsafe.Pointer(what))
+}
+
+func fromgtktogglebutton(x *C.GtkToggleButton) *gtkWidget {
+ return (*gtkWidget)(unsafe.Pointer(x))
+}
+
+func togtktogglebutton(what *gtkWidget) *C.GtkToggleButton {
+ return (*C.GtkToggleButton)(unsafe.Pointer(what))
+}
+
+func fromgtkcombobox(x *C.GtkComboBoxText) *gtkWidget {
+ return (*gtkWidget)(unsafe.Pointer(x))
+}
+
+func togtkcombobox(what *gtkWidget) *C.GtkComboBoxText {
+ return (*C.GtkComboBoxText)(unsafe.Pointer(what))
+}
+
+func fromgtkentry(x *C.GtkEntry) *gtkWidget {
+ return (*gtkWidget)(unsafe.Pointer(x))
+}
+
+func togtkentry(what *gtkWidget) *C.GtkEntry {
+ return (*C.GtkEntry)(unsafe.Pointer(what))
+}
+
+func fromgtklabel(x *C.GtkLabel) *gtkWidget {
+ return (*gtkWidget)(unsafe.Pointer(x))
+}
+
+func togtklabel(what *gtkWidget) *C.GtkLabel {
+ return (*C.GtkLabel)(unsafe.Pointer(what))
+}