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

-- * Exported types
    DOMStyleMedia(..)                       ,
    DOMStyleMediaK                          ,
    toDOMStyleMedia                         ,
    noDOMStyleMedia                         ,


 -- * Methods
-- ** dOMStyleMediaMatchMedium
    dOMStyleMediaMatchMedium                ,




 -- * Properties
-- ** Type
    DOMStyleMediaTypePropertyInfo           ,
    getDOMStyleMediaType                    ,




    ) 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 DOMStyleMedia = DOMStyleMedia (ForeignPtr DOMStyleMedia)
foreign import ccall "webkit_dom_style_media_get_type"
    c_webkit_dom_style_media_get_type :: IO GType

type instance ParentTypes DOMStyleMedia = DOMStyleMediaParentTypes
type DOMStyleMediaParentTypes = '[DOMObject, GObject.Object]

instance GObject DOMStyleMedia where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_webkit_dom_style_media_get_type
    

class GObject o => DOMStyleMediaK o
instance (GObject o, IsDescendantOf DOMStyleMedia o) => DOMStyleMediaK o

toDOMStyleMedia :: DOMStyleMediaK o => o -> IO DOMStyleMedia
toDOMStyleMedia = unsafeCastTo DOMStyleMedia

noDOMStyleMedia :: Maybe DOMStyleMedia
noDOMStyleMedia = Nothing

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

getDOMStyleMediaType :: (MonadIO m, DOMStyleMediaK o) => o -> m T.Text
getDOMStyleMediaType obj = liftIO $ getObjectPropertyString obj "type"

data DOMStyleMediaTypePropertyInfo
instance AttrInfo DOMStyleMediaTypePropertyInfo where
    type AttrAllowedOps DOMStyleMediaTypePropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DOMStyleMediaTypePropertyInfo = (~) ()
    type AttrBaseTypeConstraint DOMStyleMediaTypePropertyInfo = DOMStyleMediaK
    type AttrGetType DOMStyleMediaTypePropertyInfo = T.Text
    type AttrLabel DOMStyleMediaTypePropertyInfo = "DOMStyleMedia::type"
    attrGet _ = getDOMStyleMediaType
    attrSet _ = undefined
    attrConstruct _ = undefined

type instance AttributeList DOMStyleMedia = DOMStyleMediaAttributeList
type DOMStyleMediaAttributeList = ('[ '("core-object", DOMObjectCoreObjectPropertyInfo), '("type", DOMStyleMediaTypePropertyInfo)] :: [(Symbol, *)])

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

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

foreign import ccall "webkit_dom_style_media_match_medium" webkit_dom_style_media_match_medium :: 
    Ptr DOMStyleMedia ->                    -- _obj : TInterface "WebKit" "DOMStyleMedia"
    CString ->                              -- mediaquery : TBasicType TUTF8
    IO CInt


dOMStyleMediaMatchMedium ::
    (MonadIO m, DOMStyleMediaK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- mediaquery
    m Bool
dOMStyleMediaMatchMedium _obj mediaquery = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    mediaquery' <- textToCString mediaquery
    result <- webkit_dom_style_media_match_medium _obj' mediaquery'
    let result' = (/= 0) result
    touchManagedPtr _obj
    freeMem mediaquery'
    return result'