GtkSource.CompletionContext

g GObject.GInterface GObject.GInterface Gio.ListModel Gio.ListModel GObject.GInterface->Gio.ListModel GObject.Object GObject.Object GtkSource.CompletionContext GtkSource.CompletionContext GObject.Object->GtkSource.CompletionContext Gio.ListModel->GtkSource.CompletionContext

Subclasses:

None

Methods

Inherited:

GObject.Object (37), Gio.ListModel (4)

Structs:

GObject.ObjectClass (5)

get_activation ()

get_bounds ()

get_buffer ()

get_busy ()

get_completion ()

get_empty ()

get_language ()

get_proposals_for_provider (provider)

get_view ()

get_word ()

list_providers ()

set_proposals_for_provider (provider, results)

Virtual Methods

Inherited:

GObject.Object (7), Gio.ListModel (3)

Properties

Name

Type

Flags

Short Description

busy

bool

r

Is the completion context busy populating

completion

GtkSource.Completion

r/w/co

Completion

empty

bool

r

If the context has no results

Signals

Inherited:

GObject.Object (1), Gio.ListModel (1)

Name

Short Description

provider-model-changed

Emitted when a provider changes a model.

Fields

Inherited:

GObject.Object (1), Gio.ListModel (1)

Class Details

class GtkSource.CompletionContext(**kwargs)
Bases:

GObject.Object, Gio.ListModel

Abstract:

No

Structure:

GtkSource.CompletionContextClass

The context of a completion.

GtkSourceCompletionContext contains information about an attept to display completion proposals to the user based on typed text in the [class`View`].

When typing, [class`Completion`] may use registered [iface`CompletionProvider`] to determine if there may be results which could be displayed. If so, a GtkSourceCompletionContext is created with information that is provided to the [iface`CompletionProvider`] to populate results which might be useful to the user.

[iface`CompletionProvider`] are expected to provide [iface`Gio`.ListModel] with [iface`CompletionProposal`] which may be joined together in a list of results for the user. They are also responsible for how the contents are displayed using [class`CompletionCell`] which allows for some level of customization.

get_activation()
Return type:

GtkSource.CompletionActivation

Gets the mode for which the context was activated.

get_bounds()
Returns:

True if the marks are still valid and begin or end was set.

begin:

a Gtk.TextIter

end:

a Gtk.TextIter

Return type:

(bool, begin: Gtk.TextIter, end: Gtk.TextIter)

Gets the bounds for the completion, which is the beginning of the current word (taking break characters into account) to the current insertion cursor.

If begin is non-None, it will be set to the start position of the current word being completed.

If end is non-None, it will be set to the insertion cursor for the current word being completed.

get_buffer()
Returns:

a Gtk.TextBuffer or None

Return type:

GtkSource.Buffer or None

Gets the underlying buffer used by the context.

This is a convenience function to get the buffer via the GtkSource.Completion property.

get_busy()
Returns:

True if the context is busy

Return type:

bool

Gets the “busy” property. This is set to True while the completion context is actively fetching proposals from registered GtkSource.CompletionProvider's.

get_completion()
Returns:

an GtkSource.Completion or None

Return type:

GtkSource.Completion or None

Gets the GtkSource.Completion that created the context.

get_empty()
Returns:

True if there are no proposals in the context

Return type:

bool

Checks if any proposals have been provided to the context.

Out of convenience, this function will return True if self is None.

get_language()
Returns:

a GtkSource.Language or None

Return type:

GtkSource.Language or None

Gets the language of the underlying buffer, if any.

get_proposals_for_provider(provider)
Parameters:

provider (GtkSource.CompletionProvider) – a GtkSource.CompletionProvider

Returns:

a Gio.ListModel or None

Return type:

Gio.ListModel or None

Gets the Gio.ListModel associated with the provider.

You can connect to GtkSource.CompletionContext ::model-changed to receive notifications about when the model has been replaced by a new model.

New in version 5.6.

get_view()
Returns:

a GtkSource.View or None

Return type:

GtkSource.View or None

Gets the text view for the context.

get_word()
Returns:

a string containing the current word

Return type:

str

Gets the word that is being completed up to the position of the insert mark.

list_providers()
Returns:

a Gio.ListModel of GtkSource.CompletionProvider

Return type:

Gio.ListModel

Gets the providers that are associated with the context.

New in version 5.6.

set_proposals_for_provider(provider, results)
Parameters:

This function allows providers to update their results for a context outside of a call to [method`CompletionProvider`.populate_async].

This can be used to immediately return results for a provider while it does additional asynchronous work. Doing so will allow the completions to update while the operation is in progress.

Signal Details

GtkSource.CompletionContext.signals.provider_model_changed(completion_context, provider, model)
Signal Name:

provider-model-changed

Flags:

RUN_LAST

Parameters:

Emitted when a provider changes a model.

This signal is primarily useful for GtkSource.CompletionProvider's that want to track other providers in context. For example, it can be used to create a “top results” provider.

New in version 5.6.

Property Details

GtkSource.CompletionContext.props.busy
Name:

busy

Type:

bool

Default Value:

False

Flags:

READABLE

The “busy” property is True while the completion context is populating completion proposals.

GtkSource.CompletionContext.props.completion
Name:

completion

Type:

GtkSource.Completion

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The “completion” is the GtkSource.Completion that was used to create the context.

GtkSource.CompletionContext.props.empty
Name:

empty

Type:

bool

Default Value:

True

Flags:

READABLE

The “empty” property is True when there are no results.

It will be notified when the first result is added or the last result is removed.