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

-- * Exported types
    DOMCSSRule(..)                          ,
    DOMCSSRuleK                             ,
    toDOMCSSRule                            ,
    noDOMCSSRule                            ,


 -- * Methods
-- ** dOMCSSRuleGetCssText
    dOMCSSRuleGetCssText                    ,


-- ** dOMCSSRuleGetParentRule
    dOMCSSRuleGetParentRule                 ,


-- ** dOMCSSRuleGetParentStyleSheet
    dOMCSSRuleGetParentStyleSheet           ,


-- ** dOMCSSRuleGetRuleType
    dOMCSSRuleGetRuleType                   ,


-- ** dOMCSSRuleSetCssText
    dOMCSSRuleSetCssText                    ,




 -- * Properties
-- ** CssText
    DOMCSSRuleCssTextPropertyInfo           ,
    constructDOMCSSRuleCssText              ,
    getDOMCSSRuleCssText                    ,
    setDOMCSSRuleCssText                    ,


-- ** ParentRule
    DOMCSSRuleParentRulePropertyInfo        ,
    getDOMCSSRuleParentRule                 ,


-- ** ParentStyleSheet
    DOMCSSRuleParentStyleSheetPropertyInfo  ,
    getDOMCSSRuleParentStyleSheet           ,


-- ** Type
    DOMCSSRuleTypePropertyInfo              ,
    getDOMCSSRuleType                       ,




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

newtype DOMCSSRule = DOMCSSRule (ForeignPtr DOMCSSRule)
foreign import ccall "webkit_dom_css_rule_get_type"
    c_webkit_dom_css_rule_get_type :: IO GType

type instance ParentTypes DOMCSSRule = DOMCSSRuleParentTypes
type DOMCSSRuleParentTypes = '[DOMObject, GObject.Object]

instance GObject DOMCSSRule where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_webkit_dom_css_rule_get_type
    

class GObject o => DOMCSSRuleK o
instance (GObject o, IsDescendantOf DOMCSSRule o) => DOMCSSRuleK o

toDOMCSSRule :: DOMCSSRuleK o => o -> IO DOMCSSRule
toDOMCSSRule = unsafeCastTo DOMCSSRule

noDOMCSSRule :: Maybe DOMCSSRule
noDOMCSSRule = Nothing

-- VVV Prop "css-text"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable]

getDOMCSSRuleCssText :: (MonadIO m, DOMCSSRuleK o) => o -> m T.Text
getDOMCSSRuleCssText obj = liftIO $ getObjectPropertyString obj "css-text"

setDOMCSSRuleCssText :: (MonadIO m, DOMCSSRuleK o) => o -> T.Text -> m ()
setDOMCSSRuleCssText obj val = liftIO $ setObjectPropertyString obj "css-text" val

constructDOMCSSRuleCssText :: T.Text -> IO ([Char], GValue)
constructDOMCSSRuleCssText val = constructObjectPropertyString "css-text" val

data DOMCSSRuleCssTextPropertyInfo
instance AttrInfo DOMCSSRuleCssTextPropertyInfo where
    type AttrAllowedOps DOMCSSRuleCssTextPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint DOMCSSRuleCssTextPropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint DOMCSSRuleCssTextPropertyInfo = DOMCSSRuleK
    type AttrGetType DOMCSSRuleCssTextPropertyInfo = T.Text
    type AttrLabel DOMCSSRuleCssTextPropertyInfo = "DOMCSSRule::css-text"
    attrGet _ = getDOMCSSRuleCssText
    attrSet _ = setDOMCSSRuleCssText
    attrConstruct _ = constructDOMCSSRuleCssText

-- VVV Prop "parent-rule"
   -- Type: TInterface "WebKit2WebExtension" "DOMCSSRule"
   -- Flags: [PropertyReadable]

getDOMCSSRuleParentRule :: (MonadIO m, DOMCSSRuleK o) => o -> m DOMCSSRule
getDOMCSSRuleParentRule obj = liftIO $ getObjectPropertyObject obj "parent-rule" DOMCSSRule

data DOMCSSRuleParentRulePropertyInfo
instance AttrInfo DOMCSSRuleParentRulePropertyInfo where
    type AttrAllowedOps DOMCSSRuleParentRulePropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DOMCSSRuleParentRulePropertyInfo = (~) ()
    type AttrBaseTypeConstraint DOMCSSRuleParentRulePropertyInfo = DOMCSSRuleK
    type AttrGetType DOMCSSRuleParentRulePropertyInfo = DOMCSSRule
    type AttrLabel DOMCSSRuleParentRulePropertyInfo = "DOMCSSRule::parent-rule"
    attrGet _ = getDOMCSSRuleParentRule
    attrSet _ = undefined
    attrConstruct _ = undefined

-- VVV Prop "parent-style-sheet"
   -- Type: TInterface "WebKit2WebExtension" "DOMCSSStyleSheet"
   -- Flags: [PropertyReadable]

getDOMCSSRuleParentStyleSheet :: (MonadIO m, DOMCSSRuleK o) => o -> m DOMCSSStyleSheet
getDOMCSSRuleParentStyleSheet obj = liftIO $ getObjectPropertyObject obj "parent-style-sheet" DOMCSSStyleSheet

