{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Pango.Structs.AttrFontDesc
(
AttrFontDesc(..) ,
newZeroAttrFontDesc ,
noAttrFontDesc ,
#if defined(ENABLE_OVERLOADING)
ResolveAttrFontDescMethod ,
#endif
attrFontDescNew ,
#if defined(ENABLE_OVERLOADING)
attrFontDesc_attr ,
#endif
getAttrFontDescAttr ,
#if defined(ENABLE_OVERLOADING)
attrFontDesc_desc ,
#endif
clearAttrFontDescDesc ,
getAttrFontDescDesc ,
setAttrFontDescDesc ,
) where
import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P
import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL
import {-# SOURCE #-} qualified GI.Pango.Structs.Attribute as Pango.Attribute
import {-# SOURCE #-} qualified GI.Pango.Structs.FontDescription as Pango.FontDescription
newtype AttrFontDesc = AttrFontDesc (ManagedPtr AttrFontDesc)
deriving (AttrFontDesc -> AttrFontDesc -> Bool
(AttrFontDesc -> AttrFontDesc -> Bool)
-> (AttrFontDesc -> AttrFontDesc -> Bool) -> Eq AttrFontDesc
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttrFontDesc -> AttrFontDesc -> Bool
$c/= :: AttrFontDesc -> AttrFontDesc -> Bool
== :: AttrFontDesc -> AttrFontDesc -> Bool
$c== :: AttrFontDesc -> AttrFontDesc -> Bool
Eq)
instance WrappedPtr AttrFontDesc where
wrappedPtrCalloc :: IO (Ptr AttrFontDesc)
wrappedPtrCalloc = Int -> IO (Ptr AttrFontDesc)
forall a. Int -> IO (Ptr a)
callocBytes 24
wrappedPtrCopy :: AttrFontDesc -> IO AttrFontDesc
wrappedPtrCopy = \p :: AttrFontDesc
p -> AttrFontDesc
-> (Ptr AttrFontDesc -> IO AttrFontDesc) -> IO AttrFontDesc
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr AttrFontDesc
p (Int -> Ptr AttrFontDesc -> IO (Ptr AttrFontDesc)
forall a. WrappedPtr a => Int -> Ptr a -> IO (Ptr a)
copyBytes 24 (Ptr AttrFontDesc -> IO (Ptr AttrFontDesc))
-> (Ptr AttrFontDesc -> IO AttrFontDesc)
-> Ptr AttrFontDesc
-> IO AttrFontDesc
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> (ManagedPtr AttrFontDesc -> AttrFontDesc)
-> Ptr AttrFontDesc -> IO AttrFontDesc
forall a.
(HasCallStack, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr AttrFontDesc -> AttrFontDesc
AttrFontDesc)
wrappedPtrFree :: Maybe (GDestroyNotify AttrFontDesc)
wrappedPtrFree = GDestroyNotify AttrFontDesc -> Maybe (GDestroyNotify AttrFontDesc)
forall a. a -> Maybe a
Just GDestroyNotify AttrFontDesc
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free
newZeroAttrFontDesc :: MonadIO m => m AttrFontDesc
newZeroAttrFontDesc :: m AttrFontDesc
newZeroAttrFontDesc = IO AttrFontDesc -> m AttrFontDesc
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO AttrFontDesc -> m AttrFontDesc)
-> IO AttrFontDesc -> m AttrFontDesc
forall a b. (a -> b) -> a -> b
$ IO (Ptr AttrFontDesc)
forall a. WrappedPtr a => IO (Ptr a)
wrappedPtrCalloc IO (Ptr AttrFontDesc)
-> (Ptr AttrFontDesc -> IO AttrFontDesc) -> IO AttrFontDesc
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr AttrFontDesc -> AttrFontDesc)
-> Ptr AttrFontDesc -> IO AttrFontDesc
forall a.
(HasCallStack, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr AttrFontDesc -> AttrFontDesc
AttrFontDesc
instance tag ~ 'AttrSet => Constructible AttrFontDesc tag where
new :: (ManagedPtr AttrFontDesc -> AttrFontDesc)
-> [AttrOp AttrFontDesc tag] -> m AttrFontDesc
new _ attrs :: [AttrOp AttrFontDesc tag]
attrs = do
AttrFontDesc
o <- m AttrFontDesc
forall (m :: * -> *). MonadIO m => m AttrFontDesc
newZeroAttrFontDesc
AttrFontDesc -> [AttrOp AttrFontDesc 'AttrSet] -> m ()
forall o (m :: * -> *).
MonadIO m =>
o -> [AttrOp o 'AttrSet] -> m ()
GI.Attributes.set AttrFontDesc
o [AttrOp AttrFontDesc tag]
[AttrOp AttrFontDesc 'AttrSet]
attrs
AttrFontDesc -> m AttrFontDesc
forall (m :: * -> *) a. Monad m => a -> m a
return AttrFontDesc
o
noAttrFontDesc :: Maybe AttrFontDesc
noAttrFontDesc :: Maybe AttrFontDesc
noAttrFontDesc = Maybe AttrFontDesc
forall a. Maybe a
Nothing
getAttrFontDescAttr :: MonadIO m => AttrFontDesc -> m Pango.Attribute.Attribute
getAttrFontDescAttr :: AttrFontDesc -> m Attribute
getAttrFontDescAttr s :: AttrFontDesc
s = IO Attribute -> m Attribute
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Attribute -> m Attribute) -> IO Attribute -> m Attribute
forall a b. (a -> b) -> a -> b
$ AttrFontDesc -> (Ptr AttrFontDesc -> IO Attribute) -> IO Attribute
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr AttrFontDesc
s ((Ptr AttrFontDesc -> IO Attribute) -> IO Attribute)
-> (Ptr AttrFontDesc -> IO Attribute) -> IO Attribute
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr AttrFontDesc
ptr -> do
let val :: Ptr Attribute
val = Ptr AttrFontDesc
ptr Ptr AttrFontDesc -> Int -> Ptr Attribute
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: (Ptr Pango.Attribute.Attribute)
Attribute
val' <- ((ManagedPtr Attribute -> Attribute)
-> Ptr Attribute -> IO Attribute
forall a.
(HasCallStack, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newPtr ManagedPtr Attribute -> Attribute
Pango.Attribute.Attribute) Ptr Attribute
val
Attribute -> IO Attribute
forall (m :: * -> *) a. Monad m => a -> m a
return Attribute
val'
#if defined(ENABLE_OVERLOADING)
data AttrFontDescAttrFieldInfo
instance AttrInfo AttrFontDescAttrFieldInfo where
type AttrBaseTypeConstraint AttrFontDescAttrFieldInfo = (~) AttrFontDesc
type AttrAllowedOps AttrFontDescAttrFieldInfo = '[ 'AttrGet]
type AttrSetTypeConstraint AttrFontDescAttrFieldInfo = (~) (Ptr Pango.Attribute.Attribute)
type AttrTransferTypeConstraint AttrFontDescAttrFieldInfo = (~)(Ptr Pango.Attribute.Attribute)
type AttrTransferType AttrFontDescAttrFieldInfo = (Ptr Pango.Attribute.Attribute)
type AttrGetType AttrFontDescAttrFieldInfo = Pango.Attribute.Attribute
type AttrLabel AttrFontDescAttrFieldInfo = "attr"
type AttrOrigin AttrFontDescAttrFieldInfo = AttrFontDesc
attrGet = getAttrFontDescAttr
attrSet = undefined
attrConstruct = undefined
attrClear = undefined
attrTransfer = undefined
attrFontDesc_attr :: AttrLabelProxy "attr"
attrFontDesc_attr = AttrLabelProxy
#endif
getAttrFontDescDesc :: MonadIO m => AttrFontDesc -> m (Maybe Pango.FontDescription.FontDescription)
getAttrFontDescDesc :: AttrFontDesc -> m (Maybe FontDescription)
getAttrFontDescDesc s :: AttrFontDesc
s = IO (Maybe FontDescription) -> m (Maybe FontDescription)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe FontDescription) -> m (Maybe FontDescription))
-> IO (Maybe FontDescription) -> m (Maybe FontDescription)
forall a b. (a -> b) -> a -> b
$ AttrFontDesc
-> (Ptr AttrFontDesc -> IO (Maybe FontDescription))
-> IO (Maybe FontDescription)
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr AttrFontDesc
s ((Ptr AttrFontDesc -> IO (Maybe FontDescription))
-> IO (Maybe FontDescription))
-> (Ptr AttrFontDesc -> IO (Maybe FontDescription))
-> IO (Maybe FontDescription)
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr AttrFontDesc
ptr -> do
Ptr FontDescription
val <- Ptr (Ptr FontDescription) -> IO (Ptr FontDescription)
forall a. Storable a => Ptr a -> IO a
peek (Ptr AttrFontDesc
ptr Ptr AttrFontDesc -> Int -> Ptr (Ptr FontDescription)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16) :: IO (Ptr Pango.FontDescription.FontDescription)
Maybe FontDescription
result <- Ptr FontDescription
-> (Ptr FontDescription -> IO FontDescription)
-> IO (Maybe FontDescription)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
SP.convertIfNonNull Ptr FontDescription
val ((Ptr FontDescription -> IO FontDescription)
-> IO (Maybe FontDescription))
-> (Ptr FontDescription -> IO FontDescription)
-> IO (Maybe FontDescription)
forall a b. (a -> b) -> a -> b
$ \val' :: Ptr FontDescription
val' -> do
FontDescription
val'' <- ((ManagedPtr FontDescription -> FontDescription)
-> Ptr FontDescription -> IO FontDescription
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr FontDescription -> FontDescription
Pango.FontDescription.FontDescription) Ptr FontDescription
val'
FontDescription -> IO FontDescription
forall (m :: * -> *) a. Monad m => a -> m a
return FontDescription
val''
Maybe FontDescription -> IO (Maybe FontDescription)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe FontDescription
result
setAttrFontDescDesc :: MonadIO m => AttrFontDesc -> Ptr Pango.FontDescription.FontDescription -> m ()
setAttrFontDescDesc :: AttrFontDesc -> Ptr FontDescription -> m ()
setAttrFontDescDesc s :: AttrFontDesc
s val :: Ptr FontDescription
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ AttrFontDesc -> (Ptr AttrFontDesc -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr AttrFontDesc
s ((Ptr AttrFontDesc -> IO ()) -> IO ())
-> (Ptr AttrFontDesc -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr AttrFontDesc
ptr -> do
Ptr (Ptr FontDescription) -> Ptr FontDescription -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr AttrFontDesc
ptr Ptr AttrFontDesc -> Int -> Ptr (Ptr FontDescription)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16) (Ptr FontDescription
val :: Ptr Pango.FontDescription.FontDescription)
clearAttrFontDescDesc :: MonadIO m => AttrFontDesc -> m ()
clearAttrFontDescDesc :: AttrFontDesc -> m ()
clearAttrFontDescDesc s :: AttrFontDesc
s = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ AttrFontDesc -> (Ptr AttrFontDesc -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr AttrFontDesc
s ((Ptr AttrFontDesc -> IO ()) -> IO ())
-> (Ptr AttrFontDesc -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr AttrFontDesc
ptr -> do
Ptr (Ptr FontDescription) -> Ptr FontDescription -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr AttrFontDesc
ptr Ptr AttrFontDesc -> Int -> Ptr (Ptr FontDescription)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16) (Ptr FontDescription
forall a. Ptr a
FP.nullPtr :: Ptr Pango.FontDescription.FontDescription)
#if defined(ENABLE_OVERLOADING)
data AttrFontDescDescFieldInfo
instance AttrInfo AttrFontDescDescFieldInfo where
type AttrBaseTypeConstraint AttrFontDescDescFieldInfo = (~) AttrFontDesc
type AttrAllowedOps AttrFontDescDescFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
type AttrSetTypeConstraint AttrFontDescDescFieldInfo = (~) (Ptr Pango.FontDescription.FontDescription)
type AttrTransferTypeConstraint AttrFontDescDescFieldInfo = (~)(Ptr Pango.FontDescription.FontDescription)
type AttrTransferType AttrFontDescDescFieldInfo = (Ptr Pango.FontDescription.FontDescription)
type AttrGetType AttrFontDescDescFieldInfo = Maybe Pango.FontDescription.FontDescription
type AttrLabel AttrFontDescDescFieldInfo = "desc"
type AttrOrigin AttrFontDescDescFieldInfo = AttrFontDesc
attrGet = getAttrFontDescDesc
attrSet = setAttrFontDescDesc
attrConstruct = undefined
attrClear = clearAttrFontDescDesc
attrTransfer _ v = do
return v
attrFontDesc_desc :: AttrLabelProxy "desc"
attrFontDesc_desc = AttrLabelProxy
#endif
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList AttrFontDesc
type instance O.AttributeList AttrFontDesc = AttrFontDescAttributeList
type AttrFontDescAttributeList = ('[ '("attr", AttrFontDescAttrFieldInfo), '("desc", AttrFontDescDescFieldInfo)] :: [(Symbol, *)])
#endif
foreign import ccall "pango_attr_font_desc_new" pango_attr_font_desc_new ::
Ptr Pango.FontDescription.FontDescription ->
IO (Ptr Pango.Attribute.Attribute)
attrFontDescNew ::
(B.CallStack.HasCallStack, MonadIO m) =>
Pango.FontDescription.FontDescription
-> m Pango.Attribute.Attribute
attrFontDescNew :: FontDescription -> m Attribute
attrFontDescNew desc :: FontDescription
desc = IO Attribute -> m Attribute
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Attribute -> m Attribute) -> IO Attribute -> m Attribute
forall a b. (a -> b) -> a -> b
$ do
Ptr FontDescription
desc' <- FontDescription -> IO (Ptr FontDescription)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr FontDescription
desc
Ptr Attribute
result <- Ptr FontDescription -> IO (Ptr Attribute)
pango_attr_font_desc_new Ptr FontDescription
desc'
Text -> Ptr Attribute -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "attrFontDescNew" Ptr Attribute
result
Attribute
result' <- ((ManagedPtr Attribute -> Attribute)
-> Ptr Attribute -> IO Attribute
forall a.
(HasCallStack, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr Attribute -> Attribute
Pango.Attribute.Attribute) Ptr Attribute
result
FontDescription -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr FontDescription
desc
Attribute -> IO Attribute
forall (m :: * -> *) a. Monad m => a -> m a
return Attribute
result'
#if defined(ENABLE_OVERLOADING)
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveAttrFontDescMethod (t :: Symbol) (o :: *) :: * where
ResolveAttrFontDescMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveAttrFontDescMethod t AttrFontDesc, O.MethodInfo info AttrFontDesc p) => OL.IsLabel t (AttrFontDesc -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#endif