Module: Gio::AppInfo

Defined in:
(unknown)

Overview

Information about an installed application and methods to launch
it (with file arguments).

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 [methodGio.File.get_path]) when using [methodGio.AppInfo.launch]
even if the application requested an URI and not a POSIX path. For example
for a desktop-file based application with the following Exec key:

Exec=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 [ifaceGio.File] constructors (since GVfs
implements the GVfs extension point). As such, if the application
needs to examine the URI, it needs to use [methodGio.File.get_uri]
or similar on [ifaceGio.File]. In other words, an application cannot
assume that the URI passed to e.g. [funcGio.File.new_for_commandline_arg]
is equal to the result of [methodGio.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;
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.

Instance Method Summary collapse

Instance Method Details

#add_supports_type(appinfo, content_type) ⇒ Boolean

Returns TRUE on success, FALSE on error.

Parameters:

  • appinfo (Gio::AppInfo) —

    the app info

  • content_type (String) —

    a string.

Returns:

  • (Boolean) —

    TRUE on success, FALSE on error.

#as_default_for_extension=(extension) ⇒ Boolean

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

Parameters:

  • extension (Gio::filename) —

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

Returns:

  • (Boolean) —

    TRUE on success, FALSE on error.

#as_default_for_type=(content_type) ⇒ Boolean

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

Parameters:

  • content_type (String) —

    the content type.

Returns:

  • (Boolean) —

    TRUE on success, FALSE on error.

#as_last_used_for_type=(content_type) ⇒ Boolean

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
[funcGio.AppInfo.get_recommended_for_type], regardless of the default
application for that content type.

Parameters:

  • content_type (String) —

    the content type.

Returns:

  • (Boolean) —

    TRUE on success, FALSE on error.

#can_delete(appinfo) ⇒ Boolean

Returns TRUE if appinfo can be deleted.

Parameters:

Returns:

  • (Boolean) —

    TRUE if appinfo can be deleted

#can_remove_supports_type(appinfo) ⇒ Boolean

Returns TRUE if it is possible to remove supported content types from a
given appinfo, FALSE if not.

Parameters:

Returns:

  • (Boolean) —

    TRUE if it is possible to remove supported content types from a
    given appinfo, FALSE if not.

#commandline ⇒ Gio::filename

Gets the commandline with which the application will be
started.

Returns:

  • (Gio::filename) —

    a string containing the appinfo’s
    commandline, or NULL if this information is not available

#delete ⇒ Boolean

Tries to delete a [ifaceGio.AppInfo].

On some platforms, there may be a difference between user-defined
[ifaceGio.AppInfo]s which can be deleted, and system-wide ones which cannot.
See [methodGio.AppInfo.can_delete].

Returns:

  • (Boolean) —

    TRUE if appinfo has been deleted

#description ⇒ String

Gets a human-readable description of an installed application.
application appinfo, or NULL if none.

Returns:

  • (String) —

    a string containing a description of the

#display_name ⇒ String

Gets the display name of the application. The display name is often more
descriptive to the user than the name itself.
no display name is available.

Returns:

  • (String) —

    the display name of the application for appinfo, or the name if

#do_delete(appinfo) ⇒ Boolean

Returns TRUE if appinfo has been deleted.

Parameters:

Returns:

  • (Boolean) —

    TRUE if appinfo has been deleted

#dup(appinfo) ⇒ Gio::AppInfo

Returns a duplicate of appinfo.

Parameters:

Returns:

#equal(appinfo1, appinfo2) ⇒ Boolean

Returns TRUE if appinfo1 is equal to appinfo2. FALSE otherwise.

Parameters:

Returns:

  • (Boolean) —

    TRUE if appinfo1 is equal to appinfo2. FALSE otherwise.

#executable ⇒ Gio::filename

Gets the executable’s name for the installed application.

This is intended to be used for debugging or labelling what program is going
to be run. To launch the executable, use [methodGio.AppInfo.launch] and related
functions, rather than spawning the return value from this function.
binaries name

Returns:

  • (Gio::filename) —

    a string containing the appinfo’s application

#get_commandline(appinfo) ⇒ Gio::filename

Returns a string containing the appinfo’s
commandline, or NULL if this information is not available.

Parameters:

Returns:

  • (Gio::filename) —

    a string containing the appinfo’s
    commandline, or NULL if this information is not available

#get_description(appinfo) ⇒ String

application appinfo, or NULL if none.

Parameters:

Returns:

  • (String) —

    a string containing a description of the

#get_display_name(appinfo) ⇒ String

no display name is available.

Parameters:

Returns:

  • (String) —

    the display name of the application for appinfo, or the name if

#get_executable(appinfo) ⇒ Gio::filename

binaries name

Parameters:

Returns:

  • (Gio::filename) —

    a string containing the appinfo’s application

#get_icon(appinfo) ⇒ Gio::Icon

Returns the default [ifaceGio.Icon] for
appinfo or NULL if there is no default icon.

Parameters:

Returns:

  • (Gio::Icon) —

    the default [ifaceGio.Icon] for
    appinfo or NULL if there is no default icon.

#get_id(appinfo) ⇒ String

Returns a string containing the application’s ID.

Parameters:

Returns:

  • (String) —

    a string containing the application’s ID.

#get_name(appinfo) ⇒ String

Returns the name of the application for appinfo.

Parameters:

Returns:

  • (String) —

    the name of the application for appinfo.

#get_supported_types(appinfo) ⇒ Array<String>

Returns a list of content types.

Parameters:

  • appinfo (Gio::AppInfo) —

    an app info that can handle files

Returns:

  • (Array<String>) —

    a list of content types.

#icon ⇒ Gio::Icon

Gets the icon for the application.

Returns:

  • (Gio::Icon) —

    the default [ifaceGio.Icon] for
    appinfo or NULL if there is no default icon.

#id ⇒ String

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.

Returns:

  • (String) —

    a string containing the application’s ID.

#launch(appinfo, files, context) ⇒ Boolean

Returns TRUE on successful launch, FALSE otherwise.

Parameters:

Returns:

  • (Boolean) —

    TRUE on successful launch, FALSE otherwise.

#launch_uris(appinfo, uris, context) ⇒ Boolean

Returns TRUE on successful launch, FALSE otherwise.

Parameters:

Returns:

  • (Boolean) —

    TRUE on successful launch, FALSE otherwise.

#launch_uris_async(appinfo, uris, context, cancellable, callback, user_data) ⇒ nil

Parameters:

  • appinfo (Gio::AppInfo) —

    the app info

  • uris (GLib::List<String>) —

    a list of URIs to launch.

  • context (Gio::AppLaunchContext) —

    the launch context

  • cancellable (Gio::Cancellable) —

    a [classGio.Cancellable]

  • callback (Gio::AsyncReadyCallback) —

    a [typeGio.AsyncReadyCallback] to call
    when the request is done

  • user_data (GObject) —

    data to pass to callback

Returns:

  • (nil)

#launch_uris_finish(appinfo, result) ⇒ Boolean

Returns TRUE on successful launch, FALSE otherwise.

Parameters:

Returns:

  • (Boolean) —

    TRUE on successful launch, FALSE otherwise.

#name ⇒ String

Gets the installed name of the application.

Returns:

  • (String) —

    the name of the application for appinfo.

#remove_supports_type(appinfo, content_type) ⇒ Boolean

Returns TRUE on success, FALSE on error.

Parameters:

  • appinfo (Gio::AppInfo) —

    the app info

  • content_type (String) —

    a string.

Returns:

  • (Boolean) —

    TRUE on success, FALSE on error.

#set_as_default_for_extension(appinfo, extension) ⇒ Boolean

Returns TRUE on success, FALSE on error.

Parameters:

  • appinfo (Gio::AppInfo) —

    the app info

  • extension (Gio::filename) —

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

Returns:

  • (Boolean) —

    TRUE on success, FALSE on error.

#set_as_default_for_type(appinfo, content_type) ⇒ Boolean

Returns TRUE on success, FALSE on error.

Parameters:

  • appinfo (Gio::AppInfo) —

    the app info

  • content_type (String) —

    the content type.

Returns:

  • (Boolean) —

    TRUE on success, FALSE on error.

#set_as_last_used_for_type(appinfo, content_type) ⇒ Boolean

Returns TRUE on success, FALSE on error.

Parameters:

  • appinfo (Gio::AppInfo) —

    the app info

  • content_type (String) —

    the content type.

Returns:

  • (Boolean) —

    TRUE on success, FALSE on error.

#should_show(appinfo) ⇒ Boolean

Returns TRUE if the appinfo should be shown, FALSE otherwise.

Parameters:

Returns:

  • (Boolean) —

    TRUE if the appinfo should be shown, FALSE otherwise.

#supported_types ⇒ Array<String>

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
[methodGio.AppInfo.add_supports_type], but only those exported directly by
the application.

Returns:

  • (Array<String>) —

    a list of content types.

#supports_files(appinfo) ⇒ Boolean

Returns TRUE if the appinfo supports files.

Parameters:

Returns:

  • (Boolean) —

    TRUE if the appinfo supports files.

#supports_uris(appinfo) ⇒ Boolean

Returns TRUE if the appinfo supports URIs.

Parameters:

Returns:

  • (Boolean) —

    TRUE if the appinfo supports URIs.