summaryrefslogtreecommitdiff
path: root/gtkcalls_unix.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-03-14 20:03:02 -0400
committerPietro Gagliardi <[email protected]>2014-03-14 20:03:02 -0400
commita7f7ea1b8da51a19aaca7d5d989a28f0c9ecbf94 (patch)
treea054a7abea61eb6d9eb8bd16f807de99494d0d0e /gtkcalls_unix.go
parentaf7a218b473e8602ad818dbf9688efa5d3594648 (diff)
Major overhaul of the way GTK+ events are handled. Closures that perform events are no longer generated; instead all events are given to fixed, compile-time, cgo-exported callback functions that take the sysData as user data. This saves memory (we no longer need to generate closures and we no longer have to save them elsewhere to keep them from being garbage collected) and makes the top of sysdata_unix.go slightly cleaner, but it moves the code for handling UI events into callbacks_unix.go. This is needed for Area, in which we need to feed the sysData to an event connected to a subwidget instead of the main widget returned.
Diffstat (limited to 'gtkcalls_unix.go')
-rw-r--r--gtkcalls_unix.go23
1 files changed, 0 insertions, 23 deletions
diff --git a/gtkcalls_unix.go b/gtkcalls_unix.go
index 5d3702d..f2bce9e 100644
--- a/gtkcalls_unix.go
+++ b/gtkcalls_unix.go
@@ -12,8 +12,6 @@ import (
// #cgo pkg-config: gtk+-3.0
// #include <stdlib.h>
// #include <gtk/gtk.h>
-// /* because cgo is flaky with macros */
-// void gSignalConnect(GtkWidget *widget, char *signal, GCallback callback, void *data) { g_signal_connect(widget, signal, callback, data); }
import "C"
type (
@@ -25,16 +23,6 @@ func gtk_init() bool {
return fromgbool(C.gtk_init_check((*C.int)(nil), (***C.char)(nil)))
}
-// see our_idle_callback in callbacks_unix.go for details
-type gtkIdleOp struct {
- what func()
- done chan struct{}
-}
-
-func gdk_threads_add_idle(idleop *gtkIdleOp) {
- C.gdk_threads_add_idle(callbacks["idle"], C.gpointer(unsafe.Pointer(idleop)))
-}
-
func gtk_main() {
C.gtk_main()
}
@@ -48,17 +36,6 @@ func gtk_window_new() *gtkWidget {
return fromgtkwidget(C.gtk_window_new(0))
}
-// the garbage collector has been found to eat my callback functions; this will stop it
-var callbackstore = make([]*func() bool, 0, 50)
-
-func g_signal_connect(obj *gtkWidget, sig string, callback func() bool) {
- callbackstore = append(callbackstore, &callback)
- ccallback := callbacks[sig]
- csig := C.CString(sig)
- defer C.free(unsafe.Pointer(csig))
- C.gSignalConnect(togtkwidget(obj), csig, ccallback, unsafe.Pointer(&callback))
-}
-
// TODO ensure this works if called on an individual control
func gtk_widget_show(widget *gtkWidget) {
C.gtk_widget_show_all(togtkwidget(widget))