GioUnix.DesktopAppInfo

g GObject.GInterface GObject.GInterface Gio.AppInfo Gio.AppInfo GObject.GInterface->Gio.AppInfo GObject.Object GObject.Object GioUnix.DesktopAppInfo GioUnix.DesktopAppInfo GObject.Object->GioUnix.DesktopAppInfo Gio.AppInfo->GioUnix.DesktopAppInfo

Subclasses:

None

Methods

Inherited:

GObject.Object (37), Gio.AppInfo (40)

Structs:

GObject.ObjectClass (5)

class

get_action_name (info, action_name)

class

get_boolean (info, key)

class

get_categories (info)

class

get_filename (info)

class

get_generic_name (info)

class

get_implementations (interface)

class

get_is_hidden (info)

class

get_keywords (info)

class

get_locale_string (info, key)

class

get_nodisplay (info)

class

get_show_in (info, desktop_env)

class

get_startup_wm_class (info)

class

get_string (info, key)

class

get_string_list (info, key)

class

has_key (info, key)

class

launch_action (info, action_name, launch_context)

class

launch_uris_as_manager (appinfo, uris, launch_context, spawn_flags, user_setup, user_setup_data, pid_callback, *pid_callback_data)

class

launch_uris_as_manager_with_fds (appinfo, uris, launch_context, spawn_flags, user_setup, user_setup_data, pid_callback, pid_callback_data, stdin_fd, stdout_fd, stderr_fd)

class

list_actions (info)

class

new (desktop_id)

class

new_from_filename (filename)

class

new_from_keyfile (key_file)

class

search (search_string)

class

set_desktop_env (desktop_env)

Virtual Methods

Inherited:

GObject.Object (7), Gio.AppInfo (25)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class GioUnix.DesktopAppInfo(**kwargs)
Bases:

GObject.Object, Gio.AppInfo

Abstract:

No

Structure:

GioUnix.DesktopAppInfoClass

GDesktopAppInfo is an implementation of [iface`Gio`.AppInfo] based on desktop files.

Note that <gio/gdesktopappinfo.h> belongs to the UNIX-specific GIO interfaces, thus you have to use the gio-unix-2.0.pc pkg-config file or the GioUnix-2.0 GIR namespace when using it.

classmethod get_action_name(info, action_name)
Parameters:
  • info (Gio.DesktopAppInfo) – a [class`Gio`.DesktopAppInfo]

  • action_name (str) – the name of the action as from [method`Gio`.DesktopAppInfo.list_actions]

Returns:

the locale-specific action name

Return type:

str

Gets the user-visible display name of the ‘additional application actions’ specified by action_name.

This corresponds to the Name key within the keyfile group for the action.

New in version 2.38.

classmethod get_boolean(info, key)
Parameters:
Returns:

the boolean value, or FALSE if the key is not found

Return type:

bool

Looks up a boolean value in the keyfile backing info.

The key is looked up in the Desktop Entry group.

New in version 2.36.

classmethod get_categories(info)
Parameters:

info (Gio.DesktopAppInfo) – a [class`Gio`.DesktopAppInfo]

Returns:

The unparsed Categories key from the desktop file; i.e. no attempt is made to split it by ; or validate it.

Return type:

str or None

Gets the categories from the desktop file.

classmethod get_filename(info)
Parameters:

info (Gio.DesktopAppInfo) – a [class`Gio`.DesktopAppInfo]

Returns:

The full path to the file for info, or NULL if not known.

Return type:

str or None

When info was created from a known filename, return it. In some situations such as a [class`Gio`.DesktopAppInfo] returned from [ctor`Gio`.DesktopAppInfo.new_from_keyfile], this function will return NULL.

New in version 2.24.

classmethod get_generic_name(info)
Parameters:

info (Gio.DesktopAppInfo) – a [class`Gio`.DesktopAppInfo]

Returns:

The value of the GenericName key

Return type:

str or None

Gets the generic name from the desktop file.

classmethod get_implementations(interface)
Parameters:

interface (str) – the name of the interface

Returns:

a list of [class`Gio`.DesktopAppInfo] objects.

Return type:

[Gio.DesktopAppInfo]

Gets all applications that implement interface.

An application implements an interface if that interface is listed in the Implements line of the desktop file of the application.

New in version 2.42.

classmethod get_is_hidden(info)
Parameters:

info (Gio.DesktopAppInfo) – a [class`Gio`.DesktopAppInfo].

Returns:

TRUE if hidden, FALSE otherwise.

Return type:

bool

A desktop file is hidden if the Hidden key in it is set to True.

classmethod get_keywords(info)
Parameters:

info (Gio.DesktopAppInfo) – a [class`Gio`.DesktopAppInfo]

Returns:

The value of the Keywords key

Return type:

