Re: [Language Binders] Re: Chaining Class Closures
- From: Owen Taylor <otaylor redhat com>
- To: James Henstridge <james daa com au>
- Cc: Tim Janik <timj gtk org>,	Gtk+ Developers <gtk-devel-list gnome org>
- Subject: Re: [Language Binders] Re: Chaining Class Closures
- Date: 29 Oct 2001 23:55:10 -0500
James Henstridge <james daa com au> writes:
> Tim Janik wrote:
> 
> >On Tue, 30 Oct 2001, James Henstridge wrote:
> >
> >>  class PythonWidget(gtk.Widget):
> >>      def do_show(self, invocation_hint):
> >>          print "show!"
> >>          return invocation_hint()  # or possibly pass the self arg as well?
The name invocation_hint() here could certainly be improved - confused
me for some minutes, even being vaguely familiar with the underlying
GSignal mechanics. Using a name like "chain_up_func" - that is  
return chain_up_func() would be clearer. 
[ The example is also confusing because show() doesn't have a return
  value, so the return here is extraneous, if not harmful in Python ]
I must admit, this strikes me as ugly magic. I'd certainly expect
do_show() to look like:
  class PythonWidget(gtk.Widget):
      def do_show(self):
          print "show!"
          gtk.Widget.do_show(self)
That is, chaining in PyGtk should look like chaining in Python.
What are the barriers to this:
 - You have to get the GSignalInvocationHint *. This shouldn't
   be a big problem -- you can just keep a (per-thread) stack
   of current invocations. I think I suggested at one point
   to Tim that the chain-up-function should look more like:
   void g_signal_chain_from_overridden (GObject               *object,
                                        guint                  signal_id,
                                        GValue                *return_value,
                                        const GValue          *param_values);
   Where the first two parameter provide checking against the 
   GSignalInvocationHint at the top of GObject's stack of current
   invocations. But the same thing could be done in the language
   binding.
 - You have to provide gtk.Widget.do_show(). Doesn't sound
   to hard to do in Python, even dynamically at the 
   time the "override" is registered, if there isn't one already
   registered.
Regards,
                                        Owen
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]