{- |
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.Objects.ContextMenu
    (

-- * Exported types
    ContextMenu(..)                         ,
    IsContextMenu                           ,
    toContextMenu                           ,
    noContextMenu                           ,


 -- * Methods
-- ** append #method:append#

#if ENABLE_OVERLOADING
    ContextMenuAppendMethodInfo             ,
#endif
    contextMenuAppend                       ,


-- ** first #method:first#

#if ENABLE_OVERLOADING
    ContextMenuFirstMethodInfo              ,
#endif
    contextMenuFirst                        ,


-- ** getItemAtPosition #method:getItemAtPosition#

#if ENABLE_OVERLOADING
    ContextMenuGetItemAtPositionMethodInfo  ,
#endif
    contextMenuGetItemAtPosition            ,


-- ** getItems #method:getItems#

#if ENABLE_OVERLOADING
    ContextMenuGetItemsMethodInfo           ,
#endif
    contextMenuGetItems                     ,


-- ** getNItems #method:getNItems#

#if ENABLE_OVERLOADING
    ContextMenuGetNItemsMethodInfo          ,
#endif
    contextMenuGetNItems                    ,


-- ** getUserData #method:getUserData#

#if ENABLE_OVERLOADING
    ContextMenuGetUserDataMethodInfo        ,
#endif
    contextMenuGetUserData                  ,


-- ** insert #method:insert#

#if ENABLE_OVERLOADING
    ContextMenuInsertMethodInfo             ,
#endif
    contextMenuInsert                       ,


-- ** last #method:last#

#if ENABLE_OVERLOADING
    ContextMenuLastMethodInfo               ,
#endif
    contextMenuLast                         ,


-- ** moveItem #method:moveItem#

#if ENABLE_OVERLOADING
    ContextMenuMoveItemMethodInfo           ,
#endif
    contextMenuMoveItem                     ,


-- ** new #method:new#

    contextMenuNew                          ,


-- ** newWithItems #method:newWithItems#

    contextMenuNewWithItems                 ,


-- ** prepend #method:prepend#

#if ENABLE_OVERLOADING
    ContextMenuPrependMethodInfo            ,
#endif
    contextMenuPrepend                      ,


-- ** remove #method:remove#

#if ENABLE_OVERLOADING
    ContextMenuRemoveMethodInfo             ,
#endif
    contextMenuRemove                       ,


-- ** removeAll #method:removeAll#

#if ENABLE_OVERLOADING
    ContextMenuRemoveAllMethodInfo          ,
#endif
    contextMenuRemoveAll                    ,


-- ** setUserData #method:setUserData#

#if ENABLE_OVERLOADING
    ContextMenuSetUserDataMethodInfo        ,
#endif
    contextMenuSetUserData                  ,




    ) 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 qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.WebKit2.Objects.ContextMenuItem as WebKit2.ContextMenuItem

-- | Memory-managed wrapper type.
newtype ContextMenu = ContextMenu (ManagedPtr ContextMenu)
foreign import ccall "webkit_context_menu_get_type"
    c_webkit_context_menu_get_type :: IO GType

instance GObject ContextMenu where
    gobjectType = c_webkit_context_menu_get_type


-- | Type class for types which can be safely cast to `ContextMenu`, for instance with `toContextMenu`.
class (GObject o, O.IsDescendantOf ContextMenu o) => IsContextMenu o
instance (GObject o, O.IsDescendantOf ContextMenu o) => IsContextMenu o

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

-- | Cast to `ContextMenu`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toContextMenu :: (MonadIO m, IsContextMenu o) => o -> m ContextMenu
toContextMenu = liftIO . unsafeCastTo ContextMenu

-- | A convenience alias for `Nothing` :: `Maybe` `ContextMenu`.
noContextMenu :: Maybe ContextMenu
noContextMenu = Nothing

#if ENABLE_OVERLOADING
type family ResolveContextMenuMethod (t :: Symbol) (o :: *) :: * where
    ResolveContextMenuMethod "append" o = ContextMenuAppendMethodInfo
    ResolveContextMenuMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveContextMenuMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveContextMenuMethod "first" o = ContextMenuFirstMethodInfo
    ResolveContextMenuMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveContextMenuMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveContextMenuMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveContextMenuMethod "insert" o = ContextMenuInsertMethodInfo
    ResolveContextMenuMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveContextMenuMethod "last" o = ContextMenuLastMethodInfo
    ResolveContextMenuMethod "moveItem" o = ContextMenuMoveItemMethodInfo
    ResolveContextMenuMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveContextMenuMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveContextMenuMethod "prepend" o = ContextMenuPrependMethodInfo
    ResolveContextMenuMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveContextMenuMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveContextMenuMethod "remove" o = ContextMenuRemoveMethodInfo
    ResolveContextMenuMethod "removeAll" o = ContextMenuRemoveAllMethodInfo
    ResolveContextMenuMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveContextMenuMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveContextMenuMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveContextMenuMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveContextMenuMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveContextMenuMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveContextMenuMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveContextMenuMethod "getItemAtPosition" o = ContextMenuGetItemAtPositionMethodInfo
    ResolveContextMenuMethod "getItems" o = ContextMenuGetItemsMethodInfo
    ResolveContextMenuMethod "getNItems" o = ContextMenuGetNItemsMethodInfo
    ResolveContextMenuMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveContextMenuMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveContextMenuMethod "getUserData" o = ContextMenuGetUserDataMethodInfo
    ResolveContextMenuMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveContextMenuMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveContextMenuMethod "setUserData" o = ContextMenuSetUserDataMethodInfo
    ResolveContextMenuMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveContextMenuMethod t ContextMenu, O.MethodInfo info ContextMenu p) => OL.IsLabel t (ContextMenu -> 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

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

#if ENABLE_OVERLOADING
#endif

#if ENABLE_OVERLOADING
type instance O.SignalList ContextMenu = ContextMenuSignalList
type ContextMenuSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

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

foreign import ccall "webkit_context_menu_new" webkit_context_menu_new ::
    IO (Ptr ContextMenu)

{- |
Creates a new 'GI.WebKit2.Objects.ContextMenu.ContextMenu' object to be used as a submenu of an existing
'GI.WebKit2.Objects.ContextMenu.ContextMenu'. The context menu of a 'GI.WebKit2.Objects.WebView.WebView' is created by the view
and passed as an argument of 'GI.WebKit2.Objects.WebView.WebView'::@/context-menu/@ signal.
To add items to the menu use 'GI.WebKit2.Objects.ContextMenu.contextMenuPrepend',
'GI.WebKit2.Objects.ContextMenu.contextMenuAppend' or 'GI.WebKit2.Objects.ContextMenu.contextMenuInsert'.
See also 'GI.WebKit2.Objects.ContextMenu.contextMenuNewWithItems' to create a 'GI.WebKit2.Objects.ContextMenu.ContextMenu' with
a list of initial items.
-}
contextMenuNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m ContextMenu
    {- ^ __Returns:__ The newly created 'GI.WebKit2.Objects.ContextMenu.ContextMenu' object -}
contextMenuNew  = liftIO $ do
    result <- webkit_context_menu_new
    checkUnexpectedReturnNULL "contextMenuNew" result
    result' <- (wrapObject ContextMenu) result
    return result'

#if ENABLE_OVERLOADING
#endif

-- method ContextMenu::new_with_items
-- method type : Constructor
-- Args : [Arg {argCName = "items", argType = TGList (TInterface (Name {namespace = "WebKit2", name = "ContextMenuItem"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GList of #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_new_with_items" webkit_context_menu_new_with_items ::
    Ptr (GList (Ptr WebKit2.ContextMenuItem.ContextMenuItem)) -> -- items : TGList (TInterface (Name {namespace = "WebKit2", name = "ContextMenuItem"}))
    IO (Ptr ContextMenu)

{- |
Creates a new 'GI.WebKit2.Objects.ContextMenu.ContextMenu' object to be used as a submenu of an existing
'GI.WebKit2.Objects.ContextMenu.ContextMenu' with the given initial items.
See also 'GI.WebKit2.Objects.ContextMenu.contextMenuNew'
-}
contextMenuNewWithItems ::
    (B.CallStack.HasCallStack, MonadIO m, WebKit2.ContextMenuItem.IsContextMenuItem a) =>
    [a]
    {- ^ /@items@/: a 'GI.GLib.Structs.List.List' of 'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem' -}
    -> m ContextMenu
    {- ^ __Returns:__ The newly created 'GI.WebKit2.Objects.ContextMenu.ContextMenu' object -}
contextMenuNewWithItems items = liftIO $ do
    items' <- mapM unsafeManagedPtrCastPtr items
    items'' <- packGList items'
    result <- webkit_context_menu_new_with_items items''
    checkUnexpectedReturnNULL "contextMenuNewWithItems" result
    result' <- (wrapObject ContextMenu) result
    mapM_ touchManagedPtr items
    g_list_free items''
    return result'

#if ENABLE_OVERLOADING
#endif

-- method ContextMenu::append
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "menu", argType = TInterface (Name {namespace = "WebKit2", name = "ContextMenu"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitContextMenu", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "item", argType = TInterface (Name {namespace = "WebKit2", name = "ContextMenuItem"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #WebKitContextMenuItem to add", 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_append" webkit_context_menu_append ::
    Ptr ContextMenu ->                      -- menu : TInterface (Name {namespace = "WebKit2", name = "ContextMenu"})
    Ptr WebKit2.ContextMenuItem.ContextMenuItem -> -- item : TInterface (Name {namespace = "WebKit2", name = "ContextMenuItem"})
    IO ()

{- |
Adds /@item@/ at the end of the /@menu@/.
-}
contextMenuAppend ::
    (B.CallStack.HasCallStack, MonadIO m, IsContextMenu a, WebKit2.ContextMenuItem.IsContextMenuItem b) =>
    a
    {- ^ /@menu@/: a 'GI.WebKit2.Objects.ContextMenu.ContextMenu' -}
    -> b
    {- ^ /@item@/: the 'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem' to add -}
    -> m ()
contextMenuAppend menu item = liftIO $ do
    menu' <- unsafeManagedPtrCastPtr menu
    item' <- unsafeManagedPtrCastPtr item
    webkit_context_menu_append menu' item'
    touchManagedPtr menu
    touchManagedPtr item
    return ()

#if ENABLE_OVERLOADING
data ContextMenuAppendMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsContextMenu a, WebKit2.ContextMenuItem.IsContextMenuItem b) => O.MethodInfo ContextMenuAppendMethodInfo a signature where
    overloadedMethod _ = contextMenuAppend

#endif

-- method ContextMenu::first
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "menu", argType = TInterface (Name {namespace = "WebKit2", name = "ContextMenu"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitContextMenu", 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_first" webkit_context_menu_first ::
    Ptr ContextMenu ->                      -- menu : TInterface (Name {namespace = "WebKit2", name = "ContextMenu"})
    IO (Ptr WebKit2.ContextMenuItem.ContextMenuItem)

{- |
Gets the first item in the /@menu@/.
-}
contextMenuFirst ::
    (B.CallStack.HasCallStack, MonadIO m, IsContextMenu a) =>
    a
    {- ^ /@menu@/: a 'GI.WebKit2.Objects.ContextMenu.ContextMenu' -}
    -> m (Maybe WebKit2.ContextMenuItem.ContextMenuItem)
    {- ^ __Returns:__ the first 'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem' of /@menu@/,
   or 'Nothing' if the 'GI.WebKit2.Objects.ContextMenu.ContextMenu' is empty. -}
contextMenuFirst menu = liftIO $ do
    menu' <- unsafeManagedPtrCastPtr menu
    result <- webkit_context_menu_first menu'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (newObject WebKit2.ContextMenuItem.ContextMenuItem) result'
        return result''
    touchManagedPtr menu
    return maybeResult

#if ENABLE_OVERLOADING
data ContextMenuFirstMethodInfo
instance (signature ~ (m (Maybe WebKit2.ContextMenuItem.ContextMenuItem)), MonadIO m, IsContextMenu a) => O.MethodInfo ContextMenuFirstMethodInfo a signature where
    overloadedMethod _ = contextMenuFirst

#endif

-- method ContextMenu::get_item_at_position
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "menu", argType = TInterface (Name {namespace = "WebKit2", name = "ContextMenu"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitContextMenu", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "position", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the position of the item, counting from 0", 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_get_item_at_position" webkit_context_menu_get_item_at_position ::
    Ptr ContextMenu ->                      -- menu : TInterface (Name {namespace = "WebKit2", name = "ContextMenu"})
    Word32 ->                               -- position : TBasicType TUInt
    IO (Ptr WebKit2.ContextMenuItem.ContextMenuItem)

{- |
Gets the item at the given position in the /@menu@/.
-}
contextMenuGetItemAtPosition ::
    (B.CallStack.HasCallStack, MonadIO m, IsContextMenu a) =>
    a
    {- ^ /@menu@/: a 'GI.WebKit2.Objects.ContextMenu.ContextMenu' -}
    -> Word32
    {- ^ /@position@/: the position of the item, counting from 0 -}
    -> m (Maybe WebKit2.ContextMenuItem.ContextMenuItem)
    {- ^ __Returns:__ the 'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem' at position /@position@/ in /@menu@/,
   or 'Nothing' if the position is off the end of the /@menu@/. -}
contextMenuGetItemAtPosition menu position = liftIO $ do
    menu' <- unsafeManagedPtrCastPtr menu
    result <- webkit_context_menu_get_item_at_position menu' position
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (newObject WebKit2.ContextMenuItem.ContextMenuItem) result'
        return result''
    touchManagedPtr menu
    return maybeResult

#if ENABLE_OVERLOADING
data ContextMenuGetItemAtPositionMethodInfo
instance (signature ~ (Word32 -> m (Maybe WebKit2.ContextMenuItem.ContextMenuItem)), MonadIO m, IsContextMenu a) => O.MethodInfo ContextMenuGetItemAtPositionMethodInfo a signature where
    overloadedMethod _ = contextMenuGetItemAtPosition

#endif

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

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

{- |
Returns the item list of /@menu@/.
-}
contextMenuGetItems ::
    (B.CallStack.HasCallStack, MonadIO m, IsContextMenu a) =>
    a
    {- ^ /@menu@/: a 'GI.WebKit2.Objects.ContextMenu.ContextMenu' -}
    -> m [WebKit2.ContextMenuItem.ContextMenuItem]
    {- ^ __Returns:__ a 'GI.GLib.Structs.List.List' of
   'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem'\<!-- -->s -}
contextMenuGetItems menu = liftIO $ do
    menu' <- unsafeManagedPtrCastPtr menu
    result <- webkit_context_menu_get_items menu'
    result' <- unpackGList result
    result'' <- mapM (newObject WebKit2.ContextMenuItem.ContextMenuItem) result'
    touchManagedPtr menu
    return result''

#if ENABLE_OVERLOADING
data ContextMenuGetItemsMethodInfo
instance (signature ~ (m [WebKit2.ContextMenuItem.ContextMenuItem]), MonadIO m, IsContextMenu a) => O.MethodInfo ContextMenuGetItemsMethodInfo a signature where
    overloadedMethod _ = contextMenuGetItems

#endif

-- method ContextMenu::get_n_items
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "menu", argType = TInterface (Name {namespace = "WebKit2", name = "ContextMenu"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitContextMenu", 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_context_menu_get_n_items" webkit_context_menu_get_n_items ::
    Ptr ContextMenu ->                      -- menu : TInterface (Name {namespace = "WebKit2", name = "ContextMenu"})
    IO Word32

{- |
Gets the length of the /@menu@/.
-}
contextMenuGetNItems ::
    (B.CallStack.HasCallStack, MonadIO m, IsContextMenu a) =>
    a
    {- ^ /@menu@/: a 'GI.WebKit2.Objects.ContextMenu.ContextMenu' -}
    -> m Word32
    {- ^ __Returns:__ the number of 'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem'\<!-- -->s in /@menu@/ -}
contextMenuGetNItems menu = liftIO $ do
    menu' <- unsafeManagedPtrCastPtr menu
    result <- webkit_context_menu_get_n_items menu'
    touchManagedPtr menu
    return result

#if ENABLE_OVERLOADING
data ContextMenuGetNItemsMethodInfo
instance (signature ~ (m Word32), MonadIO m, IsContextMenu a) => O.MethodInfo ContextMenuGetNItemsMethodInfo a signature where
    overloadedMethod _ = contextMenuGetNItems

#endif

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

foreign import ccall "webkit_context_menu_get_user_data" webkit_context_menu_get_user_data ::
    Ptr ContextMenu ->                      -- menu : TInterface (Name {namespace = "WebKit2", name = "ContextMenu"})
    IO (Ptr GVariant)

{- |
Gets the user data of /@menu@/.
This function can be used from the UI Process to get user data previously set
from the Web Process with 'GI.WebKit2.Objects.ContextMenu.contextMenuSetUserData'.

/Since: 2.8/
-}
contextMenuGetUserData ::
    (B.CallStack.HasCallStack, MonadIO m, IsContextMenu a) =>
    a
    {- ^ /@menu@/: a 'GI.WebKit2.Objects.ContextMenu.ContextMenu' -}
    -> m (Maybe GVariant)
    {- ^ __Returns:__ the user data of /@menu@/, or 'Nothing' if /@menu@/ doesn\'t have user data -}
contextMenuGetUserData menu = liftIO $ do
    menu' <- unsafeManagedPtrCastPtr menu
    result <- webkit_context_menu_get_user_data menu'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- B.GVariant.newGVariantFromPtr result'
        return result''
    touchManagedPtr menu
    return maybeResult

#if ENABLE_OVERLOADING
data ContextMenuGetUserDataMethodInfo
instance (signature ~ (m (Maybe GVariant)), MonadIO m, IsContextMenu a) => O.MethodInfo ContextMenuGetUserDataMethodInfo a signature where
    overloadedMethod _ = contextMenuGetUserData

#endif

-- method ContextMenu::insert
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "menu", argType = TInterface (Name {namespace = "WebKit2", name = "ContextMenu"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitContextMenu", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "item", argType = TInterface (Name {namespace = "WebKit2", name = "ContextMenuItem"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #WebKitContextMenuItem to add", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "position", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the position to insert the item", 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_insert" webkit_context_menu_insert ::
    Ptr ContextMenu ->                      -- menu : TInterface (Name {namespace = "WebKit2", name = "ContextMenu"})
    Ptr WebKit2.ContextMenuItem.ContextMenuItem -> -- item : TInterface (Name {namespace = "WebKit2", name = "ContextMenuItem"})
    Int32 ->                                -- position : TBasicType TInt
    IO ()

{- |
Inserts /@item@/ into the /@menu@/ at the given position.
If /@position@/ is negative, or is larger than the number of items
in the 'GI.WebKit2.Objects.ContextMenu.ContextMenu', the item is added on to the end of
the /@menu@/. The first position is 0.
-}
contextMenuInsert ::
    (B.CallStack.HasCallStack, MonadIO m, IsContextMenu a, WebKit2.ContextMenuItem.IsContextMenuItem b) =>
    a
    {- ^ /@menu@/: a 'GI.WebKit2.Objects.ContextMenu.ContextMenu' -}
    -> b
    {- ^ /@item@/: the 'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem' to add -}
    -> Int32
    {- ^ /@position@/: the position to insert the item -}
    -> m ()
contextMenuInsert menu item position = liftIO $ do
    menu' <- unsafeManagedPtrCastPtr menu
    item' <- unsafeManagedPtrCastPtr item
    webkit_context_menu_insert menu' item' position
    touchManagedPtr menu
    touchManagedPtr item
    return ()

#if ENABLE_OVERLOADING
data ContextMenuInsertMethodInfo
instance (signature ~ (b -> Int32 -> m ()), MonadIO m, IsContextMenu a, WebKit2.ContextMenuItem.IsContextMenuItem b) => O.MethodInfo ContextMenuInsertMethodInfo a signature where
    overloadedMethod _ = contextMenuInsert

#endif

-- method ContextMenu::last
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "menu", argType = TInterface (Name {namespace = "WebKit2", name = "ContextMenu"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitContextMenu", 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_last" webkit_context_menu_last ::
    Ptr ContextMenu ->                      -- menu : TInterface (Name {namespace = "WebKit2", name = "ContextMenu"})
    IO (Ptr WebKit2.ContextMenuItem.ContextMenuItem)

{- |
Gets the last item in the /@menu@/.
-}
contextMenuLast ::
    (B.CallStack.HasCallStack, MonadIO m, IsContextMenu a) =>
    a
    {- ^ /@menu@/: a 'GI.WebKit2.Objects.ContextMenu.ContextMenu' -}
    -> m (Maybe WebKit2.ContextMenuItem.ContextMenuItem)
    {- ^ __Returns:__ the last 'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem' of /@menu@/,
   or 'Nothing' if the 'GI.WebKit2.Objects.ContextMenu.ContextMenu' is empty. -}
contextMenuLast menu = liftIO $ do
    menu' <- unsafeManagedPtrCastPtr menu
    result <- webkit_context_menu_last menu'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (newObject WebKit2.ContextMenuItem.ContextMenuItem) result'
        return result''
    touchManagedPtr menu
    return maybeResult

#if ENABLE_OVERLOADING
data ContextMenuLastMethodInfo
instance (signature ~ (m (Maybe WebKit2.ContextMenuItem.ContextMenuItem)), MonadIO m, IsContextMenu a) => O.MethodInfo ContextMenuLastMethodInfo a signature where
    overloadedMethod _ = contextMenuLast

#endif

-- method ContextMenu::move_item
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "menu", argType = TInterface (Name {namespace = "WebKit2", name = "ContextMenu"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitContextMenu", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "item", argType = TInterface (Name {namespace = "WebKit2", name = "ContextMenuItem"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #WebKitContextMenuItem to add", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "position", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the new position to move the item", 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_move_item" webkit_context_menu_move_item ::
    Ptr ContextMenu ->                      -- menu : TInterface (Name {namespace = "WebKit2", name = "ContextMenu"})
    Ptr WebKit2.ContextMenuItem.ContextMenuItem -> -- item : TInterface (Name {namespace = "WebKit2", name = "ContextMenuItem"})
    Int32 ->                                -- position : TBasicType TInt
    IO ()

{- |
Moves /@item@/ to the given position in the /@menu@/.
If /@position@/ is negative, or is larger than the number of items
in the 'GI.WebKit2.Objects.ContextMenu.ContextMenu', the item is added on to the end of
the /@menu@/.
The first position is 0.
-}
contextMenuMoveItem ::
    (B.CallStack.HasCallStack, MonadIO m, IsContextMenu a, WebKit2.ContextMenuItem.IsContextMenuItem b) =>
    a
    {- ^ /@menu@/: a 'GI.WebKit2.Objects.ContextMenu.ContextMenu' -}
    -> b
    {- ^ /@item@/: the 'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem' to add -}
    -> Int32
    {- ^ /@position@/: the new position to move the item -}
    -> m ()
contextMenuMoveItem menu item position = liftIO $ do
    menu' <- unsafeManagedPtrCastPtr menu
    item' <- unsafeManagedPtrCastPtr item
    webkit_context_menu_move_item menu' item' position
    touchManagedPtr menu
    touchManagedPtr item
    return ()

#if ENABLE_OVERLOADING
data ContextMenuMoveItemMethodInfo
instance (signature ~ (b -> Int32 -> m ()), MonadIO m, IsContextMenu a, WebKit2.ContextMenuItem.IsContextMenuItem b) => O.MethodInfo ContextMenuMoveItemMethodInfo a signature where
    overloadedMethod _ = contextMenuMoveItem

#endif

-- method ContextMenu::prepend
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "menu", argType = TInterface (Name {namespace = "WebKit2", name = "ContextMenu"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitContextMenu", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "item", argType = TInterface (Name {namespace = "WebKit2", name = "ContextMenuItem"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #WebKitContextMenuItem to add", 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_prepend" webkit_context_menu_prepend ::
    Ptr ContextMenu ->                      -- menu : TInterface (Name {namespace = "WebKit2", name = "ContextMenu"})
    Ptr WebKit2.ContextMenuItem.ContextMenuItem -> -- item : TInterface (Name {namespace = "WebKit2", name = "ContextMenuItem"})
    IO ()

{- |
Adds /@item@/ at the beginning of the /@menu@/.
-}
contextMenuPrepend ::
    (B.CallStack.HasCallStack, MonadIO m, IsContextMenu a, WebKit2.ContextMenuItem.IsContextMenuItem b) =>
    a
    {- ^ /@menu@/: a 'GI.WebKit2.Objects.ContextMenu.ContextMenu' -}
    -> b
    {- ^ /@item@/: the 'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem' to add -}
    -> m ()
contextMenuPrepend menu item = liftIO $ do
    menu' <- unsafeManagedPtrCastPtr menu
    item' <- unsafeManagedPtrCastPtr item
    webkit_context_menu_prepend menu' item'
    touchManagedPtr menu
    touchManagedPtr item
    return ()

#if ENABLE_OVERLOADING
data ContextMenuPrependMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsContextMenu a, WebKit2.ContextMenuItem.IsContextMenuItem b) => O.MethodInfo ContextMenuPrependMethodInfo a signature where
    overloadedMethod _ = contextMenuPrepend

#endif

-- method ContextMenu::remove
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "menu", argType = TInterface (Name {namespace = "WebKit2", name = "ContextMenu"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitContextMenu", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "item", argType = TInterface (Name {namespace = "WebKit2", name = "ContextMenuItem"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #WebKitContextMenuItem to remove", 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_remove" webkit_context_menu_remove ::
    Ptr ContextMenu ->                      -- menu : TInterface (Name {namespace = "WebKit2", name = "ContextMenu"})
    Ptr WebKit2.ContextMenuItem.ContextMenuItem -> -- item : TInterface (Name {namespace = "WebKit2", name = "ContextMenuItem"})
    IO ()

{- |
Removes /@item@/ from the /@menu@/.
See also 'GI.WebKit2.Objects.ContextMenu.contextMenuRemoveAll' to remove all items.
-}
contextMenuRemove ::
    (B.CallStack.HasCallStack, MonadIO m, IsContextMenu a, WebKit2.ContextMenuItem.IsContextMenuItem b) =>
    a
    {- ^ /@menu@/: a 'GI.WebKit2.Objects.ContextMenu.ContextMenu' -}
    -> b
    {- ^ /@item@/: the 'GI.WebKit2.Objects.ContextMenuItem.ContextMenuItem' to remove -}
    -> m ()
contextMenuRemove menu item = liftIO $ do
    menu' <- unsafeManagedPtrCastPtr menu
    item' <- unsafeManagedPtrCastPtr item
    webkit_context_menu_remove menu' item'
    touchManagedPtr menu
    touchManagedPtr item
    return ()

#if ENABLE_OVERLOADING
data ContextMenuRemoveMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsContextMenu a, WebKit2.ContextMenuItem.IsContextMenuItem b) => O.MethodInfo ContextMenuRemoveMethodInfo a signature where
    overloadedMethod _ = contextMenuRemove

#endif

-- method ContextMenu::remove_all
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "menu", argType = TInterface (Name {namespace = "WebKit2", name = "ContextMenu"}), direction = DirectionIn, mayBeNull = False, 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_remove_all" webkit_context_menu_remove_all ::
    Ptr ContextMenu ->                      -- menu : TInterface (Name {namespace = "WebKit2", name = "ContextMenu"})
    IO ()

{- |
Removes all items of the /@menu@/.
-}
contextMenuRemoveAll ::
    (B.CallStack.HasCallStack, MonadIO m, IsContextMenu a) =>
    a
    {- ^ /@menu@/: a 'GI.WebKit2.Objects.ContextMenu.ContextMenu' -}
    -> m ()
contextMenuRemoveAll menu = liftIO $ do
    menu' <- unsafeManagedPtrCastPtr menu
    webkit_context_menu_remove_all menu'
    touchManagedPtr menu
    return ()

#if ENABLE_OVERLOADING
data ContextMenuRemoveAllMethodInfo
instance (signature ~ (m ()), MonadIO m, IsContextMenu a) => O.MethodInfo ContextMenuRemoveAllMethodInfo a signature where
    overloadedMethod _ = contextMenuRemoveAll

#endif

-- method ContextMenu::set_user_data
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "menu", argType = TInterface (Name {namespace = "WebKit2", name = "ContextMenu"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitContextMenu", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TVariant, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GVariant", 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_set_user_data" webkit_context_menu_set_user_data ::
    Ptr ContextMenu ->                      -- menu : TInterface (Name {namespace = "WebKit2", name = "ContextMenu"})
    Ptr GVariant ->                         -- user_data : TVariant
    IO ()

{- |
Sets user data to /@menu@/.
This function can be used from a Web Process extension to set user data
that can be retrieved from the UI Process using 'GI.WebKit2.Objects.ContextMenu.contextMenuGetUserData'.
If the /@userData@/ 'GVariant' is floating, it is consumed.

/Since: 2.8/
-}
contextMenuSetUserData ::
    (B.CallStack.HasCallStack, MonadIO m, IsContextMenu a) =>
    a
    {- ^ /@menu@/: a 'GI.WebKit2.Objects.ContextMenu.ContextMenu' -}
    -> GVariant
    {- ^ /@userData@/: a 'GVariant' -}
    -> m ()
contextMenuSetUserData menu userData = liftIO $ do
    menu' <- unsafeManagedPtrCastPtr menu
    userData' <- unsafeManagedPtrGetPtr userData
    webkit_context_menu_set_user_data menu' userData'
    touchManagedPtr menu
    touchManagedPtr userData
    return ()

#if ENABLE_OVERLOADING
data ContextMenuSetUserDataMethodInfo
instance (signature ~ (GVariant -> m ()), MonadIO m, IsContextMenu a) => O.MethodInfo ContextMenuSetUserDataMethodInfo a signature where
    overloadedMethod _ = contextMenuSetUserData

#endif