AppInfoT

GAppInfo and GAppLaunchContext 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 g_file_get_path()) when using g_app_info_launch() 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 GFile constructors (since gvfs implements the GVfs extension point). As such, if the application needs to examine the URI, it needs to use g_file_get_uri() or similar on GFile. In other words, an application cannot assume that the URI passed to e.g. g_file_new_for_commandline_arg() is equal to the result of g_file_get_uri(). 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; // FALSE 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.

template AppInfoT (
TStruct
) {}

Members

Functions

addOnLaunchFailed
void addOnLaunchFailed(void delegate(string, AppInfoIF) dlg, ConnectFlags connectFlags)
addOnLaunched
void addOnLaunched(void delegate(AppInfoIF, GVariant*, AppInfoIF) dlg, ConnectFlags connectFlags)
addSupportsType
int addSupportsType(string contentType)

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

canDelete
int canDelete()

Obtains the information whether the GAppInfo can be deleted. See g_app_info_delete(). Since 2.20

canRemoveSupportsType
int canRemoveSupportsType()

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

delet
int delet()

Tries to delete a GAppInfo. On some platforms, there may be a difference between user-defined GAppInfos which can be deleted, and system-wide ones which cannot. See g_app_info_can_delete(). Virtual: do_delete Since 2.20

dup
AppInfoIF dup()

Creates a duplicate of a GAppInfo.

equal
int equal(AppInfoIF appinfo2)

Checks if two GAppInfos are equal.

getAppInfoTStruct
GAppInfo* getAppInfoTStruct()
Undocumented in source. Be warned that the author may not have intended to support it.
getCommandline
string getCommandline()

Gets the commandline with which the application will be started. Since 2.20

getDescription
string getDescription()

Gets a human-readable description of an installed application.

getDisplayName
string getDisplayName()

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
string getExecutable()

Gets the executable's name for the installed application.

getIcon
IconIF getIcon()

Gets the icon for the application.

getId
string getId()

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 NULL, depending on how the appinfo has been constructed.

getName
string getName()

Gets the installed name of the application.

getSupportedTypes
string[] getSupportedTypes()

Retrieves the list of content types that app_info claims to support. If this information is not provided by the environment, this function will return NULL. This function does not take in consideration associations added with g_app_info_add_supports_type(), but only those exported directly by the application. Since 2.34

launch
int launch(ListG files, AppLaunchContext launchContext)

Launches the application. Passes files to the launched application as arguments, using the optional launch_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 NULL 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 g_app_info_launch_uris() instead. The launched application inherits the environment of the launching process, but it can be modified with g_app_launch_context_setenv() and g_app_launch_context_unsetenv(). 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 launch_context.

launchUris
int launchUris(ListG uris, AppLaunchContext launchContext)

Launches the application. This passes the uris to the launched application as arguments, using the optional launch_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 NULL 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.

onLaunchFailedListeners
void delegate(string, AppInfoIF)[] onLaunchFailedListeners()
Undocumented in source. Be warned that the author may not have intended to support it.
onLaunchedListeners
void delegate(AppInfoIF, GVariant*, AppInfoIF)[] onLaunchedListeners()
Undocumented in source. Be warned that the author may not have intended to support it.
removeSupportsType
int removeSupportsType(string contentType)

Removes a supported type from an application, if possible.

setAsDefaultForExtension
int setAsDefaultForExtension(string extension)

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

setAsDefaultForType
int setAsDefaultForType(string contentType)

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

setAsLastUsedForType
int setAsLastUsedForType(string contentType)

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 g_app_info_get_recommended_for_type(), regardless of the default application for that content type.

shouldShow
int shouldShow()

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

supportsFiles
int supportsFiles()

Checks if the application accepts files as arguments.

supportsUris
int supportsUris()

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

Static functions

callBackLaunchFailed
void callBackLaunchFailed(GAppLaunchContext* gapplaunchcontextStruct, gchar* arg1, AppInfoIF _appInfoIF)
Undocumented in source. Be warned that the author may not have intended to support it.
callBackLaunched
void callBackLaunched(GAppLaunchContext* gapplaunchcontextStruct, GAppInfo* arg1, GVariant* arg2, AppInfoIF _appInfoIF)
Undocumented in source. Be warned that the author may not have intended to support it.
createFromCommandline
AppInfoIF createFromCommandline(string commandline, string applicationName, GAppInfoCreateFlags flags)

Creates a new GAppInfo 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.

getAll
ListG getAll()

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 g_app_info_should_show(). The returned list does not include applications which have the Hidden key set.

getAllForType
ListG getAllForType(string contentType)

Gets a list of all GAppInfos for a given content type, including the recommended and fallback GAppInfos. See g_app_info_get_recommended_for_type() and g_app_info_get_fallback_for_type().

getDefaultForType
AppInfoIF getDefaultForType(string contentType, int mustSupportUris)

Gets the default GAppInfo for a given content type.

getDefaultForUriScheme
AppInfoIF getDefaultForUriScheme(string uriScheme)

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

getFallbackForType
ListG getFallbackForType(string contentType)

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

getRecommendedForType
ListG getRecommendedForType(string contentType)

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 g_app_info_set_as_last_used_for_type() has been called. Since 2.28

launchDefaultForUri
int launchDefaultForUri(string uri, AppLaunchContext launchContext)

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.

resetTypeAssociations
void resetTypeAssociations(string contentType)

Removes all changes to the type associations done by g_app_info_set_as_default_for_type(), g_app_info_set_as_default_for_extension(), g_app_info_add_supports_type() or g_app_info_remove_supports_type(). Since 2.20

Variables

_onLaunchFailedListeners
void delegate(string, AppInfoIF)[] _onLaunchFailedListeners;
Undocumented in source.
_onLaunchedListeners
void delegate(AppInfoIF, GVariant*, AppInfoIF)[] _onLaunchedListeners;
Undocumented in source.
connectedSignals
int[string] connectedSignals;
gAppInfo
GAppInfo* gAppInfo;

the main Gtk struct

Meta