Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
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
- 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
- constructMapListModelModel :: (IsMapListModel o, MonadIO m, IsListModel a) => a -> m (GValueConstruct o)
- getMapListModelModel :: (MonadIO m, IsMapListModel o) => o -> m (Maybe ListModel)
Exported types
newtype MapListModel Source #
Memory-managed wrapper type.
MapListModel (ManagedPtr MapListModel) |
Instances
Eq MapListModel Source # | |
Defined in GI.Gtk.Objects.MapListModel (==) :: MapListModel -> MapListModel -> Bool # (/=) :: MapListModel -> MapListModel -> Bool # | |
GObject MapListModel Source # | |
Defined in GI.Gtk.Objects.MapListModel | |
ManagedPtrNewtype MapListModel Source # | |
Defined in GI.Gtk.Objects.MapListModel toManagedPtr :: MapListModel -> ManagedPtr MapListModel | |
TypedObject MapListModel Source # | |
Defined in GI.Gtk.Objects.MapListModel | |
HasParentTypes MapListModel Source # | |
Defined in GI.Gtk.Objects.MapListModel | |
IsGValue (Maybe MapListModel) Source # | Convert |
Defined in GI.Gtk.Objects.MapListModel gvalueGType_ :: IO GType gvalueSet_ :: Ptr GValue -> Maybe MapListModel -> IO () gvalueGet_ :: Ptr GValue -> IO (Maybe MapListModel) | |
type ParentTypes MapListModel Source # | |
Defined in GI.Gtk.Objects.MapListModel |
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
(GObject o, IsDescendantOf MapListModel o) => IsMapListModel o Source # | |
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
Methods
bindProperty, bindPropertyFull, forceFloating, freezeNotify, getv, hasMap, isFloating, itemsChanged, notify, notifyByPspec, ref, refSink, runDispose, stealData, stealQdata, thawNotify, unref, watchClosure.
Getters
getData, getItem, getItemType, getModel, getNItems, getProperty, getQdata.
Setters
getModel
:: (HasCallStack, MonadIO m, IsMapListModel a) | |
=> a |
|
-> m (Maybe ListModel) | Returns: The model that gets mapped |
Gets the model that is currently being mapped or Nothing
if none.
hasMap
:: (HasCallStack, MonadIO m, IsMapListModel a) | |
=> a |
|
-> m Bool | Returns: |
Checks if a map function is currently set on self
new
:: (HasCallStack, MonadIO m, IsListModel a) | |
=> Maybe a |
|
-> Maybe MapListModelMapFunc |
|
-> m MapListModel | Returns: a new |
Creates a new MapListModel
for the given arguments.
setMapFunc
mapListModelSetMapFunc Source #
:: (HasCallStack, MonadIO m, IsMapListModel a) | |
=> a |
|
-> Maybe MapListModelMapFunc |
|
-> 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
:: (HasCallStack, MonadIO m, IsMapListModel a, IsListModel b) | |
=> a |
|
-> Maybe b |
|
-> 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