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

-- * Exported types
    DOMCSSStyleSheet(..)                    ,
    DOMCSSStyleSheetK                       ,
    toDOMCSSStyleSheet                      ,
    noDOMCSSStyleSheet                      ,


 -- * Methods
-- ** dOMCSSStyleSheetAddRule
    dOMCSSStyleSheetAddRule                 ,


-- ** dOMCSSStyleSheetDeleteRule
    dOMCSSStyleSheetDeleteRule              ,


-- ** dOMCSSStyleSheetGetCssRules
    dOMCSSStyleSheetGetCssRules             ,


-- ** dOMCSSStyleSheetGetOwnerRule
    dOMCSSStyleSheetGetOwnerRule            ,


-- ** dOMCSSStyleSheetGetRules
    dOMCSSStyleSheetGetRules                ,


-- ** dOMCSSStyleSheetInsertRule
    dOMCSSStyleSheetInsertRule              ,


-- ** dOMCSSStyleSheetRemoveRule
    dOMCSSStyleSheetRemoveRule              ,




 -- * Properties
-- ** CssRules
    DOMCSSStyleSheetCssRulesPropertyInfo    ,
    getDOMCSSStyleSheetCssRules             ,


-- ** OwnerRule
    DOMCSSStyleSheetOwnerRulePropertyInfo   ,
    getDOMCSSStyleSheetOwnerRule            ,


-- ** Rules
    DOMCSSStyleSheetRulesPropertyInfo       ,
    getDOMCSSStyleSheetRules                ,




    ) 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 DOMCSSStyleSheet = DOMCSSStyleSheet (ForeignPtr DOMCSSStyleSheet)
foreign import ccall "webkit_dom_css_style_sheet_get_type"
    c_webkit_dom_css_style_sheet_get_type :: IO GType

type instance ParentTypes DOMCSSStyleSheet = DOMCSSStyleSheetParentTypes
type DOMCSSStyleSheetParentTypes = '[DOMStyleSheet, DOMObject, GObject.Object]

instance GObject DOMCSSStyleSheet where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_webkit_dom_css_style_sheet_get_type
    

class GObject o => DOMCSSStyleSheetK o
instance (GObject o, IsDescendantOf DOMCSSStyleSheet o) => DOMCSSStyleSheetK o

toDOMCSSStyleSheet :: DOMCSSStyleSheetK o => o -> IO DOMCSSStyleSheet
toDOMCSSStyleSheet = unsafeCastTo DOMCSSStyleSheet

noDOMCSSStyleSheet :: Maybe DOMCSSStyleSheet
noDOMCSSStyleSheet = Nothing

-- VVV Prop "css-rules"
   -- Type: TInterface "WebKit" "DOMCSSRuleList"
   -- Flags: [PropertyReadable]

getDOMCSSStyleSheetCssRules :: (MonadIO m, DOMCSSStyleSheetK o) => o -> m DOMCSSRuleList
getDOMCSSStyleSheetCssRules obj = liftIO $ getObjectPropertyObject obj "css-rules" DOMCSSRuleList

data DOMCSSStyleSheetCssRulesPropertyInfo
instance AttrInfo DOMCSSStyleSheetCssRulesPropertyInfo where
    type AttrAllowedOps DOMCSSStyleSheetCssRulesPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DOMCSSStyleSheetCssRulesPropertyInfo = (~) ()
    type AttrBaseTypeConstraint DOMCSSStyleSheetCssRulesPropertyInfo = DOMCSSStyleSheetK
    type AttrGetType DOMCSSStyleSheetCssRulesPropertyInfo = DOMCSSRuleList
    type AttrLabel DOMCSSStyleSheetCssRulesPropertyInfo = "DOMCSSStyleSheet::css-rules"
    attrGet _ = getDOMCSSStyleSheetCssRules
    attrSet _ = undefined
    attrConstruct _ = undefined

-- VVV Prop "owner-rule"
   -- Type: TInterface "WebKit" "DOMCSSRule"
   -- Flags: [PropertyReadable]

getDOMCSSStyleSheetOwnerRule :: (MonadIO m, DOMCSSStyleSheetK o) => o -> m DOMCSSRule
getDOMCSSStyleSheetOwnerRule obj = liftIO $ getObjectPropertyObject obj "owner-rule" DOMCSSRule

data DOMCSSStyleSheetOwnerRulePropertyInfo
instance AttrInfo DOMCSSStyleSheetOwnerRulePropertyInfo where
    type AttrAllowedOps DOMCSSStyleSheetOwnerRulePropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DOMCSSStyleSheetOwnerRulePropertyInfo = (~) ()
    type AttrBaseTypeConstraint DOMCSSStyleSheetOwnerRulePropertyInfo = DOMCSSStyleSheetK
    type AttrGetType DOMCSSStyleSheetOwnerRulePropertyInfo = DOMCSSRule
    type AttrLabel DOMCSSStyleSheetOwnerRulePropertyInfo = "DOMCSSStyleSheet::owner-rule"
    attrGet _ = getDOMCSSStyleSheetOwnerRule
    attrSet _ = undefined
    attrConstruct _ = undefined