[str]

Gets the keywords from the desktop file.

New in version 2.32.

classmethod get_locale_string(info, key)
Parameters:
Returns:

a newly allocated string, or NULL if the key is not found

Return type:

str or None

Looks up a localized string value in the keyfile backing info translated to the current locale.

The key is looked up in the Desktop Entry group.

New in version 2.56.

classmethod get_nodisplay(info)
Parameters:

info (Gio.DesktopAppInfo) – a [class`Gio`.DesktopAppInfo]

Returns:

The value of the NoDisplay key

Return type:

bool

Gets the value of the NoDisplay key which helps determine if the application info should be shown in menus. See G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY and [method`Gio`.AppInfo.should_show].

New in version 2.30.

classmethod get_show_in(info, desktop_env)
Parameters:
  • info (Gio.DesktopAppInfo) – a [class`Gio`.DesktopAppInfo]

  • desktop_env (str or None) – a string specifying a desktop name

Returns:

TRUE if the info should be shown in desktop_env according to the OnlyShowIn and NotShowIn keys, FALSE otherwise.

Return type:

bool

Checks if the application info should be shown in menus that list available applications for a specific name of the desktop, based on the OnlyShowIn and NotShowIn keys.

desktop_env should typically be given as NULL, in which case the XDG_CURRENT_DESKTOP environment variable is consulted. If you want to override the default mechanism then you may specify desktop_env, but this is not recommended.

Note that [method`Gio`.AppInfo.should_show] for info will include this check (with NULL for desktop_env) as well as additional checks.

New in version 2.30.

classmethod get_startup_wm_class(info)
Parameters:

info (Gio.DesktopAppInfo) – a [class`Gio`.DesktopAppInfo] that supports startup notify

Returns:

the startup WM class, or NULL if none is set in the desktop file.

Return type:

str or None

Retrieves the StartupWMClass field from info. This represents the WM_CLASS property of the main window of the application, if launched through info.

New in version 2.34.

classmethod get_string(info, key)
Parameters:
Returns:

a newly allocated string, or NULL if the key is not found

Return type:

str or None

Looks up a string value in the keyfile backing info.

The key is looked up in the Desktop Entry group.

New in version 2.36.

classmethod get_string_list(info, key)
Parameters:
Returns:

a NULL-terminated string array or NULL if the specified key cannot be found. The array should be freed with [func`GLib`.strfreev].

Return type:

[str]

Looks up a string list value in the keyfile backing info.

The key is looked up in the Desktop Entry group.

New in version 2.60.

classmethod has_key(info, key)
Parameters:
Returns:

TRUE if the key exists

Return type:

bool

Returns whether key exists in the Desktop Entry group of the keyfile backing info.

New in version 2.36.

classmethod launch_action(info, action_name, launch_context)
Parameters:
  • info (Gio.DesktopAppInfo) – a [class`Gio`.DesktopAppInfo]

  • action_name (str) – the name of the action as from [method`Gio`.DesktopAppInfo.list_actions]

  • launch_context (Gio.AppLaunchContext or None) – a [class`Gio`.AppLaunchContext]

Activates the named application action.

You may only call this function on action names that were returned from [method`Gio`.DesktopAppInfo.list_actions].

Note that if the main entry of the desktop file indicates that the application supports startup notification, and launch_context is non-NULL, then startup notification will be used when activating the action (and as such, invocation of the action on the receiving side must signal the end of startup notification when it is completed). This is the expected behaviour of applications declaring additional actions, as per the desktop file specification.

As with [method`Gio`.AppInfo.launch] there is no way to detect failures that occur while using this function.

New in version 2.38.

classmethod launch_uris_as_manager(appinfo, uris, launch_context, spawn_flags, user_setup, user_setup_data, pid_callback, *pid_callback_data)
Parameters:
Raises:

GLib.Error

Returns:

TRUE on successful launch, FALSE otherwise.

Return type:

bool

This function performs the equivalent of [method`Gio`.AppInfo.launch_uris], but is intended primarily for operating system components that launch applications. Ordinary applications should use [method`Gio`.AppInfo.launch_uris].

If the application is launched via GSpawn, then spawn_flags, user_setup and user_setup_data are used for the call to [func`GLib`.spawn_async]. Additionally, pid_callback (with pid_callback_data) will be called to inform about the PID of the created process. See [func`GLib`.spawn_async_with_pipes] for information on certain parameter conditions that can enable an optimized posix_spawn()) code path to be used.

If application launching occurs via some other mechanism (for example, D-Bus activation) then spawn_flags, user_setup, user_setup_data, pid_callback and pid_callback_data are ignored.

