summaryrefslogtreecommitdiff
path: root/callbacks_unix.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-02-16 17:09:58 -0500
committerPietro Gagliardi <[email protected]>2014-02-16 17:09:58 -0500
commit1bcbce414287a9eecfd291522f4a8e2dd0c28102 (patch)
tree865fe3950f4c37545748f1f6429bea5f951689bc /callbacks_unix.go
parentf5652737ebbd44310a7a19815c88f7f83d67a3a9 (diff)
Cleaned up the idle callback code.
Diffstat (limited to 'callbacks_unix.go')
-rw-r--r--callbacks_unix.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/callbacks_unix.go b/callbacks_unix.go
index d47d67d..dd29399 100644
--- a/callbacks_unix.go
+++ b/callbacks_unix.go
@@ -9,19 +9,28 @@ import (
/*
cgo doesn't support calling Go functions by default; we have to mark them for export. Not a problem, except arguments to GTK+ callbacks depend on the callback itself. Since we're generating callback functions as simple closures of one type, this file will wrap the generated callbacks in the appropriate callback type. We pass the actual generated pointer to the extra data parameter of the callback.
+
+while we're at it the callback for our idle function will be handled here too for cleanliness purposes
*/
// #cgo pkg-config: gtk+-3.0
// #include <gtk/gtk.h>
+// extern gboolean our_callback(gpointer);
// extern gboolean our_delete_event_callback(GtkWidget *, GdkEvent *, gpointer);
import "C"
-//export our_delete_event_callback
-func our_delete_event_callback(widget *C.GtkWidget, event *C.GdkEvent, what C.gpointer) C.gboolean {
+//export our_callback
+func our_callback(what C.gpointer) C.gboolean {
f := *(*func() bool)(unsafe.Pointer(what))
return togbool(f())
}
+//export our_delete_event_callback
+func our_delete_event_callback(widget *C.GtkWidget, event *C.GdkEvent, what C.gpointer) C.gboolean {
+ return our_callback(what)
+}
+
var callbacks = map[string]C.GCallback{
+ "idle": C.GCallback(C.our_callback),
"delete-event": C.GCallback(C.our_delete_event_callback),
}