{- | 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.Gio.Interfaces.LoadableIcon ( -- * Exported types LoadableIcon(..) , noLoadableIcon , LoadableIconK , toLoadableIcon , -- * Methods -- ** loadableIconLoad loadableIconLoad , -- ** loadableIconLoadAsync loadableIconLoadAsync , -- ** loadableIconLoadFinish loadableIconLoadFinish , ) 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.Gio.Types import GI.Gio.Callbacks import qualified GI.GObject as GObject -- interface LoadableIcon newtype LoadableIcon = LoadableIcon (ForeignPtr LoadableIcon) noLoadableIcon :: Maybe LoadableIcon noLoadableIcon = Nothing type instance AttributeList LoadableIcon = LoadableIconAttributeList type LoadableIconAttributeList = ('[ ] :: [(Symbol, *)]) type instance SignalList LoadableIcon = LoadableIconSignalList type LoadableIconSignalList = ('[ '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)]) foreign import ccall "g_loadable_icon_get_type" c_g_loadable_icon_get_type :: IO GType type instance ParentTypes LoadableIcon = LoadableIconParentTypes type LoadableIconParentTypes = '[Icon, GObject.Object] instance GObject LoadableIcon where gobjectIsInitiallyUnowned _ = False gobjectType _ = c_g_loadable_icon_get_type class GObject o => LoadableIconK o instance (GObject o, IsDescendantOf LoadableIcon o) => LoadableIconK o toLoadableIcon :: LoadableIconK o => o -> IO LoadableIcon toLoadableIcon = unsafeCastTo LoadableIcon -- method LoadableIcon::load -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "LoadableIcon", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "size", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "type", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "LoadableIcon", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "size", argType = TBasicType TInt32, 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 "Gio" "InputStream" -- throws : True -- Skip return : False foreign import ccall "g_loadable_icon_load" g_loadable_icon_load :: Ptr LoadableIcon -> -- _obj : TInterface "Gio" "LoadableIcon" Int32 -> -- size : TBasicType TInt32 Ptr CString -> -- type : TBasicType TUTF8 Ptr Cancellable -> -- cancellable : TInterface "Gio" "Cancellable" Ptr (Ptr GError) -> -- error IO (Ptr InputStream) loadableIconLoad :: (MonadIO m, LoadableIconK a, CancellableK b) => a -> -- _obj Int32 -> -- size Maybe (b) -> -- cancellable m (InputStream,T.Text) loadableIconLoad _obj size cancellable = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj type_ <- allocMem :: IO (Ptr CString) maybeCancellable <- case cancellable of Nothing -> return nullPtr Just jCancellable -> do let jCancellable' = unsafeManagedPtrCastPtr jCancellable return jCancellable' onException (do result <- propagateGError $ g_loadable_icon_load _obj' size type_ maybeCancellable checkUnexpectedReturnNULL "g_loadable_icon_load" result result' <- (wrapObject InputStream) result type_' <- peek type_ type_'' <- cstringToText type_' freeMem type_' touchManagedPtr _obj whenJust cancellable touchManagedPtr freeMem type_ return (result', type_'') ) (do freeMem type_ ) -- method LoadableIcon::load_async -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "LoadableIcon", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "size", argType = TBasicType TInt32, 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 = 4, 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 = "_obj", argType = TInterface "Gio" "LoadableIcon", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "size", argType = TBasicType TInt32, 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 = 4, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TVoid -- throws : False -- Skip return : False foreign import ccall "g_loadable_icon_load_async" g_loadable_icon_load_async :: Ptr LoadableIcon -> -- _obj : TInterface "Gio" "LoadableIcon" Int32 -> -- size : TBasicType TInt32 Ptr Cancellable -> -- cancellable : TInterface "Gio" "Cancellable" FunPtr AsyncReadyCallbackC -> -- callback : TInterface "Gio" "AsyncReadyCallback" Ptr () -> -- user_data : TBasicType TVoid IO () loadableIconLoadAsync :: (MonadIO m, LoadableIconK a, CancellableK b) => a -> -- _obj Int32 -> -- size Maybe (b) -> -- cancellable Maybe (AsyncReadyCallback) -> -- callback m () loadableIconLoadAsync _obj size cancellable callback = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj maybeCancellable <- case cancellable of Nothing -> return nullPtr Just jCancellable -> do let jCancellable' = unsafeManagedPtrCastPtr jCancellable return jCancellable' ptrcallback <- callocMem :: IO (Ptr (FunPtr AsyncReadyCallbackC)) maybeCallback <- case callback of Nothing -> return (castPtrToFunPtr nullPtr) Just jCallback -> do jCallback' <- mkAsyncReadyCallback (asyncReadyCallbackWrapper (Just ptrcallback) jCallback) poke ptrcallback jCallback' return jCallback' let user_data = nullPtr g_loadable_icon_load_async _obj' size maybeCancellable maybeCallback user_data touchManagedPtr _obj whenJust cancellable touchManagedPtr return () -- method LoadableIcon::load_finish -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "LoadableIcon", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "res", argType = TInterface "Gio" "AsyncResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "type", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "LoadableIcon", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "res", argType = TInterface "Gio" "AsyncResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TInterface "Gio" "InputStream" -- throws : True -- Skip return : False foreign import ccall "g_loadable_icon_load_finish" g_loadable_icon_load_finish :: Ptr LoadableIcon -> -- _obj : TInterface "Gio" "LoadableIcon" Ptr AsyncResult -> -- res : TInterface "Gio" "AsyncResult" Ptr CString -> -- type : TBasicType TUTF8 Ptr (Ptr GError) -> -- error IO (Ptr InputStream) loadableIconLoadFinish :: (MonadIO m, LoadableIconK a, AsyncResultK b) => a -> -- _obj b -> -- res m (InputStream,T.Text) loadableIconLoadFinish _obj res = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj let res' = unsafeManagedPtrCastPtr res type_ <- allocMem :: IO (Ptr CString) onException (do result <- propagateGError $ g_loadable_icon_load_finish _obj' res' type_ checkUnexpectedReturnNULL "g_loadable_icon_load_finish" result result' <- (wrapObject InputStream) result type_' <- peek type_ type_'' <- cstringToText type_' freeMem type_' touchManagedPtr _obj touchManagedPtr res freeMem type_ return (result', type_'') ) (do freeMem type_ )