classmethod launch_uris_as_manager_with_fds(appinfo, uris, launch_context, spawn_flags, user_setup, user_setup_data, pid_callback, pid_callback_data, stdin_fd, stdout_fd, stderr_fd)
Parameters:
  • appinfo (Gio.DesktopAppInfo) – a [class`Gio`.DesktopAppInfo]

  • uris ([str]) – List of URIs

  • launch_context (Gio.AppLaunchContext or None) – a [class`Gio`.AppLaunchContext]

  • spawn_flags (GLib.SpawnFlags) – [flags`GLib`.SpawnFlags], used for each process

  • user_setup (GLib.SpawnChildSetupFunc or None) – a [callback`GLib`.SpawnChildSetupFunc], used once for each process.

  • user_setup_data (object or None) – User data for user_setup

  • pid_callback (Gio.DesktopAppLaunchCallback or None) – Callback for child processes

  • pid_callback_data (object or None) – User data for callback

  • stdin_fd (int) – file descriptor to use for child’s stdin, or -1

  • stdout_fd (int) – file descriptor to use for child’s stdout, or -1

  • stderr_fd (int) – file descriptor to use for child’s stderr, or -1

Raises:

GLib.Error

Returns:

TRUE on successful launch, FALSE otherwise.

Return type:

bool

Equivalent to [method`Gio`.DesktopAppInfo.launch_uris_as_manager] but allows you to pass in file descriptors for the stdin, stdout and stderr streams of the launched process.

If application launching occurs via some non-spawn mechanism (e.g. D-Bus activation) then stdin_fd, stdout_fd and stderr_fd are ignored.

New in version 2.58.

classmethod list_actions(info)
Parameters:

info (Gio.DesktopAppInfo) – a [class`Gio`.DesktopAppInfo]

Returns:

a list of strings, always non-NULL

Return type:

[str]

Returns the list of ‘additional application actions’ supported on the desktop file, as per the desktop file specification.

As per the specification, this is the list of actions that are explicitly listed in the Actions key of the Desktop Entry group.

New in version 2.38.

classmethod new(desktop_id)
Parameters:

desktop_id (str) – the desktop file ID

Returns:

a new [class`Gio`.DesktopAppInfo], or NULL if no desktop file with that ID exists.

Return type:

Gio.DesktopAppInfo or None

Creates a new [class`Gio`.DesktopAppInfo] based on a desktop file ID.

A desktop file ID is the basename of the desktop file, including the .desktop extension. GIO is looking for a desktop file with this name in the applications subdirectories of the XDG data directories (i.e. the directories specified in the XDG_DATA_HOME and XDG_DATA_DIRS environment variables). GIO also supports the prefix-to-subdirectory mapping that is described in the Menu Spec (i.e. a desktop ID of kde-foo.desktop will match /usr/share/applications/kde/foo.desktop).

classmethod new_from_filename(filename)
Parameters:

filename (str) – the path of a desktop file, in the GLib filename encoding

Returns:

a new [class`Gio`.DesktopAppInfo] or NULL on error.

Return type:

Gio.DesktopAppInfo or None

Creates a new [class`Gio`.DesktopAppInfo].

classmethod new_from_keyfile(key_file)
Parameters:

key_file (GLib.KeyFile) – an opened [type`GLib`.KeyFile]

Returns:

a new [class`Gio`.DesktopAppInfo] or NULL on error.

Return type:

Gio.DesktopAppInfo or None

Creates a new [class`Gio`.DesktopAppInfo].

New in version 2.18.

classmethod search(search_string)
Parameters:

search_string (str) – the search string to use

Returns:

a list of strvs. Free each item with [func`GLib`.strfreev] and free the outer list with [func`GLib`.free].

Return type:

[[str]]

Searches desktop files for ones that match search_string.

The return value is an array of strvs. Each strv contains a list of applications that matched search_string with an equal score. The outer list is sorted by score so that the first strv contains the best-matching applications, and so on. The algorithm for determining matches is undefined and may change at any time.

None of the search results are subjected to the normal validation checks performed by [ctor`Gio`.DesktopAppInfo.new] (for example, checking that the executable referenced by a result exists), and so it is possible for [ctor`Gio`.DesktopAppInfo.new] to return NULL when passed an app ID returned by this function. It is expected that calling code will do this when subsequently creating a [class`Gio`.DesktopAppInfo] for each result.

classmethod set_desktop_env(desktop_env)
Parameters:

desktop_env (str) – a string specifying what desktop this is

Sets the name of the desktop that the application is running in.

This is used by [method`Gio`.AppInfo.should_show] and [method`Gio`.DesktopAppInfo.get_show_in] to evaluate the OnlyShowIn and NotShowIn keys.

Should be called only once; subsequent calls are ignored.

Deprecated since version 2.42: do not use this API. Since 2.42 the value of the XDG_CURRENT_DESKTOP environment variable will be used.