Class

GtkEntryCompletion

Description [src]

class Gtk.EntryCompletion : GObject.Object
  implements Gtk.Buildable, Gtk.CellLayout {
  /* No available fields */
}

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_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 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_set_completion().

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_get(), this will make no difference to you. If for some reason, you need the original model, use gtk_tree_model_filter_get_model(). Don’t forget to use gtk_tree_model_filter_convert_iter_to_child_iter() to obtain a matching iter.

Hierarchy

hierarchy this GtkEntryCompletion implements_0 GtkBuildable this--implements_0 implements_1 GtkCellLayout this--implements_1 ancestor_0 GObject ancestor_0--this

Ancestors

Constructors

gtk_entry_completion_new

Creates a new GtkEntryCompletion object.

since: 2.4

gtk_entry_completion_new_with_area

Creates a new GtkEntryCompletion object using the specified area to layout cells in the underlying GtkTreeViewColumn for the drop-down menu.

since: 3.0

Instance methods

gtk_entry_completion_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.

since: 2.4

gtk_entry_completion_compute_prefix

Computes 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 to work, see gtk_entry_completion_set_text_column() for details.

since: 3.4

gtk_entry_completion_delete_action

Deletes the action at index_ from completion’s action list.

since: 2.4

gtk_entry_completion_get_completion_prefix

Get the original text entered by the user that triggered the completion or NULL if there’s no completion ongoing.

since: 2.12

gtk_entry_completion_get_entry

Gets the entry completion has been attached to.

since: 2.4

gtk_entry_completion_get_inline_completion

Returns whether the common prefix of the possible completions should be automatically inserted in the entry.

since: 2.6

gtk_entry_completion_get_inline_selection

Returns TRUE if inline-selection mode is turned on.

since: 2.12

gtk_entry_completion_get_minimum_key_length

Returns the minimum key length as set for completion.

since: 2.4

gtk_entry_completion_get_model

Returns the model the GtkEntryCompletion is using as data source. Returns NULL if the model is unset.

since: 2.4

gtk_entry_completion_get_popup_completion

Returns whether the completions should be presented in a popup window.

since: 2.6

gtk_entry_completion_get_popup_set_width

Returns whether the completion popup window will be resized to the width of the entry.

since: 2.8

gtk_entry_completion_get_popup_single_match

Returns whether the completion popup window will appear even if there is only a single match.

since: 2.8

gtk_entry_completion_get_text_column

Returns the column in the model of completion to get strings from.

since: 2.6

gtk_entry_completion_insert_action_markup

Inserts an action in completion’s action item list at position index_ with markup markup.

since: 2.4

gtk_entry_completion_insert_action_text

Inserts 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_insert_action_markup().

since: 2.4

gtk_entry_completion_insert_prefix

Requests a prefix insertion.

since: 2.6

gtk_entry_completion_set_inline_completion

Sets whether the common prefix of the possible completions should be automatically inserted in the entry.

since: 2.6

gtk_entry_completion_set_inline_selection

Sets whether it is possible to cycle through the possible completions inside the entry.

since: 2.12

gtk_entry_completion_set_match_func

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.

since: 2.4

gtk_entry_completion_set_minimum_key_length

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).

since: 2.4

gtk_entry_completion_set_model

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 NULL, then it will unset the model.

since: 2.4

gtk_entry_completion_set_popup_completion

Sets whether the completions should be presented in a popup window.

since: 2.6

gtk_entry_completion_set_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_set_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 FALSE if you are using [inline completion][GtkEntryCompletion—inline-completion].

since: 2.8

gtk_entry_completion_set_text_column

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.

since: 2.4

Methods inherited from GObject (43)

Please see GObject for a full list of methods.

Methods inherited from GtkBuildable (10)
gtk_buildable_add_child

Adds a child to buildable. type is an optional string describing how the child should be added.

since: 2.12

gtk_buildable_construct_child

Constructs a child of buildable with the name name.

since: 2.12

gtk_buildable_custom_finished

This is similar to gtk_buildable_parser_finished() but is called once for each custom tag handled by the buildable.

since: 2.12

gtk_buildable_custom_tag_end

This is called at the end of each custom element handled by the buildable.

since: 2.12

gtk_buildable_custom_tag_start

This is called for each unknown element under <child>.

since: 2.12

gtk_buildable_get_internal_child

Get the internal child called childname of the buildable object.

since: 2.12

gtk_buildable_get_name

Gets the name of the buildable object.

since: 2.12

gtk_buildable_parser_finished

Called when the builder finishes the parsing of a [GtkBuilder UI definition][BUILDER-UI]. Note that this will be called once for each time gtk_builder_add_from_file() or gtk_builder_add_from_string() is called on a builder.

since: 2.12

gtk_buildable_set_buildable_property

Sets the property name name to value on the buildable object.

since: 2.12

gtk_buildable_set_name

Sets the name of the buildable object.

since: 2.12

Methods inherited from GtkCellLayout (10)
gtk_cell_layout_add_attribute

