{- |
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.Gio.Interfaces.Action
    ( 

-- * Exported types
    Action(..)                              ,
    noAction                                ,
    ActionK                                 ,
    toAction                                ,


 -- * Methods
-- ** actionActivate
    actionActivate                          ,


-- ** actionChangeState
    actionChangeState                       ,


-- ** actionGetEnabled
    actionGetEnabled                        ,


-- ** actionGetName
    actionGetName                           ,


-- ** actionGetParameterType
    actionGetParameterType                  ,


-- ** actionGetState
    actionGetState                          ,


-- ** actionGetStateHint
    actionGetStateHint                      ,


-- ** actionGetStateType
    actionGetStateType                      ,




 -- * Properties
-- ** Enabled
    ActionEnabledPropertyInfo               ,
    getActionEnabled                        ,


-- ** Name
    ActionNamePropertyInfo                  ,
    getActionName                           ,


-- ** ParameterType
    ActionParameterTypePropertyInfo         ,
    getActionParameterType                  ,


-- ** State
    ActionStatePropertyInfo                 ,
    getActionState                          ,


-- ** StateType
    ActionStateTypePropertyInfo             ,
    getActionStateType                      ,




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

-- interface Action 

newtype Action = Action (ForeignPtr Action)
noAction :: Maybe Action
noAction = Nothing

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

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

data ActionEnabledPropertyInfo
instance AttrInfo ActionEnabledPropertyInfo where
    type AttrAllowedOps ActionEnabledPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint ActionEnabledPropertyInfo = (~) ()
    type AttrBaseTypeConstraint ActionEnabledPropertyInfo = ActionK
    type AttrGetType ActionEnabledPropertyInfo = Bool
    type AttrLabel ActionEnabledPropertyInfo = "Action::enabled"
    attrGet _ = getActionEnabled
    attrSet _ = undefined
    attrConstruct _ = undefined

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

getActionName :: (MonadIO m, ActionK o) => o -> m T.Text
getActionName obj = liftIO $ getObjectPropertyString obj "name"

data ActionNamePropertyInfo
instance AttrInfo ActionNamePropertyInfo where
    type AttrAllowedOps ActionNamePropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint ActionNamePropertyInfo = (~) ()
    type AttrBaseTypeConstraint ActionNamePropertyInfo = ActionK
    type AttrGetType ActionNamePropertyInfo = T.Text
    type AttrLabel ActionNamePropertyInfo = "Action::name"
    attrGet _ = getActionName
    attrSet _ = undefined
    attrConstruct _ = undefined

-- VVV Prop "parameter-type"
   -- Type: TInterface "GLib" "VariantType"
   -- Flags: [PropertyReadable]

getActionParameterType :: (MonadIO m, ActionK o) => o -> m GLib.VariantType
getActionParameterType obj = liftIO $ getObjectPropertyBoxed obj "parameter-type" GLib.VariantType

data ActionParameterTypePropertyInfo
instance AttrInfo ActionParameterTypePropertyInfo where
    type AttrAllowedOps ActionParameterTypePropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint ActionParameterTypePropertyInfo = (~) ()
    type AttrBaseTypeConstraint ActionParameterTypePropertyInfo = ActionK
    type AttrGetType ActionParameterTypePropertyInfo = GLib.VariantType
    type AttrLabel ActionParameterTypePropertyInfo = "Action::parameter-type"
    attrGet _ = getActionParameterType
    attrSet _ = undefined
    attrConstruct _ = undefined

-- VVV Prop "state"
   -- Type: TVariant
   -- Flags: [PropertyReadable]

getActionState :: (MonadIO m, ActionK o) => o -> m GVariant
getActionState obj = liftIO $ getObjectPropertyVariant obj "state"

data ActionStatePropertyInfo
instance AttrInfo ActionStatePropertyInfo where
    type AttrAllowedOps ActionStatePropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint ActionStatePropertyInfo = (~) ()
    type AttrBaseTypeConstraint ActionStatePropertyInfo = ActionK
    type AttrGetType ActionStatePropertyInfo = GVariant
    type AttrLabel ActionStatePropertyInfo = "Action::state"
    attrGet _ = getActionState
    attrSet _ = undefined
    attrConstruct _ = undefined

-- VVV Prop "state-type"
   -- Type: TInterface "GLib" "VariantType"
   -- Flags: [PropertyReadable]

getActionStateType :: (MonadIO m, ActionK o) => o -> m GLib.VariantType
getActionStateType obj = liftIO $ getObjectPropertyBoxed obj "state-type" GLib.VariantType

data ActionStateTypePropertyInfo
instance AttrInfo ActionStateTypePropertyInfo where
    type AttrAllowedOps ActionStateTypePropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint ActionStateTypePropertyInfo = (~) ()
    type AttrBaseTypeConstraint ActionStateTypePropertyInfo = ActionK
    type AttrGetType ActionStateTypePropertyInfo = GLib.VariantType
    type AttrLabel ActionStateTypePropertyInfo = "Action::state-type"
    attrGet _ = getActionStateType
    attrSet _ = undefined
    attrConstruct _ = undefined

type instance AttributeList Action = ActionAttributeList
type ActionAttributeList = ('[ '("enabled", ActionEnabledPropertyInfo), '("name", ActionNamePropertyInfo), '("parameter-type", ActionParameterTypePropertyInfo), '("state", ActionStatePropertyInfo), '("state-type", ActionStateTypePropertyInfo)] :: [(Symbol, *)])

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

foreign import ccall "g_action_get_type"
    c_g_action_get_type :: IO GType

type instance ParentTypes Action = ActionParentTypes
type ActionParentTypes = '[GObject.Object]

instance GObject Action where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_g_action_get_type
    

class GObject o => ActionK o
instance (GObject o, IsDescendantOf Action o) => ActionK o

toAction :: ActionK o => o -> IO Action
toAction = unsafeCastTo Action

-- method Action::activate
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Action", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "parameter", argType = TVariant, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Action", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "parameter", argType = TVariant, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_action_activate" g_action_activate :: 
    Ptr Action ->                           -- _obj : TInterface "Gio" "Action"
    Ptr GVariant ->                         -- parameter : TVariant
    IO ()


actionActivate ::
    (MonadIO m, ActionK a) =>
    a ->                                    -- _obj
    Maybe (GVariant) ->                     -- parameter
    m ()
actionActivate _obj parameter = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    maybeParameter <- case parameter of
        Nothing -> return nullPtr
        Just jParameter -> do
            let jParameter' = unsafeManagedPtrGetPtr jParameter
            return jParameter'
    g_action_activate _obj' maybeParameter
    touchManagedPtr _obj
    return ()

-- method Action::change_state
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Action", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "value", argType = TVariant, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Action", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "value", argType = TVariant, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_action_change_state" g_action_change_state :: 
    Ptr Action ->                           -- _obj : TInterface "Gio" "Action"
    Ptr GVariant ->                         -- value : TVariant
    IO ()


actionChangeState ::
    (MonadIO m, ActionK a) =>
    a ->                                    -- _obj
    GVariant ->                             -- value
    m ()
actionChangeState _obj value = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let value' = unsafeManagedPtrGetPtr value
    g_action_change_state _obj' value'
    touchManagedPtr _obj
    return ()

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

foreign import ccall "g_action_get_enabled" g_action_get_enabled :: 
    Ptr Action ->                           -- _obj : TInterface "Gio" "Action"
    IO CInt


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

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

foreign import ccall "g_action_get_name" g_action_get_name :: 
    Ptr Action ->                           -- _obj : TInterface "Gio" "Action"
    IO CString


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

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

foreign import ccall "g_action_get_parameter_type" g_action_get_parameter_type :: 
    Ptr Action ->                           -- _obj : TInterface "Gio" "Action"
    IO (Ptr GLib.VariantType)


actionGetParameterType ::
    (MonadIO m, ActionK a) =>
    a ->                                    -- _obj
    m GLib.VariantType
actionGetParameterType _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_action_get_parameter_type _obj'
    checkUnexpectedReturnNULL "g_action_get_parameter_type" result
    result' <- (newBoxed GLib.VariantType) result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "g_action_get_state" g_action_get_state :: 
    Ptr Action ->                           -- _obj : TInterface "Gio" "Action"
    IO (Ptr GVariant)


actionGetState ::
    (MonadIO m, ActionK a) =>
    a ->                                    -- _obj
    m GVariant
actionGetState _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_action_get_state _obj'
    checkUnexpectedReturnNULL "g_action_get_state" result
    result' <- wrapGVariantPtr result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "g_action_get_state_hint" g_action_get_state_hint :: 
    Ptr Action ->                           -- _obj : TInterface "Gio" "Action"
    IO (Ptr GVariant)


actionGetStateHint ::
    (MonadIO m, ActionK a) =>
    a ->                                    -- _obj
    m GVariant
actionGetStateHint _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_action_get_state_hint _obj'
    checkUnexpectedReturnNULL "g_action_get_state_hint" result
    result' <- wrapGVariantPtr result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "g_action_get_state_type" g_action_get_state_type :: 
    Ptr Action ->                           -- _obj : TInterface "Gio" "Action"
    IO (Ptr GLib.VariantType)


actionGetStateType ::
    (MonadIO m, ActionK a) =>
    a ->                                    -- _obj
    m GLib.VariantType
actionGetStateType _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_action_get_state_type _obj'
    checkUnexpectedReturnNULL "g_action_get_state_type" result
    result' <- (newBoxed GLib.VariantType) result
    touchManagedPtr _obj
    return result'