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

-- * Exported types
    WebNavigationAction(..)                 ,
    WebNavigationActionK                    ,
    toWebNavigationAction                   ,
    noWebNavigationAction                   ,


 -- * Methods
-- ** webNavigationActionGetButton
    webNavigationActionGetButton            ,


-- ** webNavigationActionGetModifierState
    webNavigationActionGetModifierState     ,


-- ** webNavigationActionGetOriginalUri
    webNavigationActionGetOriginalUri       ,


-- ** webNavigationActionGetReason
    webNavigationActionGetReason            ,


-- ** webNavigationActionGetTargetFrame
    webNavigationActionGetTargetFrame       ,


-- ** webNavigationActionSetOriginalUri
    webNavigationActionSetOriginalUri       ,


-- ** webNavigationActionSetReason
    webNavigationActionSetReason            ,




 -- * Properties
-- ** Button
    WebNavigationActionButtonPropertyInfo   ,
    constructWebNavigationActionButton      ,
    getWebNavigationActionButton            ,


-- ** ModifierState
    WebNavigationActionModifierStatePropertyInfo,
    constructWebNavigationActionModifierState,
    getWebNavigationActionModifierState     ,


-- ** OriginalUri
    WebNavigationActionOriginalUriPropertyInfo,
    constructWebNavigationActionOriginalUri ,
    getWebNavigationActionOriginalUri       ,
    setWebNavigationActionOriginalUri       ,


-- ** Reason
    WebNavigationActionReasonPropertyInfo   ,
    constructWebNavigationActionReason      ,
    getWebNavigationActionReason            ,
    setWebNavigationActionReason            ,


-- ** TargetFrame
    WebNavigationActionTargetFramePropertyInfo,
    constructWebNavigationActionTargetFrame ,
    getWebNavigationActionTargetFrame       ,




    ) 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 WebNavigationAction = WebNavigationAction (ForeignPtr WebNavigationAction)
foreign import ccall "webkit_web_navigation_action_get_type"
    c_webkit_web_navigation_action_get_type :: IO GType

type instance ParentTypes WebNavigationAction = WebNavigationActionParentTypes
type WebNavigationActionParentTypes = '[GObject.Object]

instance GObject WebNavigationAction where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_webkit_web_navigation_action_get_type
    

class GObject o => WebNavigationActionK o
instance (GObject o, IsDescendantOf WebNavigationAction o) => WebNavigationActionK o

toWebNavigationAction :: WebNavigationActionK o => o -> IO WebNavigationAction
toWebNavigationAction = unsafeCastTo WebNavigationAction

noWebNavigationAction :: Maybe WebNavigationAction
noWebNavigationAction = Nothing

-- VVV Prop "button"
   -- Type: TBasicType TInt32
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]

getWebNavigationActionButton :: (MonadIO m, WebNavigationActionK o) => o -> m Int32
getWebNavigationActionButton obj = liftIO $ getObjectPropertyCInt obj "button"

constructWebNavigationActionButton :: Int32 -> IO ([Char], GValue)
constructWebNavigationActionButton val = constructObjectPropertyCInt "button" val

data WebNavigationActionButtonPropertyInfo
instance AttrInfo WebNavigationActionButtonPropertyInfo where
    type AttrAllowedOps WebNavigationActionButtonPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint WebNavigationActionButtonPropertyInfo = (~) Int32
    type AttrBaseTypeConstraint WebNavigationActionButtonPropertyInfo = WebNavigationActionK
    type AttrGetType WebNavigationActionButtonPropertyInfo = Int32
    type AttrLabel WebNavigationActionButtonPropertyInfo = "WebNavigationAction::button"
    attrGet _ = getWebNavigationActionButton
    attrSet _ = undefined
    attrConstruct _ = constructWebNavigationActionButton

-- VVV Prop "modifier-state"
   -- Type: TBasicType TInt32
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]

getWebNavigationActionModifierState :: (MonadIO m, WebNavigationActionK o) => o -> m Int32
getWebNavigationActionModifierState obj = liftIO $ getObjectPropertyCInt obj "modifier-state"

constructWebNavigationActionModifierState :: Int32 -> IO ([Char], GValue)
constructWebNavigationActionModifierState val = constructObjectPropertyCInt "modifier-state" val

