Re: Signal handler args
- From: Dermot Musgrove <dermot glade perl connectfree co uk>
- To: goran kirra net
- Cc: "gtk-perl-list gnome org" <gtk-perl-list gnome org>, gc mandrakesoft com
- Subject: Re: Signal handler args
- Date: Tue, 22 Oct 2002 22:37:03 +0100
goran kirra net wrote:
Dermot,
I not too happy about the syntax myself,
but the behavior is consistent with how it is done in C
and probably in old gtk-perl(?)
No, old Gtk-Perl sends ($widget, @data) or ($widget, @data, $event)
but this means that you must know how many data items were connected
and IMO is confusing. I seem to remember that there was talk of changing
this to a single dataref instead of a list but it was too late as too
much code had been written with handlers like this.
We are still at a stage where we can make these choices and I would
_very_ much urge that we go with ($widget, $dataref) or, for events,
($widget, $dataref, $eventref). I reckon that this is an example of
making the Perl interfaces as perlish as possible.
The reason probably is that these signalhandlers are
most often different kind of beast.
You should be able to test the second arggument with
something like (untested code follows):
if (defined $arg2 and $arg2->isa("Gtk2::Gdk::Event"))
{
...
}
Or even $data = $arg3 || $arg2;
You could this or something more complex (as Randy pointed out) - but to
code it in many, many handlers seems a terrible waste of effort.
I am willing to change this in line with your
suggestion if we can reach consensus.
The only other approach that seems half sensible to me is to always pass
($widget, $eventref, $dataref) to handlers with undef or {} for the
$eventref if the handler is not for an event. I am not sure how elegant
this approach is though.
As long as the decision is made before too much Perl code is written
and we are stuck with something less than ideal I will be happy :)
Best regards, Dermot
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]