{- |
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.DOMVideoTrackList
    ( 

-- * Exported types
    DOMVideoTrackList(..)                   ,
    DOMVideoTrackListK                      ,
    toDOMVideoTrackList                     ,
    noDOMVideoTrackList                     ,


 -- * Methods
-- ** dOMVideoTrackListDispatchEvent
    dOMVideoTrackListDispatchEvent          ,


-- ** dOMVideoTrackListGetLength
    dOMVideoTrackListGetLength              ,


-- ** dOMVideoTrackListGetTrackById
    dOMVideoTrackListGetTrackById           ,


-- ** dOMVideoTrackListItem
    dOMVideoTrackListItem                   ,




 -- * Properties
-- ** Length
    DOMVideoTrackListLengthPropertyInfo     ,
    getDOMVideoTrackListLength              ,




    ) 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 DOMVideoTrackList = DOMVideoTrackList (ForeignPtr DOMVideoTrackList)
foreign import ccall "webkit_dom_video_track_list_get_type"
    c_webkit_dom_video_track_list_get_type :: IO GType

type instance ParentTypes DOMVideoTrackList = DOMVideoTrackListParentTypes
type DOMVideoTrackListParentTypes = '[DOMObject, GObject.Object, DOMEventTarget]

instance GObject DOMVideoTrackList where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_webkit_dom_video_track_list_get_type
    

class GObject o => DOMVideoTrackListK o
instance (GObject o, IsDescendantOf DOMVideoTrackList o) => DOMVideoTrackListK o

toDOMVideoTrackList :: DOMVideoTrackListK o => o -> IO DOMVideoTrackList
toDOMVideoTrackList = unsafeCastTo DOMVideoTrackList

noDOMVideoTrackList :: Maybe DOMVideoTrackList
noDOMVideoTrackList = Nothing

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

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

data DOMVideoTrackListLengthPropertyInfo
instance AttrInfo DOMVideoTrackListLengthPropertyInfo where
    type AttrAllowedOps DOMVideoTrackListLengthPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DOMVideoTrackListLengthPropertyInfo = (~) ()
    type AttrBaseTypeConstraint DOMVideoTrackListLengthPropertyInfo = DOMVideoTrackListK
    type AttrGetType DOMVideoTrackListLengthPropertyInfo = Word64
    type AttrLabel DOMVideoTrackListLengthPropertyInfo = "DOMVideoTrackList::length"
    attrGet _ = getDOMVideoTrackListLength
    attrSet _ = undefined
    attrConstruct _ = undefined

type instance AttributeList DOMVideoTrackList = DOMVideoTrackListAttributeList
type DOMVideoTrackListAttributeList = ('[ '("core-object", DOMObjectCoreObjectPropertyInfo), '("length", DOMVideoTrackListLengthPropertyInfo)] :: [(Symbol, *)])

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

-- method DOMVideoTrackList::dispatch_event
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMVideoTrackList", 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" "DOMVideoTrackList", 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_video_track_list_dispatch_event" webkit_dom_video_track_list_dispatch_event :: 
    Ptr DOMVideoTrackList ->                -- _obj : TInterface "WebKit" "DOMVideoTrackList"
    Ptr DOMEvent ->                         -- evt : TInterface "WebKit" "DOMEvent"
    Ptr (Ptr GError) ->                     -- error
    IO CInt

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

-- method DOMVideoTrackList::get_length
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMVideoTrackList", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMVideoTrackList", 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_video_track_list_get_length" webkit_dom_video_track_list_get_length :: 
    Ptr DOMVideoTrackList ->                -- _obj : TInterface "WebKit" "DOMVideoTrackList"
    IO Word64


dOMVideoTrackListGetLength ::
    (MonadIO m, DOMVideoTrackListK a) =>
    a ->                                    -- _obj
    m Word64
dOMVideoTrackListGetLength _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_dom_video_track_list_get_length _obj'
    touchManagedPtr _obj
    return result

-- method DOMVideoTrackList::get_track_by_id
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMVideoTrackList", 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" "DOMVideoTrackList", 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" "DOMVideoTrack"
-- throws : False
-- Skip return : False

foreign import ccall "webkit_dom_video_track_list_get_track_by_id" webkit_dom_video_track_list_get_track_by_id :: 
    Ptr DOMVideoTrackList ->                -- _obj : TInterface "WebKit" "DOMVideoTrackList"
    CString ->                              -- id : TBasicType TUTF8
    IO (Ptr DOMVideoTrack)


dOMVideoTrackListGetTrackById ::
    (MonadIO m, DOMVideoTrackListK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- id
    m DOMVideoTrack
dOMVideoTrackListGetTrackById _obj id = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    id' <- textToCString id
    result <- webkit_dom_video_track_list_get_track_by_id _obj' id'
    checkUnexpectedReturnNULL "webkit_dom_video_track_list_get_track_by_id" result
    result' <- (wrapObject DOMVideoTrack) result
    touchManagedPtr _obj
    freeMem id'
    return result'

-- method DOMVideoTrackList::item
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMVideoTrackList", 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" "DOMVideoTrackList", 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" "DOMVideoTrack"
-- throws : False
-- Skip return : False

foreign import ccall "webkit_dom_video_track_list_item" webkit_dom_video_track_list_item :: 
    Ptr DOMVideoTrackList ->                -- _obj : TInterface "WebKit" "DOMVideoTrackList"
    Word64 ->                               -- index : TBasicType TUInt64
    IO (Ptr DOMVideoTrack)


dOMVideoTrackListItem ::
    (MonadIO m, DOMVideoTrackListK a) =>
    a ->                                    -- _obj
    Word64 ->                               -- index
    m DOMVideoTrack
dOMVideoTrackListItem _obj index = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_dom_video_track_list_item _obj' index
    checkUnexpectedReturnNULL "webkit_dom_video_track_list_item" result
    result' <- (wrapObject DOMVideoTrack) result
    touchManagedPtr _obj
    return result'