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

-- * Exported types
    DOMTextTrackList(..)                    ,
    DOMTextTrackListK                       ,
    toDOMTextTrackList                      ,
    noDOMTextTrackList                      ,


 -- * Methods
-- ** dOMTextTrackListDispatchEvent
    dOMTextTrackListDispatchEvent           ,


-- ** dOMTextTrackListGetLength
    dOMTextTrackListGetLength               ,


-- ** dOMTextTrackListGetTrackById
    dOMTextTrackListGetTrackById            ,


-- ** dOMTextTrackListItem
    dOMTextTrackListItem                    ,




 -- * Properties
-- ** Length
    DOMTextTrackListLengthPropertyInfo      ,
    getDOMTextTrackListLength               ,




    ) 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 DOMTextTrackList = DOMTextTrackList (ForeignPtr DOMTextTrackList)
foreign import ccall "webkit_dom_text_track_list_get_type"
    c_webkit_dom_text_track_list_get_type :: IO GType

type instance ParentTypes DOMTextTrackList = DOMTextTrackListParentTypes
type DOMTextTrackListParentTypes = '[DOMObject, GObject.Object, DOMEventTarget]

instance GObject DOMTextTrackList where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_webkit_dom_text_track_list_get_type
    

class GObject o => DOMTextTrackListK o
instance (GObject o, IsDescendantOf DOMTextTrackList o) => DOMTextTrackListK o

toDOMTextTrackList :: DOMTextTrackListK o => o -> IO DOMTextTrackList
toDOMTextTrackList = unsafeCastTo DOMTextTrackList

noDOMTextTrackList :: Maybe DOMTextTrackList
noDOMTextTrackList = Nothing

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

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

data DOMTextTrackListLengthPropertyInfo
instance AttrInfo DOMTextTrackListLengthPropertyInfo where
    type AttrAllowedOps DOMTextTrackListLengthPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DOMTextTrackListLengthPropertyInfo = (~) ()
    type AttrBaseTypeConstraint DOMTextTrackListLengthPropertyInfo = DOMTextTrackListK
    type AttrGetType DOMTextTrackListLengthPropertyInfo = Word64
    type AttrLabel DOMTextTrackListLengthPropertyInfo = "DOMTextTrackList::length"
    attrGet _ = getDOMTextTrackListLength
    attrSet _ = undefined
    attrConstruct _ = undefined

type instance AttributeList DOMTextTrackList = DOMTextTrackListAttributeList
type DOMTextTrackListAttributeList = ('[ '("core-object", DOMObjectCoreObjectPropertyInfo), '("length", DOMTextTrackListLengthPropertyInfo)] :: [(Symbol, *)])

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

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

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

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


dOMTextTrackListGetLength ::
    (MonadIO m, DOMTextTrackListK a) =>
    a ->                                    -- _obj
    m Word64
dOMTextTrackListGetLength _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_dom_text_track_list_get_length _obj'
    touchManagedPtr _obj
    return result

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

foreign import ccall "webkit_dom_text_track_list_get_track_by_id" webkit_dom_text_track_list_get_track_by_id :: 
    Ptr DOMTextTrackList ->                 -- _obj : TInterface "WebKit" "DOMTextTrackList"
    CString ->                              -- id : TBasicType TUTF8
    IO (Ptr DOMTextTrack)


dOMTextTrackListGetTrackById ::
    (MonadIO m, DOMTextTrackListK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- id
    m DOMTextTrack
dOMTextTrackListGetTrackById _obj id = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    id' <- textToCString id
    result <- webkit_dom_text_track_list_get_track_by_id _obj' id'
    checkUnexpectedReturnNULL "webkit_dom_text_track_list_get_track_by_id" result
    result' <- (wrapObject DOMTextTrack) result
    touchManagedPtr _obj
    freeMem id'
    return result'

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

foreign import ccall "webkit_dom_text_track_list_item" webkit_dom_text_track_list_item :: 
    Ptr DOMTextTrackList ->                 -- _obj : TInterface "WebKit" "DOMTextTrackList"
    Word64 ->                               -- index : TBasicType TUInt64
    IO (Ptr DOMTextTrack)


dOMTextTrackListItem ::
    (MonadIO m, DOMTextTrackListK a) =>
    a ->                                    -- _obj
    Word64 ->                               -- index
    m DOMTextTrack
dOMTextTrackListItem _obj index = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_dom_text_track_list_item _obj' index
    checkUnexpectedReturnNULL "webkit_dom_text_track_list_item" result
    result' <- (wrapObject DOMTextTrack) result
    touchManagedPtr _obj
    return result'