{- |
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 @GOptionGroup@ struct defines the options in a single
group. The struct has only private fields and should not be directly accessed.

All options in a group share the same translation function. Libraries which
need to parse commandline options are expected to provide a function for
getting a @GOptionGroup@ holding their options, which
the application can then add to its 'GI.GLib.Structs.OptionContext.OptionContext'.
-}

#define ENABLE_OVERLOADING \
       (!defined(__HADDOCK_VERSION__))

module GI.GLib.Structs.OptionGroup
    ( 

-- * Exported types
    OptionGroup(..)                         ,
    noOptionGroup                           ,


 -- * Methods
-- ** addEntries #method:addEntries#

#if ENABLE_OVERLOADING
    OptionGroupAddEntriesMethodInfo         ,
#endif
    optionGroupAddEntries                   ,


-- ** free #method:free#

#if ENABLE_OVERLOADING
    OptionGroupFreeMethodInfo               ,
#endif
    optionGroupFree                         ,


-- ** new #method:new#

    optionGroupNew                          ,


-- ** ref #method:ref#

#if ENABLE_OVERLOADING
    OptionGroupRefMethodInfo                ,
#endif
    optionGroupRef                          ,


-- ** setTranslateFunc #method:setTranslateFunc#

#if ENABLE_OVERLOADING
    OptionGroupSetTranslateFuncMethodInfo   ,
#endif
    optionGroupSetTranslateFunc             ,


-- ** setTranslationDomain #method:setTranslationDomain#

#if ENABLE_OVERLOADING
    OptionGroupSetTranslationDomainMethodInfo,
#endif
    optionGroupSetTranslationDomain         ,


-- ** unref #method:unref#

#if ENABLE_OVERLOADING
    OptionGroupUnrefMethodInfo              ,
#endif
    optionGroupUnref                        ,




    ) 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

-- | Memory-managed wrapper type.
newtype OptionGroup = OptionGroup (ManagedPtr OptionGroup)
foreign import ccall "g_option_group_get_type" c_g_option_group_get_type :: 
    IO GType

instance BoxedObject OptionGroup where
    boxedType :: OptionGroup -> IO GType
boxedType _ = IO GType
c_g_option_group_get_type

-- | A convenience alias for `Nothing` :: `Maybe` `OptionGroup`.
noOptionGroup :: Maybe OptionGroup
noOptionGroup :: Maybe OptionGroup
noOptionGroup = Maybe OptionGroup
forall a. Maybe a
Nothing


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

-- method OptionGroup::new
-- method type : Constructor
-- Args : [Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the name for the option group, this is used to provide\n  help for the options in this group with `--help-`@name", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "description", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a description for this group to be shown in\n  `--help`. This string is translated using the translation\n  domain or translation function of the group", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "help_description", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a description for the `--help-`@name option.\n  This string is translated using the translation domain or translation function\n  of the group", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data that will be passed to the pre- and post-parse hooks,\n  the error hook and to callbacks of %G_OPTION_ARG_CALLBACK options, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "destroy", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a function that will be called to free @user_data, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeAsync, 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_group_new" g_option_group_new :: 
    CString ->                              -- name : TBasicType TUTF8
    CString ->                              -- description : TBasicType TUTF8
    CString ->                              -- help_description : TBasicType TUTF8
    Ptr () ->                               -- user_data : TBasicType TPtr
    FunPtr GLib.Callbacks.C_DestroyNotify -> -- destroy : TInterface (Name {namespace = "GLib", name = "DestroyNotify"})
    IO (Ptr OptionGroup)

{- |
Creates a new 'GI.GLib.Structs.OptionGroup.OptionGroup'.

/Since: 2.6/
-}
optionGroupNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@name@/: the name for the option group, this is used to provide
  help for the options in this group with @--help-@/@name@/ -}
    -> T.Text
    {- ^ /@description@/: a description for this group to be shown in
  @--help@. This string is translated using the translation
  domain or translation function of the group -}
    -> T.Text
    {- ^ /@helpDescription@/: a description for the @--help-@/@name@/ option.
  This string is translated using the translation domain or translation function
  of the group -}
    -> Ptr ()
    {- ^ /@userData@/: user data that will be passed to the pre- and post-parse hooks,
  the error hook and to callbacks of 'GI.GLib.Enums.OptionArgCallback' options, or 'Nothing' -}
    -> Maybe (GLib.Callbacks.DestroyNotify)
    {- ^ /@destroy@/: a function that will be called to free /@userData@/, or 'Nothing' -}
    -> m OptionGroup
    {- ^ __Returns:__ a newly created option group. It should be added
  to a 'GI.GLib.Structs.OptionContext.OptionContext' or freed with 'GI.GLib.Structs.OptionGroup.optionGroupUnref'. -}
