packages feed

gi-gdkpixbuf-0.2.31.12: GI/GdkPixbuf/Objects/PixbufAnimation.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.GdkPixbuf.Objects.PixbufAnimation
    ( 

-- * Exported types
    PixbufAnimation(..)                     ,
    PixbufAnimationK                        ,
    toPixbufAnimation                       ,
    noPixbufAnimation                       ,


 -- * Methods
-- ** pixbufAnimationGetHeight
    pixbufAnimationGetHeight                ,


-- ** pixbufAnimationGetIter
    pixbufAnimationGetIter                  ,


-- ** pixbufAnimationGetStaticImage
    pixbufAnimationGetStaticImage           ,


-- ** pixbufAnimationGetWidth
    pixbufAnimationGetWidth                 ,


-- ** pixbufAnimationIsStaticImage
    pixbufAnimationIsStaticImage            ,


-- ** pixbufAnimationNewFromFile
    pixbufAnimationNewFromFile              ,


-- ** pixbufAnimationNewFromResource
    pixbufAnimationNewFromResource          ,


-- ** pixbufAnimationNewFromStream
    pixbufAnimationNewFromStream            ,


-- ** pixbufAnimationNewFromStreamAsync
    pixbufAnimationNewFromStreamAsync       ,


-- ** pixbufAnimationNewFromStreamFinish
    pixbufAnimationNewFromStreamFinish      ,




    ) 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.GLib as GLib
import qualified GI.GObject as GObject
import qualified GI.Gio as Gio

newtype PixbufAnimation = PixbufAnimation (ForeignPtr PixbufAnimation)
foreign import ccall "gdk_pixbuf_animation_get_type"
    c_gdk_pixbuf_animation_get_type :: IO GType

type instance ParentTypes PixbufAnimation = PixbufAnimationParentTypes
type PixbufAnimationParentTypes = '[GObject.Object]

instance GObject PixbufAnimation where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_gdk_pixbuf_animation_get_type
    

class GObject o => PixbufAnimationK o
instance (GObject o, IsDescendantOf PixbufAnimation o) => PixbufAnimationK o

toPixbufAnimation :: PixbufAnimationK o => o -> IO PixbufAnimation
toPixbufAnimation = unsafeCastTo PixbufAnimation

noPixbufAnimation :: Maybe PixbufAnimation
noPixbufAnimation = Nothing

