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

    A @GOptionContext@ struct defines which options
    are accepted by the commandline option parser. The struct has only private
    fields and should not be directly accessed.
    -}

    #define ENABLE_OVERLOADING \
           (!defined(__HADDOCK_VERSION__))

    module GI.GLib.Structs.OptionContext
        (

    -- * Exported types
        OptionContext(..)                       ,
        noOptionContext                         ,

     -- * Methods
    -- ** addGroup #method:addGroup#

    #if ENABLE_OVERLOADING
        OptionContextAddGroupMethodInfo         ,
    #endif
        optionContextAddGroup                   ,

    -- ** addMainEntries #method:addMainEntries#

    #if ENABLE_OVERLOADING
        OptionContextAddMainEntriesMethodInfo   ,
    #endif
        optionContextAddMainEntries             ,

    -- ** free #method:free#

    #if ENABLE_OVERLOADING
        OptionContextFreeMethodInfo             ,
    #endif
        optionContextFree                       ,

    -- ** getDescription #method:getDescription#

    #if ENABLE_OVERLOADING
        OptionContextGetDescriptionMethodInfo   ,
    #endif
        optionContextGetDescription             ,

    -- ** getHelp #method:getHelp#

    #if ENABLE_OVERLOADING
        OptionContextGetHelpMethodInfo          ,
    #endif
        optionContextGetHelp                    ,

    -- ** getHelpEnabled #method:getHelpEnabled#

    #if ENABLE_OVERLOADING
        OptionContextGetHelpEnabledMethodInfo   ,
    #endif
        optionContextGetHelpEnabled             ,

    -- ** getIgnoreUnknownOptions #method:getIgnoreUnknownOptions#

    #if ENABLE_OVERLOADING
        OptionContextGetIgnoreUnknownOptionsMethodInfo,
    #endif
        optionContextGetIgnoreUnknownOptions    ,

    -- ** getMainGroup #method:getMainGroup#

    #if ENABLE_OVERLOADING
        OptionContextGetMainGroupMethodInfo     ,
    #endif
        optionContextGetMainGroup               ,

    -- ** getStrictPosix #method:getStrictPosix#

    #if ENABLE_OVERLOADING
        OptionContextGetStrictPosixMethodInfo   ,
    #endif
        optionContextGetStrictPosix             ,

    -- ** getSummary #method:getSummary#

    #if ENABLE_OVERLOADING
        OptionContextGetSummaryMethodInfo       ,
    #endif
        optionContextGetSummary                 ,

    -- ** parse #method:parse#

    #if ENABLE_OVERLOADING
        OptionContextParseMethodInfo            ,
    #endif
        optionContextParse                      ,

    -- ** parseStrv #method:parseStrv#

    #if ENABLE_OVERLOADING
        OptionContextParseStrvMethodInfo        ,
    #endif
        optionContextParseStrv                  ,

    -- ** setDescription #method:setDescription#

    #if ENABLE_OVERLOADING
        OptionContextSetDescriptionMethodInfo   ,
    #endif
        optionContextSetDescription             ,

    -- ** setHelpEnabled #method:setHelpEnabled#

    #if ENABLE_OVERLOADING
        OptionContextSetHelpEnabledMethodInfo   ,
    #endif
        optionContextSetHelpEnabled             ,

    -- ** setIgnoreUnknownOptions #method:setIgnoreUnknownOptions#

    #if ENABLE_OVERLOADING
        OptionContextSetIgnoreUnknownOptionsMethodInfo,
    #endif
        optionContextSetIgnoreUnknownOptions    ,

    -- ** setMainGroup #method:setMainGroup#

    #if ENABLE_OVERLOADING
        OptionContextSetMainGroupMethodInfo     ,
    #endif
        optionContextSetMainGroup               ,

    -- ** setStrictPosix #method:setStrictPosix#

    #if ENABLE_OVERLOADING
        OptionContextSetStrictPosixMethodInfo   ,
    #endif
        optionContextSetStrictPosix             ,

    -- ** setSummary #method:setSummary#

    #if ENABLE_OVERLOADING
        OptionContextSetSummaryMethodInfo       ,
    #endif
        optionContextSetSummary                 ,

    -- ** setTranslateFunc #method:setTranslateFunc#

    #if ENABLE_OVERLOADING
        OptionContextSetTranslateFuncMethodInfo ,
    #endif
        optionContextSetTranslateFunc           ,

    -- ** setTranslationDomain #method:setTranslationDomain#

    #if ENABLE_OVERLOADING
        OptionContextSetTranslationDomainMethodInfo,
    #endif
        optionContextSetTranslationDomain       ,

        ) 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.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.Text as T
    import qualified Data.ByteString.Char8 as B
    import qualified Data.Map as Map
    import qualified Foreign.Ptr as FP

    import qualified GI.GLib.Callbacks as GLib.Callbacks
    import {-# SOURCE #-} qualified GI.GLib.Structs.OptionEntry as GLib.OptionEntry
    import {-# SOURCE #-} qualified GI.GLib.Structs.OptionGroup as GLib.OptionGroup

    -- | Memory-managed wrapper type.
    newtype OptionContext = OptionContext (ManagedPtr OptionContext)
    -- XXX Wrapping a foreign struct/union with no known destructor or size, leak?
    instance WrappedPtr OptionContext where
        wrappedPtrCalloc = return nullPtr
        wrappedPtrCopy = return
        wrappedPtrFree = Nothing

    -- | A convenience alias for `Nothing` :: `Maybe` `OptionContext`.
    noOptionContext :: Maybe OptionContext
    noOptionContext = Nothing

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

    -- method OptionContext::add_group
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "GLib", name = "OptionContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GOptionContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "group", argType = TInterface (Name {namespace = "GLib", name = "OptionGroup"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the group to add", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
    -- Lengths : []
    -- returnType : Nothing
    -- throws : False
    -- Skip return : False

    foreign import ccall "g_option_context_add_group" g_option_context_add_group ::
        Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
        Ptr GLib.OptionGroup.OptionGroup ->     -- group : TInterface (Name {namespace = "GLib", name = "OptionGroup"})
        IO ()

    {- |
    Adds a 'GI.GLib.Structs.OptionGroup.OptionGroup' to the /@context@/, so that parsing with /@context@/
    will recognize the options in the group. Note that this will take
    ownership of the /@group@/ and thus the /@group@/ should not be freed.

    /Since: 2.6/
    -}
    optionContextAddGroup ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        OptionContext
        {- ^ /@context@/: a 'GI.GLib.Structs.OptionContext.OptionContext' -}
        -> GLib.OptionGroup.OptionGroup
        {- ^ /@group@/: the group to add -}
        -> m ()
    optionContextAddGroup context group = liftIO $ do
        context' <- unsafeManagedPtrGetPtr context
        group' <- B.ManagedPtr.disownBoxed group
        g_option_context_add_group context' group'
        touchManagedPtr context
        touchManagedPtr group
        return ()

    #if ENABLE_OVERLOADING
    data OptionContextAddGroupMethodInfo
    instance (signature ~ (GLib.OptionGroup.OptionGroup -> m ()), MonadIO m) => O.MethodInfo OptionContextAddGroupMethodInfo OptionContext signature where
        overloadedMethod _ = optionContextAddGroup

    #endif

    -- method OptionContext::add_main_entries
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "GLib", name = "OptionContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GOptionContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "entries", argType = TInterface (Name {namespace = "GLib", name = "OptionEntry"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a %NULL-terminated array of #GOptionEntrys", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "translation_domain", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a translation domain to use for translating\n   the `--help` output for the options in @entries\n   with gettext(), 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_option_context_add_main_entries" g_option_context_add_main_entries ::
        Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
        Ptr GLib.OptionEntry.OptionEntry ->     -- entries : TInterface (Name {namespace = "GLib", name = "OptionEntry"})
        CString ->                              -- translation_domain : TBasicType TUTF8
        IO ()

    {- |
    A convenience function which creates a main group if it doesn\'t
    exist, adds the /@entries@/ to it and sets the translation domain.

    /Since: 2.6/
    -}
    optionContextAddMainEntries ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        OptionContext
        {- ^ /@context@/: a 'GI.GLib.Structs.OptionContext.OptionContext' -}
        -> GLib.OptionEntry.OptionEntry
        {- ^ /@entries@/: a 'Nothing'-terminated array of @/GOptionEntrys/@ -}
        -> Maybe (T.Text)
        {- ^ /@translationDomain@/: a translation domain to use for translating
       the @--help@ output for the options in /@entries@/
       with @/gettext()/@, or 'Nothing' -}
        -> m ()
    optionContextAddMainEntries context entries translationDomain = liftIO $ do
        context' <- unsafeManagedPtrGetPtr context
        entries' <- unsafeManagedPtrGetPtr entries
        maybeTranslationDomain <- case translationDomain of
            Nothing -> return nullPtr
            Just jTranslationDomain -> do
                jTranslationDomain' <- textToCString jTranslationDomain
                return jTranslationDomain'
        g_option_context_add_main_entries context' entries' maybeTranslationDomain
        touchManagedPtr context
        touchManagedPtr entries
        freeMem maybeTranslationDomain
        return ()

    #if ENABLE_OVERLOADING
    data OptionContextAddMainEntriesMethodInfo
    instance (signature ~ (GLib.OptionEntry.OptionEntry -> Maybe (T.Text) -> m ()), MonadIO m) => O.MethodInfo OptionContextAddMainEntriesMethodInfo OptionContext signature where
        overloadedMethod _ = optionContextAddMainEntries

    #endif

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

    foreign import ccall "g_option_context_free" g_option_context_free ::
        Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
        IO ()

    {- |
    Frees context and all the groups which have been
    added to it.

    Please note that parsed arguments need to be freed separately (see
    'GI.GLib.Structs.OptionEntry.OptionEntry').

    /Since: 2.6/
    -}
    optionContextFree ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        OptionContext
        {- ^ /@context@/: a 'GI.GLib.Structs.OptionContext.OptionContext' -}
        -> m ()
    optionContextFree context = liftIO $ do
        context' <- unsafeManagedPtrGetPtr context
        g_option_context_free context'
        touchManagedPtr context
        return ()

    #if ENABLE_OVERLOADING
    data OptionContextFreeMethodInfo
    instance (signature ~ (m ()), MonadIO m) => O.MethodInfo OptionContextFreeMethodInfo OptionContext signature where
        overloadedMethod _ = optionContextFree

    #endif

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

    foreign import ccall "g_option_context_get_description" g_option_context_get_description ::
        Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
        IO CString

    {- |
    Returns the description. See 'GI.GLib.Structs.OptionContext.optionContextSetDescription'.

    /Since: 2.12/
    -}
    optionContextGetDescription ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        OptionContext
        {- ^ /@context@/: a 'GI.GLib.Structs.OptionContext.OptionContext' -}
        -> m T.Text
        {- ^ __Returns:__ the description -}
    optionContextGetDescription context = liftIO $ do
        context' <- unsafeManagedPtrGetPtr context
        result <- g_option_context_get_description context'
        checkUnexpectedReturnNULL "optionContextGetDescription" result
        result' <- cstringToText result
        touchManagedPtr context
        return result'

    #if ENABLE_OVERLOADING
    data OptionContextGetDescriptionMethodInfo
    instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo OptionContextGetDescriptionMethodInfo OptionContext signature where
        overloadedMethod _ = optionContextGetDescription

    #endif

    -- method OptionContext::get_help
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "GLib", name = "OptionContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GOptionContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "main_help", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "if %TRUE, only include the main group", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "group", argType = TInterface (Name {namespace = "GLib", name = "OptionGroup"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the #GOptionGroup to create help for, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
    -- Lengths : []
    -- returnType : Just (TBasicType TUTF8)
    -- throws : False
    -- Skip return : False

    foreign import ccall "g_option_context_get_help" g_option_context_get_help ::
        Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
        CInt ->                                 -- main_help : TBasicType TBoolean
        Ptr GLib.OptionGroup.OptionGroup ->     -- group : TInterface (Name {namespace = "GLib", name = "OptionGroup"})
        IO CString

    {- |
    Returns a formatted, translated help text for the given context.
    To obtain the text produced by @--help@, call
    @g_option_context_get_help (context, TRUE, NULL)@.
    To obtain the text produced by @--help-all@, call
    @g_option_context_get_help (context, FALSE, NULL)@.
    To obtain the help text for an option group, call
    @g_option_context_get_help (context, FALSE, group)@.

    /Since: 2.14/
    -}
    optionContextGetHelp ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        OptionContext
        {- ^ /@context@/: a 'GI.GLib.Structs.OptionContext.OptionContext' -}
        -> Bool
        {- ^ /@mainHelp@/: if 'True', only include the main group -}
        -> Maybe (GLib.OptionGroup.OptionGroup)
        {- ^ /@group@/: the 'GI.GLib.Structs.OptionGroup.OptionGroup' to create help for, or 'Nothing' -}
        -> m T.Text
        {- ^ __Returns:__ A newly allocated string containing the help text -}
    optionContextGetHelp context mainHelp group = liftIO $ do
        context' <- unsafeManagedPtrGetPtr context
        let mainHelp' = (fromIntegral . fromEnum) mainHelp
        maybeGroup <- case group of
            Nothing -> return nullPtr
            Just jGroup -> do
                jGroup' <- unsafeManagedPtrGetPtr jGroup
                return jGroup'
        result <- g_option_context_get_help context' mainHelp' maybeGroup
        checkUnexpectedReturnNULL "optionContextGetHelp" result
        result' <- cstringToText result
        freeMem result
        touchManagedPtr context
        whenJust group touchManagedPtr
        return result'

    #if ENABLE_OVERLOADING
    data OptionContextGetHelpMethodInfo
    instance (signature ~ (Bool -> Maybe (GLib.OptionGroup.OptionGroup) -> m T.Text), MonadIO m) => O.MethodInfo OptionContextGetHelpMethodInfo OptionContext signature where
        overloadedMethod _ = optionContextGetHelp

    #endif

    -- method OptionContext::get_help_enabled
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "GLib", name = "OptionContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GOptionContext", 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 "g_option_context_get_help_enabled" g_option_context_get_help_enabled ::
        Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
        IO CInt

    {- |
    Returns whether automatic @--help@ generation
    is turned on for /@context@/. See 'GI.GLib.Structs.OptionContext.optionContextSetHelpEnabled'.

    /Since: 2.6/
    -}
    optionContextGetHelpEnabled ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        OptionContext
        {- ^ /@context@/: a 'GI.GLib.Structs.OptionContext.OptionContext' -}
        -> m Bool
        {- ^ __Returns:__ 'True' if automatic help generation is turned on. -}
    optionContextGetHelpEnabled context = liftIO $ do
        context' <- unsafeManagedPtrGetPtr context
        result <- g_option_context_get_help_enabled context'
        let result' = (/= 0) result
        touchManagedPtr context
        return result'

    #if ENABLE_OVERLOADING
    data OptionContextGetHelpEnabledMethodInfo
    instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo OptionContextGetHelpEnabledMethodInfo OptionContext signature where
        overloadedMethod _ = optionContextGetHelpEnabled

    #endif

    -- method OptionContext::get_ignore_unknown_options
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "GLib", name = "OptionContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GOptionContext", 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 "g_option_context_get_ignore_unknown_options" g_option_context_get_ignore_unknown_options ::
        Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
        IO CInt

    {- |
    Returns whether unknown options are ignored or not. See
    'GI.GLib.Structs.OptionContext.optionContextSetIgnoreUnknownOptions'.

    /Since: 2.6/
    -}
    optionContextGetIgnoreUnknownOptions ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        OptionContext
        {- ^ /@context@/: a 'GI.GLib.Structs.OptionContext.OptionContext' -}
        -> m Bool
        {- ^ __Returns:__ 'True' if unknown options are ignored. -}
    optionContextGetIgnoreUnknownOptions context = liftIO $ do
        context' <- unsafeManagedPtrGetPtr context
        result <- g_option_context_get_ignore_unknown_options context'
        let result' = (/= 0) result
        touchManagedPtr context
        return result'

    #if ENABLE_OVERLOADING
    data OptionContextGetIgnoreUnknownOptionsMethodInfo
    instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo OptionContextGetIgnoreUnknownOptionsMethodInfo OptionContext signature where
        overloadedMethod _ = optionContextGetIgnoreUnknownOptions

    #endif

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

    foreign import ccall "g_option_context_get_main_group" g_option_context_get_main_group ::
        Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
        IO (Ptr GLib.OptionGroup.OptionGroup)

    {- |
    Returns a pointer to the main group of /@context@/.

    /Since: 2.6/
    -}
    optionContextGetMainGroup ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        OptionContext
        {- ^ /@context@/: a 'GI.GLib.Structs.OptionContext.OptionContext' -}
        -> m GLib.OptionGroup.OptionGroup
        {- ^ __Returns:__ the main group of /@context@/, or 'Nothing' if
     /@context@/ doesn\'t have a main group. Note that group belongs to
     /@context@/ and should not be modified or freed. -}
    optionContextGetMainGroup context = liftIO $ do
        context' <- unsafeManagedPtrGetPtr context
        result <- g_option_context_get_main_group context'
        checkUnexpectedReturnNULL "optionContextGetMainGroup" result
        result' <- (newBoxed GLib.OptionGroup.OptionGroup) result
        touchManagedPtr context
        return result'

    #if ENABLE_OVERLOADING
    data OptionContextGetMainGroupMethodInfo
    instance (signature ~ (m GLib.OptionGroup.OptionGroup), MonadIO m) => O.MethodInfo OptionContextGetMainGroupMethodInfo OptionContext signature where
        overloadedMethod _ = optionContextGetMainGroup

    #endif

    -- method OptionContext::get_strict_posix
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "GLib", name = "OptionContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GOptionContext", 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 "g_option_context_get_strict_posix" g_option_context_get_strict_posix ::
        Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
        IO CInt

    {- |
    Returns whether strict POSIX code is enabled.

    See 'GI.GLib.Structs.OptionContext.optionContextSetStrictPosix' for more information.

    /Since: 2.44/
    -}
    optionContextGetStrictPosix ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        OptionContext
        {- ^ /@context@/: a 'GI.GLib.Structs.OptionContext.OptionContext' -}
        -> m Bool
        {- ^ __Returns:__ 'True' if strict POSIX is enabled, 'False' otherwise. -}
    optionContextGetStrictPosix context = liftIO $ do
        context' <- unsafeManagedPtrGetPtr context
        result <- g_option_context_get_strict_posix context'
        let result' = (/= 0) result
        touchManagedPtr context
        return result'

    #if ENABLE_OVERLOADING
    data OptionContextGetStrictPosixMethodInfo
    instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo OptionContextGetStrictPosixMethodInfo OptionContext signature where
        overloadedMethod _ = optionContextGetStrictPosix

    #endif

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

    foreign import ccall "g_option_context_get_summary" g_option_context_get_summary ::
        Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
        IO CString

    {- |
    Returns the summary. See 'GI.GLib.Structs.OptionContext.optionContextSetSummary'.

    /Since: 2.12/
    -}
    optionContextGetSummary ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        OptionContext
        {- ^ /@context@/: a 'GI.GLib.Structs.OptionContext.OptionContext' -}
        -> m T.Text
        {- ^ __Returns:__ the summary -}
    optionContextGetSummary context = liftIO $ do
        context' <- unsafeManagedPtrGetPtr context
        result <- g_option_context_get_summary context'
        checkUnexpectedReturnNULL "optionContextGetSummary" result
        result' <- cstringToText result
        touchManagedPtr context
        return result'

    #if ENABLE_OVERLOADING
    data OptionContextGetSummaryMethodInfo
    instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo OptionContextGetSummaryMethodInfo OptionContext signature where
        overloadedMethod _ = optionContextGetSummary

    #endif

    -- method OptionContext::parse
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "GLib", name = "OptionContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GOptionContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "argc", argType = TBasicType TInt, direction = DirectionInout, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a pointer to the number of command line arguments", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "argv", argType = TCArray False (-1) 1 (TBasicType TUTF8), direction = DirectionInout, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a pointer to the array of command line arguments", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
    -- Lengths : [Arg {argCName = "argc", argType = TBasicType TInt, direction = DirectionInout, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a pointer to the number of command line arguments", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
    -- returnType : Just (TBasicType TBoolean)
    -- throws : True
    -- Skip return : False

    foreign import ccall "g_option_context_parse" g_option_context_parse ::
        Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
        Ptr Int32 ->                            -- argc : TBasicType TInt
        Ptr (Ptr CString) ->                    -- argv : TCArray False (-1) 1 (TBasicType TUTF8)
        Ptr (Ptr GError) ->                     -- error
        IO CInt

    {- |
    Parses the command line arguments, recognizing options
    which have been added to /@context@/. A side-effect of
    calling this function is that 'GI.GLib.Functions.setPrgname' will be
    called.

    If the parsing is successful, any parsed arguments are
    removed from the array and /@argc@/ and /@argv@/ are updated
    accordingly. A \'--\' option is stripped from /@argv@/
    unless there are unparsed options before and after it,
    or some of the options after it start with \'-\'. In case
    of an error, /@argc@/ and /@argv@/ are left unmodified.

    If automatic @--help@ support is enabled
    (see 'GI.GLib.Structs.OptionContext.optionContextSetHelpEnabled'), and the
    /@argv@/ array contains one of the recognized help options,
    this function will produce help output to stdout and
    call @exit (0)@.

    Note that function depends on the [current locale][setlocale] for
    automatic character set conversion of string and filename
    arguments.

    /Since: 2.6/
    -}
    optionContextParse ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        OptionContext
        {- ^ /@context@/: a 'GI.GLib.Structs.OptionContext.OptionContext' -}
        -> Maybe ([T.Text])
        {- ^ /@argv@/: a pointer to the array of command line arguments -}
        -> m ((Maybe [T.Text]))
        {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
    optionContextParse context argv = liftIO $ do
        let argc = case argv of
                Nothing -> 0
                Just jArgv -> fromIntegral $ length jArgv
        context' <- unsafeManagedPtrGetPtr context
        argc' <- allocMem :: IO (Ptr Int32)
        poke argc' argc
        maybeArgv <- case argv of
            Nothing -> return nullPtr
            Just jArgv -> do
                jArgv' <- packUTF8CArray jArgv
                return jArgv'
        maybeArgv' <- allocMem :: IO (Ptr (Ptr CString))
        poke maybeArgv' maybeArgv
        onException (do
            _ <- propagateGError $ g_option_context_parse context' argc' maybeArgv'
            argc'' <- peek argc'
            maybeArgv'' <- peek maybeArgv'
            maybeMaybeArgv'' <- convertIfNonNull maybeArgv'' $ \maybeArgv''' -> do
                maybeArgv'''' <- (unpackUTF8CArrayWithLength argc'') maybeArgv'''
                (mapCArrayWithLength argc'') freeMem maybeArgv'''
                freeMem maybeArgv'''
                return maybeArgv''''
            touchManagedPtr context
            freeMem argc'
            freeMem maybeArgv'
            return maybeMaybeArgv''
         ) (do
            freeMem argc'
            freeMem maybeArgv'
         )

    #if ENABLE_OVERLOADING
    data OptionContextParseMethodInfo
    instance (signature ~ (Maybe ([T.Text]) -> m ((Maybe [T.Text]))), MonadIO m) => O.MethodInfo OptionContextParseMethodInfo OptionContext signature where
        overloadedMethod _ = optionContextParse

    #endif

    -- method OptionContext::parse_strv
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "GLib", name = "OptionContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GOptionContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "arguments", argType = TCArray True (-1) (-1) (TBasicType TUTF8), direction = DirectionInout, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to the\n   command line arguments (which must be in UTF-8 on Windows)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
    -- Lengths : []
    -- returnType : Just (TBasicType TBoolean)
    -- throws : True
    -- Skip return : False

    foreign import ccall "g_option_context_parse_strv" g_option_context_parse_strv ::
        Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
        Ptr (Ptr CString) ->                    -- arguments : TCArray True (-1) (-1) (TBasicType TUTF8)
        Ptr (Ptr GError) ->                     -- error
        IO CInt

    {- |
    Parses the command line arguments.

    This function is similar to 'GI.GLib.Structs.OptionContext.optionContextParse' except that it
    respects the normal memory rules when dealing with a strv instead of
    assuming that the passed-in array is the argv of the main function.

    In particular, strings that are removed from the arguments list will
    be freed using 'GI.GLib.Functions.free'.

    On Windows, the strings are expected to be in UTF-8.  This is in
    contrast to 'GI.GLib.Structs.OptionContext.optionContextParse' which expects them to be in the
    system codepage, which is how they are passed as /@argv@/ to @/main()/@.
    See @/g_win32_get_command_line()/@ for a solution.

    This function is useful if you are trying to use 'GI.GLib.Structs.OptionContext.OptionContext' with
    @/GApplication/@.

    /Since: 2.40/
    -}
    optionContextParseStrv ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        OptionContext
        {- ^ /@context@/: a 'GI.GLib.Structs.OptionContext.OptionContext' -}
        -> [T.Text]
        {- ^ /@arguments@/: a pointer to the
       command line arguments (which must be in UTF-8 on Windows) -}
        -> m ([T.Text])
        {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
    optionContextParseStrv context arguments = liftIO $ do
        context' <- unsafeManagedPtrGetPtr context
        arguments' <- packZeroTerminatedUTF8CArray arguments
        arguments'' <- allocMem :: IO (Ptr (Ptr CString))
        poke arguments'' arguments'
        onException (do
            _ <- propagateGError $ g_option_context_parse_strv context' arguments''
            arguments''' <- peek arguments''
            arguments'''' <- unpackZeroTerminatedUTF8CArray arguments'''
            mapZeroTerminatedCArray freeMem arguments'''
            freeMem arguments'''
            touchManagedPtr context
            freeMem arguments''
            return arguments''''
         ) (do
            freeMem arguments''
         )

    #if ENABLE_OVERLOADING
    data OptionContextParseStrvMethodInfo
    instance (signature ~ ([T.Text] -> m ([T.Text])), MonadIO m) => O.MethodInfo OptionContextParseStrvMethodInfo OptionContext signature where
        overloadedMethod _ = optionContextParseStrv

    #endif

    -- method OptionContext::set_description
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "GLib", name = "OptionContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GOptionContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "description", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a string to be shown in `--help` output\n  after the list of options, 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_option_context_set_description" g_option_context_set_description ::
        Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
        CString ->                              -- description : TBasicType TUTF8
        IO ()

    {- |
    Adds a string to be displayed in @--help@ output after the list
    of options. This text often includes a bug reporting address.

    Note that the summary is translated (see
    'GI.GLib.Structs.OptionContext.optionContextSetTranslateFunc').

    /Since: 2.12/
    -}
    optionContextSetDescription ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        OptionContext
        {- ^ /@context@/: a 'GI.GLib.Structs.OptionContext.OptionContext' -}
        -> Maybe (T.Text)
        {- ^ /@description@/: a string to be shown in @--help@ output
      after the list of options, or 'Nothing' -}
        -> m ()
    optionContextSetDescription context description = liftIO $ do
        context' <- unsafeManagedPtrGetPtr context
        maybeDescription <- case description of
            Nothing -> return nullPtr
            Just jDescription -> do
                jDescription' <- textToCString jDescription
                return jDescription'
        g_option_context_set_description context' maybeDescription
        touchManagedPtr context
        freeMem maybeDescription
        return ()

    #if ENABLE_OVERLOADING
    data OptionContextSetDescriptionMethodInfo
    instance (signature ~ (Maybe (T.Text) -> m ()), MonadIO m) => O.MethodInfo OptionContextSetDescriptionMethodInfo OptionContext signature where
        overloadedMethod _ = optionContextSetDescription

    #endif

    -- method OptionContext::set_help_enabled
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "GLib", name = "OptionContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GOptionContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "help_enabled", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "%TRUE to enable `--help`, %FALSE to disable it", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
    -- Lengths : []
    -- returnType : Nothing
    -- throws : False
    -- Skip return : False

    foreign import ccall "g_option_context_set_help_enabled" g_option_context_set_help_enabled ::
        Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
        CInt ->                                 -- help_enabled : TBasicType TBoolean
        IO ()

    {- |
    Enables or disables automatic generation of @--help@ output.
    By default, 'GI.GLib.Structs.OptionContext.optionContextParse' recognizes @--help@, @-h@,
    @-?@, @--help-all@ and @--help-groupname@ and creates suitable
    output to stdout.

    /Since: 2.6/
    -}
    optionContextSetHelpEnabled ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        OptionContext
        {- ^ /@context@/: a 'GI.GLib.Structs.OptionContext.OptionContext' -}
        -> Bool
        {- ^ /@helpEnabled@/: 'True' to enable @--help@, 'False' to disable it -}
        -> m ()
    optionContextSetHelpEnabled context helpEnabled = liftIO $ do
        context' <- unsafeManagedPtrGetPtr context
        let helpEnabled' = (fromIntegral . fromEnum) helpEnabled
        g_option_context_set_help_enabled context' helpEnabled'
        touchManagedPtr context
        return ()

    #if ENABLE_OVERLOADING
    data OptionContextSetHelpEnabledMethodInfo
    instance (signature ~ (Bool -> m ()), MonadIO m) => O.MethodInfo OptionContextSetHelpEnabledMethodInfo OptionContext signature where
        overloadedMethod _ = optionContextSetHelpEnabled

    #endif

    -- method OptionContext::set_ignore_unknown_options
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "GLib", name = "OptionContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GOptionContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "ignore_unknown", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "%TRUE to ignore unknown options, %FALSE to produce\n   an error when unknown options are met", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
    -- Lengths : []
    -- returnType : Nothing
    -- throws : False
    -- Skip return : False

    foreign import ccall "g_option_context_set_ignore_unknown_options" g_option_context_set_ignore_unknown_options ::
        Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
        CInt ->                                 -- ignore_unknown : TBasicType TBoolean
        IO ()

    {- |
    Sets whether to ignore unknown options or not. If an argument is
    ignored, it is left in the /@argv@/ array after parsing. By default,
    'GI.GLib.Structs.OptionContext.optionContextParse' treats unknown options as error.

    This setting does not affect non-option arguments (i.e. arguments
    which don\'t start with a dash). But note that GOption cannot reliably
    determine whether a non-option belongs to a preceding unknown option.

    /Since: 2.6/
    -}
    optionContextSetIgnoreUnknownOptions ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        OptionContext
        {- ^ /@context@/: a 'GI.GLib.Structs.OptionContext.OptionContext' -}
        -> Bool
        {- ^ /@ignoreUnknown@/: 'True' to ignore unknown options, 'False' to produce
       an error when unknown options are met -}
        -> m ()
    optionContextSetIgnoreUnknownOptions context ignoreUnknown = liftIO $ do
        context' <- unsafeManagedPtrGetPtr context
        let ignoreUnknown' = (fromIntegral . fromEnum) ignoreUnknown
        g_option_context_set_ignore_unknown_options context' ignoreUnknown'
        touchManagedPtr context
        return ()

    #if ENABLE_OVERLOADING
    data OptionContextSetIgnoreUnknownOptionsMethodInfo
    instance (signature ~ (Bool -> m ()), MonadIO m) => O.MethodInfo OptionContextSetIgnoreUnknownOptionsMethodInfo OptionContext signature where
        overloadedMethod _ = optionContextSetIgnoreUnknownOptions

    #endif

    -- method OptionContext::set_main_group
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "GLib", name = "OptionContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GOptionContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "group", argType = TInterface (Name {namespace = "GLib", name = "OptionGroup"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the group to set as main group", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
    -- Lengths : []
    -- returnType : Nothing
    -- throws : False
    -- Skip return : False

    foreign import ccall "g_option_context_set_main_group" g_option_context_set_main_group ::
        Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
        Ptr GLib.OptionGroup.OptionGroup ->     -- group : TInterface (Name {namespace = "GLib", name = "OptionGroup"})
        IO ()

    {- |
    Sets a 'GI.GLib.Structs.OptionGroup.OptionGroup' as main group of the /@context@/.
    This has the same effect as calling 'GI.GLib.Structs.OptionContext.optionContextAddGroup',
    the only difference is that the options in the main group are
    treated differently when generating @--help@ output.

    /Since: 2.6/
    -}
    optionContextSetMainGroup ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        OptionContext
        {- ^ /@context@/: a 'GI.GLib.Structs.OptionContext.OptionContext' -}
        -> GLib.OptionGroup.OptionGroup
        {- ^ /@group@/: the group to set as main group -}
        -> m ()
    optionContextSetMainGroup context group = liftIO $ do
        context' <- unsafeManagedPtrGetPtr context
        group' <- B.ManagedPtr.disownBoxed group
        g_option_context_set_main_group context' group'
        touchManagedPtr context
        touchManagedPtr group
        return ()

    #if ENABLE_OVERLOADING
    data OptionContextSetMainGroupMethodInfo
    instance (signature ~ (GLib.OptionGroup.OptionGroup -> m ()), MonadIO m) => O.MethodInfo OptionContextSetMainGroupMethodInfo OptionContext signature where
        overloadedMethod _ = optionContextSetMainGroup

    #endif

    -- method OptionContext::set_strict_posix
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "GLib", name = "OptionContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GOptionContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "strict_posix", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the new value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
    -- Lengths : []
    -- returnType : Nothing
    -- throws : False
    -- Skip return : False

    foreign import ccall "g_option_context_set_strict_posix" g_option_context_set_strict_posix ::
        Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
        CInt ->                                 -- strict_posix : TBasicType TBoolean
        IO ()

    {- |
    Sets strict POSIX mode.

    By default, this mode is disabled.

    In strict POSIX mode, the first non-argument parameter encountered
    (eg: filename) terminates argument processing.  Remaining arguments
    are treated as non-options and are not attempted to be parsed.

    If strict POSIX mode is disabled then parsing is done in the GNU way
    where option arguments can be freely mixed with non-options.

    As an example, consider \"ls foo -l\".  With GNU style parsing, this
    will list \"foo\" in long mode.  In strict POSIX style, this will list
    the files named \"foo\" and \"-l\".

    It may be useful to force strict POSIX mode when creating \"verb
    style\" command line tools.  For example, the \"gsettings\" command line
    tool supports the global option \"--schemadir\" as well as many
    subcommands (\"get\", \"set\", etc.) which each have their own set of
    arguments.  Using strict POSIX mode will allow parsing the global
    options up to the verb name while leaving the remaining options to be
    parsed by the relevant subcommand (which can be determined by
    examining the verb name, which should be present in argv[1] after
    parsing).

    /Since: 2.44/
    -}
    optionContextSetStrictPosix ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        OptionContext
        {- ^ /@context@/: a 'GI.GLib.Structs.OptionContext.OptionContext' -}
        -> Bool
        {- ^ /@strictPosix@/: the new value -}
        -> m ()
    optionContextSetStrictPosix context strictPosix = liftIO $ do
        context' <- unsafeManagedPtrGetPtr context
        let strictPosix' = (fromIntegral . fromEnum) strictPosix
        g_option_context_set_strict_posix context' strictPosix'
        touchManagedPtr context
        return ()

    #if ENABLE_OVERLOADING
    data OptionContextSetStrictPosixMethodInfo
    instance (signature ~ (Bool -> m ()), MonadIO m) => O.MethodInfo OptionContextSetStrictPosixMethodInfo OptionContext signature where
        overloadedMethod _ = optionContextSetStrictPosix

    #endif

    -- method OptionContext::set_summary
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "GLib", name = "OptionContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GOptionContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "summary", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a string to be shown in `--help` output\n before the list of options, 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_option_context_set_summary" g_option_context_set_summary ::
        Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
        CString ->                              -- summary : TBasicType TUTF8
        IO ()

    {- |
    Adds a string to be displayed in @--help@ output before the list
    of options. This is typically a summary of the program functionality.

    Note that the summary is translated (see
    'GI.GLib.Structs.OptionContext.optionContextSetTranslateFunc' and
    'GI.GLib.Structs.OptionContext.optionContextSetTranslationDomain').

    /Since: 2.12/
    -}
    optionContextSetSummary ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        OptionContext
        {- ^ /@context@/: a 'GI.GLib.Structs.OptionContext.OptionContext' -}
        -> Maybe (T.Text)
        {- ^ /@summary@/: a string to be shown in @--help@ output
     before the list of options, or 'Nothing' -}
        -> m ()
    optionContextSetSummary context summary = liftIO $ do
        context' <- unsafeManagedPtrGetPtr context
        maybeSummary <- case summary of
            Nothing -> return nullPtr
            Just jSummary -> do
                jSummary' <- textToCString jSummary
                return jSummary'
        g_option_context_set_summary context' maybeSummary
        touchManagedPtr context
        freeMem maybeSummary
        return ()

    #if ENABLE_OVERLOADING
    data OptionContextSetSummaryMethodInfo
    instance (signature ~ (Maybe (T.Text) -> m ()), MonadIO m) => O.MethodInfo OptionContextSetSummaryMethodInfo OptionContext signature where
        overloadedMethod _ = optionContextSetSummary

    #endif

    -- method OptionContext::set_translate_func
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "GLib", name = "OptionContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GOptionContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "func", argType = TInterface (Name {namespace = "GLib", name = "TranslateFunc"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the #GTranslateFunc, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeNotified, argClosure = 2, argDestroy = 3, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data to pass to @func, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "destroy_notify", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a function which gets called to free @data, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
    -- Lengths : []
    -- returnType : Nothing
    -- throws : False
    -- Skip return : False

    foreign import ccall "g_option_context_set_translate_func" g_option_context_set_translate_func ::
        Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
        FunPtr GLib.Callbacks.C_TranslateFunc -> -- func : TInterface (Name {namespace = "GLib", name = "TranslateFunc"})
        Ptr () ->                               -- data : TBasicType TPtr
        FunPtr GLib.Callbacks.C_DestroyNotify -> -- destroy_notify : TInterface (Name {namespace = "GLib", name = "DestroyNotify"})
        IO ()

    {- |
    Sets the function which is used to translate the contexts
    user-visible strings, for @--help@ output. If /@func@/ is 'Nothing',
    strings are not translated.

    Note that option groups have their own translation functions,
    this function only affects the /@parameterString@/ (see @/g_option_context_new()/@),
    the summary (see 'GI.GLib.Structs.OptionContext.optionContextSetSummary') and the description
    (see 'GI.GLib.Structs.OptionContext.optionContextSetDescription').

    If you are using @/gettext()/@, you only need to set the translation
    domain, see 'GI.GLib.Structs.OptionContext.optionContextSetTranslationDomain'.

    /Since: 2.12/
    -}
    optionContextSetTranslateFunc ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        OptionContext
        {- ^ /@context@/: a 'GI.GLib.Structs.OptionContext.OptionContext' -}
        -> Maybe (GLib.Callbacks.TranslateFunc)
        {- ^ /@func@/: the 'GI.GLib.Callbacks.TranslateFunc', or 'Nothing' -}
        -> m ()
    optionContextSetTranslateFunc context func = liftIO $ do
        context' <- unsafeManagedPtrGetPtr context
        maybeFunc <- case func of
            Nothing -> return (castPtrToFunPtr nullPtr)
            Just jFunc -> do
                jFunc' <- GLib.Callbacks.mk_TranslateFunc (GLib.Callbacks.wrap_TranslateFunc Nothing jFunc)
                return jFunc'
        let data_ = castFunPtrToPtr maybeFunc
        let destroyNotify = safeFreeFunPtrPtr
        g_option_context_set_translate_func context' maybeFunc data_ destroyNotify
        touchManagedPtr context
        return ()

    #if ENABLE_OVERLOADING
    data OptionContextSetTranslateFuncMethodInfo
    instance (signature ~ (Maybe (GLib.Callbacks.TranslateFunc) -> m ()), MonadIO m) => O.MethodInfo OptionContextSetTranslateFuncMethodInfo OptionContext signature where
        overloadedMethod _ = optionContextSetTranslateFunc

    #endif

    -- method OptionContext::set_translation_domain
    -- method type : OrdinaryMethod
    -- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "GLib", name = "OptionContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GOptionContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "domain", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the domain to use", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
    -- Lengths : []
    -- returnType : Nothing
    -- throws : False
    -- Skip return : False

    foreign import ccall "g_option_context_set_translation_domain" g_option_context_set_translation_domain ::
        Ptr OptionContext ->                    -- context : TInterface (Name {namespace = "GLib", name = "OptionContext"})
        CString ->                              -- domain : TBasicType TUTF8
        IO ()

    {- |
    A convenience function to use @/gettext()/@ for translating
    user-visible strings.

    /Since: 2.12/
    -}
    optionContextSetTranslationDomain ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        OptionContext
        {- ^ /@context@/: a 'GI.GLib.Structs.OptionContext.OptionContext' -}
        -> T.Text
        {- ^ /@domain@/: the domain to use -}
        -> m ()
    optionContextSetTranslationDomain context domain = liftIO $ do
        context' <- unsafeManagedPtrGetPtr context
        domain' <- textToCString domain
        g_option_context_set_translation_domain context' domain'
        touchManagedPtr context
        freeMem domain'
        return ()

    #if ENABLE_OVERLOADING
    data OptionContextSetTranslationDomainMethodInfo
    instance (signature ~ (T.Text -> m ()), MonadIO m) => O.MethodInfo OptionContextSetTranslationDomainMethodInfo OptionContext signature where
        overloadedMethod _ = optionContextSetTranslationDomain

    #endif

    #if ENABLE_OVERLOADING
    type family ResolveOptionContextMethod (t :: Symbol) (o :: *) :: * where
        ResolveOptionContextMethod "addGroup" o = OptionContextAddGroupMethodInfo
        ResolveOptionContextMethod "addMainEntries" o = OptionContextAddMainEntriesMethodInfo
        ResolveOptionContextMethod "free" o = OptionContextFreeMethodInfo
        ResolveOptionContextMethod "parse" o = OptionContextParseMethodInfo
        ResolveOptionContextMethod "parseStrv" o = OptionContextParseStrvMethodInfo
        ResolveOptionContextMethod "getDescription" o = OptionContextGetDescriptionMethodInfo
        ResolveOptionContextMethod "getHelp" o = OptionContextGetHelpMethodInfo
        ResolveOptionContextMethod "getHelpEnabled" o = OptionContextGetHelpEnabledMethodInfo
        ResolveOptionContextMethod "getIgnoreUnknownOptions" o = OptionContextGetIgnoreUnknownOptionsMethodInfo
        ResolveOptionContextMethod "getMainGroup" o = OptionContextGetMainGroupMethodInfo
        ResolveOptionContextMethod "getStrictPosix" o = OptionContextGetStrictPosixMethodInfo
        ResolveOptionContextMethod "getSummary" o = OptionContextGetSummaryMethodInfo
        ResolveOptionContextMethod "setDescription" o = OptionContextSetDescriptionMethodInfo
        ResolveOptionContextMethod "setHelpEnabled" o = OptionContextSetHelpEnabledMethodInfo
        ResolveOptionContextMethod "setIgnoreUnknownOptions" o = OptionContextSetIgnoreUnknownOptionsMethodInfo
        ResolveOptionContextMethod "setMainGroup" o = OptionContextSetMainGroupMethodInfo
        ResolveOptionContextMethod "setStrictPosix" o = OptionContextSetStrictPosixMethodInfo
        ResolveOptionContextMethod "setSummary" o = OptionContextSetSummaryMethodInfo
        ResolveOptionContextMethod "setTranslateFunc" o = OptionContextSetTranslateFuncMethodInfo
        ResolveOptionContextMethod "setTranslationDomain" o = OptionContextSetTranslationDomainMethodInfo
        ResolveOptionContextMethod l o = O.MethodResolutionFailed l o

    instance (info ~ ResolveOptionContextMethod t OptionContext, O.MethodInfo info OptionContext p) => O.IsLabelProxy t (OptionContext -> p) where
        fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

    #if MIN_VERSION_base(4,9,0)
    instance (info ~ ResolveOptionContextMethod t OptionContext, O.MethodInfo info OptionContext p) => O.IsLabel t (OptionContext -> 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

    #endif