After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 740983 - Allow plugins for Gtk Inspector
Allow plugins for Gtk Inspector
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: .General
3.13.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2014-12-01 14:44 UTC by Alexander Larsson
Modified: 2014-12-09 21:54 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Inspector: Support extending the inspector using GIOModules (5.18 KB, patch)
2014-12-01 14:45 UTC, Alexander Larsson
committed Details | Review

Description Alexander Larsson 2014-12-01 14:44:49 UTC
I wrote a gjs based interactive tab for the Gtk Inspector:

https://github.com/alexlarsson/gjs-inspector

This can't be part of Gtk+ for natural reasons, so i made it possible
to extend GtkInspector using GIOModules.
Comment 1 Alexander Larsson 2014-12-01 14:45:15 UTC
Created attachment 291891 [details] [review]
Inspector: Support extending the inspector using GIOModules

This allows external modules to add a page to the Gtk Inspector.
Comment 2 Emmanuele Bassi (:ebassi) 2014-12-01 15:06:39 UTC
personally, I prefer a module loading approach to a direct dependency.

linking GTK+ with mozjs via gjs would make GTK+ builds suddenly fairly sizable — definitely unsuitable for minimal environments, and adding a configure switch would imply we tested the reduced build, which I don't believe will happen.

we would also need to avoid the indirect dependency on libstdc++ — basically, wrapping the C++ entry points of mozjs in GJS, and using the C linker. I did that for the Xapian (a C++ library) GLib bindings, and Behdad did that for harfbuzz, but it's not really trivial, and would require more maintenance efforts spent in the direction of GJS.

the interaction of a GJS-powered inspector running against an application written using Python/Perl/whatever is also a sizable unknown.
Comment 3 Matthias Clasen 2014-12-01 15:09:53 UTC
We could still keep the gjs-inspector module in the gtk tree, I guess, just not link it into libgtk.
Comment 4 Alexander Larsson 2014-12-01 15:35:34 UTC
Matthias: Isn't that a circular dependency though? Gjs has an (optional) dependency on gtk.
Comment 5 Alexander Larsson 2014-12-01 15:36:21 UTC
Another alternative is to ship the gjs-inspector module with GJs.
Comment 6 Matthias Clasen 2014-12-01 15:50:15 UTC
yeah, you'd have to have a --disable-gjs configure flag and use it to break the cycle for bootstrapping
Comment 7 Matthias Clasen 2014-12-03 03:23:55 UTC
Just a few things I wonder.

Imagine somebody implements the same extension point for an interactive python repl. Do we expect them both to show up in the UI ? will they both be called "Interactive" ? Do we need a way to disable or choose individual extensions ?

When trying this, I get a few warnings like
<interactive>:1:strict warning: reference to undefined property imports.gi
resource:///org/gnome/gjs/modules/overrides/GLib.js:258:strict warning: reference to undefined property this.Variant

It would be really helpful to have completion in the entry.

Do you think a box full of labels is the best way to represent history ? Wouldn't a text view be more natural ? You could select and copy the whole thing then, not just individual lines...
Comment 8 Alexander Larsson 2014-12-03 08:55:10 UTC
Yeah, not sure about the multiple extensions. It would depend on what they did. Having several repl would be kind of weird, and also problematic (due to the at-most-one-toggle-ref issue). We could have a specifically named extension for that where we only pick one repl i guess. I'm not sure we would actually get multiple repls though. For apps written in e.g. python i'd think you get a python repl some other way than the inspector.

The warnings seem to be from gjs itself, not sure about the exact reason, or why they don't show up in other gjs code.

Completion is tricky, you would have to parse the js code and figure out what to expand to. Christian, you did some research into this, right?

As for the history, yeah, you might be right. And additionally, we should probably show the commands that you typed in the history list too.
Comment 9 Matthias Clasen 2014-12-03 12:51:16 UTC
(In reply to comment #8)
 
> Completion is tricky, you would have to parse the js code and figure out what
> to expand to. Christian, you did some research into this, right?

The kind of completion I would expect is for existing properties / functions of objects - no need to parse js for that , I hope ? isn't that what introspection was invented for ?
Comment 10 Matthias Clasen 2014-12-03 12:55:21 UTC
(In reply to comment #8)

> The warnings seem to be from gjs itself, not sure about the exact reason, or
> why they don't show up in other gjs code.

Are you seeing the same warnings ?
Comment 11 Christian Hergert 2014-12-03 18:09:50 UTC
Completion with JS is tricky for two major reasons.

1) When you need to complete something, you almost definitely do not have a valid parse tree.
2) You have to guess scoping and use conventions to determine what types things are (based on previous parse tree's due to 1).

That said, https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Parser_API seems useful.

We can try to guess gobject introspection information based on imports and assignments. Probably easier for a REPL than for a full blown text editor where you write OO styled code.
Comment 12 Matthias Clasen 2014-12-04 00:43:46 UTC
I mean something in the style of the completion you get in gnome-shell's looking glass.
Comment 13 Alexander Larsson 2014-12-08 15:52:58 UTC
I switched master to use a GtkTextView.

I also imported the gnome-shell completion. Its not great, but it completes some stuff at least. I think the problem is that all the introspection data is resolved lazily, so completion only lists whats been used so far, or something.
Comment 14 Alexander Larsson 2014-12-08 15:53:29 UTC
And yes, i see the warnings too. I hacked around it in master.
Comment 15 Matthias Clasen 2014-12-08 23:27:58 UTC
Comment on attachment 291891 [details] [review]
Inspector: Support extending the inspector using GIOModules

Attachment 291891 [details] pushed as 2d6ae59 - Inspector: Support extending the inspector using GIOModules
Comment 16 Matthias Clasen 2014-12-08 23:29:39 UTC
pushed this, since I think it is pretty cool. A few things would make it even cooler:

- Make the picker button visible on the interactive tab, and inject the picked object into the entry

- Allow backrefences to the previously evaluated expressions, like looking glass does with r(n)
Comment 17 Matthias Clasen 2014-12-08 23:41:48 UTC
may not be super-easy to do with the extension point approach, unless you make the extension point provide the header bar button, I guess
Comment 18 Alexander Larsson 2014-12-09 14:22:38 UTC
Latest gjs-inspector has picker injection and backreferences
Comment 19 Matthias Clasen 2014-12-09 21:54:10 UTC
cool