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

'GI.Gio.Interfaces.AppInfo.AppInfo' and 'GI.Gio.Objects.AppLaunchContext.AppLaunchContext' are used for describing and launching
applications installed on the system.

As of GLib 2.20, URIs will always be converted to POSIX paths
(using 'GI.Gio.Interfaces.File.fileGetPath') when using 'GI.Gio.Interfaces.AppInfo.appInfoLaunch' even if
the application requested an URI and not a POSIX path. For example
for an desktop-file based application with Exec key @totem
%U@ and a single URI, @sftp:\/\/foo\/file.avi@, then
@\/home\/user\/.gvfs\/sftp on foo\/file.avi@ will be passed. This will
only work if a set of suitable GIO extensions (such as gvfs 2.26
compiled with FUSE support), is available and operational; if this
is not the case, the URI will be passed unmodified to the application.
Some URIs, such as @mailto:@, of course cannot be mapped to a POSIX
path (in gvfs there\'s no FUSE mount for it); such URIs will be
passed unmodified to the application.

Specifically for gvfs 2.26 and later, the POSIX URI will be mapped
back to the GIO URI in the 'GI.Gio.Interfaces.File.File' constructors (since gvfs
implements the 'GI.Gio.Objects.Vfs.Vfs' extension point). As such, if the application
needs to examine the URI, it needs to use 'GI.Gio.Interfaces.File.fileGetUri' or
similar on 'GI.Gio.Interfaces.File.File'. In other words, an application cannot assume
that the URI passed to e.g. 'GI.Gio.Functions.fileNewForCommandlineArg' is
equal to the result of 'GI.Gio.Interfaces.File.fileGetUri'. The following snippet
illustrates this:

>
>GFile *f;
>char *uri;
>
>file = g_file_new_for_commandline_arg (uri_from_commandline);
>
>uri = g_file_get_uri (file);
>strcmp (uri, uri_from_commandline) == 0;
>g_free (uri);
>
>if (g_file_has_uri_scheme (file, "cdda"))
>  {
>    // do something special with uri
>  }
>g_object_unref (file);


This code will work when both @cdda:\/\/sr0\/Track 1.wav@ and
@\/home\/user\/.gvfs\/cdda on sr0\/Track 1.wav@ is passed to the
application. It should be noted that it\'s generally not safe
for applications to rely on the format of a particular URIs.
Different launcher applications (e.g. file managers) may have
different ideas of what a given URI means.
-}

module GI.Gio.Interfaces.AppInfo
    ( 

-- * Exported types
    AppInfo(..)                             ,
    noAppInfo                               ,
    IsAppInfo                               ,
    toAppInfo                               ,


 -- * Methods
-- ** addSupportsType #method:addSupportsType#
    AppInfoAddSupportsTypeMethodInfo        ,
    appInfoAddSupportsType                  ,


-- ** canDelete #method:canDelete#
    AppInfoCanDeleteMethodInfo              ,
    appInfoCanDelete                        ,


-- ** canRemoveSupportsType #method:canRemoveSupportsType#
    AppInfoCanRemoveSupportsTypeMethodInfo  ,
    appInfoCanRemoveSupportsType            ,


-- ** createFromCommandline #method:createFromCommandline#
    appInfoCreateFromCommandline            ,


-- ** delete #method:delete#
    AppInfoDeleteMethodInfo                 ,
    appInfoDelete                           ,


-- ** dup #method:dup#
    AppInfoDupMethodInfo                    ,
    appInfoDup                              ,


-- ** equal #method:equal#
    AppInfoEqualMethodInfo                  ,
    appInfoEqual                            ,


-- ** getAll #method:getAll#
    appInfoGetAll                           ,


-- ** getAllForType #method:getAllForType#
    appInfoGetAllForType                    ,


-- ** getCommandline #method:getCommandline#
    AppInfoGetCommandlineMethodInfo         ,
    appInfoGetCommandline                   ,


-- ** getDefaultForType #method:getDefaultForType#
    appInfoGetDefaultForType                ,


-- ** getDefaultForUriScheme #method:getDefaultForUriScheme#
    appInfoGetDefaultForUriScheme           ,


-- ** getDescription #method:getDescription#
    AppInfoGetDescriptionMethodInfo         ,
    appInfoGetDescription                   ,


-- ** getDisplayName #method:getDisplayName#
    AppInfoGetDisplayNameMethodInfo         ,
    appInfoGetDisplayName                   ,


-- ** getExecutable #method:getExecutable#
    AppInfoGetExecutableMethodInfo          ,
    appInfoGetExecutable                    ,


-- ** getFallbackForType #method:getFallbackForType#
    appInfoGetFallbackForType               ,


-- ** getIcon #method:getIcon#
    AppInfoGetIconMethodInfo                ,
    appInfoGetIcon                          ,


-- ** getId #method:getId#
    AppInfoGetIdMethodInfo                  ,
    appInfoGetId                            ,


-- ** getName #method:getName#
    AppInfoGetNameMethodInfo                ,
    appInfoGetName                          ,


-- ** getRecommendedForType #method:getRecommendedForType#
    appInfoGetRecommendedForType            ,


-- ** getSupportedTypes #method:getSupportedTypes#
    AppInfoGetSupportedTypesMethodInfo      ,
    appInfoGetSupportedTypes                ,


-- ** launch #method:launch#
    AppInfoLaunchMethodInfo                 ,
    appInfoLaunch                           ,


-- ** launchDefaultForUri #method:launchDefaultForUri#
    appInfoLaunchDefaultForUri              ,


-- ** launchDefaultForUriAsync #method:launchDefaultForUriAsync#
    appInfoLaunchDefaultForUriAsync         ,


-- ** launchDefaultForUriFinish #method:launchDefaultForUriFinish#
    appInfoLaunchDefaultForUriFinish        ,


-- ** launchUris #method:launchUris#
    AppInfoLaunchUrisMethodInfo             ,
    appInfoLaunchUris                       ,


-- ** removeSupportsType #method:removeSupportsType#
    AppInfoRemoveSupportsTypeMethodInfo     ,
    appInfoRemoveSupportsType               ,


-- ** resetTypeAssociations #method:resetTypeAssociations#
    appInfoResetTypeAssociations            ,


-- ** setAsDefaultForExtension #method:setAsDefaultForExtension#
    AppInfoSetAsDefaultForExtensionMethodInfo,
    appInfoSetAsDefaultForExtension         ,


-- ** setAsDefaultForType #method:setAsDefaultForType#
    AppInfoSetAsDefaultForTypeMethodInfo    ,
    appInfoSetAsDefaultForType              ,


-- ** setAsLastUsedForType #method:setAsLastUsedForType#
    AppInfoSetAsLastUsedForTypeMethodInfo   ,
    appInfoSetAsLastUsedForType             ,


-- ** shouldShow #method:shouldShow#
    AppInfoShouldShowMethodInfo             ,
    appInfoShouldShow                       ,


-- ** supportsFiles #method:supportsFiles#
    AppInfoSupportsFilesMethodInfo          ,
    appInfoSupportsFiles                    ,


-- ** supportsUris #method:supportsUris#
    AppInfoSupportsUrisMethodInfo           ,
    appInfoSupportsUris                     ,




    ) 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 qualified GI.Gio.Callbacks as Gio.Callbacks
