{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)

Note: /@oldValue@/ field of 'GI.Atk.Structs.PropertyValues.PropertyValues' will not contain a
valid value. This is a field defined with the purpose of contain
the previous value of the property, but is not used anymore.
-}

#define ENABLE_OVERLOADING \
       (!defined(__HADDOCK_VERSION__))

module GI.Atk.Structs.PropertyValues
    ( 

-- * Exported types
    PropertyValues(..)                      ,
    newZeroPropertyValues                   ,
    noPropertyValues                        ,


 -- * Properties
-- ** newValue #attr:newValue#
{- | The new value of the named property.
-}
    getPropertyValuesNewValue               ,
#if ENABLE_OVERLOADING
    propertyValues_newValue                 ,
#endif


-- ** oldValue #attr:oldValue#
{- | NULL. This field is not used anymore.
-}
    getPropertyValuesOldValue               ,
#if ENABLE_OVERLOADING
    propertyValues_oldValue                 ,
#endif


-- ** propertyName #attr:propertyName#
{- | The name of the ATK property which has changed.
-}
    clearPropertyValuesPropertyName         ,
    getPropertyValuesPropertyName           ,
#if ENABLE_OVERLOADING
    propertyValues_propertyName             ,
#endif
    setPropertyValuesPropertyName           ,




    ) 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.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.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP


-- | Memory-managed wrapper type.
newtype PropertyValues = PropertyValues (ManagedPtr PropertyValues)
instance WrappedPtr PropertyValues where
    wrappedPtrCalloc :: IO (Ptr PropertyValues)
wrappedPtrCalloc = Int -> IO (Ptr PropertyValues)
forall a. Int -> IO (Ptr a)
callocBytes 56
    wrappedPtrCopy :: PropertyValues -> IO PropertyValues