optionGroupNew :: Text
-> Text -> Text -> Ptr () -> Maybe DestroyNotify -> m OptionGroup
optionGroupNew name :: Text
name description :: Text
description helpDescription :: Text
helpDescription userData :: Ptr ()
userData destroy :: Maybe DestroyNotify
destroy = IO OptionGroup -> m OptionGroup
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO OptionGroup -> m OptionGroup)
-> IO OptionGroup -> m OptionGroup
forall a b. (a -> b) -> a -> b
$ do
    CString
name' <- Text -> IO CString
textToCString Text
name
    CString
description' <- Text -> IO CString
textToCString Text
description
    CString
helpDescription' <- Text -> IO CString
textToCString Text
helpDescription
    FunPtr DestroyNotify
maybeDestroy <- case Maybe DestroyNotify
destroy of
        Nothing -> FunPtr DestroyNotify -> IO (FunPtr DestroyNotify)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr DestroyNotify
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
        Just jDestroy :: DestroyNotify
jDestroy -> do
            Ptr (FunPtr DestroyNotify)
ptrdestroy <- IO (Ptr (FunPtr DestroyNotify))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_DestroyNotify))
            FunPtr DestroyNotify
jDestroy' <- DestroyNotify -> IO (FunPtr DestroyNotify)
GLib.Callbacks.mk_DestroyNotify (Maybe (Ptr (FunPtr DestroyNotify))
-> DestroyNotify -> DestroyNotify
GLib.Callbacks.wrap_DestroyNotify (Ptr (FunPtr DestroyNotify) -> Maybe (Ptr (FunPtr DestroyNotify))
forall a. a -> Maybe a
Just Ptr (FunPtr DestroyNotify)
ptrdestroy) DestroyNotify
jDestroy)
            Ptr (FunPtr DestroyNotify) -> FunPtr DestroyNotify -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr DestroyNotify)
ptrdestroy FunPtr DestroyNotify
jDestroy'
            FunPtr DestroyNotify -> IO (FunPtr DestroyNotify)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr DestroyNotify
jDestroy'
    Ptr OptionGroup
result <- CString
-> CString
-> CString
-> Ptr ()
-> FunPtr DestroyNotify
-> IO (Ptr OptionGroup)
g_option_group_new CString
name' CString
description' CString
helpDescription' Ptr ()
userData FunPtr DestroyNotify
maybeDestroy
    Text -> Ptr OptionGroup -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "optionGroupNew" Ptr OptionGroup
result
    OptionGroup
result' <- ((ManagedPtr OptionGroup -> OptionGroup)
-> Ptr OptionGroup -> IO OptionGroup
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr OptionGroup -> OptionGroup
OptionGroup) Ptr OptionGroup
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
name'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
description'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
helpDescription'
    OptionGroup -> IO OptionGroup
forall (m :: * -> *) a. Monad m => a -> m a
return OptionGroup
result'

#if ENABLE_OVERLOADING
#endif

