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

-- * Exported types
    DOMCSSValue(..)                         ,
    DOMCSSValueK                            ,
    toDOMCSSValue                           ,
    noDOMCSSValue                           ,


 -- * Methods
-- ** dOMCSSValueGetCssText
    dOMCSSValueGetCssText                   ,


-- ** dOMCSSValueGetCssValueType
    dOMCSSValueGetCssValueType              ,


-- ** dOMCSSValueSetCssText
    dOMCSSValueSetCssText                   ,




 -- * Properties
-- ** CssText
    DOMCSSValueCssTextPropertyInfo          ,
    constructDOMCSSValueCssText             ,
    getDOMCSSValueCssText                   ,
    setDOMCSSValueCssText                   ,


-- ** CssValueType
    DOMCSSValueCssValueTypePropertyInfo     ,
    getDOMCSSValueCssValueType              ,




    ) 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 DOMCSSValue = DOMCSSValue (ForeignPtr DOMCSSValue)
foreign import ccall "webkit_dom_css_value_get_type"
    c_webkit_dom_css_value_get_type :: IO GType

type instance ParentTypes DOMCSSValue = DOMCSSValueParentTypes
type DOMCSSValueParentTypes = '[DOMObject, GObject.Object]

instance GObject DOMCSSValue where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_webkit_dom_css_value_get_type
    

class GObject o => DOMCSSValueK o
instance (GObject o, IsDescendantOf DOMCSSValue o) => DOMCSSValueK o

toDOMCSSValue :: DOMCSSValueK o => o -> IO DOMCSSValue
toDOMCSSValue = unsafeCastTo DOMCSSValue

noDOMCSSValue :: Maybe DOMCSSValue
noDOMCSSValue = Nothing

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

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

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

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

data DOMCSSValueCssTextPropertyInfo
instance AttrInfo DOMCSSValueCssTextPropertyInfo where
    type AttrAllowedOps DOMCSSValueCssTextPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint DOMCSSValueCssTextPropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint DOMCSSValueCssTextPropertyInfo = DOMCSSValueK
    type AttrGetType DOMCSSValueCssTextPropertyInfo = T.Text
    type AttrLabel DOMCSSValueCssTextPropertyInfo = "DOMCSSValue::css-text"
    attrGet _ = getDOMCSSValueCssText
    attrSet _ = setDOMCSSValueCssText
    attrConstruct _ = constructDOMCSSValueCssText

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

getDOMCSSValueCssValueType :: (MonadIO m, DOMCSSValueK o) => o -> m Word32
getDOMCSSValueCssValueType obj = liftIO $ getObjectPropertyCUInt obj "css-value-type"

data DOMCSSValueCssValueTypePropertyInfo
instance AttrInfo DOMCSSValueCssValueTypePropertyInfo where
    type AttrAllowedOps DOMCSSValueCssValueTypePropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DOMCSSValueCssValueTypePropertyInfo = (~) ()
    type AttrBaseTypeConstraint DOMCSSValueCssValueTypePropertyInfo = DOMCSSValueK
    type AttrGetType DOMCSSValueCssValueTypePropertyInfo = Word32
    type AttrLabel DOMCSSValueCssValueTypePropertyInfo = "DOMCSSValue::css-value-type"
    attrGet _ = getDOMCSSValueCssValueType
    attrSet _ = undefined
    attrConstruct _ = undefined

type instance AttributeList DOMCSSValue = DOMCSSValueAttributeList
type DOMCSSValueAttributeList = ('[ '("core-object", DOMObjectCoreObjectPropertyInfo), '("css-text", DOMCSSValueCssTextPropertyInfo), '("css-value-type", DOMCSSValueCssValueTypePropertyInfo)] :: [(Symbol, *)])

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

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


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

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


dOMCSSValueGetCssValueType ::
    (MonadIO m, DOMCSSValueK a) =>
    a ->                                    -- _obj
    m Word16
dOMCSSValueGetCssValueType _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_dom_css_value_get_css_value_type _obj'
    touchManagedPtr _obj
    return result

-- method DOMCSSValue::set_css_text
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMCSSValue", 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 "WebKit" "DOMCSSValue", 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_value_set_css_text" webkit_dom_css_value_set_css_text :: 
    Ptr DOMCSSValue ->                      -- _obj : TInterface "WebKit" "DOMCSSValue"
    CString ->                              -- value : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO ()


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