import {-# SOURCE #-} qualified GI.Gio.Flags as Gio.Flags
import {-# SOURCE #-} qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import {-# SOURCE #-} qualified GI.Gio.Interfaces.File as Gio.File
import {-# SOURCE #-} qualified GI.Gio.Interfaces.Icon as Gio.Icon
import {-# SOURCE #-} qualified GI.Gio.Objects.AppLaunchContext as Gio.AppLaunchContext
import {-# SOURCE #-} qualified GI.Gio.Objects.Cancellable as Gio.Cancellable

-- interface AppInfo 
newtype AppInfo = AppInfo (ManagedPtr AppInfo)
noAppInfo :: Maybe AppInfo
noAppInfo = Nothing

type family ResolveAppInfoMethod (t :: Symbol) (o :: *) :: * where
    ResolveAppInfoMethod "addSupportsType" o = AppInfoAddSupportsTypeMethodInfo
    ResolveAppInfoMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveAppInfoMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveAppInfoMethod "canDelete" o = AppInfoCanDeleteMethodInfo
    ResolveAppInfoMethod "canRemoveSupportsType" o = AppInfoCanRemoveSupportsTypeMethodInfo
    ResolveAppInfoMethod "delete" o = AppInfoDeleteMethodInfo
    ResolveAppInfoMethod "dup" o = AppInfoDupMethodInfo
    ResolveAppInfoMethod "equal" o = AppInfoEqualMethodInfo
    ResolveAppInfoMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveAppInfoMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveAppInfoMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveAppInfoMethod "launch" o = AppInfoLaunchMethodInfo
    ResolveAppInfoMethod "launchUris" o = AppInfoLaunchUrisMethodInfo
    ResolveAppInfoMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveAppInfoMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveAppInfoMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveAppInfoMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveAppInfoMethod "removeSupportsType" o = AppInfoRemoveSupportsTypeMethodInfo
    ResolveAppInfoMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveAppInfoMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveAppInfoMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveAppInfoMethod "shouldShow" o = AppInfoShouldShowMethodInfo
    ResolveAppInfoMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveAppInfoMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveAppInfoMethod "supportsFiles" o = AppInfoSupportsFilesMethodInfo
    ResolveAppInfoMethod "supportsUris" o = AppInfoSupportsUrisMethodInfo
    ResolveAppInfoMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveAppInfoMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveAppInfoMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveAppInfoMethod "getCommandline" o = AppInfoGetCommandlineMethodInfo
    ResolveAppInfoMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveAppInfoMethod "getDescription" o = AppInfoGetDescriptionMethodInfo
    ResolveAppInfoMethod "getDisplayName" o = AppInfoGetDisplayNameMethodInfo
    ResolveAppInfoMethod "getExecutable" o = AppInfoGetExecutableMethodInfo
    ResolveAppInfoMethod "getIcon" o = AppInfoGetIconMethodInfo
    ResolveAppInfoMethod "getId" o = AppInfoGetIdMethodInfo
    ResolveAppInfoMethod "getName" o = AppInfoGetNameMethodInfo
    ResolveAppInfoMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveAppInfoMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveAppInfoMethod "getSupportedTypes" o = AppInfoGetSupportedTypesMethodInfo
    ResolveAppInfoMethod "setAsDefaultForExtension" o = AppInfoSetAsDefaultForExtensionMethodInfo
    ResolveAppInfoMethod "setAsDefaultForType" o = AppInfoSetAsDefaultForTypeMethodInfo
    ResolveAppInfoMethod "setAsLastUsedForType" o = AppInfoSetAsLastUsedForTypeMethodInfo
    ResolveAppInfoMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveAppInfoMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveAppInfoMethod l o = O.MethodResolutionFailed l o

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

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

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

type instance O.SignalList AppInfo = AppInfoSignalList
type AppInfoSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

foreign import ccall "g_app_info_get_type"
    c_g_app_info_get_type :: IO GType

instance GObject AppInfo where
    gobjectType _ = c_g_app_info_get_type
    

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

toAppInfo :: IsAppInfo o => o -> IO AppInfo
toAppInfo = unsafeCastTo AppInfo

-- method AppInfo::add_supports_type
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "appinfo", 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 = "content_type", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_app_info_add_supports_type" g_app_info_add_supports_type :: 
    Ptr AppInfo ->                          -- appinfo : TInterface (Name {namespace = "Gio", name = "AppInfo"})
    CString ->                              -- content_type : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Adds a content type to the application information to indicate the
application is capable of opening files with the given content type.
-}
appInfoAddSupportsType ::
    (B.CallStack.HasCallStack, MonadIO m, IsAppInfo a) =>
    a
    {- ^ /@appinfo@/: a 'GI.Gio.Interfaces.AppInfo.AppInfo'. -}
    -> T.Text
    {- ^ /@contentType@/: a string. -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
appInfoAddSupportsType appinfo contentType = liftIO $ do
    appinfo' <- unsafeManagedPtrCastPtr appinfo
    contentType' <- textToCString contentType
    onException (do
        _ <- propagateGError $ g_app_info_add_supports_type appinfo' contentType'
        touchManagedPtr appinfo
        freeMem contentType'
        return ()
     ) (do
        freeMem contentType'
     )

data AppInfoAddSupportsTypeMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m, IsAppInfo a) => O.MethodInfo AppInfoAddSupportsTypeMethodInfo a signature where
    overloadedMethod _ = appInfoAddSupportsType

-- method AppInfo::can_delete
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "appinfo", 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}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_app_info_can_delete" g_app_info_can_delete :: 
    Ptr AppInfo ->                          -- appinfo : TInterface (Name {namespace = "Gio", name = "AppInfo"})
    IO CInt

{- |
Obtains the information whether the 'GI.Gio.Interfaces.AppInfo.AppInfo' can be deleted.
See 'GI.Gio.Interfaces.AppInfo.appInfoDelete'.

@since 2.20
-}
appInfoCanDelete ::
    (B.CallStack.HasCallStack, MonadIO m, IsAppInfo a) =>
    a
    {- ^ /@appinfo@/: a 'GI.Gio.Interfaces.AppInfo.AppInfo' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@appinfo@/ can be deleted -}
appInfoCanDelete appinfo = liftIO $ do
    appinfo' <- unsafeManagedPtrCastPtr appinfo
    result <- g_app_info_can_delete appinfo'
    let result' = (/= 0) result
    touchManagedPtr appinfo
    return result'

data AppInfoCanDeleteMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsAppInfo a) => O.MethodInfo AppInfoCanDeleteMethodInfo a signature where
    overloadedMethod _ = appInfoCanDelete

-- method AppInfo::can_remove_supports_type
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "appinfo", 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}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_app_info_can_remove_supports_type" g_app_info_can_remove_supports_type :: 
    Ptr AppInfo ->                          -- appinfo : TInterface (Name {namespace = "Gio", name = "AppInfo"})
    IO CInt

{- |
Checks if a supported content type can be removed from an application.
-}
appInfoCanRemoveSupportsType ::
    (B.CallStack.HasCallStack, MonadIO m, IsAppInfo a) =>
    a
    {- ^ /@appinfo@/: a 'GI.Gio.Interfaces.AppInfo.AppInfo'. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if it is possible to remove supported
    content types from a given /@appinfo@/, 'False' if not. -}
appInfoCanRemoveSupportsType appinfo = liftIO $ do
    appinfo' <- unsafeManagedPtrCastPtr appinfo
    result <- g_app_info_can_remove_supports_type appinfo'
    let result' = (/= 0) result
    touchManagedPtr appinfo
    return result'

data AppInfoCanRemoveSupportsTypeMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsAppInfo a) => O.MethodInfo AppInfoCanRemoveSupportsTypeMethodInfo a signature where
    overloadedMethod _ = appInfoCanRemoveSupportsType

-- method AppInfo::delete
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "appinfo", 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}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_app_info_delete" g_app_info_delete :: 
    Ptr AppInfo ->                          -- appinfo : TInterface (Name {namespace = "Gio", name = "AppInfo"})
    IO CInt

