Re: Confused about $data=undef in API documentation





On Sat, Jul 11, 2009 at 12:15 PM, muppet <scott asofyet org> wrote:

On Jul 11, 2009, at 10:58 AM, Joseph Thames wrote:

Hello,

I am confused about your use of $data="" in the Glib documentation, as in:

unsigned = $instance->signal_connect ($detailed_signal, $callback, $data="">        • $detailed_signal (string)
       • $callback (subroutine)
       • $data (scalar) arbitrary data to be passed to each invocation of callback

Does this simply mean that undef (NULL) is the default value of the $data parameter, or does it mean that passing unique user_data to a callback is not yet supported in this API?

Yes, it means that if you don't specify that argument, it will be treated as though you passed undef.  The syntax is borrowed from C++'s default parameters.

I thought so, thanks for confirming that.


I am trying to figure out a way to employ a common callback function for an "unlimited" number of menu items (determined at run-time) by passing unique user_data for each signal.

This does not seem to be supported by the $builder->connect_signals method, which can only pass the same user_data to a group of unique callback functions.

Your single callback is free to inspect the widget / object names (as set in the xml) and dispatch to the correct place based on that.

Ok, now I understand. I think I was misled by most of the examples, which all seem to show callbacks statically the same as the Glade-specified menuitem names.

Thanks again.



--
Doing a good job around here is like wetting your pants in a dark suit; you get a warm feeling, but no one notices.
 -- unknown





--
Joseph 'Bear' Thames
Meta Science Foundation
(505) 977-9024 - Cell Phone
beartham gmail com


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]