{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
module Data.GI.Gio.ListModel.CustomStoreItem
( CustomStoreItem (..),
customStoreItemGetItem,
fromObject,
)
where
import Control.Monad.IO.Class (MonadIO (liftIO))
import Data.GI.Base (castTo, withManagedPtr)
import Data.GI.Base.BasicTypes
import Data.GI.Base.Overloading (HasParentTypes, ParentTypes)
import Data.GI.Gio.ListModel.Internal.ListItemCImports
import Foreign (Ptr, StablePtr, deRefStablePtr)
import GI.GObject (Object)
foreign import ccall "GiGioHsListItem.h gi_gio_hs_list_item_get_item"
giGioHsListItemGetItem :: Ptr (CustomStoreItem a) -> IO (StablePtr a)
newtype CustomStoreItem a = CustomStoreItem (ManagedPtr (CustomStoreItem a))
instance HasParentTypes (CustomStoreItem a)
type instance ParentTypes (CustomStoreItem a) = '[Object]
instance TypedObject (CustomStoreItem a) where
glibType :: IO GType
glibType = CGType -> GType
GType (CGType -> GType) -> IO CGType -> IO GType
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> IO CGType
listItemGetType
instance GObject (CustomStoreItem a)
customStoreItemGetItem :: MonadIO m => CustomStoreItem a -> m a
customStoreItemGetItem :: CustomStoreItem a -> m a
customStoreItemGetItem CustomStoreItem a
item =
IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO a -> m a) -> IO a -> m a
forall a b. (a -> b) -> a -> b
$ CustomStoreItem a
-> (Ptr (CustomStoreItem a) -> IO (StablePtr a))
-> IO (StablePtr a)
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr CustomStoreItem a
item Ptr (CustomStoreItem a) -> IO (StablePtr a)
forall a. Ptr (CustomStoreItem a) -> IO (StablePtr a)
giGioHsListItemGetItem IO (StablePtr a) -> (StablePtr a -> IO a) -> IO a
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= StablePtr a -> IO a
forall a. StablePtr a -> IO a
deRefStablePtr
fromObject :: forall a m. MonadIO m => Object -> m (Maybe a)
fromObject :: Object -> m (Maybe a)
fromObject Object
obj = IO (Maybe a) -> m (Maybe a)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe a) -> m (Maybe a)) -> IO (Maybe a) -> m (Maybe a)
forall a b. (a -> b) -> a -> b
$ do
Maybe (CustomStoreItem a)
mStoreItem :: Maybe (CustomStoreItem a) <- (ManagedPtr (CustomStoreItem a) -> CustomStoreItem a)
-> Object -> IO (Maybe (CustomStoreItem a))
forall o o'.
(HasCallStack, ManagedPtrNewtype o, TypedObject o,
ManagedPtrNewtype o', TypedObject o', GObject o') =>
(ManagedPtr o' -> o') -> o -> IO (Maybe o')
castTo ManagedPtr (CustomStoreItem a) -> CustomStoreItem a
forall a. ManagedPtr (CustomStoreItem a) -> CustomStoreItem a
CustomStoreItem Object
obj
(CustomStoreItem a -> IO a)
-> Maybe (CustomStoreItem a) -> IO (Maybe a)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse CustomStoreItem a -> IO a
forall (m :: * -> *) a. MonadIO m => CustomStoreItem a -> m a
customStoreItemGetItem Maybe (CustomStoreItem a)
mStoreItem