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

Integrating the launch with the launching application. This is used to
handle for instance startup notification and launching the new application
on the same screen as the launching window.
-}

module GI.Gio.Objects.AppLaunchContext
    ( 

-- * Exported types
    AppLaunchContext(..)                    ,
    IsAppLaunchContext                      ,
    toAppLaunchContext                      ,
    noAppLaunchContext                      ,


 -- * Methods
-- ** getDisplay #method:getDisplay#
    AppLaunchContextGetDisplayMethodInfo    ,
    appLaunchContextGetDisplay              ,


-- ** getEnvironment #method:getEnvironment#
    AppLaunchContextGetEnvironmentMethodInfo,
    appLaunchContextGetEnvironment          ,


-- ** getStartupNotifyId #method:getStartupNotifyId#
    AppLaunchContextGetStartupNotifyIdMethodInfo,
    appLaunchContextGetStartupNotifyId      ,


-- ** launchFailed #method:launchFailed#
    AppLaunchContextLaunchFailedMethodInfo  ,
    appLaunchContextLaunchFailed            ,


-- ** new #method:new#
    appLaunchContextNew                     ,


-- ** setenv #method:setenv#
    AppLaunchContextSetenvMethodInfo        ,
    appLaunchContextSetenv                  ,


-- ** unsetenv #method:unsetenv#
    AppLaunchContextUnsetenvMethodInfo      ,
    appLaunchContextUnsetenv                ,




 -- * Signals
-- ** launchFailed #signal:launchFailed#
    AppLaunchContextLaunchFailedCallback    ,
    AppLaunchContextLaunchFailedSignalInfo  ,
    C_AppLaunchContextLaunchFailedCallback  ,
    afterAppLaunchContextLaunchFailed       ,
    genClosure_AppLaunchContextLaunchFailed ,
    mk_AppLaunchContextLaunchFailedCallback ,
    noAppLaunchContextLaunchFailedCallback  ,
    onAppLaunchContextLaunchFailed          ,
    wrap_AppLaunchContextLaunchFailedCallback,


-- ** launched #signal:launched#
    AppLaunchContextLaunchedCallback        ,
    AppLaunchContextLaunchedSignalInfo      ,
    C_AppLaunchContextLaunchedCallback      ,
    afterAppLaunchContextLaunched           ,
    genClosure_AppLaunchContextLaunched     ,
    mk_AppLaunchContextLaunchedCallback     ,
    noAppLaunchContextLaunchedCallback      ,
    onAppLaunchContextLaunched              ,
    wrap_AppLaunchContextLaunchedCallback   ,




    ) 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.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.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Gio.Interfaces.AppInfo as Gio.AppInfo
import {-# SOURCE #-} qualified GI.Gio.Interfaces.File as Gio.File

newtype AppLaunchContext = AppLaunchContext (ManagedPtr AppLaunchContext)
foreign import ccall "g_app_launch_context_get_type"
    c_g_app_launch_context_get_type :: IO GType

instance GObject AppLaunchContext where
    gobjectType _ = c_g_app_launch_context_get_type
    

class GObject o => IsAppLaunchContext o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError AppLaunchContext a) =>
    IsAppLaunchContext a
#endif
instance IsAppLaunchContext AppLaunchContext
instance GObject.Object.IsObject AppLaunchContext

toAppLaunchContext :: IsAppLaunchContext o => o -> IO AppLaunchContext
toAppLaunchContext = unsafeCastTo AppLaunchContext

noAppLaunchContext :: Maybe AppLaunchContext
noAppLaunchContext = Nothing

