{- |
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.WebKit.Objects.DOMAudioTrackList
    ( 

-- * Exported types
    DOMAudioTrackList(..)                   ,
    DOMAudioTrackListK                      ,
    toDOMAudioTrackList                     ,
    noDOMAudioTrackList                     ,


 -- * Methods
-- ** dOMAudioTrackListDispatchEvent
    dOMAudioTrackListDispatchEvent          ,


-- ** dOMAudioTrackListGetLength
    dOMAudioTrackListGetLength              ,


-- ** dOMAudioTrackListGetTrackById
    dOMAudioTrackListGetTrackById           ,


-- ** dOMAudioTrackListItem
    dOMAudioTrackListItem                   ,




 -- * Properties
-- ** Length
    DOMAudioTrackListLengthPropertyInfo     ,
    getDOMAudioTrackListLength              ,




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

newtype DOMAudioTrackList = DOMAudioTrackList (ForeignPtr DOMAudioTrackList)
foreign import ccall "webkit_dom_audio_track_list_get_type"
    c_webkit_dom_audio_track_list_get_type :: IO GType

type instance ParentTypes DOMAudioTrackList = DOMAudioTrackListParentTypes
type DOMAudioTrackListParentTypes = '[DOMObject, GObject.Object, DOMEventTarget]

instance GObject DOMAudioTrackList where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_webkit_dom_audio_track_list_get_type
    

class GObject o => DOMAudioTrackListK o
instance (GObject o, IsDescendantOf DOMAudioTrackList o) => DOMAudioTrackListK o

toDOMAudioTrackList :: DOMAudioTrackListK o => o -> IO DOMAudioTrackList
toDOMAudioTrackList = unsafeCastTo DOMAudioTrackList

noDOMAudioTrackList :: Maybe DOMAudioTrackList
noDOMAudioTrackList = Nothing

-- VVV Prop "length"
   -- Type: TBasicType TUInt64
   -- Flags: [PropertyReadable]

getDOMAudioTrackListLength :: (MonadIO m, DOMAudioTrackListK o) => o -> m Word64
getDOMAudioTrackListLength obj = liftIO $ getObjectPropertyUInt64 obj "length"

data DOMAudioTrackListLengthPropertyInfo
instance AttrInfo DOMAudioTrackListLengthPropertyInfo where
    type AttrAllowedOps DOMAudioTrackListLengthPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DOMAudioTrackListLengthPropertyInfo = (~) ()
    type AttrBaseTypeConstraint DOMAudioTrackListLengthPropertyInfo = DOMAudioTrackListK
    type AttrGetType DOMAudioTrackListLengthPropertyInfo = Word64
    type AttrLabel DOMAudioTrackListLengthPropertyInfo = "DOMAudioTrackList::length"
    attrGet _ = getDOMAudioTrackListLength
    attrSet _ = undefined
    attrConstruct _ = undefined

type instance AttributeList DOMAudioTrackList = DOMAudioTrackListAttributeList
type DOMAudioTrackListAttributeList = ('[ '("core-object", DOMObjectCoreObjectPropertyInfo), '("length", DOMAudioTrackListLengthPropertyInfo)] :: [(Symbol, *)])

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

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

foreign import ccall "webkit_dom_audio_track_list_dispatch_event" webkit_dom_audio_track_list_dispatch_event :: 
    Ptr DOMAudioTrackList ->                -- _obj : TInterface "WebKit" "DOMAudioTrackList"
    Ptr DOMEvent ->                         -- evt : TInterface "WebKit" "DOMEvent"
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{-# DEPRECATED dOMAudioTrackListDispatchEvent ["(Since version 2.4)","Use webkit_dom_event_target_dispatch_event() instead."]#-}
dOMAudioTrackListDispatchEvent ::
    (MonadIO m, DOMAudioTrackListK a, DOMEventK b) =>
    a ->                                    -- _obj
    b ->                                    -- evt
    m ()
dOMAudioTrackListDispatchEvent _obj evt = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let evt' = unsafeManagedPtrCastPtr evt
    onException (do
        _ <- propagateGError $ webkit_dom_audio_track_list_dispatch_event _obj' evt'
        touchManagedPtr _obj
        touchManagedPtr evt
        return ()
     ) (do
        return ()
     )

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

foreign import ccall "webkit_dom_audio_track_list_get_length" webkit_dom_audio_track_list_get_length :: 
    Ptr DOMAudioTrackList ->                -- _obj : TInterface "WebKit" "DOMAudioTrackList"
    IO Word64


dOMAudioTrackListGetLength ::
    (MonadIO m, DOMAudioTrackListK a) =>
    a ->                                    -- _obj
    m Word64
dOMAudioTrackListGetLength _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_dom_audio_track_list_get_length _obj'
    touchManagedPtr _obj
    return result

-- method DOMAudioTrackList::get_track_by_id
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMAudioTrackList", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "id", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMAudioTrackList", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "id", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "WebKit" "DOMAudioTrack"
-- throws : False
-- Skip return : False

foreign import ccall "webkit_dom_audio_track_list_get_track_by_id" webkit_dom_audio_track_list_get_track_by_id :: 
    Ptr DOMAudioTrackList ->                -- _obj : TInterface "WebKit" "DOMAudioTrackList"
    CString ->                              -- id : TBasicType TUTF8
    IO (Ptr DOMAudioTrack)


dOMAudioTrackListGetTrackById ::
    (MonadIO m, DOMAudioTrackListK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- id
    m DOMAudioTrack
dOMAudioTrackListGetTrackById _obj id = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    id' <- textToCString id
    result <- webkit_dom_audio_track_list_get_track_by_id _obj' id'
    checkUnexpectedReturnNULL "webkit_dom_audio_track_list_get_track_by_id" result
    result' <- (wrapObject DOMAudioTrack) result
    touchManagedPtr _obj
    freeMem id'
    return result'

-- method DOMAudioTrackList::item
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMAudioTrackList", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "index", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMAudioTrackList", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "index", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "WebKit" "DOMAudioTrack"
-- throws : False
-- Skip return : False

foreign import ccall "webkit_dom_audio_track_list_item" webkit_dom_audio_track_list_item :: 
    Ptr DOMAudioTrackList ->                -- _obj : TInterface "WebKit" "DOMAudioTrackList"
    Word64 ->                               -- index : TBasicType TUInt64
    IO (Ptr DOMAudioTrack)


dOMAudioTrackListItem ::
    (MonadIO m, DOMAudioTrackListK a) =>
    a ->                                    -- _obj
    Word64 ->                               -- index
    m DOMAudioTrack
dOMAudioTrackListItem _obj index = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_dom_audio_track_list_item _obj' index
    checkUnexpectedReturnNULL "webkit_dom_audio_track_list_item" result
    result' <- (wrapObject DOMAudioTrack) result
    touchManagedPtr _obj
    return result'