{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- One item of a t'GI.WebKit2.Objects.ContextMenu.ContextMenu'.
-- 
-- The t'GI.WebKit2.Objects.ContextMenu.ContextMenu' is composed of t'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem's. These items can be created from a t'GI.Gtk.Objects.Action.Action', from a
-- t'GI.WebKit2.Enums.ContextMenuAction' or from a t'GI.WebKit2.Enums.ContextMenuAction' and a
-- label. These t'GI.WebKit2.Enums.ContextMenuAction's denote stock actions
-- for the items. You can also create separators and submenus.

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

module GI.WebKit2.Objects.ContextMenuItem
    ( 

-- * Exported types
    ContextMenuItem(..)                     ,
    IsContextMenuItem                       ,
    toContextMenuItem                       ,


 -- * Methods
-- | 
-- 
--  === __Click to display all available methods, including inherited ones__
-- ==== Methods
-- [bindProperty]("GI.GObject.Objects.Object#g:method:bindProperty"), [bindPropertyFull]("GI.GObject.Objects.Object#g:method:bindPropertyFull"), [forceFloating]("GI.GObject.Objects.Object#g:method:forceFloating"), [freezeNotify]("GI.GObject.Objects.Object#g:method:freezeNotify"), [getv]("GI.GObject.Objects.Object#g:method:getv"), [isFloating]("GI.GObject.Objects.Object#g:method:isFloating"), [isSeparator]("GI.WebKit2.Objects.ContextMenuItem#g:method:isSeparator"), [notify]("GI.GObject.Objects.Object#g:method:notify"), [notifyByPspec]("GI.GObject.Objects.Object#g:method:notifyByPspec"), [ref]("GI.GObject.Objects.Object#g:method:ref"), [refSink]("GI.GObject.Objects.Object#g:method:refSink"), [runDispose]("GI.GObject.Objects.Object#g:method:runDispose"), [stealData]("GI.GObject.Objects.Object#g:method:stealData"), [stealQdata]("GI.GObject.Objects.Object#g:method:stealQdata"), [thawNotify]("GI.GObject.Objects.Object#g:method:thawNotify"), [unref]("GI.GObject.Objects.Object#g:method:unref"), [watchClosure]("GI.GObject.Objects.Object#g:method:watchClosure").
-- 
-- ==== Getters
-- [getAction]("GI.WebKit2.Objects.ContextMenuItem#g:method:getAction"), [getData]("GI.GObject.Objects.Object#g:method:getData"), [getGaction]("GI.WebKit2.Objects.ContextMenuItem#g:method:getGaction"), [getProperty]("GI.GObject.Objects.Object#g:method:getProperty"), [getQdata]("GI.GObject.Objects.Object#g:method:getQdata"), [getStockAction]("GI.WebKit2.Objects.ContextMenuItem#g:method:getStockAction"), [getSubmenu]("GI.WebKit2.Objects.ContextMenuItem#g:method:getSubmenu").
-- 
-- ==== Setters
-- [setData]("GI.GObject.Objects.Object#g:method:setData"), [setDataFull]("GI.GObject.Objects.Object#g:method:setDataFull"), [setProperty]("GI.GObject.Objects.Object#g:method:setProperty"), [setSubmenu]("GI.WebKit2.Objects.ContextMenuItem#g:method:setSubmenu").

#if defined(ENABLE_OVERLOADING)
    ResolveContextMenuItemMethod            ,
#endif

-- ** getAction #method:getAction#

#if defined(ENABLE_OVERLOADING)
    ContextMenuItemGetActionMethodInfo      ,
#endif
    contextMenuItemGetAction                ,


-- ** getGaction #method:getGaction#

#if defined(ENABLE_OVERLOADING)
    ContextMenuItemGetGactionMethodInfo     ,
#endif
    contextMenuItemGetGaction               ,


-- ** getStockAction #method:getStockAction#

#if defined(ENABLE_OVERLOADING)
    ContextMenuItemGetStockActionMethodInfo ,
#endif
    contextMenuItemGetStockAction           ,


-- ** getSubmenu #method:getSubmenu#

#if defined(ENABLE_OVERLOADING)
    ContextMenuItemGetSubmenuMethodInfo     ,
#endif
    contextMenuItemGetSubmenu               ,


-- ** isSeparator #method:isSeparator#

#if defined(ENABLE_OVERLOADING)
    ContextMenuItemIsSeparatorMethodInfo    ,
#endif
    contextMenuItemIsSeparator              ,


-- ** new #method:new#

    contextMenuItemNew                      ,


-- ** newFromGaction #method:newFromGaction#

    contextMenuItemNewFromGaction           ,


-- ** newFromStockAction #method:newFromStockAction#

    contextMenuItemNewFromStockAction       ,


-- ** newFromStockActionWithLabel #method:newFromStockActionWithLabel#

    contextMenuItemNewFromStockActionWithLabel,


-- ** newSeparator #method:newSeparator#

    contextMenuItemNewSeparator             ,


-- ** newWithSubmenu #method:newWithSubmenu#

    contextMenuItemNewWithSubmenu           ,


-- ** setSubmenu #method:setSubmenu#

#if defined(ENABLE_OVERLOADING)
    ContextMenuItemSetSubmenuMethodInfo     ,
#endif
    contextMenuItemSetSubmenu               ,




    ) 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.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GHashTable as B.GHT
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.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
import qualified Data.Coerce as Coerce
import qualified Data.Text as T
import qualified Data.Kind as DK
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 qualified GHC.Records as R

import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Interfaces.Action as Gio.Action
import qualified GI.Gtk.Objects.Action as Gtk.Action
import {-# SOURCE #-} qualified GI.WebKit2.Enums as WebKit2.Enums
import {-# SOURCE #-} qualified GI.WebKit2.Objects.ContextMenu as WebKit2.ContextMenu

-- | Memory-managed wrapper type.
newtype ContextMenuItem = ContextMenuItem (SP.ManagedPtr ContextMenuItem)
    deriving (ContextMenuItem -> ContextMenuItem -> Bool
(ContextMenuItem -> ContextMenuItem -> Bool)
-> (ContextMenuItem -> ContextMenuItem -> Bool)
-> Eq ContextMenuItem
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ContextMenuItem -> ContextMenuItem -> Bool
== :: ContextMenuItem -> ContextMenuItem -> Bool
$c/= :: ContextMenuItem -> ContextMenuItem -> Bool
/= :: ContextMenuItem -> ContextMenuItem -> Bool
Eq)

instance SP.ManagedPtrNewtype ContextMenuItem where
    toManagedPtr :: ContextMenuItem -> ManagedPtr ContextMenuItem
toManagedPtr (ContextMenuItem ManagedPtr ContextMenuItem
p) = ManagedPtr ContextMenuItem
p

foreign import ccall "webkit_context_menu_item_get_type"
    c_webkit_context_menu_item_get_type :: IO B.Types.GType

instance B.Types.TypedObject ContextMenuItem where
    glibType :: IO GType
glibType = IO GType
c_webkit_context_menu_item_get_type

instance B.Types.GObject ContextMenuItem

-- | Type class for types which can be safely cast to `ContextMenuItem`, for instance with `toContextMenuItem`.
class (SP.GObject o, O.IsDescendantOf ContextMenuItem o) => IsContextMenuItem o
instance (SP.GObject o, O.IsDescendantOf ContextMenuItem o) => IsContextMenuItem o

instance O.HasParentTypes ContextMenuItem
type instance O.ParentTypes ContextMenuItem = '[GObject.Object.Object]

-- | Cast to `ContextMenuItem`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toContextMenuItem :: (MIO.MonadIO m, IsContextMenuItem o) => o -> m ContextMenuItem
toContextMenuItem :: forall (m :: * -> *) o.
(MonadIO m, IsContextMenuItem o) =>
o -> m ContextMenuItem
toContextMenuItem = IO ContextMenuItem -> m ContextMenuItem
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO ContextMenuItem -> m ContextMenuItem)
-> (o -> IO ContextMenuItem) -> o -> m ContextMenuItem
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr ContextMenuItem -> ContextMenuItem)
-> o -> IO ContextMenuItem
forall o o'.
(HasCallStack, ManagedPtrNewtype o, TypedObject o,
 ManagedPtrNewtype o', TypedObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
B.ManagedPtr.unsafeCastTo ManagedPtr ContextMenuItem -> ContextMenuItem
ContextMenuItem

-- | Convert 'ContextMenuItem' to and from 'Data.GI.Base.GValue.GValue'. See 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue (Maybe ContextMenuItem) where
    gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_webkit_context_menu_item_get_type
    gvalueSet_ :: Ptr GValue -> Maybe ContextMenuItem -> IO ()
gvalueSet_ Ptr GValue
gv Maybe ContextMenuItem
P.Nothing = Ptr GValue -> Ptr ContextMenuItem -> IO ()
forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv (Ptr ContextMenuItem
forall a. Ptr a
FP.nullPtr :: FP.Ptr ContextMenuItem)
    gvalueSet_ Ptr GValue
gv (P.Just ContextMenuItem
obj) = ContextMenuItem -> (Ptr ContextMenuItem -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr ContextMenuItem
obj (Ptr GValue -> Ptr ContextMenuItem -> IO ()
forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv)
    gvalueGet_ :: Ptr GValue -> IO (Maybe ContextMenuItem)
gvalueGet_ Ptr GValue
gv = do
        Ptr ContextMenuItem
ptr <- Ptr GValue -> IO (Ptr ContextMenuItem)
forall a. GObject a => Ptr GValue -> IO (Ptr a)
B.GValue.get_object Ptr GValue
gv :: IO (FP.Ptr ContextMenuItem)
        if Ptr ContextMenuItem
ptr Ptr ContextMenuItem -> Ptr ContextMenuItem -> Bool
forall a. Eq a => a -> a -> Bool
/= Ptr ContextMenuItem
forall a. Ptr a
FP.nullPtr
        then ContextMenuItem -> Maybe ContextMenuItem
forall a. a -> Maybe a
P.Just (ContextMenuItem -> Maybe ContextMenuItem)
-> IO ContextMenuItem -> IO (Maybe ContextMenuItem)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ManagedPtr ContextMenuItem -> ContextMenuItem)
-> Ptr ContextMenuItem -> IO ContextMenuItem
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr ContextMenuItem -> ContextMenuItem
ContextMenuItem Ptr ContextMenuItem
ptr
        else Maybe ContextMenuItem -> IO (Maybe ContextMenuItem)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe ContextMenuItem
forall a. Maybe a
P.Nothing
        
    

#if defined(ENABLE_OVERLOADING)
type family ResolveContextMenuItemMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
    ResolveContextMenuItemMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveContextMenuItemMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveContextMenuItemMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveContextMenuItemMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveContextMenuItemMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveContextMenuItemMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveContextMenuItemMethod "isSeparator" o = ContextMenuItemIsSeparatorMethodInfo
    ResolveContextMenuItemMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveContextMenuItemMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveContextMenuItemMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveContextMenuItemMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveContextMenuItemMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveContextMenuItemMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveContextMenuItemMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveContextMenuItemMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveContextMenuItemMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveContextMenuItemMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveContextMenuItemMethod "getAction" o = ContextMenuItemGetActionMethodInfo
    ResolveContextMenuItemMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveContextMenuItemMethod "getGaction" o = ContextMenuItemGetGactionMethodInfo
    ResolveContextMenuItemMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveContextMenuItemMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveContextMenuItemMethod "getStockAction" o = ContextMenuItemGetStockActionMethodInfo
    ResolveContextMenuItemMethod "getSubmenu" o = ContextMenuItemGetSubmenuMethodInfo
    ResolveContextMenuItemMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveContextMenuItemMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveContextMenuItemMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveContextMenuItemMethod "setSubmenu" o = ContextMenuItemSetSubmenuMethodInfo
    ResolveContextMenuItemMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveContextMenuItemMethod t ContextMenuItem, O.OverloadedMethod info ContextMenuItem p) => OL.IsLabel t (ContextMenuItem -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolveContextMenuItemMethod t ContextMenuItem, O.OverloadedMethod info ContextMenuItem p, R.HasField t ContextMenuItem p) => R.HasField t ContextMenuItem p where
    getField = O.overloadedMethod @info

#endif

instance (info ~ ResolveContextMenuItemMethod t ContextMenuItem, O.OverloadedMethodInfo info ContextMenuItem) => OL.IsLabel t (O.MethodProxy info ContextMenuItem) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.MethodProxy
#else
    fromLabel _ = O.MethodProxy
#endif

#endif

#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList ContextMenuItem
type instance O.AttributeList ContextMenuItem = ContextMenuItemAttributeList
type ContextMenuItemAttributeList = ('[ ] :: [(Symbol, DK.Type)])
#endif

#if defined(ENABLE_OVERLOADING)
#endif

#if defined(ENABLE_OVERLOADING)
type instance O.SignalList ContextMenuItem = ContextMenuItemSignalList
type ContextMenuItemSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, DK.Type)])

