SnippetManager

class SnippetManager(**properties: Any)

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_search_path() list[str]

Gets the list directories where self looks for snippet files.

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/or trigger.

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

Parameters:
  • group – a group name or None

  • language_id – a Language:id or None

  • 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 by self 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/or trigger_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 until get_item is called for a specific snippet. This helps reduce the number of Object’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 or None

  • 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 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.

Parameters:

dirs – a None-terminated array of strings or None.

Properties

class SnippetManager
props.search_path: Sequence[str]

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