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

GI.Gtk.Objects.MapListModel

Description

MapListModel is a list model that takes a list model and maps the items in that model to different items according to a MapListModelMapFunc.

Example: Create a list of GtkEventControllers > > 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 (G_TYPE_LIST_MODEL, > widgets, > map_to_controllers, > NULL, NULL); > > model = gtk_flatten_list_model_new (GTK_TYPE_EVENT_CONTROLLER, > controllers);

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

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

-> 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 or Nothing for none

-> Maybe MapListModelMapFunc

mapFunc: map function or Nothing to not map items

-> m MapListModel

Returns: a new MapListModel

Creates a new MapListModel for the given arguments.

setMapFunc

mapListModelSetMapFunc Source #

Arguments

:: (HasCallStack, MonadIO m, IsMapListModel a) 
=> a

self: a MapListModel

-> Maybe MapListModelMapFunc

mapFunc: map function or Nothing to not map items

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

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

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