#endif

-- method ContextMenuItem::new
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "action"
--           , argType = TInterface Name { namespace = "Gtk" , name = "Action" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GtkAction" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface
--                  Name { namespace = "WebKit2" , name = "ContextMenuItem" })
-- throws : False
-- Skip return : False

foreign import ccall "webkit_context_menu_item_new" webkit_context_menu_item_new :: 
    Ptr Gtk.Action.Action ->                -- action : TInterface (Name {namespace = "Gtk", name = "Action"})
    IO (Ptr ContextMenuItem)

{-# DEPRECATED contextMenuItemNew ["(Since version 2.18)","Use 'GI.WebKit2.Objects.ContextMenuItem.contextMenuItemNewFromGaction' instead."] #-}
-- | Creates a new t'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem' for the given /@action@/.
contextMenuItemNew ::
    (B.CallStack.HasCallStack, MonadIO m, Gtk.Action.IsAction a) =>
    a
    -- ^ /@action@/: a t'GI.Gtk.Objects.Action.Action'
    -> m ContextMenuItem
    -- ^ __Returns:__ the newly created t'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem' object.
contextMenuItemNew :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsAction a) =>
a -> m ContextMenuItem
contextMenuItemNew a
action = IO ContextMenuItem -> m ContextMenuItem
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ContextMenuItem -> m ContextMenuItem)
-> IO ContextMenuItem -> m ContextMenuItem
forall a b. (a -> b) -> a -> b
$ do
    Ptr Action
