:right-sidebar: True SnippetContext =================================================================== .. currentmodule:: gi.repository.GtkSource .. class:: SnippetContext(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` :Constructors: :: SnippetContext(**properties) new() -> GtkSource.SnippetContext Constructors ------------ .. rst-class:: interim-class .. class:: SnippetContext :no-index: .. classmethod:: new() -> ~gi.repository.GtkSource.SnippetContext Creates a new :obj:`~gi.repository.GtkSource.SnippetContext`. Generally, this isn't needed unless you are controlling the expansion of snippets manually. Methods ------- .. rst-class:: interim-class .. class:: SnippetContext :no-index: .. method:: clear_variables() -> None Removes all variables from the context. .. method:: expand(input: str) -> str :param input: .. method:: get_variable(key: str) -> str | None Gets the current value for a variable named ``key``. :param key: the name of the variable .. method:: set_constant(key: str, value: str) -> None Sets a constatnt within the context. This is similar to a variable set with :obj:`~gi.repository.SnippetContext.set_variable` but is expected to not change during use of the snippet. Examples would be the date or users name. :param key: the constant name :param value: the value of the constant .. method:: set_line_prefix(line_prefix: str) -> None :param line_prefix: .. method:: set_tab_width(tab_width: int) -> None :param tab_width: .. method:: set_use_spaces(use_spaces: bool) -> None :param use_spaces: .. method:: set_variable(key: str, value: str) -> None Sets a variable within the context. This variable may be overridden by future updates to the context. :param key: the variable name :param value: the value for the variable Signals ------- .. rst-class:: interim-class .. class:: SnippetContext.signals :no-index: .. method:: changed() -> None The signal is emitted when a change has been discovered in one of the chunks of the snippet which has caused a variable or other dynamic data within the context to have changed.