GIRepository

GIRepository — GObject Introspection repository manager

Types and Values

Object Hierarchy

    GObject
    ╰── GIRepository

Includes

#include <girepository.h>

Description

GIRepository is used to manage repositories of namespaces. Namespaces are represented on disk by type libraries (.typelib files).

### Discovery of type libraries

GIRepository will typically look for a girepository-1.0 directory under the library directory used when compiling gobject-introspection.

It is possible to control the search paths programmatically, using g_irepository_prepend_search_path(). It is also possible to modify the search paths by using the GI_TYPELIB_PATH environment variable. The environment variable takes precedence over the default search path and the g_irepository_prepend_search_path() calls.

Functions

g_irepository_get_default ()

GIRepository *
g_irepository_get_default (void);

Returns the singleton process-global default GIRepository. It is not currently supported to have multiple repositories in a particular process, but this function is provided in the unlikely eventuality that it would become possible, and as a convenience for higher level language bindings to conform to the GObject method call conventions.

All methods on GIRepository also accept NULL as an instance parameter to mean this default repository, which is usually more convenient for C.

Returns

The global singleton GIRepository.

[transfer none]


g_irepository_get_dependencies ()

gchar **
g_irepository_get_dependencies (GIRepository *repository,
                                const gchar *namespace_);

Return an array of all (transitive) versioned dependencies for namespace_ . Returned strings are of the form

namespace-version.

Note: namespace_ must have already been loaded using a function such as g_irepository_require() before calling this function.

To get only the immediate dependencies for namespace_ , use g_irepository_get_immediate_dependencies().

Parameters

repository

A GIRepository or NULL for the singleton process-global default GIRepository.

[allow-none]

namespace_

Namespace of interest

 

Returns

Zero-terminated string array of all versioned dependencies.

[transfer full]


g_irepository_get_immediate_dependencies ()

gchar **
g_irepository_get_immediate_dependencies
                               (GIRepository *repository,
                                const gchar *namespace_);

Return an array of the immediate versioned dependencies for namespace_ . Returned strings are of the form namespace-version.

Note: namespace_ must have already been loaded using a function such as g_irepository_require() before calling this function.

To get the transitive closure of dependencies for namespace_ , use g_irepository_get_dependencies().

Parameters

repository

A GIRepository or NULL for the singleton process-global default GIRepository.

[nullable]

namespace_

Namespace of interest

 

Returns

Zero-terminated string array of immediate versioned dependencies.

[transfer full]

Since: 1.44


g_irepository_get_loaded_namespaces ()

gchar **
g_irepository_get_loaded_namespaces (GIRepository *repository);

Return the list of currently loaded namespaces.

Parameters

repository

A GIRepository or NULL for the singleton process-global default GIRepository.

[allow-none]

Returns

List of namespaces.

[element-type utf8][transfer full]


g_irepository_get_n_infos ()

gint
g_irepository_get_n_infos (GIRepository *repository,
                           const gchar *namespace_);

This function returns the number of metadata entries in given namespace namespace_ . The namespace must have already been loaded before calling this function.

Parameters

repository

A GIRepository or NULL for the singleton process-global default GIRepository.

[allow-none]

namespace_

Namespace to inspect

 

Returns

number of metadata entries


g_irepository_get_info ()

GIBaseInfo *
g_irepository_get_info (GIRepository *repository,
                        const gchar *namespace_,
                        gint index);

This function returns a particular metadata entry in the given namespace namespace_ . The namespace must have already been loaded before calling this function. See g_irepository_get_n_infos() to find the maximum number of entries.

Parameters

repository

A GIRepository or NULL for the singleton process-global default GIRepository.

[allow-none]

namespace_

Namespace to inspect

 

index

0-based offset into namespace metadata for entry

 

Returns

GIBaseInfo containing metadata.

[transfer full]


g_irepository_get_option_group ()

GOptionGroup *
g_irepository_get_option_group (void);

Obtain the option group for girepository, it's used by the dumper and for programs that wants to provide introspection information

Returns

the option group.

[transfer full]


g_irepository_enumerate_versions ()

GList *
g_irepository_enumerate_versions (GIRepository *repository,
                                  const gchar *namespace_);

Obtain an unordered list of versions (either currently loaded or available) for namespace_ in this repository .

Parameters

repository

A GIRepository or NULL for the singleton process-global default GIRepository.

[allow-none]

namespace_

GI namespace, e.g. "Gtk"

 

Returns

the array of versions.

[element-type utf8][transfer full]


g_irepository_prepend_library_path ()

void
g_irepository_prepend_library_path (const char *directory);

Prepends directory to the search path that is used to search shared libraries referenced by imported namespaces. Multiple calls to this function all contribute to the final list of paths. The list of paths is unique and shared for all GIRepository instances across the process, but it doesn't affect namespaces imported before the call.

If the library is not found in the directories configured in this way, loading will fall back to the system library path (ie. LD_LIBRARY_PATH and DT_RPATH in ELF systems). See the documentation of your dynamic linker for full details.

