Next: , Up: Reference Guide   [Contents][Index]


3.1 Typelib Introspection

A GObject typelib file contains information on the public classes, functions, and variables in a GObject-based library, and most GObject-compliant libraries, such as GLib and GTK, provide one. Usually these files are on the file system in a single directory location. On Fedora, for example, these files may be stored in /var/lib64/girepository-1.0.

All functions outlined in this section are part of (gi repository) and are not re-exported by (gi).

Procedure: require lib [version]

Forces the namespace lib to be loaded if it isn’t already. This step is required once per lib before any other functionality of this module is used.

If version is given, loads that version, otherwise loads the latest available.

Throws an error, if the library could not be found or loaded.

Procedure: get-search-path

This returns the current search path used to find typelib files as a list of strings.

If it returns an empty list, this indicates that it is only searching the default typelib directory.

Procedure: prepend-search-path! directory

Given directory, a string representation of a file system directory, this prepends that directory to the typelib search path.

This change doesn’t affect libraries loaded before it. It therefore is advisable to put such directives at the start of a script.

Procedure: infos lib

Fetches all top-level metadata entries of lib.

Procedure: info lib name

Searches lib for an entry with name name and returns it. Throws an error, if name could not be found.

Procedure: load (info <GBaseInfo>)
Procedure: load (info <GBaseInfo>) flags

Generates bindings for info.

flags is a logical or of LOAD_METHODS, LOAD_SIGNALS and LOAD_PROPERTIES, and may be 0 or LOAD_INFO_ONLY tells load, how to handle infos with nested information, such as structs and objects. They enable loading of methods, signals, properties and fields respectively. By default, all of them are loaded.

Procedure: load-by-name lib name [flags]

A convenience function composing info and load.

Procedure: typelib->module module lib [version]

Loads all infos of lib into module and adds them to its public interface.

module may be a module or a list of symbols. If the latter is given, it is resolved to a (potentially new) module. In either case, the resulting module is returned.

If version is given, loads that version, otherwise loads the latest. Throws an error, if the library could not be found or loaded.


Next: Typelib Documentation, Up: Reference Guide   [Contents][Index]