Re: libglade connections
| From: | Steph Fox | Date: | Mon, 07 Nov 2005 20:12:27 +0000 |
| Subject: | Re: libglade connections | ||
| References: | 1 2 3 4 5 6 | Groups: | php.gtk.dev |
| Request: | Send a blank email to php-gtk-dev+get-2070@lists.php.net to get a copy of this message | ||
hmm, that'd cut out the middle-man alright...
We already have the ability to do that with static methods, but it would be
kind of nice to be able to do it for non-static calls too. It'd save devs
having to write a lot of tiny functions and pass objects to them via
autoconnect arrays...
Glade simply makes -> into -> in the generated file, so we could even use
that as the 'identifier' tag directly. The only trouble with going
non-standard in this way would be that wrappers written in other languages
won't be able to use glade files written for use with PHP... (but then we
already have that issue through having :: rather than _ for internal static
calls, so how much do we care about it?)
The only problem I can see isn't one of implementation, it's back to the
'design vs development' discussion we had a few weeks back, probably
off-list, I don't remember. We're heading further from what Glade actually
does here, which is to offer a range of potential static GTK+ handlers for
the given widget, or a default signal handler name if none is chosen. The
further we get from that, the less Glade is a design tool and the more it
becomes a programming tool. But TBH I don't think signal handlers should
really be in the sphere of design anyway... so my gut instinct is 'yeah,
sounds like a great idea Andrei!'
All that said, I can't get signal_autoconnect() to work properly in the
'array of arrays' sense here, although it's fine in every other respect.
Jeremy - if you're staring into space a lot at the conference, would you
mind testing it properly? It's possible (nay, downright likely) I'm doing
some Bad Thing on the glade/php side when I try.
- Steph
----- Original Message -----
From: "Andrei Zmievski" <andrei@gravitonic.com>
To: "Steph Fox" <steph@zend.com>
Cc: "PHP-GTK dev" <php-gtk-dev@lists.php.net>
Sent: Monday, November 07, 2005 6:37 PM
Subject: Re: [PHP-GTK-DEV] libglade connections
> Hey,
>
> I don't have time to research it right now. But I had an idea for
> another type of signal connection, if you actually wanted to connect to
> a method of a Glade object. Suppose you have a button called 'button1'
> which is inside a window called 'window1'. And you wanted to connect
> button1's "clicked" signal so that it invokes window1's destroy()
> method. In regular PHP-GTK you would do:
>
> $button->connect_simple('clicked', array($window, 'destroy'));
>
> In Glade I think we can do it by specifying the handler as
> "window1->destroy". I can easily write code to parse this and connect
> things properly. But here we do need to differentiate between simple
> and normal connections (or even replaced ones), so prefixing it with
> something may be useful.
>
> -Andrei
>
> On Nov 7, 2005, at 1:54 AM, Steph Fox wrote:
>
> > Hey Andrei,
> >
> > OK, I tried to think of one example when a calling object might need
> > to be
> > carried as part of the signal to a _static_ function or method, and I
> > honestly can't. Heck, Glade 2 doesn't even allow for it, and I can't
> > think
> > of anywhere GTK+ does either, and this is a wrapper around libglade
> > _as it
> > exists_, not as it may be in the future.
> >
> > Where the calling object's passed to the callback with the signal, it's
> > never a static call. How could it be? How could you have
> > $window->Gtk::main()? You might have a callback like
> > GtkContainer::do_stuff($container), but that's catered for...
> >
> > If you (or anyone?) can come up with any serious examples that render
> > those
> > arguments invalid, please do so and I'll revert (albeit unhappily,
> > because I
> > think the existing solution's a good one). Remember, this doesn't
> > affect
> > static methods belonging to classes created in user space - it's purely
> > about internal class methods.
> >
> > - Steph
> >
> >
> > ----- Original Message -----
> > From: "Andrei Zmievski" <andrei@gravitonic.com>
> > To: "Steph Fox" <steph@zend.com>
> > Cc: "PHP-GTK dev" <php-gtk-dev@lists.php.net>
> > Sent: Sunday, November 06, 2005 9:15 PM
> > Subject: Re: [PHP-GTK-DEV] libglade connections
> >
> >
> >> "640k should be enough for everybody"
> >>
> >> -Andrei
> >>
> >>
> >> On Nov 5, 2005, at 10:47 AM, Steph Fox wrote:
> >>
> >>> There should never be any... put it this way, there never have been.
> >>>
> >>> ----- Original Message -----
> >>> From: "Andrei Zmievski" <andrei@gravitonic.com>
> >>> To: "Steph Fox" <steph@zend.com>
> >>> Cc: "PHP-GTK dev" <php-gtk-dev@lists.php.net>
> >>> Sent: Saturday, November 05, 2005 6:40 PM
> >>> Subject: Re: [PHP-GTK-DEV] libglade connections
> >>>
> >>>
> >>>
> >>>> Bah, thanks for consulting me too.
> >>>>
> >>>> This is not as simple as it looks. Can you guarantee that any
> >>>> internal class method that .glade file may wish to connect to will
> >>>> need only simple connection? What if there are methods that actually
> >>>> need to have the signal widget?
> >>>>
> >>>> -Andrei
> >>>>
> >>>>
> >>>> On Nov 5, 2005, at 10:22 AM, Steph Fox wrote:
> >>>>
> >>>>
> >>>>> Thanks to the irc gang (Rob, Wez, Derick), the need for a tag just
> >>>>> left the
> >>>>> building.
> >>>>>
> >>>>> All systems go :)
> >>>>>
> >>>>> ----- Original Message -----
> >>>>> From: "Steph Fox" <steph@zend.com>
> >>>>> To: "Andrei" <andrei@gravitonic.com>
> >>>>> Cc: "PHP-GTK dev" <php-gtk-dev@lists.php.net>
> >>>>> Sent: Saturday, November 05, 2005 4:08 PM
> >>>>> Subject: Fw: [PHP-GTK-DEV] libglade connections
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>> ps signal_autoconnect_instance() is brilliant :)
> >>>>>>
> >>>>>> The only remaining problem's having to tag those statics, we
> >>>>>> shouldn't
> >>>>>>
> >>>>>>
> >>>>> need
> >>>>>
> >>>>>
> >>>>>> to do that.
> >>>>>>
> >>>>>> ----- Original Message -----
> >>>>>> From: "Steph Fox" <steph@zend.com>
> >>>>>> To: "Andrei" <andrei@gravitonic.com>
> >>>>>> Cc: "PHP-GTK dev" <php-gtk-dev@lists.php.net>
> >>>>>> Sent: Saturday, November 05, 2005 3:59 PM
> >>>>>> Subject: Fw: [PHP-GTK-DEV] libglade connections
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>> OK, crash gorn.
> >>>>>>>
> >>>>>>> Statics still weird. I don't get the '-'
> >>>>>>> reference...
> >>>>>>>
> >>>>>>> ----- Original Message -----
> >>>>>>> From: "Steph Fox" <steph@zend.com>
> >>>>>>> To: "Andrei" <andrei@gravitonic.com>
> >>>>>>> Cc: "PHP-GTK dev" <php-gtk-dev@lists.php.net>
> >>>>>>> Sent: Saturday, November 05, 2005 3:25 PM
> >>>>>>> Subject: [PHP-GTK-DEV] libglade connections
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>> Andrei,
> >>>>>>>>
> >>>>>>>> I just tested some of the changes using a bog-standard
> >>>>>>>> no-clever-object-business test script. signal_autoconnect()
> >>>>>>>> works for
> >>>>>>>> everything except static calls (i.e. gtk::main_quit
> >>>>>>>> doesn't work
> >>>>>>>> any
> >>>>>>>>
> >>>>>>>>
> >>>>>>> more),
> >>>>>>>
> >>>>>>>
> >>>>>>>> no leaks, congrats (but can we have our static support back
> >>>>>>>> please? -
> >>>>>>>>
> >>>>>>>>
> >>>>>>> since
> >>>>>>>
> >>>>>>>
> >>>>>>>> Glade actually encourages it. At present it's seen as a
> >>>>>>>> straight
> >>>>>>>> connect() - it needs to go as connect_simple()).
> >>>>>>>>
> >>>>>>>> signal_connect() crashes whatever you try to do to it,
> >>>>>>>> haven't
> >>>>>>>>
> >>>>>>>>
> >>>>>>> investigated
> >>>>>>>
> >>>>>>>
> >>>>>>>> why yet.
> >>>>>>>>
> >>>>>>>> Mind if I play?
> >>>>>>>>
> >>>>>>>> - Steph
> >>>>>>>>
> >>>>>>>> --
> >>>>>>>> PHP-GTK Development Mailing List (http://gtk.php.net/)
> >>>>>>>> To unsubscribe, visit:
> >>>>>>>> http://www.php.net/unsub.php
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>
> >>>>>>> --
> >>>>>>> PHP-GTK Development Mailing List (http://gtk.php.net/)
> >>>>>>> To unsubscribe, visit:
> >>>>>>> http://www.php.net/unsub.php
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>
> >>>>>> --
> >>>>>> PHP-GTK Development Mailing List (http://gtk.php.net/)
> >>>>>> To unsubscribe, visit:
> >>>>>> http://www.php.net/unsub.php
> >>>>>>
> >>>>>>
> >>>>>
> >>>>>
> >>>>
> >>>>
> >>>
> >>> --
> >>> PHP-GTK Development Mailing List (http://gtk.php.net/)
> >>> To unsubscribe, visit:
> >>> http://www.php.net/unsub.php
> >>>
> >>
>
> --
> PHP-GTK Development Mailing List (http://gtk.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>