type family ResolveAppLaunchContextMethod (t :: Symbol) (o :: *) :: * where
    ResolveAppLaunchContextMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveAppLaunchContextMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveAppLaunchContextMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveAppLaunchContextMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveAppLaunchContextMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveAppLaunchContextMethod "launchFailed" o = AppLaunchContextLaunchFailedMethodInfo
    ResolveAppLaunchContextMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveAppLaunchContextMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveAppLaunchContextMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveAppLaunchContextMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveAppLaunchContextMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveAppLaunchContextMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveAppLaunchContextMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveAppLaunchContextMethod "setenv" o = AppLaunchContextSetenvMethodInfo
    ResolveAppLaunchContextMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveAppLaunchContextMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveAppLaunchContextMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveAppLaunchContextMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveAppLaunchContextMethod "unsetenv" o = AppLaunchContextUnsetenvMethodInfo
    ResolveAppLaunchContextMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveAppLaunchContextMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveAppLaunchContextMethod "getDisplay" o = AppLaunchContextGetDisplayMethodInfo
    ResolveAppLaunchContextMethod "getEnvironment" o = AppLaunchContextGetEnvironmentMethodInfo
    ResolveAppLaunchContextMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveAppLaunchContextMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveAppLaunchContextMethod "getStartupNotifyId" o = AppLaunchContextGetStartupNotifyIdMethodInfo
    ResolveAppLaunchContextMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveAppLaunchContextMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveAppLaunchContextMethod l o = O.MethodResolutionFailed l o

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

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveAppLaunchContextMethod t AppLaunchContext, O.MethodInfo info AppLaunchContext p) => O.IsLabel t (AppLaunchContext -> p) where
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

-- signal AppLaunchContext::launch-failed
type AppLaunchContextLaunchFailedCallback =
    T.Text ->
    IO ()

noAppLaunchContextLaunchFailedCallback :: Maybe AppLaunchContextLaunchFailedCallback
noAppLaunchContextLaunchFailedCallback = Nothing

type C_AppLaunchContextLaunchFailedCallback =
    Ptr () ->                               -- object
    CString ->
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mk_AppLaunchContextLaunchFailedCallback :: C_AppLaunchContextLaunchFailedCallback -> IO (FunPtr C_AppLaunchContextLaunchFailedCallback)

genClosure_AppLaunchContextLaunchFailed :: AppLaunchContextLaunchFailedCallback -> IO Closure
genClosure_AppLaunchContextLaunchFailed cb = do
    let cb' = wrap_AppLaunchContextLaunchFailedCallback cb
    mk_AppLaunchContextLaunchFailedCallback cb' >>= newCClosure


wrap_AppLaunchContextLaunchFailedCallback ::
    AppLaunchContextLaunchFailedCallback ->
    Ptr () ->
    CString ->
    Ptr () ->
    IO ()
wrap_AppLaunchContextLaunchFailedCallback _cb _ startupNotifyId _ = do
    startupNotifyId' <- cstringToText startupNotifyId
    _cb  startupNotifyId'


onAppLaunchContextLaunchFailed :: (GObject a, MonadIO m) => a -> AppLaunchContextLaunchFailedCallback -> m SignalHandlerId
onAppLaunchContextLaunchFailed obj cb = liftIO $ connectAppLaunchContextLaunchFailed obj cb SignalConnectBefore
afterAppLaunchContextLaunchFailed :: (GObject a, MonadIO m) => a -> AppLaunchContextLaunchFailedCallback -> m SignalHandlerId
afterAppLaunchContextLaunchFailed obj cb = connectAppLaunchContextLaunchFailed obj cb SignalConnectAfter

connectAppLaunchContextLaunchFailed :: (GObject a, MonadIO m) =>
                                       a -> AppLaunchContextLaunchFailedCallback -> SignalConnectMode -> m SignalHandlerId
connectAppLaunchContextLaunchFailed obj cb after = liftIO $ do
    let cb' = wrap_AppLaunchContextLaunchFailedCallback cb
    cb'' <- mk_AppLaunchContextLaunchFailedCallback cb'
    connectSignalFunPtr obj "launch-failed" cb'' after

-- signal AppLaunchContext::launched
type AppLaunchContextLaunchedCallback =
    Gio.AppInfo.AppInfo ->
    GVariant ->
    IO ()

