gi-gio-2.0.18: Gio bindings

CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria (garetxe@gmail.com)
Safe HaskellNone
LanguageHaskell2010

GI.Gio.Interfaces.AppInfo

Contents

Description

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

Exported types

newtype AppInfo Source #

Memory-managed wrapper type.

Constructors

AppInfo (ManagedPtr AppInfo) 
Instances
GObject AppInfo Source # 
Instance details

Defined in GI.Gio.Interfaces.AppInfo

IsObject AppInfo Source # 
Instance details

Defined in GI.Gio.Interfaces.AppInfo

IsAppInfo AppInfo Source # 
Instance details

Defined in GI.Gio.Interfaces.AppInfo

noAppInfo :: Maybe AppInfo Source #

A convenience alias for Nothing :: Maybe AppInfo.

class GObject o => IsAppInfo o Source #

Type class for types which can be safely cast to AppInfo, for instance with toAppInfo.

Instances
(GObject a, (UnknownAncestorError AppInfo a :: Constraint)) => IsAppInfo a Source # 
Instance details

Defined in GI.Gio.Interfaces.AppInfo

IsAppInfo AppInfo Source # 
Instance details

Defined in GI.Gio.Interfaces.AppInfo

IsAppInfo DesktopAppInfo Source # 
Instance details

Defined in GI.Gio.Objects.DesktopAppInfo

toAppInfo :: (MonadIO m, IsAppInfo o) => o -> m AppInfo Source #

Cast to AppInfo, for types for which this is known to be safe. For general casts, use castTo.

Methods

addSupportsType

appInfoAddSupportsType Source #

Arguments

:: (HasCallStack, MonadIO m, IsAppInfo a) 
=> a

appinfo: a AppInfo.

-> Text

contentType: a string.

-> m ()

(Can throw GError)

Adds a content type to the application information to indicate the application is capable of opening files with the given content type.

canDelete

appInfoCanDelete Source #

Arguments

:: (HasCallStack, MonadIO m, IsAppInfo a) 
=> a

appinfo: a AppInfo

-> m Bool

Returns: True if appinfo can be deleted

Obtains the information whether the AppInfo can be deleted. See appInfoDelete.

Since: 2.20

canRemoveSupportsType

appInfoCanRemoveSupportsType Source #

Arguments

:: (HasCallStack, MonadIO m, IsAppInfo a) 
=> a

appinfo: a AppInfo.

-> m Bool

Returns: True if it is possible to remove supported content types from a given appinfo, False if not.

Checks if a supported content type can be removed from an application.

createFromCommandline

appInfoCreateFromCommandline Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> [Char]

commandline: the commandline to use

-> Maybe Text

applicationName: the application name, or Nothing to use commandline

-> [AppInfoCreateFlags]

flags: flags that can specify details of the created AppInfo

-> m AppInfo

Returns: new AppInfo for given command. (Can throw GError)

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

appInfoDelete Source #

Arguments

:: (HasCallStack, MonadIO m, IsAppInfo a) 
=> a

appinfo: a AppInfo

-> m Bool

Returns: True if appinfo has been deleted

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

appInfoDup Source #

Arguments

:: (HasCallStack, MonadIO m, IsAppInfo a) 
=> a

appinfo: a AppInfo.

-> m AppInfo

Returns: a duplicate of appinfo.

Creates a duplicate of a AppInfo.

equal

appInfoEqual Source #

Arguments

:: (HasCallStack, MonadIO m, IsAppInfo a, IsAppInfo b) 
=> a

appinfo1: the first AppInfo.

-> b

appinfo2: the second AppInfo.

-> m Bool

Returns: True if appinfo1 is equal to appinfo2. False otherwise.

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

appInfoGetAll Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m [AppInfo]

Returns: a newly allocated List of references to GAppInfos.

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

appInfoGetAllForType Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Text

contentType: the content type to find a AppInfo for

-> m [AppInfo]

Returns: List of GAppInfos for given contentType or Nothing on error.

Gets a list of all GAppInfos for a given content type, including the recommended and fallback GAppInfos. See appInfoGetRecommendedForType and appInfoGetFallbackForType.

getCommandline

appInfoGetCommandline Source #

Arguments

:: (HasCallStack, MonadIO m, IsAppInfo a) 
=> a

appinfo: a AppInfo

-> m [Char]

Returns: a string containing the appinfo's commandline, or Nothing if this information is not available

Gets the commandline with which the application will be started.

Since: 2.20

getDefaultForType

appInfoGetDefaultForType Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Text

contentType: the content type to find a AppInfo for

-> Bool

mustSupportUris: if True, the AppInfo is expected to support URIs

-> m AppInfo

Returns: AppInfo for given contentType or Nothing on error.

Gets the default AppInfo for a given content type.

getDefaultForUriScheme

appInfoGetDefaultForUriScheme Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Text

uriScheme: a string containing a URI scheme.

-> m AppInfo

Returns: AppInfo for given uriScheme or Nothing on error.

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 #

Arguments

:: (HasCallStack, MonadIO m, IsAppInfo a) 
=> a

appinfo: a AppInfo.

-> m Text

Returns: a string containing a description of the application appinfo, or Nothing if none.

Gets a human-readable description of an installed application.

getDisplayName

appInfoGetDisplayName Source #

Arguments

:: (HasCallStack, MonadIO m, IsAppInfo a) 
=> a

appinfo: a AppInfo.

-> m Text

