Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria (garetxe@gmail.com) |
Safe Haskell | None |
Language | Haskell2010 |
- Exported types
- Methods
- addSupportsType
- canDelete
- canRemoveSupportsType
- createFromCommandline
- delete
- dup
- equal
- getAll
- getAllForType
- getCommandline
- getDefaultForType
- getDefaultForUriScheme
- getDescription
- getDisplayName
- getExecutable
- getFallbackForType
- getIcon
- getId
- getName
- getRecommendedForType
- getSupportedTypes
- launch
- launchDefaultForUri
- launchDefaultForUriAsync
- launchDefaultForUriFinish
- launchUris
- removeSupportsType
- resetTypeAssociations
- setAsDefaultForExtension
- setAsDefaultForType
- setAsLastUsedForType
- shouldShow
- supportsFiles
- supportsUris
AppInfo
and 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 fileGetPath
) when using 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 File
constructors (since gvfs
implements the Vfs
extension point). As such, if the application
needs to examine the URI, it needs to use fileGetUri
or
similar on File
. In other words, an application cannot assume
that the URI passed to e.g. fileNewForCommandlineArg
is
equal to the result of 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.
Synopsis
- newtype AppInfo = AppInfo (ManagedPtr AppInfo)
- noAppInfo :: Maybe AppInfo
- class GObject o => IsAppInfo o
- toAppInfo :: (MonadIO m, IsAppInfo o) => o -> m AppInfo
- appInfoAddSupportsType :: (HasCallStack, MonadIO m, IsAppInfo a) => a -> Text -> m ()
- appInfoCanDelete :: (HasCallStack, MonadIO m, IsAppInfo a) => a -> m Bool
- appInfoCanRemoveSupportsType :: (HasCallStack, MonadIO m, IsAppInfo a) => a -> m Bool
- appInfoCreateFromCommandline :: (HasCallStack, MonadIO m) => [Char] -> Maybe Text -> [AppInfoCreateFlags] -> m AppInfo
- appInfoDelete :: (HasCallStack, MonadIO m, IsAppInfo a) => a -> m Bool
- appInfoDup :: (HasCallStack, MonadIO m, IsAppInfo a) => a -> m AppInfo
- appInfoEqual :: (HasCallStack, MonadIO m, IsAppInfo a, IsAppInfo b) => a -> b -> m Bool
- appInfoGetAll :: (HasCallStack, MonadIO m) => m [AppInfo]
- appInfoGetAllForType :: (HasCallStack, MonadIO m) => Text -> m [AppInfo]
- appInfoGetCommandline :: (HasCallStack, MonadIO m, IsAppInfo a) => a -> m [Char]
- appInfoGetDefaultForType :: (HasCallStack, MonadIO m) => Text -> Bool -> m AppInfo
- appInfoGetDefaultForUriScheme :: (HasCallStack, MonadIO m) => Text -> m AppInfo
- appInfoGetDescription :: (HasCallStack, MonadIO m, IsAppInfo a) => a -> m Text
- appInfoGetDisplayName :: (HasCallStack, MonadIO m, IsAppInfo a) => a -> m Text
- appInfoGetExecutable :: (HasCallStack, MonadIO m, IsAppInfo a) => a -> m [Char]
- appInfoGetFallbackForType :: (HasCallStack, MonadIO m) => Text -> m [AppInfo]
- appInfoGetIcon :: (HasCallStack, MonadIO m, IsAppInfo a) => a -> m Icon
- appInfoGetId :: (HasCallStack, MonadIO m, IsAppInfo a) => a -> m Text
- appInfoGetName :: (HasCallStack, MonadIO m, IsAppInfo a) => a -> m Text
- appInfoGetRecommendedForType :: (HasCallStack, MonadIO m) => Text -> m [AppInfo]
- appInfoGetSupportedTypes :: (HasCallStack, MonadIO m, IsAppInfo a) => a -> m [Text]
- appInfoLaunch :: (HasCallStack, MonadIO m, IsAppInfo a, IsFile b, IsAppLaunchContext c) => a -> [b] -> Maybe c -> m ()
- appInfoLaunchDefaultForUri :: (HasCallStack, MonadIO m, IsAppLaunchContext a) => Text -> Maybe a -> m ()
- appInfoLaunchDefaultForUriAsync :: (HasCallStack, MonadIO m, IsAppLaunchContext a, IsCancellable b) => Text -> Maybe a -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- appInfoLaunchDefaultForUriFinish :: (HasCallStack, MonadIO m, IsAsyncResult a) => a -> m ()
- appInfoLaunchUris :: (HasCallStack, MonadIO m, IsAppInfo a, IsAppLaunchContext b) => a -> [Text] -> Maybe b -> m ()
- appInfoRemoveSupportsType :: (HasCallStack, MonadIO m, IsAppInfo a) => a -> Text -> m ()
- appInfoResetTypeAssociations :: (HasCallStack, MonadIO m) => Text -> m ()
- appInfoSetAsDefaultForExtension :: (HasCallStack, MonadIO m, IsAppInfo a) => a -> [Char] -> m ()
- appInfoSetAsDefaultForType :: (HasCallStack, MonadIO m, IsAppInfo a) => a -> Text -> m ()
- appInfoSetAsLastUsedForType :: (HasCallStack, MonadIO m, IsAppInfo a) => a -> Text -> m ()
- appInfoShouldShow :: (HasCallStack, MonadIO m, IsAppInfo a) => a -> m Bool
- appInfoSupportsFiles :: (HasCallStack, MonadIO m, IsAppInfo a) => a -> m Bool
- appInfoSupportsUris :: (HasCallStack, MonadIO m, IsAppInfo a) => a -> m Bool
Exported types
Memory-managed wrapper type.
Instances
GObject AppInfo Source # | |
Defined in GI.Gio.Interfaces.AppInfo gobjectType :: AppInfo -> IO GType # | |
IsObject AppInfo Source # | |
Defined in GI.Gio.Interfaces.AppInfo | |
IsAppInfo AppInfo Source # | |
Defined in GI.Gio.Interfaces.AppInfo |
class GObject o => IsAppInfo o Source #
Instances
(GObject a, (UnknownAncestorError AppInfo a :: Constraint)) => IsAppInfo a Source # | |
Defined in GI.Gio.Interfaces.AppInfo | |
IsAppInfo AppInfo Source # | |
Defined in GI.Gio.Interfaces.AppInfo | |
IsAppInfo DesktopAppInfo Source # | |
Defined in GI.Gio.Objects.DesktopAppInfo |
Methods
addSupportsType
appInfoAddSupportsType Source #
:: (HasCallStack, MonadIO m, IsAppInfo a) | |
=> a |
|
-> Text |
|
-> m () | (Can throw |
Adds a content type to the application information to indicate the application is capable of opening files with the given content type.
canDelete
:: (HasCallStack, MonadIO m, IsAppInfo a) | |
=> a |
|
-> m Bool | Returns: |
Obtains the information whether the AppInfo
can be deleted.
See appInfoDelete
.
Since: 2.20
canRemoveSupportsType
appInfoCanRemoveSupportsType Source #
:: (HasCallStack, MonadIO m, IsAppInfo a) | |
=> a |
|
-> m Bool | Returns: |
Checks if a supported content type can be removed from an application.
createFromCommandline
appInfoCreateFromCommandline Source #
:: (HasCallStack, MonadIO m) | |
=> [Char] |
|
-> Maybe Text |
|
-> [AppInfoCreateFlags] |
|
-> m AppInfo |
Creates a new AppInfo
from the given information.
Note that for commandline
, the quoting rules of the Exec key of the
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.
delete
:: (HasCallStack, MonadIO m, IsAppInfo a) | |
=> a |
|
-> m Bool | Returns: |
Tries to delete a AppInfo
.
On some platforms, there may be a difference between user-defined
GAppInfos
which can be deleted, and system-wide ones which cannot.
See appInfoCanDelete
.
Since: 2.20
dup
:: (HasCallStack, MonadIO m, IsAppInfo a) | |
=> a |
|
-> m AppInfo | Returns: a duplicate of |
Creates a duplicate of a AppInfo
.
equal
:: (HasCallStack, MonadIO m, IsAppInfo a, IsAppInfo b) | |
=> a |
|
-> b |
|
-> m Bool | Returns: |
Checks if two GAppInfos
are equal.
Note that the check <emphasis>may not</emphasis> compare each individual field, and only does an identity check. In case detecting changes in the contents is needed, program code must additionally compare relevant fields.
getAll
:: (HasCallStack, MonadIO m) | |
=> m [AppInfo] | Returns: a newly allocated |
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 appInfoShouldShow
.
The returned list does not include applications which have
the Hidden
key set.
getAllForType
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m [AppInfo] | Returns: |
Gets a list of all GAppInfos
for a given content type,
including the recommended and fallback GAppInfos
. See
appInfoGetRecommendedForType
and
appInfoGetFallbackForType
.
getCommandline
appInfoGetCommandline Source #
:: (HasCallStack, MonadIO m, IsAppInfo a) | |
=> a |
|
-> m [Char] | Returns: a string containing the |
Gets the commandline with which the application will be started.
Since: 2.20
getDefaultForType
appInfoGetDefaultForType Source #
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> Bool |
|
-> m AppInfo |
Gets the default AppInfo
for a given content type.
getDefaultForUriScheme
appInfoGetDefaultForUriScheme Source #
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m 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".
getDescription
appInfoGetDescription Source #
:: (HasCallStack, MonadIO m, IsAppInfo a) | |
=> a |
|
-> m Text | Returns: a string containing a description of the
application |
Gets a human-readable description of an installed application.
getDisplayName
appInfoGetDisplayName Source #
:: (HasCallStack, MonadIO m, IsAppInfo a) | |
=> a |
|
-> m Text | Returns: the display name of the application for |
Gets the display name of the application. The display name is often more descriptive to the user than the name itself.
Since: 2.24
getExecutable
:: (HasCallStack, MonadIO m, IsAppInfo a) | |
=> a |
|
-> m [Char] | Returns: a string containing the |
Gets the executable's name for the installed application.
getFallbackForType
appInfoGetFallbackForType Source #
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m [AppInfo] | Returns: |
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
getIcon
:: (HasCallStack, MonadIO m, IsAppInfo a) | |
=> a |
|
-> m Icon | Returns: the default |
Gets the icon for the application.
getId
:: (HasCallStack, MonadIO m, IsAppInfo a) | |
=> a |
|
-> m Text | Returns: a string containing the application's ID. |
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.
getName
:: (HasCallStack, MonadIO m, IsAppInfo a) | |
=> a |
|
-> m Text | Returns: the name of the application for |
Gets the installed name of the application.
getRecommendedForType
appInfoGetRecommendedForType Source #
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m [AppInfo] | Returns: |
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 appInfoSetAsLastUsedForType
has been
called.
Since: 2.28
getSupportedTypes
appInfoGetSupportedTypes Source #
:: (HasCallStack, MonadIO m, IsAppInfo a) | |
=> a |
|
-> m [Text] | Returns: a list of content types. |
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
appInfoAddSupportsType
, but only those exported directly by
the application.
Since: 2.34
launch
:: (HasCallStack, MonadIO m, IsAppInfo a, IsFile b, IsAppLaunchContext c) | |
=> a |
|
-> [b] | |
-> Maybe c |
|
-> m () | (Can throw |
Launches the application. Passes files
to the launched application
as arguments, using the optional context
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
appInfoLaunchUris
instead.
The launched application inherits the environment of the launching
process, but it can be modified with appLaunchContextSetenv
and 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 context
.
launchDefaultForUri
appInfoLaunchDefaultForUri Source #
:: (HasCallStack, MonadIO m, IsAppLaunchContext a) | |
=> Text |
|
-> Maybe a |
|
-> m () | (Can throw |
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.
launchDefaultForUriAsync
appInfoLaunchDefaultForUriAsync Source #
:: (HasCallStack, MonadIO m, IsAppLaunchContext a, IsCancellable b) | |
=> Text |
|
-> Maybe a |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> m () |
Async version of 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
launchDefaultForUriFinish
appInfoLaunchDefaultForUriFinish Source #
:: (HasCallStack, MonadIO m, IsAsyncResult a) | |
=> a |
|
-> m () | (Can throw |
Finishes an asynchronous launch-default-for-uri operation.
Since: 2.50
launchUris
:: (HasCallStack, MonadIO m, IsAppInfo a, IsAppLaunchContext b) | |
=> a |
|
-> [Text] |
|
-> Maybe b |
|
-> m () | (Can throw |
Launches the application. This passes the uris
to the launched application
as arguments, using the optional context
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.
removeSupportsType
appInfoRemoveSupportsType Source #
:: (HasCallStack, MonadIO m, IsAppInfo a) | |
=> a |
|
-> Text |
|
-> m () | (Can throw |
Removes a supported type from an application, if possible.
resetTypeAssociations
appInfoResetTypeAssociations Source #
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m () |
Removes all changes to the type associations done by
appInfoSetAsDefaultForType
,
appInfoSetAsDefaultForExtension
,
appInfoAddSupportsType
or
appInfoRemoveSupportsType
.
Since: 2.20
setAsDefaultForExtension
appInfoSetAsDefaultForExtension Source #
:: (HasCallStack, MonadIO m, IsAppInfo a) | |
=> a |
|
-> [Char] |
|
-> m () | (Can throw |
Sets the application as the default handler for the given file extension.
setAsDefaultForType
appInfoSetAsDefaultForType Source #
:: (HasCallStack, MonadIO m, IsAppInfo a) | |
=> a |
|
-> Text |
|
-> m () | (Can throw |
Sets the application as the default handler for a given type.
setAsLastUsedForType
appInfoSetAsLastUsedForType Source #
:: (HasCallStack, MonadIO m, IsAppInfo a) | |
=> a |
|
-> Text |
|
-> m () | (Can throw |
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 appInfoGetRecommendedForType
, regardless of the default
application for that content type.
shouldShow
:: (HasCallStack, MonadIO m, IsAppInfo a) | |
=> a |
|
-> m Bool | Returns: |
Checks if the application info should be shown in menus that list available applications.
supportsFiles
:: (HasCallStack, MonadIO m, IsAppInfo a) | |
=> a |
|
-> m Bool | Returns: |
Checks if the application accepts files as arguments.