type instance AttributeList PixbufAnimation = PixbufAnimationAttributeList
type PixbufAnimationAttributeList = ('[ ] :: [(Symbol, *)])

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

-- method PixbufAnimation::new_from_file
-- method type : Constructor
-- Args : [Arg {argName = "filename", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "filename", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "GdkPixbuf" "PixbufAnimation"
-- throws : True
-- Skip return : False

foreign import ccall "gdk_pixbuf_animation_new_from_file" gdk_pixbuf_animation_new_from_file :: 
    CString ->                              -- filename : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr PixbufAnimation)


pixbufAnimationNewFromFile ::
    (MonadIO m) =>
    T.Text ->                               -- filename
    m PixbufAnimation
pixbufAnimationNewFromFile filename = liftIO $ do
    filename' <- textToCString filename
    onException (do
        result <- propagateGError $ gdk_pixbuf_animation_new_from_file filename'
        checkUnexpectedReturnNULL "gdk_pixbuf_animation_new_from_file" result
        result' <- (wrapObject PixbufAnimation) result
        freeMem filename'
        return result'
     ) (do
        freeMem filename'
     )

-- method PixbufAnimation::new_from_resource
-- method type : Constructor
-- Args : [Arg {argName = "resource_path", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "resource_path", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "GdkPixbuf" "PixbufAnimation"
-- throws : True
-- Skip return : False

foreign import ccall "gdk_pixbuf_animation_new_from_resource" gdk_pixbuf_animation_new_from_resource :: 
    CString ->                              -- resource_path : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr PixbufAnimation)


pixbufAnimationNewFromResource ::
    (MonadIO m) =>
    T.Text ->                               -- resource_path
    m PixbufAnimation
pixbufAnimationNewFromResource resource_path = liftIO $ do
    resource_path' <- textToCString resource_path
    onException (do
        result <- propagateGError $ gdk_pixbuf_animation_new_from_resource resource_path'
        checkUnexpectedReturnNULL "gdk_pixbuf_animation_new_from_resource" result
        result' <- (wrapObject PixbufAnimation) result
        freeMem resource_path'
        return result'
     ) (do
        freeMem resource_path'
     )

-- method PixbufAnimation::new_from_stream
-- method type : Constructor
-- Args : [Arg {argName = "stream", argType = TInterface "Gio" "InputStream", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "stream", argType = TInterface "Gio" "InputStream", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "GdkPixbuf" "PixbufAnimation"
-- throws : True
-- Skip return : False

foreign import ccall "gdk_pixbuf_animation_new_from_stream" gdk_pixbuf_animation_new_from_stream :: 
    Ptr Gio.InputStream ->                  -- stream : TInterface "Gio" "InputStream"
    Ptr Gio.Cancellable ->                  -- cancellable : TInterface "Gio" "Cancellable"
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr PixbufAnimation)


pixbufAnimationNewFromStream ::
    (MonadIO m, Gio.InputStreamK a, Gio.CancellableK b) =>
    a ->                                    -- stream
    Maybe (b) ->                            -- cancellable
    m PixbufAnimation
pixbufAnimationNewFromStream stream cancellable = liftIO $ do
    let stream' = unsafeManagedPtrCastPtr stream
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ gdk_pixbuf_animation_new_from_stream stream' maybeCancellable
        checkUnexpectedReturnNULL "gdk_pixbuf_animation_new_from_stream" result
        result' <- (wrapObject PixbufAnimation) result
        touchManagedPtr stream
        whenJust cancellable touchManagedPtr
        return result'
     ) (do
        return ()
     )

-- method PixbufAnimation::new_from_stream_finish
-- method type : Constructor
-- Args : [Arg {argName = "async_result", argType = TInterface "Gio" "AsyncResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "async_result", argType = TInterface "Gio" "AsyncResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "GdkPixbuf" "PixbufAnimation"
-- throws : True
-- Skip return : False

foreign import ccall "gdk_pixbuf_animation_new_from_stream_finish" gdk_pixbuf_animation_new_from_stream_finish :: 
    Ptr Gio.AsyncResult ->                  -- async_result : TInterface "Gio" "AsyncResult"
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr PixbufAnimation)


pixbufAnimationNewFromStreamFinish ::
    (MonadIO m, Gio.AsyncResultK a) =>
    a ->                                    -- async_result
    m PixbufAnimation
pixbufAnimationNewFromStreamFinish async_result = liftIO $ do
    let async_result' = unsafeManagedPtrCastPtr async_result
    onException (do
        result <- propagateGError $ gdk_pixbuf_animation_new_from_stream_finish async_result'
        checkUnexpectedReturnNULL "gdk_pixbuf_animation_new_from_stream_finish" result
        result' <- (wrapObject PixbufAnimation) result
        touchManagedPtr async_result
        return result'
     ) (do
        return ()
     )

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

foreign import ccall "gdk_pixbuf_animation_get_height" gdk_pixbuf_animation_get_height :: 
    Ptr PixbufAnimation ->                  -- _obj : TInterface "GdkPixbuf" "PixbufAnimation"
    IO Int32


pixbufAnimationGetHeight ::
    (MonadIO m, PixbufAnimationK a) =>
    a ->                                    -- _obj
    m Int32
pixbufAnimationGetHeight _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_pixbuf_animation_get_height _obj'
    touchManagedPtr _obj
    return result

-- method PixbufAnimation::get_iter
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GdkPixbuf" "PixbufAnimation", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "start_time", argType = TInterface "GLib" "TimeVal", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GdkPixbuf" "PixbufAnimation", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "start_time", argType = TInterface "GLib" "TimeVal", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "GdkPixbuf" "PixbufAnimationIter"
-- throws : False
-- Skip return : False

foreign import ccall "gdk_pixbuf_animation_get_iter" gdk_pixbuf_animation_get_iter :: 
    Ptr PixbufAnimation ->                  -- _obj : TInterface "GdkPixbuf" "PixbufAnimation"
    Ptr GLib.TimeVal ->                     -- start_time : TInterface "GLib" "TimeVal"
    IO (Ptr PixbufAnimationIter)


pixbufAnimationGetIter ::
    (MonadIO m, PixbufAnimationK a) =>
    a ->                                    -- _obj
    Maybe (GLib.TimeVal) ->                 -- start_time
    m PixbufAnimationIter
pixbufAnimationGetIter _obj start_time = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    maybeStart_time <- case start_time of
        Nothing -> return nullPtr
        Just jStart_time -> do
            let jStart_time' = unsafeManagedPtrGetPtr jStart_time
            return jStart_time'
    result <- gdk_pixbuf_animation_get_iter _obj' maybeStart_time
    checkUnexpectedReturnNULL "gdk_pixbuf_animation_get_iter" result
    result' <- (wrapObject PixbufAnimationIter) result
    touchManagedPtr _obj
    whenJust start_time touchManagedPtr
    return result'

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

foreign import ccall "gdk_pixbuf_animation_get_static_image" gdk_pixbuf_animation_get_static_image :: 
    Ptr PixbufAnimation ->                  -- _obj : TInterface "GdkPixbuf" "PixbufAnimation"
    IO (Ptr Pixbuf)


pixbufAnimationGetStaticImage ::
    (MonadIO m, PixbufAnimationK a) =>
    a ->                                    -- _obj
    m Pixbuf
pixbufAnimationGetStaticImage _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_pixbuf_animation_get_static_image _obj'
    checkUnexpectedReturnNULL "gdk_pixbuf_animation_get_static_image" result
    result' <- (newObject Pixbuf) result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "gdk_pixbuf_animation_get_width" gdk_pixbuf_animation_get_width :: 
    Ptr PixbufAnimation ->                  -- _obj : TInterface "GdkPixbuf" "PixbufAnimation"
    IO Int32


pixbufAnimationGetWidth ::
    (MonadIO m, PixbufAnimationK a) =>
    a ->                                    -- _obj
    m Int32
pixbufAnimationGetWidth _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gdk_pixbuf_animation_get_width _obj'
    touchManagedPtr _obj
    return result

-- method PixbufAnimation::is_static_image
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GdkPixbuf" "PixbufAnimation", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GdkPixbuf" "PixbufAnimation", 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_animation_is_static_image" gdk_pixbuf_animation_is_static_image :: 
    Ptr PixbufAnimation ->                  -- _obj : TInterface "GdkPixbuf" "PixbufAnimation"
    IO CInt


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

-- method PixbufAnimation::new_from_stream_async
-- method type : MemberFunction
-- Args : [Arg {argName = "stream", argType = TInterface "Gio" "InputStream", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "callback", argType = TInterface "Gio" "AsyncReadyCallback", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeAsync, argClosure = 3, argDestroy = -1, transfer = TransferNothing},Arg {argName = "user_data", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "stream", argType = TInterface "Gio" "InputStream", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "callback", argType = TInterface "Gio" "AsyncReadyCallback", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeAsync, argClosure = 3, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "gdk_pixbuf_animation_new_from_stream_async" gdk_pixbuf_animation_new_from_stream_async :: 
    Ptr Gio.InputStream ->                  -- stream : TInterface "Gio" "InputStream"
    Ptr Gio.Cancellable ->                  -- cancellable : TInterface "Gio" "Cancellable"
    FunPtr Gio.AsyncReadyCallbackC ->       -- callback : TInterface "Gio" "AsyncReadyCallback"
    Ptr () ->                               -- user_data : TBasicType TVoid
    IO ()


pixbufAnimationNewFromStreamAsync ::
    (MonadIO m, Gio.InputStreamK a, Gio.CancellableK b) =>
    a ->                                    -- stream
    Maybe (b) ->                            -- cancellable
    Maybe (Gio.AsyncReadyCallback) ->       -- callback
    m ()
pixbufAnimationNewFromStreamAsync stream cancellable callback = liftIO $ do
    let stream' = unsafeManagedPtrCastPtr stream
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.AsyncReadyCallbackC))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.mkAsyncReadyCallback (Gio.asyncReadyCallbackWrapper (Just ptrcallback) jCallback)
            poke ptrcallback jCallback'
            return jCallback'
    let user_data = nullPtr
    gdk_pixbuf_animation_new_from_stream_async stream' maybeCancellable maybeCallback user_data
    touchManagedPtr stream
    whenJust cancellable touchManagedPtr
    return ()