action' <- a -> IO (Ptr Action)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
action
    Ptr ContextMenuItem
result <- Ptr Action -> IO (Ptr ContextMenuItem)
webkit_context_menu_item_new Ptr Action
action'
    Text -> Ptr ContextMenuItem -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"contextMenuItemNew" Ptr ContextMenuItem
result
    ContextMenuItem
result' <- ((ManagedPtr ContextMenuItem -> ContextMenuItem)
-> Ptr ContextMenuItem -> IO ContextMenuItem
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr ContextMenuItem -> ContextMenuItem
ContextMenuItem) Ptr ContextMenuItem
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
action
    ContextMenuItem -> IO ContextMenuItem
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ContextMenuItem
result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method ContextMenuItem::new_from_gaction
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "action"
--           , argType = TInterface Name { namespace = "Gio" , name = "Action" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GAction" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "label"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the menu item label text"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "target"
--           , argType = TVariant
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GVariant to use as the action target"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface
--                  Name { namespace = "WebKit2" , name = "ContextMenuItem" })
-- throws : False
-- Skip return : False

foreign import ccall "webkit_context_menu_item_new_from_gaction" webkit_context_menu_item_new_from_gaction :: 
    Ptr Gio.Action.Action ->                -- action : TInterface (Name {namespace = "Gio", name = "Action"})
    CString ->                              -- label : TBasicType TUTF8
    Ptr GVariant ->                         -- target : TVariant
    IO (Ptr ContextMenuItem)

-- | Creates a new t'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem' for the given /@action@/ and /@label@/.
-- 
-- On activation
-- /@target@/ will be passed as parameter to the callback.
-- 
-- /Since: 2.18/
contextMenuItemNewFromGaction ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.Action.IsAction a) =>
    a
    -- ^ /@action@/: a t'GI.Gio.Interfaces.Action.Action'
    -> T.Text
    -- ^ /@label@/: the menu item label text
    -> Maybe (GVariant)
    -- ^ /@target@/: a t'GVariant' to use as the action target
    -> m ContextMenuItem
    -- ^ __Returns:__ the newly created t'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem' object.
contextMenuItemNewFromGaction :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsAction a) =>
a -> Text -> Maybe GVariant -> m ContextMenuItem
contextMenuItemNewFromGaction a
action Text
label Maybe GVariant
target = IO ContextMenuItem -> m ContextMenuItem
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ContextMenuItem -> m ContextMenuItem)
-> IO ContextMenuItem -> m ContextMenuItem
forall a b. (a -> b) -> a -> b
$ do
    Ptr Action
