SnippetManager
Superclasses: Object
Provides access to Snippet
.
GtkSourceSnippetManager
is an object which processes snippet description
files and creates Snippet
objects.
Use get_default
to retrieve the default
instance of GtkSourceSnippetManager
.
Use get_snippet
to retrieve snippets for
a given snippets.
Methods
- class SnippetManager
- get_default() SnippetManager
Returns the default
SnippetManager
instance.
- get_snippet(group: str | None, language_id: str | None, trigger: str) Snippet | None
Queries the known snippets for the first matching
group
,language_id
, and/ortrigger
.If
group
orlanguage_id
areNone
, they will be ignored.- Parameters:
group – a group name or
None
language_id – a
Language
:id orNone
trigger – the trigger for the snippet
- list_all() ListModel
Gets a
ListModel
of all snippets.This can be used to get an unfiltered list of all of the snippets known to the snippet manager.
Added in version 5.6.
- list_groups() list[str]
List all the known groups within the snippet manager.
The result should be freed with
free()
, and the individual strings are owned byself
and should never be freed by the caller.
- list_matching(group: str | None = None, language_id: str | None = None, trigger_prefix: str | None = None) ListModel
Queries the known snippets for those matching
group
,language_id
, and/ortrigger_prefix
.If any of these are
None
, they will be ignored when filtering the available snippets.The
ListModel
only contains information about the available snippets untilget_item
is called for a specific snippet. This helps reduce the number ofObject
’s that are created at runtime to those needed by the calling application.- Parameters:
group – a group name or
None
language_id – a
Language
:id orNone
trigger_prefix – a prefix for a trigger to activate
- set_search_path(dirs: Sequence[str] | None = None) None
Sets the list of directories in which the
GtkSourceSnippetManager
looks for snippet files.If
dirs
isNone
, 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.- Parameters:
dirs – a
None
-terminated array of strings orNone
.