{- |
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.WebKit2WebExtension.Objects.DOMMediaList
    ( 

-- * Exported types
    DOMMediaList(..)                        ,
    IsDOMMediaList                          ,
    toDOMMediaList                          ,
    noDOMMediaList                          ,


 -- * Methods
-- ** appendMedium #method:appendMedium#
    DOMMediaListAppendMediumMethodInfo      ,
    dOMMediaListAppendMedium                ,


-- ** deleteMedium #method:deleteMedium#
    DOMMediaListDeleteMediumMethodInfo      ,
    dOMMediaListDeleteMedium                ,


-- ** getLength #method:getLength#
    DOMMediaListGetLengthMethodInfo         ,
    dOMMediaListGetLength                   ,


-- ** getMediaText #method:getMediaText#
    DOMMediaListGetMediaTextMethodInfo      ,
    dOMMediaListGetMediaText                ,


-- ** item #method:item#
    DOMMediaListItemMethodInfo              ,
    dOMMediaListItem                        ,


-- ** setMediaText #method:setMediaText#
    DOMMediaListSetMediaTextMethodInfo      ,
    dOMMediaListSetMediaText                ,




 -- * Properties
-- ** length #attr:length#
    DOMMediaListLengthPropertyInfo          ,
    dOMMediaListLength                      ,
    getDOMMediaListLength                   ,


-- ** mediaText #attr:mediaText#
    DOMMediaListMediaTextPropertyInfo       ,
    clearDOMMediaListMediaText              ,
    constructDOMMediaListMediaText          ,
    dOMMediaListMediaText                   ,
    getDOMMediaListMediaText                ,
    setDOMMediaListMediaText                ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.WebKit2WebExtension.Objects.DOMObject as WebKit2WebExtension.DOMObject

newtype DOMMediaList = DOMMediaList (ManagedPtr DOMMediaList)
foreign import ccall "webkit_dom_media_list_get_type"
    c_webkit_dom_media_list_get_type :: IO GType

instance GObject DOMMediaList where
    gobjectType _ = c_webkit_dom_media_list_get_type
    

class GObject o => IsDOMMediaList o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError DOMMediaList a) =>
    IsDOMMediaList a
#endif
instance IsDOMMediaList DOMMediaList
instance WebKit2WebExtension.DOMObject.IsDOMObject DOMMediaList
instance GObject.Object.IsObject DOMMediaList

toDOMMediaList :: IsDOMMediaList o => o -> IO DOMMediaList
toDOMMediaList = unsafeCastTo DOMMediaList

noDOMMediaList :: Maybe DOMMediaList
noDOMMediaList = Nothing

type family ResolveDOMMediaListMethod (t :: Symbol) (o :: *) :: * where
    ResolveDOMMediaListMethod "appendMedium" o = DOMMediaListAppendMediumMethodInfo
    ResolveDOMMediaListMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveDOMMediaListMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveDOMMediaListMethod "deleteMedium" o = DOMMediaListDeleteMediumMethodInfo
    ResolveDOMMediaListMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveDOMMediaListMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveDOMMediaListMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveDOMMediaListMethod "item" o = DOMMediaListItemMethodInfo
    ResolveDOMMediaListMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveDOMMediaListMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveDOMMediaListMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveDOMMediaListMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveDOMMediaListMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveDOMMediaListMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveDOMMediaListMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveDOMMediaListMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveDOMMediaListMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveDOMMediaListMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveDOMMediaListMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveDOMMediaListMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveDOMMediaListMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveDOMMediaListMethod "getLength" o = DOMMediaListGetLengthMethodInfo
    ResolveDOMMediaListMethod "getMediaText" o = DOMMediaListGetMediaTextMethodInfo
    ResolveDOMMediaListMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveDOMMediaListMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveDOMMediaListMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveDOMMediaListMethod "setMediaText" o = DOMMediaListSetMediaTextMethodInfo
    ResolveDOMMediaListMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveDOMMediaListMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveDOMMediaListMethod t DOMMediaList, O.MethodInfo info DOMMediaList p) => O.IsLabelProxy t (DOMMediaList -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveDOMMediaListMethod t DOMMediaList, O.MethodInfo info DOMMediaList p) => O.IsLabel t (DOMMediaList -> p) where
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