action' <- a -> IO (Ptr Action)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
action
    CString
label' <- Text -> IO CString
textToCString Text
label
    Ptr GVariant
maybeTarget <- case Maybe GVariant
target of
        Maybe GVariant
Nothing -> Ptr GVariant -> IO (Ptr GVariant)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr GVariant
forall a. Ptr a
nullPtr
        Just GVariant
jTarget -> do
            Ptr GVariant
jTarget' <- GVariant -> IO (Ptr GVariant)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr GVariant
jTarget
            Ptr GVariant -> IO (Ptr GVariant)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr GVariant
jTarget'
    Ptr ContextMenuItem
result <- Ptr Action -> CString -> Ptr GVariant -> IO (Ptr ContextMenuItem)
webkit_context_menu_item_new_from_gaction Ptr Action
action' CString
label' Ptr GVariant
maybeTarget
    Text -> Ptr ContextMenuItem -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"contextMenuItemNewFromGaction" Ptr ContextMenuItem
result
    ContextMenuItem
result' <- ((ManagedPtr ContextMenuItem -> ContextMenuItem)
-> Ptr ContextMenuItem -> IO ContextMenuItem
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr ContextMenuItem -> ContextMenuItem
ContextMenuItem) Ptr ContextMenuItem
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
action
    Maybe GVariant -> (GVariant -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe GVariant
target GVariant -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
label'
    ContextMenuItem -> IO ContextMenuItem
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ContextMenuItem
result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method ContextMenuItem::new_from_stock_action
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "action"
--           , argType =
--               TInterface
--                 Name { namespace = "WebKit2" , name = "ContextMenuAction" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #WebKitContextMenuAction stock action"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface
--                  Name { namespace = "WebKit2" , name = "ContextMenuItem" })
-- throws : False
-- Skip return : False

foreign import ccall "webkit_context_menu_item_new_from_stock_action" webkit_context_menu_item_new_from_stock_action :: 
    CUInt ->                                -- action : TInterface (Name {namespace = "WebKit2", name = "ContextMenuAction"})
    IO (Ptr ContextMenuItem)

-- | Creates a new t'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem' for the given stock action.
-- 
-- Stock actions are handled automatically by WebKit so that, for example,
-- when a menu item created with a 'GI.WebKit2.Enums.ContextMenuActionStop' is
-- activated the action associated will be handled by WebKit and the current
-- load operation will be stopped. You can get the t'GI.Gio.Interfaces.Action.Action' of a
-- t'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem' created with a t'GI.WebKit2.Enums.ContextMenuAction' with
-- 'GI.WebKit2.Objects.ContextMenuItem.contextMenuItemGetGaction' and connect to the [SimpleAction::activate]("GI.Gio.Objects.SimpleAction#g:signal:activate") signal
-- to be notified when the item is activated, but you can\'t prevent the associated
-- action from being performed.
contextMenuItemNewFromStockAction ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    WebKit2.Enums.ContextMenuAction
    -- ^ /@action@/: a t'GI.WebKit2.Enums.ContextMenuAction' stock action
    -> m ContextMenuItem
    -- ^ __Returns:__ the newly created t'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem' object.
contextMenuItemNewFromStockAction :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
ContextMenuAction -> m ContextMenuItem
contextMenuItemNewFromStockAction ContextMenuAction
action = IO ContextMenuItem -> m ContextMenuItem
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ContextMenuItem -> m ContextMenuItem)
-> IO ContextMenuItem -> m ContextMenuItem
forall a b. (a -> b) -> a -> b
$ do
    let action' :: CUInt
action' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt)
-> (ContextMenuAction -> Int) -> ContextMenuAction -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContextMenuAction -> Int
forall a. Enum a => a -> Int
fromEnum) ContextMenuAction
action
    Ptr ContextMenuItem
result <- CUInt -> IO (Ptr ContextMenuItem)
webkit_context_menu_item_new_from_stock_action CUInt
action'
    Text -> Ptr ContextMenuItem -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"contextMenuItemNewFromStockAction" Ptr ContextMenuItem
result
    ContextMenuItem
result' <- ((ManagedPtr ContextMenuItem -> ContextMenuItem)
-> Ptr ContextMenuItem -> IO ContextMenuItem
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr ContextMenuItem -> ContextMenuItem
ContextMenuItem) Ptr ContextMenuItem
result
    ContextMenuItem -> IO ContextMenuItem
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ContextMenuItem
result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method ContextMenuItem::new_from_stock_action_with_label
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "action"
--           , argType =
--               TInterface
--                 Name { namespace = "WebKit2" , name = "ContextMenuAction" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #WebKitContextMenuAction stock action"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "label"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "a custom label text to use instead of the predefined one"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface
--                  Name { namespace = "WebKit2" , name = "ContextMenuItem" })
-- throws : False
-- Skip return : False

foreign import ccall "webkit_context_menu_item_new_from_stock_action_with_label" webkit_context_menu_item_new_from_stock_action_with_label :: 
    CUInt ->                                -- action : TInterface (Name {namespace = "WebKit2", name = "ContextMenuAction"})
    CString ->                              -- label : TBasicType TUTF8
    IO (Ptr ContextMenuItem)

