{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc)

/No description available in the introspection data./
-}

#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
       && !defined(__HADDOCK_VERSION__))

module GI.WebKit2.Structs.NavigationAction
    (

-- * Exported types
    NavigationAction(..)                    ,
    noNavigationAction                      ,


 -- * Methods
-- ** copy #method:copy#

#if ENABLE_OVERLOADING
    NavigationActionCopyMethodInfo          ,
#endif
    navigationActionCopy                    ,


-- ** free #method:free#

#if ENABLE_OVERLOADING
    NavigationActionFreeMethodInfo          ,
#endif
    navigationActionFree                    ,


-- ** getModifiers #method:getModifiers#

#if ENABLE_OVERLOADING
    NavigationActionGetModifiersMethodInfo  ,
#endif
    navigationActionGetModifiers            ,


-- ** getMouseButton #method:getMouseButton#

#if ENABLE_OVERLOADING
    NavigationActionGetMouseButtonMethodInfo,
#endif
    navigationActionGetMouseButton          ,


-- ** getNavigationType #method:getNavigationType#

#if ENABLE_OVERLOADING
    NavigationActionGetNavigationTypeMethodInfo,
#endif
    navigationActionGetNavigationType       ,


-- ** getRequest #method:getRequest#

#if ENABLE_OVERLOADING
    NavigationActionGetRequestMethodInfo    ,
#endif
    navigationActionGetRequest              ,


-- ** isRedirect #method:isRedirect#

#if ENABLE_OVERLOADING
    NavigationActionIsRedirectMethodInfo    ,
#endif
    navigationActionIsRedirect              ,


-- ** isUserGesture #method:isUserGesture#

#if ENABLE_OVERLOADING
    NavigationActionIsUserGestureMethodInfo ,
#endif
    navigationActionIsUserGesture           ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL

import {-# SOURCE #-} qualified GI.WebKit2.Enums as WebKit2.Enums
import {-# SOURCE #-} qualified GI.WebKit2.Objects.URIRequest as WebKit2.URIRequest

-- | Memory-managed wrapper type.
newtype NavigationAction = NavigationAction (ManagedPtr NavigationAction)
foreign import ccall "webkit_navigation_action_get_type" c_webkit_navigation_action_get_type ::
    IO GType

instance BoxedObject NavigationAction where
    boxedType _ = c_webkit_navigation_action_get_type

-- | A convenience alias for `Nothing` :: `Maybe` `NavigationAction`.
noNavigationAction :: Maybe NavigationAction
noNavigationAction = Nothing


#if ENABLE_OVERLOADING
instance O.HasAttributeList NavigationAction
type instance O.AttributeList NavigationAction = NavigationActionAttributeList
type NavigationActionAttributeList = ('[ ] :: [(Symbol, *)])
#endif

-- method NavigationAction::copy
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "navigation", argType = TInterface (Name {namespace = "WebKit2", name = "NavigationAction"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitNavigationAction", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "WebKit2", name = "NavigationAction"}))
-- throws : False
-- Skip return : False

foreign import ccall "webkit_navigation_action_copy" webkit_navigation_action_copy ::
    Ptr NavigationAction ->                 -- navigation : TInterface (Name {namespace = "WebKit2", name = "NavigationAction"})
    IO (Ptr NavigationAction)

{- |
Make a copy of /@navigation@/.

/Since: 2.6/
-}
navigationActionCopy ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    NavigationAction
    {- ^ /@navigation@/: a 'GI.WebKit2.Structs.NavigationAction.NavigationAction' -}
    -> m NavigationAction
    {- ^ __Returns:__ A copy of passed in 'GI.WebKit2.Structs.NavigationAction.NavigationAction' -}
navigationActionCopy navigation = liftIO $ do
    navigation' <- unsafeManagedPtrGetPtr navigation
    result <- webkit_navigation_action_copy navigation'
    checkUnexpectedReturnNULL "navigationActionCopy" result
    result' <- (wrapBoxed NavigationAction) result
    touchManagedPtr navigation
    return result'

#if ENABLE_OVERLOADING
data NavigationActionCopyMethodInfo
instance (signature ~ (m NavigationAction), MonadIO m) => O.MethodInfo NavigationActionCopyMethodInfo NavigationAction signature where
    overloadedMethod _ = navigationActionCopy

#endif

-- method NavigationAction::free
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "navigation", argType = TInterface (Name {namespace = "WebKit2", name = "NavigationAction"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitNavigationAction", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "webkit_navigation_action_free" webkit_navigation_action_free ::
    Ptr NavigationAction ->                 -- navigation : TInterface (Name {namespace = "WebKit2", name = "NavigationAction"})
    IO ()

{- |
Free the 'GI.WebKit2.Structs.NavigationAction.NavigationAction'

/Since: 2.6/
-}
navigationActionFree ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    NavigationAction
    {- ^ /@navigation@/: a 'GI.WebKit2.Structs.NavigationAction.NavigationAction' -}
    -> m ()
navigationActionFree navigation = liftIO $ do
    navigation' <- unsafeManagedPtrGetPtr navigation
    webkit_navigation_action_free navigation'
    touchManagedPtr navigation
    return ()

#if ENABLE_OVERLOADING
data NavigationActionFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo NavigationActionFreeMethodInfo NavigationAction signature where
    overloadedMethod _ = navigationActionFree

#endif

-- method NavigationAction::get_modifiers
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "navigation", argType = TInterface (Name {namespace = "WebKit2", name = "NavigationAction"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitNavigationAction", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "webkit_navigation_action_get_modifiers" webkit_navigation_action_get_modifiers ::
    Ptr NavigationAction ->                 -- navigation : TInterface (Name {namespace = "WebKit2", name = "NavigationAction"})
    IO Word32

{- |
Return a bitmask of 'GI.Gdk.Flags.ModifierType' values describing the modifier keys that were in effect
when the navigation was requested

/Since: 2.6/
-}
navigationActionGetModifiers ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    NavigationAction
    {- ^ /@navigation@/: a 'GI.WebKit2.Structs.NavigationAction.NavigationAction' -}
    -> m Word32
    {- ^ __Returns:__ the modifier keys -}
navigationActionGetModifiers navigation = liftIO $ do
    navigation' <- unsafeManagedPtrGetPtr navigation
    result <- webkit_navigation_action_get_modifiers navigation'
    touchManagedPtr navigation
    return result

#if ENABLE_OVERLOADING
data NavigationActionGetModifiersMethodInfo
instance (signature ~ (m Word32), MonadIO m) => O.MethodInfo NavigationActionGetModifiersMethodInfo NavigationAction signature where
    overloadedMethod _ = navigationActionGetModifiers

#endif

-- method NavigationAction::get_mouse_button
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "navigation", argType = TInterface (Name {namespace = "WebKit2", name = "NavigationAction"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitNavigationAction", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "webkit_navigation_action_get_mouse_button" webkit_navigation_action_get_mouse_button ::
    Ptr NavigationAction ->                 -- navigation : TInterface (Name {namespace = "WebKit2", name = "NavigationAction"})
    IO Word32

{- |
Return the number of the mouse button that triggered the navigation, or 0 if
the navigation was not started by a mouse event.

/Since: 2.6/
-}
navigationActionGetMouseButton ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    NavigationAction
    {- ^ /@navigation@/: a 'GI.WebKit2.Structs.NavigationAction.NavigationAction' -}
    -> m Word32
    {- ^ __Returns:__ the mouse button number or 0 -}
navigationActionGetMouseButton navigation = liftIO $ do
    navigation' <- unsafeManagedPtrGetPtr navigation
    result <- webkit_navigation_action_get_mouse_button navigation'
    touchManagedPtr navigation
    return result

#if ENABLE_OVERLOADING
data NavigationActionGetMouseButtonMethodInfo
instance (signature ~ (m Word32), MonadIO m) => O.MethodInfo NavigationActionGetMouseButtonMethodInfo NavigationAction signature where
    overloadedMethod _ = navigationActionGetMouseButton

#endif

-- method NavigationAction::get_navigation_type
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "navigation", argType = TInterface (Name {namespace = "WebKit2", name = "NavigationAction"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitNavigationAction", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "WebKit2", name = "NavigationType"}))
-- throws : False
-- Skip return : False

foreign import ccall "webkit_navigation_action_get_navigation_type" webkit_navigation_action_get_navigation_type ::
    Ptr NavigationAction ->                 -- navigation : TInterface (Name {namespace = "WebKit2", name = "NavigationAction"})
    IO CUInt

{- |
Return the type of action that triggered the navigation.

/Since: 2.6/
-}
navigationActionGetNavigationType ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    NavigationAction
    {- ^ /@navigation@/: a 'GI.WebKit2.Structs.NavigationAction.NavigationAction' -}
    -> m WebKit2.Enums.NavigationType
    {- ^ __Returns:__ a 'GI.WebKit2.Enums.NavigationType' -}
navigationActionGetNavigationType navigation = liftIO $ do
    navigation' <- unsafeManagedPtrGetPtr navigation
    result <- webkit_navigation_action_get_navigation_type navigation'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr navigation
    return result'

#if ENABLE_OVERLOADING
data NavigationActionGetNavigationTypeMethodInfo
instance (signature ~ (m WebKit2.Enums.NavigationType), MonadIO m) => O.MethodInfo NavigationActionGetNavigationTypeMethodInfo NavigationAction signature where
    overloadedMethod _ = navigationActionGetNavigationType

#endif

-- method NavigationAction::get_request
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "navigation", argType = TInterface (Name {namespace = "WebKit2", name = "NavigationAction"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitNavigationAction", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "WebKit2", name = "URIRequest"}))
-- throws : False
-- Skip return : False

foreign import ccall "webkit_navigation_action_get_request" webkit_navigation_action_get_request ::
    Ptr NavigationAction ->                 -- navigation : TInterface (Name {namespace = "WebKit2", name = "NavigationAction"})
    IO (Ptr WebKit2.URIRequest.URIRequest)

{- |
Return the 'GI.WebKit2.Objects.URIRequest.URIRequest' associated with the navigation action.
Modifications to the returned object are \<emphasis>not\<\/emphasis> taken
into account when the request is sent over the network, and is intended
only to aid in evaluating whether a navigation action should be taken or
not. To modify requests before they are sent over the network the
@/WebKitPage::send-request/@ signal can be used instead.

/Since: 2.6/
-}
navigationActionGetRequest ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    NavigationAction
    {- ^ /@navigation@/: a 'GI.WebKit2.Structs.NavigationAction.NavigationAction' -}
    -> m WebKit2.URIRequest.URIRequest
    {- ^ __Returns:__ a 'GI.WebKit2.Objects.URIRequest.URIRequest' -}
navigationActionGetRequest navigation = liftIO $ do
    navigation' <- unsafeManagedPtrGetPtr navigation
    result <- webkit_navigation_action_get_request navigation'
    checkUnexpectedReturnNULL "navigationActionGetRequest" result
    result' <- (newObject WebKit2.URIRequest.URIRequest) result
    touchManagedPtr navigation
    return result'

#if ENABLE_OVERLOADING
data NavigationActionGetRequestMethodInfo
instance (signature ~ (m WebKit2.URIRequest.URIRequest), MonadIO m) => O.MethodInfo NavigationActionGetRequestMethodInfo NavigationAction signature where
    overloadedMethod _ = navigationActionGetRequest

#endif

-- method NavigationAction::is_redirect
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "navigation", argType = TInterface (Name {namespace = "WebKit2", name = "NavigationAction"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitNavigationAction", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "webkit_navigation_action_is_redirect" webkit_navigation_action_is_redirect ::
    Ptr NavigationAction ->                 -- navigation : TInterface (Name {namespace = "WebKit2", name = "NavigationAction"})
    IO CInt

{- |
Returns whether the /@navigation@/ was redirected.

/Since: 2.20/
-}
navigationActionIsRedirect ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    NavigationAction
    {- ^ /@navigation@/: a 'GI.WebKit2.Structs.NavigationAction.NavigationAction' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the original navigation was redirected, 'False' otherwise. -}
navigationActionIsRedirect navigation = liftIO $ do
    navigation' <- unsafeManagedPtrGetPtr navigation
    result <- webkit_navigation_action_is_redirect navigation'
    let result' = (/= 0) result
    touchManagedPtr navigation
    return result'

#if ENABLE_OVERLOADING
data NavigationActionIsRedirectMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo NavigationActionIsRedirectMethodInfo NavigationAction signature where
    overloadedMethod _ = navigationActionIsRedirect

#endif

-- method NavigationAction::is_user_gesture
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "navigation", argType = TInterface (Name {namespace = "WebKit2", name = "NavigationAction"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitNavigationAction", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "webkit_navigation_action_is_user_gesture" webkit_navigation_action_is_user_gesture ::
    Ptr NavigationAction ->                 -- navigation : TInterface (Name {namespace = "WebKit2", name = "NavigationAction"})
    IO CInt

{- |
Return whether the navigation was triggered by a user gesture like a mouse click.

/Since: 2.6/
-}
navigationActionIsUserGesture ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    NavigationAction
    {- ^ /@navigation@/: a 'GI.WebKit2.Structs.NavigationAction.NavigationAction' -}
    -> m Bool
    {- ^ __Returns:__ whether navigation action is a user gesture -}
navigationActionIsUserGesture navigation = liftIO $ do
    navigation' <- unsafeManagedPtrGetPtr navigation
    result <- webkit_navigation_action_is_user_gesture navigation'
    let result' = (/= 0) result
    touchManagedPtr navigation
    return result'

#if ENABLE_OVERLOADING
data NavigationActionIsUserGestureMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo NavigationActionIsUserGestureMethodInfo NavigationAction signature where
    overloadedMethod _ = navigationActionIsUserGesture

#endif

#if ENABLE_OVERLOADING
type family ResolveNavigationActionMethod (t :: Symbol) (o :: *) :: * where
    ResolveNavigationActionMethod "copy" o = NavigationActionCopyMethodInfo
    ResolveNavigationActionMethod "free" o = NavigationActionFreeMethodInfo
    ResolveNavigationActionMethod "isRedirect" o = NavigationActionIsRedirectMethodInfo
    ResolveNavigationActionMethod "isUserGesture" o = NavigationActionIsUserGestureMethodInfo
    ResolveNavigationActionMethod "getModifiers" o = NavigationActionGetModifiersMethodInfo
    ResolveNavigationActionMethod "getMouseButton" o = NavigationActionGetMouseButtonMethodInfo
    ResolveNavigationActionMethod "getNavigationType" o = NavigationActionGetNavigationTypeMethodInfo
    ResolveNavigationActionMethod "getRequest" o = NavigationActionGetRequestMethodInfo
    ResolveNavigationActionMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveNavigationActionMethod t NavigationAction, O.MethodInfo info NavigationAction p) => OL.IsLabel t (NavigationAction -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

#endif