Class EntryCompletion

All Implemented Interfaces:
Buildable, CellLayout, Proxy

@Generated("org.javagi.JavaGI") @Deprecated public class EntryCompletion extends GObject implements Buildable, CellLayout
Deprecated.

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(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(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(TreeIter, 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(TreeIter, TreeIter) to obtain a matching iter.

  • Constructor Details

    • EntryCompletion

      public EntryCompletion(MemorySegment address)
      Deprecated.
      Create a EntryCompletion instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • EntryCompletion

      public EntryCompletion()
      Deprecated.
      Create a new EntryCompletion.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Deprecated.
      Get the GType of the EntryCompletion class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      Deprecated.
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected EntryCompletion asParent()
      Deprecated.
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GObject
      Returns:
      the instance as if it were its parent type
    • withArea

      @Deprecated public static EntryCompletion withArea(CellArea area)
      Deprecated.
      GtkEntryCompletion will be removed in GTK 5.

      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

      @Deprecated public void 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 public @Nullable String computePrefix(String key)
      Deprecated.
      GtkEntryCompletion will be removed in GTK 5.

      Computes the common prefix that is shared by all rows in this EntryCompletion 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 setTextColumn(int) for details.

      Parameters:
      key - The text to complete for
      Returns:
      The common prefix all rows starting with key
    • getCompletionPrefix

      @Deprecated public @Nullable String getCompletionPrefix()
      Deprecated.
      GtkEntryCompletion will be removed in GTK 5.
      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

      @Deprecated public Widget 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 public boolean 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 public boolean getInlineSelection()
      Deprecated.
      GtkEntryCompletion will be removed in GTK 5.
      Returns true if inline-selection mode is turned on.
      Returns:
      true if inline-selection mode is on
    • getMinimumKeyLength

      @Deprecated public int getMinimumKeyLength()
      Deprecated.
      GtkEntryCompletion will be removed in GTK 5.
      Returns the minimum key length as set for completion.
      Returns:
      The currently used minimum key length
    • getModel

      @Deprecated public @Nullable TreeModel getModel()
      Deprecated.
      GtkEntryCompletion will be removed in GTK 5.

      Returns the model the GtkEntryCompletion is using as data source.

      Returns null if the model is unset.

      Returns:
      A GtkTreeModel
    • getPopupCompletion

      @Deprecated public boolean 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 public boolean 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 public boolean 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 public int 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 public void insertPrefix()
      Deprecated.
      GtkEntryCompletion will be removed in GTK 5.
      Requests a prefix insertion.
    • setInlineCompletion

      @Deprecated public void setInlineCompletion(boolean inlineCompletion)
      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 public void setInlineSelection(boolean inlineSelection)
      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 public void setMatchFunc(@Nullable EntryCompletionMatchFunc func)
      Deprecated.
      GtkEntryCompletion will be removed in GTK 5.

      Sets the match function for this EntryCompletion 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 GtkEntryCompletionMatchFunc to use
    • setMinimumKeyLength

      @Deprecated public void setMinimumKeyLength(int length)
      Deprecated.
      GtkEntryCompletion will be removed in GTK 5.

      Requires the length of the search key for this EntryCompletion 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

      @Deprecated public void setModel(@Nullable TreeModel model)
      Deprecated.
      GtkEntryCompletion will be removed in GTK 5.

      Sets the model for a GtkEntryCompletion.

      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 - the GtkTreeModel
    • setPopupCompletion

      @Deprecated public void setPopupCompletion(boolean popupCompletion)
      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 public void setPopupSetWidth(boolean popupSetWidth)
      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 public void setPopupSingleMatch(boolean popupSingleMatch)
      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 using Gtk.EntryCompletion:inline-completion.

      Parameters:
      popupSingleMatch - true if the popup should appear even for a single match
    • setTextColumn

      @Deprecated public void setTextColumn(int column)
      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 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 Gtk.EntryCompletion:text-column property directly.

      Parameters:
      column - the column in the model of this EntryCompletion to get strings from
    • onCursorOnMatch

      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 to setModel(TreeModel).

      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitCursorOnMatch

      public boolean emitCursorOnMatch(@Nullable TreeModel model, @Nullable TreeIter iter)
      Deprecated.
      Emits the "cursor-on-match" signal. See onCursorOnMatch(EntryCompletion.CursorOnMatchCallback).
    • onInsertPrefix

      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 the GtkFileChooser 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

      public boolean emitInsertPrefix(String prefix)
      Deprecated.
      Emits the "insert-prefix" signal. See onInsertPrefix(EntryCompletion.InsertPrefixCallback).
    • onMatchSelected

      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 to setModel(TreeModel).

      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitMatchSelected

      public boolean emitMatchSelected(@Nullable TreeModel model, @Nullable TreeIter iter)
      Deprecated.
      Emits the "match-selected" signal. See onMatchSelected(EntryCompletion.MatchSelectedCallback).
    • onNoMatches

      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. See onNoMatches(EntryCompletion.NoMatchesCallback).
    • builder

      public static EntryCompletion.Builder<? extends EntryCompletion.Builder> builder()
      Deprecated.
      A EntryCompletion.Builder object constructs a EntryCompletion with the specified properties. Use the various set...() methods to set properties, and finish construction with EntryCompletion.Builder.build().
      Returns:
      the builder object