noAppLaunchContextLaunchedCallback :: Maybe AppLaunchContextLaunchedCallback
noAppLaunchContextLaunchedCallback = Nothing

type C_AppLaunchContextLaunchedCallback =
    Ptr () ->                               -- object
    Ptr Gio.AppInfo.AppInfo ->
    Ptr GVariant ->
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mk_AppLaunchContextLaunchedCallback :: C_AppLaunchContextLaunchedCallback -> IO (FunPtr C_AppLaunchContextLaunchedCallback)

genClosure_AppLaunchContextLaunched :: AppLaunchContextLaunchedCallback -> IO Closure
genClosure_AppLaunchContextLaunched cb = do
    let cb' = wrap_AppLaunchContextLaunchedCallback cb
    mk_AppLaunchContextLaunchedCallback cb' >>= newCClosure


wrap_AppLaunchContextLaunchedCallback ::
    AppLaunchContextLaunchedCallback ->
    Ptr () ->
    Ptr Gio.AppInfo.AppInfo ->
    Ptr GVariant ->
    Ptr () ->
    IO ()
wrap_AppLaunchContextLaunchedCallback _cb _ info platformData _ = do
    info' <- (newObject Gio.AppInfo.AppInfo) info
    platformData' <- newGVariantFromPtr platformData
    _cb  info' platformData'


onAppLaunchContextLaunched :: (GObject a, MonadIO m) => a -> AppLaunchContextLaunchedCallback -> m SignalHandlerId
onAppLaunchContextLaunched obj cb = liftIO $ connectAppLaunchContextLaunched obj cb SignalConnectBefore
afterAppLaunchContextLaunched :: (GObject a, MonadIO m) => a -> AppLaunchContextLaunchedCallback -> m SignalHandlerId
afterAppLaunchContextLaunched obj cb = connectAppLaunchContextLaunched obj cb SignalConnectAfter

connectAppLaunchContextLaunched :: (GObject a, MonadIO m) =>
                                   a -> AppLaunchContextLaunchedCallback -> SignalConnectMode -> m SignalHandlerId
connectAppLaunchContextLaunched obj cb after = liftIO $ do
    let cb' = wrap_AppLaunchContextLaunchedCallback cb
    cb'' <- mk_AppLaunchContextLaunchedCallback cb'
    connectSignalFunPtr obj "launched" cb'' after

