2014-07-17 22:50:14 -05:00
|
|
|
// +build !windows,!darwin
|
2014-07-08 15:47:28 -05:00
|
|
|
|
2014-07-07 21:46:23 -05:00
|
|
|
// 7 july 2014
|
|
|
|
|
|
|
|
package ui
|
|
|
|
|
|
|
|
import (
|
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
|
|
|
// #include "gtk_unix.h"
|
2014-07-08 11:04:51 -05:00
|
|
|
// /* because cgo doesn't like g_signal_connect() */
|
|
|
|
// void gSignalConnect(gpointer obj, gchar *sig, GCallback callback, gpointer data)
|
|
|
|
// {
|
|
|
|
// g_signal_connect(obj, sig, callback, data);
|
|
|
|
// }
|
2014-07-18 18:36:29 -05:00
|
|
|
// void gSignalConnectAfter(gpointer obj, gchar *sig, GCallback callback, gpointer data)
|
|
|
|
// {
|
|
|
|
// g_signal_connect_after(obj, sig, callback, data);
|
|
|
|
// }
|
2014-07-07 21:46:23 -05:00
|
|
|
import "C"
|
|
|
|
|
|
|
|
func fromgstr(s *C.gchar) string {
|
|
|
|
return C.GoString((*C.char)(unsafe.Pointer(s)))
|
|
|
|
}
|
|
|
|
|
|
|
|
func togstr(s string) *C.gchar {
|
|
|
|
return (*C.gchar)(unsafe.Pointer(C.CString(s)))
|
|
|
|
}
|
|
|
|
|
|
|
|
func freegstr(s *C.gchar) {
|
|
|
|
C.free(unsafe.Pointer(s))
|
|
|
|
}
|
2014-07-08 11:04:51 -05:00
|
|
|
|
2014-07-21 20:07:14 -05:00
|
|
|
func fromgbool(b C.gboolean) bool {
|
|
|
|
return b != C.FALSE
|
|
|
|
}
|
|
|
|
|
|
|
|
func togbool(b bool) C.gboolean {
|
|
|
|
if b == true {
|
|
|
|
return C.TRUE
|
|
|
|
}
|
|
|
|
return C.FALSE
|
|
|
|
}
|
|
|
|
|
2014-07-08 11:04:51 -05:00
|
|
|
func g_signal_connect(object C.gpointer, name string, to C.GCallback, data C.gpointer) {
|
|
|
|
cname := togstr(name)
|
|
|
|
defer freegstr(cname)
|
|
|
|
C.gSignalConnect(object, cname, to, data)
|
|
|
|
}
|
2014-07-18 18:36:29 -05:00
|
|
|
|
|
|
|
func g_signal_connect_after(object C.gpointer, name string, to C.GCallback, data C.gpointer) {
|
|
|
|
cname := togstr(name)
|
|
|
|
defer freegstr(cname)
|
|
|
|
C.gSignalConnectAfter(object, cname, to, data)
|
|
|
|
}
|