Vala does support passing a context argument, calling user_data to callbacks,
by this two methods(source: FAQ and Tutorial):
1. Passing this/self as user_data, for instance method.
2. Variables outside the lambda expression.
Method 2 is done perfectly by Vala, when we talk about lambda
private static void static_on_stop_clicked ([args], user_data_type user_data)
{
A copypaste mistake in method name. Please threat this as:
private static void method ([args], user_data_type user_data) {
From: tal...@hotmail.com
To: vala-list@gnome.org
Date: Mon, 10 Oct 2011 15:48:45 +0200
Why not just use lambda? From the Gtk+
examplehttp://live.gnome.org/Vala/GTKSample
:
var button = new Button.with_label (Click me!);
button.clicked.connect (() = {
button.label = Thank you;
this.my_data = 3;
});
And you can have that my_data be anything you want, an
Thanks for your answer Alexandre Rosenfeld, but you get me wrong.
Why not just use lambda? From the Gtk+ example:
Yes I know I can do this. I point this out in my post:
2. Variables outside the lambda expression.
Some prefer using lambda, some prefer using traditional methods.
Another quote I
I understand your problem, but you can still use lambdas. If you try to fool
the compiler into taking a pointer as a user data, you end up with reference
issues (what happens if no one uses the object but the signal handler?). The
easiest solution is to use lambdas, so that Vala manages the
I know this method, and I'm happy it's possible.
And no, I don't have problem at all while coding, I just think that Vala
shell support also other syntax.
I just wish Vala could use some thing like this:
another_object.my_signal.connect(user_data:my_method);
I wasn't a real C developer in my