Returns: the display name of the application for appinfo, or the name if no display name is available.

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

appInfoGetExecutable Source #

Arguments

:: (HasCallStack, MonadIO m, IsAppInfo a) 
=> a

appinfo: a AppInfo

-> m [Char]

Returns: a string containing the appinfo's application binaries name

Gets the executable's name for the installed application.

getFallbackForType

appInfoGetFallbackForType Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Text

contentType: the content type to find a AppInfo for

-> m [AppInfo]

Returns: List of GAppInfos for given contentType or Nothing on error.

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

appInfoGetIcon Source #

Arguments

:: (HasCallStack, MonadIO m, IsAppInfo a) 
=> a

appinfo: a AppInfo.

-> m Icon

Returns: the default Icon for appinfo or Nothing if there is no default icon.

Gets the icon for the application.

getId

appInfoGetId Source #

Arguments

:: (HasCallStack, MonadIO m, IsAppInfo a) 
=> a

appinfo: a AppInfo.

-> 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

appInfoGetName Source #

Arguments

:: (HasCallStack, MonadIO m, IsAppInfo a) 
=> a

appinfo: a AppInfo.

-> m Text

Returns: the name of the application for appinfo.

Gets the installed name of the application.

getRecommendedForType

appInfoGetRecommendedForType Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Text

contentType: the content type to find a AppInfo for

-> m [AppInfo]

Returns: List of GAppInfos for given contentType or Nothing on error.

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 #

Arguments

:: (HasCallStack, MonadIO m, IsAppInfo a) 
=> a

appinfo: a AppInfo that can handle files

-> 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

appInfoLaunch Source #

Arguments

:: (HasCallStack, MonadIO m, IsAppInfo a, IsFile b, IsAppLaunchContext c) 
=> a

appinfo: a AppInfo

-> [b]

files: a List of File objects

-> Maybe c

context: a AppLaunchContext or Nothing

-> m ()

(Can throw GError)

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 #

Arguments

:: (HasCallStack, MonadIO m, IsAppLaunchContext a) 
=> Text

uri: the uri to show

-> Maybe a

context: an optional AppLaunchContext

-> m ()

(Can throw GError)

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 #

Arguments

:: (HasCallStack, MonadIO m, IsAppLaunchContext a, IsCancellable b) 
=> Text

uri: the uri to show

-> Maybe a

context: an optional AppLaunchContext

-> Maybe b

cancellable: a Cancellable

-> Maybe AsyncReadyCallback

callback: a GASyncReadyCallback to call when the request is done

-> 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 #

Arguments

:: (HasCallStack, MonadIO m, IsAsyncResult a) 
=> a

result: a AsyncResult

-> m ()

(Can throw GError)

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

Since: 2.50

launchUris

appInfoLaunchUris Source #

Arguments

:: (HasCallStack, MonadIO m, IsAppInfo a, IsAppLaunchContext b) 
=> a

appinfo: a AppInfo

-> [Text]

uris: a List containing URIs to launch.

-> Maybe b

context: a AppLaunchContext or Nothing

-> m ()

(Can throw GError)

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 #

Arguments

:: (HasCallStack, MonadIO m, IsAppInfo a) 
=> a

appinfo: a AppInfo.

-> Text

contentType: a string.

-> m ()

(Can throw GError)

Removes a supported type from an application, if possible.

resetTypeAssociations

appInfoResetTypeAssociations Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Text

contentType: a content type

-> m () 

Removes all changes to the type associations done by appInfoSetAsDefaultForType, appInfoSetAsDefaultForExtension, appInfoAddSupportsType or appInfoRemoveSupportsType.

Since: 2.20

setAsDefaultForExtension

appInfoSetAsDefaultForExtension Source #

Arguments

:: (HasCallStack, MonadIO m, IsAppInfo a) 
=> a

appinfo: a AppInfo.

-> [Char]

extension: a string containing the file extension (without the dot).

-> m ()

(Can throw GError)

Sets the application as the default handler for the given file extension.

setAsDefaultForType

appInfoSetAsDefaultForType Source #

Arguments

:: (HasCallStack, MonadIO m, IsAppInfo a) 
=> a

appinfo: a AppInfo.

-> Text

contentType: the content type.

-> m ()

(Can throw GError)

Sets the application as the default handler for a given type.

setAsLastUsedForType

appInfoSetAsLastUsedForType Source #

Arguments

:: (HasCallStack, MonadIO m, IsAppInfo a) 
=> a

appinfo: a AppInfo.

-> Text

contentType: the content type.

-> m ()

(Can throw GError)

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

appInfoShouldShow Source #

Arguments

:: (HasCallStack, MonadIO m, IsAppInfo a) 
=> a

appinfo: a AppInfo.

-> m Bool

Returns: True if the appinfo should be shown, False otherwise.

Checks if the application info should be shown in menus that list available applications.

supportsFiles

appInfoSupportsFiles Source #

Arguments

:: (HasCallStack, MonadIO m, IsAppInfo a) 
=> a

appinfo: a AppInfo.

-> m Bool

Returns: True if the appinfo supports files.

Checks if the application accepts files as arguments.

supportsUris

appInfoSupportsUris Source #

Arguments

:: (HasCallStack, MonadIO m, IsAppInfo a) 
=> a

appinfo: a AppInfo.

-> m Bool

Returns: True if the appinfo supports URIs.

Checks if the application supports reading files and directories from URIs.