{- |
Tries to delete a 'GI.Gio.Interfaces.AppInfo.AppInfo'.

On some platforms, there may be a difference between user-defined
@/GAppInfos/@ which can be deleted, and system-wide ones which cannot.
See 'GI.Gio.Interfaces.AppInfo.appInfoCanDelete'.

@since 2.20
-}
appInfoDelete ::
    (B.CallStack.HasCallStack, MonadIO m, IsAppInfo a) =>
    a
    {- ^ /@appinfo@/: a 'GI.Gio.Interfaces.AppInfo.AppInfo' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@appinfo@/ has been deleted -}
appInfoDelete appinfo = liftIO $ do
    appinfo' <- unsafeManagedPtrCastPtr appinfo
    result <- g_app_info_delete appinfo'
    let result' = (/= 0) result
    touchManagedPtr appinfo
    return result'

data AppInfoDeleteMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsAppInfo a) => O.MethodInfo AppInfoDeleteMethodInfo a signature where
    overloadedMethod _ = appInfoDelete

-- method AppInfo::dup
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "appinfo", 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}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "AppInfo"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_app_info_dup" g_app_info_dup :: 
    Ptr AppInfo ->                          -- appinfo : TInterface (Name {namespace = "Gio", name = "AppInfo"})
    IO (Ptr AppInfo)

{- |
Creates a duplicate of a 'GI.Gio.Interfaces.AppInfo.AppInfo'.
-}
appInfoDup ::
    (B.CallStack.HasCallStack, MonadIO m, IsAppInfo a) =>
    a
    {- ^ /@appinfo@/: a 'GI.Gio.Interfaces.AppInfo.AppInfo'. -}
    -> m AppInfo
    {- ^ __Returns:__ a duplicate of /@appinfo@/. -}
appInfoDup appinfo = liftIO $ do
    appinfo' <- unsafeManagedPtrCastPtr appinfo
    result <- g_app_info_dup appinfo'
    checkUnexpectedReturnNULL "appInfoDup" result
    result' <- (wrapObject AppInfo) result
    touchManagedPtr appinfo
    return result'

data AppInfoDupMethodInfo
instance (signature ~ (m AppInfo), MonadIO m, IsAppInfo a) => O.MethodInfo AppInfoDupMethodInfo a signature where
    overloadedMethod _ = appInfoDup

-- method AppInfo::equal
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "appinfo1", argType = TInterface (Name {namespace = "Gio", name = "AppInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the first #GAppInfo.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "appinfo2", argType = TInterface (Name {namespace = "Gio", name = "AppInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the second #GAppInfo.", 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_app_info_equal" g_app_info_equal :: 
    Ptr AppInfo ->                          -- appinfo1 : TInterface (Name {namespace = "Gio", name = "AppInfo"})
    Ptr AppInfo ->                          -- appinfo2 : TInterface (Name {namespace = "Gio", name = "AppInfo"})
    IO CInt

{- |
Checks if two @/GAppInfos/@ are equal.
-}
appInfoEqual ::
    (B.CallStack.HasCallStack, MonadIO m, IsAppInfo a, IsAppInfo b) =>
    a
    {- ^ /@appinfo1@/: the first 'GI.Gio.Interfaces.AppInfo.AppInfo'. -}
    -> b
    {- ^ /@appinfo2@/: the second 'GI.Gio.Interfaces.AppInfo.AppInfo'. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@appinfo1@/ is equal to /@appinfo2@/. 'False' otherwise. -}
appInfoEqual appinfo1 appinfo2 = liftIO $ do
    appinfo1' <- unsafeManagedPtrCastPtr appinfo1
    appinfo2' <- unsafeManagedPtrCastPtr appinfo2
    result <- g_app_info_equal appinfo1' appinfo2'
    let result' = (/= 0) result
    touchManagedPtr appinfo1
    touchManagedPtr appinfo2
    return result'

data AppInfoEqualMethodInfo
instance (signature ~ (b -> m Bool), MonadIO m, IsAppInfo a, IsAppInfo b) => O.MethodInfo AppInfoEqualMethodInfo a signature where
    overloadedMethod _ = appInfoEqual

-- method AppInfo::get_commandline
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "appinfo", 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}]
-- Lengths : []
-- returnType : Just (TBasicType TFileName)
-- throws : False
-- Skip return : False

foreign import ccall "g_app_info_get_commandline" g_app_info_get_commandline :: 
    Ptr AppInfo ->                          -- appinfo : TInterface (Name {namespace = "Gio", name = "AppInfo"})
    IO CString

{- |
Gets the commandline with which the application will be
started.

@since 2.20
-}
appInfoGetCommandline ::
    (B.CallStack.HasCallStack, MonadIO m, IsAppInfo a) =>
    a
    {- ^ /@appinfo@/: a 'GI.Gio.Interfaces.AppInfo.AppInfo' -}
    -> m [Char]
    {- ^ __Returns:__ a string containing the /@appinfo@/\'s commandline,
    or 'Nothing' if this information is not available -}
appInfoGetCommandline appinfo = liftIO $ do
    appinfo' <- unsafeManagedPtrCastPtr appinfo
    result <- g_app_info_get_commandline appinfo'
    checkUnexpectedReturnNULL "appInfoGetCommandline" result
    result' <- cstringToString result
    touchManagedPtr appinfo
    return result'

data AppInfoGetCommandlineMethodInfo
instance (signature ~ (m [Char]), MonadIO m, IsAppInfo a) => O.MethodInfo AppInfoGetCommandlineMethodInfo a signature where
    overloadedMethod _ = appInfoGetCommandline

-- method AppInfo::get_description
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "appinfo", 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}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_app_info_get_description" g_app_info_get_description :: 
    Ptr AppInfo ->                          -- appinfo : TInterface (Name {namespace = "Gio", name = "AppInfo"})
    IO CString

{- |
Gets a human-readable description of an installed application.
-}
appInfoGetDescription ::
    (B.CallStack.HasCallStack, MonadIO m, IsAppInfo a) =>
    a
    {- ^ /@appinfo@/: a 'GI.Gio.Interfaces.AppInfo.AppInfo'. -}
    -> m T.Text
    {- ^ __Returns:__ a string containing a description of the
application /@appinfo@/, or 'Nothing' if none. -}
appInfoGetDescription appinfo = liftIO $ do
    appinfo' <- unsafeManagedPtrCastPtr appinfo
    result <- g_app_info_get_description appinfo'
    checkUnexpectedReturnNULL "appInfoGetDescription" result
    result' <- cstringToText result
    touchManagedPtr appinfo
    return result'

data AppInfoGetDescriptionMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsAppInfo a) => O.MethodInfo AppInfoGetDescriptionMethodInfo a signature where
    overloadedMethod _ = appInfoGetDescription

-- method AppInfo::get_display_name
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "appinfo", 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}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_app_info_get_display_name" g_app_info_get_display_name :: 
    Ptr AppInfo ->                          -- appinfo : TInterface (Name {namespace = "Gio", name = "AppInfo"})
    IO CString

{- |
Gets the display name of the application. The display name is often more
descriptive to the user than the name itself.

@since 2.24
-}
appInfoGetDisplayName ::
    (B.CallStack.HasCallStack, MonadIO m, IsAppInfo a) =>
    a
    {- ^ /@appinfo@/: a 'GI.Gio.Interfaces.AppInfo.AppInfo'. -}
    -> m T.Text
    {- ^ __Returns:__ the display name of the application for /@appinfo@/, or the name if
no display name is available. -}
appInfoGetDisplayName appinfo = liftIO $ do
    appinfo' <- unsafeManagedPtrCastPtr appinfo
    result <- g_app_info_get_display_name appinfo'
    checkUnexpectedReturnNULL "appInfoGetDisplayName" result
    result' <- cstringToText result
    touchManagedPtr appinfo
    return result'

data AppInfoGetDisplayNameMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsAppInfo a) => O.MethodInfo AppInfoGetDisplayNameMethodInfo a signature where
    overloadedMethod _ = appInfoGetDisplayName

-- method AppInfo::get_executable
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "appinfo", 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}]
-- Lengths : []
-- returnType : Just (TBasicType TFileName)
-- throws : False
-- Skip return : False

foreign import ccall "g_app_info_get_executable" g_app_info_get_executable :: 
    Ptr AppInfo ->                          -- appinfo : TInterface (Name {namespace = "Gio", name = "AppInfo"})
    IO CString

{- |
Gets the executable\'s name for the installed application.
-}
appInfoGetExecutable ::
    (B.CallStack.HasCallStack, MonadIO m, IsAppInfo a) =>
    a
    {- ^ /@appinfo@/: a 'GI.Gio.Interfaces.AppInfo.AppInfo' -}
    -> m [Char]
    {- ^ __Returns:__ a string containing the /@appinfo@/\'s application
binaries name -}
appInfoGetExecutable appinfo = liftIO $ do
    appinfo' <- unsafeManagedPtrCastPtr appinfo
    result <- g_app_info_get_executable appinfo'
    checkUnexpectedReturnNULL "appInfoGetExecutable" result
    result' <- cstringToString result
    touchManagedPtr appinfo
    return result'

data AppInfoGetExecutableMethodInfo
instance (signature ~ (m [Char]), MonadIO m, IsAppInfo a) => O.MethodInfo AppInfoGetExecutableMethodInfo a signature where
    overloadedMethod _ = appInfoGetExecutable

-- method AppInfo::get_icon
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "appinfo", 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}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "Icon"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_app_info_get_icon" g_app_info_get_icon :: 
    Ptr AppInfo ->                          -- appinfo : TInterface (Name {namespace = "Gio", name = "AppInfo"})
    IO (Ptr Gio.Icon.Icon)

{- |
Gets the icon for the application.
-}
appInfoGetIcon ::
    (B.CallStack.HasCallStack, MonadIO m, IsAppInfo a) =>
    a
    {- ^ /@appinfo@/: a 'GI.Gio.Interfaces.AppInfo.AppInfo'. -}
    -> m Gio.Icon.Icon
    {- ^ __Returns:__ the default 'GI.Gio.Interfaces.Icon.Icon' for /@appinfo@/ or 'Nothing'
if there is no default icon. -}
appInfoGetIcon appinfo = liftIO $ do
    appinfo' <- unsafeManagedPtrCastPtr appinfo
    result <- g_app_info_get_icon appinfo'
    checkUnexpectedReturnNULL "appInfoGetIcon" result
    result' <- (newObject Gio.Icon.Icon) result
    touchManagedPtr appinfo
    return result'

data AppInfoGetIconMethodInfo
instance (signature ~ (m Gio.Icon.Icon), MonadIO m, IsAppInfo a) => O.MethodInfo AppInfoGetIconMethodInfo a signature where
    overloadedMethod _ = appInfoGetIcon

-- method AppInfo::get_id
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "appinfo", 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}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_app_info_get_id" g_app_info_get_id :: 
    Ptr AppInfo ->                          -- appinfo : TInterface (Name {namespace = "Gio", name = "AppInfo"})
    IO CString

{- |
Gets the ID of an application. An id is a string that
identifies the application. The exact format of the id is
platform dependent. For instance, on Unix this is the
desktop file id from the xdg menu specification.

Note that the returned ID may be 'Nothing', depending on how
the /@appinfo@/ has been constructed.
-}
appInfoGetId ::
    (B.CallStack.HasCallStack, MonadIO m, IsAppInfo a) =>
    a
    {- ^ /@appinfo@/: a 'GI.Gio.Interfaces.AppInfo.AppInfo'. -}
    -> m T.Text
    {- ^ __Returns:__ a string containing the application\'s ID. -}
appInfoGetId appinfo = liftIO $ do
    appinfo' <- unsafeManagedPtrCastPtr appinfo
    result <- g_app_info_get_id appinfo'
    checkUnexpectedReturnNULL "appInfoGetId" result
    result' <- cstringToText result
    touchManagedPtr appinfo
    return result'

data AppInfoGetIdMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsAppInfo a) => O.MethodInfo AppInfoGetIdMethodInfo a signature where
    overloadedMethod _ = appInfoGetId

-- method AppInfo::get_name
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "appinfo", 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}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_app_info_get_name" g_app_info_get_name :: 
    Ptr AppInfo ->                          -- appinfo : TInterface (Name {namespace = "Gio", name = "AppInfo"})
    IO CString

{- |
Gets the installed name of the application.
-}
appInfoGetName ::
    (B.CallStack.HasCallStack, MonadIO m, IsAppInfo a) =>
    a
    {- ^ /@appinfo@/: a 'GI.Gio.Interfaces.AppInfo.AppInfo'. -}
    -> m T.Text
    {- ^ __Returns:__ the name of the application for /@appinfo@/. -}
appInfoGetName appinfo = liftIO $ do
    appinfo' <- unsafeManagedPtrCastPtr appinfo
    result <- g_app_info_get_name appinfo'
    checkUnexpectedReturnNULL "appInfoGetName" result
    result' <- cstringToText result
    touchManagedPtr appinfo
    return result'

data AppInfoGetNameMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsAppInfo a) => O.MethodInfo AppInfoGetNameMethodInfo a signature where
    overloadedMethod _ = appInfoGetName

