Added basic signal connection. I'm going to need to build a different callback system, though...

This commit is contained in:
Pietro Gagliardi 2014-02-16 16:23:49 -05:00
parent 21c1ec6f83
commit c40b7b5599
2 changed files with 19 additions and 0 deletions

View File

@ -21,6 +21,10 @@ import "C"
type (
gtkWidget C.GtkWidget
// these are needed for signals
gdkEvent C.GdkEvent
gpointer C.gpointer
)
func fromgbool(b C.gboolean) bool {

View File

@ -18,12 +18,24 @@ type sysData struct {
type classData struct {
make func() *gtkWidget
setText func(widget *gtkWidget, text string)
// ...
signals map[string]func(*sysData) interface{}
}
var classTypes = [nctypes]*classData{
c_window: &classData{
make: gtk_window_new,
setText: gtk_window_set_title,
signals: map[string]func(*sysData) interface{}{
"delete-event": func(w *sysData) interface{} {
return func(*gtkWidget, *gdkEvent, gpointer) bool {
if w.event != nil {
w.event <- struct{}{}
}
return true // do not close the window
}
},
},
},
c_button: &classData{
// make: gtk_button_new,
@ -57,6 +69,9 @@ println(s.widget)
uitask <- func() {
fixed := gtk_fixed_new()
gtk_container_add(s.widget, fixed)
for signal, generator := range ct.signals {
g_signal_connect(s.widget, signal, generator(s))
}
ret <- fixed
}
s.container = <-ret