data WebNavigationActionModifierStatePropertyInfo
instance AttrInfo WebNavigationActionModifierStatePropertyInfo where
    type AttrAllowedOps WebNavigationActionModifierStatePropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint WebNavigationActionModifierStatePropertyInfo = (~) Int32
    type AttrBaseTypeConstraint WebNavigationActionModifierStatePropertyInfo = WebNavigationActionK
    type AttrGetType WebNavigationActionModifierStatePropertyInfo = Int32
    type AttrLabel WebNavigationActionModifierStatePropertyInfo = "WebNavigationAction::modifier-state"
    attrGet _ = getWebNavigationActionModifierState
    attrSet _ = undefined
    attrConstruct _ = constructWebNavigationActionModifierState

-- VVV Prop "original-uri"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstruct]

getWebNavigationActionOriginalUri :: (MonadIO m, WebNavigationActionK o) => o -> m T.Text
getWebNavigationActionOriginalUri obj = liftIO $ getObjectPropertyString obj "original-uri"

setWebNavigationActionOriginalUri :: (MonadIO m, WebNavigationActionK o) => o -> T.Text -> m ()
setWebNavigationActionOriginalUri obj val = liftIO $ setObjectPropertyString obj "original-uri" val

constructWebNavigationActionOriginalUri :: T.Text -> IO ([Char], GValue)
constructWebNavigationActionOriginalUri val = constructObjectPropertyString "original-uri" val

data WebNavigationActionOriginalUriPropertyInfo
instance AttrInfo WebNavigationActionOriginalUriPropertyInfo where
    type AttrAllowedOps WebNavigationActionOriginalUriPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint WebNavigationActionOriginalUriPropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint WebNavigationActionOriginalUriPropertyInfo = WebNavigationActionK
    type AttrGetType WebNavigationActionOriginalUriPropertyInfo = T.Text
    type AttrLabel WebNavigationActionOriginalUriPropertyInfo = "WebNavigationAction::original-uri"
    attrGet _ = getWebNavigationActionOriginalUri
    attrSet _ = setWebNavigationActionOriginalUri
    attrConstruct _ = constructWebNavigationActionOriginalUri

-- VVV Prop "reason"
   -- Type: TInterface "WebKit" "WebNavigationReason"
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstruct]

getWebNavigationActionReason :: (MonadIO m, WebNavigationActionK o) => o -> m WebNavigationReason
getWebNavigationActionReason obj = liftIO $ getObjectPropertyEnum obj "reason"

setWebNavigationActionReason :: (MonadIO m, WebNavigationActionK o) => o -> WebNavigationReason -> m ()
setWebNavigationActionReason obj val = liftIO $ setObjectPropertyEnum obj "reason" val

constructWebNavigationActionReason :: WebNavigationReason -> IO ([Char], GValue)
constructWebNavigationActionReason val = constructObjectPropertyEnum "reason" val

data WebNavigationActionReasonPropertyInfo
instance AttrInfo WebNavigationActionReasonPropertyInfo where
    type AttrAllowedOps WebNavigationActionReasonPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint WebNavigationActionReasonPropertyInfo = (~) WebNavigationReason
    type AttrBaseTypeConstraint WebNavigationActionReasonPropertyInfo = WebNavigationActionK
    type AttrGetType WebNavigationActionReasonPropertyInfo = WebNavigationReason
    type AttrLabel WebNavigationActionReasonPropertyInfo = "WebNavigationAction::reason"
    attrGet _ = getWebNavigationActionReason
    attrSet _ = setWebNavigationActionReason
    attrConstruct _ = constructWebNavigationActionReason

-- VVV Prop "target-frame"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]

getWebNavigationActionTargetFrame :: (MonadIO m, WebNavigationActionK o) => o -> m T.Text
getWebNavigationActionTargetFrame obj = liftIO $ getObjectPropertyString obj "target-frame"

constructWebNavigationActionTargetFrame :: T.Text -> IO ([Char], GValue)
constructWebNavigationActionTargetFrame val = constructObjectPropertyString "target-frame" val

