Re: programmatically list available signals



I'd consider writing two branches of the extension -- something easy
to do with git -- rather than writing a polyglot for two separate
APIs.

On Mon, Jun 4, 2012 at 1:28 AM, Amy C <mathematical coffee gmail com> wrote:
> On 4 June 2012 11:53, Amy C <mathematical coffee gmail com> wrote:
>> Hi all,
>>
>> Is there a way to programmatically ask an object if it has a
>> particular signal, or get a list of signals it has?
>
> Worked it out - found the relevant documentation in 'GObject signals'[0].
>
> Suppose I want to see if global.window_manager has signal 'map'.
> Then I can use:
>
> const GObject = imports.gi.GObject;
> GObject.signal_lookup('map', GObject.type_from_name('ShellWM'));
>
> This returns the signal's ID, or 0 if the signal does not exist.
> As to getting the GType from the class name - I typed
> 'global.window_manager' into the looking glass and saw that its class
> is 'Shell.WM', and so used GObject.type_from_name( name_of_class ) to
> obtain the type[1].
>
> Name of the class is probably the string [namespace][classname], i.e.
> without the '.' in between.
>
> There is a macro G_TYPE_FROM_CLASS and G_TYPE_FROM_INSTANCE that (to
> me) seems more useful than type_from_name - something like
> `GObject.type_from_instance(global.window_manager)` - but as far as I
> can tell they aren't in the introspection interface.
>
> Hope that helps someone.
>
> [0]:http://developer.gnome.org/gobject/stable/gobject-Signals.html
> [1]:http://developer.gnome.org/gobject/stable/gobject-Type-Information.html#g-type-from-name
> _______________________________________________
> gnome-shell-list mailing list
> gnome-shell-list gnome org
> https://mail.gnome.org/mailman/listinfo/gnome-shell-list



-- 
  Jasper


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