GtkSource.SnippetManager

g GObject.Object GObject.Object GtkSource.SnippetManager GtkSource.SnippetManager GObject.Object->GtkSource.SnippetManager

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

get_default ()

get_search_path ()

get_snippet (group, language_id, trigger)

list_all ()

list_groups ()

list_matching (group, language_id, trigger_prefix)

set_search_path (dirs)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

search-path

[str]

r/w/en

List of directories with snippet definitions (*.snippets)

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class GtkSource.SnippetManager(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

GtkSource.SnippetManagerClass

Provides access to [class`Snippet`].

GtkSourceSnippetManager is an object which processes snippet description files and creates [class`Snippet`] objects.

Use [func`SnippetManager`.get_default] to retrieve the default instance of GtkSourceSnippetManager.

Use [method`SnippetManager`.get_snippet] to retrieve snippets for a given snippets.

classmethod get_default()
Returns:

a GtkSource.SnippetManager which is owned by GtkSource.View library and must not be unref’d.

Return type:

GtkSource.SnippetManager

Returns the default GtkSource.SnippetManager instance.

get_search_path()
Returns:

None-terminated array containing a list of snippet files directories. The array is owned by lm and must not be modified.

Return type:

[str]

Gets the list directories where self looks for snippet files.

get_snippet(group, language_id, trigger)
Parameters:
Returns:

a GtkSource.Snippet or None if no matching snippet was found.

Return type:

GtkSource.Snippet or None

Queries the known snippets for the first matching group, language_id, and/or trigger.

If group or language_id are None, they will be ignored.

list_all()
Returns:

a [iface`Gio`.ListModel] of [class`GtkSource`.Snippet]

Return type:

Gio.ListModel

Gets a [iface`Gio`.ListModel] of all snippets.

This can be used to get an unfiltered list of all of the snippets known to the snippet manager.

New in version 5.6.

list_groups()
Returns:

An array of strings which should be freed with GLib.free().

Return type:

[str]

List all the known groups within the snippet manager.

The result should be freed with GLib.free(), and the individual strings are owned by self and should never be freed by the caller.

list_matching(group, language_id, trigger_prefix)
Parameters:
Returns:

a Gio.ListModel of GtkSource.Snippet.

Return type:

Gio.ListModel

Queries the known snippets for those matching group, language_id, and/or trigger_prefix.

If any of these are None, they will be ignored when filtering the available snippets.

The [iface`Gio`.ListModel] only contains information about the available snippets until [method`Gio`.ListModel.get_item] is called for a specific snippet. This helps reduce the number of [class`GObject`.Object]’s that are created at runtime to those needed by the calling application.

set_search_path(dirs)
Parameters:

dirs ([str] or None) – a None-terminated array of strings or None.

Sets the list of directories in which the GtkSourceSnippetManager looks for snippet files.

If dirs is None, the search path is reset to default.

At the moment this function can be called only before the snippet files are loaded for the first time. In practice to set a custom search path for a GtkSourceSnippetManager, you have to call this function right after creating it.

Property Details

GtkSource.SnippetManager.props.search_path
Name:

search-path

Type:

[str]

Default Value:

[]

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Contains a list of directories to search for files containing snippets (*.snippets).