data WebNavigationActionTargetFramePropertyInfo
instance AttrInfo WebNavigationActionTargetFramePropertyInfo where
    type AttrAllowedOps WebNavigationActionTargetFramePropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint WebNavigationActionTargetFramePropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint WebNavigationActionTargetFramePropertyInfo = WebNavigationActionK
    type AttrGetType WebNavigationActionTargetFramePropertyInfo = T.Text
    type AttrLabel WebNavigationActionTargetFramePropertyInfo = "WebNavigationAction::target-frame"
    attrGet _ = getWebNavigationActionTargetFrame
    attrSet _ = undefined
    attrConstruct _ = constructWebNavigationActionTargetFrame

type instance AttributeList WebNavigationAction = WebNavigationActionAttributeList
type WebNavigationActionAttributeList = ('[ '("button", WebNavigationActionButtonPropertyInfo), '("modifier-state", WebNavigationActionModifierStatePropertyInfo), '("original-uri", WebNavigationActionOriginalUriPropertyInfo), '("reason", WebNavigationActionReasonPropertyInfo), '("target-frame", WebNavigationActionTargetFramePropertyInfo)] :: [(Symbol, *)])

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

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

foreign import ccall "webkit_web_navigation_action_get_button" webkit_web_navigation_action_get_button :: 
    Ptr WebNavigationAction ->              -- _obj : TInterface "WebKit" "WebNavigationAction"
    IO Int32


webNavigationActionGetButton ::
    (MonadIO m, WebNavigationActionK a) =>
    a ->                                    -- _obj
    m Int32
webNavigationActionGetButton _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_web_navigation_action_get_button _obj'
    touchManagedPtr _obj
    return result

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

foreign import ccall "webkit_web_navigation_action_get_modifier_state" webkit_web_navigation_action_get_modifier_state :: 
    Ptr WebNavigationAction ->              -- _obj : TInterface "WebKit" "WebNavigationAction"
    IO Int32


webNavigationActionGetModifierState ::
    (MonadIO m, WebNavigationActionK a) =>
    a ->                                    -- _obj
    m Int32
webNavigationActionGetModifierState _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_web_navigation_action_get_modifier_state _obj'
    touchManagedPtr _obj
    return result

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


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

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

foreign import ccall "webkit_web_navigation_action_get_reason" webkit_web_navigation_action_get_reason :: 
    Ptr WebNavigationAction ->              -- _obj : TInterface "WebKit" "WebNavigationAction"
    IO CUInt


webNavigationActionGetReason ::
    (MonadIO m, WebNavigationActionK a) =>
    a ->                                    -- _obj
    m WebNavigationReason
webNavigationActionGetReason _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_web_navigation_action_get_reason _obj'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr _obj
    return result'

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


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

-- method WebNavigationAction::set_original_uri
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebNavigationAction", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "originalUri", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebNavigationAction", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "originalUri", argType = TBasicType TUTF8, 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_navigation_action_set_original_uri" webkit_web_navigation_action_set_original_uri :: 
    Ptr WebNavigationAction ->              -- _obj : TInterface "WebKit" "WebNavigationAction"
    CString ->                              -- originalUri : TBasicType TUTF8
    IO ()


webNavigationActionSetOriginalUri ::
    (MonadIO m, WebNavigationActionK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- originalUri
    m ()
webNavigationActionSetOriginalUri _obj originalUri = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    originalUri' <- textToCString originalUri
    webkit_web_navigation_action_set_original_uri _obj' originalUri'
    touchManagedPtr _obj
    freeMem originalUri'
    return ()

-- method WebNavigationAction::set_reason
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebNavigationAction", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "reason", argType = TInterface "WebKit" "WebNavigationReason", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebNavigationAction", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "reason", argType = TInterface "WebKit" "WebNavigationReason", 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_navigation_action_set_reason" webkit_web_navigation_action_set_reason :: 
    Ptr WebNavigationAction ->              -- _obj : TInterface "WebKit" "WebNavigationAction"
    CUInt ->                                -- reason : TInterface "WebKit" "WebNavigationReason"
    IO ()


webNavigationActionSetReason ::
    (MonadIO m, WebNavigationActionK a) =>
    a ->                                    -- _obj
    WebNavigationReason ->                  -- reason
    m ()
webNavigationActionSetReason _obj reason = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let reason' = (fromIntegral . fromEnum) reason
    webkit_web_navigation_action_set_reason _obj' reason'
    touchManagedPtr _obj
    return ()