conformal / gotk3

Go bindings for GTK3
ISC License
470 stars 81 forks source link

go version of: gtk_builder_connect_signals( builder, NULL ); #50

Open comaldave opened 10 years ago

comaldave commented 10 years ago

I was following tutorial for glade and in reading this line in c++, I could not find the equivalent for go. Demo is running well otherwise. Very nice package!

/* Connect signals */ gtk_builder_connect_signals( builder, NULL );

jrick commented 10 years ago

Admittedly I don't use the Builder, but according to the gtk documentation, this connects the signals that have been already added to the builder with previous calls to gtk_builder_add_callback_symbol. I'm not sure how others use the Builder, but I think implementing gtk_builder_add_callback_symbol would have to be a first step.

The tricky part there is that gtk_builder_add_callback_symbol takes a C function pointer. I'll have to see if any of the glib closure code can be reused for this, so we would be able to call Go closures when a signal is emitted, just like when using Connect.

marcioAlmada commented 10 years ago

:+1: this is very important

marcioAlmada commented 10 years ago

Just found out that go-gtk package has this implemented https://github.com/mattn/go-gtk/blob/c61f51135f7d96ba6fdccdd88fdc5eb042ec967f/gtk/gtk.go#L9938-L9940

This example might help: https://github.com/mattn/go-gtk/tree/c61f51135f7d96ba6fdccdd88fdc5eb042ec967f/example/builder

I tried to implement the same methods on gotk3 but I'm stuck with error:

(main:28716): Gtk-WARNING **: Could not find signal handler 'signalName'.  Did you compile with -rdynamic?

Anyway, hope it helps.