Re: GladeXML: signal_autoconnect to an object?
| From: | Steph Fox | Date: | Tue, 25 Oct 2005 01:16:24 +0000 |
| Subject: | Re: GladeXML: signal_autoconnect to an object? | ||
| References: | 1 | Groups: | php.gtk.dev |
| Request: | Send a blank email to php-gtk-dev+get-1927@lists.php.net to get a copy of this message | ||
I just added support for this into CVS.
Staying with your example below, you need to declare either
"self::btnClicked" or "MyApp::btnClicked" as the callback handler within the
Glade file, rather than plain-vanilla "btnClicked".
Adding any parameter to the signal_autoconnect() call simply passes that
data to the callback(s), no change there.
I'd like to make static GTK calls work in a similar way to this - especially
main_quit, for obvious reasons! - but that'll take a little more umming and
ahhing over here... at present there's always an object passed to the
callback, exactly as if connect() were being called.
----- Original Message -----
From: "Steph Fox" <steph@zend.com>
To: "Christian Weiske" <cweiske@cweiske.de>; "PHP-GTK dev"
<php-gtk-dev@lists.php.net>
Sent: Monday, October 24, 2005 7:44 PM
Subject: Re: [PHP-GTK-DEV] GladeXML: signal_autoconnect to an object?
> OK, I can see how to do it I think (looking at Zend API), but you'd need
to
> change your handler name within the Glade file, not within PHP.
>
> ----- Original Message -----
> From: "Steph Fox" <steph@zend.com>
> To: "Christian Weiske" <cweiske@cweiske.de>
> Sent: Monday, October 24, 2005 7:32 PM
> Subject: Re: [PHP-GTK-DEV] GladeXML: signal_autoconnect to an object?
>
>
> > hrrrrrrrrmm... passing an object as a parameter works in the sense that
> > signal->autoconnect($button) would pass $button to each callback
function,
> > not in the sense that $button would be the object 'owning' the callback,
> so
> > there's a syntactic error in that concept, although obviously:
> >
> > $glade->signal_connect('btnClicked', array($this, 'btnClicked'));
> >
> > would work.
> >
> > I'll look into it... I can see how it would be useful.
> >
> >
> > ----- Original Message -----
> > From: "Christian Weiske" <cweiske@cweiske.de>
> > To: "Steph Fox" <steph@zend.com>
> > Sent: Monday, October 24, 2005 6:39 PM
> > Subject: Re: [PHP-GTK-DEV] GladeXML: signal_autoconnect to an object?
> >
> >
> > > Steph,
> > >
> > > > Sample pseudocode?
> > > Assume I have a glade file with a button, and that button's "clicked"
> > > signal has been connected to the "btnClicked" function.
> > > Now when doing a $glade->signal_autoconnect(), I have to have the
> > > following code:
> > >
> > > <?php
> > > $glade = null;//load glade here
> > > $glade->signal_autoconnect();
> > >
> > > function btnClicked()
> > > {
> > > echo "button has been clicked";
> > > }
> > > ?>
> > >
> > >
> > > However, I want to be able to do the following:
> > > <?php
> > > class MyApp
> > > {
> > > function init() {
> > > $glade = null;//load glade here
> > > $glade->signal_autoconnect($this);
> > >
> > > }
> > >
> > > function btnClicked()
> > > {
> > > echo "button has been clicked";
> > > }
> > > }
> > > $app = new MyApp();
> > > $app->init();
> > > ?>
> > >
> > >
> > > --
> > > Regards/MfG,
> > > Christian Weiske
> >
>
> --
> PHP-GTK Development Mailing List (http://gtk.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>