Gtk.EntryCompletion¶
class — extends GObject.Object, Buildable, CellLayout
:::warning Deprecated since 4.10 This API is deprecated. :::
GtkEntryCompletion is an auxiliary object to provide completion functionality
for GtkEntry.
It implements the 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
EntryCompletion.set_text_column), but this can be overridden
with a custom match function (see 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 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
Entry.set_completion.
GtkEntryCompletion uses a TreeModelFilter model to
represent the subset of the entire model that is currently matching.
While the GtkEntryCompletion signals
EntryCompletion.match-selected and
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 TreeModel.get, this will make no difference to
you. If for some reason, you need the original model, use
TreeModelFilter.get_model. Don’t forget to use
TreeModelFilter.convert_iter_to_child_iter to obtain a
matching iter.
Constructors¶
new¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Creates a new GtkEntryCompletion object.
new_with_area¶
:::warning Deprecated since 4.10 This API is deprecated. :::
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.
Parameters:
area— theGtkCellAreaused to layout cells
Methods¶
complete¶
:::warning Deprecated since 4.10 This API is deprecated. :::
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.
compute_prefix¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Computes the common prefix that is shared by all rows in completion
that start with key.
If no row matches key, None will be returned.
Note that a text column must have been set for this function to work,
see EntryCompletion.set_text_column for details.
Parameters:
key— The text to complete for
get_completion_prefix¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Get the original text entered by the user that triggered
the completion or None if there’s no completion ongoing.
get_entry¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Gets the entry completion has been attached to.
get_inline_completion¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Returns whether the common prefix of the possible completions should be automatically inserted in the entry.
get_inline_selection¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Returns True if inline-selection mode is turned on.
get_minimum_key_length¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Returns the minimum key length as set for completion.
get_model¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Returns the model the GtkEntryCompletion is using as data source.
Returns None if the model is unset.
get_popup_completion¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Returns whether the completions should be presented in a popup window.
get_popup_set_width¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Returns whether the completion popup window will be resized to the width of the entry.
get_popup_single_match¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Returns whether the completion popup window will appear even if there is only a single match.
get_text_column¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Returns the column in the model of completion to get strings from.
insert_prefix¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Requests a prefix insertion.
set_inline_completion¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Sets whether the common prefix of the possible completions should be automatically inserted in the entry.
Parameters:
inline_completion—Trueto do inline completion
set_inline_selection¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Sets whether it is possible to cycle through the possible completions inside the entry.
Parameters:
inline_selection—Trueto do inline selection
set_match_func¶
:::warning Deprecated since 4.10 This API is deprecated. :::
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.
Parameters:
func— theGtkEntryCompletionMatchFunc to use
set_minimum_key_length¶
:::warning Deprecated since 4.10 This API is deprecated. :::
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 results anyway (ie, a too large dataset).
Parameters:
length— the minimum length of the key in order to start completing
set_model¶
:::warning Deprecated since 4.10 This API is deprecated. :::
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 None, then it
will unset the model.
Parameters:
model— theGtkTreeModel
set_popup_completion¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Sets whether the completions should be presented in a popup window.
Parameters:
popup_completion—Trueto do popup completion
set_popup_set_width¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Sets whether the completion popup window will be resized to be the same width as the entry.
Parameters:
popup_set_width—Trueto make the width of the popup the same as the entry
set_popup_single_match¶
:::warning Deprecated since 4.10 This API is deprecated. :::
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 EntryCompletion.inline-completion.
Parameters:
popup_single_match—Trueif the popup should appear even for a single match
set_text_column¶
:::warning Deprecated since 4.10 This API is deprecated. :::
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 the completion list,
and to get those strings from column in the model of completion.
This functions creates and adds a GtkCellRendererText for the selected
column. If you need to set the text column, but don't want the cell
renderer, use g_object_set() to set the
EntryCompletion.text-column property directly.
Parameters:
column— the column in the model ofcompletionto get strings from
Properties¶
cell_area¶
The GtkCellArea used to layout cell renderers in the treeview column.
If no area is specified when creating the entry completion with
EntryCompletion.new_with_area, a horizontally oriented
CellAreaBox will be used.
inline_completion¶
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¶
Determines whether the possible completions on the popup will appear in the entry as you navigate through them.
minimum_key_length¶
The minimum key length as set for completion.
model¶
The model used as data source.
popup_completion¶
Determines whether the possible completions should be shown in a popup window.
popup_set_width¶
Determines whether the completions popup window will be resized to the width of the entry.
popup_single_match¶
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
EntryCompletion.inline-completion.
text_column¶
The column of the model containing the strings.
Note that the strings must be UTF-8.
Signals¶
cursor-on-match¶
Emitted when a match from the cursor is on a match of the list.
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.
Note that model is the model that was passed to
EntryCompletion.set_model.
insert-prefix¶
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 GtkFileChooser inserts only the part of the prefix up to the
next '/'.
match-selected¶
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.
Note that model is the model that was passed to
EntryCompletion.set_model.
no-matches¶
Emitted when the filter model has zero number of rows in completion_complete method.
In other words when GtkEntryCompletion is out of suggestions.