Next: , Previous: GtkEntry, Up: Top

21 GtkEntryCompletion

Completion functionality for GtkEntry

21.1 Overview

<gtk-entry-completion> is an auxiliary object to be used in conjunction with <gtk-entry> to provide the completion functionality. It implements the <gtk-cell-layout> interface, to allow the user to add extra cells to the <gtk-tree-view> with completion matches.

"Completion functionality" means that when the user modifies the text in the entry, <gtk-entry-completion> 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-set-text-column), but this can be overridden with a custom match function (see gtk-entry-completion-set-match-func).

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 ::match-selected signal and updating the entry in the signal handler. Note that you should return ‘#t’ from the signal handler to suppress the default behaviour.

To add completion functionality to an entry, use gtk-entry-set-completion.

In addition to regular completion matches, which will be inserted into the entry when they are selected, <gtk-entry-completion> 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 ::action-activated signal is emitted.

21.2 Usage

— Class: <gtk-entry-completion>

Derives from <gtk-buildable>, <gtk-cell-layout>, <gobject>.

This class defines the following slots:

The model to find matches in
Minimum length of the search key in order to look up matches
The column of the model containing the strings.
Whether the common prefix should be inserted automatically
Whether the completions should be shown in a popup window
If TRUE, the popup window will have the same size as the entry
If TRUE, the popup window will appear for a single match.
Your description here
— Signal on <gtk-entry-completion>: insert-prefix (arg0 <gchararray>) ⇒ <gboolean>

Gets emitted when the inline autocompletion is triggered. The default behaviour is to make the entry display the whole prefix and select the newly inserted part.

Applications may connect to this signal in order to insert only a smaller part of the prefix into the entry - e.g. the entry used in the <gtk-file-chooser> inserts only the part of the prefix up to the next '/'.

Since 2.6

— Signal on <gtk-entry-completion>: match-selected (arg0 <gtk-tree-model>) (arg1 <gtk-tree-iter>) ⇒ <gboolean>

Gets emitted when a match from the list is selected. The default behaviour is to replace the contents of the entry with the contents of the text column in the row pointed to by iter.

Since 2.4

— Signal on <gtk-entry-completion>: cursor-on-match (arg0 <gtk-tree-model>) (arg1 <gtk-tree-iter>) ⇒ <gboolean>


— Signal on <gtk-entry-completion>: action-activated (arg0 <gint>)

Gets emitted when an action is activated.

Since 2.4

— Function: gtk-entry-completion-new ⇒  (ret <gtk-entry-completion>)

Creates a new <gtk-entry-completion> object.

A newly created <gtk-entry-completion> object.

Since 2.4

— Function: gtk-entry-completion-get-entry (self <gtk-entry-completion>) ⇒  (ret <gtk-widget>)
— Method: get-entry

Gets the entry completion has been attached to.

A <gtk-entry-completion>.
The entry completion has been attached to.

Since 2.4

— Function: gtk-entry-completion-set-model (self <gtk-entry-completion>) (model <gtk-tree-model>)
— Method: set-model

Sets the model for a <gtk-entry-completion>. If completion already has a model set, it will remove it before setting the new model. If model is ‘#f’, then it will unset the model.

A <gtk-entry-completion>.
The <gtk-tree-model>.

Since 2.4

— Function: gtk-entry-completion-get-model (self <gtk-entry-completion>) ⇒  (ret <gtk-tree-model>)
— Method: get-model

Returns the model the <gtk-entry-completion> is using as data source. Returns ‘#f’ if the model is unset.

A <gtk-entry-completion>.
A <gtk-tree-model>, or ‘#f’ if none is currently being used.

Since 2.4

— Function: gtk-entry-completion-complete (self <gtk-entry-completion>)
— Method: 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.

A <gtk-entry-completion>.

Since 2.4

— Function: gtk-entry-completion-insert-prefix (self <gtk-entry-completion>)
— Method: insert-prefix

Requests a prefix insertion.

a <gtk-entry-completion>

Since 2.6

— Function: gtk-entry-completion-delete-action (self <gtk-entry-completion>) (index int)
— Method: delete-action

Deletes the action at index from completion's action list.

A <gtk-entry-completion>.
The index of the item to Delete.

Since 2.4