În data de Jo, 07-05-2009 la 20:18 +0000, Jan Hudec a scris:
> Adi Roiban <a...@...> writes:
> > În data de Mi, 06-05-2009 la 17:48 +0000, Jan Hudec a scris:
[snip]
> > For example in the case of MenuItem, we have the "activated" signal and
> > there is not way to pass userdata when connecting the signal.
> > The method called for the "activate" signal will only receive a pointer
> > to the MenuItem... and I can not pass userdata.
> False!
> 
> You can always specify a user data for g_signal_connect(). Vala uses
> that pointer to pass in the *invocant* of the handler. So all you have to do
> is create an object describing the action to take and connect it's instance
> method (*not* static) to the activated signal of the menu item.
Thank you very much for you explanations!

I don't know how to connect userdata. Can you point me to some
documentation?

Reading the Vala wiki pages I know I can use this syntax:

menuItem.activated += (sender) => {doSomething(sender)};

Where should I fit the userdata?

> Alternatively, you can simply attach data to the MenuItem using the
> Glib::Object method set_data (and corresponding get_data to read them).

I didn't knew about this nice feature of GObject. Thanks!

> > Maybe this is a problem with GTK bindings for Vala.
> 
> I see the only problem in that it might not be immediately obvious
> where the data argument of g_signal_connect has gone and how to use it.
You are right, in this case the problem is between the chair and
keyboard :D

Cheers!
-- 
Adi Roiban

_______________________________________________
Vala-list mailing list
Vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to