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

'GI.Gio.Objects.Menu.Menu' is a simple implementation of 'GI.Gio.Objects.MenuModel.MenuModel'.
You populate a 'GI.Gio.Objects.Menu.Menu' by adding 'GI.Gio.Objects.MenuItem.MenuItem' instances to it.

There are some convenience functions to allow you to directly
add items (avoiding 'GI.Gio.Objects.MenuItem.MenuItem') for the common cases. To add
a regular item, use 'GI.Gio.Objects.Menu.menuInsert'. To add a section, use
'GI.Gio.Objects.Menu.menuInsertSection'. To add a submenu, use
'GI.Gio.Objects.Menu.menuInsertSubmenu'.

/Since: 2.32/
-}

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

module GI.Gio.Objects.Menu
    (

-- * Exported types
    Menu(..)                                ,
    IsMenu                                  ,
    toMenu                                  ,
    noMenu                                  ,


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

#if ENABLE_OVERLOADING
    MenuAppendMethodInfo                    ,
#endif
    menuAppend                              ,


-- ** appendItem #method:appendItem#

#if ENABLE_OVERLOADING
    MenuAppendItemMethodInfo                ,
#endif
    menuAppendItem                          ,


-- ** appendSection #method:appendSection#

#if ENABLE_OVERLOADING
    MenuAppendSectionMethodInfo             ,
#endif
    menuAppendSection                       ,


-- ** appendSubmenu #method:appendSubmenu#

#if ENABLE_OVERLOADING
    MenuAppendSubmenuMethodInfo             ,
#endif
    menuAppendSubmenu                       ,


-- ** freeze #method:freeze#

#if ENABLE_OVERLOADING
    MenuFreezeMethodInfo                    ,
#endif
    menuFreeze                              ,


-- ** insert #method:insert#

#if ENABLE_OVERLOADING
    MenuInsertMethodInfo                    ,
#endif
    menuInsert                              ,


-- ** insertItem #method:insertItem#

#if ENABLE_OVERLOADING
    MenuInsertItemMethodInfo                ,
#endif
    menuInsertItem                          ,


-- ** insertSection #method:insertSection#

#if ENABLE_OVERLOADING
    MenuInsertSectionMethodInfo             ,
#endif
    menuInsertSection                       ,


-- ** insertSubmenu #method:insertSubmenu#

#if ENABLE_OVERLOADING
    MenuInsertSubmenuMethodInfo             ,
#endif
    menuInsertSubmenu                       ,


-- ** new #method:new#

    menuNew                                 ,


-- ** prepend #method:prepend#

#if ENABLE_OVERLOADING
    MenuPrependMethodInfo                   ,
#endif
    menuPrepend                             ,


-- ** prependItem #method:prependItem#

#if ENABLE_OVERLOADING
    MenuPrependItemMethodInfo               ,
#endif
    menuPrependItem                         ,


-- ** prependSection #method:prependSection#

#if ENABLE_OVERLOADING
    MenuPrependSectionMethodInfo            ,
#endif
    menuPrependSection                      ,


-- ** prependSubmenu #method:prependSubmenu#

#if ENABLE_OVERLOADING
    MenuPrependSubmenuMethodInfo            ,
#endif
    menuPrependSubmenu                      ,


-- ** remove #method:remove#

#if ENABLE_OVERLOADING
    MenuRemoveMethodInfo                    ,
#endif
    menuRemove                              ,


-- ** removeAll #method:removeAll#

#if ENABLE_OVERLOADING
    MenuRemoveAllMethodInfo                 ,
#endif
    menuRemoveAll                           ,




    ) 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.Gio.Objects.MenuItem as Gio.MenuItem