instance O.HasAttributeList AppLaunchContext
type instance O.AttributeList AppLaunchContext = AppLaunchContextAttributeList
type AppLaunchContextAttributeList = ('[ ] :: [(Symbol, *)])

data AppLaunchContextLaunchFailedSignalInfo
instance SignalInfo AppLaunchContextLaunchFailedSignalInfo where
    type HaskellCallbackType AppLaunchContextLaunchFailedSignalInfo = AppLaunchContextLaunchFailedCallback
    connectSignal _ = connectAppLaunchContextLaunchFailed

data AppLaunchContextLaunchedSignalInfo
instance SignalInfo AppLaunchContextLaunchedSignalInfo where
    type HaskellCallbackType AppLaunchContextLaunchedSignalInfo = AppLaunchContextLaunchedCallback
    connectSignal _ = connectAppLaunchContextLaunched

type instance O.SignalList AppLaunchContext = AppLaunchContextSignalList
type AppLaunchContextSignalList = ('[ '("launchFailed", AppLaunchContextLaunchFailedSignalInfo), '("launched", AppLaunchContextLaunchedSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

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

foreign import ccall "g_app_launch_context_new" g_app_launch_context_new :: 
    IO (Ptr AppLaunchContext)

{- |
Creates a new application launch context. This is not normally used,
instead you instantiate a subclass of this, such as @/GdkAppLaunchContext/@.
-}
appLaunchContextNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m AppLaunchContext
    {- ^ __Returns:__ a 'GI.Gio.Objects.AppLaunchContext.AppLaunchContext'. -}
appLaunchContextNew  = liftIO $ do
    result <- g_app_launch_context_new
    checkUnexpectedReturnNULL "appLaunchContextNew" result
    result' <- (wrapObject AppLaunchContext) result
    return result'

-- method AppLaunchContext::get_display
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Gio", name = "AppLaunchContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAppLaunchContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "info", argType = TInterface (Name {namespace = "Gio", name = "AppInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAppInfo", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "files", argType = TGList (TInterface (Name {namespace = "Gio", name = "File"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GList of #GFile objects", 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_app_launch_context_get_display" g_app_launch_context_get_display :: 
    Ptr AppLaunchContext ->                 -- context : TInterface (Name {namespace = "Gio", name = "AppLaunchContext"})
    Ptr Gio.AppInfo.AppInfo ->              -- info : TInterface (Name {namespace = "Gio", name = "AppInfo"})
    Ptr (GList (Ptr Gio.File.File)) ->      -- files : TGList (TInterface (Name {namespace = "Gio", name = "File"}))
    IO CString

{- |
Gets the display string for the /@context@/. This is used to ensure new
applications are started on the same display as the launching
application, by setting the @DISPLAY@ environment variable.
-}
appLaunchContextGetDisplay ::
    (B.CallStack.HasCallStack, MonadIO m, IsAppLaunchContext a, Gio.AppInfo.IsAppInfo b, Gio.File.IsFile c) =>
    a
    {- ^ /@context@/: a 'GI.Gio.Objects.AppLaunchContext.AppLaunchContext' -}
    -> b
    {- ^ /@info@/: a 'GI.Gio.Interfaces.AppInfo.AppInfo' -}
    -> [c]
    {- ^ /@files@/: a 'GI.GLib.Structs.List.List' of 'GI.Gio.Interfaces.File.File' objects -}
    -> m T.Text
    {- ^ __Returns:__ a display string for the display. -}
appLaunchContextGetDisplay context info files = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    info' <- unsafeManagedPtrCastPtr info
    files' <- mapM unsafeManagedPtrCastPtr files
    files'' <- packGList files'
    result <- g_app_launch_context_get_display context' info' files''
    checkUnexpectedReturnNULL "appLaunchContextGetDisplay" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr context
    touchManagedPtr info
    mapM_ touchManagedPtr files
    g_list_free files''
    return result'

data AppLaunchContextGetDisplayMethodInfo
instance (signature ~ (b -> [c] -> m T.Text), MonadIO m, IsAppLaunchContext a, Gio.AppInfo.IsAppInfo b, Gio.File.IsFile c) => O.MethodInfo AppLaunchContextGetDisplayMethodInfo a signature where
    overloadedMethod _ = appLaunchContextGetDisplay

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

foreign import ccall "g_app_launch_context_get_environment" g_app_launch_context_get_environment :: 
    Ptr AppLaunchContext ->                 -- context : TInterface (Name {namespace = "Gio", name = "AppLaunchContext"})
    IO (Ptr CString)

{- |
Gets the complete environment variable list to be passed to
the child process when /@context@/ is used to launch an application.
This is a 'Nothing'-terminated array of strings, where each string has
the form @KEY=VALUE@.

@since 2.32
-}
appLaunchContextGetEnvironment ::
    (B.CallStack.HasCallStack, MonadIO m, IsAppLaunchContext a) =>
    a
    {- ^ /@context@/: a 'GI.Gio.Objects.AppLaunchContext.AppLaunchContext' -}
    -> m [T.Text]
    {- ^ __Returns:__ the
    child\'s environment -}
appLaunchContextGetEnvironment context = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    result <- g_app_launch_context_get_environment context'
    checkUnexpectedReturnNULL "appLaunchContextGetEnvironment" result
    result' <- unpackZeroTerminatedUTF8CArray result
    mapZeroTerminatedCArray freeMem result
    freeMem result
    touchManagedPtr context
    return result'

data AppLaunchContextGetEnvironmentMethodInfo
instance (signature ~ (m [T.Text]), MonadIO m, IsAppLaunchContext a) => O.MethodInfo AppLaunchContextGetEnvironmentMethodInfo a signature where
    overloadedMethod _ = appLaunchContextGetEnvironment

-- method AppLaunchContext::get_startup_notify_id
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Gio", name = "AppLaunchContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAppLaunchContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "info", argType = TInterface (Name {namespace = "Gio", name = "AppInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAppInfo", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "files", argType = TGList (TInterface (Name {namespace = "Gio", name = "File"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GList of of #GFile objects", 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_app_launch_context_get_startup_notify_id" g_app_launch_context_get_startup_notify_id :: 
    Ptr AppLaunchContext ->                 -- context : TInterface (Name {namespace = "Gio", name = "AppLaunchContext"})
    Ptr Gio.AppInfo.AppInfo ->              -- info : TInterface (Name {namespace = "Gio", name = "AppInfo"})
    Ptr (GList (Ptr Gio.File.File)) ->      -- files : TGList (TInterface (Name {namespace = "Gio", name = "File"}))
    IO CString

{- |
Initiates startup notification for the application and returns the
@DESKTOP_STARTUP_ID@ for the launched operation, if supported.

Startup notification IDs are defined in the
<http://standards.freedesktop.org/startup-notification-spec/startup-notification-latest.txt" FreeDesktop.Org Startup Notifications standard>.
-}
appLaunchContextGetStartupNotifyId ::
    (B.CallStack.HasCallStack, MonadIO m, IsAppLaunchContext a, Gio.AppInfo.IsAppInfo b, Gio.File.IsFile c) =>
    a
    {- ^ /@context@/: a 'GI.Gio.Objects.AppLaunchContext.AppLaunchContext' -}
    -> b
    {- ^ /@info@/: a 'GI.Gio.Interfaces.AppInfo.AppInfo' -}
    -> [c]
    {- ^ /@files@/: a 'GI.GLib.Structs.List.List' of of 'GI.Gio.Interfaces.File.File' objects -}
    -> m T.Text
    {- ^ __Returns:__ a startup notification ID for the application, or 'Nothing' if
    not supported. -}
appLaunchContextGetStartupNotifyId context info files = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    info' <- unsafeManagedPtrCastPtr info
    files' <- mapM unsafeManagedPtrCastPtr files
    files'' <- packGList files'
    result <- g_app_launch_context_get_startup_notify_id context' info' files''
    checkUnexpectedReturnNULL "appLaunchContextGetStartupNotifyId" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr context
    touchManagedPtr info
    mapM_ touchManagedPtr files
    g_list_free files''
    return result'

data AppLaunchContextGetStartupNotifyIdMethodInfo
instance (signature ~ (b -> [c] -> m T.Text), MonadIO m, IsAppLaunchContext a, Gio.AppInfo.IsAppInfo b, Gio.File.IsFile c) => O.MethodInfo AppLaunchContextGetStartupNotifyIdMethodInfo a signature where
    overloadedMethod _ = appLaunchContextGetStartupNotifyId

-- method AppLaunchContext::launch_failed
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Gio", name = "AppLaunchContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAppLaunchContext.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "startup_notify_id", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the startup notification id that was returned by g_app_launch_context_get_startup_notify_id().", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_app_launch_context_launch_failed" g_app_launch_context_launch_failed :: 
    Ptr AppLaunchContext ->                 -- context : TInterface (Name {namespace = "Gio", name = "AppLaunchContext"})
    CString ->                              -- startup_notify_id : TBasicType TUTF8
    IO ()

{- |
Called when an application has failed to launch, so that it can cancel
the application startup notification started in 'GI.Gio.Objects.AppLaunchContext.appLaunchContextGetStartupNotifyId'.
-}
appLaunchContextLaunchFailed ::
    (B.CallStack.HasCallStack, MonadIO m, IsAppLaunchContext a) =>
    a
    {- ^ /@context@/: a 'GI.Gio.Objects.AppLaunchContext.AppLaunchContext'. -}
    -> T.Text
    {- ^ /@startupNotifyId@/: the startup notification id that was returned by 'GI.Gio.Objects.AppLaunchContext.appLaunchContextGetStartupNotifyId'. -}
    -> m ()
appLaunchContextLaunchFailed context startupNotifyId = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    startupNotifyId' <- textToCString startupNotifyId
    g_app_launch_context_launch_failed context' startupNotifyId'
    touchManagedPtr context
    freeMem startupNotifyId'
    return ()

data AppLaunchContextLaunchFailedMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m, IsAppLaunchContext a) => O.MethodInfo AppLaunchContextLaunchFailedMethodInfo a signature where
    overloadedMethod _ = appLaunchContextLaunchFailed

-- method AppLaunchContext::setenv
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Gio", name = "AppLaunchContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAppLaunchContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "variable", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the environment variable to set", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "value", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the value for to set the variable to.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_app_launch_context_setenv" g_app_launch_context_setenv :: 
    Ptr AppLaunchContext ->                 -- context : TInterface (Name {namespace = "Gio", name = "AppLaunchContext"})
    CString ->                              -- variable : TBasicType TUTF8
    CString ->                              -- value : TBasicType TUTF8
    IO ()

{- |
Arranges for /@variable@/ to be set to /@value@/ in the child\'s
environment when /@context@/ is used to launch an application.

@since 2.32
-}
appLaunchContextSetenv ::
    (B.CallStack.HasCallStack, MonadIO m, IsAppLaunchContext a) =>
    a
    {- ^ /@context@/: a 'GI.Gio.Objects.AppLaunchContext.AppLaunchContext' -}
    -> T.Text
    {- ^ /@variable@/: the environment variable to set -}
    -> T.Text
    {- ^ /@value@/: the value for to set the variable to. -}
    -> m ()
appLaunchContextSetenv context variable value = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    variable' <- textToCString variable
    value' <- textToCString value
    g_app_launch_context_setenv context' variable' value'
    touchManagedPtr context
    freeMem variable'
    freeMem value'
    return ()

data AppLaunchContextSetenvMethodInfo
instance (signature ~ (T.Text -> T.Text -> m ()), MonadIO m, IsAppLaunchContext a) => O.MethodInfo AppLaunchContextSetenvMethodInfo a signature where
    overloadedMethod _ = appLaunchContextSetenv

-- method AppLaunchContext::unsetenv
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Gio", name = "AppLaunchContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAppLaunchContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "variable", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the environment variable 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_app_launch_context_unsetenv" g_app_launch_context_unsetenv :: 
    Ptr AppLaunchContext ->                 -- context : TInterface (Name {namespace = "Gio", name = "AppLaunchContext"})
    CString ->                              -- variable : TBasicType TUTF8
    IO ()

{- |
Arranges for /@variable@/ to be unset in the child\'s environment
when /@context@/ is used to launch an application.

@since 2.32
-}
appLaunchContextUnsetenv ::
    (B.CallStack.HasCallStack, MonadIO m, IsAppLaunchContext a) =>
    a
    {- ^ /@context@/: a 'GI.Gio.Objects.AppLaunchContext.AppLaunchContext' -}
    -> T.Text
    {- ^ /@variable@/: the environment variable to remove -}
    -> m ()
appLaunchContextUnsetenv context variable = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    variable' <- textToCString variable
    g_app_launch_context_unsetenv context' variable'
    touchManagedPtr context
    freeMem variable'
    return ()

data AppLaunchContextUnsetenvMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m, IsAppLaunchContext a) => O.MethodInfo AppLaunchContextUnsetenvMethodInfo a signature where
    overloadedMethod _ = appLaunchContextUnsetenv