About all my projects
Gnome::Gtk4::EntryCompletion

Gnome::Gtk4::EntryCompletion

Description

Gnome::Gtk4::EntryCompletion is an auxiliary object to provide completion functionality for Gnome::Gtk4::Entry.

It implements the Gnome::Gtk4::R-CellLayout interface, to allow the user to add extra cells to the Gnome::Gtk4::TreeView with completion matches.

“Completion functionality” means that when the user modifies the text in the entry, Gnome::Gtk4::EntryCompletion 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 .set-text-column()), but this can be overridden with a custom match function (see .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 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 .set-completion() in class Gnome::Gtk4::Entry.

Gnome::Gtk4::EntryCompletion uses a Gnome::Gtk4::TreeModelFilter model to represent the subset of the entire model that is currently matching. While the Gnome::Gtk4::EntryCompletion signals match-selected and cursor-on-match take the original model and an iter pointing to that model as arguments, other callbacks and signals (such as Gnome::Gtk4::T-celllayout or apply-attributes) defined in CellArea will generally take the filter model as argument. As long as you are only calling .get() in class Gnome::Gtk4::R-TreeModel, this will make no difference to you. If for some reason, you need the original model, use .get-model() in class Gnome::Gtk4::TreeModelFilter. Don’t forget to use .convert-iter-to-child-iter() in class Gnome::Gtk4::TreeModelFilter to obtain a matching iter.

Class initialization

Note: The native version of this class is deprecated in gtk4-lib() since version 4.10

new

:native-object

Create an object using a native object from elsewhere. See also Gnome::N::TopLevelSupportClass.

multi method new ( N-Object :$native-object! )

new-entrycompletion

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

Creates a new Gnome::Gtk4::EntryCompletion object.

method new-entrycompletion ( --> Gnome::Gtk4::EntryCompletion \)

new-with-area

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

Creates a new Gnome::Gtk4::EntryCompletion object using the specified $area.

The Gnome::Gtk4::CellArea is used to layout cells in the underlying Gnome::Gtk4::TreeViewColumn for the drop-down menu.

method new-with-area ( N-Object() $area --> Gnome::Gtk4::EntryCompletion \)
  • $area; the Gnome::Gtk4::CellArea used to layout cells.

Methods

complete

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

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.

method complete ( )

compute-prefix

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

Computes the common prefix that is shared by all rows in $completion that start with $key.

If no row matches $key, undefined will be returned. Note that a text column must have been set for this function to work, see .set-text-column() for details.

method compute-prefix ( Str $key --> Str )
  • $key; The text to complete for.

Return value; The common prefix all rows starting with $key.

get-completion-prefix

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

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

method get-completion-prefix (--> Str )

Return value; the prefix for the current completion.

get-entry

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

Gets the entry $completion has been attached to.

method get-entry (--> N-Object )

Return value; The entry $completion has been attached to.

get-inline-completion

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

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

method get-inline-completion (--> Bool )

Return value; True if inline completion is turned on.

get-inline-selection

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

Returns True if inline-selection mode is turned on.

method get-inline-selection (--> Bool )

Return value; True if inline-selection mode is on.

get-minimum-key-length

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

Returns the minimum key length as set for $completion.

method get-minimum-key-length (--> Int )

Return value; The currently used minimum key length.

get-model

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

Returns the model the Gnome::Gtk4::EntryCompletion is using as data source.

Returns undefined if the model is unset.

method get-model (--> N-Object )

Return value; A Gnome::Gtk4::R-TreeModel.

get-popup-completion

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

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

method get-popup-completion (--> Bool )

Return value; True if popup completion is turned on.

get-popup-set-width

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

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

method get-popup-set-width (--> Bool )

Return value; True if the popup window will be resized to the width of the entry.

get-popup-single-match

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

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

method get-popup-single-match (--> Bool )

Return value; True if the popup window will appear regardless of the number of matches.

get-text-column

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

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

method get-text-column (--> Int )

Return value; the column containing the strings.

insert-prefix

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

Requests a prefix insertion.

method insert-prefix ( )

set-inline-completion

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

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

method set-inline-completion ( Bool() $inline-completion )
  • $inline-completion; True to do inline completion.

set-inline-selection

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

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

method set-inline-selection ( Bool() $inline-selection )
  • $inline-selection; True to do inline selection.

set-match-func This function is not yet available

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

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.

method set-match-func ( &func, gpointer $func-data, … )
  • &func; the Gnome::Gtk4::EntryCompletionMatchFunc to use. Tthe function must be specified with following signature; :( N-Object $completion, Str $key, N-Object $iter, gpointer $user-data -- gboolean )>.

  • $func-data; user data for $func.

  • func-notify; destroy notify for $func-data.. Note that each argument must be specified as a type followed by its value!

set-minimum-key-length

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

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

method set-minimum-key-length ( Int() $length )
  • $length; the minimum length of the key in order to start completing.

set-model

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

Sets the model for a Gnome::Gtk4::EntryCompletion.

If $completion already has a model set, it will remove it before setting the new model. If model is undefined, then it will unset the model.

method set-model ( N-Object() $model )
  • $model; the Gnome::Gtk4::R-TreeModel.

set-popup-completion

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

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

method set-popup-completion ( Bool() $popup-completion )
  • $popup-completion; True to do popup completion.

set-popup-set-width

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

Sets whether the completion popup window will be resized to be the same width as the entry.

method set-popup-set-width ( Bool() $popup-set-width )
  • $popup-set-width; True to make the width of the popup the same as the entry.

set-popup-single-match

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

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.

method set-popup-single-match ( Bool() $popup-single-match )
  • $popup-single-match; True if the popup should appear even for a single match.

set-text-column

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

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 Gnome::Gtk4::CellRendererText 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 text-column property directly.

method set-text-column ( Int() $column )
  • $column; the column in the model of $completion to get strings from.

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 .set-model().

method handler (
  N-Object $model,
  N-Object $iter,
  Int :$_handle_id,
  N-GObject :$_native-object,
  Gnome::Gtk4::EntryCompletion :$_widget,
  *C<user>-options
  --> gboolean
)
  • $model; the Gnome::Gtk4::R-TreeModel containing the matches.

  • $iter; a Gnome::Gtk4::N-TreeIter positioned at the selected match.

  • $_handle_id; The registered event handler id.

  • $_native-object; The native object provided by the Raku object which registered this event. This a native Gnome::Gtk4::EntryCompletion object.

  • $_widget; The object which registered the signal. User code may have left the object going out of scope.

  • user-options; A list of named arguments provided at the .register-signal() method from Gnome::GObject::Object.

Return value; True if the signal has been handled

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 Gnome::Gtk4::R-FileChooser inserts only the part of the prefix up to the next '/'.

method handler (
  Str $prefix,
  Int :$_handle_id,
  N-GObject :$_native-object,
  Gnome::Gtk4::EntryCompletion :$_widget,
  *C<user>-options
  --> gboolean
)
  • $prefix; the common prefix of all possible completions.

  • $_handle_id; The registered event handler id.

  • $_native-object; The native object provided by the Raku object which registered this event. This a native Gnome::Gtk4::EntryCompletion object.

  • $_widget; The object which registered the signal. User code may have left the object going out of scope.

  • user-options; A list of named arguments provided at the .register-signal() method from Gnome::GObject::Object.

Return value; True if the signal has been handled

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 .set-model().

method handler (
  N-Object $model,
  N-Object $iter,
  Int :$_handle_id,
  N-GObject :$_native-object,
  Gnome::Gtk4::EntryCompletion :$_widget,
  *C<user>-options
  --> gboolean
)
  • $model; the Gnome::Gtk4::R-TreeModel containing the matches.

  • $iter; a Gnome::Gtk4::N-TreeIter positioned at the selected match.

  • $_handle_id; The registered event handler id.

  • $_native-object; The native object provided by the Raku object which registered this event. This a native Gnome::Gtk4::EntryCompletion object.

  • $_widget; The object which registered the signal. User code may have left the object going out of scope.

  • user-options; A list of named arguments provided at the .register-signal() method from Gnome::GObject::Object.

Return value; True if the signal has been handled

no-matches

Emitted when the filter model has zero number of rows in completion_complete method.

In other words when Gnome::Gtk4::EntryCompletion is out of suggestions.

method handler (
  Int :$_handle_id,
  N-GObject :$_native-object,
  Gnome::Gtk4::EntryCompletion :$_widget,
  *C<user>-options
)
  • $_handle_id; The registered event handler id.

  • $_native-object; The native object provided by the Raku object which registered this event. This a native Gnome::Gtk4::EntryCompletion object.

  • $_widget; The object which registered the signal. User code may have left the object going out of scope.

  • user-options; A list of named arguments provided at the .register-signal() method from Gnome::GObject::Object.