-- VVV Prop "rules"
   -- Type: TInterface "WebKit" "DOMCSSRuleList"
   -- Flags: [PropertyReadable]

getDOMCSSStyleSheetRules :: (MonadIO m, DOMCSSStyleSheetK o) => o -> m DOMCSSRuleList
getDOMCSSStyleSheetRules obj = liftIO $ getObjectPropertyObject obj "rules" DOMCSSRuleList

data DOMCSSStyleSheetRulesPropertyInfo
instance AttrInfo DOMCSSStyleSheetRulesPropertyInfo where
    type AttrAllowedOps DOMCSSStyleSheetRulesPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DOMCSSStyleSheetRulesPropertyInfo = (~) ()
    type AttrBaseTypeConstraint DOMCSSStyleSheetRulesPropertyInfo = DOMCSSStyleSheetK
    type AttrGetType DOMCSSStyleSheetRulesPropertyInfo = DOMCSSRuleList
    type AttrLabel DOMCSSStyleSheetRulesPropertyInfo = "DOMCSSStyleSheet::rules"
    attrGet _ = getDOMCSSStyleSheetRules
    attrSet _ = undefined
    attrConstruct _ = undefined

type instance AttributeList DOMCSSStyleSheet = DOMCSSStyleSheetAttributeList
type DOMCSSStyleSheetAttributeList = ('[ '("core-object", DOMObjectCoreObjectPropertyInfo), '("css-rules", DOMCSSStyleSheetCssRulesPropertyInfo), '("disabled", DOMStyleSheetDisabledPropertyInfo), '("href", DOMStyleSheetHrefPropertyInfo), '("media", DOMStyleSheetMediaPropertyInfo), '("owner-node", DOMStyleSheetOwnerNodePropertyInfo), '("owner-rule", DOMCSSStyleSheetOwnerRulePropertyInfo), '("parent-style-sheet", DOMStyleSheetParentStyleSheetPropertyInfo), '("rules", DOMCSSStyleSheetRulesPropertyInfo), '("title", DOMStyleSheetTitlePropertyInfo), '("type", DOMStyleSheetTypePropertyInfo)] :: [(Symbol, *)])

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

-- method DOMCSSStyleSheet::add_rule
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMCSSStyleSheet", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "selector", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "style", argType = TBasicType TUTF8, 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" "DOMCSSStyleSheet", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "selector", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "style", argType = TBasicType TUTF8, 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 : TBasicType TInt64
-- throws : True
-- Skip return : False

foreign import ccall "webkit_dom_css_style_sheet_add_rule" webkit_dom_css_style_sheet_add_rule :: 
    Ptr DOMCSSStyleSheet ->                 -- _obj : TInterface "WebKit" "DOMCSSStyleSheet"
    CString ->                              -- selector : TBasicType TUTF8
    CString ->                              -- style : TBasicType TUTF8
    Word64 ->                               -- index : TBasicType TUInt64
    Ptr (Ptr GError) ->                     -- error
    IO Int64


