gtk.entry_completion

Module for [EntryCompletion] class

Types 3

#GtkEntryCompletion is an auxiliary object to be used in conjunction with #GtkEntry to provide the completion functionality. It implements the #GtkCellLayout interface, to allow the user to add extra cells to the #GtkTreeView with completion matches.

“Completion functionality” means that when the user modifies the text in the entry, #GtkEntryCompletion checks which rows in the model match the current content of the entry, and displays a list of matches. By default, the matching is done by comparing the entry text case-insensitively against the text column of the model (see [gtk.entry_completion.EntryCompletion.setTextColumn]), but this can be overridden with a custom match function (see [gtk.entry_completion.EntryCompletion.setMatchFunc]).

When the user selects a completion, the content of the entry is updated. By default, the content of the entry is replaced by the text column of the model, but this can be overridden by connecting to the #GtkEntryCompletion::match-selected signal and updating the entry in the signal handler. Note that you should return true from the signal handler to suppress the default behaviour.

To add completion functionality to an entry, use [gtk.entry.Entry.setCompletion].

In addition to regular completion matches, which will be inserted into the entry when they are selected, #GtkEntryCompletion also allows to display “actions” in the popup window. Their appearance is similar to menuitems, to differentiate them clearly from completion strings. When an action is selected, the #GtkEntryCompletion::action-activated signal is emitted.

GtkEntryCompletion uses a #GtkTreeModelFilter model to represent the subset of the entire model that is currently matching. While the GtkEntryCompletion signals #GtkEntryCompletion::match-selected and #GtkEntryCompletion::cursor-on-match take the original model and an iter pointing to that model as arguments, other callbacks and signals (such as #GtkCellLayoutDataFuncs or #GtkCellArea::apply-attributes) will generally take the filter model as argument. As long as you are only calling [gtk.tree_model.TreeModel.get], this will make no difference to you. If for some reason, you need the original model, use [gtk.tree_model_filter.TreeModelFilter.getModel]. Don’t forget to use [gtk.tree_model_filter.TreeModelFilter.convertIterToChildIter] to obtain a matching iter.

