2014-02-17 14:45:26 -06:00
|
|
|
// +build !windows,!darwin,!plan9
|
|
|
|
|
|
|
|
// 17 february 2014
|
2014-03-12 20:55:45 -05:00
|
|
|
|
2014-02-19 10:41:10 -06:00
|
|
|
package ui
|
2014-02-17 14:45:26 -06:00
|
|
|
|
|
|
|
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
|
2014-02-17 15:19:00 -06:00
|
|
|
// Listbox casts are stored in listbox_unix.go
|
2014-02-17 14:45:26 -06:00
|
|
|
|
|
|
|
// #cgo pkg-config: gtk+-3.0
|
2014-03-16 09:34:12 -05:00
|
|
|
// #include "gtk_unix.h"
|
2014-02-17 14:45:26 -06:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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))
|
|
|
|
}
|
|
|
|
|
2014-04-01 15:30:38 -05:00
|
|
|
func fromgtkwindow(x *C.GtkWindow) *C.GtkWidget {
|
|
|
|
return (*C.GtkWidget)(unsafe.Pointer(x))
|
2014-02-17 14:45:26 -06:00
|
|
|
}
|
|
|
|
|
2014-04-01 15:30:38 -05:00
|
|
|
func togtkwindow(what *C.GtkWidget) *C.GtkWindow {
|
2014-02-17 14:45:26 -06:00
|
|
|
return (*C.GtkWindow)(unsafe.Pointer(what))
|
|
|
|
}
|
|
|
|
|
2014-04-01 15:30:38 -05:00
|
|
|
func fromgtkcontainer(x *C.GtkContainer) *C.GtkWidget {
|
|
|
|
return (*C.GtkWidget)(unsafe.Pointer(x))
|
2014-02-17 14:45:26 -06:00
|
|
|
}
|
|
|
|
|
2014-04-01 15:30:38 -05:00
|
|
|
func togtkcontainer(what *C.GtkWidget) *C.GtkContainer {
|
2014-02-17 14:45:26 -06:00
|
|
|
return (*C.GtkContainer)(unsafe.Pointer(what))
|
|
|
|
}
|
|
|
|
|
2014-04-01 15:30:38 -05:00
|
|
|
func fromgtklayout(x *C.GtkLayout) *C.GtkWidget {
|
|
|
|
return (*C.GtkWidget)(unsafe.Pointer(x))
|
2014-02-17 14:45:26 -06:00
|
|
|
}
|
|
|
|
|
2014-04-01 15:30:38 -05:00
|
|
|
func togtklayout(what *C.GtkWidget) *C.GtkLayout {
|
2014-03-15 13:27:18 -05:00
|
|
|
return (*C.GtkLayout)(unsafe.Pointer(what))
|
2014-02-17 14:45:26 -06:00
|
|
|
}
|
|
|
|
|
2014-04-01 15:30:38 -05:00
|
|
|
func fromgtkbutton(x *C.GtkButton) *C.GtkWidget {
|
|
|
|
return (*C.GtkWidget)(unsafe.Pointer(x))
|
2014-02-17 14:45:26 -06:00
|
|
|
}
|
|
|
|
|
2014-04-01 15:30:38 -05:00
|
|
|
func togtkbutton(what *C.GtkWidget) *C.GtkButton {
|
2014-02-17 14:45:26 -06:00
|
|
|
return (*C.GtkButton)(unsafe.Pointer(what))
|
|
|
|
}
|
|
|
|
|
2014-04-01 15:30:38 -05:00
|
|
|
func fromgtktogglebutton(x *C.GtkToggleButton) *C.GtkWidget {
|
|
|
|
return (*C.GtkWidget)(unsafe.Pointer(x))
|
2014-02-17 14:45:26 -06:00
|
|
|
}
|
|
|
|
|
2014-04-01 15:30:38 -05:00
|
|
|
func togtktogglebutton(what *C.GtkWidget) *C.GtkToggleButton {
|
2014-02-17 14:45:26 -06:00
|
|
|
return (*C.GtkToggleButton)(unsafe.Pointer(what))
|
|
|
|
}
|
|
|
|
|
2014-04-01 15:30:38 -05:00
|
|
|
func fromgtkcombobox(x *C.GtkComboBoxText) *C.GtkWidget {
|
|
|
|
return (*C.GtkWidget)(unsafe.Pointer(x))
|
2014-02-17 14:45:26 -06:00
|
|
|
}
|
|
|
|
|
2014-04-01 15:30:38 -05:00
|
|
|
func togtkcombobox(what *C.GtkWidget) *C.GtkComboBoxText {
|
2014-02-17 14:45:26 -06:00
|
|
|
return (*C.GtkComboBoxText)(unsafe.Pointer(what))
|
|
|
|
}
|
|
|
|
|
2014-04-01 15:30:38 -05:00
|
|
|
func fromgtkentry(x *C.GtkEntry) *C.GtkWidget {
|
|
|
|
return (*C.GtkWidget)(unsafe.Pointer(x))
|
2014-02-17 14:45:26 -06:00
|
|
|
}
|
|
|
|
|
2014-04-01 15:30:38 -05:00
|
|
|
func togtkentry(what *C.GtkWidget) *C.GtkEntry {
|
2014-02-17 14:45:26 -06:00
|
|
|
return (*C.GtkEntry)(unsafe.Pointer(what))
|
|
|
|
}
|
|
|
|
|
2014-04-01 15:30:38 -05:00
|
|
|
func fromgtklabel(x *C.GtkLabel) *C.GtkWidget {
|
|
|
|
return (*C.GtkWidget)(unsafe.Pointer(x))
|
2014-02-17 14:45:26 -06:00
|
|
|
}
|
|
|
|
|
2014-04-01 15:30:38 -05:00
|
|
|
func togtklabel(what *C.GtkWidget) *C.GtkLabel {
|
2014-02-17 14:45:26 -06:00
|
|
|
return (*C.GtkLabel)(unsafe.Pointer(what))
|
|
|
|
}
|
2014-02-24 23:48:23 -06:00
|
|
|
|
2014-04-01 15:30:38 -05:00
|
|
|
func fromgtkprogressbar(x *C.GtkProgressBar) *C.GtkWidget {
|
|
|
|
return (*C.GtkWidget)(unsafe.Pointer(x))
|
2014-02-24 23:48:23 -06:00
|
|
|
}
|
|
|
|
|
2014-04-01 15:30:38 -05:00
|
|
|
func togtkprogressbar(what *C.GtkWidget) *C.GtkProgressBar {
|
2014-02-24 23:48:23 -06:00
|
|
|
return (*C.GtkProgressBar)(unsafe.Pointer(what))
|
|
|
|
}
|