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

-- * Exported types
    WebPlugin(..)                           ,
    WebPluginK                              ,
    toWebPlugin                             ,
    noWebPlugin                             ,


 -- * Methods
-- ** webPluginGetDescription
    webPluginGetDescription                 ,


-- ** webPluginGetEnabled
    webPluginGetEnabled                     ,


-- ** webPluginGetName
    webPluginGetName                        ,


-- ** webPluginGetPath
    webPluginGetPath                        ,


-- ** webPluginSetEnabled
    webPluginSetEnabled                     ,




 -- * Properties
-- ** Enabled
    WebPluginEnabledPropertyInfo            ,
    constructWebPluginEnabled               ,
    getWebPluginEnabled                     ,
    setWebPluginEnabled                     ,




    ) 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 WebPlugin = WebPlugin (ForeignPtr WebPlugin)
foreign import ccall "webkit_web_plugin_get_type"
    c_webkit_web_plugin_get_type :: IO GType

type instance ParentTypes WebPlugin = WebPluginParentTypes
type WebPluginParentTypes = '[GObject.Object]

instance GObject WebPlugin where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_webkit_web_plugin_get_type
    

class GObject o => WebPluginK o
instance (GObject o, IsDescendantOf WebPlugin o) => WebPluginK o

toWebPlugin :: WebPluginK o => o -> IO WebPlugin
toWebPlugin = unsafeCastTo WebPlugin

noWebPlugin :: Maybe WebPlugin
noWebPlugin = Nothing

-- VVV Prop "enabled"
   -- Type: TBasicType TBoolean
   -- Flags: [PropertyReadable,PropertyWritable]

getWebPluginEnabled :: (MonadIO m, WebPluginK o) => o -> m Bool
getWebPluginEnabled obj = liftIO $ getObjectPropertyBool obj "enabled"

setWebPluginEnabled :: (MonadIO m, WebPluginK o) => o -> Bool -> m ()
setWebPluginEnabled obj val = liftIO $ setObjectPropertyBool obj "enabled" val

constructWebPluginEnabled :: Bool -> IO ([Char], GValue)
constructWebPluginEnabled val = constructObjectPropertyBool "enabled" val

data WebPluginEnabledPropertyInfo
instance AttrInfo WebPluginEnabledPropertyInfo where
    type AttrAllowedOps WebPluginEnabledPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint WebPluginEnabledPropertyInfo = (~) Bool
    type AttrBaseTypeConstraint WebPluginEnabledPropertyInfo = WebPluginK
    type AttrGetType WebPluginEnabledPropertyInfo = Bool
    type AttrLabel WebPluginEnabledPropertyInfo = "WebPlugin::enabled"
    attrGet _ = getWebPluginEnabled
    attrSet _ = setWebPluginEnabled
    attrConstruct _ = constructWebPluginEnabled

type instance AttributeList WebPlugin = WebPluginAttributeList
type WebPluginAttributeList = ('[ '("enabled", WebPluginEnabledPropertyInfo)] :: [(Symbol, *)])

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

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

foreign import ccall "webkit_web_plugin_get_description" webkit_web_plugin_get_description :: 
    Ptr WebPlugin ->                        -- _obj : TInterface "WebKit" "WebPlugin"
    IO CString


webPluginGetDescription ::
    (MonadIO m, WebPluginK a) =>
    a ->                                    -- _obj
    m T.Text
webPluginGetDescription _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_web_plugin_get_description _obj'
    checkUnexpectedReturnNULL "webkit_web_plugin_get_description" result
    result' <- cstringToText result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "webkit_web_plugin_get_enabled" webkit_web_plugin_get_enabled :: 
    Ptr WebPlugin ->                        -- _obj : TInterface "WebKit" "WebPlugin"
    IO CInt


webPluginGetEnabled ::
    (MonadIO m, WebPluginK a) =>
    a ->                                    -- _obj
    m Bool
webPluginGetEnabled _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_web_plugin_get_enabled _obj'
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "webkit_web_plugin_get_name" webkit_web_plugin_get_name :: 
    Ptr WebPlugin ->                        -- _obj : TInterface "WebKit" "WebPlugin"
    IO CString


webPluginGetName ::
    (MonadIO m, WebPluginK a) =>
    a ->                                    -- _obj
    m T.Text
webPluginGetName _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_web_plugin_get_name _obj'
    checkUnexpectedReturnNULL "webkit_web_plugin_get_name" result
    result' <- cstringToText result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "webkit_web_plugin_get_path" webkit_web_plugin_get_path :: 
    Ptr WebPlugin ->                        -- _obj : TInterface "WebKit" "WebPlugin"
    IO CString


webPluginGetPath ::
    (MonadIO m, WebPluginK a) =>
    a ->                                    -- _obj
    m T.Text
webPluginGetPath _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_web_plugin_get_path _obj'
    checkUnexpectedReturnNULL "webkit_web_plugin_get_path" result
    result' <- cstringToText result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "webkit_web_plugin_set_enabled" webkit_web_plugin_set_enabled :: 
    Ptr WebPlugin ->                        -- _obj : TInterface "WebKit" "WebPlugin"
    CInt ->                                 -- enabled : TBasicType TBoolean
    IO ()


webPluginSetEnabled ::
    (MonadIO m, WebPluginK a) =>
    a ->                                    -- _obj
    Bool ->                                 -- enabled
    m ()
webPluginSetEnabled _obj enabled = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let enabled' = (fromIntegral . fromEnum) enabled
    webkit_web_plugin_set_enabled _obj' enabled'
    touchManagedPtr _obj
    return ()