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 _getGType() static nothrow
GType _gType() @property nothrow
EntryCompletion self() nothrowReturns `this`, for use in `with` statements.
EntryCompletionGidBuilder builder() static nothrowGet builder for [gtk.entry_completion.EntryCompletion] Returns: New builder object
gtk.cell_area.CellArea cellArea() @property nothrowGet `cellArea` property. Returns: The #GtkCellArea used to layout cell renderers in the treeview column.
bool inlineCompletion() @property nothrowGet `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) @property nothrowSet `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() @property nothrowGet `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) @property nothrowSet `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 nothrow
void minimumKeyLength(int propval) @property nothrow
gtk.tree_model.TreeModel model() @property nothrow
void model(gtk.tree_model.TreeModel propval) @property nothrow
bool popupCompletion() @property nothrowGet `popupCompletion` property. Returns: Determines whether the possible completions should be shown in a popup window.
void popupCompletion(bool propval) @property nothrowSet `popupCompletion` property. Params: propval = Determines whether the possible completions should be shown in a popup window.
bool popupSetWidth() @property nothrowGet `popupSetWidth` property. Returns: Determines whether the completions popup window will be resized to the width of the entry.
void popupSetWidth(bool propval) @property nothrowSet `popupSetWidth` property. Params: propval = Determines whether the completions popup window will be resized to the width of the entry.
bool popupSingleMatch() @property nothrowGet `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) @property nothrowSet `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() @property nothrowGet `textColumn` property. Returns: The column of the model containing the strings. Note that the strings must be UTF-8.
void textColumn(int propval) @property nothrowSet `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) static nothrowCreates a new #GtkEntryCompletion object using the specified area to layout cells in the underlying #GtkTreeViewColumn for the drop-down menu.
void complete() nothrowRequests 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) nothrowComputes 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) nothrowDeletes the action at index_ from completion’s action list.
string getCompletionPrefix() nothrowGet 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() nothrowGets the entry completion has been attached to. Returns: The entry completion has been attached to
bool getInlineCompletion() nothrowReturns 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() nothrowReturns true if inline-selection mode is turned on. Returns: true if inline-selection mode is on
int getMinimumKeyLength() nothrowReturns the minimum key length as set for completion. Returns: The currently used minimum key length
gtk.tree_model.TreeModel getModel() nothrowReturns 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() nothrowReturns whether the completions should be presented in a popup window. Returns: true if popup completion is turned on
bool getPopupSetWidth() nothrowReturns 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() nothrowReturns 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() nothrowReturns the column in the model of completion to get strings from. Returns: the column containing the strings
void insertActionMarkup(int index, string markup) nothrowInserts an action in completion’s action item list at position index_ with markup markup.
void insertActionText(int index, string text) nothrowInserts 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.entry_completion.EntryCompletion.insertActionMarkup].
void insertPrefix() nothrowRequests a prefix insertion.
void setInlineCompletion(bool inlineCompletion) nothrowSets whether the common prefix of the possible completions should be automatically inserted in the entry.
void setInlineSelection(bool inlineSelection) nothrowSets whether it is possible to cycle through the possible completions inside the entry.
void setMatchFunc(gtk.types.EntryCompletionMatchFunc func) nothrowSets 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) nothrowRequires 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) nothrowSets 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) nothrowSets whether the completions should be presented in a popup window.
void setPopupSetWidth(bool popupSetWidth) nothrowSets whether the completion popup window will be resized to be the same width as the entry.
void setPopupSingleMatch(bool popupSingleMatch) nothrowSets 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) nothrowConvenience 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect to `NoMatches` signal.
Constructors
this(void * ptr, Flag!"Take" take)
this()Creates a new #GtkEntryCompletion object. Returns: A newly created #GtkEntryCompletion object

Fluent builder implementation template for gtk.entry_completion.EntryCompletion

Methods
T cellArea(gtk.cell_area.CellArea propval) nothrowSet `cellArea` property. Params: propval = The #GtkCellArea used to layout cell renderers in the treeview column.
T inlineCompletion(bool propval) nothrowSet `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) nothrowSet `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) nothrow
T model(gtk.tree_model.TreeModel propval) nothrow
T popupCompletion(bool propval) nothrowSet `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) nothrowSet `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) nothrowSet `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) nothrowSet `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
Methods
EntryCompletion build() nothrowCreate object from builder. Returns: New object