Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is imported using the Gjs imports statement?

Tags:

linux

gnome

gjs

If I'm looking at Gjs code and see this line near the beginning:

const Gio = imports.gi.Gio;

How can I know what methods, constants, events, etc. are on 'Gio' (without doing a Google search)? Is there a file somewhere on my installation that contains that information?

Obviously I'm asking for any 'imports' statement, not Gio specifically.

like image 872
Marcel Lamothe Avatar asked Sep 22 '13 18:09

Marcel Lamothe


2 Answers

Some of imports statements import other javascript files:

  • imports.ui.* -> /usr/share/cinnamon/js/ui/*
  • imports.misc.* -> /usr/share/cinnamon/js/misc/*
  • imports.[cairo, dbus, format, gettext, jsUnit, lang, promise, signals] -> /usr/share/gjs-1.0/

For the imports.gi imports, Gnome Introspection is used to allow gjs to use C library.
So to get informations about those libraries I suggest you to look at the Gnome reference manuals:

  • Gio
  • Gtk
  • St

But to conclude, there is a huge lack of documentation and examples. That makes difficult to develop with gjs.

UPDATE
Here other useful links:

  • Seed documentation (seed is another javascript implementation for GNOME)
  • Gjs exemples
like image 127
Nicolas Avatar answered Oct 15 '22 11:10

Nicolas


Since I got no answers I kept searching online and found this excellent blog post on how to generate HTML-formatted documentation from typelib files (such as Gio-2.0.typelib):

http://mathematicalcoffee.blogspot.com/2012/09/developing-gnome-shell-extensions_6.html

like image 4
Marcel Lamothe Avatar answered Oct 15 '22 11:10

Marcel Lamothe