-- | Creates a new t'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem' for the given stock action using the given /@label@/.
-- 
-- Stock actions have a predefined label, this method can be used to create a
-- t'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem' for a t'GI.WebKit2.Enums.ContextMenuAction' but using a custom label.
contextMenuItemNewFromStockActionWithLabel ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    WebKit2.Enums.ContextMenuAction
    -- ^ /@action@/: a t'GI.WebKit2.Enums.ContextMenuAction' stock action
    -> T.Text
    -- ^ /@label@/: a custom label text to use instead of the predefined one
    -> m ContextMenuItem
    -- ^ __Returns:__ the newly created t'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem' object.
contextMenuItemNewFromStockActionWithLabel :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
ContextMenuAction -> Text -> m ContextMenuItem
contextMenuItemNewFromStockActionWithLabel ContextMenuAction
action Text
label = IO ContextMenuItem -> m ContextMenuItem
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ContextMenuItem -> m ContextMenuItem)
-> IO ContextMenuItem -> m ContextMenuItem
forall a b. (a -> b) -> a -> b
$ do
    let action' :: CUInt
action' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt)
-> (ContextMenuAction -> Int) -> ContextMenuAction -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContextMenuAction -> Int
forall a. Enum a => a -> Int
fromEnum) ContextMenuAction
action
    CString
label' <- Text -> IO CString
textToCString Text
label
    Ptr ContextMenuItem
result <- CUInt -> CString -> IO (Ptr ContextMenuItem)
webkit_context_menu_item_new_from_stock_action_with_label CUInt
action' CString
label'
    Text -> Ptr ContextMenuItem -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"contextMenuItemNewFromStockActionWithLabel" Ptr ContextMenuItem
result
    ContextMenuItem
result' <- ((ManagedPtr ContextMenuItem -> ContextMenuItem)
-> Ptr ContextMenuItem -> IO ContextMenuItem
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr ContextMenuItem -> ContextMenuItem
ContextMenuItem) Ptr ContextMenuItem
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
label'
    ContextMenuItem -> IO ContextMenuItem
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ContextMenuItem
result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method ContextMenuItem::new_separator
-- method type : Constructor
-- Args: []
-- Lengths: []
-- returnType: Just
--               (TInterface
--                  Name { namespace = "WebKit2" , name = "ContextMenuItem" })
-- throws : False
-- Skip return : False

foreign import ccall "webkit_context_menu_item_new_separator" webkit_context_menu_item_new_separator :: 
    IO (Ptr ContextMenuItem)

-- | Creates a new t'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem' representing a separator.
contextMenuItemNewSeparator ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m ContextMenuItem
    -- ^ __Returns:__ the newly created t'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem' object.
contextMenuItemNewSeparator :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
m ContextMenuItem
contextMenuItemNewSeparator  = IO ContextMenuItem -> m ContextMenuItem
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ContextMenuItem -> m ContextMenuItem)
-> IO ContextMenuItem -> m ContextMenuItem
forall a b. (a -> b) -> a -> b
$ do
    Ptr ContextMenuItem
result <- IO (Ptr ContextMenuItem)
webkit_context_menu_item_new_separator
    Text -> Ptr ContextMenuItem -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"contextMenuItemNewSeparator" Ptr ContextMenuItem
result
    ContextMenuItem
result' <- ((ManagedPtr ContextMenuItem -> ContextMenuItem)
-> Ptr ContextMenuItem -> IO ContextMenuItem
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr ContextMenuItem -> ContextMenuItem
ContextMenuItem) Ptr ContextMenuItem
result
    ContextMenuItem -> IO ContextMenuItem
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ContextMenuItem
result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method ContextMenuItem::new_with_submenu
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "label"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the menu item label text"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "submenu"
--           , argType =
--               TInterface Name { namespace = "WebKit2" , name = "ContextMenu" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #WebKitContextMenu to set"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface
--                  Name { namespace = "WebKit2" , name = "ContextMenuItem" })
-- throws : False
-- Skip return : False

foreign import ccall "webkit_context_menu_item_new_with_submenu" webkit_context_menu_item_new_with_submenu :: 
    CString ->                              -- label : TBasicType TUTF8
    Ptr WebKit2.ContextMenu.ContextMenu ->  -- submenu : TInterface (Name {namespace = "WebKit2", name = "ContextMenu"})
    IO (Ptr ContextMenuItem)

-- | Creates a new t'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem' using the given /@label@/ with a submenu.
contextMenuItemNewWithSubmenu ::
    (B.CallStack.HasCallStack, MonadIO m, WebKit2.ContextMenu.IsContextMenu a) =>
    T.Text
    -- ^ /@label@/: the menu item label text
    -> a
    -- ^ /@submenu@/: a t'GI.WebKit2.Objects.ContextMenu.ContextMenu' to set
    -> m ContextMenuItem
    -- ^ __Returns:__ the newly created t'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem' object.
contextMenuItemNewWithSubmenu :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsContextMenu a) =>
Text -> a -> m ContextMenuItem
contextMenuItemNewWithSubmenu Text
label a
submenu = IO ContextMenuItem -> m ContextMenuItem
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ContextMenuItem -> m ContextMenuItem)
-> IO ContextMenuItem -> m ContextMenuItem
forall a b. (a -> b) -> a -> b
$ do
    CString
label' <- Text -> IO CString
textToCString Text
label
    Ptr ContextMenu
submenu' <- a -> IO (Ptr ContextMenu)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
submenu
    Ptr ContextMenuItem
result <- CString -> Ptr ContextMenu -> IO (Ptr ContextMenuItem)
webkit_context_menu_item_new_with_submenu CString
label' Ptr ContextMenu
submenu'
    Text -> Ptr ContextMenuItem -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"contextMenuItemNewWithSubmenu" Ptr ContextMenuItem
result
    ContextMenuItem
