module System.GIO.File.AppInfo (
AppInfo,
AppInfoClass,
AppLaunchContext,
AppLaunchContextClass,
AppInfoCreateFlags (..),
appInfoCreateFromCommandline,
appInfoDup,
appInfoEqual,
appInfoGetId,
appInfoGetName,
appInfoGetDisplayName,
appInfoGetDescription,
appInfoGetExecutable,
appInfoGetCommandline,
appInfoGetIcon,
appInfoLaunch,
appInfoSupportsFiles,
appInfoSupportsUris,
appInfoLaunchUris,
appInfoShouldShow,
appInfoCanDelete,
appInfoDelete,
appInfoResetTypeAssociations,
appInfoSetAsDefaultForType,
appInfoSetAsDefaultForExtension,
appInfoAddSupportsType,
appInfoCanRemoveSupportsType,
appInfoRemoveSupportsType,
appInfoGetAll,
appInfoGetAllForType,
appInfoGetDefaultForType,
appInfoGetDefaultForUriScheme,
appInfoLaunchDefaultForUri,
appLaunchContextGetDisplay,
appLaunchContextGetStartupNotifyId,
appLaunchContextLaunchFailed,
appLaunchContextNew
) where
import Control.Monad
import Data.Maybe (fromMaybe)
import Data.ByteString (ByteString)
import Data.ByteString.Unsafe (unsafePackCStringFinalizer)
import System.GIO.Enums
import System.Glib.FFI
import System.Glib.Flags
import System.Glib.GError
import System.Glib.GList
import System.Glib.GObject
import System.Glib.UTFString
import System.GIO.Types
appInfoCreateFromCommandline ::
GlibString string
=> string
-> Maybe string
-> [AppInfoCreateFlags]
-> IO AppInfo
appInfoCreateFromCommandline commandline applicationName flags =
wrapNewGObject mkAppInfo $
withUTFString commandline $ \ commandlinePtr ->
maybeWith withUTFString applicationName $ \ applicationNamePtr ->
propagateGError (g_app_info_create_from_commandline
commandlinePtr
applicationNamePtr
((fromIntegral . fromFlags) flags))
appInfoDup :: AppInfoClass appinfo => appinfo -> IO AppInfo
appInfoDup appinfo =
wrapNewGObject mkAppInfo $
(\(AppInfo arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_app_info_dup argPtr1) (toAppInfo appinfo)
appInfoEqual :: (AppInfoClass info1, AppInfoClass info2) => info1 -> info2
-> Bool
appInfoEqual info1 info2 =
unsafePerformIO $ liftM toBool $
(\(AppInfo arg1) (AppInfo arg2) -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->g_app_info_equal argPtr1 argPtr2) (toAppInfo info1) (toAppInfo info2)
appInfoGetId :: (AppInfoClass appinfo, GlibString string)
=> appinfo
-> IO (Maybe string)
appInfoGetId appinfo =
(\(AppInfo arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_app_info_get_id argPtr1) (toAppInfo appinfo)
>>= maybePeek readUTFString
appInfoGetName :: AppInfoClass appinfo => appinfo
-> String
appInfoGetName appinfo =
unsafePerformIO $
(\(AppInfo arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_app_info_get_name argPtr1) (toAppInfo appinfo)
>>= readCString
appInfoGetDisplayName :: (AppInfoClass appinfo, GlibString string)
=> appinfo
-> string
appInfoGetDisplayName appinfo =
unsafePerformIO $
(\(AppInfo arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_app_info_get_display_name argPtr1) (toAppInfo appinfo)
>>= readUTFString
appInfoGetDescription :: (AppInfoClass appinfo, GlibString string)
=> appinfo
-> Maybe string
appInfoGetDescription appinfo =
unsafePerformIO $ do
(\(AppInfo arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_app_info_get_description argPtr1) (toAppInfo appinfo)
>>= maybePeek peekUTFString
appInfoGetExecutable :: (AppInfoClass appinfo, GlibString string)
=> appinfo
-> string
appInfoGetExecutable appinfo =
unsafePerformIO $
(\(AppInfo arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_app_info_get_executable argPtr1) (toAppInfo appinfo)
>>= peekUTFString
appInfoGetCommandline :: AppInfoClass appinfo => appinfo
-> Maybe ByteString
appInfoGetCommandline appinfo =
unsafePerformIO $ do
sPtr <- (\(AppInfo arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_app_info_get_commandline argPtr1) (toAppInfo appinfo)
if sPtr == nullPtr
then return Nothing
else do
sLen <- lengthArray0 0 sPtr
liftM Just $ unsafePackCStringFinalizer (castPtr sPtr) (fromIntegral sLen)
(g_free (castPtr sPtr))
appInfoGetIcon :: AppInfoClass appinfo => appinfo
-> IO (Maybe Icon)
appInfoGetIcon appinfo =
maybeNull (makeNewGObject mkIcon) $
(\(AppInfo arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_app_info_get_icon argPtr1) (toAppInfo appinfo)
appInfoLaunch :: AppInfoClass appinfo => appinfo
-> [File]
-> Maybe AppLaunchContext
-> IO ()
appInfoLaunch appinfo files launchContext =
withForeignPtrs (map unFile files) $ \wFilePtr ->
withGList wFilePtr $ \filesPtr ->
propagateGError (\gErrorPtr -> do
(\(AppInfo arg1) arg2 (AppLaunchContext arg3) arg4 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg3 $ \argPtr3 ->g_app_info_launch argPtr1 arg2 argPtr3 arg4)
(toAppInfo appinfo)
filesPtr
(fromMaybe (AppLaunchContext nullForeignPtr) launchContext)
gErrorPtr
return ())
appInfoSupportsFiles :: AppInfoClass appinfo => appinfo
-> IO Bool
appInfoSupportsFiles appinfo =
liftM toBool $
(\(AppInfo arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_app_info_supports_files argPtr1) (toAppInfo appinfo)
appInfoSupportsUris :: AppInfoClass appinfo => appinfo
-> IO Bool
appInfoSupportsUris appinfo =
liftM toBool $
(\(AppInfo arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_app_info_supports_uris argPtr1) (toAppInfo appinfo)
appInfoLaunchUris :: (AppInfoClass appinfo, GlibString string)
=> appinfo
-> [string]
-> Maybe AppLaunchContext
-> IO ()
appInfoLaunchUris appinfo uris launchContext =
withUTFStringArray uris $ \urisPtr ->
propagateGError (\gErrorPtr -> do
(\(AppInfo arg1) arg2 (AppLaunchContext arg3) arg4 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg3 $ \argPtr3 ->g_app_info_launch_uris argPtr1 arg2 argPtr3 arg4)
(toAppInfo appinfo)
(castPtr urisPtr)
(fromMaybe (AppLaunchContext nullForeignPtr) launchContext)
gErrorPtr
return ())
appInfoShouldShow :: AppInfoClass appinfo => appinfo
-> IO Bool
appInfoShouldShow appinfo =
liftM toBool $
(\(AppInfo arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_app_info_should_show argPtr1) (toAppInfo appinfo)
appInfoCanDelete :: AppInfoClass appinfo => appinfo
-> IO Bool
appInfoCanDelete appinfo =
liftM toBool $
(\(AppInfo arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_app_info_can_delete argPtr1) (toAppInfo appinfo)
appInfoDelete :: AppInfoClass appinfo => appinfo
-> IO Bool
appInfoDelete appinfo =
liftM toBool $
(\(AppInfo arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_app_info_delete argPtr1) (toAppInfo appinfo)
appInfoResetTypeAssociations ::
GlibString string
=> string
-> IO ()
appInfoResetTypeAssociations contentType =
withUTFString contentType $ \ contentTypePtr ->
g_app_info_reset_type_associations (castPtr contentTypePtr)
appInfoSetAsDefaultForType :: (AppInfoClass appinfo, GlibString string)
=> appinfo
-> string
-> IO ()
appInfoSetAsDefaultForType appinfo contentType =
withUTFString contentType $ \ contentTypePtr ->
propagateGError (\gErrorPtr -> do
(\(AppInfo arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->g_app_info_set_as_default_for_type argPtr1 arg2 arg3)
(toAppInfo appinfo)
(castPtr contentTypePtr)
gErrorPtr
return ())
appInfoSetAsDefaultForExtension :: (AppInfoClass appinfo, GlibString string)
=> appinfo
-> string
-> IO ()
appInfoSetAsDefaultForExtension appinfo extension =
withUTFString extension $ \ extensionPtr ->
propagateGError (\gErrorPtr -> do
(\(AppInfo arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->g_app_info_set_as_default_for_extension argPtr1 arg2 arg3)
(toAppInfo appinfo)
(castPtr extensionPtr)
gErrorPtr
return ())
appInfoAddSupportsType :: (AppInfoClass appinfo, GlibString string)
=> appinfo
-> string
-> IO ()
appInfoAddSupportsType appinfo extension =
withUTFString extension $ \ extensionPtr ->
propagateGError (\gErrorPtr -> do
(\(AppInfo arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->g_app_info_add_supports_type argPtr1 arg2 arg3)
(toAppInfo appinfo)
(castPtr extensionPtr)
gErrorPtr
return ())
appInfoCanRemoveSupportsType :: AppInfoClass appinfo => appinfo
-> IO Bool
appInfoCanRemoveSupportsType appinfo =
liftM toBool $
(\(AppInfo arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_app_info_can_remove_supports_type argPtr1) (toAppInfo appinfo)
appInfoRemoveSupportsType :: (AppInfoClass appinfo, GlibString string)
=> appinfo
-> string
-> IO ()
appInfoRemoveSupportsType appinfo extension =
withUTFString extension $ \ extensionPtr ->
propagateGError (\gErrorPtr -> do
(\(AppInfo arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->g_app_info_remove_supports_type argPtr1 arg2 arg3)
(toAppInfo appinfo)
(castPtr extensionPtr)
gErrorPtr
return ())
appInfoGetAll :: IO [AppInfo]
appInfoGetAll = do
glistPtr <- g_app_info_get_all
list <- fromGList glistPtr
mapM (wrapNewGObject mkAppInfo . return) list
appInfoGetAllForType ::
GlibString string
=> string
-> IO [AppInfo]
appInfoGetAllForType contentType =
withUTFString contentType $ \ contentTypePtr -> do
glistPtr <- g_app_info_get_all_for_type (castPtr contentTypePtr)
if glistPtr == nullPtr
then return []
else do
list <- fromGList glistPtr
mapM (wrapNewGObject mkAppInfo . return) list
appInfoGetDefaultForType ::
GlibString string
=> string
-> Bool
-> IO (Maybe AppInfo)
appInfoGetDefaultForType contentType mustSupportUris =
maybeNull (wrapNewGObject mkAppInfo) $
withUTFString contentType $ \ contentTypePtr -> do
g_app_info_get_default_for_type
(castPtr contentTypePtr)
(fromBool mustSupportUris)
appInfoGetDefaultForUriScheme ::
GlibString string
=> string
-> IO (Maybe AppInfo)
appInfoGetDefaultForUriScheme uriScheme =
maybeNull (wrapNewGObject mkAppInfo) $
withUTFString uriScheme $ \ uriSchemePtr ->
g_app_info_get_default_for_uri_scheme (castPtr uriSchemePtr)
appInfoLaunchDefaultForUri ::
GlibString string
=> string
-> AppLaunchContext
-> IO ()
appInfoLaunchDefaultForUri uri launchContext =
withUTFString uri $ \ uriPtr ->
propagateGError (\gErrorPtr -> do
(\arg1 (AppLaunchContext arg2) arg3 -> withForeignPtr arg2 $ \argPtr2 ->g_app_info_launch_default_for_uri arg1 argPtr2 arg3)
(castPtr uriPtr)
launchContext
gErrorPtr
return ())
appLaunchContextGetDisplay :: (AppInfoClass appinfo, GlibString string)
=> AppLaunchContext
-> appinfo
-> [File]
-> IO string
appLaunchContextGetDisplay launchContext appinfo files =
withForeignPtrs (map unFile files) $ \wFilePtr ->
withGList wFilePtr $ \filesPtr ->
(\(AppLaunchContext arg1) (AppInfo arg2) arg3 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->g_app_launch_context_get_display argPtr1 argPtr2 arg3)
(toAppLaunchContext launchContext)
(toAppInfo appinfo)
filesPtr
>>= readUTFString
appLaunchContextGetStartupNotifyId :: (AppInfoClass appinfo, GlibString string)
=> AppLaunchContext
-> appinfo
-> [File]
-> IO (Maybe string)
appLaunchContextGetStartupNotifyId launchContext appinfo files =
withForeignPtrs (map unFile files) $ \wFilePtr ->
withGList wFilePtr $ \filesPtr ->
(\(AppLaunchContext arg1) (AppInfo arg2) arg3 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->g_app_launch_context_get_startup_notify_id argPtr1 argPtr2 arg3)
(toAppLaunchContext launchContext)
(toAppInfo appinfo)
filesPtr
>>= maybePeek readUTFString
appLaunchContextLaunchFailed :: GlibString string
=> AppLaunchContext
-> string
-> IO ()
appLaunchContextLaunchFailed launchContext startupNotifyId =
withUTFString startupNotifyId $ \ startupNotifyIdPtr ->
(\(AppLaunchContext arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->g_app_launch_context_launch_failed argPtr1 arg2)
(toAppLaunchContext launchContext)
(castPtr startupNotifyIdPtr)
appLaunchContextNew :: IO AppLaunchContext
appLaunchContextNew =
wrapNewGObject mkAppLaunchContext $
g_app_launch_context_new
foreign import ccall safe "g_app_info_create_from_commandline"
g_app_info_create_from_commandline :: ((Ptr CChar) -> ((Ptr CChar) -> (CInt -> ((Ptr (Ptr ())) -> (IO (Ptr AppInfo))))))
foreign import ccall safe "g_app_info_dup"
g_app_info_dup :: ((Ptr AppInfo) -> (IO (Ptr AppInfo)))
foreign import ccall safe "g_app_info_equal"
g_app_info_equal :: ((Ptr AppInfo) -> ((Ptr AppInfo) -> (IO CInt)))
foreign import ccall safe "g_app_info_get_id"
g_app_info_get_id :: ((Ptr AppInfo) -> (IO (Ptr CChar)))
foreign import ccall safe "g_app_info_get_name"
g_app_info_get_name :: ((Ptr AppInfo) -> (IO (Ptr CChar)))
foreign import ccall safe "g_app_info_get_display_name"
g_app_info_get_display_name :: ((Ptr AppInfo) -> (IO (Ptr CChar)))
foreign import ccall safe "g_app_info_get_description"
g_app_info_get_description :: ((Ptr AppInfo) -> (IO (Ptr CChar)))
foreign import ccall safe "g_app_info_get_executable"
g_app_info_get_executable :: ((Ptr AppInfo) -> (IO (Ptr CChar)))
foreign import ccall safe "g_app_info_get_commandline"
g_app_info_get_commandline :: ((Ptr AppInfo) -> (IO (Ptr CChar)))
foreign import ccall unsafe "g_free"
g_free :: ((Ptr ()) -> (IO ()))
foreign import ccall safe "g_app_info_get_icon"
g_app_info_get_icon :: ((Ptr AppInfo) -> (IO (Ptr Icon)))
foreign import ccall safe "g_app_info_launch"
g_app_info_launch :: ((Ptr AppInfo) -> ((Ptr ()) -> ((Ptr AppLaunchContext) -> ((Ptr (Ptr ())) -> (IO CInt)))))
foreign import ccall safe "g_app_info_supports_files"
g_app_info_supports_files :: ((Ptr AppInfo) -> (IO CInt))
foreign import ccall safe "g_app_info_supports_uris"
g_app_info_supports_uris :: ((Ptr AppInfo) -> (IO CInt))
foreign import ccall safe "g_app_info_launch_uris"
g_app_info_launch_uris :: ((Ptr AppInfo) -> ((Ptr ()) -> ((Ptr AppLaunchContext) -> ((Ptr (Ptr ())) -> (IO CInt)))))
foreign import ccall safe "g_app_info_should_show"
g_app_info_should_show :: ((Ptr AppInfo) -> (IO CInt))
foreign import ccall safe "g_app_info_can_delete"
g_app_info_can_delete :: ((Ptr AppInfo) -> (IO CInt))
foreign import ccall safe "g_app_info_delete"
g_app_info_delete :: ((Ptr AppInfo) -> (IO CInt))
foreign import ccall safe "g_app_info_reset_type_associations"
g_app_info_reset_type_associations :: ((Ptr CChar) -> (IO ()))
foreign import ccall safe "g_app_info_set_as_default_for_type"
g_app_info_set_as_default_for_type :: ((Ptr AppInfo) -> ((Ptr CChar) -> ((Ptr (Ptr ())) -> (IO CInt))))
foreign import ccall safe "g_app_info_set_as_default_for_extension"
g_app_info_set_as_default_for_extension :: ((Ptr AppInfo) -> ((Ptr CChar) -> ((Ptr (Ptr ())) -> (IO CInt))))
foreign import ccall safe "g_app_info_add_supports_type"
g_app_info_add_supports_type :: ((Ptr AppInfo) -> ((Ptr CChar) -> ((Ptr (Ptr ())) -> (IO CInt))))
foreign import ccall safe "g_app_info_can_remove_supports_type"
g_app_info_can_remove_supports_type :: ((Ptr AppInfo) -> (IO CInt))
foreign import ccall safe "g_app_info_remove_supports_type"
g_app_info_remove_supports_type :: ((Ptr AppInfo) -> ((Ptr CChar) -> ((Ptr (Ptr ())) -> (IO CInt))))
foreign import ccall safe "g_app_info_get_all"
g_app_info_get_all :: (IO (Ptr ()))
foreign import ccall safe "g_app_info_get_all_for_type"
g_app_info_get_all_for_type :: ((Ptr CChar) -> (IO (Ptr ())))
foreign import ccall safe "g_app_info_get_default_for_type"
g_app_info_get_default_for_type :: ((Ptr CChar) -> (CInt -> (IO (Ptr AppInfo))))
foreign import ccall safe "g_app_info_get_default_for_uri_scheme"
g_app_info_get_default_for_uri_scheme :: ((Ptr CChar) -> (IO (Ptr AppInfo)))
foreign import ccall safe "g_app_info_launch_default_for_uri"
g_app_info_launch_default_for_uri :: ((Ptr CChar) -> ((Ptr AppLaunchContext) -> ((Ptr (Ptr ())) -> (IO CInt))))
foreign import ccall safe "g_app_launch_context_get_display"
g_app_launch_context_get_display :: ((Ptr AppLaunchContext) -> ((Ptr AppInfo) -> ((Ptr ()) -> (IO (Ptr CChar)))))
foreign import ccall safe "g_app_launch_context_get_startup_notify_id"
g_app_launch_context_get_startup_notify_id :: ((Ptr AppLaunchContext) -> ((Ptr AppInfo) -> ((Ptr ()) -> (IO (Ptr CChar)))))
foreign import ccall safe "g_app_launch_context_launch_failed"
g_app_launch_context_launch_failed :: ((Ptr AppLaunchContext) -> ((Ptr CChar) -> (IO ())))
foreign import ccall safe "g_app_launch_context_new"
g_app_launch_context_new :: (IO (Ptr AppLaunchContext))