Re: g_signal_lookup for interfaces



Tim Janik <timj gtk org> writes:

> On Thu, 18 Oct 2001, James Henstridge wrote:
> 
> > Bill Haneman wrote:
> > 
> > >Hi:
> > >
> > >I guess this one is for you, Tim...
> > >
> > >We have defined a number of signals in ATK on interfaces.  We know we 
> > >can't define properties on interfaces now, but we have been using 
> > >signals on interfaces, which is supported.
> > >
> > >However in order to intercept these signals we need to register an 
> > >emission hook.  In the bridge to at-spi this is done via a string-based 
> > >register call containing the names of the signal and type.
> > >[where type_name = "AtkText", signal_name = "text-caret-moved"]
> > >
> > >GType *type = g_type_from_name(type_name);
> > >
> > >However, if we call 
> > >
> > >g_signal_lookup (signal_name, type); 
> > >
> > Calling the atk_text_get_type() function for your interface doesn't 
> > guarantee your atk_text_base_init() function will be called (this is 
> > delayed til the first time the interface is used (ie. getting the class 
> > pointer for a type implementing the interface).  Not sure how best to 
> > force the interface to initialise though.  For GObject subclasses, it is 
> > as simple as:
> >   class = g_type_class_ref(type);
> >   id = g_signal_lookup(name, type);
> >   ...
> >   g_type_class_unref(class);
> 
> its the same for interfaces, say you added an interface to class foo,
> the interface is initialized once you cause the foo-class to be created,
> e.g. via g_type_class_ref(TYPE_FOO).

But how do you initialize an interface's signals _without_ creating an
instance of class implementing it? It would be much pain if
gtk-doc had to register a dummy type for each interface it had
to query. 

I'm not sure how to get around this though - the base_init()
hack we use for registering signals on interfaces makes it
pretty unnatural, and there is nothing to "ref".

Regards,
                                  Owen



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]