result' <- ((ManagedPtr ContextMenuItem -> ContextMenuItem)
-> Ptr ContextMenuItem -> IO ContextMenuItem
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr ContextMenuItem -> ContextMenuItem
ContextMenuItem) Ptr ContextMenuItem
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
submenu
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
label'
    ContextMenuItem -> IO ContextMenuItem
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ContextMenuItem
result'

#if defined(ENABLE_OVERLOADING)
#endif

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

foreign import ccall "webkit_context_menu_item_get_action" webkit_context_menu_item_get_action :: 
    Ptr ContextMenuItem ->                  -- item : TInterface (Name {namespace = "WebKit2", name = "ContextMenuItem"})
    IO (Ptr Gtk.Action.Action)

{-# DEPRECATED contextMenuItemGetAction ["(Since version 2.18)","Use 'GI.WebKit2.Objects.ContextMenuItem.contextMenuItemGetGaction' instead."] #-}
-- | Gets the action associated to /@item@/ as a t'GI.Gtk.Objects.Action.Action'.
contextMenuItemGetAction ::
    (B.CallStack.HasCallStack, MonadIO m, IsContextMenuItem a) =>
    a
    -- ^ /@item@/: a t'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem'
    -> m (Maybe Gtk.Action.Action)
    -- ^ __Returns:__ the t'GI.Gtk.Objects.Action.Action' associated to the t'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem',
    --    or 'P.Nothing' if /@item@/ is a separator.
contextMenuItemGetAction :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsContextMenuItem a) =>
a -> m (Maybe Action)
contextMenuItemGetAction a
item = IO (Maybe Action) -> m (Maybe Action)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Action) -> m (Maybe Action))
-> IO (Maybe Action) -> m (Maybe Action)
forall a b. (a -> b) -> a -> b
$ do
    Ptr ContextMenuItem
item' <- a -> IO (Ptr ContextMenuItem)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
item
    Ptr Action
result <- Ptr ContextMenuItem -> IO (Ptr Action)
webkit_context_menu_item_get_action Ptr ContextMenuItem
item'
    Maybe Action
maybeResult <- Ptr Action -> (Ptr Action -> IO Action) -> IO (Maybe Action)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Action
result ((Ptr Action -> IO Action) -> IO (Maybe Action))
-> (Ptr Action -> IO Action) -> IO (Maybe Action)
forall a b. (a -> b) -> a -> b
$ \Ptr Action
result' -> do
        Action
result'' <- ((ManagedPtr Action -> Action) -> Ptr Action -> IO Action
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr Action -> Action
Gtk.Action.Action) Ptr Action
result'
        Action -> IO Action
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Action
result''
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
item
    Maybe Action -> IO (Maybe Action)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Action
maybeResult

#if defined(ENABLE_OVERLOADING)
data ContextMenuItemGetActionMethodInfo
instance (signature ~ (m (Maybe Gtk.Action.Action)), MonadIO m, IsContextMenuItem a) => O.OverloadedMethod ContextMenuItemGetActionMethodInfo a signature where
    overloadedMethod = contextMenuItemGetAction

instance O.OverloadedMethodInfo ContextMenuItemGetActionMethodInfo a where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.WebKit2.Objects.ContextMenuItem.contextMenuItemGetAction",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-webkit2-4.0.30/docs/GI-WebKit2-Objects-ContextMenuItem.html#v:contextMenuItemGetAction"
        })


#endif

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

foreign import ccall "webkit_context_menu_item_get_gaction" webkit_context_menu_item_get_gaction :: 
    Ptr ContextMenuItem ->                  -- item : TInterface (Name {namespace = "WebKit2", name = "ContextMenuItem"})
    IO (Ptr Gio.Action.Action)

-- | Gets the action associated to /@item@/ as a t'GI.Gio.Interfaces.Action.Action'.
-- 
-- /Since: 2.18/
contextMenuItemGetGaction ::
    (B.CallStack.HasCallStack, MonadIO m, IsContextMenuItem a) =>
    a
    -- ^ /@item@/: a t'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem'
    -> m (Maybe Gio.Action.Action)
    -- ^ __Returns:__ the t'GI.Gio.Interfaces.Action.Action' associated to the t'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem',
    --    or 'P.Nothing' if /@item@/ is a separator.
contextMenuItemGetGaction :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsContextMenuItem a) =>
a -> m (Maybe Action)
contextMenuItemGetGaction a
item = IO (Maybe Action) -> m (Maybe Action)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Action) -> m (Maybe Action))
-> IO (Maybe Action) -> m (Maybe Action)
forall a b. (a -> b) -> a -> b
$ do
    Ptr ContextMenuItem
item' <- a -> IO (Ptr ContextMenuItem)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
item
    Ptr Action
result <- Ptr ContextMenuItem -> IO (Ptr Action)
webkit_context_menu_item_get_gaction Ptr ContextMenuItem
item'
    Maybe Action
maybeResult <- Ptr Action -> (Ptr Action -> IO Action) -> IO (Maybe Action)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Action
result ((Ptr Action -> IO Action) -> IO (Maybe Action))
-> (Ptr Action -> IO Action) -> IO (Maybe Action)
forall a b. (a -> b) -> a -> b
$ \Ptr Action
result' -> do
        Action
result'' <- ((ManagedPtr Action -> Action) -> Ptr Action -> IO Action
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr Action -> Action
Gio.Action.Action) Ptr Action
result'
        Action -> IO Action
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Action
result''
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
item
    Maybe Action -> IO (Maybe Action)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Action
maybeResult

#if defined(ENABLE_OVERLOADING)
data ContextMenuItemGetGactionMethodInfo
instance (signature ~ (m (Maybe Gio.Action.Action)), MonadIO m, IsContextMenuItem a) => O.OverloadedMethod ContextMenuItemGetGactionMethodInfo a signature where
    overloadedMethod = contextMenuItemGetGaction