-- method OptionGroup::add_entries
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "group", argType = TInterface (Name {namespace = "GLib", name = "OptionGroup"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GOptionGroup", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "entries", argType = TCArray True (-1) (-1) (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}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_option_group_add_entries" g_option_group_add_entries :: 
    Ptr OptionGroup ->                      -- group : TInterface (Name {namespace = "GLib", name = "OptionGroup"})
    Ptr (Ptr GLib.OptionEntry.OptionEntry) -> -- entries : TCArray True (-1) (-1) (TInterface (Name {namespace = "GLib", name = "OptionEntry"}))
    IO ()

{- |
Adds the options specified in /@entries@/ to /@group@/.

/Since: 2.6/
-}
optionGroupAddEntries ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    OptionGroup
    {- ^ /@group@/: a 'GI.GLib.Structs.OptionGroup.OptionGroup' -}
    -> [GLib.OptionEntry.OptionEntry]
    {- ^ /@entries@/: a 'Nothing'-terminated array of @/GOptionEntrys/@ -}
    -> m ()
optionGroupAddEntries :: OptionGroup -> [OptionEntry] -> m ()
optionGroupAddEntries group :: OptionGroup
group entries :: [OptionEntry]
entries = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr OptionGroup
group' <- OptionGroup -> IO (Ptr OptionGroup)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionGroup
group
    [Ptr OptionEntry]
entries' <- (OptionEntry -> IO (Ptr OptionEntry))
-> [OptionEntry] -> IO [Ptr OptionEntry]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM OptionEntry -> IO (Ptr OptionEntry)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr [OptionEntry]
entries
    Ptr (Ptr OptionEntry)
entries'' <- [Ptr OptionEntry] -> IO (Ptr (Ptr OptionEntry))
forall a. [Ptr a] -> IO (Ptr (Ptr a))
packZeroTerminatedPtrArray [Ptr OptionEntry]
entries'
    Ptr OptionGroup -> Ptr (Ptr OptionEntry) -> IO ()
g_option_group_add_entries Ptr OptionGroup
group' Ptr (Ptr OptionEntry)
entries''
    OptionGroup -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionGroup
group
    (OptionEntry -> IO ()) -> [OptionEntry] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ OptionEntry -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr [OptionEntry]
entries
    Ptr (Ptr OptionEntry) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr OptionEntry)
entries''
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if ENABLE_OVERLOADING
data OptionGroupAddEntriesMethodInfo
instance (signature ~ ([GLib.OptionEntry.OptionEntry] -> m ()), MonadIO m) => O.MethodInfo OptionGroupAddEntriesMethodInfo OptionGroup signature where
    overloadedMethod _ = optionGroupAddEntries

#endif

-- method OptionGroup::free
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "group", argType = TInterface (Name {namespace = "GLib", name = "OptionGroup"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GOptionGroup", 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_group_free" g_option_group_free :: 
    Ptr OptionGroup ->                      -- group : TInterface (Name {namespace = "GLib", name = "OptionGroup"})
    IO ()

{-# DEPRECATED optionGroupFree ["(Since version 2.44)","Use 'GI.GLib.Structs.OptionGroup.optionGroupUnref' instead."] #-}
{- |
Frees a 'GI.GLib.Structs.OptionGroup.OptionGroup'. Note that you must not free groups
which have been added to a 'GI.GLib.Structs.OptionContext.OptionContext'.

/Since: 2.6/
-}
optionGroupFree ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    OptionGroup
    {- ^ /@group@/: a 'GI.GLib.Structs.OptionGroup.OptionGroup' -}
    -> m ()
optionGroupFree :: OptionGroup -> m ()
optionGroupFree group :: OptionGroup
group = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr OptionGroup
group' <- OptionGroup -> IO (Ptr OptionGroup)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionGroup
group
    Ptr OptionGroup -> IO ()
g_option_group_free Ptr OptionGroup
group'
    OptionGroup -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionGroup
group
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if ENABLE_OVERLOADING
data OptionGroupFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo OptionGroupFreeMethodInfo OptionGroup signature where
    overloadedMethod _ = optionGroupFree

#endif

-- method OptionGroup::ref
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "group", argType = TInterface (Name {namespace = "GLib", name = "OptionGroup"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GOptionGroup", 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_group_ref" g_option_group_ref :: 
    Ptr OptionGroup ->                      -- group : TInterface (Name {namespace = "GLib", name = "OptionGroup"})
    IO (Ptr OptionGroup)

{- |
Increments the reference count of /@group@/ by one.

/Since: 2.44/
-}
optionGroupRef ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    OptionGroup
    {- ^ /@group@/: a 'GI.GLib.Structs.OptionGroup.OptionGroup' -}
    -> m OptionGroup
    {- ^ __Returns:__ a 'GI.GLib.Structs.OptionGroup.OptionGroup' -}
optionGroupRef :: OptionGroup -> m OptionGroup
optionGroupRef group :: OptionGroup
group = IO OptionGroup -> m OptionGroup
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO OptionGroup -> m OptionGroup)
-> IO OptionGroup -> m OptionGroup
forall a b. (a -> b) -> a -> b
$ do
    Ptr OptionGroup
group' <- OptionGroup -> IO (Ptr OptionGroup)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionGroup
group
    Ptr OptionGroup
result <- Ptr OptionGroup -> IO (Ptr OptionGroup)
g_option_group_ref Ptr OptionGroup
group'
    Text -> Ptr OptionGroup -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "optionGroupRef" Ptr OptionGroup
result
    OptionGroup
result' <- ((ManagedPtr OptionGroup -> OptionGroup)
-> Ptr OptionGroup -> IO OptionGroup
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr OptionGroup -> OptionGroup
OptionGroup) Ptr OptionGroup
result
    OptionGroup -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionGroup
group
    OptionGroup -> IO OptionGroup
forall (m :: * -> *) a. Monad m => a -> m a
return OptionGroup
result'

#if ENABLE_OVERLOADING
data OptionGroupRefMethodInfo
instance (signature ~ (m OptionGroup), MonadIO m) => O.MethodInfo OptionGroupRefMethodInfo OptionGroup signature where
    overloadedMethod _ = optionGroupRef

#endif

-- method OptionGroup::set_translate_func
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "group", argType = TInterface (Name {namespace = "GLib", name = "OptionGroup"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GOptionGroup", 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_group_set_translate_func" g_option_group_set_translate_func :: 
    Ptr OptionGroup ->                      -- group : TInterface (Name {namespace = "GLib", name = "OptionGroup"})
    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 user-visible strings,
for @--help@ output. Different groups can use different
@/GTranslateFuncs/@. If /@func@/ is 'Nothing', strings are not translated.

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

/Since: 2.6/
-}
optionGroupSetTranslateFunc ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    OptionGroup
    {- ^ /@group@/: a 'GI.GLib.Structs.OptionGroup.OptionGroup' -}
    -> Maybe (GLib.Callbacks.TranslateFunc)
    {- ^ /@func@/: the 'GI.GLib.Callbacks.TranslateFunc', or 'Nothing' -}
    -> m ()
optionGroupSetTranslateFunc :: OptionGroup -> Maybe TranslateFunc -> m ()
optionGroupSetTranslateFunc group :: OptionGroup
group func :: Maybe TranslateFunc
func = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr OptionGroup
group' <- OptionGroup -> IO (Ptr OptionGroup)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionGroup
group
    FunPtr C_TranslateFunc
maybeFunc <- case Maybe TranslateFunc
func of
        Nothing -> FunPtr C_TranslateFunc -> IO (FunPtr C_TranslateFunc)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_TranslateFunc
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
        Just jFunc :: TranslateFunc
jFunc -> do
            FunPtr C_TranslateFunc
jFunc' <- C_TranslateFunc -> IO (FunPtr C_TranslateFunc)
GLib.Callbacks.mk_TranslateFunc (Maybe (Ptr (FunPtr C_TranslateFunc))
-> TranslateFunc -> C_TranslateFunc
GLib.Callbacks.wrap_TranslateFunc Maybe (Ptr (FunPtr C_TranslateFunc))
forall a. Maybe a
Nothing TranslateFunc
jFunc)
            FunPtr C_TranslateFunc -> IO (FunPtr C_TranslateFunc)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_TranslateFunc
jFunc'
    let data_ :: Ptr ()
data_ = FunPtr C_TranslateFunc -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr FunPtr C_TranslateFunc
maybeFunc
    let destroyNotify :: FunPtr (Ptr a -> IO ())
destroyNotify = FunPtr (Ptr a -> IO ())
forall a. FunPtr (Ptr a -> IO ())
safeFreeFunPtrPtr
    Ptr OptionGroup
-> FunPtr C_TranslateFunc
-> Ptr ()
-> FunPtr DestroyNotify
-> IO ()
g_option_group_set_translate_func Ptr OptionGroup
group' FunPtr C_TranslateFunc
maybeFunc Ptr ()
data_ FunPtr DestroyNotify
forall a. FunPtr (Ptr a -> IO ())
destroyNotify
    OptionGroup -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionGroup
group
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

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

#endif

-- method OptionGroup::set_translation_domain
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "group", argType = TInterface (Name {namespace = "GLib", name = "OptionGroup"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GOptionGroup", 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_group_set_translation_domain" g_option_group_set_translation_domain :: 
    Ptr OptionGroup ->                      -- group : TInterface (Name {namespace = "GLib", name = "OptionGroup"})
    CString ->                              -- domain : TBasicType TUTF8
    IO ()

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

/Since: 2.6/
-}
optionGroupSetTranslationDomain ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    OptionGroup
    {- ^ /@group@/: a 'GI.GLib.Structs.OptionGroup.OptionGroup' -}
    -> T.Text
    {- ^ /@domain@/: the domain to use -}
    -> m ()
optionGroupSetTranslationDomain :: OptionGroup -> Text -> m ()
optionGroupSetTranslationDomain group :: OptionGroup
group domain :: Text
domain = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr OptionGroup
group' <- OptionGroup -> IO (Ptr OptionGroup)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionGroup
group
    CString
domain' <- Text -> IO CString
textToCString Text
domain
    Ptr OptionGroup -> CString -> IO ()
g_option_group_set_translation_domain Ptr OptionGroup
group' CString
domain'
    OptionGroup -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionGroup
group
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
domain'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if ENABLE_OVERLOADING
data OptionGroupSetTranslationDomainMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m) => O.MethodInfo OptionGroupSetTranslationDomainMethodInfo OptionGroup signature where
    overloadedMethod _ = optionGroupSetTranslationDomain

#endif

-- method OptionGroup::unref
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "group", argType = TInterface (Name {namespace = "GLib", name = "OptionGroup"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GOptionGroup", 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_group_unref" g_option_group_unref :: 
    Ptr OptionGroup ->                      -- group : TInterface (Name {namespace = "GLib", name = "OptionGroup"})
    IO ()

{- |
Decrements the reference count of /@group@/ by one.
If the reference count drops to 0, the /@group@/ will be freed.
and all memory allocated by the /@group@/ is released.

/Since: 2.44/
-}
optionGroupUnref ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    OptionGroup
    {- ^ /@group@/: a 'GI.GLib.Structs.OptionGroup.OptionGroup' -}
    -> m ()
optionGroupUnref :: OptionGroup -> m ()
optionGroupUnref group :: OptionGroup
group = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr OptionGroup
group' <- OptionGroup -> IO (Ptr OptionGroup)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr OptionGroup
group
    Ptr OptionGroup -> IO ()
g_option_group_unref Ptr OptionGroup
group'
    OptionGroup -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr OptionGroup
group
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if ENABLE_OVERLOADING
data OptionGroupUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo OptionGroupUnrefMethodInfo OptionGroup signature where
    overloadedMethod _ = optionGroupUnref

#endif

#if ENABLE_OVERLOADING
type family ResolveOptionGroupMethod (t :: Symbol) (o :: *) :: * where
    ResolveOptionGroupMethod "addEntries" o = OptionGroupAddEntriesMethodInfo
    ResolveOptionGroupMethod "free" o = OptionGroupFreeMethodInfo
    ResolveOptionGroupMethod "ref" o = OptionGroupRefMethodInfo
    ResolveOptionGroupMethod "unref" o = OptionGroupUnrefMethodInfo
    ResolveOptionGroupMethod "setTranslateFunc" o = OptionGroupSetTranslateFuncMethodInfo
    ResolveOptionGroupMethod "setTranslationDomain" o = OptionGroupSetTranslationDomainMethodInfo
    ResolveOptionGroupMethod l o = O.MethodResolutionFailed l o

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

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