dOMCSSStyleSheetAddRule ::
    (MonadIO m, DOMCSSStyleSheetK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- selector
    T.Text ->                               -- style
    Word64 ->                               -- index
    m Int64
dOMCSSStyleSheetAddRule _obj selector style index = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    selector' <- textToCString selector
    style' <- textToCString style
    onException (do
        result <- propagateGError $ webkit_dom_css_style_sheet_add_rule _obj' selector' style' index
        touchManagedPtr _obj
        freeMem selector'
        freeMem style'
        return result
     ) (do
        freeMem selector'
        freeMem style'
     )

-- method DOMCSSStyleSheet::delete_rule
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMCSSStyleSheet", 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" "DOMCSSStyleSheet", 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 : TBasicType TVoid
-- throws : True
-- Skip return : False

foreign import ccall "webkit_dom_css_style_sheet_delete_rule" webkit_dom_css_style_sheet_delete_rule :: 
    Ptr DOMCSSStyleSheet ->                 -- _obj : TInterface "WebKit" "DOMCSSStyleSheet"
    Word64 ->                               -- index : TBasicType TUInt64
    Ptr (Ptr GError) ->                     -- error
    IO ()


dOMCSSStyleSheetDeleteRule ::
    (MonadIO m, DOMCSSStyleSheetK a) =>
    a ->                                    -- _obj
    Word64 ->                               -- index
    m ()
dOMCSSStyleSheetDeleteRule _obj index = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    onException (do
        propagateGError $ webkit_dom_css_style_sheet_delete_rule _obj' index
        touchManagedPtr _obj
        return ()
     ) (do
        return ()
     )

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

foreign import ccall "webkit_dom_css_style_sheet_get_css_rules" webkit_dom_css_style_sheet_get_css_rules :: 
    Ptr DOMCSSStyleSheet ->                 -- _obj : TInterface "WebKit" "DOMCSSStyleSheet"
    IO (Ptr DOMCSSRuleList)


dOMCSSStyleSheetGetCssRules ::
    (MonadIO m, DOMCSSStyleSheetK a) =>
    a ->                                    -- _obj
    m DOMCSSRuleList
dOMCSSStyleSheetGetCssRules _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_dom_css_style_sheet_get_css_rules _obj'
    checkUnexpectedReturnNULL "webkit_dom_css_style_sheet_get_css_rules" result
    result' <- (wrapObject DOMCSSRuleList) result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "webkit_dom_css_style_sheet_get_owner_rule" webkit_dom_css_style_sheet_get_owner_rule :: 
    Ptr DOMCSSStyleSheet ->                 -- _obj : TInterface "WebKit" "DOMCSSStyleSheet"
    IO (Ptr DOMCSSRule)


dOMCSSStyleSheetGetOwnerRule ::
    (MonadIO m, DOMCSSStyleSheetK a) =>
    a ->                                    -- _obj
    m DOMCSSRule
dOMCSSStyleSheetGetOwnerRule _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_dom_css_style_sheet_get_owner_rule _obj'
    checkUnexpectedReturnNULL "webkit_dom_css_style_sheet_get_owner_rule" result
    result' <- (wrapObject DOMCSSRule) result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "webkit_dom_css_style_sheet_get_rules" webkit_dom_css_style_sheet_get_rules :: 
    Ptr DOMCSSStyleSheet ->                 -- _obj : TInterface "WebKit" "DOMCSSStyleSheet"
    IO (Ptr DOMCSSRuleList)


dOMCSSStyleSheetGetRules ::
    (MonadIO m, DOMCSSStyleSheetK a) =>
    a ->                                    -- _obj
    m DOMCSSRuleList
dOMCSSStyleSheetGetRules _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_dom_css_style_sheet_get_rules _obj'
    checkUnexpectedReturnNULL "webkit_dom_css_style_sheet_get_rules" result
    result' <- (wrapObject DOMCSSRuleList) result
    touchManagedPtr _obj
    return result'

-- method DOMCSSStyleSheet::insert_rule
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMCSSStyleSheet", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "rule", argType = TBasicType TUTF8, 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" "DOMCSSStyleSheet", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "rule", argType = TBasicType TUTF8, 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 : TBasicType TUInt64
-- throws : True
-- Skip return : False

foreign import ccall "webkit_dom_css_style_sheet_insert_rule" webkit_dom_css_style_sheet_insert_rule :: 
    Ptr DOMCSSStyleSheet ->                 -- _obj : TInterface "WebKit" "DOMCSSStyleSheet"
    CString ->                              -- rule : TBasicType TUTF8
    Word64 ->                               -- index : TBasicType TUInt64
    Ptr (Ptr GError) ->                     -- error
    IO Word64


dOMCSSStyleSheetInsertRule ::
    (MonadIO m, DOMCSSStyleSheetK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- rule
    Word64 ->                               -- index
    m Word64
dOMCSSStyleSheetInsertRule _obj rule index = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    rule' <- textToCString rule
    onException (do
        result <- propagateGError $ webkit_dom_css_style_sheet_insert_rule _obj' rule' index
        touchManagedPtr _obj
        freeMem rule'
        return result
     ) (do
        freeMem rule'
     )

-- method DOMCSSStyleSheet::remove_rule
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMCSSStyleSheet", 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" "DOMCSSStyleSheet", 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 : TBasicType TVoid
-- throws : True
-- Skip return : False

foreign import ccall "webkit_dom_css_style_sheet_remove_rule" webkit_dom_css_style_sheet_remove_rule :: 
    Ptr DOMCSSStyleSheet ->                 -- _obj : TInterface "WebKit" "DOMCSSStyleSheet"
    Word64 ->                               -- index : TBasicType TUInt64
    Ptr (Ptr GError) ->                     -- error
    IO ()


dOMCSSStyleSheetRemoveRule ::
    (MonadIO m, DOMCSSStyleSheetK a) =>
    a ->                                    -- _obj
    Word64 ->                               -- index
    m ()
dOMCSSStyleSheetRemoveRule _obj index = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    onException (do
        propagateGError $ webkit_dom_css_style_sheet_remove_rule _obj' index
        touchManagedPtr _obj
        return ()
     ) (do
        return ()
     )