{- |
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.GdkPixbuf.Objects.PixbufSimpleAnim
    ( 

-- * Exported types
    PixbufSimpleAnim(..)                    ,
    PixbufSimpleAnimK                       ,
    toPixbufSimpleAnim                      ,
    noPixbufSimpleAnim                      ,


 -- * Methods
-- ** pixbufSimpleAnimAddFrame
    pixbufSimpleAnimAddFrame                ,


-- ** pixbufSimpleAnimGetLoop
    pixbufSimpleAnimGetLoop                 ,


-- ** pixbufSimpleAnimNew
    pixbufSimpleAnimNew                     ,


-- ** pixbufSimpleAnimSetLoop
    pixbufSimpleAnimSetLoop                 ,




 -- * Properties
-- ** Loop
    PixbufSimpleAnimLoopPropertyInfo        ,
    constructPixbufSimpleAnimLoop           ,
    getPixbufSimpleAnimLoop                 ,
    setPixbufSimpleAnimLoop                 ,




    ) 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.GdkPixbuf.Types
import GI.GdkPixbuf.Callbacks
import qualified GI.GObject as GObject

newtype PixbufSimpleAnim = PixbufSimpleAnim (ForeignPtr PixbufSimpleAnim)
foreign import ccall "gdk_pixbuf_simple_anim_get_type"
    c_gdk_pixbuf_simple_anim_get_type :: IO GType

type instance ParentTypes PixbufSimpleAnim = PixbufSimpleAnimParentTypes
type PixbufSimpleAnimParentTypes = '[PixbufAnimation, GObject.Object]

instance GObject PixbufSimpleAnim where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_gdk_pixbuf_simple_anim_get_type
    

class GObject o => PixbufSimpleAnimK o
instance (GObject o, IsDescendantOf PixbufSimpleAnim o) => PixbufSimpleAnimK o

toPixbufSimpleAnim :: PixbufSimpleAnimK o => o -> IO PixbufSimpleAnim
toPixbufSimpleAnim = unsafeCastTo PixbufSimpleAnim

noPixbufSimpleAnim :: Maybe PixbufSimpleAnim
noPixbufSimpleAnim = Nothing

-- VVV Prop "loop"
   -- Type: TBasicType TBoolean
   -- Flags: [PropertyReadable,PropertyWritable]

getPixbufSimpleAnimLoop :: (MonadIO m, PixbufSimpleAnimK o) => o -> m Bool
getPixbufSimpleAnimLoop obj = liftIO $ getObjectPropertyBool obj "loop"

setPixbufSimpleAnimLoop :: (MonadIO m, PixbufSimpleAnimK o) => o -> Bool -> m ()
setPixbufSimpleAnimLoop obj val = liftIO $ setObjectPropertyBool obj "loop" val

constructPixbufSimpleAnimLoop :: Bool -> IO ([Char], GValue)
constructPixbufSimpleAnimLoop val = constructObjectPropertyBool "loop" val

data PixbufSimpleAnimLoopPropertyInfo
instance AttrInfo PixbufSimpleAnimLoopPropertyInfo where
    type AttrAllowedOps PixbufSimpleAnimLoopPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint PixbufSimpleAnimLoopPropertyInfo = (~) Bool
    type AttrBaseTypeConstraint PixbufSimpleAnimLoopPropertyInfo = PixbufSimpleAnimK
    type AttrGetType PixbufSimpleAnimLoopPropertyInfo = Bool
    type AttrLabel PixbufSimpleAnimLoopPropertyInfo = "PixbufSimpleAnim::loop"
    attrGet _ = getPixbufSimpleAnimLoop
    attrSet _ = setPixbufSimpleAnimLoop
    attrConstruct _ = constructPixbufSimpleAnimLoop

type instance AttributeList PixbufSimpleAnim = PixbufSimpleAnimAttributeList
type PixbufSimpleAnimAttributeList = ('[ '("loop", PixbufSimpleAnimLoopPropertyInfo)] :: [(Symbol, *)])

