Class Filter

All Implemented Interfaces:
Proxy
Direct Known Subclasses:
BoolFilter, CustomFilter, FileFilter, MultiFilter, StringFilter

@Generated("org.javagi.JavaGI") public class Filter extends GObject

Describes the filtering to be performed by a FilterListModel.

The model will use the filter to determine if it should include items or not by calling match(GObject) for each item and only keeping the ones that the function returns true for.

Filters may change what items they match through their lifetime. In that case, they will emit the Gtk.Filter::changed signal to notify that previous filter results are no longer valid and that items should be checked again via match(GObject).

GTK provides various pre-made filter implementations for common filtering operations. These filters often include properties that can be linked to various widgets to easily allow searches.

However, in particular for large lists or complex search methods, it is also possible to subclass GtkFilter and provide one's own filter.

  • Constructor Details

    • Filter

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

      public Filter()
      Create a new Filter.
  • Method Details

    • getType

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

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

      protected Filter asParent()
      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
    • changed

      public void changed(FilterChange change)

      Notifies all users of the filter that it has changed.

      This emits the Gtk.Filter::changed signal. Users of the filter should then check items again via match(GObject).

      Depending on the change parameter, not all items need to be changed, but only some. Refer to the Gtk.FilterChange documentation for details.

      This function is intended for implementers of GtkFilter subclasses and should not be called from other functions.

      Parameters:
      change - how the filter changed
    • getStrictness

      public FilterMatch getStrictness()

      Gets the known strictness of a filter.

      If the strictness is not known, Gtk.FilterMatch.some is returned.

      This value may change after emission of the Gtk.Filter::changed signal.

      This function is meant purely for optimization purposes. Filters can choose to omit implementing it, but GtkFilterListModel uses it.

      Returns:
      the strictness of this Filter
    • match

      public boolean match(GObject item)
      Checks if the given item is matched by the filter or not.
      Parameters:
      item - The item to check
      Returns:
      true if the filter matches the item
    • onChanged

      Emitted whenever the filter changed.

      Users of the filter should then check items again via match(GObject).

      GtkFilterListModel handles this signal automatically.

      Depending on the change parameter, not all items need to be checked, but only some. Refer to the Gtk.FilterChange documentation for details.

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

      public void emitChanged(FilterChange change)
      Emits the "changed" signal. See onChanged(Filter.ChangedCallback).
    • builder

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