instance O.OverloadedMethodInfo ContextMenuItemGetGactionMethodInfo a where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.WebKit2.Objects.ContextMenuItem.contextMenuItemGetGaction",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-webkit2-4.0.30/docs/GI-WebKit2-Objects-ContextMenuItem.html#v:contextMenuItemGetGaction"
        })


#endif

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

foreign import ccall "webkit_context_menu_item_get_stock_action" webkit_context_menu_item_get_stock_action :: 
    Ptr ContextMenuItem ->                  -- item : TInterface (Name {namespace = "WebKit2", name = "ContextMenuItem"})
    IO CUInt

-- | Gets the t'GI.WebKit2.Enums.ContextMenuAction' of /@item@/.
-- 
-- If the t'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem' was not
-- created for a stock action 'GI.WebKit2.Enums.ContextMenuActionCustom' will be
-- returned. If the t'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem' is a separator 'GI.WebKit2.Enums.ContextMenuActionNoAction'
-- will be returned.
contextMenuItemGetStockAction ::
    (B.CallStack.HasCallStack, MonadIO m, IsContextMenuItem a) =>
    a
    -- ^ /@item@/: a t'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem'
    -> m WebKit2.Enums.ContextMenuAction
    -- ^ __Returns:__ the t'GI.WebKit2.Enums.ContextMenuAction' of /@item@/
contextMenuItemGetStockAction :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsContextMenuItem a) =>
a -> m ContextMenuAction
contextMenuItemGetStockAction a
item = IO ContextMenuAction -> m ContextMenuAction
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ContextMenuAction -> m ContextMenuAction)
-> IO ContextMenuAction -> m ContextMenuAction
forall a b. (a -> b) -> a -> b
$ do
    Ptr ContextMenuItem
item' <- a -> IO (Ptr ContextMenuItem)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
item
    CUInt
result <- Ptr ContextMenuItem -> IO CUInt
webkit_context_menu_item_get_stock_action Ptr ContextMenuItem
item'
    let result' :: ContextMenuAction
result' = (Int -> ContextMenuAction
forall a. Enum a => Int -> a
toEnum (Int -> ContextMenuAction)
-> (CUInt -> Int) -> CUInt -> ContextMenuAction
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
item
    ContextMenuAction -> IO ContextMenuAction
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ContextMenuAction
result'

#if defined(ENABLE_OVERLOADING)
data ContextMenuItemGetStockActionMethodInfo
instance (signature ~ (m WebKit2.Enums.ContextMenuAction), MonadIO m, IsContextMenuItem a) => O.OverloadedMethod ContextMenuItemGetStockActionMethodInfo a signature where
    overloadedMethod = contextMenuItemGetStockAction

instance O.OverloadedMethodInfo ContextMenuItemGetStockActionMethodInfo a where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.WebKit2.Objects.ContextMenuItem.contextMenuItemGetStockAction",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-webkit2-4.0.30/docs/GI-WebKit2-Objects-ContextMenuItem.html#v:contextMenuItemGetStockAction"
        })


#endif

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

foreign import ccall "webkit_context_menu_item_get_submenu" webkit_context_menu_item_get_submenu :: 
    Ptr ContextMenuItem ->                  -- item : TInterface (Name {namespace = "WebKit2", name = "ContextMenuItem"})
    IO (Ptr WebKit2.ContextMenu.ContextMenu)

-- | Gets the submenu of /@item@/.
contextMenuItemGetSubmenu ::
    (B.CallStack.HasCallStack, MonadIO m, IsContextMenuItem a) =>
    a
    -- ^ /@item@/: a t'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem'
    -> m (Maybe WebKit2.ContextMenu.ContextMenu)
    -- ^ __Returns:__ the t'GI.WebKit2.Objects.ContextMenu.ContextMenu' representing the submenu of
    --    /@item@/ or 'P.Nothing' if /@item@/ doesn\'t have a submenu.
contextMenuItemGetSubmenu :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsContextMenuItem a) =>
a -> m (Maybe ContextMenu)
contextMenuItemGetSubmenu a
item = IO (Maybe ContextMenu) -> m (Maybe ContextMenu)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe ContextMenu) -> m (Maybe ContextMenu))
-> IO (Maybe ContextMenu) -> m (Maybe ContextMenu)
forall a b. (a -> b) -> a -> b
$ do
    Ptr ContextMenuItem
item' <- a -> IO (Ptr ContextMenuItem)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
item
    Ptr ContextMenu
result <- Ptr ContextMenuItem -> IO (Ptr ContextMenu)
webkit_context_menu_item_get_submenu Ptr ContextMenuItem
item'
    Maybe ContextMenu
maybeResult <- Ptr ContextMenu
-> (Ptr ContextMenu -> IO ContextMenu) -> IO (Maybe ContextMenu)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr ContextMenu
result ((Ptr ContextMenu -> IO ContextMenu) -> IO (Maybe ContextMenu))
-> (Ptr ContextMenu -> IO ContextMenu) -> IO (Maybe ContextMenu)
forall a b. (a -> b) -> a -> b
$ \Ptr ContextMenu
result' -> do
        ContextMenu
result'' <- ((ManagedPtr ContextMenu -> ContextMenu)
-> Ptr ContextMenu -> IO ContextMenu
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr ContextMenu -> ContextMenu
WebKit2.ContextMenu.ContextMenu) Ptr ContextMenu
result'
        ContextMenu -> IO ContextMenu
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ContextMenu
result''
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
item
    Maybe ContextMenu -> IO (Maybe ContextMenu)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe ContextMenu
maybeResult