wrappedPtrCopy = \p :: PropertyValues
p -> PropertyValues
-> (Ptr PropertyValues -> IO PropertyValues) -> IO PropertyValues
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr PropertyValues
p (Int -> Ptr PropertyValues -> IO (Ptr PropertyValues)
forall a. WrappedPtr a => Int -> Ptr a -> IO (Ptr a)
copyBytes 56 (Ptr PropertyValues -> IO (Ptr PropertyValues))
-> (Ptr PropertyValues -> IO PropertyValues)
-> Ptr PropertyValues
-> IO PropertyValues
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> (ManagedPtr PropertyValues -> PropertyValues)
-> Ptr PropertyValues -> IO PropertyValues
forall a.
(HasCallStack, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr PropertyValues -> PropertyValues
PropertyValues)
    wrappedPtrFree :: Maybe (FunPtr (Ptr PropertyValues -> IO ()))
wrappedPtrFree = FunPtr (Ptr PropertyValues -> IO ())
-> Maybe (FunPtr (Ptr PropertyValues -> IO ()))
forall a. a -> Maybe a
Just FunPtr (Ptr PropertyValues -> IO ())
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free

-- | Construct a `PropertyValues` struct initialized to zero.
newZeroPropertyValues :: MonadIO m => m PropertyValues
newZeroPropertyValues :: m PropertyValues
newZeroPropertyValues = IO PropertyValues -> m PropertyValues
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO PropertyValues -> m PropertyValues)
-> IO PropertyValues -> m PropertyValues
forall a b. (a -> b) -> a -> b
$ IO (Ptr PropertyValues)
forall a. WrappedPtr a => IO (Ptr a)
wrappedPtrCalloc IO (Ptr PropertyValues)
-> (Ptr PropertyValues -> IO PropertyValues) -> IO PropertyValues
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr PropertyValues -> PropertyValues)
-> Ptr PropertyValues -> IO PropertyValues
forall a.
(HasCallStack, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr PropertyValues -> PropertyValues
PropertyValues

instance tag ~ 'AttrSet => Constructible PropertyValues tag where
    new :: (ManagedPtr PropertyValues -> PropertyValues)
-> [AttrOp PropertyValues tag] -> m PropertyValues
new _ attrs :: [AttrOp PropertyValues tag]
attrs = do
        PropertyValues
o <- m PropertyValues
forall (m :: * -> *). MonadIO m => m PropertyValues
newZeroPropertyValues
        PropertyValues -> [AttrOp PropertyValues 'AttrSet] -> m ()
forall o (m :: * -> *).
MonadIO m =>
o -> [AttrOp o 'AttrSet] -> m ()
GI.Attributes.set PropertyValues
o [AttrOp PropertyValues tag]
[AttrOp PropertyValues 'AttrSet]
attrs
        PropertyValues -> m PropertyValues
forall (m :: * -> *) a. Monad m => a -> m a
return PropertyValues
o


-- | A convenience alias for `Nothing` :: `Maybe` `PropertyValues`.
noPropertyValues :: Maybe PropertyValues
noPropertyValues :: Maybe PropertyValues
noPropertyValues = Maybe PropertyValues
forall a. Maybe a
Nothing

{- |
Get the value of the “@property_name@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' propertyValues #propertyName
@
-}
getPropertyValuesPropertyName :: MonadIO m => PropertyValues -> m (Maybe T.Text)
getPropertyValuesPropertyName :: PropertyValues -> m (Maybe Text)
getPropertyValuesPropertyName s :: PropertyValues
s = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ PropertyValues
-> (Ptr PropertyValues -> IO (Maybe Text)) -> IO (Maybe Text)
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr PropertyValues
s ((Ptr PropertyValues -> IO (Maybe Text)) -> IO (Maybe Text))
-> (Ptr PropertyValues -> IO (Maybe Text)) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr PropertyValues
ptr -> do
    CString
val <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek (Ptr PropertyValues
ptr Ptr PropertyValues -> Int -> Ptr CString
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0) :: IO CString
    Maybe Text
result <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
SP.convertIfNonNull CString
val ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \val' :: CString
val' -> do
        Text
val'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
val'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
val''
    Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
result

{- |
Set the value of the “@property_name@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' propertyValues [ #propertyName 'Data.GI.Base.Attributes.:=' value ]
@
-}
setPropertyValuesPropertyName :: MonadIO m => PropertyValues -> CString -> m ()
setPropertyValuesPropertyName :: PropertyValues -> CString -> m ()
setPropertyValuesPropertyName s :: PropertyValues
s val :: CString
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ PropertyValues -> (Ptr PropertyValues -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr PropertyValues
s ((Ptr PropertyValues -> IO ()) -> IO ())
-> (Ptr PropertyValues -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr PropertyValues
ptr -> do
    Ptr CString -> CString -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr PropertyValues
ptr Ptr PropertyValues -> Int -> Ptr CString
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0) (CString
val :: CString)

{- |
Set the value of the “@property_name@” field to `Nothing`.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.clear' #propertyName
@
-}
clearPropertyValuesPropertyName :: MonadIO m => PropertyValues -> m ()
clearPropertyValuesPropertyName :: PropertyValues -> m ()
clearPropertyValuesPropertyName s :: PropertyValues
s = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ PropertyValues -> (Ptr PropertyValues -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr PropertyValues
s ((Ptr PropertyValues -> IO ()) -> IO ())
-> (Ptr PropertyValues -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr PropertyValues
ptr -> do
    Ptr CString -> CString -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr PropertyValues
ptr Ptr PropertyValues -> Int -> Ptr CString
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0) (CString
forall a. Ptr a
FP.nullPtr :: CString)

#if ENABLE_OVERLOADING
data PropertyValuesPropertyNameFieldInfo
instance AttrInfo PropertyValuesPropertyNameFieldInfo where
    type AttrAllowedOps PropertyValuesPropertyNameFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint PropertyValuesPropertyNameFieldInfo = (~) CString
    type AttrBaseTypeConstraint PropertyValuesPropertyNameFieldInfo = (~) PropertyValues
    type AttrGetType PropertyValuesPropertyNameFieldInfo = Maybe T.Text
    type AttrLabel PropertyValuesPropertyNameFieldInfo = "property_name"
    type AttrOrigin PropertyValuesPropertyNameFieldInfo = PropertyValues
    attrGet _ = getPropertyValuesPropertyName
    attrSet _ = setPropertyValuesPropertyName
    attrConstruct = undefined
    attrClear _ = clearPropertyValuesPropertyName

propertyValues_propertyName :: AttrLabelProxy "propertyName"
propertyValues_propertyName = AttrLabelProxy

#endif


{- |
Get the value of the “@old_value@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' propertyValues #oldValue
@
-}
getPropertyValuesOldValue :: MonadIO m => PropertyValues -> m GValue
getPropertyValuesOldValue :: PropertyValues -> m GValue
getPropertyValuesOldValue s :: PropertyValues
s = IO GValue -> m GValue
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO GValue -> m GValue) -> IO GValue -> m GValue
forall a b. (a -> b) -> a -> b
$ PropertyValues -> (Ptr PropertyValues -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr PropertyValues
s ((Ptr PropertyValues -> IO GValue) -> IO GValue)
-> (Ptr PropertyValues -> IO GValue) -> IO GValue
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr PropertyValues
ptr -> do
    let val :: Ptr GValue
val = Ptr PropertyValues
ptr Ptr PropertyValues -> Int -> Ptr GValue
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: (Ptr GValue)
    GValue
val' <- ((ManagedPtr GValue -> GValue) -> Ptr GValue -> IO GValue
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr GValue -> GValue
GValue) Ptr GValue
val
    GValue -> IO GValue
forall (m :: * -> *) a. Monad m => a -> m a
return GValue
val'

#if ENABLE_OVERLOADING
data PropertyValuesOldValueFieldInfo
instance AttrInfo PropertyValuesOldValueFieldInfo where
    type AttrAllowedOps PropertyValuesOldValueFieldInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint PropertyValuesOldValueFieldInfo = (~) (Ptr GValue)
    type AttrBaseTypeConstraint PropertyValuesOldValueFieldInfo = (~) PropertyValues
    type AttrGetType PropertyValuesOldValueFieldInfo = GValue
    type AttrLabel PropertyValuesOldValueFieldInfo = "old_value"
    type AttrOrigin PropertyValuesOldValueFieldInfo = PropertyValues
    attrGet _ = getPropertyValuesOldValue
    attrSet _ = undefined
    attrConstruct = undefined
    attrClear _ = undefined

propertyValues_oldValue :: AttrLabelProxy "oldValue"
propertyValues_oldValue = AttrLabelProxy

#endif


{- |
Get the value of the “@new_value@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' propertyValues #newValue
@
-}
getPropertyValuesNewValue :: MonadIO m => PropertyValues -> m GValue
getPropertyValuesNewValue :: PropertyValues -> m GValue
getPropertyValuesNewValue s :: PropertyValues
s = IO GValue -> m GValue
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO GValue -> m GValue) -> IO GValue -> m GValue
forall a b. (a -> b) -> a -> b
$ PropertyValues -> (Ptr PropertyValues -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr PropertyValues
s ((Ptr PropertyValues -> IO GValue) -> IO GValue)
-> (Ptr PropertyValues -> IO GValue) -> IO GValue
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr PropertyValues
ptr -> do
    let val :: Ptr GValue
val = Ptr PropertyValues
ptr Ptr PropertyValues -> Int -> Ptr GValue
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: (Ptr GValue)
    GValue
val' <- ((ManagedPtr GValue -> GValue) -> Ptr GValue -> IO GValue
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr GValue -> GValue
GValue) Ptr GValue
val
    GValue -> IO GValue
forall (m :: * -> *) a. Monad m => a -> m a
return GValue
val'

#if ENABLE_OVERLOADING
data PropertyValuesNewValueFieldInfo
instance AttrInfo PropertyValuesNewValueFieldInfo where
    type AttrAllowedOps PropertyValuesNewValueFieldInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint PropertyValuesNewValueFieldInfo = (~) (Ptr GValue)
    type AttrBaseTypeConstraint PropertyValuesNewValueFieldInfo = (~) PropertyValues
    type AttrGetType PropertyValuesNewValueFieldInfo = GValue
    type AttrLabel PropertyValuesNewValueFieldInfo = "new_value"
    type AttrOrigin PropertyValuesNewValueFieldInfo = PropertyValues
    attrGet _ = getPropertyValuesNewValue
    attrSet _ = undefined
    attrConstruct = undefined
    attrClear _ = undefined

propertyValues_newValue :: AttrLabelProxy "newValue"
propertyValues_newValue = AttrLabelProxy

#endif



#if ENABLE_OVERLOADING
instance O.HasAttributeList PropertyValues
type instance O.AttributeList PropertyValues = PropertyValuesAttributeList
type PropertyValuesAttributeList = ('[ '("propertyName", PropertyValuesPropertyNameFieldInfo), '("oldValue", PropertyValuesOldValueFieldInfo), '("newValue", PropertyValuesNewValueFieldInfo)] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
type family ResolvePropertyValuesMethod (t :: Symbol) (o :: *) :: * where
    ResolvePropertyValuesMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolvePropertyValuesMethod t PropertyValues, O.MethodInfo info PropertyValues p) => O.IsLabelProxy t (PropertyValues -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolvePropertyValuesMethod t PropertyValues, O.MethodInfo info PropertyValues p) => O.IsLabel t (PropertyValues -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif
#endif

#endif