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
- classmethod get_default() SnippetManager#
Returns the default
SnippetManagerinstance.
- 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
grouporlanguage_idareNone, they will be ignored.- Parameters:
group – a group name or
Nonelanguage_id – a
Language:id orNonetrigger – the trigger for the snippet
- list_all() ListModel#
Gets a
ListModelof 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 byselfand 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
ListModelonly contains information about the available snippets untilget_itemis 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
Nonelanguage_id – a
Language:id orNonetrigger_prefix – a prefix for a trigger to activate
- set_search_path(dirs: list[str] | None = None) None#
Sets the list of directories in which the
GtkSourceSnippetManagerlooks for snippet files.If
dirsisNone, 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.