gi-gtk4-4.0.12: Gtk 4.x bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | None
Language | Haskell2010

GI.Gtk.Objects.Filter

Contents

- Exported types
- Methods
  - changed
  - getStrictness
  - match
- Signals
  - changed

Description

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 `filterMatch` 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 Filter::changed signal to notify that previous filter results are no longer valid and that items should be checked again via `filterMatch`.

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.

Synopsis

- newtype Filter = Filter (ManagedPtr Filter)
- class (GObject o, IsDescendantOf Filter o) => IsFilter o
- toFilter :: (MonadIO m, IsFilter o) => o -> m Filter
- filterChanged :: (HasCallStack, MonadIO m, IsFilter a) => a -> FilterChange -> m ()
- filterGetStrictness :: (HasCallStack, MonadIO m, IsFilter a) => a -> m FilterMatch
- filterMatch :: (HasCallStack, MonadIO m, IsFilter a, IsObject b) => a -> b -> m Bool
- type FilterChangedCallback = FilterChange -> IO ()
- afterFilterChanged :: (IsFilter a, MonadIO m) => a -> ((?self :: a) => FilterChangedCallback) -> m SignalHandlerId
- onFilterChanged :: (IsFilter a, MonadIO m) => a -> ((?self :: a) => FilterChangedCallback) -> m SignalHandlerId

# Exported types

newtype Filter Source #

Memory-managed wrapper type.

Constructors

Filter (ManagedPtr Filter) |

#### Instances

Instances details

Eq Filter Source # |
Instance details Defined in GI.Gtk.Objects.Filter Methods (==) :: Filter -> Filter -> Bool Source # (/=) :: Filter -> Filter -> Bool Source #
GObject Filter Source # |
Instance details Defined in GI.Gtk.Objects.Filter
ManagedPtrNewtype Filter Source # |
Instance details Defined in GI.Gtk.Objects.Filter Methods toManagedPtr :: Filter -> ManagedPtr Filter Source #
TypedObject Filter Source # |
Instance details Defined in GI.Gtk.Objects.Filter Methods glibType :: IO GType Source #
HasParentTypes Filter Source # |
Instance details Defined in GI.Gtk.Objects.Filter
IsGValue (Maybe Filter) Source # | Convert `Filter` to and from `GValue`. See `toGValue` and `fromGValue`.
Instance details Defined in GI.Gtk.Objects.Filter Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Maybe Filter -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (Maybe Filter) Source #
type ParentTypes Filter Source # |
Instance details Defined in GI.Gtk.Objects.Filter type ParentTypes Filter = '[Object]

class (GObject o, IsDescendantOf Filter o) => IsFilter o Source #

Type class for types which can be safely cast to `Filter`, for instance with `toFilter`.

#### Instances

Instances details

(GObject o, IsDescendantOf Filter o) => IsFilter o Source # |
Instance details Defined in GI.Gtk.Objects.Filter

toFilter :: (MonadIO m, IsFilter o) => o -> m Filter Source #

Cast to `Filter`, for types for which this is known to be safe. For general casts, use `castTo`.

# Methods

### Click to display all available methods, including inherited ones

Expand

#### Methods

bindProperty, bindPropertyFull, changed, forceFloating, freezeNotify, getv, isFloating, match, notify, notifyByPspec, ref, refSink, runDispose, stealData, stealQdata, thawNotify, unref, watchClosure.

#### Getters

getData, getProperty, getQdata, getStrictness.

#### Setters

setData, setDataFull, setProperty.

## changed

filterChanged Source #

Arguments

:: (HasCallStack, MonadIO m, IsFilter a) |
=> a | `self`: a filter
-> FilterChange | `change`: how the filter changed
-> m () |

Notifies all users of the filter that it has changed.

This emits the Filter::changed signal. Users of the filter should then check items again via `filterMatch`.

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

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

## getStrictness

filterGetStrictness Source #

Arguments

:: (HasCallStack, MonadIO m, IsFilter a) |
=> a | `self`: a filter
-> m FilterMatch | Returns: the strictness of `self`

Gets the known strictness of a filter.

If the strictness is not known, `FilterMatchSome` is returned.

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

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

## match

filterMatch Source #

Arguments

:: (HasCallStack, MonadIO m, IsFilter a, IsObject b) |
=> a | `self`: a filter
-> b | `item`: The item to check
-> m Bool | Returns: true if the filter matches the item

Checks if the given `item` is matched by the filter or not.

# Signals

## changed

type FilterChangedCallback Source #

Arguments

= FilterChange | `change`: how the filter changed
-> IO () |

Emitted whenever the filter changed.

Users of the filter should then check items again via `filterMatch`.

`GtkFilterListModel` handles this signal automatically.

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

afterFilterChanged :: (IsFilter a, MonadIO m) => a -> ((?self :: a) => FilterChangedCallback) -> m SignalHandlerId Source #

Connect a signal handler for the changed signal, to be run after the default handler. When overloading is enabled, this is equivalent to

    after filter #changed callback

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit `?self` parameter. Note that this requires activating the `ImplicitParams` GHC extension.

onFilterChanged :: (IsFilter a, MonadIO m) => a -> ((?self :: a) => FilterChangedCallback) -> m SignalHandlerId Source #

Connect a signal handler for the changed signal, to be run before the default handler. When overloading is enabled, this is equivalent to

    on filter #changed callback