Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: AppInfo

[40:7] extends: object

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 [method@Gio.File.get_path]) when using [method@Gio.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 [iface@Gio.File] constructors (since GVfs implements the GVfs extension point). As such, if the application needs to examine the URI, it needs to use [method@Gio.File.get_uri] or similar on [iface@Gio.File]. In other words, an application cannot assume that the URI passed to e.g. [func@Gio.File.new_for_commandline_arg] is equal to the result of [method@Gio.File.get_uri]. The following snippet illustrates this: c 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.

Members

  • handleObj
  • lib
  • retainedCallbacks
  • signalHandlerNames
  • signalSetterHandlers

Methods

  • AppInfo (Handle = null)

    Creates a new AppInfo by wrapping a native handle or another wrapper.

    • @p Handle is the native handle or another wrapper whose handle to adopt.
  • toNativeHandle (Source)

    Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from fn.call(...), another generated wrapper exposing handle(), or null. Returns null when the argument carries no pointer.

    • @p Source is the raw handle, raw buffer, wrapper, or null.
    • @r A raw pointer carrier or null when no pointer is present.
  • getLib ()

    Returns the opened native library for this generated wrapper.

    • @r The opened native library.
  • handle ()

    Returns the wrapped NativeHandle.

    • @r The wrapped NativeHandle.
  • isNull ()

    Returns true when the wrapped handle is null.

    • @r A bool.
  • describe ()

    Returns a small string for debugging generated wrappers.

    • @r A string.
  • add_supports_type (string content_type)

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

    • @p content_type is a string..
  • can_delete ()

    Obtains the information whether the [iface@Gio.AppInfo] can be deleted. See [method@Gio.AppInfo.delete].

  • can_remove_supports_type ()

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

  • delete ()

    Tries to delete a [iface@Gio.AppInfo]. On some platforms, there may be a difference between user-defined [iface@Gio.AppInfo]s which can be deleted, and system-wide ones which cannot. See [method@Gio.AppInfo.can_delete].

  • dup ()

    Creates a duplicate of a [iface@Gio.AppInfo].

  • equal (object appinfo2)

    Checks if two [iface@Gio.AppInfo]s are equal. Note that the check may not 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.

    • @p appinfo2 is the second [iface@Gio.AppInfo]..
  • get_commandline ()

    Gets the commandline with which the application will be started.

  • get_description ()

    Gets a human-readable description of an installed application.

  • get_display_name ()

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

  • get_executable ()

    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 [method@Gio.AppInfo.launch] and related functions, rather than spawning the return value from this function.

  • get_icon ()

    Gets the icon for the application.

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

  • get_name ()

    Gets the installed name of the application.

  • get_supported_types ()

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

  • launch (object files, object context)

    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 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 [method@Gio.AppInfo.launch_uris] instead. The launched application inherits the environment of the launching process, but it can be modified with [method@Gio.AppLaunchContext.setenv] and [method@Gio.AppLaunchContext.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, XDG_ACTIVATION_TOKEN and DESKTOP_STARTUP_ID environment variables are also set, based on information provided in

    • @context. ``
    • @p files is a list of [iface@Gio.File] objects.
    • @p context is the launch context.
  • launch_uris (object uris, object context)

    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. If the application only supports one URI per invocation as part of their command-line, multiple instances of the application will be spawned. 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.
    • @p uris is a list of URIs to launch..
    • @p context is the launch context.
  • launch_uris_finish (object result)

    Finishes a [method@Gio.AppInfo.launch_uris_async] operation.

    • @p result is the async result.
  • remove_supports_type (string content_type)

    Removes a supported type from an application, if possible.

    • @p content_type is a string..
  • set_as_default_for_extension (string extension)

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

    • @p extension is a string containing the file extension (without the dot)..
  • set_as_default_for_type (string content_type)

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

    • @p content_type is the content type..
  • set_as_last_used_for_type (string content_type)

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

    • @p content_type is the content type..
  • should_show ()

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

  • supports_files ()

    Checks if the application accepts files as arguments.

  • supports_uris ()

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