GtkSourceCompletionProvider

GtkSourceCompletionProvider — Completion provider interface

Functions

Types and Values

Object Hierarchy

    GInterface
    ╰── GtkSourceCompletionProvider

Prerequisites

GtkSourceCompletionProvider requires GObject.

Known Implementations

GtkSourceCompletionProvider is implemented by GtkSourceCompletionWords.

Includes

#include <gtksourceview/gtksource.h>

Description

You must implement this interface to provide proposals to GtkSourceCompletion

The provider may be displayed in the completion window as a header row, showing its name and optionally an icon. The icon may be specified as a GdkPixbuf, as an icon name or as a GIcon by implementing the corresponding get function. At most one of those get functions should return a value different from NULL, if they all return NULL no icon will be used.

Functions

gtk_source_completion_provider_get_name ()

gchar *
gtk_source_completion_provider_get_name
                               (GtkSourceCompletionProvider *provider);

Get the name of the provider. This should be a translatable name for display to the user. For example: _("Document word completion provider"). The returned string must be freed with g_free().

Parameters

Returns

a new string containing the name of the provider.


gtk_source_completion_provider_get_icon ()

GdkPixbuf *
gtk_source_completion_provider_get_icon
                               (GtkSourceCompletionProvider *provider);

Get the GdkPixbuf for the icon of the provider .

Parameters

provider

The GtkSourceCompletionProvider

 

Returns

The icon to be used for the provider, or NULL if the provider does not have a special icon.

[nullable][transfer none]


gtk_source_completion_provider_get_icon_name ()

const gchar *
gtk_source_completion_provider_get_icon_name
                               (GtkSourceCompletionProvider *provider);

Gets the icon name of provider .

Parameters

provider

The GtkSourceCompletionProvider

 

Returns

The icon name to be used for the provider, or NULL if the provider does not have a special icon.

[nullable][transfer none]

Since: 3.18


gtk_source_completion_provider_get_gicon ()

GIcon *
gtk_source_completion_provider_get_gicon
                               (GtkSourceCompletionProvider *provider);

Gets the GIcon for the icon of provider .

Parameters

provider

The GtkSourceCompletionProvider

 

Returns

The icon to be used for the provider, or NULL if the provider does not have a special icon.

[nullable][transfer none]

Since: 3.18


gtk_source_completion_provider_populate ()

void
gtk_source_completion_provider_populate
                               (GtkSourceCompletionProvider *provider,
                                GtkSourceCompletionContext *context);

Populate context with proposals from provider added with the gtk_source_completion_context_add_proposals() function.

Parameters


gtk_source_completion_provider_get_activation ()

GtkSourceCompletionActivation
gtk_source_completion_provider_get_activation
                               (GtkSourceCompletionProvider *provider);

Get with what kind of activation the provider should be activated.

Parameters

Returns

a combination of GtkSourceCompletionActivation.


gtk_source_completion_provider_match ()

gboolean
gtk_source_completion_provider_match (GtkSourceCompletionProvider *provider,
                                      GtkSourceCompletionContext *context);

Get whether the provider match the context of completion detailed in context .

Parameters

Returns

TRUE if provider matches the completion context, FALSE otherwise.


gtk_source_completion_provider_get_info_widget ()

GtkWidget *
gtk_source_completion_provider_get_info_widget
                               (GtkSourceCompletionProvider *provider,
                                GtkSourceCompletionProposal *proposal);

Get a customized info widget to show extra information of a proposal. This allows for customized widgets on a proposal basis, although in general providers will have the same custom widget for all their proposals and proposal can be ignored. The implementation of this function is optional.

If this function is not implemented, the default widget is a GtkLabel. The return value of gtk_source_completion_proposal_get_info() is used as the content of the GtkLabel.

If implemented, gtk_source_completion_provider_update_info() must also be implemented.

Parameters

provider

a GtkSourceCompletionProvider.

 

proposal

a currently selected GtkSourceCompletionProposal.

 

Returns

a custom GtkWidget to show extra information about proposal , or NULL if the provider does not have a special info widget.

[nullable][transfer none]


gtk_source_completion_provider_update_info ()

void
gtk_source_completion_provider_update_info
                               (GtkSourceCompletionProvider *provider,
                                GtkSourceCompletionProposal *proposal,
                                GtkSourceCompletionInfo *info);

Update extra information shown in info for proposal .

This function must be implemented when gtk_source_completion_provider_get_info_widget() is implemented.

Parameters


gtk_source_completion_provider_get_start_iter ()

gboolean
gtk_source_completion_provider_get_start_iter
                               (GtkSourceCompletionProvider *provider,
                                GtkSourceCompletionContext *context,
                                GtkSourceCompletionProposal *proposal,
                                GtkTextIter *iter);

Get the GtkTextIter at which the completion for proposal starts. When implemented, this information is used to position the completion window accordingly when a proposal is selected in the completion window. The proposal text inside the completion window is aligned on iter .

If this function is not implemented, the word boundary is taken to position the completion window. See gtk_source_completion_provider_activate_proposal() for an explanation on the word boundaries.

When the proposal is activated, the default handler uses iter as the start of the word to replace. See gtk_source_completion_provider_activate_proposal() for more information.

Parameters

provider

a GtkSourceCompletionProvider.

 

proposal

a GtkSourceCompletionProposal.

 

context

a GtkSourceCompletionContext.

 