-- method AppInfo::get_supported_types
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "appinfo", argType = TInterface (Name {namespace = "Gio", name = "AppInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAppInfo that can handle files", 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_info_get_supported_types" g_app_info_get_supported_types :: 
    Ptr AppInfo ->                          -- appinfo : TInterface (Name {namespace = "Gio", name = "AppInfo"})
    IO (Ptr CString)

{- |
Retrieves the list of content types that /@appInfo@/ claims to support.
If this information is not provided by the environment, this function
will return 'Nothing'.
This function does not take in consideration associations added with
'GI.Gio.Interfaces.AppInfo.appInfoAddSupportsType', but only those exported directly by
the application.

@since 2.34
-}
appInfoGetSupportedTypes ::
    (B.CallStack.HasCallStack, MonadIO m, IsAppInfo a) =>
    a
    {- ^ /@appinfo@/: a 'GI.Gio.Interfaces.AppInfo.AppInfo' that can handle files -}
    -> m [T.Text]
    {- ^ __Returns:__ 
   a list of content types. -}
appInfoGetSupportedTypes appinfo = liftIO $ do
    appinfo' <- unsafeManagedPtrCastPtr appinfo
    result <- g_app_info_get_supported_types appinfo'
    checkUnexpectedReturnNULL "appInfoGetSupportedTypes" result
    result' <- unpackZeroTerminatedUTF8CArray result
    touchManagedPtr appinfo
    return result'

data AppInfoGetSupportedTypesMethodInfo
instance (signature ~ (m [T.Text]), MonadIO m, IsAppInfo a) => O.MethodInfo AppInfoGetSupportedTypesMethodInfo a signature where
    overloadedMethod _ = appInfoGetSupportedTypes

-- method AppInfo::launch
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "appinfo", 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 = True, argDoc = Documentation {rawDocText = Just "a #GList of #GFile objects", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "launch_context", argType = TInterface (Name {namespace = "Gio", name = "AppLaunchContext"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAppLaunchContext or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_app_info_launch" g_app_info_launch :: 
    Ptr AppInfo ->                          -- appinfo : TInterface (Name {namespace = "Gio", name = "AppInfo"})
    Ptr (GList (Ptr Gio.File.File)) ->      -- files : TGList (TInterface (Name {namespace = "Gio", name = "File"}))
    Ptr Gio.AppLaunchContext.AppLaunchContext -> -- launch_context : TInterface (Name {namespace = "Gio", name = "AppLaunchContext"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Launches the application. Passes /@files@/ to the launched application
as arguments, using the optional /@launchContext@/ to get information
about the details of the launcher (like what screen it is on).
On error, /@error@/ will be set accordingly.

To launch the application without arguments pass a 'Nothing' /@files@/ list.

Note that even if the launch is successful the application launched
can fail to start if it runs into problems during startup. There is
no way to detect this.

Some URIs can be changed when passed through a GFile (for instance
unsupported URIs with strange formats like mailto:), so if you have
a textual URI you want to pass in as argument, consider using
'GI.Gio.Interfaces.AppInfo.appInfoLaunchUris' instead.

The launched application inherits the environment of the launching
process, but it can be modified with 'GI.Gio.Objects.AppLaunchContext.appLaunchContextSetenv'
and 'GI.Gio.Objects.AppLaunchContext.appLaunchContextUnsetenv'.

On UNIX, this function sets the @GIO_LAUNCHED_DESKTOP_FILE@
environment variable with the path of the launched desktop file and
@GIO_LAUNCHED_DESKTOP_FILE_PID@ to the process id of the launched
process. This can be used to ignore @GIO_LAUNCHED_DESKTOP_FILE@,
should it be inherited by further processes. The @DISPLAY@ and
@DESKTOP_STARTUP_ID@ environment variables are also set, based
on information provided in /@launchContext@/.
-}
appInfoLaunch ::
    (B.CallStack.HasCallStack, MonadIO m, IsAppInfo a, Gio.File.IsFile b, Gio.AppLaunchContext.IsAppLaunchContext c) =>
    a
    {- ^ /@appinfo@/: a 'GI.Gio.Interfaces.AppInfo.AppInfo' -}
    -> [b]
    {- ^ /@files@/: a 'GI.GLib.Structs.List.List' of 'GI.Gio.Interfaces.File.File' objects -}
    -> Maybe (c)
    {- ^ /@launchContext@/: a 'GI.Gio.Objects.AppLaunchContext.AppLaunchContext' or 'Nothing' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
appInfoLaunch appinfo files launchContext = liftIO $ do
    appinfo' <- unsafeManagedPtrCastPtr appinfo
    files' <- mapM unsafeManagedPtrCastPtr files
    files'' <- packGList files'
    maybeLaunchContext <- case launchContext of
        Nothing -> return nullPtr
        Just jLaunchContext -> do
            jLaunchContext' <- unsafeManagedPtrCastPtr jLaunchContext
            return jLaunchContext'
    onException (do
        _ <- propagateGError $ g_app_info_launch appinfo' files'' maybeLaunchContext
        touchManagedPtr appinfo
        mapM_ touchManagedPtr files
        whenJust launchContext touchManagedPtr
        g_list_free files''
        return ()
     ) (do
        g_list_free files''
     )

data AppInfoLaunchMethodInfo
instance (signature ~ ([b] -> Maybe (c) -> m ()), MonadIO m, IsAppInfo a, Gio.File.IsFile b, Gio.AppLaunchContext.IsAppLaunchContext c) => O.MethodInfo AppInfoLaunchMethodInfo a signature where
    overloadedMethod _ = appInfoLaunch

-- method AppInfo::launch_uris
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "appinfo", 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 = "uris", argType = TGList (TBasicType TUTF8), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GList containing URIs to launch.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "launch_context", argType = TInterface (Name {namespace = "Gio", name = "AppLaunchContext"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAppLaunchContext or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_app_info_launch_uris" g_app_info_launch_uris :: 
    Ptr AppInfo ->                          -- appinfo : TInterface (Name {namespace = "Gio", name = "AppInfo"})
    Ptr (GList CString) ->                  -- uris : TGList (TBasicType TUTF8)
    Ptr Gio.AppLaunchContext.AppLaunchContext -> -- launch_context : TInterface (Name {namespace = "Gio", name = "AppLaunchContext"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Launches the application. This passes the /@uris@/ to the launched application
as arguments, using the optional /@launchContext@/ to get information
about the details of the launcher (like what screen it is on).
On error, /@error@/ will be set accordingly.

To launch the application without arguments pass a 'Nothing' /@uris@/ list.

Note that even if the launch is successful the application launched
can fail to start if it runs into problems during startup. There is
no way to detect this.
-}
appInfoLaunchUris ::
    (B.CallStack.HasCallStack, MonadIO m, IsAppInfo a, Gio.AppLaunchContext.IsAppLaunchContext b) =>
    a
    {- ^ /@appinfo@/: a 'GI.Gio.Interfaces.AppInfo.AppInfo' -}
    -> [T.Text]
    {- ^ /@uris@/: a 'GI.GLib.Structs.List.List' containing URIs to launch. -}
    -> Maybe (b)
    {- ^ /@launchContext@/: a 'GI.Gio.Objects.AppLaunchContext.AppLaunchContext' or 'Nothing' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
appInfoLaunchUris appinfo uris launchContext = liftIO $ do
    appinfo' <- unsafeManagedPtrCastPtr appinfo
    uris' <- mapM textToCString uris
    uris'' <- packGList uris'
    maybeLaunchContext <- case launchContext of
        Nothing -> return nullPtr
        Just jLaunchContext -> do
            jLaunchContext' <- unsafeManagedPtrCastPtr jLaunchContext
            return jLaunchContext'
    onException (do
        _ <- propagateGError $ g_app_info_launch_uris appinfo' uris'' maybeLaunchContext
        touchManagedPtr appinfo
        whenJust launchContext touchManagedPtr
        mapGList freeMem uris''
        g_list_free uris''
        return ()
     ) (do
        mapGList freeMem uris''
        g_list_free uris''
     )

data AppInfoLaunchUrisMethodInfo
instance (signature ~ ([T.Text] -> Maybe (b) -> m ()), MonadIO m, IsAppInfo a, Gio.AppLaunchContext.IsAppLaunchContext b) => O.MethodInfo AppInfoLaunchUrisMethodInfo a signature where
    overloadedMethod _ = appInfoLaunchUris

-- method AppInfo::remove_supports_type
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "appinfo", 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 = "content_type", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_app_info_remove_supports_type" g_app_info_remove_supports_type :: 
    Ptr AppInfo ->                          -- appinfo : TInterface (Name {namespace = "Gio", name = "AppInfo"})
    CString ->                              -- content_type : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Removes a supported type from an application, if possible.
-}
appInfoRemoveSupportsType ::
    (B.CallStack.HasCallStack, MonadIO m, IsAppInfo a) =>
    a
    {- ^ /@appinfo@/: a 'GI.Gio.Interfaces.AppInfo.AppInfo'. -}
    -> T.Text
    {- ^ /@contentType@/: a string. -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
appInfoRemoveSupportsType appinfo contentType = liftIO $ do
    appinfo' <- unsafeManagedPtrCastPtr appinfo
    contentType' <- textToCString contentType
    onException (do
        _ <- propagateGError $ g_app_info_remove_supports_type appinfo' contentType'
        touchManagedPtr appinfo
        freeMem contentType'
        return ()
     ) (do
        freeMem contentType'
     )

data AppInfoRemoveSupportsTypeMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m, IsAppInfo a) => O.MethodInfo AppInfoRemoveSupportsTypeMethodInfo a signature where
    overloadedMethod _ = appInfoRemoveSupportsType

-- method AppInfo::set_as_default_for_extension
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "appinfo", 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 = "extension", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string containing the file extension\n    (without the dot).", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_app_info_set_as_default_for_extension" g_app_info_set_as_default_for_extension :: 
    Ptr AppInfo ->                          -- appinfo : TInterface (Name {namespace = "Gio", name = "AppInfo"})
    CString ->                              -- extension : TBasicType TFileName
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Sets the application as the default handler for the given file extension.
-}
appInfoSetAsDefaultForExtension ::
    (B.CallStack.HasCallStack, MonadIO m, IsAppInfo a) =>
    a
    {- ^ /@appinfo@/: a 'GI.Gio.Interfaces.AppInfo.AppInfo'. -}
    -> [Char]
    {- ^ /@extension@/: a string containing the file extension
    (without the dot). -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
appInfoSetAsDefaultForExtension appinfo extension = liftIO $ do
    appinfo' <- unsafeManagedPtrCastPtr appinfo
    extension' <- stringToCString extension
    onException (do
        _ <- propagateGError $ g_app_info_set_as_default_for_extension appinfo' extension'
        touchManagedPtr appinfo
        freeMem extension'
        return ()
     ) (do
        freeMem extension'
     )

data AppInfoSetAsDefaultForExtensionMethodInfo
instance (signature ~ ([Char] -> m ()), MonadIO m, IsAppInfo a) => O.MethodInfo AppInfoSetAsDefaultForExtensionMethodInfo a signature where
    overloadedMethod _ = appInfoSetAsDefaultForExtension

-- method AppInfo::set_as_default_for_type
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "appinfo", 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 = "content_type", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the content type.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_app_info_set_as_default_for_type" g_app_info_set_as_default_for_type :: 
    Ptr AppInfo ->                          -- appinfo : TInterface (Name {namespace = "Gio", name = "AppInfo"})
    CString ->                              -- content_type : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Sets the application as the default handler for a given type.
-}
appInfoSetAsDefaultForType ::
    (B.CallStack.HasCallStack, MonadIO m, IsAppInfo a) =>
    a
    {- ^ /@appinfo@/: a 'GI.Gio.Interfaces.AppInfo.AppInfo'. -}
    -> T.Text
    {- ^ /@contentType@/: the content type. -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
appInfoSetAsDefaultForType appinfo contentType = liftIO $ do
    appinfo' <- unsafeManagedPtrCastPtr appinfo
    contentType' <- textToCString contentType
    onException (do
        _ <- propagateGError $ g_app_info_set_as_default_for_type appinfo' contentType'
        touchManagedPtr appinfo
        freeMem contentType'
        return ()
     ) (do
        freeMem contentType'
     )

data AppInfoSetAsDefaultForTypeMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m, IsAppInfo a) => O.MethodInfo AppInfoSetAsDefaultForTypeMethodInfo a signature where
    overloadedMethod _ = appInfoSetAsDefaultForType

-- method AppInfo::set_as_last_used_for_type
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "appinfo", 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 = "content_type", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the content type.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_app_info_set_as_last_used_for_type" g_app_info_set_as_last_used_for_type :: 
    Ptr AppInfo ->                          -- appinfo : TInterface (Name {namespace = "Gio", name = "AppInfo"})
    CString ->                              -- content_type : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Sets the application as the last used application for a given type.
This will make the application appear as first in the list returned
by 'GI.Gio.Functions.appInfoGetRecommendedForType', regardless of the default
application for that content type.
-}
appInfoSetAsLastUsedForType ::
    (B.CallStack.HasCallStack, MonadIO m, IsAppInfo a) =>
    a
    {- ^ /@appinfo@/: a 'GI.Gio.Interfaces.AppInfo.AppInfo'. -}
    -> T.Text
    {- ^ /@contentType@/: the content type. -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
appInfoSetAsLastUsedForType appinfo contentType = liftIO $ do
    appinfo' <- unsafeManagedPtrCastPtr appinfo
    contentType' <- textToCString contentType
    onException (do
        _ <- propagateGError $ g_app_info_set_as_last_used_for_type appinfo' contentType'
        touchManagedPtr appinfo
        freeMem contentType'
        return ()
     ) (do
        freeMem contentType'
     )

data AppInfoSetAsLastUsedForTypeMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m, IsAppInfo a) => O.MethodInfo AppInfoSetAsLastUsedForTypeMethodInfo a signature where
    overloadedMethod _ = appInfoSetAsLastUsedForType

-- method AppInfo::should_show
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "appinfo", 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}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_app_info_should_show" g_app_info_should_show :: 
    Ptr AppInfo ->                          -- appinfo : TInterface (Name {namespace = "Gio", name = "AppInfo"})
    IO CInt

{- |
Checks if the application info should be shown in menus that
list available applications.
-}
appInfoShouldShow ::
    (B.CallStack.HasCallStack, MonadIO m, IsAppInfo a) =>
    a
    {- ^ /@appinfo@/: a 'GI.Gio.Interfaces.AppInfo.AppInfo'. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the /@appinfo@/ should be shown, 'False' otherwise. -}
appInfoShouldShow appinfo = liftIO $ do
    appinfo' <- unsafeManagedPtrCastPtr appinfo
    result <- g_app_info_should_show appinfo'
    let result' = (/= 0) result
    touchManagedPtr appinfo
    return result'

data AppInfoShouldShowMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsAppInfo a) => O.MethodInfo AppInfoShouldShowMethodInfo a signature where
    overloadedMethod _ = appInfoShouldShow

-- method AppInfo::supports_files
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "appinfo", 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}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_app_info_supports_files" g_app_info_supports_files :: 
    Ptr AppInfo ->                          -- appinfo : TInterface (Name {namespace = "Gio", name = "AppInfo"})
    IO CInt

{- |
Checks if the application accepts files as arguments.
-}
appInfoSupportsFiles ::
    (B.CallStack.HasCallStack, MonadIO m, IsAppInfo a) =>
    a
    {- ^ /@appinfo@/: a 'GI.Gio.Interfaces.AppInfo.AppInfo'. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the /@appinfo@/ supports files. -}
appInfoSupportsFiles appinfo = liftIO $ do
    appinfo' <- unsafeManagedPtrCastPtr appinfo
    result <- g_app_info_supports_files appinfo'
    let result' = (/= 0) result
    touchManagedPtr appinfo
    return result'

data AppInfoSupportsFilesMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsAppInfo a) => O.MethodInfo AppInfoSupportsFilesMethodInfo a signature where
    overloadedMethod _ = appInfoSupportsFiles

-- method AppInfo::supports_uris
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "appinfo", 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}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_app_info_supports_uris" g_app_info_supports_uris :: 
    Ptr AppInfo ->                          -- appinfo : TInterface (Name {namespace = "Gio", name = "AppInfo"})
    IO CInt

{- |
Checks if the application supports reading files and directories from URIs.
-}
appInfoSupportsUris ::
    (B.CallStack.HasCallStack, MonadIO m, IsAppInfo a) =>
    a
    {- ^ /@appinfo@/: a 'GI.Gio.Interfaces.AppInfo.AppInfo'. -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the /@appinfo@/ supports URIs. -}
appInfoSupportsUris appinfo = liftIO $ do
    appinfo' <- unsafeManagedPtrCastPtr appinfo
    result <- g_app_info_supports_uris appinfo'
    let result' = (/= 0) result
    touchManagedPtr appinfo
    return result'

data AppInfoSupportsUrisMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsAppInfo a) => O.MethodInfo AppInfoSupportsUrisMethodInfo a signature where
    overloadedMethod _ = appInfoSupportsUris

-- method AppInfo::create_from_commandline
-- method type : MemberFunction
-- Args : [Arg {argCName = "commandline", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the commandline to use", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "application_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the application name, or %NULL to use @commandline", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "AppInfoCreateFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "flags that can specify details of the created #GAppInfo", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "AppInfo"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_app_info_create_from_commandline" g_app_info_create_from_commandline :: 
    CString ->                              -- commandline : TBasicType TUTF8
    CString ->                              -- application_name : TBasicType TUTF8
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "AppInfoCreateFlags"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr AppInfo)

{- |
Creates a new 'GI.Gio.Interfaces.AppInfo.AppInfo' from the given information.

Note that for /@commandline@/, the quoting rules of the Exec key of the
<http://freedesktop.org/Standards/desktop-entry-spec freedesktop.org Desktop Entry Specification>
are applied. For example, if the /@commandline@/ contains
percent-encoded URIs, the percent-character must be doubled in order to prevent it from
being swallowed by Exec key unquoting. See the specification for exact quoting rules.
-}
appInfoCreateFromCommandline ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@commandline@/: the commandline to use -}
    -> Maybe (T.Text)
    {- ^ /@applicationName@/: the application name, or 'Nothing' to use /@commandline@/ -}
    -> [Gio.Flags.AppInfoCreateFlags]
    {- ^ /@flags@/: flags that can specify details of the created 'GI.Gio.Interfaces.AppInfo.AppInfo' -}
    -> m AppInfo
    {- ^ __Returns:__ new 'GI.Gio.Interfaces.AppInfo.AppInfo' for given command. /(Can throw 'Data.GI.Base.GError.GError')/ -}
appInfoCreateFromCommandline commandline applicationName flags = liftIO $ do
    commandline' <- textToCString commandline
    maybeApplicationName <- case applicationName of
        Nothing -> return nullPtr
        Just jApplicationName -> do
            jApplicationName' <- textToCString jApplicationName
            return jApplicationName'
    let flags' = gflagsToWord flags
    onException (do
        result <- propagateGError $ g_app_info_create_from_commandline commandline' maybeApplicationName flags'
        checkUnexpectedReturnNULL "appInfoCreateFromCommandline" result
        result' <- (wrapObject AppInfo) result
        freeMem commandline'
        freeMem maybeApplicationName
        return result'
     ) (do
        freeMem commandline'
        freeMem maybeApplicationName
     )

-- method AppInfo::get_all
-- method type : MemberFunction
-- Args : []
-- Lengths : []
-- returnType : Just (TGList (TInterface (Name {namespace = "Gio", name = "AppInfo"})))
-- throws : False
-- Skip return : False

foreign import ccall "g_app_info_get_all" g_app_info_get_all :: 
    IO (Ptr (GList (Ptr AppInfo)))

{- |
Gets a list of all of the applications currently registered
on this system.

For desktop files, this includes applications that have
@NoDisplay=true@ set or are excluded from display by means
of @OnlyShowIn@ or @NotShowIn@. See 'GI.Gio.Interfaces.AppInfo.appInfoShouldShow'.
The returned list does not include applications which have
the @Hidden@ key set.
-}
appInfoGetAll ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m [AppInfo]
    {- ^ __Returns:__ a newly allocated 'GI.GLib.Structs.List.List' of references to @/GAppInfos/@. -}
appInfoGetAll  = liftIO $ do
    result <- g_app_info_get_all
    result' <- unpackGList result
    result'' <- mapM (wrapObject AppInfo) result'
    g_list_free result
    return result''

-- method AppInfo::get_all_for_type
-- method type : MemberFunction
-- Args : [Arg {argCName = "content_type", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the content type to find a #GAppInfo for", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TGList (TInterface (Name {namespace = "Gio", name = "AppInfo"})))
-- throws : False
-- Skip return : False

foreign import ccall "g_app_info_get_all_for_type" g_app_info_get_all_for_type :: 
    CString ->                              -- content_type : TBasicType TUTF8
    IO (Ptr (GList (Ptr AppInfo)))

{- |
Gets a list of all @/GAppInfos/@ for a given content type,
including the recommended and fallback @/GAppInfos/@. See
'GI.Gio.Functions.appInfoGetRecommendedForType' and
'GI.Gio.Functions.appInfoGetFallbackForType'.
-}
appInfoGetAllForType ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@contentType@/: the content type to find a 'GI.Gio.Interfaces.AppInfo.AppInfo' for -}
    -> m [AppInfo]
    {- ^ __Returns:__ 'GI.GLib.Structs.List.List' of @/GAppInfos/@
    for given /@contentType@/ or 'Nothing' on error. -}
appInfoGetAllForType contentType = liftIO $ do
    contentType' <- textToCString contentType
    result <- g_app_info_get_all_for_type contentType'
    result' <- unpackGList result
    result'' <- mapM (wrapObject AppInfo) result'
    g_list_free result
    freeMem contentType'
    return result''

-- method AppInfo::get_default_for_type
-- method type : MemberFunction
-- Args : [Arg {argCName = "content_type", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the content type to find a #GAppInfo for", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "must_support_uris", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "if %TRUE, the #GAppInfo is expected to\n    support URIs", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "AppInfo"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_app_info_get_default_for_type" g_app_info_get_default_for_type :: 
    CString ->                              -- content_type : TBasicType TUTF8
    CInt ->                                 -- must_support_uris : TBasicType TBoolean
    IO (Ptr AppInfo)

{- |
Gets the default 'GI.Gio.Interfaces.AppInfo.AppInfo' for a given content type.
-}
appInfoGetDefaultForType ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@contentType@/: the content type to find a 'GI.Gio.Interfaces.AppInfo.AppInfo' for -}
    -> Bool
    {- ^ /@mustSupportUris@/: if 'True', the 'GI.Gio.Interfaces.AppInfo.AppInfo' is expected to
    support URIs -}
    -> m AppInfo
    {- ^ __Returns:__ 'GI.Gio.Interfaces.AppInfo.AppInfo' for given /@contentType@/ or
    'Nothing' on error. -}
appInfoGetDefaultForType contentType mustSupportUris = liftIO $ do
    contentType' <- textToCString contentType
    let mustSupportUris' = (fromIntegral . fromEnum) mustSupportUris
    result <- g_app_info_get_default_for_type contentType' mustSupportUris'
    checkUnexpectedReturnNULL "appInfoGetDefaultForType" result
    result' <- (wrapObject AppInfo) result
    freeMem contentType'
    return result'

-- method AppInfo::get_default_for_uri_scheme
-- method type : MemberFunction
-- Args : [Arg {argCName = "uri_scheme", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string containing a URI scheme.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "AppInfo"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_app_info_get_default_for_uri_scheme" g_app_info_get_default_for_uri_scheme :: 
    CString ->                              -- uri_scheme : TBasicType TUTF8
    IO (Ptr AppInfo)

{- |
Gets the default application for handling URIs with
the given URI scheme. A URI scheme is the initial part
of the URI, up to but not including the \':\', e.g. \"http\",
\"ftp\" or \"sip\".
-}
appInfoGetDefaultForUriScheme ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@uriScheme@/: a string containing a URI scheme. -}
    -> m AppInfo
    {- ^ __Returns:__ 'GI.Gio.Interfaces.AppInfo.AppInfo' for given /@uriScheme@/ or 'Nothing' on error. -}
appInfoGetDefaultForUriScheme uriScheme = liftIO $ do
    uriScheme' <- textToCString uriScheme
    result <- g_app_info_get_default_for_uri_scheme uriScheme'
    checkUnexpectedReturnNULL "appInfoGetDefaultForUriScheme" result
    result' <- (wrapObject AppInfo) result
    freeMem uriScheme'
    return result'

-- method AppInfo::get_fallback_for_type
-- method type : MemberFunction
-- Args : [Arg {argCName = "content_type", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the content type to find a #GAppInfo for", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TGList (TInterface (Name {namespace = "Gio", name = "AppInfo"})))
-- throws : False
-- Skip return : False

foreign import ccall "g_app_info_get_fallback_for_type" g_app_info_get_fallback_for_type :: 
    CString ->                              -- content_type : TBasicType TUTF8
    IO (Ptr (GList (Ptr AppInfo)))

{- |
Gets a list of fallback @/GAppInfos/@ for a given content type, i.e.
those applications which claim to support the given content type
by MIME type subclassing and not directly.

@since 2.28
-}
appInfoGetFallbackForType ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@contentType@/: the content type to find a 'GI.Gio.Interfaces.AppInfo.AppInfo' for -}
    -> m [AppInfo]
    {- ^ __Returns:__ 'GI.GLib.Structs.List.List' of @/GAppInfos/@
    for given /@contentType@/ or 'Nothing' on error. -}
appInfoGetFallbackForType contentType = liftIO $ do
    contentType' <- textToCString contentType
    result <- g_app_info_get_fallback_for_type contentType'
    result' <- unpackGList result
    result'' <- mapM (wrapObject AppInfo) result'
    g_list_free result
    freeMem contentType'
    return result''

-- method AppInfo::get_recommended_for_type
-- method type : MemberFunction
-- Args : [Arg {argCName = "content_type", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the content type to find a #GAppInfo for", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TGList (TInterface (Name {namespace = "Gio", name = "AppInfo"})))
-- throws : False
-- Skip return : False

foreign import ccall "g_app_info_get_recommended_for_type" g_app_info_get_recommended_for_type :: 
    CString ->                              -- content_type : TBasicType TUTF8
    IO (Ptr (GList (Ptr AppInfo)))

{- |
Gets a list of recommended @/GAppInfos/@ for a given content type, i.e.
those applications which claim to support the given content type exactly,
and not by MIME type subclassing.
Note that the first application of the list is the last used one, i.e.
the last one for which 'GI.Gio.Interfaces.AppInfo.appInfoSetAsLastUsedForType' has been
called.

@since 2.28
-}
appInfoGetRecommendedForType ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@contentType@/: the content type to find a 'GI.Gio.Interfaces.AppInfo.AppInfo' for -}
    -> m [AppInfo]
    {- ^ __Returns:__ 'GI.GLib.Structs.List.List' of @/GAppInfos/@
    for given /@contentType@/ or 'Nothing' on error. -}
appInfoGetRecommendedForType contentType = liftIO $ do
    contentType' <- textToCString contentType
    result <- g_app_info_get_recommended_for_type contentType'
    result' <- unpackGList result
    result'' <- mapM (wrapObject AppInfo) result'
    g_list_free result
    freeMem contentType'
    return result''

-- method AppInfo::launch_default_for_uri
-- method type : MemberFunction
-- Args : [Arg {argCName = "uri", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the uri to show", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "launch_context", argType = TInterface (Name {namespace = "Gio", name = "AppLaunchContext"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "an optional #GAppLaunchContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_app_info_launch_default_for_uri" g_app_info_launch_default_for_uri :: 
    CString ->                              -- uri : TBasicType TUTF8
    Ptr Gio.AppLaunchContext.AppLaunchContext -> -- launch_context : TInterface (Name {namespace = "Gio", name = "AppLaunchContext"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Utility function that launches the default application
registered to handle the specified uri. Synchronous I\/O
is done on the uri to detect the type of the file if
required.
-}
appInfoLaunchDefaultForUri ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.AppLaunchContext.IsAppLaunchContext a) =>
    T.Text
    {- ^ /@uri@/: the uri to show -}
    -> Maybe (a)
    {- ^ /@launchContext@/: an optional 'GI.Gio.Objects.AppLaunchContext.AppLaunchContext' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
appInfoLaunchDefaultForUri uri launchContext = liftIO $ do
    uri' <- textToCString uri
    maybeLaunchContext <- case launchContext of
        Nothing -> return nullPtr
        Just jLaunchContext -> do
            jLaunchContext' <- unsafeManagedPtrCastPtr jLaunchContext
            return jLaunchContext'
    onException (do
        _ <- propagateGError $ g_app_info_launch_default_for_uri uri' maybeLaunchContext
        whenJust launchContext touchManagedPtr
        freeMem uri'
        return ()
     ) (do
        freeMem uri'
     )

-- method AppInfo::launch_default_for_uri_async
-- method type : MemberFunction
-- Args : [Arg {argCName = "uri", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the uri to show", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "launch_context", argType = TInterface (Name {namespace = "Gio", name = "AppLaunchContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GASyncReadyCallback to call when the request is done", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 4, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "data to pass to @callback", 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_info_launch_default_for_uri_async" g_app_info_launch_default_for_uri_async :: 
    CString ->                              -- uri : TBasicType TUTF8
    Ptr Gio.AppLaunchContext.AppLaunchContext -> -- launch_context : TInterface (Name {namespace = "Gio", name = "AppLaunchContext"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Async version of 'GI.Gio.Functions.appInfoLaunchDefaultForUri'.

This version is useful if you are interested in receiving
error information in the case where the application is
sandboxed and the portal may present an application chooser
dialog to the user.

@since 2.50
-}
appInfoLaunchDefaultForUriAsync ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.AppLaunchContext.IsAppLaunchContext a, Gio.Cancellable.IsCancellable b) =>
    T.Text
    {- ^ /@uri@/: the uri to show -}
    -> a
    -> Maybe (b)
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a @/GASyncReadyCallback/@ to call when the request is done -}
    -> m ()
appInfoLaunchDefaultForUriAsync uri launchContext cancellable callback = liftIO $ do
    uri' <- textToCString uri
    launchContext' <- unsafeManagedPtrCastPtr launchContext
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_app_info_launch_default_for_uri_async uri' launchContext' maybeCancellable maybeCallback userData
    touchManagedPtr launchContext
    whenJust cancellable touchManagedPtr
    freeMem uri'
    return ()

-- method AppInfo::launch_default_for_uri_finish
-- method type : MemberFunction
-- Args : [Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_app_info_launch_default_for_uri_finish" g_app_info_launch_default_for_uri_finish :: 
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Finishes an asynchronous launch-default-for-uri operation.

@since 2.50
-}
appInfoLaunchDefaultForUriFinish ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.AsyncResult.IsAsyncResult a) =>
    a
    {- ^ /@result@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
appInfoLaunchDefaultForUriFinish result_ = liftIO $ do
    result_' <- unsafeManagedPtrCastPtr result_
    onException (do
        _ <- propagateGError $ g_app_info_launch_default_for_uri_finish result_'
        touchManagedPtr result_
        return ()
     ) (do
        return ()
     )

-- method AppInfo::reset_type_associations
-- method type : MemberFunction
-- Args : [Arg {argCName = "content_type", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a content type", 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_info_reset_type_associations" g_app_info_reset_type_associations :: 
    CString ->                              -- content_type : TBasicType TUTF8
    IO ()

{- |
Removes all changes to the type associations done by
'GI.Gio.Interfaces.AppInfo.appInfoSetAsDefaultForType',
'GI.Gio.Interfaces.AppInfo.appInfoSetAsDefaultForExtension',
'GI.Gio.Interfaces.AppInfo.appInfoAddSupportsType' or
'GI.Gio.Interfaces.AppInfo.appInfoRemoveSupportsType'.

@since 2.20
-}
appInfoResetTypeAssociations ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@contentType@/: a content type -}
    -> m ()
appInfoResetTypeAssociations contentType = liftIO $ do
    contentType' <- textToCString contentType
    g_app_info_reset_type_associations contentType'
    freeMem contentType'
    return ()