packages feed

gi-atk-0.2.18.13: GI/Atk/Interfaces/Image.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)
-}

module GI.Atk.Interfaces.Image
    ( 

-- * Exported types
    Image(..)                               ,
    noImage                                 ,
    ImageK                                  ,


 -- * Methods
-- ** imageGetImageDescription
    ImageGetImageDescriptionMethodInfo      ,
    imageGetImageDescription                ,


-- ** imageGetImageLocale
    ImageGetImageLocaleMethodInfo           ,
    imageGetImageLocale                     ,


-- ** imageGetImagePosition
    ImageGetImagePositionMethodInfo         ,
    imageGetImagePosition                   ,


-- ** imageGetImageSize
    ImageGetImageSizeMethodInfo             ,
    imageGetImageSize                       ,


-- ** imageSetImageDescription
    ImageSetImageDescriptionMethodInfo      ,
    imageSetImageDescription                ,




    ) 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

-- interface Image 

newtype Image = Image (ForeignPtr Image)
noImage :: Maybe Image
noImage = Nothing

type family ResolveImageMethod (t :: Symbol) (o :: *) :: * where
    ResolveImageMethod "getImageDescription" o = ImageGetImageDescriptionMethodInfo
    ResolveImageMethod "getImageLocale" o = ImageGetImageLocaleMethodInfo
    ResolveImageMethod "getImagePosition" o = ImageGetImagePositionMethodInfo
    ResolveImageMethod "getImageSize" o = ImageGetImageSizeMethodInfo
    ResolveImageMethod "setImageDescription" o = ImageSetImageDescriptionMethodInfo
    ResolveImageMethod l o = MethodResolutionFailed l o

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

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

type instance AttributeList Image = ImageAttributeList
type ImageAttributeList = ('[ ] :: [(Symbol, *)])

type instance SignalList Image = ImageSignalList
type ImageSignalList = ('[ ] :: [(Symbol, *)])

class ForeignPtrNewtype a => ImageK a
instance (ForeignPtrNewtype o, IsDescendantOf Image o) => ImageK o
type instance ParentTypes Image = ImageParentTypes
type ImageParentTypes = '[]

-- method Image::get_image_description
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "Atk" "Image", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TBasicType TUTF8
-- throws : False
-- Skip return : False

foreign import ccall "atk_image_get_image_description" atk_image_get_image_description :: 
    Ptr Image ->                            -- _obj : TInterface "Atk" "Image"
    IO CString


imageGetImageDescription ::
    (MonadIO m, ImageK a) =>
    a                                       -- _obj
    -> m T.Text                             -- result
imageGetImageDescription _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- atk_image_get_image_description _obj'
    checkUnexpectedReturnNULL "atk_image_get_image_description" result
    result' <- cstringToText result
    touchManagedPtr _obj
    return result'

data ImageGetImageDescriptionMethodInfo
instance (signature ~ (m T.Text), MonadIO m, ImageK a) => MethodInfo ImageGetImageDescriptionMethodInfo a signature where
    overloadedMethod _ = imageGetImageDescription

-- method Image::get_image_locale
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "Atk" "Image", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TBasicType TUTF8
-- throws : False
-- Skip return : False

foreign import ccall "atk_image_get_image_locale" atk_image_get_image_locale :: 
    Ptr Image ->                            -- _obj : TInterface "Atk" "Image"
    IO CString


imageGetImageLocale ::
    (MonadIO m, ImageK a) =>
    a                                       -- _obj
    -> m T.Text                             -- result
imageGetImageLocale _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- atk_image_get_image_locale _obj'
    checkUnexpectedReturnNULL "atk_image_get_image_locale" result
    result' <- cstringToText result
    touchManagedPtr _obj
    return result'

data ImageGetImageLocaleMethodInfo
instance (signature ~ (m T.Text), MonadIO m, ImageK a) => MethodInfo ImageGetImageLocaleMethodInfo a signature where
    overloadedMethod _ = imageGetImageLocale

-- method Image::get_image_position
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "Atk" "Image", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "x", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "y", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "coord_type", argType = TInterface "Atk" "CoordType", 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_image_get_image_position" atk_image_get_image_position :: 
    Ptr Image ->                            -- _obj : TInterface "Atk" "Image"
    Int32 ->                                -- x : TBasicType TInt32
    Int32 ->                                -- y : TBasicType TInt32
    CUInt ->                                -- coord_type : TInterface "Atk" "CoordType"
    IO ()


imageGetImagePosition ::
    (MonadIO m, ImageK a) =>
    a                                       -- _obj
    -> Int32                                -- x
    -> Int32                                -- y
    -> CoordType                            -- coordType
    -> m ()                                 -- result
imageGetImagePosition _obj x y coordType = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let coordType' = (fromIntegral . fromEnum) coordType
    atk_image_get_image_position _obj' x y coordType'
    touchManagedPtr _obj
    return ()

data ImageGetImagePositionMethodInfo
instance (signature ~ (Int32 -> Int32 -> CoordType -> m ()), MonadIO m, ImageK a) => MethodInfo ImageGetImagePositionMethodInfo a signature where
    overloadedMethod _ = imageGetImagePosition

-- method Image::get_image_size
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "Atk" "Image", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "width", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "height", argType = TBasicType TInt32, 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_image_get_image_size" atk_image_get_image_size :: 
    Ptr Image ->                            -- _obj : TInterface "Atk" "Image"
    Int32 ->                                -- width : TBasicType TInt32
    Int32 ->                                -- height : TBasicType TInt32
    IO ()


imageGetImageSize ::
    (MonadIO m, ImageK a) =>
    a                                       -- _obj
    -> Int32                                -- width
    -> Int32                                -- height
    -> m ()                                 -- result
imageGetImageSize _obj width height = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    atk_image_get_image_size _obj' width height
    touchManagedPtr _obj
    return ()

data ImageGetImageSizeMethodInfo
instance (signature ~ (Int32 -> Int32 -> m ()), MonadIO m, ImageK a) => MethodInfo ImageGetImageSizeMethodInfo a signature where
    overloadedMethod _ = imageGetImageSize

-- method Image::set_image_description
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "Atk" "Image", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "description", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "atk_image_set_image_description" atk_image_set_image_description :: 
    Ptr Image ->                            -- _obj : TInterface "Atk" "Image"
    CString ->                              -- description : TBasicType TUTF8
    IO CInt


imageSetImageDescription ::
    (MonadIO m, ImageK a) =>
    a                                       -- _obj
    -> T.Text                               -- description
    -> m Bool                               -- result
imageSetImageDescription _obj description = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    description' <- textToCString description
    result <- atk_image_set_image_description _obj' description'
    let result' = (/= 0) result
    touchManagedPtr _obj
    freeMem description'
    return result'

data ImageSetImageDescriptionMethodInfo
instance (signature ~ (T.Text -> m Bool), MonadIO m, ImageK a) => MethodInfo ImageSetImageDescriptionMethodInfo a signature where
    overloadedMethod _ = imageSetImageDescription