Class: Gtk::EntryCompletion

Inherits:
Object
  • Object
show all
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

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.

Parameters:

Instance Method Details

#cell_areaGtk::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.

Returns:

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

Parameters:

Returns:

#completenil

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.

Returns:

  • (nil)

#completion_prefixString

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

Returns:

  • (String)

    the prefix for the current completion

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

Parameters:

  • key (String)

    The text to complete for

Returns:

  • (String)

    The common prefix all rows starting with key

#entryGtk::Widget

Gets the entry completion has been attached to.

Returns:

  • (Gtk::Widget)

    The entry completion has been attached to

#inline_completionBoolean

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

Returns:

  • (Boolean)

    true if inline completion is turned on

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

Parameters:

  • inline_completion (Boolean)

Returns:

  • (Boolean)

    inline-completion

  • (Boolean)

    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.

Returns:

  • (Boolean)

    inline-completion

#inline_selectionBoolean

Returns true if inline-selection mode is turned on.

Returns:

  • (Boolean)

    true if inline-selection mode is on

#inline_selection=(inline_selection) ⇒ Boolean

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

Parameters:

  • inline_selection (Boolean)

Returns:

  • (Boolean)

    inline-selection

  • (Boolean)

    inline-selection

#inline_selection?Boolean

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

Returns:

  • (Boolean)

    inline-selection

#insert_prefixnil

Requests a prefix insertion.

Returns:

  • (nil)

#minimum_key_lengthInteger

Returns minimum-key-length.

Returns:

  • (Integer)

    minimum-key-length

#minimum_key_length=(minimum_key_length) ⇒ Integer

Parameters:

  • minimum_key_length (Integer)

Returns:

  • (Integer)

    minimum-key-length

  • (Integer)

    minimum-key-length

#modelGtk::TreeModel

Returns model.

Returns:

#model=(model) ⇒ Gtk::TreeModel

Parameters:

Returns:

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

Returns:

  • (Boolean)

    true if popup completion is turned on

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

Parameters:

  • popup_completion (Boolean)

Returns:

  • (Boolean)

    popup-completion

  • (Boolean)

    popup-completion

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

Returns:

  • (Boolean)

    popup-completion

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

Returns:

  • (Boolean)

    true if the popup window will be resized to the width of the entry

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

Parameters:

  • popup_set_width (Boolean)

Returns:

  • (Boolean)

    popup-set-width

  • (Boolean)

    popup-set-width

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

Returns:

  • (Boolean)

    popup-set-width

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

Returns:

  • (Boolean)

    true if the popup window will appear regardless of the number of matches

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

Parameters:

  • popup_single_match (Boolean)

Returns:

  • (Boolean)

    popup-single-match

  • (Boolean)

    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 [propertyGtk.EntryCompletion:inline-completion].

Returns:

  • (Boolean)

    popup-single-match

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

Parameters:

  • func (Gtk::EntryCompletionMatchFunc)

    the GtkEntryCompletionMatchFunc to use

  • func_data (GObject)

    user data for func

  • func_notify (GLib::DestroyNotify)

    destroy notify for func_data.

Returns:

  • (nil)

#text_columnInteger

The column of the model containing the strings.

Note that the strings must be UTF-8.

Returns:

  • (Integer)

    text-column

#text_column=(text_column) ⇒ Integer

The column of the model containing the strings.

Note that the strings must be UTF-8.

Parameters:

  • text_column (Integer)

Returns:

  • (Integer)

    text-column

  • (Integer)

    text-column