Gio.DesktopAppInfo

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

Subclasses:

None

Methods

Inherited:

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

Structs:

GObject.ObjectClass (5)

class

get_implementations (interface)

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)

get_action_name (action_name)

get_boolean (key)

get_categories ()

get_filename ()

get_generic_name ()

get_is_hidden ()

get_keywords ()

get_locale_string (key)

get_nodisplay ()

get_show_in (desktop_env)

get_startup_wm_class ()

get_string (key)

get_string_list (key)

has_key (key)

launch_action (action_name, launch_context)

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

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

list_actions ()

Virtual Methods

Inherited:

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

Properties

Name

Type

Flags

Short Description

filename

str

r/w/co

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class Gio.DesktopAppInfo(**kwargs)
Bases:

GObject.Object, Gio.AppInfo

Abstract:

No

Structure:

Gio.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_implementations(interface)[source]
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 new(desktop_id)[source]
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)[source]
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)[source]
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)[source]
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)[source]
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.

get_action_name(action_name)[source]
Parameters:

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.

get_boolean(key)[source]
Parameters:

key (str) – the key to look up

Returns:

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

Return type:

bool

Looks up a boolean value in the keyfile backing self.

The key is looked up in the Desktop Entry group.

New in version 2.36.

get_categories()[source]
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.

get_filename()[source]
Returns:

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

Return type:

str or None

When self 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.

get_generic_name()[source]
Returns:

The value of the GenericName key

Return type:

str or None

Gets the generic name from the desktop file.

get_is_hidden()[source]
Returns:

TRUE if hidden, FALSE otherwise.

Return type:

bool

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

get_keywords()[source]
Returns:

The value of the Keywords key

Return type:

[str]

Gets the keywords from the desktop file.

New in version 2.32.

get_locale_string(key)[source]
Parameters:

key (str) – the key to look up

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 self translated to the current locale.

The key is looked up in the Desktop Entry group.

New in version 2.56.

get_nodisplay()[source]
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.

get_show_in(desktop_env)[source]
Parameters:

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

Returns:

TRUE if the self 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 self will include this check (with NULL for desktop_env) as well as additional checks.

New in version 2.30.

get_startup_wm_class()[source]
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 self. This represents the WM_CLASS property of the main window of the application, if launched through self.

New in version 2.34.

get_string(key)[source]
Parameters:

key (str) – the key to look up

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

The key is looked up in the Desktop Entry group.

New in version 2.36.

get_string_list(key)[source]
Parameters:

key (str) – the key to look up

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

The key is looked up in the Desktop Entry group.

New in version 2.60.

has_key(key)[source]
Parameters:

key (str) – the key to look up

Returns:

TRUE if the key exists

Return type:

bool

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

New in version 2.36.

launch_action(action_name, launch_context)[source]
Parameters:
  • 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.

launch_uris_as_manager(uris, launch_context, spawn_flags, user_setup, user_setup_data, pid_callback, *pid_callback_data)[source]
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.

launch_uris_as_manager_with_fds(uris, launch_context, spawn_flags, user_setup, user_setup_data, pid_callback, pid_callback_data, stdin_fd, stdout_fd, stderr_fd)[source]
Parameters:
  • 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.

list_actions()[source]
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.

Property Details

Gio.DesktopAppInfo.props.filename
Name:

filename

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The origin filename of this [class`Gio`.DesktopAppInfo]