Class: Gtk::EntryCompletion
- Inherits:
-
Object
- Object
- Gtk::EntryCompletion
- Defined in:
- (unknown)
Overview
GtkEntryCompletion is an auxiliary object to provide completion functionality
for GtkEntry.
It implements the [ifaceGtk.CellLayout] 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
[methodGtk.EntryCompletion.set_text_column]), but this can be overridden
with a custom match function (see [methodGtk.EntryCompletion.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 [signalGtk.EntryCompletion::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 [methodGtk.Entry.set_completion].
GtkEntryCompletion uses a [classGtk.TreeModelFilter] model to
represent the subset of the entire model that is currently matching.
While the GtkEntryCompletion signals
[signalGtk.EntryCompletion::match-selected] and
[signalGtk.EntryCompletion::cursor-on-match] take the original model
and an iter pointing to that model as arguments, other callbacks and
signals (such as GtkCellLayoutDataFunc or
[signalGtk.CellArea::apply-attributes)]
will generally take the filter model as argument. As long as you are
only calling [methodGtk.TreeModel.get], this will make no difference to
you. If for some reason, you need the original model, use
[methodGtk.TreeModelFilter.get_model]. Don’t forget to use
[methodGtk.TreeModelFilter.convert_iter_to_child_iter] to obtain a
matching iter.
Instance Method Summary collapse
-
#cell_area ⇒ Gtk::CellArea
The
GtkCellAreaused to layout cell renderers in the treeview column. -
#cell_area=(cell_area) ⇒ Gtk::CellArea
The
GtkCellAreaused to layout cell renderers in the treeview column. -
#complete ⇒ nil
Requests a completion operation, or in other words a refiltering of the current list with completions, using the current key.
-
#completion_prefix ⇒ String
Get the original text entered by the user that triggered the completion or nil if there’s no completion ongoing.
-
#compute_prefix(key) ⇒ String
Computes the common prefix that is shared by all rows in completion that start with key.
-
#entry ⇒ Gtk::Widget
Gets the entry completion has been attached to.
-
#initialize(area) ⇒ Gtk::EntryCompletion
constructor
Creates a new
GtkEntryCompletionobject using the specified area. -
#inline_completion ⇒ Boolean
Returns whether the common prefix of the possible completions should be automatically inserted in the entry.
-
#inline_completion=(inline_completion) ⇒ Boolean
Determines whether the common prefix of the possible completions should be inserted automatically in the entry.
-
#inline_completion? ⇒ Boolean
Determines whether the common prefix of the possible completions should be inserted automatically in the entry.
-
#inline_selection ⇒ Boolean
Returns true if inline-selection mode is turned on.
-
#inline_selection=(inline_selection) ⇒ Boolean
Determines whether the possible completions on the popup will appear in the entry as you navigate through them.
-
#inline_selection? ⇒ Boolean
Determines whether the possible completions on the popup will appear in the entry as you navigate through them.
-
#insert_prefix ⇒ nil
Requests a prefix insertion.
-
#minimum_key_length ⇒ Integer
Minimum-key-length.
- #minimum_key_length=(minimum_key_length) ⇒ Integer
-
#model ⇒ Gtk::TreeModel
Model.
- #model=(model) ⇒ Gtk::TreeModel
-
#popup_completion ⇒ Boolean
Returns whether the completions should be presented in a popup window.
-
#popup_completion=(popup_completion) ⇒ Boolean
Determines whether the possible completions should be shown in a popup window.
-
#popup_completion? ⇒ Boolean
Determines whether the possible completions should be shown in a popup window.
-
#popup_set_width ⇒ Boolean
Returns whether the completion popup window will be resized to the width of the entry.
-
#popup_set_width=(popup_set_width) ⇒ Boolean
Determines whether the completions popup window will be resized to the width of the entry.
-
#popup_set_width? ⇒ Boolean
Determines whether the completions popup window will be resized to the width of the entry.
-
#popup_single_match ⇒ Boolean
Returns whether the completion popup window will appear even if there is only a single match.
-
#popup_single_match=(popup_single_match) ⇒ Boolean
Determines whether the completions popup window will shown for a single possible completion.
-
#popup_single_match? ⇒ Boolean
Determines whether the completions popup window will shown for a single possible completion.
-
#set_match_func(func, func_data, func_notify) ⇒ nil
Sets the match function for completion to be func.
-
#text_column ⇒ Integer
The column of the model containing the strings.
-
#text_column=(text_column) ⇒ Integer
The column of the model containing the strings.
Constructor Details
#initialize(area) ⇒ Gtk::EntryCompletion
Creates a new GtkEntryCompletion object using the
specified area.
The GtkCellArea is used to layout cells in the underlying
GtkTreeViewColumn for the drop-down menu.
Instance Method Details
#cell_area ⇒ Gtk::CellArea
The GtkCellArea used to layout cell renderers in the treeview column.
If no area is specified when creating the entry completion with [ctorGtk.EntryCompletion.new_with_area], a horizontally oriented [classGtk.CellAreaBox] will be used.
#cell_area=(cell_area) ⇒ Gtk::CellArea
The GtkCellArea used to layout cell renderers in the treeview column.
If no area is specified when creating the entry completion with [ctorGtk.EntryCompletion.new_with_area], a horizontally oriented [classGtk.CellAreaBox] will be used.
#complete ⇒ nil
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.
#completion_prefix ⇒ String
Get the original text entered by the user that triggered the completion or nil if there’s no completion ongoing.
#compute_prefix(key) ⇒ String
Computes the common prefix that is shared by all rows in completion that start with key.
If no row matches key, nil will be returned. Note that a text column must have been set for this function to work, see [methodGtk.EntryCompletion.set_text_column] for details.
#entry ⇒ Gtk::Widget
Gets the entry completion has been attached to.
#inline_completion ⇒ Boolean
Returns whether the common prefix of the possible completions should be automatically inserted in the entry.
#inline_completion=(inline_completion) ⇒ Boolean
Determines whether the common prefix of the possible completions should be inserted automatically in the entry.
Note that this requires text-column to be set, even if you are using a custom match function.
#inline_completion? ⇒ Boolean
Determines whether the common prefix of the possible completions should be inserted automatically in the entry.
Note that this requires text-column to be set, even if you are using a custom match function.
#inline_selection ⇒ Boolean
Returns true if inline-selection mode is turned on.
#inline_selection=(inline_selection) ⇒ Boolean
Determines whether the possible completions on the popup will appear in the entry as you navigate through them.
#inline_selection? ⇒ Boolean
Determines whether the possible completions on the popup will appear in the entry as you navigate through them.
#insert_prefix ⇒ nil
Requests a prefix insertion.
#minimum_key_length ⇒ Integer
Returns minimum-key-length.
#minimum_key_length=(minimum_key_length) ⇒ Integer
#model ⇒ Gtk::TreeModel
Returns model.
#model=(model) ⇒ Gtk::TreeModel
#popup_completion ⇒ Boolean
Returns whether the completions should be presented in a popup window.
#popup_completion=(popup_completion) ⇒ Boolean
Determines whether the possible completions should be shown in a popup window.
#popup_completion? ⇒ Boolean
Determines whether the possible completions should be shown in a popup window.
#popup_set_width ⇒ Boolean
Returns whether the completion popup window will be resized to the width of the entry.
#popup_set_width=(popup_set_width) ⇒ Boolean
Determines whether the completions popup window will be resized to the width of the entry.
#popup_set_width? ⇒ Boolean
Determines whether the completions popup window will be resized to the width of the entry.
#popup_single_match ⇒ Boolean
Returns whether the completion popup window will appear even if there is only a single match.
#popup_single_match=(popup_single_match) ⇒ Boolean
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 [propertyGtk.EntryCompletion:inline-completion].
#popup_single_match? ⇒ Boolean
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 [propertyGtk.EntryCompletion:inline-completion].
#set_match_func(func, func_data, func_notify) ⇒ nil
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.
#text_column ⇒ Integer
The column of the model containing the strings.
Note that the strings must be UTF-8.
#text_column=(text_column) ⇒ Integer
The column of the model containing the strings.
Note that the strings must be UTF-8.