Methods
GType _gType() @property
EntryCompletion self()Returns `this`, for use in `with` statements.
EntryCompletionGidBuilder builder()Get builder for [gtk.entry_completion.EntryCompletion] Returns: New builder object
gtk.cell_area.CellArea cellArea() @propertyGet `cellArea` property. Returns: The #GtkCellArea used to layout cell renderers in the treeview column.
bool inlineCompletion() @propertyGet `inlineCompletion` property. Returns: Determines whether the common prefix of the possible completions should be inserted automatically in the entry. Note that this requires text-column to be s...
void inlineCompletion(bool propval) @propertySet `inlineCompletion` property. Params: propval = Determines whether the common prefix of the possible completions should be inserted automatically in the entry. Note that this requires text-colum...
bool inlineSelection() @propertyGet `inlineSelection` property. Returns: Determines whether the possible completions on the popup will appear in the entry as you navigate through them.
void inlineSelection(bool propval) @propertySet `inlineSelection` property. Params: propval = Determines whether the possible completions on the popup will appear in the entry as you navigate through them.
int minimumKeyLength() @property
void minimumKeyLength(int propval) @property
void model(gtk.tree_model.TreeModel propval) @property
bool popupCompletion() @propertyGet `popupCompletion` property. Returns: Determines whether the possible completions should be shown in a popup window.
void popupCompletion(bool propval) @propertySet `popupCompletion` property. Params: propval = Determines whether the possible completions should be shown in a popup window.
bool popupSetWidth() @propertyGet `popupSetWidth` property. Returns: Determines whether the completions popup window will be resized to the width of the entry.
void popupSetWidth(bool propval) @propertySet `popupSetWidth` property. Params: propval = Determines whether the completions popup window will be resized to the width of the entry.
bool popupSingleMatch() @propertyGet `popupSingleMatch` property. Returns: Determines whether the completions popup window will shown for a single possible completion. You probably want to set this to false if you are using [inlin...
void popupSingleMatch(bool propval) @propertySet `popupSingleMatch` property. Params: propval = Determines whether the completions popup window will shown for a single possible completion. You probably want to set this to false if you are usi...
int textColumn() @propertyGet `textColumn` property. Returns: The column of the model containing the strings. Note that the strings must be UTF-8.
void textColumn(int propval) @propertySet `textColumn` property. Params: propval = The column of the model containing the strings. Note that the strings must be UTF-8.
gtk.entry_completion.EntryCompletion newWithArea(gtk.cell_area.CellArea area)Creates a new #GtkEntryCompletion object using the specified area to layout cells in the underlying #GtkTreeViewColumn for the drop-down menu.
void complete()Requests a completion operation, or in other words a refiltering of the current list with completions, using the current key. The completion list view will be updated accordingly.
string computePrefix(string key)Computes the common prefix that is shared by all rows in completion that start with key. If no row matches key, null will be returned. Note that a text column must have been set for this function t...
void deleteAction(int index)Deletes the action at index_ from completion’s action list.
string getCompletionPrefix()Get the original text entered by the user that triggered the completion or null if there’s no completion ongoing. Returns: the prefix for the current completion
gtk.widget.Widget getEntry()Gets the entry completion has been attached to. Returns: The entry completion has been attached to
bool getInlineCompletion()Returns whether the common prefix of the possible completions should be automatically inserted in the entry. Returns: true if inline completion is turned on
bool getInlineSelection()Returns true if inline-selection mode is turned on. Returns: true if inline-selection mode is on
int getMinimumKeyLength()Returns the minimum key length as set for completion. Returns: The currently used minimum key length
gtk.tree_model.TreeModel getModel()Returns the model the #GtkEntryCompletion is using as data source. Returns null if the model is unset. Returns: A #GtkTreeModel, or null if none is currently being used
bool getPopupCompletion()Returns whether the completions should be presented in a popup window. Returns: true if popup completion is turned on
bool getPopupSetWidth()Returns whether the completion popup window will be resized to the width of the entry. Returns: true if the popup window will be resized to the width of the entry
bool getPopupSingleMatch()Returns whether the completion popup window will appear even if there is only a single match. Returns: true if the popup window will appear regardless of the number of matches
int getTextColumn()Returns the column in the model of completion to get strings from. Returns: the column containing the strings
void insertActionMarkup(int index, string markup)Inserts an action in completion’s action item list at position index_ with markup markup.
void insertActionText(int index, string text)Inserts an action in completion’s action item list at position index with text text. If you want the action item to have markup, use [gtk.entrycompletion.EntryCompletion.insertActionMarkup].
void insertPrefix()Requests a prefix insertion.
void setInlineCompletion(bool inlineCompletion)Sets whether the common prefix of the possible completions should be automatically inserted in the entry.
void setInlineSelection(bool inlineSelection)Sets whether it is possible to cycle through the possible completions inside the entry.
void setMatchFunc(gtk.types.EntryCompletionMatchFunc func)Sets the match function for completion to be func. The match function is used to determine if a row should or should not be in the completion list.
void setMinimumKeyLength(int length)Requires the length of the search key for completion to be at least length. This is useful for long lists, where completing using a small key takes a lot of time and will come up with meaningless r...
void setModel(gtk.tree_model.TreeModel model = null)Sets the model for a #GtkEntryCompletion. If completion already has a model set, it will remove it before setting the new model. If model is null, then it will unset the model.
void setPopupCompletion(bool popupCompletion)Sets whether the completions should be presented in a popup window.
void setPopupSetWidth(bool popupSetWidth)Sets whether the completion popup window will be resized to be the same width as the entry.
void setPopupSingleMatch(bool popupSingleMatch)Sets whether the completion popup window will appear even if there is only a single match. You may want to set this to false if you are using [inline completion][GtkEntryCompletion--inline-completi...
void setTextColumn(int column)Convenience function for setting up the most used case of this code: a completion list with just strings. This function will set up completion to have a list displaying all (and just) strings in th...
gulong connectActionActivated(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == int))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.entry_completion.EntryCompletion))) && Parameters!T.length < 3)Connect to `ActionActivated` signal.
gulong connectCursorOnMatch(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == bool) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.tree_model.TreeModel))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] == gtk.tree_iter.TreeIter))) && (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] : gtk.entry_completion.EntryCompletion))) && Parameters!T.length < 4)Connect to `CursorOnMatch` signal.
gulong connectInsertPrefix(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == bool) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == string))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.entry_completion.EntryCompletion))) && Parameters!T.length < 3)Connect to `InsertPrefix` signal.
gulong connectMatchSelected(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == bool) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.tree_model.TreeModel))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] == gtk.tree_iter.TreeIter))) && (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] : gtk.entry_completion.EntryCompletion))) && Parameters!T.length < 4)Connect to `MatchSelected` signal.
gulong connectNoMatches(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.entry_completion.EntryCompletion))) && Parameters!T.length < 2)Connect to `NoMatches` signal.
Constructors
this(void * ptr, Flag!"Take" take)
this()Creates a new #GtkEntryCompletion object. Returns: A newly created #GtkEntryCompletion object
Methods
T cellArea(gtk.cell_area.CellArea propval)Set `cellArea` property. Params: propval = The #GtkCellArea used to layout cell renderers in the treeview column.
T inlineCompletion(bool propval)Set `inlineCompletion` property. Params: propval = Determines whether the common prefix of the possible completions should be inserted automatically in the entry. Note that this requires text-colum...
T inlineSelection(bool propval)Set `inlineSelection` property. Params: propval = Determines whether the possible completions on the popup will appear in the entry as you navigate through them. Returns: Builder instance for fluen...
T minimumKeyLength(int propval)
T popupCompletion(bool propval)Set `popupCompletion` property. Params: propval = Determines whether the possible completions should be shown in a popup window. Returns: Builder instance for fluent chaining
T popupSetWidth(bool propval)Set `popupSetWidth` property. Params: propval = Determines whether the completions popup window will be resized to the width of the entry. Returns: Builder instance for fluent chaining
T popupSingleMatch(bool propval)Set `popupSingleMatch` property. Params: propval = Determines whether the completions popup window will shown for a single possible completion. You probably want to set this to false if you are usi...
T textColumn(int propval)Set `textColumn` property. Params: propval = The column of the model containing the strings. Note that the strings must be UTF-8. Returns: Builder instance for fluent chaining

Fluent builder for [gtk.entry_completion.EntryCompletion]