import {-# SOURCE #-} qualified GI.Gio.Objects.MenuModel as Gio.MenuModel

-- | Memory-managed wrapper type.
newtype Menu = Menu (ManagedPtr Menu)
foreign import ccall "g_menu_get_type"
    c_g_menu_get_type :: IO GType

instance GObject Menu where
    gobjectType = c_g_menu_get_type


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

instance O.HasParentTypes Menu
type instance O.ParentTypes Menu = '[Gio.MenuModel.MenuModel, GObject.Object.Object]

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

-- | A convenience alias for `Nothing` :: `Maybe` `Menu`.
noMenu :: Maybe Menu
noMenu = Nothing

#if ENABLE_OVERLOADING
type family ResolveMenuMethod (t :: Symbol) (o :: *) :: * where
    ResolveMenuMethod "append" o = MenuAppendMethodInfo
    ResolveMenuMethod "appendItem" o = MenuAppendItemMethodInfo
    ResolveMenuMethod "appendSection" o = MenuAppendSectionMethodInfo
    ResolveMenuMethod "appendSubmenu" o = MenuAppendSubmenuMethodInfo
    ResolveMenuMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveMenuMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveMenuMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveMenuMethod "freeze" o = MenuFreezeMethodInfo
    ResolveMenuMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveMenuMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveMenuMethod "insert" o = MenuInsertMethodInfo
    ResolveMenuMethod "insertItem" o = MenuInsertItemMethodInfo
    ResolveMenuMethod "insertSection" o = MenuInsertSectionMethodInfo
    ResolveMenuMethod "insertSubmenu" o = MenuInsertSubmenuMethodInfo
    ResolveMenuMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveMenuMethod "isMutable" o = Gio.MenuModel.MenuModelIsMutableMethodInfo
    ResolveMenuMethod "itemsChanged" o = Gio.MenuModel.MenuModelItemsChangedMethodInfo
    ResolveMenuMethod "iterateItemAttributes" o = Gio.MenuModel.MenuModelIterateItemAttributesMethodInfo
    ResolveMenuMethod "iterateItemLinks" o = Gio.MenuModel.MenuModelIterateItemLinksMethodInfo
    ResolveMenuMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveMenuMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveMenuMethod "prepend" o = MenuPrependMethodInfo
    ResolveMenuMethod "prependItem" o = MenuPrependItemMethodInfo
    ResolveMenuMethod "prependSection" o = MenuPrependSectionMethodInfo
    ResolveMenuMethod "prependSubmenu" o = MenuPrependSubmenuMethodInfo
    ResolveMenuMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveMenuMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveMenuMethod "remove" o = MenuRemoveMethodInfo
    ResolveMenuMethod "removeAll" o = MenuRemoveAllMethodInfo
    ResolveMenuMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveMenuMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveMenuMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveMenuMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveMenuMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveMenuMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveMenuMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveMenuMethod "getItemAttributeValue" o = Gio.MenuModel.MenuModelGetItemAttributeValueMethodInfo
    ResolveMenuMethod "getItemLink" o = Gio.MenuModel.MenuModelGetItemLinkMethodInfo
    ResolveMenuMethod "getNItems" o = Gio.MenuModel.MenuModelGetNItemsMethodInfo
    ResolveMenuMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveMenuMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveMenuMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveMenuMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveMenuMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveMenuMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveMenuMethod t Menu, O.MethodInfo info Menu p) => OL.IsLabel t (Menu -> 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 Menu
type instance O.AttributeList Menu = MenuAttributeList
type MenuAttributeList = ('[ ] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
#endif

#if ENABLE_OVERLOADING
type instance O.SignalList Menu = MenuSignalList
type MenuSignalList = ('[ '("itemsChanged", Gio.MenuModel.MenuModelItemsChangedSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

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

foreign import ccall "g_menu_new" g_menu_new ::
    IO (Ptr Menu)

{- |
Creates a new 'GI.Gio.Objects.Menu.Menu'.

The new menu has no items.

/Since: 2.32/
-}
menuNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Menu
    {- ^ __Returns:__ a new 'GI.Gio.Objects.Menu.Menu' -}
menuNew  = liftIO $ do
    result <- g_menu_new
    checkUnexpectedReturnNULL "menuNew" result
    result' <- (wrapObject Menu) result
    return result'

#if ENABLE_OVERLOADING
#endif

-- method Menu::append
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "menu", argType = TInterface (Name {namespace = "Gio", name = "Menu"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMenu", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "label", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the section label, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "detailed_action", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the detailed action string, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_menu_append" g_menu_append ::
    Ptr Menu ->                             -- menu : TInterface (Name {namespace = "Gio", name = "Menu"})
    CString ->                              -- label : TBasicType TUTF8
    CString ->                              -- detailed_action : TBasicType TUTF8
    IO ()

{- |
Convenience function for appending a normal menu item to the end of
/@menu@/.  Combine 'GI.Gio.Objects.MenuItem.menuItemNew' and 'GI.Gio.Objects.Menu.menuInsertItem' for a more
flexible alternative.

/Since: 2.32/
-}
menuAppend ::
    (B.CallStack.HasCallStack, MonadIO m, IsMenu a) =>
    a
    {- ^ /@menu@/: a 'GI.Gio.Objects.Menu.Menu' -}
    -> Maybe (T.Text)
    {- ^ /@label@/: the section label, or 'Nothing' -}
    -> Maybe (T.Text)
    {- ^ /@detailedAction@/: the detailed action string, or 'Nothing' -}
    -> m ()
menuAppend menu label detailedAction = liftIO $ do
    menu' <- unsafeManagedPtrCastPtr menu
    maybeLabel <- case label of
        Nothing -> return nullPtr
        Just jLabel -> do
            jLabel' <- textToCString jLabel
            return jLabel'
    maybeDetailedAction <- case detailedAction of
        Nothing -> return nullPtr
        Just jDetailedAction -> do
            jDetailedAction' <- textToCString jDetailedAction
            return jDetailedAction'
    g_menu_append menu' maybeLabel maybeDetailedAction
    touchManagedPtr menu
    freeMem maybeLabel
    freeMem maybeDetailedAction
    return ()

#if ENABLE_OVERLOADING
data MenuAppendMethodInfo
instance (signature ~ (Maybe (T.Text) -> Maybe (T.Text) -> m ()), MonadIO m, IsMenu a) => O.MethodInfo MenuAppendMethodInfo a signature where
    overloadedMethod _ = menuAppend

#endif

-- method Menu::append_item
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "menu", argType = TInterface (Name {namespace = "Gio", name = "Menu"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMenu", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "item", argType = TInterface (Name {namespace = "Gio", name = "MenuItem"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMenuItem to append", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_menu_append_item" g_menu_append_item ::
    Ptr Menu ->                             -- menu : TInterface (Name {namespace = "Gio", name = "Menu"})
    Ptr Gio.MenuItem.MenuItem ->            -- item : TInterface (Name {namespace = "Gio", name = "MenuItem"})
    IO ()

{- |
Appends /@item@/ to the end of /@menu@/.

See 'GI.Gio.Objects.Menu.menuInsertItem' for more information.

/Since: 2.32/
-}
menuAppendItem ::
    (B.CallStack.HasCallStack, MonadIO m, IsMenu a, Gio.MenuItem.IsMenuItem b) =>
    a
    {- ^ /@menu@/: a 'GI.Gio.Objects.Menu.Menu' -}
    -> b
    {- ^ /@item@/: a 'GI.Gio.Objects.MenuItem.MenuItem' to append -}
    -> m ()
menuAppendItem menu item = liftIO $ do
    menu' <- unsafeManagedPtrCastPtr menu
    item' <- unsafeManagedPtrCastPtr item
    g_menu_append_item menu' item'
    touchManagedPtr menu
    touchManagedPtr item
    return ()

#if ENABLE_OVERLOADING
data MenuAppendItemMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsMenu a, Gio.MenuItem.IsMenuItem b) => O.MethodInfo MenuAppendItemMethodInfo a signature where
    overloadedMethod _ = menuAppendItem

#endif

-- method Menu::append_section
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "menu", argType = TInterface (Name {namespace = "Gio", name = "Menu"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMenu", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "label", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the section label, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "section", argType = TInterface (Name {namespace = "Gio", name = "MenuModel"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMenuModel with the items of the section", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_menu_append_section" g_menu_append_section ::
    Ptr Menu ->                             -- menu : TInterface (Name {namespace = "Gio", name = "Menu"})
    CString ->                              -- label : TBasicType TUTF8
    Ptr Gio.MenuModel.MenuModel ->          -- section : TInterface (Name {namespace = "Gio", name = "MenuModel"})
    IO ()

{- |
Convenience function for appending a section menu item to the end of
/@menu@/.  Combine 'GI.Gio.Objects.MenuItem.menuItemNewSection' and 'GI.Gio.Objects.Menu.menuInsertItem' for a
more flexible alternative.

/Since: 2.32/
-}
menuAppendSection ::
    (B.CallStack.HasCallStack, MonadIO m, IsMenu a, Gio.MenuModel.IsMenuModel b) =>
    a
    {- ^ /@menu@/: a 'GI.Gio.Objects.Menu.Menu' -}
    -> Maybe (T.Text)
    {- ^ /@label@/: the section label, or 'Nothing' -}
    -> b
    {- ^ /@section@/: a 'GI.Gio.Objects.MenuModel.MenuModel' with the items of the section -}
    -> m ()
menuAppendSection menu label section = liftIO $ do
    menu' <- unsafeManagedPtrCastPtr menu
    maybeLabel <- case label of
        Nothing -> return nullPtr
        Just jLabel -> do
            jLabel' <- textToCString jLabel
            return jLabel'
    section' <- unsafeManagedPtrCastPtr section
    g_menu_append_section menu' maybeLabel section'
    touchManagedPtr menu
    touchManagedPtr section
    freeMem maybeLabel
    return ()

#if ENABLE_OVERLOADING
data MenuAppendSectionMethodInfo
instance (signature ~ (Maybe (T.Text) -> b -> m ()), MonadIO m, IsMenu a, Gio.MenuModel.IsMenuModel b) => O.MethodInfo MenuAppendSectionMethodInfo a signature where
    overloadedMethod _ = menuAppendSection

#endif

-- method Menu::append_submenu
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "menu", argType = TInterface (Name {namespace = "Gio", name = "Menu"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMenu", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "label", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the section label, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "submenu", argType = TInterface (Name {namespace = "Gio", name = "MenuModel"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMenuModel with the items of the submenu", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_menu_append_submenu" g_menu_append_submenu ::
    Ptr Menu ->                             -- menu : TInterface (Name {namespace = "Gio", name = "Menu"})
    CString ->                              -- label : TBasicType TUTF8
    Ptr Gio.MenuModel.MenuModel ->          -- submenu : TInterface (Name {namespace = "Gio", name = "MenuModel"})
    IO ()

{- |
Convenience function for appending a submenu menu item to the end of
/@menu@/.  Combine 'GI.Gio.Objects.MenuItem.menuItemNewSubmenu' and 'GI.Gio.Objects.Menu.menuInsertItem' for a
more flexible alternative.

/Since: 2.32/
-}
menuAppendSubmenu ::
    (B.CallStack.HasCallStack, MonadIO m, IsMenu a, Gio.MenuModel.IsMenuModel b) =>
    a
    {- ^ /@menu@/: a 'GI.Gio.Objects.Menu.Menu' -}
    -> Maybe (T.Text)
    {- ^ /@label@/: the section label, or 'Nothing' -}
    -> b
    {- ^ /@submenu@/: a 'GI.Gio.Objects.MenuModel.MenuModel' with the items of the submenu -}
    -> m ()
menuAppendSubmenu menu label submenu = liftIO $ do
    menu' <- unsafeManagedPtrCastPtr menu
    maybeLabel <- case label of
        Nothing -> return nullPtr
        Just jLabel -> do
            jLabel' <- textToCString jLabel
            return jLabel'
    submenu' <- unsafeManagedPtrCastPtr submenu
    g_menu_append_submenu menu' maybeLabel submenu'
    touchManagedPtr menu
    touchManagedPtr submenu
    freeMem maybeLabel
    return ()

#if ENABLE_OVERLOADING
data MenuAppendSubmenuMethodInfo
instance (signature ~ (Maybe (T.Text) -> b -> m ()), MonadIO m, IsMenu a, Gio.MenuModel.IsMenuModel b) => O.MethodInfo MenuAppendSubmenuMethodInfo a signature where
    overloadedMethod _ = menuAppendSubmenu

#endif

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

foreign import ccall "g_menu_freeze" g_menu_freeze ::
    Ptr Menu ->                             -- menu : TInterface (Name {namespace = "Gio", name = "Menu"})
    IO ()

{- |
Marks /@menu@/ as frozen.

After the menu is frozen, it is an error to attempt to make any
changes to it.  In effect this means that the 'GI.Gio.Objects.Menu.Menu' API must no
longer be used.

This function causes 'GI.Gio.Objects.MenuModel.menuModelIsMutable' to begin returning
'False', which has some positive performance implications.

/Since: 2.32/
-}
menuFreeze ::
    (B.CallStack.HasCallStack, MonadIO m, IsMenu a) =>
    a
    {- ^ /@menu@/: a 'GI.Gio.Objects.Menu.Menu' -}
    -> m ()
menuFreeze menu = liftIO $ do
    menu' <- unsafeManagedPtrCastPtr menu
    g_menu_freeze menu'
    touchManagedPtr menu
    return ()

#if ENABLE_OVERLOADING
data MenuFreezeMethodInfo
instance (signature ~ (m ()), MonadIO m, IsMenu a) => O.MethodInfo MenuFreezeMethodInfo a signature where
    overloadedMethod _ = menuFreeze

#endif

-- method Menu::insert
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "menu", argType = TInterface (Name {namespace = "Gio", name = "Menu"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMenu", 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 at which to insert the item", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "label", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the section label, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "detailed_action", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the detailed action string, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_menu_insert" g_menu_insert ::
    Ptr Menu ->                             -- menu : TInterface (Name {namespace = "Gio", name = "Menu"})
    Int32 ->                                -- position : TBasicType TInt
    CString ->                              -- label : TBasicType TUTF8
    CString ->                              -- detailed_action : TBasicType TUTF8
    IO ()

{- |
Convenience function for inserting a normal menu item into /@menu@/.
Combine 'GI.Gio.Objects.MenuItem.menuItemNew' and 'GI.Gio.Objects.Menu.menuInsertItem' for a more flexible
alternative.

/Since: 2.32/
-}
menuInsert ::
    (B.CallStack.HasCallStack, MonadIO m, IsMenu a) =>
    a
    {- ^ /@menu@/: a 'GI.Gio.Objects.Menu.Menu' -}
    -> Int32
    {- ^ /@position@/: the position at which to insert the item -}
    -> Maybe (T.Text)
    {- ^ /@label@/: the section label, or 'Nothing' -}
    -> Maybe (T.Text)
    {- ^ /@detailedAction@/: the detailed action string, or 'Nothing' -}
    -> m ()
menuInsert menu position label detailedAction = liftIO $ do
    menu' <- unsafeManagedPtrCastPtr menu
    maybeLabel <- case label of
        Nothing -> return nullPtr
        Just jLabel -> do
            jLabel' <- textToCString jLabel
            return jLabel'
    maybeDetailedAction <- case detailedAction of
        Nothing -> return nullPtr
        Just jDetailedAction -> do
            jDetailedAction' <- textToCString jDetailedAction
            return jDetailedAction'
    g_menu_insert menu' position maybeLabel maybeDetailedAction
    touchManagedPtr menu
    freeMem maybeLabel
    freeMem maybeDetailedAction
    return ()

#if ENABLE_OVERLOADING
data MenuInsertMethodInfo
instance (signature ~ (Int32 -> Maybe (T.Text) -> Maybe (T.Text) -> m ()), MonadIO m, IsMenu a) => O.MethodInfo MenuInsertMethodInfo a signature where
    overloadedMethod _ = menuInsert

#endif

-- method Menu::insert_item
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "menu", argType = TInterface (Name {namespace = "Gio", name = "Menu"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMenu", 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 at which to insert the item", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "item", argType = TInterface (Name {namespace = "Gio", name = "MenuItem"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GMenuItem to insert", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_menu_insert_item" g_menu_insert_item ::
    Ptr Menu ->                             -- menu : TInterface (Name {namespace = "Gio", name = "Menu"})
    Int32 ->                                -- position : TBasicType TInt
    Ptr Gio.MenuItem.MenuItem ->            -- item : TInterface (Name {namespace = "Gio", name = "MenuItem"})
    IO ()

{- |
Inserts /@item@/ into /@menu@/.

The \"insertion\" is actually done by copying all of the attribute and
link values of /@item@/ and using them to form a new item within /@menu@/.
As such, /@item@/ itself is not really inserted, but rather, a menu item
that is exactly the same as the one presently described by /@item@/.

This means that /@item@/ is essentially useless after the insertion
occurs.  Any changes you make to it are ignored unless it is inserted
again (at which point its updated values will be copied).

You should probably just free /@item@/ once you\'re done.

There are many convenience functions to take care of common cases.
See 'GI.Gio.Objects.Menu.menuInsert', 'GI.Gio.Objects.Menu.menuInsertSection' and
'GI.Gio.Objects.Menu.menuInsertSubmenu' as well as \"prepend\" and \"append\" variants of
each of these functions.

/Since: 2.32/
-}
menuInsertItem ::
    (B.CallStack.HasCallStack, MonadIO m, IsMenu a, Gio.MenuItem.IsMenuItem b) =>
    a
    {- ^ /@menu@/: a 'GI.Gio.Objects.Menu.Menu' -}
    -> Int32
    {- ^ /@position@/: the position at which to insert the item -}
    -> b
    {- ^ /@item@/: the 'GI.Gio.Objects.MenuItem.MenuItem' to insert -}
    -> m ()
menuInsertItem menu position item = liftIO $ do
    menu' <- unsafeManagedPtrCastPtr menu
    item' <- unsafeManagedPtrCastPtr item
    g_menu_insert_item menu' position item'
    touchManagedPtr menu
    touchManagedPtr item
    return ()

#if ENABLE_OVERLOADING
data MenuInsertItemMethodInfo
instance (signature ~ (Int32 -> b -> m ()), MonadIO m, IsMenu a, Gio.MenuItem.IsMenuItem b) => O.MethodInfo MenuInsertItemMethodInfo a signature where
    overloadedMethod _ = menuInsertItem

#endif

-- method Menu::insert_section
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "menu", argType = TInterface (Name {namespace = "Gio", name = "Menu"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMenu", 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 at which to insert the item", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "label", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the section label, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "section", argType = TInterface (Name {namespace = "Gio", name = "MenuModel"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMenuModel with the items of the section", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_menu_insert_section" g_menu_insert_section ::
    Ptr Menu ->                             -- menu : TInterface (Name {namespace = "Gio", name = "Menu"})
    Int32 ->                                -- position : TBasicType TInt
    CString ->                              -- label : TBasicType TUTF8
    Ptr Gio.MenuModel.MenuModel ->          -- section : TInterface (Name {namespace = "Gio", name = "MenuModel"})
    IO ()

{- |
Convenience function for inserting a section menu item into /@menu@/.
Combine 'GI.Gio.Objects.MenuItem.menuItemNewSection' and 'GI.Gio.Objects.Menu.menuInsertItem' for a more
flexible alternative.

/Since: 2.32/
-}
menuInsertSection ::
    (B.CallStack.HasCallStack, MonadIO m, IsMenu a, Gio.MenuModel.IsMenuModel b) =>
    a
    {- ^ /@menu@/: a 'GI.Gio.Objects.Menu.Menu' -}
    -> Int32
    {- ^ /@position@/: the position at which to insert the item -}
    -> Maybe (T.Text)
    {- ^ /@label@/: the section label, or 'Nothing' -}
    -> b
    {- ^ /@section@/: a 'GI.Gio.Objects.MenuModel.MenuModel' with the items of the section -}
    -> m ()
menuInsertSection menu position label section = liftIO $ do
    menu' <- unsafeManagedPtrCastPtr menu
    maybeLabel <- case label of
        Nothing -> return nullPtr
        Just jLabel -> do
            jLabel' <- textToCString jLabel
            return jLabel'
    section' <- unsafeManagedPtrCastPtr section
    g_menu_insert_section menu' position maybeLabel section'
    touchManagedPtr menu
    touchManagedPtr section
    freeMem maybeLabel
    return ()

#if ENABLE_OVERLOADING
data MenuInsertSectionMethodInfo
instance (signature ~ (Int32 -> Maybe (T.Text) -> b -> m ()), MonadIO m, IsMenu a, Gio.MenuModel.IsMenuModel b) => O.MethodInfo MenuInsertSectionMethodInfo a signature where
    overloadedMethod _ = menuInsertSection

#endif

-- method Menu::insert_submenu
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "menu", argType = TInterface (Name {namespace = "Gio", name = "Menu"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMenu", 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 at which to insert the item", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "label", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the section label, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "submenu", argType = TInterface (Name {namespace = "Gio", name = "MenuModel"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMenuModel with the items of the submenu", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_menu_insert_submenu" g_menu_insert_submenu ::
    Ptr Menu ->                             -- menu : TInterface (Name {namespace = "Gio", name = "Menu"})
    Int32 ->                                -- position : TBasicType TInt
    CString ->                              -- label : TBasicType TUTF8
    Ptr Gio.MenuModel.MenuModel ->          -- submenu : TInterface (Name {namespace = "Gio", name = "MenuModel"})
    IO ()

{- |
Convenience function for inserting a submenu menu item into /@menu@/.
Combine 'GI.Gio.Objects.MenuItem.menuItemNewSubmenu' and 'GI.Gio.Objects.Menu.menuInsertItem' for a more
flexible alternative.

/Since: 2.32/
-}
menuInsertSubmenu ::
    (B.CallStack.HasCallStack, MonadIO m, IsMenu a, Gio.MenuModel.IsMenuModel b) =>
    a
    {- ^ /@menu@/: a 'GI.Gio.Objects.Menu.Menu' -}
    -> Int32
    {- ^ /@position@/: the position at which to insert the item -}
    -> Maybe (T.Text)
    {- ^ /@label@/: the section label, or 'Nothing' -}
    -> b
    {- ^ /@submenu@/: a 'GI.Gio.Objects.MenuModel.MenuModel' with the items of the submenu -}
    -> m ()
menuInsertSubmenu menu position label submenu = liftIO $ do
    menu' <- unsafeManagedPtrCastPtr menu
    maybeLabel <- case label of
        Nothing -> return nullPtr
        Just jLabel -> do
            jLabel' <- textToCString jLabel
            return jLabel'
    submenu' <- unsafeManagedPtrCastPtr submenu
    g_menu_insert_submenu menu' position maybeLabel submenu'
    touchManagedPtr menu
    touchManagedPtr submenu
    freeMem maybeLabel
    return ()

#if ENABLE_OVERLOADING
data MenuInsertSubmenuMethodInfo
instance (signature ~ (Int32 -> Maybe (T.Text) -> b -> m ()), MonadIO m, IsMenu a, Gio.MenuModel.IsMenuModel b) => O.MethodInfo MenuInsertSubmenuMethodInfo a signature where
    overloadedMethod _ = menuInsertSubmenu

#endif

-- method Menu::prepend
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "menu", argType = TInterface (Name {namespace = "Gio", name = "Menu"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMenu", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "label", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the section label, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "detailed_action", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the detailed action string, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_menu_prepend" g_menu_prepend ::
    Ptr Menu ->                             -- menu : TInterface (Name {namespace = "Gio", name = "Menu"})
    CString ->                              -- label : TBasicType TUTF8
    CString ->                              -- detailed_action : TBasicType TUTF8
    IO ()

{- |
Convenience function for prepending a normal menu item to the start
of /@menu@/.  Combine 'GI.Gio.Objects.MenuItem.menuItemNew' and 'GI.Gio.Objects.Menu.menuInsertItem' for a more
flexible alternative.

/Since: 2.32/
-}
menuPrepend ::
    (B.CallStack.HasCallStack, MonadIO m, IsMenu a) =>
    a
    {- ^ /@menu@/: a 'GI.Gio.Objects.Menu.Menu' -}
    -> Maybe (T.Text)
    {- ^ /@label@/: the section label, or 'Nothing' -}
    -> Maybe (T.Text)
    {- ^ /@detailedAction@/: the detailed action string, or 'Nothing' -}
    -> m ()
menuPrepend menu label detailedAction = liftIO $ do
    menu' <- unsafeManagedPtrCastPtr menu
    maybeLabel <- case label of
        Nothing -> return nullPtr
        Just jLabel -> do
            jLabel' <- textToCString jLabel
            return jLabel'
    maybeDetailedAction <- case detailedAction of
        Nothing -> return nullPtr
        Just jDetailedAction -> do
            jDetailedAction' <- textToCString jDetailedAction
            return jDetailedAction'
    g_menu_prepend menu' maybeLabel maybeDetailedAction
    touchManagedPtr menu
    freeMem maybeLabel
    freeMem maybeDetailedAction
    return ()

#if ENABLE_OVERLOADING
data MenuPrependMethodInfo
instance (signature ~ (Maybe (T.Text) -> Maybe (T.Text) -> m ()), MonadIO m, IsMenu a) => O.MethodInfo MenuPrependMethodInfo a signature where
    overloadedMethod _ = menuPrepend

#endif

-- method Menu::prepend_item
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "menu", argType = TInterface (Name {namespace = "Gio", name = "Menu"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMenu", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "item", argType = TInterface (Name {namespace = "Gio", name = "MenuItem"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMenuItem to prepend", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_menu_prepend_item" g_menu_prepend_item ::
    Ptr Menu ->                             -- menu : TInterface (Name {namespace = "Gio", name = "Menu"})
    Ptr Gio.MenuItem.MenuItem ->            -- item : TInterface (Name {namespace = "Gio", name = "MenuItem"})
    IO ()

{- |
Prepends /@item@/ to the start of /@menu@/.

See 'GI.Gio.Objects.Menu.menuInsertItem' for more information.

/Since: 2.32/
-}
menuPrependItem ::
    (B.CallStack.HasCallStack, MonadIO m, IsMenu a, Gio.MenuItem.IsMenuItem b) =>
    a
    {- ^ /@menu@/: a 'GI.Gio.Objects.Menu.Menu' -}
    -> b
    {- ^ /@item@/: a 'GI.Gio.Objects.MenuItem.MenuItem' to prepend -}
    -> m ()
menuPrependItem menu item = liftIO $ do
    menu' <- unsafeManagedPtrCastPtr menu
    item' <- unsafeManagedPtrCastPtr item
    g_menu_prepend_item menu' item'
    touchManagedPtr menu
    touchManagedPtr item
    return ()

#if ENABLE_OVERLOADING
data MenuPrependItemMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsMenu a, Gio.MenuItem.IsMenuItem b) => O.MethodInfo MenuPrependItemMethodInfo a signature where
    overloadedMethod _ = menuPrependItem

#endif

-- method Menu::prepend_section
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "menu", argType = TInterface (Name {namespace = "Gio", name = "Menu"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMenu", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "label", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the section label, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "section", argType = TInterface (Name {namespace = "Gio", name = "MenuModel"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMenuModel with the items of the section", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_menu_prepend_section" g_menu_prepend_section ::
    Ptr Menu ->                             -- menu : TInterface (Name {namespace = "Gio", name = "Menu"})
    CString ->                              -- label : TBasicType TUTF8
    Ptr Gio.MenuModel.MenuModel ->          -- section : TInterface (Name {namespace = "Gio", name = "MenuModel"})
    IO ()

{- |
Convenience function for prepending a section menu item to the start
of /@menu@/.  Combine 'GI.Gio.Objects.MenuItem.menuItemNewSection' and 'GI.Gio.Objects.Menu.menuInsertItem' for
a more flexible alternative.

/Since: 2.32/
-}
menuPrependSection ::
    (B.CallStack.HasCallStack, MonadIO m, IsMenu a, Gio.MenuModel.IsMenuModel b) =>
    a
    {- ^ /@menu@/: a 'GI.Gio.Objects.Menu.Menu' -}
    -> Maybe (T.Text)
    {- ^ /@label@/: the section label, or 'Nothing' -}
    -> b
    {- ^ /@section@/: a 'GI.Gio.Objects.MenuModel.MenuModel' with the items of the section -}
    -> m ()
menuPrependSection menu label section = liftIO $ do
    menu' <- unsafeManagedPtrCastPtr menu
    maybeLabel <- case label of
        Nothing -> return nullPtr
        Just jLabel -> do
            jLabel' <- textToCString jLabel
            return jLabel'
    section' <- unsafeManagedPtrCastPtr section
    g_menu_prepend_section menu' maybeLabel section'
    touchManagedPtr menu
    touchManagedPtr section
    freeMem maybeLabel
    return ()

#if ENABLE_OVERLOADING
data MenuPrependSectionMethodInfo
instance (signature ~ (Maybe (T.Text) -> b -> m ()), MonadIO m, IsMenu a, Gio.MenuModel.IsMenuModel b) => O.MethodInfo MenuPrependSectionMethodInfo a signature where
    overloadedMethod _ = menuPrependSection

#endif

-- method Menu::prepend_submenu
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "menu", argType = TInterface (Name {namespace = "Gio", name = "Menu"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMenu", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "label", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the section label, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "submenu", argType = TInterface (Name {namespace = "Gio", name = "MenuModel"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMenuModel with the items of the submenu", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_menu_prepend_submenu" g_menu_prepend_submenu ::
    Ptr Menu ->                             -- menu : TInterface (Name {namespace = "Gio", name = "Menu"})
    CString ->                              -- label : TBasicType TUTF8
    Ptr Gio.MenuModel.MenuModel ->          -- submenu : TInterface (Name {namespace = "Gio", name = "MenuModel"})
    IO ()

{- |
Convenience function for prepending a submenu menu item to the start
of /@menu@/.  Combine 'GI.Gio.Objects.MenuItem.menuItemNewSubmenu' and 'GI.Gio.Objects.Menu.menuInsertItem' for
a more flexible alternative.

/Since: 2.32/
-}
menuPrependSubmenu ::
    (B.CallStack.HasCallStack, MonadIO m, IsMenu a, Gio.MenuModel.IsMenuModel b) =>
    a
    {- ^ /@menu@/: a 'GI.Gio.Objects.Menu.Menu' -}
    -> Maybe (T.Text)
    {- ^ /@label@/: the section label, or 'Nothing' -}
    -> b
    {- ^ /@submenu@/: a 'GI.Gio.Objects.MenuModel.MenuModel' with the items of the submenu -}
    -> m ()
menuPrependSubmenu menu label submenu = liftIO $ do
    menu' <- unsafeManagedPtrCastPtr menu
    maybeLabel <- case label of
        Nothing -> return nullPtr
        Just jLabel -> do
            jLabel' <- textToCString jLabel
            return jLabel'
    submenu' <- unsafeManagedPtrCastPtr submenu
    g_menu_prepend_submenu menu' maybeLabel submenu'
    touchManagedPtr menu
    touchManagedPtr submenu
    freeMem maybeLabel
    return ()

#if ENABLE_OVERLOADING
data MenuPrependSubmenuMethodInfo
instance (signature ~ (Maybe (T.Text) -> b -> m ()), MonadIO m, IsMenu a, Gio.MenuModel.IsMenuModel b) => O.MethodInfo MenuPrependSubmenuMethodInfo a signature where
    overloadedMethod _ = menuPrependSubmenu

#endif

-- method Menu::remove
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "menu", argType = TInterface (Name {namespace = "Gio", name = "Menu"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GMenu", 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 of the item 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 "g_menu_remove" g_menu_remove ::
    Ptr Menu ->                             -- menu : TInterface (Name {namespace = "Gio", name = "Menu"})
    Int32 ->                                -- position : TBasicType TInt
    IO ()

{- |
Removes an item from the menu.

/@position@/ gives the index of the item to remove.

It is an error if position is not in range the range from 0 to one
less than the number of items in the menu.

It is not possible to remove items by identity since items are added
to the menu simply by copying their links and attributes (ie:
identity of the item itself is not preserved).

/Since: 2.32/
-}
menuRemove ::
    (B.CallStack.HasCallStack, MonadIO m, IsMenu a) =>
    a
    {- ^ /@menu@/: a 'GI.Gio.Objects.Menu.Menu' -}
    -> Int32
    {- ^ /@position@/: the position of the item to remove -}
    -> m ()
menuRemove menu position = liftIO $ do
    menu' <- unsafeManagedPtrCastPtr menu
    g_menu_remove menu' position
    touchManagedPtr menu
    return ()

#if ENABLE_OVERLOADING
data MenuRemoveMethodInfo
instance (signature ~ (Int32 -> m ()), MonadIO m, IsMenu a) => O.MethodInfo MenuRemoveMethodInfo a signature where
    overloadedMethod _ = menuRemove

#endif

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

foreign import ccall "g_menu_remove_all" g_menu_remove_all ::
    Ptr Menu ->                             -- menu : TInterface (Name {namespace = "Gio", name = "Menu"})
    IO ()

{- |
Removes all items in the menu.

/Since: 2.38/
-}
menuRemoveAll ::
    (B.CallStack.HasCallStack, MonadIO m, IsMenu a) =>
    a
    {- ^ /@menu@/: a 'GI.Gio.Objects.Menu.Menu' -}
    -> m ()
menuRemoveAll menu = liftIO $ do
    menu' <- unsafeManagedPtrCastPtr menu
    g_menu_remove_all menu'
    touchManagedPtr menu
    return ()

#if ENABLE_OVERLOADING
data MenuRemoveAllMethodInfo
instance (signature ~ (m ()), MonadIO m, IsMenu a) => O.MethodInfo MenuRemoveAllMethodInfo a signature where
    overloadedMethod _ = menuRemoveAll

#endif