gi-gtk-4.0.6: Gtk bindings
CopyrightWill Thompson and Iñaki García Etxebarria
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.Gtk.Objects.MapListModel

Description

A GtkMapListModel maps the items in a list model to different items.

GtkMapListModel uses a [callbackgtk.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.

Synopsis

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

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

TypedObject MapListModel Source # 
Instance details

Defined in GI.Gtk.Objects.MapListModel

Methods

glibType :: IO GType

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

gvalueSet_ :: Ptr GValue -> Maybe MapListModel -> IO ()

gvalueGet_ :: Ptr GValue -> IO (Maybe MapListModel)

type ParentTypes MapListModel Source # 
Instance details

Defined in GI.Gtk.Objects.MapListModel

type ParentTypes MapListModel = '[Object, ListModel]

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

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.

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

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