iter

a GtkTextIter.

[out]

Returns

TRUE if iter was set for proposal , FALSE otherwise.


gtk_source_completion_provider_activate_proposal ()

gboolean
gtk_source_completion_provider_activate_proposal
                               (GtkSourceCompletionProvider *provider,
                                GtkSourceCompletionProposal *proposal,
                                GtkTextIter *iter);

Activate proposal at iter . When this functions returns FALSE, the default activation of proposal will take place which replaces the word at iter with the text of proposal (see gtk_source_completion_proposal_get_text()).

Here is how the default activation selects the boundaries of the word to replace. The end of the word is iter . For the start of the word, it depends on whether a start iter is defined for proposal (see gtk_source_completion_provider_get_start_iter()). If a start iter is defined, the start of the word is the start iter. Else, the word (as long as possible) will contain only alphanumerical and the "_" characters.

Parameters

provider

a GtkSourceCompletionProvider.

 

proposal

a GtkSourceCompletionProposal.

 

iter

a GtkTextIter.

 

Returns

TRUE to indicate that the proposal activation has been handled, FALSE otherwise.


gtk_source_completion_provider_get_interactive_delay ()

gint
gtk_source_completion_provider_get_interactive_delay
                               (GtkSourceCompletionProvider *provider);

Get the delay in milliseconds before starting interactive completion for this provider. A value of -1 indicates to use the default value as set by the “auto-complete-delay” property.

Parameters

Returns

the interactive delay in milliseconds.


gtk_source_completion_provider_get_priority ()

gint
gtk_source_completion_provider_get_priority
                               (GtkSourceCompletionProvider *provider);

Get the provider priority. The priority determines the order in which proposals appear in the completion popup. Higher priorities are sorted before lower priorities. The default priority is 0.

Parameters

Returns

the provider priority.

Types and Values

GtkSourceCompletionProvider

typedef struct _GtkSourceCompletionProvider GtkSourceCompletionProvider;

struct GtkSourceCompletionProviderIface

struct GtkSourceCompletionProviderIface {
	GTypeInterface g_iface;

	gchar		*(*get_name)       	(GtkSourceCompletionProvider *provider);

	GdkPixbuf *(*get_icon)       	(GtkSourceCompletionProvider *provider);
	const gchar *(*get_icon_name)   (GtkSourceCompletionProvider *provider);
	GIcon		*(*get_gicon)       (GtkSourceCompletionProvider *provider);

	void 		 (*populate) 		(GtkSourceCompletionProvider *provider,
						 GtkSourceCompletionContext  *context);

	gboolean 	 (*match)		(GtkSourceCompletionProvider *provider,
	                                         GtkSourceCompletionContext  *context);

	GtkSourceCompletionActivation
		         (*get_activation) (GtkSourceCompletionProvider *provider);

	GtkWidget 	*(*get_info_widget) (GtkSourceCompletionProvider *provider,
						 GtkSourceCompletionProposal *proposal);
	void		 (*update_info)		(GtkSourceCompletionProvider *provider,
						 GtkSourceCompletionProposal *proposal,
						 GtkSourceCompletionInfo     *info);

	gboolean	 (*get_start_iter) (GtkSourceCompletionProvider *provider,
						 GtkSourceCompletionContext  *context,
						 GtkSourceCompletionProposal *proposal,
						 GtkTextIter                 *iter);
	gboolean	 (*activate_proposal) (GtkSourceCompletionProvider *provider,
						 GtkSourceCompletionProposal *proposal,
						 GtkTextIter                 *iter);

	gint		 (*get_interactive_delay) (GtkSourceCompletionProvider *provider);
	gint		 (*get_priority) (GtkSourceCompletionProvider *provider);
};

The virtual function table for GtkSourceCompletionProvider.

Members

get_name ()

The virtual function pointer for gtk_source_completion_provider_get_name(). Must be implemented.

 

get_icon ()

The virtual function pointer for gtk_source_completion_provider_get_icon(). By default, NULL is returned.

 

get_icon_name ()

The virtual function pointer for gtk_source_completion_provider_get_icon_name(). By default, NULL is returned.

 

get_gicon ()

The virtual function pointer for gtk_source_completion_provider_get_gicon(). By default, NULL is returned.

 

populate ()

The virtual function pointer for gtk_source_completion_provider_populate(). Add no proposals by default.

 

match ()

The virtual function pointer for gtk_source_completion_provider_match(). By default, TRUE is returned.

 

get_activation ()

The virtual function pointer for gtk_source_completion_provider_get_activation(). The combination of all GtkSourceCompletionActivation is returned by default.

 

get_info_widget ()

The virtual function pointer for gtk_source_completion_provider_get_info_widget(). By default, NULL is returned.

 

update_info ()

The virtual function pointer for gtk_source_completion_provider_update_info(). Does nothing by default.

 

get_start_iter ()

The virtual function pointer for gtk_source_completion_provider_get_start_iter(). By default, FALSE is returned.

 

activate_proposal ()

The virtual function pointer for gtk_source_completion_provider_activate_proposal(). By default, FALSE is returned.

 

get_interactive_delay ()

The virtual function pointer for gtk_source_completion_provider_get_interactive_delay(). By default, -1 is returned.

 

get_priority ()

The virtual function pointer for gtk_source_completion_provider_get_priority(). By default, 0 is returned.