:right-sidebar: True StringFilter =================================================================== .. currentmodule:: gi.repository.Gtk .. class:: StringFilter(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.Gtk.Filter`, :class:`~gi.repository.GObject.Object` ``GtkStringFilter`` determines whether to include items by comparing strings to a fixed search term. The strings are obtained from the items by evaluating a ``GtkExpression`` set with :obj:`~gi.repository.Gtk.StringFilter.set_expression`, and they are compared against a search term set with :obj:`~gi.repository.Gtk.StringFilter.set_search`. ``GtkStringFilter`` has several different modes of comparison - it can match the whole string, just a prefix, or any substring. Use :obj:`~gi.repository.Gtk.StringFilter.set_match_mode` choose a mode. It is also possible to make case-insensitive comparisons, with :obj:`~gi.repository.Gtk.StringFilter.set_ignore_case`. Constructors ------------ .. rst-class:: interim-class .. class:: StringFilter :no-index: .. classmethod:: new(expression: ~gi.repository.Gtk.Expression | None = None) -> ~gi.repository.Gtk.StringFilter Creates a new string filter. You will want to set up the filter by providing a string to search for and by providing a property to look up on the item. :param expression: The expression to evaluate Methods ------- .. rst-class:: interim-class .. class:: StringFilter :no-index: .. method:: get_expression() -> ~gi.repository.Gtk.Expression | None Gets the expression that the string filter uses to obtain strings from items. .. method:: get_ignore_case() -> bool Returns whether the filter ignores case differences. .. method:: get_match_mode() -> ~gi.repository.Gtk.StringFilterMatchMode Returns the match mode that the filter is using. .. method:: get_search() -> str | None Gets the search term. .. method:: set_expression(expression: ~gi.repository.Gtk.Expression | None = None) -> None Sets the expression that the string filter uses to obtain strings from items. The expression must have a value type of :obj:`str`. :param expression: a ``GtkExpression`` .. method:: set_ignore_case(ignore_case: bool) -> None Sets whether the filter ignores case differences. :param ignore_case: :const:`True` to ignore case .. method:: set_match_mode(mode: ~gi.repository.Gtk.StringFilterMatchMode) -> None Sets the match mode for the filter. :param mode: the new match mode .. method:: set_search(search: str | None = None) -> None Sets the string to search for. :param search: The string to search for or :const:`None` to clear the search Properties ---------- .. rst-class:: interim-class .. class:: StringFilter :no-index: .. attribute:: props.expression :type: ~gi.repository.Gtk.Expression The expression to evaluate on item to get a string to compare with. .. attribute:: props.ignore_case :type: bool If matching is case sensitive. .. attribute:: props.match_mode :type: ~gi.repository.Gtk.StringFilterMatchMode If exact matches are necessary or if substrings are allowed. .. attribute:: props.search :type: str The search term.