Re: [Vala] Houston we have a problem(gtk.builder signals not functioning)
- From: Frederik <scumm_fredo gmx net>
- To: vala-list <vala-list gnome org>
- Subject: Re: [Vala] Houston we have a problem(gtk.builder signals not functioning)
- Date: Fri, 09 Apr 2010 10:59:57 +0200
Am 08.04.2010 20:30, Karl Zollner wrote:
I have been a lurker here for a while and noticed a number of other posts
drawing attention to difficulties getting signals from glade-3(.ui xml
files) to work with handlers defined in ones source code.
This problem is now official. Signals are not getting properly connected. I
use the word official because I have tried this on multiple different
machines, real and vms, with different versions of vala and glade-3
(including git current vala and glade-3). And in no combination does
build.connect_signals actually result in a working program- in most cases
error message just reports 'cannot find blah-blah-on-button-clicked signal',
but in other case there is just an abrupt segmentaion fault.
There are 3 common error sources when using Gtk.Builder with Vala, your problem
is probably related to one of them:
1) Forgetting to use [CCode (instance_pos = -1)] when using instance
methods instead of static methods as handlers
2) Forgetting to mangle the handler method names in Glade, e.g. from
'FooBar.my_handler' to 'foo_bar_my_handler'
3) Not using the right signature for the handler. One missing parameter
or one parameter to much will result in a segmentation fault. If the
signal signature is
public class Area : Object {
public signal void clicked (int x, int y);
}
then the handler method must have *exactly* these parameters in order
to work with Gtk.Builder's auto-connect:
[CCode (instance_pos = -1)]
public void on_clicked (Area source, int x, int y) { }
Vala can't recognize this mistake, because auto-connection happens at
runtime an it doesn't know at compile-time which method will be connected
to which signal.
One solution to make auto-connection more type safe and more convenient to
use could be to introduce a new attribute in Vala, something like:
[AutoConnectHandler (signal = "Area.clicked")]
public void on_clicked (Area source, int x, int y) { }
so that Vala could do a method signature check at compile-time.
Best regards,
Frederik
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]