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.MapListModel

Contents

- Exported types
- Methods
  - getModel
  - hasMap
  - new
  - setMapFunc
  - setModel
- Properties
  - hasMap
  - itemType
  - model
  - nItems

Description

A list model that maps the items in another model to different items.

`GtkMapListModel` uses a [callback`gtk`.MapListModelMapFunc].

Example: Create a list of `GtkEventControllers`

### c code

    static gpointer
    map_to_controllers (gpointer widget,
                        gpointer data)
    {
      gpointer result = gtk_widget_observe_controllers (widget);
      g_object_unref (widget);
      return result;
    }

    widgets = gtk_widget_observe_children (widget);

    controllers = gtk_map_list_model_new (widgets,
                                          map_to_controllers,
                                          NULL, NULL);

    model = gtk_flatten_list_model_new (GTK_TYPE_EVENT_CONTROLLER,
                                        controllers);

`GtkMapListModel` will attempt to discard the mapped objects as soon as they are no longer needed and recreate them if necessary.

`GtkMapListModel` passes through sections from the underlying model.

Synopsis

- newtype MapListModel = MapListModel (ManagedPtr MapListModel)
- class (GObject o, IsDescendantOf MapListModel o) => IsMapListModel o
- toMapListModel :: (MonadIO m, IsMapListModel o) => o -> m MapListModel
- mapListModelGetModel :: (HasCallStack, MonadIO m, IsMapListModel a) => a -> m (Maybe ListModel)
- mapListModelHasMap :: (HasCallStack, MonadIO m, IsMapListModel a) => a -> m Bool
- mapListModelNew :: (HasCallStack, MonadIO m, IsListModel a) => Maybe a -> Maybe MapListModelMapFunc -> m MapListModel
- mapListModelSetMapFunc :: (HasCallStack, MonadIO m, IsMapListModel a) => a -> Maybe MapListModelMapFunc -> m ()
- mapListModelSetModel :: (HasCallStack, MonadIO m, IsMapListModel a, IsListModel b) => a -> Maybe b -> m ()
- getMapListModelHasMap :: (MonadIO m, IsMapListModel o) => o -> m Bool
- getMapListModelItemType :: (MonadIO m, IsMapListModel o) => o -> m GType
- clearMapListModelModel :: (MonadIO m, IsMapListModel o) => o -> m ()
- constructMapListModelModel :: (IsMapListModel o, MonadIO m, IsListModel a) => a -> m (GValueConstruct o)
- getMapListModelModel :: (MonadIO m, IsMapListModel o) => o -> m (Maybe ListModel)
- setMapListModelModel :: (MonadIO m, IsMapListModel o, IsListModel a) => o -> a -> m ()
- getMapListModelNItems :: (MonadIO m, IsMapListModel o) => o -> m Word32

# Exported types

newtype MapListModel Source #

Memory-managed wrapper type.

Constructors

MapListModel (ManagedPtr MapListModel) |

#### Instances

Instances details

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

class (GObject o, IsDescendantOf MapListModel o) => IsMapListModel o Source #

Type class for types which can be safely cast to `MapListModel`, for instance with `toMapListModel`.

#### Instances

Instances details

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

toMapListModel :: (MonadIO m, IsMapListModel o) => o -> m MapListModel Source #

Cast to `MapListModel`, 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, forceFloating, freezeNotify, getv, hasMap, isFloating, itemsChanged, notify, notifyByPspec, ref, refSink, runDispose, sectionsChanged, stealData, stealQdata, thawNotify, unref, watchClosure.

#### Getters

getData, getItem, getItemType, getModel, getNItems, getProperty, getQdata, getSection.

#### Setters

setData, setDataFull, setMapFunc, setModel, setProperty.

## getModel

mapListModelGetModel Source #

Arguments

:: (HasCallStack, MonadIO m, IsMapListModel a) |
=> a | `self`: a `GtkMapListModel`
-> m (Maybe ListModel) | Returns: The model that gets mapped

Gets the model that is currently being mapped or `Nothing` if none.

## hasMap

mapListModelHasMap Source #

Arguments

:: (HasCallStack, MonadIO m, IsMapListModel a) |
=> a | `self`: a `GtkMapListModel`
-> m Bool | Returns: `True` if a map function is set

Checks if a map function is currently set on `self`.

## new

mapListModelNew Source #

Arguments

:: (HasCallStack, MonadIO m, IsListModel a) |
=> Maybe a | `model`: The model to map
-> Maybe MapListModelMapFunc | `mapFunc`: map function
-> m MapListModel | Returns: a new `GtkMapListModel`

Creates a new `GtkMapListModel` for the given arguments.

## setMapFunc

mapListModelSetMapFunc Source #

Arguments

:: (HasCallStack, MonadIO m, IsMapListModel a) |
=> a | `self`: a `GtkMapListModel`
-> Maybe MapListModelMapFunc | `mapFunc`: map function
-> m () |

Sets the function used to map items.

The function will be called whenever an item needs to be mapped and must return the item to use for the given input item.

Note that `GtkMapListModel` may call this function multiple times on the same item, because it may delete items it doesn't need anymore.

GTK makes no effort to ensure that `mapFunc` conforms to the item type of `self`. It assumes that the caller knows what they are doing and the map function returns items of the appropriate type.

## setModel

mapListModelSetModel Source #

Arguments

:: (HasCallStack, MonadIO m, IsMapListModel a, IsListModel b) |
=> a | `self`: a `GtkMapListModel`
-> Maybe b | `model`: The model to be mapped
-> m () |

Sets the model to be mapped.

GTK makes no effort to ensure that `model` conforms to the item type expected by the map function. It assumes that the caller knows what they are doing and have set up an appropriate map function.

# Properties

## hasMap

If a map is set for this model

getMapListModelHasMap :: (MonadIO m, IsMapListModel o) => o -> m Bool Source #

Get the value of the “`has-map`” property. When overloading is enabled, this is equivalent to

    get mapListModel #hasMap

## itemType

The type of items. See `listModelGetItemType`.

Since: 4.8

getMapListModelItemType :: (MonadIO m, IsMapListModel o) => o -> m GType Source #

Get the value of the “`item-type`” property. When overloading is enabled, this is equivalent to

    get mapListModel #itemType

## model

The model being mapped.

clearMapListModelModel :: (MonadIO m, IsMapListModel o) => o -> m () Source #

Set the value of the “`model`” property to `Nothing`. When overloading is enabled, this is equivalent to

    clear #model

constructMapListModelModel :: (IsMapListModel o, MonadIO m, IsListModel a) => a -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`model`” property. This is rarely needed directly, but it is used by `new`.

getMapListModelModel :: (MonadIO m, IsMapListModel o) => o -> m (Maybe ListModel) Source #

Get the value of the “`model`” property. When overloading is enabled, this is equivalent to

    get mapListModel #model

setMapListModelModel :: (MonadIO m, IsMapListModel o, IsListModel a) => o -> a -> m () Source #

Set the value of the “`model`” property. When overloading is enabled, this is equivalent to

    set mapListModel [ #model := value ]

## nItems

The number of items. See `listModelGetNItems`.

Since: 4.8

getMapListModelNItems :: (MonadIO m, IsMapListModel o) => o -> m Word32 Source #

Get the value of the “`n-items`” property. When overloading is enabled, this is equivalent to

    get mapListModel #nItems