-- VVV Prop "length"
   -- Type: TBasicType TULong
   -- Flags: [PropertyReadable]
   -- Nullable: (Just False,Nothing)

getDOMMediaListLength :: (MonadIO m, IsDOMMediaList o) => o -> m CULong
getDOMMediaListLength obj = liftIO $ getObjectPropertyULong obj "length"

data DOMMediaListLengthPropertyInfo
instance AttrInfo DOMMediaListLengthPropertyInfo where
    type AttrAllowedOps DOMMediaListLengthPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DOMMediaListLengthPropertyInfo = (~) ()
    type AttrBaseTypeConstraint DOMMediaListLengthPropertyInfo = IsDOMMediaList
    type AttrGetType DOMMediaListLengthPropertyInfo = CULong
    type AttrLabel DOMMediaListLengthPropertyInfo = "length"
    type AttrOrigin DOMMediaListLengthPropertyInfo = DOMMediaList
    attrGet _ = getDOMMediaListLength
    attrSet _ = undefined
    attrConstruct _ = undefined
    attrClear _ = undefined

-- VVV Prop "media-text"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable]
   -- Nullable: (Nothing,Nothing)

getDOMMediaListMediaText :: (MonadIO m, IsDOMMediaList o) => o -> m (Maybe T.Text)
getDOMMediaListMediaText obj = liftIO $ getObjectPropertyString obj "media-text"

setDOMMediaListMediaText :: (MonadIO m, IsDOMMediaList o) => o -> T.Text -> m ()
setDOMMediaListMediaText obj val = liftIO $ setObjectPropertyString obj "media-text" (Just val)

constructDOMMediaListMediaText :: (IsDOMMediaList o) => T.Text -> IO (GValueConstruct o)
constructDOMMediaListMediaText val = constructObjectPropertyString "media-text" (Just val)

clearDOMMediaListMediaText :: (MonadIO m, IsDOMMediaList o) => o -> m ()
clearDOMMediaListMediaText obj = liftIO $ setObjectPropertyString obj "media-text" (Nothing :: Maybe T.Text)

data DOMMediaListMediaTextPropertyInfo
instance AttrInfo DOMMediaListMediaTextPropertyInfo where
    type AttrAllowedOps DOMMediaListMediaTextPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint DOMMediaListMediaTextPropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint DOMMediaListMediaTextPropertyInfo = IsDOMMediaList
    type AttrGetType DOMMediaListMediaTextPropertyInfo = (Maybe T.Text)
    type AttrLabel DOMMediaListMediaTextPropertyInfo = "media-text"
    type AttrOrigin DOMMediaListMediaTextPropertyInfo = DOMMediaList
    attrGet _ = getDOMMediaListMediaText
    attrSet _ = setDOMMediaListMediaText
    attrConstruct _ = constructDOMMediaListMediaText
    attrClear _ = clearDOMMediaListMediaText

instance O.HasAttributeList DOMMediaList
type instance O.AttributeList DOMMediaList = DOMMediaListAttributeList
type DOMMediaListAttributeList = ('[ '("coreObject", WebKit2WebExtension.DOMObject.DOMObjectCoreObjectPropertyInfo), '("length", DOMMediaListLengthPropertyInfo), '("mediaText", DOMMediaListMediaTextPropertyInfo)] :: [(Symbol, *)])

dOMMediaListLength :: AttrLabelProxy "length"
dOMMediaListLength = AttrLabelProxy

dOMMediaListMediaText :: AttrLabelProxy "mediaText"
dOMMediaListMediaText = AttrLabelProxy

type instance O.SignalList DOMMediaList = DOMMediaListSignalList
type DOMMediaListSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method DOMMediaList::append_medium
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "WebKit2WebExtension", name = "DOMMediaList"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #WebKitDOMMediaList", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "newMedium", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #gchar", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : True
-- Skip return : False

