Class EntryCompletion
- All Implemented Interfaces:
Proxy
,Buildable
,CellLayout
GtkEntryCompletion
is an auxiliary object to provide completion functionality
for GtkEntry
.
It implements the 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
setTextColumn(int)
), but this can be overridden
with a custom match function (see setMatchFunc(org.gnome.gtk.EntryCompletionMatchFunc)
).
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 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
Entry.setCompletion(org.gnome.gtk.EntryCompletion)
.
GtkEntryCompletion
uses a TreeModelFilter
model to
represent the subset of the entire model that is currently matching.
While the GtkEntryCompletion
signals
Gtk.EntryCompletion::match-selected
and
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
Gtk.CellArea::apply-attributes)
will generally take the filter model as argument. As long as you are
only calling TreeModel.get(org.gnome.gtk.TreeIter, java.lang.Object...)
, this will make no difference to
you. If for some reason, you need the original model, use
TreeModelFilter.getModel()
. Don’t forget to use
TreeModelFilter.convertIterToChildIter(org.gnome.gtk.TreeIter, org.gnome.gtk.TreeIter)
to obtain a
matching iter.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
EntryCompletion.Builder<B extends EntryCompletion.Builder<B>>
Deprecated.Inner class implementing a builder pattern to construct a GObject with properties.static interface
Deprecated.Functional interface declaration of theCursorOnMatchCallback
callback.static interface
Deprecated.Functional interface declaration of theInsertPrefixCallback
callback.static interface
Deprecated.Functional interface declaration of theMatchSelectedCallback
callback.static interface
Deprecated.Functional interface declaration of theNoMatchesCallback
callback.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
Nested classes/interfaces inherited from interface org.gnome.gtk.Buildable
Buildable.BuildableIface, Buildable.BuildableImpl
Nested classes/interfaces inherited from interface org.gnome.gtk.CellLayout
CellLayout.CellLayoutIface, CellLayout.CellLayoutImpl
-
Constructor Summary
ConstructorDescriptionDeprecated.GtkEntryCompletion will be removed in GTK 5.EntryCompletion
(MemorySegment address) Deprecated.Create a EntryCompletion proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected EntryCompletion
asParent()
Deprecated.Returns this instance as if it were its parent type.static EntryCompletion.Builder
<? extends EntryCompletion.Builder> builder()
Deprecated.AEntryCompletion.Builder
object constructs aEntryCompletion
with the specified properties.void
complete()
Deprecated.GtkEntryCompletion will be removed in GTK 5.computePrefix
(String key) Deprecated.GtkEntryCompletion will be removed in GTK 5.boolean
emitCursorOnMatch
(TreeModel model, TreeIter iter) Deprecated.Emits the "cursor-on-match" signal.boolean
emitInsertPrefix
(String prefix) Deprecated.Emits the "insert-prefix" signal.boolean
emitMatchSelected
(TreeModel model, TreeIter iter) Deprecated.Emits the "match-selected" signal.void
Deprecated.Emits the "no-matches" signal.Deprecated.GtkEntryCompletion will be removed in GTK 5.getEntry()
Deprecated.GtkEntryCompletion will be removed in GTK 5.boolean
Deprecated.GtkEntryCompletion will be removed in GTK 5.boolean
Deprecated.GtkEntryCompletion will be removed in GTK 5.int
Deprecated.GtkEntryCompletion will be removed in GTK 5.getModel()
Deprecated.GtkEntryCompletion will be removed in GTK 5.boolean
Deprecated.GtkEntryCompletion will be removed in GTK 5.boolean
Deprecated.GtkEntryCompletion will be removed in GTK 5.boolean
Deprecated.GtkEntryCompletion will be removed in GTK 5.int
Deprecated.GtkEntryCompletion will be removed in GTK 5.static Type
getType()
Deprecated.Get the GType of the EntryCompletion classvoid
Deprecated.GtkEntryCompletion will be removed in GTK 5.Deprecated.Emitted when a match from the cursor is on a match of the list.Deprecated.Emitted when the inline autocompletion is triggered.Deprecated.Emitted when a match from the list is selected.Deprecated.Emitted when the filter model has zero number of rows in completion_complete method.void
setInlineCompletion
(boolean inlineCompletion) Deprecated.GtkEntryCompletion will be removed in GTK 5.void
setInlineSelection
(boolean inlineSelection) Deprecated.GtkEntryCompletion will be removed in GTK 5.void
Deprecated.GtkEntryCompletion will be removed in GTK 5.void
setMinimumKeyLength
(int length) Deprecated.GtkEntryCompletion will be removed in GTK 5.void
Deprecated.GtkEntryCompletion will be removed in GTK 5.void
setPopupCompletion
(boolean popupCompletion) Deprecated.GtkEntryCompletion will be removed in GTK 5.void
setPopupSetWidth
(boolean popupSetWidth) Deprecated.GtkEntryCompletion will be removed in GTK 5.void
setPopupSingleMatch
(boolean popupSingleMatch) Deprecated.GtkEntryCompletion will be removed in GTK 5.void
setTextColumn
(int column) Deprecated.GtkEntryCompletion will be removed in GTK 5.static EntryCompletion
Deprecated.GtkEntryCompletion will be removed in GTK 5.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getMemoryLayout, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.gnome.gtk.Buildable
getBuildableId
Methods inherited from interface org.gnome.gtk.CellLayout
addAttribute, clear, clearAttributes, getArea, getCells, packEnd, packStart, reorder, setAttributes, setCellDataFunc
-
Constructor Details
-
EntryCompletion
Deprecated.Create a EntryCompletion proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
EntryCompletion
Deprecated.GtkEntryCompletion will be removed in GTK 5.Creates a newGtkEntryCompletion
object.
-
-
Method Details
-
getType
Deprecated.Get the GType of the EntryCompletion class- Returns:
- the GType
-
asParent
Deprecated.Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
withArea
Deprecated.GtkEntryCompletion will be removed in GTK 5.Creates a newGtkEntryCompletion
object using the specifiedarea
.The
GtkCellArea
is used to layout cells in the underlyingGtkTreeViewColumn
for the drop-down menu.- Parameters:
area
- theGtkCellArea
used to layout cells- Returns:
- A newly created
GtkEntryCompletion
object
-
complete
Deprecated.GtkEntryCompletion will be removed in GTK 5.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
Deprecated.GtkEntryCompletion will be removed in GTK 5.Computes the common prefix that is shared by all rows in this EntryCompletion that start withkey
.If no row matches
key
,null
will be returned. Note that a text column must have been set for this function to work, seesetTextColumn(int)
for details.- Parameters:
key
- The text to complete for- Returns:
- The common prefix all rows
starting with
key
-
getCompletionPrefix
Deprecated.GtkEntryCompletion will be removed in GTK 5.Get the original text entered by the user that triggered the completion ornull
if there’s no completion ongoing.- Returns:
- the prefix for the current completion
-
getEntry
Deprecated.GtkEntryCompletion will be removed in GTK 5.Gets the entry this EntryCompletion has been attached to.- Returns:
- The entry this EntryCompletion has been attached to
-
getInlineCompletion
Deprecated.GtkEntryCompletion will be removed in GTK 5.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
Deprecated.GtkEntryCompletion will be removed in GTK 5.Returnstrue
if inline-selection mode is turned on.- Returns:
true
if inline-selection mode is on
-
getMinimumKeyLength
Deprecated.GtkEntryCompletion will be removed in GTK 5.Returns the minimum key length as set for this EntryCompletion.- Returns:
- The currently used minimum key length
-
getModel
Deprecated.GtkEntryCompletion will be removed in GTK 5.Returns the model theGtkEntryCompletion
is using as data source.Returns
null
if the model is unset.- Returns:
- A
GtkTreeModel
-
getPopupCompletion
Deprecated.GtkEntryCompletion will be removed in GTK 5.Returns whether the completions should be presented in a popup window.- Returns:
true
if popup completion is turned on
-
getPopupSetWidth
Deprecated.GtkEntryCompletion will be removed in GTK 5.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
Deprecated.GtkEntryCompletion will be removed in GTK 5.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
Deprecated.GtkEntryCompletion will be removed in GTK 5.Returns the column in the model of this EntryCompletion to get strings from.- Returns:
- the column containing the strings
-
insertPrefix
Deprecated.GtkEntryCompletion will be removed in GTK 5.Requests a prefix insertion. -
setInlineCompletion
Deprecated.GtkEntryCompletion will be removed in GTK 5.Sets whether the common prefix of the possible completions should be automatically inserted in the entry.- Parameters:
inlineCompletion
-true
to do inline completion
-
setInlineSelection
Deprecated.GtkEntryCompletion will be removed in GTK 5.Sets whether it is possible to cycle through the possible completions inside the entry.- Parameters:
inlineSelection
-true
to do inline selection
-
setMatchFunc
Deprecated.GtkEntryCompletion will be removed in GTK 5.Sets the match function for this EntryCompletion to befunc
.The match function is used to determine if a row should or should not be in the completion list.
- Parameters:
func
- theGtkEntryCompletion
MatchFunc to use
-
setMinimumKeyLength
Deprecated.GtkEntryCompletion will be removed in GTK 5.Requires the length of the search key for this EntryCompletion to be at leastlength
.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
Deprecated.GtkEntryCompletion will be removed in GTK 5.Sets the model for aGtkEntryCompletion
.If this EntryCompletion 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
- theGtkTreeModel
-
setPopupCompletion
Deprecated.GtkEntryCompletion will be removed in GTK 5.Sets whether the completions should be presented in a popup window.- Parameters:
popupCompletion
-true
to do popup completion
-
setPopupSetWidth
Deprecated.GtkEntryCompletion will be removed in GTK 5.Sets whether the completion popup window will be resized to be the same width as the entry.- Parameters:
popupSetWidth
-true
to make the width of the popup the same as the entry
-
setPopupSingleMatch
Deprecated.GtkEntryCompletion will be removed in GTK 5.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 usingGtk.EntryCompletion:inline-completion
.- Parameters:
popupSingleMatch
-true
if the popup should appear even for a single match
-
setTextColumn
Deprecated.GtkEntryCompletion will be removed in GTK 5.Convenience function for setting up the most used case of this code: a completion list with just strings.This function will set up this EntryCompletion to have a list displaying all (and just) strings in the completion list, and to get those strings from
column
in the model of this EntryCompletion.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 theGtk.EntryCompletion:text-column
property directly.- Parameters:
column
- the column in the model of this EntryCompletion to get strings from
-
onCursorOnMatch
public SignalConnection<EntryCompletion.CursorOnMatchCallback> onCursorOnMatch(EntryCompletion.CursorOnMatchCallback handler) Deprecated.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 tosetModel(org.gnome.gtk.TreeModel)
.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitCursorOnMatch
Deprecated.Emits the "cursor-on-match" signal. SeeonCursorOnMatch(org.gnome.gtk.EntryCompletion.CursorOnMatchCallback)
. -
onInsertPrefix
public SignalConnection<EntryCompletion.InsertPrefixCallback> onInsertPrefix(EntryCompletion.InsertPrefixCallback handler) Deprecated.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 theGtkFileChooser
inserts only the part of the prefix up to the next '/'.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitInsertPrefix
Deprecated.Emits the "insert-prefix" signal. SeeonInsertPrefix(org.gnome.gtk.EntryCompletion.InsertPrefixCallback)
. -
onMatchSelected
public SignalConnection<EntryCompletion.MatchSelectedCallback> onMatchSelected(EntryCompletion.MatchSelectedCallback handler) Deprecated.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 tosetModel(org.gnome.gtk.TreeModel)
.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitMatchSelected
Deprecated.Emits the "match-selected" signal. SeeonMatchSelected(org.gnome.gtk.EntryCompletion.MatchSelectedCallback)
. -
onNoMatches
public SignalConnection<EntryCompletion.NoMatchesCallback> onNoMatches(EntryCompletion.NoMatchesCallback handler) Deprecated.Emitted when the filter model has zero number of rows in completion_complete method.In other words when
GtkEntryCompletion
is out of suggestions.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitNoMatches
public void emitNoMatches()Deprecated.Emits the "no-matches" signal. SeeonNoMatches(org.gnome.gtk.EntryCompletion.NoMatchesCallback)
. -
builder
Deprecated.AEntryCompletion.Builder
object constructs aEntryCompletion
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withEntryCompletion.Builder.build()
.
-