Module: Gio::AppInfo

Defined in:
(unknown)

Overview

GApp::Info 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 a desktop-file based application with Exec key ‘totem %U` and a single URI, `sfoo/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; 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) ⇒ TrueClass

Returns true on success, false on error.

Parameters:

  • appinfo (Gio::AppInfo)

    a GApp::Info.

  • content_type (String)

    a string.

Returns:

  • (TrueClass)

    true on success, false on error.

#as_default_for_extension=(extension) ⇒ TrueClass

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:

  • (TrueClass)

    true on success, false on error.

#as_default_for_type=(content_type) ⇒ TrueClass

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

Parameters:

  • content_type (String)

    the content type.

Returns:

  • (TrueClass)

    true on success, false on error.

#as_last_used_for_type=(content_type) ⇒ TrueClass

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.

Parameters:

  • content_type (String)

    the content type.

Returns:

  • (TrueClass)

    true on success, false on error.

#can_delete(appinfo) ⇒ TrueClass

Returns true if appinfo can be deleted.

Parameters:

Returns:

  • (TrueClass)

    true if appinfo can be deleted

#can_remove_supports_type(appinfo) ⇒ TrueClass

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

Parameters:

Returns:

  • (TrueClass)

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

#commandlineGio::filename

Gets the commandline with which the application will be started.

Returns:

  • (Gio::filename)

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

#deleteTrueClass

Tries to delete a GApp::Info.

On some platforms, there may be a difference between user-defined GApp::Infos which can be deleted, and system-wide ones which cannot. See g_app_info_can_delete().

Returns:

  • (TrueClass)

    true if appinfo has been deleted

#descriptionString

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

Returns:

  • (String)

    a string containing a description of the

#display_nameString

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) ⇒ TrueClass

Returns true if appinfo has been deleted.

Parameters:

Returns:

  • (TrueClass)

    true if appinfo has been deleted

#dup(appinfo) ⇒ Gio::AppInfo

Returns a duplicate of appinfo.

Parameters:

Returns:

#equal(appinfo1, appinfo2) ⇒ TrueClass

Returns true if appinfo1 is equal to appinfo2. false otherwise.

Parameters:

Returns:

  • (TrueClass)

    true if appinfo1 is equal to appinfo2. false otherwise.

#executableGio::filename

Gets the executable’s name for the installed application. binaries name

Returns:

  • (Gio::filename)

    a string containing the appinfo’s application

#get_commandline(appinfo) ⇒ String

Parameters:

Returns:

  • (String)

#get_description(appinfo) ⇒ String

application appinfo, or nil 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) ⇒ String

Parameters:

Returns:

  • (String)

#get_icon(appinfo) ⇒ Gio::Icon

if there is no default icon.

Parameters:

Returns:

  • (Gio::Icon)

    the default #GIcon for appinfo or nil

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

    a GApp::Info that can handle files

Returns:

  • (Array<String>)

    a list of content types.

#iconGio::Icon

Gets the icon for the application. if there is no default icon.

Returns:

  • (Gio::Icon)

    the default #GIcon for appinfo or nil

#idString

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

Returns:

  • (String)

    a string containing the application’s ID.

#launch(appinfo, files, context) ⇒ TrueClass

Returns true on successful launch, false otherwise.

Parameters:

Returns:

  • (TrueClass)

    true on successful launch, false otherwise.

#launch_uris(appinfo, uris, context) ⇒ TrueClass

Returns true on successful launch, false otherwise.

Parameters:

Returns:

  • (TrueClass)

    true on successful launch, false otherwise.

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

Parameters:

  • appinfo (Gio::AppInfo)

    a GApp::Info

  • uris (GLib::List)

    a #GList containing URIs to launch.

  • context (Gio::AppLaunchContext)

    a GApp::LaunchContext or nil

  • cancellable (Gio::Cancellable)

    a #GCancellable

  • callback (Gio::AsyncReadyCallback)

    a GAsync::ReadyCallback to call when the request is done

  • user_data (GObject)

    data to pass to callback

Returns:

  • (nil)

#launch_uris_finish(appinfo, result) ⇒ TrueClass

Returns true on successful launch, false otherwise.

Parameters:

Returns:

  • (TrueClass)

    true on successful launch, false otherwise.

#nameString

Gets the installed name of the application.

Returns:

  • (String)

    the name of the application for appinfo.

#remove_supports_type(appinfo, content_type) ⇒ TrueClass

Returns true on success, false on error.

Parameters:

  • appinfo (Gio::AppInfo)

    a GApp::Info.

  • content_type (String)

    a string.

Returns:

  • (TrueClass)

    true on success, false on error.

#set_as_default_for_extension(appinfo, extension) ⇒ TrueClass

Returns true on success, false on error.

Parameters:

  • appinfo (Gio::AppInfo)

    a GApp::Info.

  • extension (Gio::filename)

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

Returns:

  • (TrueClass)

    true on success, false on error.

#set_as_default_for_type(appinfo, content_type) ⇒ TrueClass

Returns true on success, false on error.

Parameters:

  • appinfo (Gio::AppInfo)

    a GApp::Info.

  • content_type (String)

    the content type.

Returns:

  • (TrueClass)

    true on success, false on error.

#set_as_last_used_for_type(appinfo, content_type) ⇒ TrueClass

Returns true on success, false on error.

Parameters:

  • appinfo (Gio::AppInfo)

    a GApp::Info.

  • content_type (String)

    the content type.

Returns:

  • (TrueClass)

    true on success, false on error.

#should_show(appinfo) ⇒ TrueClass

Returns true if the appinfo should be shown, false otherwise.

Parameters:

Returns:

  • (TrueClass)

    true if the appinfo should be shown, false otherwise.

#supported_typesArray<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 nil. This function does not take in consideration associations added with g_app_info_add_supports_type(), but only those exported directly by the application.

Returns:

  • (Array<String>)

    a list of content types.

#supports_files(appinfo) ⇒ TrueClass

Returns true if the appinfo supports files.

Parameters:

Returns:

  • (TrueClass)

    true if the appinfo supports files.

#supports_uris(appinfo) ⇒ TrueClass

Returns true if the appinfo supports URIs.

Parameters:

Returns:

  • (TrueClass)

    true if the appinfo supports URIs.