#if defined(ENABLE_OVERLOADING)
data ContextMenuItemGetSubmenuMethodInfo
instance (signature ~ (m (Maybe WebKit2.ContextMenu.ContextMenu)), MonadIO m, IsContextMenuItem a) => O.OverloadedMethod ContextMenuItemGetSubmenuMethodInfo a signature where
    overloadedMethod = contextMenuItemGetSubmenu

instance O.OverloadedMethodInfo ContextMenuItemGetSubmenuMethodInfo a where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.WebKit2.Objects.ContextMenuItem.contextMenuItemGetSubmenu",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-webkit2-4.0.30/docs/GI-WebKit2-Objects-ContextMenuItem.html#v:contextMenuItemGetSubmenu"
        })


#endif

-- method ContextMenuItem::is_separator
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "item"
--           , argType =
--               TInterface
--                 Name { namespace = "WebKit2" , name = "ContextMenuItem" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #WebKitContextMenuItem"
--                 , 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_context_menu_item_is_separator" webkit_context_menu_item_is_separator :: 
    Ptr ContextMenuItem ->                  -- item : TInterface (Name {namespace = "WebKit2", name = "ContextMenuItem"})
    IO CInt

-- | Checks whether /@item@/ is a separator.
contextMenuItemIsSeparator ::
    (B.CallStack.HasCallStack, MonadIO m, IsContextMenuItem a) =>
    a
    -- ^ /@item@/: a t'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem'
    -> m Bool
    -- ^ __Returns:__ 'P.True' is /@item@/ is a separator or 'P.False' otherwise
contextMenuItemIsSeparator :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsContextMenuItem a) =>
a -> m Bool
contextMenuItemIsSeparator a
item = IO Bool -> m Bool
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr ContextMenuItem
item' <- a -> IO (Ptr ContextMenuItem)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
item
    CInt
result <- Ptr ContextMenuItem -> IO CInt
webkit_context_menu_item_is_separator Ptr ContextMenuItem
item'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
item
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data ContextMenuItemIsSeparatorMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsContextMenuItem a) => O.OverloadedMethod ContextMenuItemIsSeparatorMethodInfo a signature where
    overloadedMethod = contextMenuItemIsSeparator

instance O.OverloadedMethodInfo ContextMenuItemIsSeparatorMethodInfo a where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.WebKit2.Objects.ContextMenuItem.contextMenuItemIsSeparator",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-webkit2-4.0.30/docs/GI-WebKit2-Objects-ContextMenuItem.html#v:contextMenuItemIsSeparator"
        })


#endif

-- method ContextMenuItem::set_submenu
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "item"
--           , argType =
--               TInterface
--                 Name { namespace = "WebKit2" , name = "ContextMenuItem" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #WebKitContextMenuItem"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "submenu"
--           , argType =
--               TInterface Name { namespace = "WebKit2" , name = "ContextMenu" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #WebKitContextMenu"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "webkit_context_menu_item_set_submenu" webkit_context_menu_item_set_submenu :: 
    Ptr ContextMenuItem ->                  -- item : TInterface (Name {namespace = "WebKit2", name = "ContextMenuItem"})
    Ptr WebKit2.ContextMenu.ContextMenu ->  -- submenu : TInterface (Name {namespace = "WebKit2", name = "ContextMenu"})
    IO ()

-- | Sets or replaces the /@item@/ submenu.
-- 
-- If /@submenu@/ is 'P.Nothing' the current
-- submenu of /@item@/ is removed.
contextMenuItemSetSubmenu ::
    (B.CallStack.HasCallStack, MonadIO m, IsContextMenuItem a, WebKit2.ContextMenu.IsContextMenu b) =>
    a
    -- ^ /@item@/: a t'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem'
    -> Maybe (b)
    -- ^ /@submenu@/: a t'GI.WebKit2.Objects.ContextMenu.ContextMenu'
    -> m ()
contextMenuItemSetSubmenu :: forall (m :: * -> *) a b.
(HasCallStack, MonadIO m, IsContextMenuItem a, IsContextMenu b) =>
a -> Maybe b -> m ()
contextMenuItemSetSubmenu a
item Maybe b
submenu = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr ContextMenuItem
item' <- a -> IO (Ptr ContextMenuItem)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
item
    Ptr ContextMenu
maybeSubmenu <- case Maybe b
submenu of
        Maybe b
Nothing -> Ptr ContextMenu -> IO (Ptr ContextMenu)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ContextMenu
forall a. Ptr a
nullPtr
        Just b
jSubmenu -> do
            Ptr ContextMenu
jSubmenu' <- b -> IO (Ptr ContextMenu)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jSubmenu
            Ptr ContextMenu -> IO (Ptr ContextMenu)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ContextMenu
jSubmenu'
    Ptr ContextMenuItem -> Ptr ContextMenu -> IO ()
webkit_context_menu_item_set_submenu Ptr ContextMenuItem
item' Ptr ContextMenu
maybeSubmenu
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
item
    Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
submenu b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data ContextMenuItemSetSubmenuMethodInfo
instance (signature ~ (Maybe (b) -> m ()), MonadIO m, IsContextMenuItem a, WebKit2.ContextMenu.IsContextMenu b) => O.OverloadedMethod ContextMenuItemSetSubmenuMethodInfo a signature where
    overloadedMethod = contextMenuItemSetSubmenu

instance O.OverloadedMethodInfo ContextMenuItemSetSubmenuMethodInfo a where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.WebKit2.Objects.ContextMenuItem.contextMenuItemSetSubmenu",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-webkit2-4.0.30/docs/GI-WebKit2-Objects-ContextMenuItem.html#v:contextMenuItemSetSubmenu"
        })


#endif