type instance SignalList PixbufSimpleAnim = PixbufSimpleAnimSignalList
type PixbufSimpleAnimSignalList = ('[ '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method PixbufSimpleAnim::new
-- method type : Constructor
-- Args : [Arg {argName = "width", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "height", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "rate", argType = TBasicType TFloat, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "width", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "height", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "rate", argType = TBasicType TFloat, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "GdkPixbuf" "PixbufSimpleAnim"
-- throws : False
-- Skip return : False

foreign import ccall "gdk_pixbuf_simple_anim_new" gdk_pixbuf_simple_anim_new :: 
    Int32 ->                                -- width : TBasicType TInt32
    Int32 ->                                -- height : TBasicType TInt32
    CFloat ->                               -- rate : TBasicType TFloat
    IO (Ptr PixbufSimpleAnim)


pixbufSimpleAnimNew ::
    (MonadIO m) =>
    Int32 ->                                -- width
    Int32 ->                                -- height
    Float ->                                -- rate
    m PixbufSimpleAnim
pixbufSimpleAnimNew width height rate = liftIO $ do
    let rate' = realToFrac rate
    result <- gdk_pixbuf_simple_anim_new width height rate'
    checkUnexpectedReturnNULL "gdk_pixbuf_simple_anim_new" result
    result' <- (wrapObject PixbufSimpleAnim) result
    return result'

-- method PixbufSimpleAnim::add_frame
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GdkPixbuf" "PixbufSimpleAnim", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "pixbuf", argType = TInterface "GdkPixbuf" "Pixbuf", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GdkPixbuf" "PixbufSimpleAnim", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "pixbuf", argType = TInterface "GdkPixbuf" "Pixbuf", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "gdk_pixbuf_simple_anim_add_frame" gdk_pixbuf_simple_anim_add_frame :: 
    Ptr PixbufSimpleAnim ->                 -- _obj : TInterface "GdkPixbuf" "PixbufSimpleAnim"
    Ptr Pixbuf ->                           -- pixbuf : TInterface "GdkPixbuf" "Pixbuf"
    IO ()


pixbufSimpleAnimAddFrame ::
    (MonadIO m, PixbufSimpleAnimK a, PixbufK b) =>
    a ->                                    -- _obj
    b ->                                    -- pixbuf
    m ()
pixbufSimpleAnimAddFrame _obj pixbuf = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let pixbuf' = unsafeManagedPtrCastPtr pixbuf
    gdk_pixbuf_simple_anim_add_frame _obj' pixbuf'
    touchManagedPtr _obj
    touchManagedPtr pixbuf
    return ()

-- method PixbufSimpleAnim::get_loop
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GdkPixbuf" "PixbufSimpleAnim", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GdkPixbuf" "PixbufSimpleAnim", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "gdk_pixbuf_simple_anim_get_loop" gdk_pixbuf_simple_anim_get_loop :: 
    Ptr PixbufSimpleAnim ->                 -- _obj : TInterface "GdkPixbuf" "PixbufSimpleAnim"
    IO CInt


pixbufSimpleAnimGetLoop ::
    (MonadIO m, PixbufSimpleAnimK a) =>
    a ->                                    -- _obj
    m Bool
pixbufSimpleAnimGetLoop _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_pixbuf_simple_anim_get_loop _obj'
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'

-- method PixbufSimpleAnim::set_loop
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GdkPixbuf" "PixbufSimpleAnim", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "loop", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GdkPixbuf" "PixbufSimpleAnim", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "loop", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "gdk_pixbuf_simple_anim_set_loop" gdk_pixbuf_simple_anim_set_loop :: 
    Ptr PixbufSimpleAnim ->                 -- _obj : TInterface "GdkPixbuf" "PixbufSimpleAnim"
    CInt ->                                 -- loop : TBasicType TBoolean
    IO ()


pixbufSimpleAnimSetLoop ::
    (MonadIO m, PixbufSimpleAnimK a) =>
    a ->                                    -- _obj
    Bool ->                                 -- loop
    m ()
pixbufSimpleAnimSetLoop _obj loop = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let loop' = (fromIntegral . fromEnum) loop
    gdk_pixbuf_simple_anim_set_loop _obj' loop'
    touchManagedPtr _obj
    return ()