Confused about $data=undef in API documentation
Hello, I am confused about your use of $data=undef in the Glib documentation, as in: unsigned = $instance->*signal_connect* ($detailed_signal, $callback, $data=undef) - $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? 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. Thanks in advance, beartham -- Joseph 'Bear' Thames Meta Science Foundation (505) 977-9024 - Cell Phone beart...@gmail.com ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Confused about $data=undef in API documentation
On Jul 11, 2009, at 10:58 AM, Joseph Thames wrote: Hello, I am confused about your use of $data=undef in the Glib documentation, as in: unsigned = $instance->signal_connect ($detailed_signal, $callback, $data=undef) • $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 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. -- 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 ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Confused about $data=undef in API documentation
On Sat, Jul 11, 2009 at 12:15 PM, muppet wrote: > > On Jul 11, 2009, at 10:58 AM, Joseph Thames wrote: > > Hello, >> >> I am confused about your use of $data=undef in the Glib documentation, as >> in: >> > > unsigned = $instance->signal_connect ($detailed_signal, $callback, >> $data=undef) >>• $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 beart...@gmail.com ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: Confused about $data=undef in API documentation
Joseph Thames wrote: > 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. You understand perfectly how to write a patch for the docs so they are clearer, then :) Cheers, Dave ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list