Parameters

directory

a single directory to scan for shared libraries.

[type filename]

Since: 1.35.8


g_irepository_prepend_search_path ()

void
g_irepository_prepend_search_path (const char *directory);

Prepends directory to the typelib search path.

See also: g_irepository_get_search_path().

Parameters

directory

directory name to prepend to the typelib search path.

[type filename]

g_irepository_get_search_path ()

GSList *
g_irepository_get_search_path (void);

Returns the current search path GIRepository will use when loading typelib files. The list is internal to GIRespository and should not be freed, nor should its string elements.

Returns

GSList of strings.

[element-type filename][transfer none]


g_irepository_load_typelib ()

const char *
g_irepository_load_typelib (GIRepository *repository,
                            GITypelib *typelib,
                            GIRepositoryLoadFlags flags,
                            GError **error);

TODO

Parameters

repository

A GIRepository or NULL for the singleton process-global default GIRepository.

[allow-none]

typelib

TODO

 

flags

TODO

 

error

TODO

 

g_irepository_get_typelib_path ()

const gchar *
g_irepository_get_typelib_path (GIRepository *repository,
                                const gchar *namespace_);

If namespace namespace_ is loaded, return the full path to the .typelib file it was loaded from. If the typelib for namespace namespace_ was included in a shared library, return the special string "<builtin>".

Parameters

repository

A GIRepository or NULL for the singleton process-global default GIRepository.

[allow-none]

namespace_

GI namespace to use, e.g. "Gtk"

 

Returns

Filesystem path (or $lt;builtin$gt;) if successful, NULL if namespace is not loaded


g_irepository_is_registered ()

gboolean
g_irepository_is_registered (GIRepository *repository,
                             const gchar *namespace_,
                             const gchar *version);

Check whether a particular namespace (and optionally, a specific version thereof) is currently loaded. This function is likely to only be useful in unusual circumstances; in order to act upon metadata in the namespace, you should call g_irepository_require() instead which will ensure the namespace is loaded, and return as quickly as this function will if it has already been loaded.

Parameters

repository

A GIRepository or NULL for the singleton process-global default GIRepository.

[allow-none]

namespace_

Namespace of interest

 

version

Required version, may be NULL for latest.

[allow-none]

Returns

TRUE if namespace-version is loaded, FALSE otherwise


g_irepository_require ()

GITypelib *
g_irepository_require (GIRepository *repository,
                       const gchar *namespace_,
                       const gchar *version,
                       GIRepositoryLoadFlags flags,
                       GError **error);

Force the namespace namespace_ to be loaded if it isn't already. If namespace_ is not loaded, this function will search for a ".typelib" file using the repository search path. In addition, a version version of namespace may be specified. If version is not specified, the latest will be used.

Parameters

repository

A GIRepository or NULL for the singleton process-global default GIRepository.

[allow-none]

namespace_

GI namespace to use, e.g. "Gtk"

 

version

Version of namespace, may be NULL for latest.

[allow-none]

flags

Set of GIRepositoryLoadFlags, may be 0

 

error

a GError.

 

Returns

a pointer to the GITypelib if successful, NULL otherwise.

[transfer none]


g_irepository_require_private ()

GITypelib *
g_irepository_require_private (GIRepository *repository,
                               const gchar *typelib_dir,
                               const gchar *namespace_,
                               const gchar *version,
                               GIRepositoryLoadFlags flags,
                               GError **error);

Force the namespace namespace_ to be loaded if it isn't already. If namespace_ is not loaded, this function will search for a ".typelib" file within the private directory only. In addition, a version version of namespace should be specified. If version is not specified, the latest will be used.

Parameters

repository

A GIRepository or NULL for the singleton process-global default GIRepository.

[allow-none]

typelib_dir

Private directory where to find the requested typelib

 

namespace_

GI namespace to use, e.g. "Gtk"

 

version

Version of namespace, may be NULL for latest.

[allow-none]

flags

Set of GIRepositoryLoadFlags, may be 0

 

error

a GError.

 

Returns

a pointer to the GITypelib if successful, NULL otherwise.

[transfer none]


g_irepository_get_c_prefix ()

const gchar *
g_irepository_get_c_prefix (GIRepository *repository,
                            const gchar *namespace_);

This function returns the "C prefix", or the C level namespace associated with the given introspection namespace. Each C symbol starts with this prefix, as well each GType in the library.

Note: The namespace must have already been loaded using a function such as g_irepository_require() before calling this function.

Parameters

repository

A GIRepository or NULL for the singleton process-global default GIRepository.

[allow-none]

namespace_

Namespace to inspect

 

Returns

C namespace prefix, or NULL if none associated


g_irepository_get_shared_library ()

const gchar *
g_irepository_get_shared_library (GIRepository *repository,
                                  const gchar *namespace_);