foreign import ccall "webkit_dom_media_list_append_medium" webkit_dom_media_list_append_medium :: 
    Ptr DOMMediaList ->                     -- self : TInterface (Name {namespace = "WebKit2WebExtension", name = "DOMMediaList"})
    CString ->                              -- newMedium : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO ()

{- |
/No description available in the introspection data./
-}
dOMMediaListAppendMedium ::
    (B.CallStack.HasCallStack, MonadIO m, IsDOMMediaList a) =>
    a
    {- ^ /@self@/: A 'GI.WebKit2WebExtension.Objects.DOMMediaList.DOMMediaList' -}
    -> T.Text
    {- ^ /@newMedium@/: A @/gchar/@ -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
dOMMediaListAppendMedium self newMedium = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    newMedium' <- textToCString newMedium
    onException (do
        propagateGError $ webkit_dom_media_list_append_medium self' newMedium'
        touchManagedPtr self
        freeMem newMedium'
        return ()
     ) (do
        freeMem newMedium'
     )

data DOMMediaListAppendMediumMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m, IsDOMMediaList a) => O.MethodInfo DOMMediaListAppendMediumMethodInfo a signature where
    overloadedMethod _ = dOMMediaListAppendMedium

-- method DOMMediaList::delete_medium
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "WebKit2WebExtension", name = "DOMMediaList"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #WebKitDOMMediaList", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "oldMedium", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #gchar", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : True
-- Skip return : False

foreign import ccall "webkit_dom_media_list_delete_medium" webkit_dom_media_list_delete_medium :: 
    Ptr DOMMediaList ->                     -- self : TInterface (Name {namespace = "WebKit2WebExtension", name = "DOMMediaList"})
    CString ->                              -- oldMedium : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO ()

{- |
/No description available in the introspection data./
-}
dOMMediaListDeleteMedium ::
    (B.CallStack.HasCallStack, MonadIO m, IsDOMMediaList a) =>
    a
    {- ^ /@self@/: A 'GI.WebKit2WebExtension.Objects.DOMMediaList.DOMMediaList' -}
    -> T.Text
    {- ^ /@oldMedium@/: A @/gchar/@ -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
dOMMediaListDeleteMedium self oldMedium = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    oldMedium' <- textToCString oldMedium
    onException (do
        propagateGError $ webkit_dom_media_list_delete_medium self' oldMedium'
        touchManagedPtr self
        freeMem oldMedium'
        return ()
     ) (do
        freeMem oldMedium'
     )

data DOMMediaListDeleteMediumMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m, IsDOMMediaList a) => O.MethodInfo DOMMediaListDeleteMediumMethodInfo a signature where
    overloadedMethod _ = dOMMediaListDeleteMedium

-- method DOMMediaList::get_length
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "WebKit2WebExtension", name = "DOMMediaList"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #WebKitDOMMediaList", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TULong)
-- throws : False
-- Skip return : False

foreign import ccall "webkit_dom_media_list_get_length" webkit_dom_media_list_get_length :: 
    Ptr DOMMediaList ->                     -- self : TInterface (Name {namespace = "WebKit2WebExtension", name = "DOMMediaList"})
    IO CULong

{- |
/No description available in the introspection data./
-}
dOMMediaListGetLength ::
    (B.CallStack.HasCallStack, MonadIO m, IsDOMMediaList a) =>
    a
    {- ^ /@self@/: A 'GI.WebKit2WebExtension.Objects.DOMMediaList.DOMMediaList' -}
    -> m CULong
    {- ^ __Returns:__ A @/gulong/@ -}
dOMMediaListGetLength self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- webkit_dom_media_list_get_length self'
    touchManagedPtr self
    return result

data DOMMediaListGetLengthMethodInfo
instance (signature ~ (m CULong), MonadIO m, IsDOMMediaList a) => O.MethodInfo DOMMediaListGetLengthMethodInfo a signature where
    overloadedMethod _ = dOMMediaListGetLength

