gi-atk-0.2.18.13: GI/Atk/Structs/Attribute.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)
AtkAttribute is a string name/value pair representing a generic
attribute. This can be used to expose additional information from
an accessible object as a whole (see atk_object_get_attributes())
or an document (see atk_document_get_attributes()). In the case of
text attributes (see atk_text_get_default_attributes()),
#AtkTextAttribute enum defines all the possible text attribute
names. You can use atk_text_attribute_get_name() to get the string
name from the enum value. See also atk_text_attribute_for_name()
and atk_text_attribute_get_value() for more information.
A string name/value pair representing a generic attribute.
-}
module GI.Atk.Structs.Attribute
(
-- * Exported types
Attribute(..) ,
newZeroAttribute ,
noAttribute ,
-- * Methods
-- ** attributeSetFree
attributeSetFree ,
-- * Properties
-- ** Name
attributeReadName ,
-- ** Value
attributeReadValue ,
) 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 Attribute = Attribute (ForeignPtr Attribute)
-- | Construct a `Attribute` struct initialized to zero.
newZeroAttribute :: MonadIO m => m Attribute
newZeroAttribute = liftIO $ callocBytes 16 >>= wrapPtr Attribute
noAttribute :: Maybe Attribute
noAttribute = Nothing
attributeReadName :: Attribute -> IO T.Text
attributeReadName s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 0) :: IO CString
val' <- cstringToText val
return val'
attributeReadValue :: Attribute -> IO T.Text
attributeReadValue s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 8) :: IO CString
val' <- cstringToText val
return val'
-- method Attribute::set_free
-- method type : MemberFunction
-- Args : [Arg {argCName = "attrib_set", argType = TGSList (TBasicType TVoid), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False
foreign import ccall "atk_attribute_set_free" atk_attribute_set_free ::
Ptr (GSList (Ptr ())) -> -- attrib_set : TGSList (TBasicType TVoid)
IO ()
attributeSetFree ::
(MonadIO m) =>
[Ptr ()] -- attribSet
-> m () -- result
attributeSetFree attribSet = liftIO $ do
attribSet' <- packGSList attribSet
atk_attribute_set_free attribSet'
g_slist_free attribSet'
return ()
type family ResolveAttributeMethod (t :: Symbol) (o :: *) :: * where
ResolveAttributeMethod l o = MethodResolutionFailed l o
instance (info ~ ResolveAttributeMethod t Attribute, MethodInfo info Attribute p) => IsLabelProxy t (Attribute -> p) where
fromLabelProxy _ = overloadedMethod (MethodProxy :: MethodProxy info)
#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveAttributeMethod t Attribute, MethodInfo info Attribute p) => IsLabel t (Attribute -> p) where
fromLabel _ = overloadedMethod (MethodProxy :: MethodProxy info)
#endif