This function returns a comma-separated list of paths to the shared C libraries associated with the given namespace namespace_ . There may be no shared library path associated, in which case this function will return NULL.

Note: The namespace must have already been loaded using a function such as g_irepository_require() before calling this function.

Parameters

repository

A GIRepository or NULL for the singleton process-global default GIRepository.

[allow-none]

namespace_

Namespace to inspect

 

Returns

Comma-separated list of paths to shared libraries, or NULL if none are associated


g_irepository_get_version ()

const gchar *
g_irepository_get_version (GIRepository *repository,
                           const gchar *namespace_);

This function returns the loaded version associated with the given namespace namespace_ .

Note: The namespace must have already been loaded using a function such as g_irepository_require() before calling this function.

Parameters

repository

A GIRepository or NULL for the singleton process-global default GIRepository.

[allow-none]

namespace_

Namespace to inspect

 

Returns

Loaded version


g_irepository_find_by_gtype ()

GIBaseInfo *
g_irepository_find_by_gtype (GIRepository *repository,
                             GType gtype);

Searches all loaded namespaces for a particular GType. Note that in order to locate the metadata, the namespace corresponding to the type must first have been loaded. There is currently no mechanism for determining the namespace which corresponds to an arbitrary GType - thus, this function will operate most reliably when you know the GType to originate from be from a loaded namespace.

Parameters

repository

A GIRepository or NULL for the singleton process-global default GIRepository.

[allow-none]

gtype

GType to search for

 

Returns

GIBaseInfo representing metadata about type , or NULL.

[transfer full]


g_irepository_find_by_error_domain ()

GIEnumInfo *
g_irepository_find_by_error_domain (GIRepository *repository,
                                    GQuark domain);

Searches for the enum type corresponding to the given GError domain. Before calling this function for a particular namespace, you must call g_irepository_require() once to load the namespace, or otherwise ensure the namespace has already been loaded.

Parameters

repository

A GIRepository or NULL for the singleton process-global default GIRepository.

[allow-none]

domain

a GError domain

 

Returns

GIEnumInfo representing metadata about domain 's enum type, or NULL.

[transfer full]

Since: 1.29.17


g_irepository_find_by_name ()

GIBaseInfo *
g_irepository_find_by_name (GIRepository *repository,
                            const gchar *namespace_,
                            const gchar *name);

Searches for a particular entry in a namespace. Before calling this function for a particular namespace, you must call g_irepository_require() once to load the namespace, or otherwise ensure the namespace has already been loaded.

Parameters

repository

A GIRepository or NULL for the singleton process-global default GIRepository.

[allow-none]

namespace_

Namespace which will be searched

 

name

Entry name to find

 

Returns

GIBaseInfo representing metadata about name , or NULL.

[transfer full]


g_irepository_dump ()

gboolean
g_irepository_dump (const char *arg,
                    GError **error);

Argument specified is a comma-separated pair of filenames; i.e. of the form "input.txt,output.xml". The input file should be a UTF-8 Unix-line-ending text file, with each line containing either "get-type:" followed by the name of a GType _get_type function, or "error-quark:" followed by the name of an error quark function. No extra whitespace is allowed.

The output file should already exist, but be empty. This function will overwrite its contents.

Parameters

arg

Comma-separated pair of input and output filenames

 

error

a GError

 

Returns

TRUE on success, FALSE on error


gi_cclosure_marshal_generic ()

void
gi_cclosure_marshal_generic (GClosure *closure,
                             GValue *return_gvalue,
                             guint n_param_values,
                             const GValue *param_values,
                             gpointer invocation_hint,
                             gpointer marshal_data);

TODO

[skip]

Parameters

closure

TODO

 

return_gvalue

TODO

 

n_param_values

TODO

 

param_values

TODO

 

invocation_hint

TODO

 

marshal_data

TODO

 

Types and Values

struct GIRepository

struct GIRepository;

The GIRepository structure contains private data and should only be accessed using the provided API.


enum GIRepositoryLoadFlags

Flags that control how a typelib is loaded.

Members

G_IREPOSITORY_LOAD_FLAG_LAZY

Lazily load the typelib.

 

G_IREPOSITORY_ERROR

#define G_IREPOSITORY_ERROR (g_irepository_error_quark ())

Error domain for GIRepository. Errors in this domain will be from the GIRepositoryError enumeration. See GError for more information on error domains.


enum GIRepositoryError

An error code used with G_IREPOSITORY_ERROR in a GError returned from a GIRepository routine.

Members

G_IREPOSITORY_ERROR_TYPELIB_NOT_FOUND

the typelib could not be found.

 

G_IREPOSITORY_ERROR_NAMESPACE_MISMATCH

the namespace does not match the requested namespace.

 

G_IREPOSITORY_ERROR_NAMESPACE_VERSION_CONFLICT

the version of the typelib does not match the requested version.

 

G_IREPOSITORY_ERROR_LIBRARY_NOT_FOUND

the library used by the typelib could not be found.