Fw: [PHP-GTK-DEV] Connection methods
| From: | Steph | Date: | Sun, 16 Oct 2005 15:50:37 +0000 |
| Subject: | Fw: [PHP-GTK-DEV] Connection methods | ||
| Groups: | php.gtk.dev | ||
| Request: | Send a blank email to php-gtk-dev+get-1836@lists.php.net to get a copy of this message | ||
OK, now I've experimented you can forget my first paragraph earlier, you'd
just use connect_simple() there because there aren't any signal parameter
values you'd need to consider.
In GTK 2 tests the place connect_swapped() is most often used is:
g_signal_connect_swapped (button, "clicked", G_CALLBACK
(gtk_widget_destroy), window);
which we can do without needing connect_swapped(), for the same reason.
I'm still wondering about what happens if you want to differentiate a
right-click from a left-click in the callback, e.g. to bring up a
context-driven popup menu? What if the callback was a flexible one that
could be called from any of several widgets and/or in any of several ways?
We have workarounds for the event signals group, in the shape of
gtk::get_current_event(), $event->type, and gtk::get_event_widget($event),
so we don't necessarily need to pass $event as a signal parameter - but
would these cater for every situation? What happens when, for example, row
and column data are passed as signal parameters - are these _always_ the
kind of signals that use connect()?
I agree we could do with some real-life examples, but I'm the last person to
have any. Perhaps Pablo, Madeleine or Tom could argue more convincingly, or
prove me wrong?
----- Original Message -----
From: "Steph" <steph@zend.com>
To: "Andrei Zmievski" <andrei@gravitonic.com>
Cc: "PHP DEV" <php-gtk-dev@lists.php.net>; "Scott Mattocks"
<scott@crisscott.com>
Sent: Sunday, October 16, 2005 1:58 PM
Subject: Re: [PHP-GTK-DEV] Connection methods
> The one just about everyone uses is $window->connect_object('destroy',
> array('gtk', 'main_quit'));
>
> It'd be confusing (and pointless) if you also passed $window, and it'd get
> needlessly complicated if you just used a straight connect() call.
>
> You'd also use it anywhere you didn't want to pass the initial object but
> wanted to use one of its signals, and that does arise a fair deal.
> Sometimes you'll need the signal's parameters to be passed too, sometimes
> you won't. In event signals it's fairly common to want to do something
with
> $event as well as with your user data (ie other widgets etc), but at
present
> we don't have a way of passing $event without passing the initial object.
>
>
> ----- Original Message -----
> From: "Andrei Zmievski" <andrei@gravitonic.com>
> To: "Steph" <steph@zend.com>
> Cc: "PHP DEV" <php-gtk-dev@lists.php.net>; "Scott Mattocks"
> <scott@crisscott.com>
> Sent: Friday, October 14, 2005 9:40 PM
> Subject: Re: [PHP-GTK-DEV] Connection methods
>
>
> > Can you please an example of this?
> >
> > -Andrei
> >
> > On Oct 14, 2005, at 12:37 PM, Steph wrote:
> >
> > > Yes, because if you want to do something with an object that isn't
> > > responsible for emitting the signal, it makes the code much more
> > > readable if
> > > you use connect_object() or something equivalent. Think about
> > > key-press-event signal and such.
> > >
> > > We do need connect_replace() then...
> > >
> > > Gone!
> > >
> > > ----- Original Message -----
> > > From: "Andrei Zmievski" <andrei@gravitonic.com>
> > > To: "Steph" <steph@zend.com>
> > > Cc: "PHP DEV" <php-gtk-dev@lists.php.net>; "Scott Mattocks"
> > > <scott@crisscott.com>
> > > Sent: Friday, October 14, 2005 8:29 PM
> > > Subject: Re: [PHP-GTK-DEV] Connection methods
> > >
> > >
> > >> No, connect_replace() would *not* act like connect_object(). It would
> > >> substitute user-specified object instead of the signal one, e.g.:
> > >>
> > >> $drawarea->connect_object('button_press_event',
> > >> 'process_object',
> > >> $anotherarea);
> > >>
> > >> function process_object($event, $anotherarea)
> > >> {
> > >> /* note that $anotherarea is passed after event */
> > >> }
> > >>
> > >> $drawarea->connect_replace('button_press_event',
> > >> 'process_replace',
> > >> $anotherarea);
> > >>
> > >> function process_replace($anotherarea, $event)
> > >> {
> > >> /* note that $anotherarea is passed in place of the signal widget */
> > >> }
> > >>
> > >> And also I'm curious, why do you need connect_object() or
> > >> connect_replace()? Any specific reason?
> > >>
> > >> -Andrei
> > >>
> > >>
> > >> On Oct 14, 2005, at 11:18 AM, Steph wrote:
> > >>
> > >>> No, it's probably me that's confused :) I'm not good when it
> > >>> comes
> > >>> to
> > >>> discussing things theoretically rather than in practical terms.
> > >>>
> > >>> So what are you saying, Andrei - connect_simple() will _only_ pass
> > >>> user
> > >>> data, and connect_replace() will act as connect_object() did?
> > >>>
> > >>> If so we do need connect_replace()....
> > >>>
> > >>>
> > >>
> >
>
> --
> PHP-GTK Development Mailing List (http://gtk.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>