Synopsis#include <gtk/gtk.h> GtkEntryCompletion; gboolean (*GtkEntryCompletionMatchFunc) (GtkEntryCompletion *completion, const gchar *key, GtkTreeIter *iter, gpointer user_data); GtkEntryCompletion* gtk_entry_completion_new (void); GtkWidget* gtk_entry_completion_get_entry (GtkEntryCompletion *completion); void gtk_entry_completion_set_model (GtkEntryCompletion *completion, GtkTreeModel *model); GtkTreeModel* gtk_entry_completion_get_model (GtkEntryCompletion *completion); void gtk_entry_completion_set_match_func (GtkEntryCompletion *completion, GtkEntryCompletionMatchFunc func, gpointer func_data, GDestroyNotify func_notify); void gtk_entry_completion_set_minimum_key_length (GtkEntryCompletion *completion, gint length); gint gtk_entry_completion_get_minimum_key_length (GtkEntryCompletion *completion); void gtk_entry_completion_complete (GtkEntryCompletion *completion); const gchar* gtk_entry_completion_get_completion_prefix (GtkEntryCompletion *completion); void gtk_entry_completion_insert_prefix (GtkEntryCompletion *completion); void gtk_entry_completion_insert_action_text (GtkEntryCompletion *completion, gint index_, const gchar *text); void gtk_entry_completion_insert_action_markup (GtkEntryCompletion *completion, gint index_, const gchar *markup); void gtk_entry_completion_delete_action (GtkEntryCompletion *completion, gint index_); void gtk_entry_completion_set_text_column (GtkEntryCompletion *completion, gint column); gint gtk_entry_completion_get_text_column (GtkEntryCompletion *completion); void gtk_entry_completion_set_inline_completion (GtkEntryCompletion *completion, gboolean inline_completion); gboolean gtk_entry_completion_get_inline_completion (GtkEntryCompletion *completion); void gtk_entry_completion_set_inline_selection (GtkEntryCompletion *completion, gboolean inline_selection); gboolean gtk_entry_completion_get_inline_selection (GtkEntryCompletion *completion); void gtk_entry_completion_set_popup_completion (GtkEntryCompletion *completion, gboolean popup_completion); gboolean gtk_entry_completion_get_popup_completion (GtkEntryCompletion *completion); void gtk_entry_completion_set_popup_set_width (GtkEntryCompletion *completion, gboolean popup_set_width); gboolean gtk_entry_completion_get_popup_set_width (GtkEntryCompletion *completion); void gtk_entry_completion_set_popup_single_match (GtkEntryCompletion *completion, gboolean popup_single_match); gboolean gtk_entry_completion_get_popup_single_match (GtkEntryCompletion *completion); Properties"inline-completion" gboolean : Read / Write "inline-selection" gboolean : Read / Write "minimum-key-length" gint : Read / Write "model" GtkTreeModel* : Read / Write "popup-completion" gboolean : Read / Write "popup-set-width" gboolean : Read / Write "popup-single-match" gboolean : Read / Write "text-column" gint : Read / Write Signals"action-activated" : Run Last "cursor-on-match" : Run Last "insert-prefix" : Run Last "match-selected" : Run Last DescriptionGtkEntryCompletion 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
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
To add completion functionality to an entry, use 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 ::action-activated signal is emitted. DetailsGtkEntryCompletiontypedef struct _GtkEntryCompletion GtkEntryCompletion; The GtkEntryCompletion struct contains only private data. GtkEntryCompletionMatchFunc ()gboolean (*GtkEntryCompletionMatchFunc) (GtkEntryCompletion *completion, const gchar *key, GtkTreeIter *iter, gpointer user_data);
A function which decides whether the row indicated by
gtk_entry_completion_new ()GtkEntryCompletion* gtk_entry_completion_new (void); Creates a new GtkEntryCompletion object.
Since 2.4 gtk_entry_completion_get_entry ()GtkWidget* gtk_entry_completion_get_entry (GtkEntryCompletion *completion);
Gets the entry
Since 2.4 gtk_entry_completion_set_model ()void gtk_entry_completion_set_model (GtkEntryCompletion *completion, GtkTreeModel *model);
Sets the model for a GtkEntryCompletion. If
Since 2.4 gtk_entry_completion_get_model ()GtkTreeModel* gtk_entry_completion_get_model (GtkEntryCompletion *completion);
Returns the model the GtkEntryCompletion is using as data source.
Returns
Since 2.4 gtk_entry_completion_set_match_func ()void gtk_entry_completion_set_match_func (GtkEntryCompletion *completion, GtkEntryCompletionMatchFunc func, gpointer func_data, GDestroyNotify func_notify);
Sets the match function for
Since 2.4 gtk_entry_completion_set_minimum_key_length ()void gtk_entry_completion_set_minimum_key_length (GtkEntryCompletion *completion, gint length);
Requires the length of the search key for
Since 2.4 gtk_entry_completion_get_minimum_key_length ()gint gtk_entry_completion_get_minimum_key_length (GtkEntryCompletion *completion);
Returns the minimum key length as set for
Since 2.4 gtk_entry_completion_complete ()void gtk_entry_completion_complete (GtkEntryCompletion *completion); 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.
Since 2.4 gtk_entry_completion_get_completion_prefix ()const gchar* gtk_entry_completion_get_completion_prefix (GtkEntryCompletion *completion);
Get the original text entered by the user that triggered
the completion or
Since 2.12 gtk_entry_completion_insert_prefix ()void gtk_entry_completion_insert_prefix (GtkEntryCompletion *completion); Requests a prefix insertion.
Since 2.6 gtk_entry_completion_insert_action_text ()void gtk_entry_completion_insert_action_text (GtkEntryCompletion *completion, gint index_, const gchar *text);
Inserts an action in
Since 2.4 gtk_entry_completion_insert_action_markup ()void gtk_entry_completion_insert_action_markup (GtkEntryCompletion *completion, gint index_, const gchar *markup);
Inserts an action in
Since 2.4 gtk_entry_completion_delete_action ()void gtk_entry_completion_delete_action (GtkEntryCompletion *completion, gint index_);
Deletes the action at
Since 2.4 gtk_entry_completion_set_text_column ()void gtk_entry_completion_set_text_column (GtkEntryCompletion *completion, gint column);
Convenience function for setting up the most used case of this code: a
completion list with just strings. This function will set up
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
Since 2.4 gtk_entry_completion_get_text_column ()gint gtk_entry_completion_get_text_column (GtkEntryCompletion *completion);
Returns the column in the model of
Since 2.6 gtk_entry_completion_set_inline_completion ()void gtk_entry_completion_set_inline_completion (GtkEntryCompletion *completion, gboolean inline_completion); Sets whether the common prefix of the possible completions should be automatically inserted in the entry.
Since 2.6 gtk_entry_completion_get_inline_completion ()gboolean gtk_entry_completion_get_inline_completion (GtkEntryCompletion *completion); Returns whether the common prefix of the possible completions should be automatically inserted in the entry.
Since 2.6 gtk_entry_completion_set_inline_selection ()void gtk_entry_completion_set_inline_selection (GtkEntryCompletion *completion, gboolean inline_selection); Sets whether it is possible to cycle through the possible completions inside the entry.
Since 2.12 gtk_entry_completion_get_inline_selection ()gboolean gtk_entry_completion_get_inline_selection (GtkEntryCompletion *completion);
Returns
Since 2.12 gtk_entry_completion_set_popup_completion ()void gtk_entry_completion_set_popup_completion (GtkEntryCompletion *completion, gboolean popup_completion); Sets whether the completions should be presented in a popup window.
Since 2.6 gtk_entry_completion_get_popup_completion ()gboolean gtk_entry_completion_get_popup_completion (GtkEntryCompletion *completion); Returns whether the completions should be presented in a popup window.
Since 2.6 gtk_entry_completion_set_popup_set_width ()void gtk_entry_completion_set_popup_set_width (GtkEntryCompletion *completion, gboolean popup_set_width); Sets whether the completion popup window will be resized to be the same width as the entry.
Since 2.8 gtk_entry_completion_get_popup_set_width ()gboolean gtk_entry_completion_get_popup_set_width (GtkEntryCompletion *completion); Returns whether the completion popup window will be resized to the width of the entry.
Since 2.8 gtk_entry_completion_set_popup_single_match ()void gtk_entry_completion_set_popup_single_match (GtkEntryCompletion *completion, gboolean popup_single_match);
Sets whether the completion popup window will appear even if there is
only a single match. You may want to set this to
Since 2.8 gtk_entry_completion_get_popup_single_match ()gboolean gtk_entry_completion_get_popup_single_match (GtkEntryCompletion *completion); Returns whether the completion popup window will appear even if there is only a single match.
Since 2.8 Property DetailsThe
|
|
the object which received the signal |
|
the index of the activated action |
|
user data set when the signal handler was connected. |
Since 2.4
"cursor-on-match"
signalgboolean user_function (GtkEntryCompletion *widget, GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data) : Run Last
Gets 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
.
|
the object which received the signal |
|
the GtkTreeModel containing the matches |
|
a GtkTreeIter positioned at the selected match |
|
user data set when the signal handler was connected. |
Returns : |
TRUE if the signal has been handled
|
Since 2.12
"insert-prefix"
signalgboolean user_function (GtkEntryCompletion *widget, gchar *prefix, gpointer user_data) : Run Last
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 GtkFileChooser inserts only the part of the prefix up to the
next '/'.
|
the object which received the signal |
|
the common prefix of all possible completions |
|
user data set when the signal handler was connected. |
Returns : |
TRUE if the signal has been handled
|
Since 2.6
"match-selected"
signalgboolean user_function (GtkEntryCompletion *widget, GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data) : Run Last
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
.
|
the object which received the signal |
|
the GtkTreeModel containing the matches |
|
a GtkTreeIter positioned at the selected match |
|
user data set when the signal handler was connected. |
Returns : |
TRUE if the signal has been handled
|
Since 2.4