packages feed

gi-atk-0.2.18.13: GI/Atk/Structs/PropertyValues.hs


{- |
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: @old_value field of #AtkPropertyValues 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.
-}

module GI.Atk.Structs.PropertyValues
    ( 

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


 -- * Properties
-- ** NewValue
    propertyValuesReadNewValue              ,


-- ** OldValue
    propertyValuesReadOldValue              ,


-- ** PropertyName
    propertyValuesReadPropertyName          ,




    ) where

import Prelude ()
import Data.GI.Base.ShortPrelude

import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map

import GI.Atk.Types
import GI.Atk.Callbacks

newtype PropertyValues = PropertyValues (ForeignPtr PropertyValues)
-- | Construct a `PropertyValues` struct initialized to zero.
newZeroPropertyValues :: MonadIO m => m PropertyValues
newZeroPropertyValues = liftIO $ callocBytes 56 >>= wrapPtr PropertyValues

noPropertyValues :: Maybe PropertyValues
noPropertyValues = Nothing

propertyValuesReadPropertyName :: PropertyValues -> IO T.Text
propertyValuesReadPropertyName s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO CString
    val' <- cstringToText val
    return val'

propertyValuesReadOldValue :: PropertyValues -> IO GValue
propertyValuesReadOldValue s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 8) :: IO (Ptr GValue)
    val' <- (newBoxed GValue) val
    return val'

propertyValuesReadNewValue :: PropertyValues -> IO GValue
propertyValuesReadNewValue s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 32) :: IO (Ptr GValue)
    val' <- (newBoxed GValue) val
    return val'

type family ResolvePropertyValuesMethod (t :: Symbol) (o :: *) :: * where
    ResolvePropertyValuesMethod l o = MethodResolutionFailed l o

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

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