Adds an attribute mapping to the list in cell_layout.

since: 2.4

gtk_cell_layout_clear

Unsets all the mappings on all renderers on cell_layout and removes all renderers from cell_layout.

since: 2.4

gtk_cell_layout_clear_attributes

Clears all existing attributes previously set with gtk_cell_layout_set_attributes().

since: 2.4

gtk_cell_layout_get_area

Returns the underlying GtkCellArea which might be cell_layout if called on a GtkCellArea or might be NULL if no GtkCellArea is used by cell_layout.

since: 3.0

gtk_cell_layout_get_cells

Returns the cell renderers which have been added to cell_layout.

since: 2.12

gtk_cell_layout_pack_end

Adds the cell to the end of cell_layout. If expand is FALSE, then the cell is allocated no more space than it needs. Any unused space is divided evenly between cells for which expand is TRUE.

since: 2.4

gtk_cell_layout_pack_start

Packs the cell into the beginning of cell_layout. If expand is FALSE, then the cell is allocated no more space than it needs. Any unused space is divided evenly between cells for which expand is TRUE.

since: 2.4

gtk_cell_layout_reorder

Re-inserts cell at position.

since: 2.4

gtk_cell_layout_set_attributes

Sets the attributes in list as the attributes of cell_layout.

since: 2.4

gtk_cell_layout_set_cell_data_func

Sets the GtkCellLayoutDataFunc to use for cell_layout.

since: 2.4

Properties

Gtk.EntryCompletion:cell-area

The GtkCellArea used to layout cell renderers in the treeview column.

since: 3.0

Gtk.EntryCompletion: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.

since: 2.6

Gtk.EntryCompletion:inline-selection

Determines whether the possible completions on the popup will appear in the entry as you navigate through them.

since: 2.12

Gtk.EntryCompletion:minimum-key-length
No description available.

Gtk.EntryCompletion:model
No description available.

Gtk.EntryCompletion:popup-completion

Determines whether the possible completions should be shown in a popup window.

since: 2.6

Gtk.EntryCompletion:popup-set-width

Determines whether the completions popup window will be resized to the width of the entry.

since: 2.8

Gtk.EntryCompletion: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 [inline completion][GtkEntryCompletion—inline-completion].

since: 2.8

Gtk.EntryCompletion:text-column

The column of the model containing the strings. Note that the strings must be UTF-8.

since: 2.6

Signals

Gtk.EntryCompletion::action-activated

Gets emitted when an action is activated.

since: 2.4

Gtk.EntryCompletion::cursor-on-match

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.

since: 2.12

Gtk.EntryCompletion::insert-prefix

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.

since: 2.6

Gtk.EntryCompletion::match-selected

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

Gtk.EntryCompletion::no-matches

Gets emitted when the filter model has zero number of rows in completion_complete method. (In other words when GtkEntryCompletion is out of suggestions)

since: 3.14

Signals inherited from GObject (1)
GObject::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

Class structure

struct GtkEntryCompletionClass {
  GObjectClass parent_class;
  gboolean (* match_selected) (
    GtkEntryCompletion* completion,
    GtkTreeModel* model,
    GtkTreeIter* iter
  );
  void (* action_activated) (
    GtkEntryCompletion* completion,
    gint index_
  );
  gboolean (* insert_prefix) (
    GtkEntryCompletion* completion,
    const gchar* prefix
  );
  gboolean (* cursor_on_match) (
    GtkEntryCompletion* completion,
    GtkTreeModel* model,
    GtkTreeIter* iter
  );
  void (* no_matches) (
    GtkEntryCompletion* completion
  );
  void (* _gtk_reserved0) (
void
  );
  void (* _gtk_reserved1) (
void
  );
  void (* _gtk_reserved2) (
void
  );
  
}

No description available.

Class members
parent_class: GObjectClass

No description available.

match_selected: gboolean (* match_selected) ( GtkEntryCompletion* completion, GtkTreeModel* model, GtkTreeIter* iter )

No description available.

action_activated: void (* action_activated) ( GtkEntryCompletion* completion, gint index_ )

No description available.

insert_prefix: gboolean (* insert_prefix) ( GtkEntryCompletion* completion, const gchar* prefix )

No description available.

cursor_on_match: gboolean (* cursor_on_match) ( GtkEntryCompletion* completion, GtkTreeModel* model, GtkTreeIter* iter )

No description available.

no_matches: void (* no_matches) ( GtkEntryCompletion* completion )

No description available.

_gtk_reserved0: void (* _gtk_reserved0) ( void )

No description available.

_gtk_reserved1: void (* _gtk_reserved1) ( void )

No description available.

_gtk_reserved2: void (* _gtk_reserved2) ( void )

No description available.

Virtual methods

Gtk.EntryCompletionClass.action_activated
No description available.

Gtk.EntryCompletionClass.cursor_on_match
No description available.

Gtk.EntryCompletionClass.insert_prefix
No description available.

Gtk.EntryCompletionClass.match_selected
No description available.

Gtk.EntryCompletionClass.no_matches
No description available.