-- method DOMMediaList::get_media_text
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "WebKit2WebExtension", name = "DOMMediaList"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #WebKitDOMMediaList", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "webkit_dom_media_list_get_media_text" webkit_dom_media_list_get_media_text :: 
    Ptr DOMMediaList ->                     -- self : TInterface (Name {namespace = "WebKit2WebExtension", name = "DOMMediaList"})
    IO CString

{- |
/No description available in the introspection data./
-}
dOMMediaListGetMediaText ::
    (B.CallStack.HasCallStack, MonadIO m, IsDOMMediaList a) =>
    a
    {- ^ /@self@/: A 'GI.WebKit2WebExtension.Objects.DOMMediaList.DOMMediaList' -}
    -> m T.Text
    {- ^ __Returns:__ A @/gchar/@ -}
dOMMediaListGetMediaText self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- webkit_dom_media_list_get_media_text self'
    checkUnexpectedReturnNULL "dOMMediaListGetMediaText" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr self
    return result'

data DOMMediaListGetMediaTextMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsDOMMediaList a) => O.MethodInfo DOMMediaListGetMediaTextMethodInfo a signature where
    overloadedMethod _ = dOMMediaListGetMediaText

-- method DOMMediaList::item
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "WebKit2WebExtension", name = "DOMMediaList"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #WebKitDOMMediaList", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "index", argType = TBasicType TULong, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #gulong", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "webkit_dom_media_list_item" webkit_dom_media_list_item :: 
    Ptr DOMMediaList ->                     -- self : TInterface (Name {namespace = "WebKit2WebExtension", name = "DOMMediaList"})
    CULong ->                               -- index : TBasicType TULong
    IO CString

{- |
/No description available in the introspection data./
-}
dOMMediaListItem ::
    (B.CallStack.HasCallStack, MonadIO m, IsDOMMediaList a) =>
    a
    {- ^ /@self@/: A 'GI.WebKit2WebExtension.Objects.DOMMediaList.DOMMediaList' -}
    -> CULong
    {- ^ /@index@/: A @/gulong/@ -}
    -> m T.Text
    {- ^ __Returns:__ A @/gchar/@ -}
dOMMediaListItem self index = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- webkit_dom_media_list_item self' index
    checkUnexpectedReturnNULL "dOMMediaListItem" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr self
    return result'

data DOMMediaListItemMethodInfo
instance (signature ~ (CULong -> m T.Text), MonadIO m, IsDOMMediaList a) => O.MethodInfo DOMMediaListItemMethodInfo a signature where
    overloadedMethod _ = dOMMediaListItem

-- method DOMMediaList::set_media_text
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "WebKit2WebExtension", name = "DOMMediaList"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #WebKitDOMMediaList", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "value", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #gchar", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : True
-- Skip return : False

foreign import ccall "webkit_dom_media_list_set_media_text" webkit_dom_media_list_set_media_text :: 
    Ptr DOMMediaList ->                     -- self : TInterface (Name {namespace = "WebKit2WebExtension", name = "DOMMediaList"})
    CString ->                              -- value : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO ()

{- |
/No description available in the introspection data./
-}
dOMMediaListSetMediaText ::
    (B.CallStack.HasCallStack, MonadIO m, IsDOMMediaList a) =>
    a
    {- ^ /@self@/: A 'GI.WebKit2WebExtension.Objects.DOMMediaList.DOMMediaList' -}
    -> T.Text
    {- ^ /@value@/: A @/gchar/@ -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
dOMMediaListSetMediaText self value = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    value' <- textToCString value
    onException (do
        propagateGError $ webkit_dom_media_list_set_media_text self' value'
        touchManagedPtr self
        freeMem value'
        return ()
     ) (do
        freeMem value'
     )

data DOMMediaListSetMediaTextMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m, IsDOMMediaList a) => O.MethodInfo DOMMediaListSetMediaTextMethodInfo a signature where
    overloadedMethod _ = dOMMediaListSetMediaText