data DOMCSSRuleParentStyleSheetPropertyInfo
instance AttrInfo DOMCSSRuleParentStyleSheetPropertyInfo where
    type AttrAllowedOps DOMCSSRuleParentStyleSheetPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DOMCSSRuleParentStyleSheetPropertyInfo = (~) ()
    type AttrBaseTypeConstraint DOMCSSRuleParentStyleSheetPropertyInfo = DOMCSSRuleK
    type AttrGetType DOMCSSRuleParentStyleSheetPropertyInfo = DOMCSSStyleSheet
    type AttrLabel DOMCSSRuleParentStyleSheetPropertyInfo = "DOMCSSRule::parent-style-sheet"
    attrGet _ = getDOMCSSRuleParentStyleSheet
    attrSet _ = undefined
    attrConstruct _ = undefined

-- VVV Prop "type"
   -- Type: TBasicType TUInt32
   -- Flags: [PropertyReadable]

getDOMCSSRuleType :: (MonadIO m, DOMCSSRuleK o) => o -> m Word32
getDOMCSSRuleType obj = liftIO $ getObjectPropertyCUInt obj "type"

data DOMCSSRuleTypePropertyInfo
instance AttrInfo DOMCSSRuleTypePropertyInfo where
    type AttrAllowedOps DOMCSSRuleTypePropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DOMCSSRuleTypePropertyInfo = (~) ()
    type AttrBaseTypeConstraint DOMCSSRuleTypePropertyInfo = DOMCSSRuleK
    type AttrGetType DOMCSSRuleTypePropertyInfo = Word32
    type AttrLabel DOMCSSRuleTypePropertyInfo = "DOMCSSRule::type"
    attrGet _ = getDOMCSSRuleType
    attrSet _ = undefined
    attrConstruct _ = undefined

type instance AttributeList DOMCSSRule = DOMCSSRuleAttributeList
type DOMCSSRuleAttributeList = ('[ '("core-object", DOMObjectCoreObjectPropertyInfo), '("css-text", DOMCSSRuleCssTextPropertyInfo), '("parent-rule", DOMCSSRuleParentRulePropertyInfo), '("parent-style-sheet", DOMCSSRuleParentStyleSheetPropertyInfo), '("type", DOMCSSRuleTypePropertyInfo)] :: [(Symbol, *)])

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

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

foreign import ccall "webkit_dom_css_rule_get_css_text" webkit_dom_css_rule_get_css_text :: 
    Ptr DOMCSSRule ->                       -- _obj : TInterface "WebKit2WebExtension" "DOMCSSRule"
    IO CString


dOMCSSRuleGetCssText ::
    (MonadIO m, DOMCSSRuleK a) =>
    a ->                                    -- _obj
    m T.Text
dOMCSSRuleGetCssText _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_dom_css_rule_get_css_text _obj'
    checkUnexpectedReturnNULL "webkit_dom_css_rule_get_css_text" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "webkit_dom_css_rule_get_parent_rule" webkit_dom_css_rule_get_parent_rule :: 
    Ptr DOMCSSRule ->                       -- _obj : TInterface "WebKit2WebExtension" "DOMCSSRule"
    IO (Ptr DOMCSSRule)


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

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

foreign import ccall "webkit_dom_css_rule_get_parent_style_sheet" webkit_dom_css_rule_get_parent_style_sheet :: 
    Ptr DOMCSSRule ->                       -- _obj : TInterface "WebKit2WebExtension" "DOMCSSRule"
    IO (Ptr DOMCSSStyleSheet)


dOMCSSRuleGetParentStyleSheet ::
    (MonadIO m, DOMCSSRuleK a) =>
    a ->                                    -- _obj
    m DOMCSSStyleSheet
dOMCSSRuleGetParentStyleSheet _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_dom_css_rule_get_parent_style_sheet _obj'
    checkUnexpectedReturnNULL "webkit_dom_css_rule_get_parent_style_sheet" result
    result' <- (wrapObject DOMCSSStyleSheet) result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "webkit_dom_css_rule_get_rule_type" webkit_dom_css_rule_get_rule_type :: 
    Ptr DOMCSSRule ->                       -- _obj : TInterface "WebKit2WebExtension" "DOMCSSRule"
    IO Word16


dOMCSSRuleGetRuleType ::
    (MonadIO m, DOMCSSRuleK a) =>
    a ->                                    -- _obj
    m Word16
dOMCSSRuleGetRuleType _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_dom_css_rule_get_rule_type _obj'
    touchManagedPtr _obj
    return result

-- method DOMCSSRule::set_css_text
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit2WebExtension" "DOMCSSRule", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "value", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit2WebExtension" "DOMCSSRule", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "value", argType = TBasicType TUTF8, 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_rule_set_css_text" webkit_dom_css_rule_set_css_text :: 
    Ptr DOMCSSRule ->                       -- _obj : TInterface "WebKit2WebExtension" "DOMCSSRule"
    CString ->                              -- value : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO ()


dOMCSSRuleSetCssText ::
    (MonadIO m, DOMCSSRuleK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- value
    m ()
dOMCSSRuleSetCssText _obj value = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    value' <- textToCString value
    onException (do
        propagateGError $ webkit_dom_css_rule_set_css_text _obj' value'
        touchManagedPtr _obj
        freeMem value'
        return ()
     ) (do
        freeMem value'
     )