GtkSource.CompletionProvider

g GObject.GInterface GObject.GInterface GtkSource.CompletionProvider GtkSource.CompletionProvider GObject.GInterface->GtkSource.CompletionProvider

Implementations:

GtkSource.CompletionSnippets, GtkSource.CompletionWords

Methods

activate (context, proposal)

display (context, proposal, cell)

get_priority (context)

get_title ()

is_trigger (iter, ch)

key_activates (context, proposal, keyval, state)

list_alternates (context, proposal)

populate_async (context, cancellable, callback, *user_data)

populate_finish (result)

refilter (context, model)

Virtual Methods

do_activate (context, proposal)

do_display (context, proposal, cell)

do_get_priority (context)

do_get_title ()

do_is_trigger (iter, ch)

do_key_activates (context, proposal, keyval, state)

do_list_alternates (context, proposal)

do_populate_async (context, cancellable, callback, *user_data)

do_populate_finish (result)

do_refilter (context, model)

Properties

None

Signals

None

Fields

None

Class Details

class GtkSource.CompletionProvider
Bases:

GObject.GInterface

Structure:

GtkSource.CompletionProviderInterface

Completion provider interface.

You must implement this interface to provide proposals to [class`Completion`].

In most cases, implementations of this interface will want to use [vfunc`CompletionProvider`.populate_async] to asynchronously populate the results to avoid blocking the main loop.

activate(context, proposal)
Parameters:

This function requests proposal to be activated by the GtkSource.CompletionProvider.

What the provider does to activate the proposal is specific to that provider. Many providers may choose to insert a GtkSource.Snippet with edit points the user may cycle through.

See also: [class`Snippet`], [class`SnippetChunk`], [method`View`.push_snippet]

display(context, proposal, cell)
Parameters:

This function requests that the GtkSource.CompletionProvider prepares cell to display the contents of proposal.

Based on cells column type, you may want to display different information.

This allows for columns of information among completion proposals resulting in better alignment of similar content (icons, return types, method names, and parameter lists).

get_priority(context)
Parameters:

context (GtkSource.CompletionContext) – a GtkSource.CompletionContext

Return type:

int

This function should return the priority of self in context.

The priority is used to sort groups of completion proposals by provider so that higher priority providers results are shown above lower priority providers.

Higher value indicates higher priority.

get_title()
Returns:

a title for the provider or None

Return type:

str or None

Gets the title of the completion provider, if any.

Currently, titles are not displayed in the completion results, but may be at some point in the future when non-None.

is_trigger(iter, ch)
Parameters:
Return type:

bool

This function is used to determine if a character inserted into the text editor should cause a new completion request to be triggered.

An example would be period ‘.’ which might indicate that the user wants to complete method or field names of an object.

This method will only trigger when text is inserted into the Gtk.TextBuffer while the completion list is visible and a proposal is selected. Incremental key-presses (like shift, control, or alt) are not triggerable.

key_activates(context, proposal, keyval, state)
Parameters:
Return type:

bool

This function is used to determine if a key typed by the user should activate proposal (resulting in committing the text to the editor).

This is useful when using languages where convention may lead to less typing by the user. One example may be the use of “.” or “-” to expand a field access in the C programming language.

list_alternates(context, proposal)
Parameters:
Returns:

a GLib.PtrArray of GtkSource.CompletionProposal or None.

Return type:

[GtkSource.CompletionProposal] or None

Providers should return a list of alternates to proposal or None if there are no alternates available.

This can be used by the completion view to allow the user to move laterally through similar proposals, such as overrides of methods by the same name.

populate_async(context, cancellable, callback, *user_data)
Parameters:

Asynchronously requests that the provider populates the completion results for context.

For providers that would like to populate a [iface`Gio`.ListModel] while those results are displayed to the user, [method`CompletionContext`.set_proposals_for_provider] may be used to reduce latency until the user sees results.

populate_finish(result)
Parameters:

result (Gio.AsyncResult) – a Gio.AsyncResult provided to callback

Raises:

GLib.Error

Returns:

a Gio.ListModel of GtkSource.CompletionProposal

Return type:

Gio.ListModel

Completes an asynchronous operation to populate a completion provider.

refilter(context, model)
Parameters:

This function can be used to filter results previously provided to the [class`CompletionContext`] by the GtkSource.CompletionProvider.

This can happen as the user types additional text onto the word so that previously matched items may be removed from the list instead of generating new [iface`Gio`.ListModel] of results.

do_activate(context, proposal) virtual
Parameters:

This function requests proposal to be activated by the GtkSource.CompletionProvider.

What the provider does to activate the proposal is specific to that provider. Many providers may choose to insert a GtkSource.Snippet with edit points the user may cycle through.

See also: [class`Snippet`], [class`SnippetChunk`], [method`View`.push_snippet]

do_display(context, proposal, cell) virtual
Parameters:

This function requests that the GtkSource.CompletionProvider prepares cell to display the contents of proposal.

Based on cells column type, you may want to display different information.

This allows for columns of information among completion proposals resulting in better alignment of similar content (icons, return types, method names, and parameter lists).

do_get_priority(context) virtual
Parameters:

context (GtkSource.CompletionContext) – a GtkSource.CompletionContext

Return type:

int

This function should return the priority of self in context.

The priority is used to sort groups of completion proposals by provider so that higher priority providers results are shown above lower priority providers.

Higher value indicates higher priority.

do_get_title() virtual
Returns:

a title for the provider or None

Return type:

str or None

Gets the title of the completion provider, if any.

Currently, titles are not displayed in the completion results, but may be at some point in the future when non-None.

do_is_trigger(iter, ch) virtual
Parameters:
Return type:

bool

This function is used to determine if a character inserted into the text editor should cause a new completion request to be triggered.

An example would be period ‘.’ which might indicate that the user wants to complete method or field names of an object.

This method will only trigger when text is inserted into the Gtk.TextBuffer while the completion list is visible and a proposal is selected. Incremental key-presses (like shift, control, or alt) are not triggerable.

do_key_activates(context, proposal, keyval, state) virtual
Parameters:
Return type:

bool

This function is used to determine if a key typed by the user should activate proposal (resulting in committing the text to the editor).

This is useful when using languages where convention may lead to less typing by the user. One example may be the use of “.” or “-” to expand a field access in the C programming language.

do_list_alternates(context, proposal) virtual
Parameters:
Returns:

a GLib.PtrArray of GtkSource.CompletionProposal or None.

Return type:

[GtkSource.CompletionProposal] or None

Providers should return a list of alternates to proposal or None if there are no alternates available.

This can be used by the completion view to allow the user to move laterally through similar proposals, such as overrides of methods by the same name.

do_populate_async(context, cancellable, callback, *user_data) virtual
Parameters:

Asynchronously requests that the provider populates the completion results for context.

For providers that would like to populate a [iface`Gio`.ListModel] while those results are displayed to the user, [method`CompletionContext`.set_proposals_for_provider] may be used to reduce latency until the user sees results.

do_populate_finish(result) virtual
Parameters:

result (Gio.AsyncResult) – a Gio.AsyncResult provided to callback

Returns:

a Gio.ListModel of GtkSource.CompletionProposal

Return type:

Gio.ListModel

Completes an asynchronous operation to populate a completion provider.

do_refilter(context, model) virtual
Parameters:

This function can be used to filter results previously provided to the [class`CompletionContext`] by the GtkSource.CompletionProvider.

This can happen as the user types additional text onto the word so that previously matched items may be removed from the list instead of generating new [iface`Gio`.ListModel] of results.