GtkSource.SnippetContext

g GObject.Object GObject.Object GtkSource.SnippetContext GtkSource.SnippetContext GObject.Object->GtkSource.SnippetContext

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new ()

clear_variables ()

expand (input)

get_variable (key)

set_constant (key, value)

set_line_prefix (line_prefix)

set_tab_width (tab_width)

set_use_spaces (use_spaces)

set_variable (key, value)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

None

Signals

Inherited:

GObject.Object (1)

Name

Short Description

changed

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.

Fields

Inherited:

GObject.Object (1)

Class Details

class GtkSource.SnippetContext(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

GtkSource.SnippetContextClass

Context for expanding [class`SnippetChunk`].

This class is currently used primary as a hashtable. However, the longer term goal is to have it hold onto a GjsContext as well as other languages so that [class`SnippetChunk`] can expand themselves by executing script within the context.

The [class`Snippet`] will build the context and then expand each of the chunks during the insertion/edit phase.

classmethod new()
Returns:

a GtkSource.SnippetContext

Return type:

GtkSource.SnippetContext

Creates a new GtkSource.SnippetContext.

Generally, this isn’t needed unless you are controlling the expansion of snippets manually.

clear_variables()

Removes all variables from the context.

expand(input)
Parameters:

input (str) –

Return type:

str

get_variable(key)
Parameters:

key (str) – the name of the variable

Returns:

the value for the variable, or None

Return type:

str or None

Gets the current value for a variable named key.

set_constant(key, value)
Parameters:
  • key (str) – the constant name

  • value (str) – the value of the constant

Sets a constatnt within the context.

This is similar to a variable set with [method`SnippetContext`.set_variable] but is expected to not change during use of the snippet.

Examples would be the date or users name.

set_line_prefix(line_prefix)
Parameters:

line_prefix (str) –

set_tab_width(tab_width)
Parameters:

tab_width (int) –

set_use_spaces(use_spaces)
Parameters:

use_spaces (bool) –

set_variable(key, value)
Parameters:
  • key (str) – the variable name

  • value (str) – the value for the variable

Sets a variable within the context.

This variable may be overridden by future updates to the context.

Signal Details

GtkSource.SnippetContext.signals.changed(snippet_context)
Signal Name:

changed

Flags:

RUN_FIRST

Parameters:

snippet_context (GtkSource.SnippetContext) – The object which received the signal

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.