Package ch.bailu.gtk.gtk
Class EntryCompletion
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.gobject.Object
ch.bailu.gtk.gtk.EntryCompletion
- All Implemented Interfaces:
PointerInterface
`GtkEntryCompletion` is an auxiliary object to provide completion functionality
for `GtkEntry`.
It implements the [iface@Gtk.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
[method@Gtk.EntryCompletion.set_text_column]), but this can be overridden
with a custom match function (see [method@Gtk.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 [signal@Gtk.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
[method@Gtk.Entry.set_completion].
`GtkEntryCompletion` uses a [class@Gtk.TreeModelFilter] model to
represent the subset of the entire model that is currently matching.
While the `GtkEntryCompletion` signals
[signal@Gtk.EntryCompletion::match-selected] and
[signal@Gtk.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
[signal@Gtk.CellArea::apply-attributes)]
will generally take the filter model as argument. As long as you are
only calling [method@Gtk.TreeModel.get], this will make no difference to
you. If for some reason, you need the original model, use
[method@Gtk.TreeModelFilter.get_model]. Don’t forget to use
[method@Gtk.TreeModelFilter.convert_iter_to_child_iter] to obtain a
matching iter.
for `GtkEntry`.
It implements the [iface@Gtk.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
[method@Gtk.EntryCompletion.set_text_column]), but this can be overridden
with a custom match function (see [method@Gtk.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 [signal@Gtk.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
[method@Gtk.Entry.set_completion].
`GtkEntryCompletion` uses a [class@Gtk.TreeModelFilter] model to
represent the subset of the entire model that is currently matching.
While the `GtkEntryCompletion` signals
[signal@Gtk.EntryCompletion::match-selected] and
[signal@Gtk.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
[signal@Gtk.CellArea::apply-attributes)]
will generally take the filter model as argument. As long as you are
only calling [method@Gtk.TreeModel.get], this will make no difference to
you. If for some reason, you need the original model, use
[method@Gtk.TreeModelFilter.get_model]. Don’t forget to use
[method@Gtk.TreeModelFilter.convert_iter_to_child_iter] to obtain a
matching iter.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static interface
static interface
static interface
static interface
static interface
Nested classes/interfaces inherited from class ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
Fields inherited from class ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Constructor Summary
ConstructorDescriptionCreates a new `GtkEntryCompletion` object.EntryCompletion
(PointerContainer pointer) -
Method Summary
Modifier and TypeMethodDescriptionImplements interfaceBuildable
.Implements interfaceCellLayout
.void
complete()
Requests a completion operation, or in other words a refiltering of the
current list with completions, using the current key.computePrefix
(Str key) Computes the common prefix that is shared by all rows in @completion
that start with @key.computePrefix
(String key) Computes the common prefix that is shared by all rows in @completion
that start with @key.static ClassHandler
Get the original text entered by the user that triggered
the completion or %NULL if there’s no completion ongoing.getEntry()
Gets the entry @completion has been attached to.boolean
Returns whether the common prefix of the possible completions should
be automatically inserted in the entry.boolean
Returns %TRUE if inline-selection mode is turned on.static int
int
Returns the minimum key length as set for @completion.getModel()
Returns the model the `GtkEntryCompletion` is using as data source.static long
static TypeSystem.TypeSize
boolean
Returns whether the completions should be presented in a popup window.boolean
Returns whether the completion popup window will be resized to the
width of the entry.boolean
Returns whether the completion popup window will appear even if there is
only a single match.int
Returns the column in the model of @completion to get strings from.static long
static TypeSystem.TypeSize
void
Requests a prefix insertion.static EntryCompletion
Creates a new `GtkEntryCompletion` object using the
specified @area.Connect to signal "cursor-on-match".Connect to signal "insert-prefix".Connect to signal "match-selected".Connect to signal "no-matches".void
setInlineCompletion
(boolean inline_completion) Sets whether the common prefix of the possible completions should
be automatically inserted in the entry.void
setInlineSelection
(boolean inline_selection) Sets whether it is possible to cycle through the possible completions
inside the entry.void
setMatchFunc
(EntryCompletion.OnEntryCompletionMatchFunc func, Pointer func_data, EntryCompletion.OnDestroyNotify func_notify) Sets the match function for @completion to be @func.void
setMinimumKeyLength
(int length) Requires the length of the search key for @completion to be at least
@length.void
Sets the model for a `GtkEntryCompletion`.void
setPopupCompletion
(boolean popup_completion) Sets whether the completions should be presented in a popup window.void
setPopupSetWidth
(boolean popup_set_width) Sets whether the completion popup window will be resized to be the same
width as the entry.void
setPopupSingleMatch
(boolean popup_single_match) Sets whether the completion popup window will appear even if there is
only a single match.void
setTextColumn
(int column) Convenience function for setting up the most used case of this code: a
completion list with just strings.Methods inherited from class ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref
Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Field Details
-
SIGNAL_ON_CURSOR_ON_MATCH
- See Also:
-
SIGNAL_ON_INSERT_PREFIX
- See Also:
-
SIGNAL_ON_MATCH_SELECTED
- See Also:
-
SIGNAL_ON_NO_MATCHES
- See Also:
-
-
Constructor Details
-
EntryCompletion
-
EntryCompletion
public EntryCompletion()Creates a new `GtkEntryCompletion` object.
-
-
Method Details
-
getClassHandler
-
newWithAreaEntryCompletion
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
- the `GtkCellArea` used to layout cells- Returns:
- A newly created `GtkEntryCompletion` object
-
complete
public void 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. -
computePrefix
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 [method@Gtk.EntryCompletion.set_text_column] for details.- Parameters:
key
- The text to complete for- Returns:
- The common prefix all rows starting with @key
-
computePrefix
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 [method@Gtk.EntryCompletion.set_text_column] for details.- Parameters:
key
- The text to complete for- Returns:
- The common prefix all rows starting with @key
-
getCompletionPrefix
Get the original text entered by the user that triggered
the completion or %NULL if there’s no completion ongoing.- Returns:
- the prefix for the current completion
-
getEntry
Gets the entry @completion has been attached to.- Returns:
- The entry @completion has been attached to
-
getInlineCompletion
public boolean getInlineCompletion()Returns whether the common prefix of the possible completions should
be automatically inserted in the entry.- Returns:
- %TRUE if inline completion is turned on
-
getInlineSelection
public boolean getInlineSelection()Returns %TRUE if inline-selection mode is turned on.- Returns:
- %TRUE if inline-selection mode is on
-
getMinimumKeyLength
public int getMinimumKeyLength()Returns the minimum key length as set for @completion.- Returns:
- The currently used minimum key length
-
getModel
Returns the model the `GtkEntryCompletion` is using as data source.
Returns %NULL if the model is unset.- Returns:
- A `GtkTreeModel`
-
getPopupCompletion
public boolean getPopupCompletion()Returns whether the completions should be presented in a popup window.- Returns:
- %TRUE if popup completion is turned on
-
getPopupSetWidth
public boolean getPopupSetWidth()Returns whether the completion popup window will be resized to the
width of the entry.- Returns:
- %TRUE if the popup window will be resized to the width of the entry
-
getPopupSingleMatch
public boolean getPopupSingleMatch()Returns whether the completion popup window will appear even if there is
only a single match.- Returns:
- %TRUE if the popup window will appear regardless of the number of matches
-
getTextColumn
public int getTextColumn()Returns the column in the model of @completion to get strings from.- Returns:
- the column containing the strings
-
insertPrefix
public void insertPrefix()Requests a prefix insertion. -
setInlineCompletion
public void setInlineCompletion(boolean inline_completion) Sets whether the common prefix of the possible completions should
be automatically inserted in the entry.- Parameters:
inline_completion
- %TRUE to do inline completion
-
setInlineSelection
public void setInlineSelection(boolean inline_selection) Sets whether it is possible to cycle through the possible completions
inside the entry.- Parameters:
inline_selection
- %TRUE to do inline selection
-
setMatchFunc
public void setMatchFunc(EntryCompletion.OnEntryCompletionMatchFunc func, @Nullable Pointer func_data, EntryCompletion.OnDestroyNotify func_notify) 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
- the `GtkEntryCompletion`MatchFunc to usefunc_data
- user data for @funcfunc_notify
- destroy notify for @func_data.
-
setMinimumKeyLength
public void setMinimumKeyLength(int 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).- Parameters:
length
- the minimum length of the key in order to start completing
-
setModel
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.- Parameters:
model
- the `GtkTreeModel`
-
setPopupCompletion
public void setPopupCompletion(boolean popup_completion) Sets whether the completions should be presented in a popup window.- Parameters:
popup_completion
- %TRUE to do popup completion
-
setPopupSetWidth
public void setPopupSetWidth(boolean popup_set_width) Sets whether the completion popup window will be resized to be the same
width as the entry.- Parameters:
popup_set_width
- %TRUE to make the width of the popup the same as the entry
-
setPopupSingleMatch
public void setPopupSingleMatch(boolean 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 [property@Gtk.EntryCompletion:inline-completion].- Parameters:
popup_single_match
- %TRUE if the popup should appear even for a single match
-
setTextColumn
public void setTextColumn(int 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.
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
[property@Gtk.EntryCompletion:text-column] property directly.- Parameters:
column
- the column in the model of @completion to get strings from
-
onCursorOnMatch
Connect to signal "cursor-on-match".
SeeEntryCompletion.OnCursorOnMatch.onCursorOnMatch(ch.bailu.gtk.gtk.TreeModel, ch.bailu.gtk.gtk.TreeIter)
for signal description.
FieldSIGNAL_ON_CURSOR_ON_MATCH
contains original signal name and can be used as resource reference.- Parameters:
signal
- callback function (lambda).- Returns:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
onInsertPrefix
Connect to signal "insert-prefix".
SeeEntryCompletion.OnInsertPrefix.onInsertPrefix(ch.bailu.gtk.type.Str)
for signal description.
FieldSIGNAL_ON_INSERT_PREFIX
contains original signal name and can be used as resource reference.- Parameters:
signal
- callback function (lambda).- Returns:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
onMatchSelected
Connect to signal "match-selected".
SeeEntryCompletion.OnMatchSelected.onMatchSelected(ch.bailu.gtk.gtk.TreeModel, ch.bailu.gtk.gtk.TreeIter)
for signal description.
FieldSIGNAL_ON_MATCH_SELECTED
contains original signal name and can be used as resource reference.- Parameters:
signal
- callback function (lambda).- Returns:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
onNoMatches
Connect to signal "no-matches".
SeeEntryCompletion.OnNoMatches.onNoMatches()
for signal description.
FieldSIGNAL_ON_NO_MATCHES
contains original signal name and can be used as resource reference.- Parameters:
signal
- callback function (lambda).- Returns:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
asBuildable
Implements interfaceBuildable
. Call this to get access to interface functions.- Returns:
Buildable
-
asCellLayout
Implements interfaceCellLayout
. Call this to get access to interface functions.- Returns:
CellLayout
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-