Struct gio::DesktopAppInfo[][src]

pub struct DesktopAppInfo(_);
Expand description

DesktopAppInfo is an implementation of 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 when using it.

Implements

glib::ObjectExt, AppInfoExt, AppInfoExtManual

Implementations

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 new() (for example, checking that the executable referenced by a result exists), and so it is possible for new() to return None when passed an app ID returned by this function. It is expected that calling code will do this when subsequently creating a DesktopAppInfo for each result.

search_string

the search string to use

Returns

a list of strvs. Free each item with g_strfreev() and free the outer list with g_free().

This is supported on non-Windows and non-macOS only.

Creates a new 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).

desktop_id

the desktop file id

Returns

a new DesktopAppInfo, or None if no desktop file with that id exists.

This is supported on non-Windows and non-macOS only.

Creates a new DesktopAppInfo.

filename

the path of a desktop file, in the GLib filename encoding

Returns

a new DesktopAppInfo or None on error.

This is supported on non-Windows and non-macOS only.

Creates a new DesktopAppInfo.

key_file

an opened glib::KeyFile

Returns

a new DesktopAppInfo or None on error.

This is supported on non-Windows and non-macOS only.

Gets the user-visible display name of the “additional application action” specified by action_name.

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

action_name

the name of the action as from list_actions()

Returns

the locale-specific action name

This is supported on non-Windows and non-macOS only.

Looks up a boolean value in the keyfile backing self.

The key is looked up in the “Desktop Entry” group.

key

the key to look up

Returns

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

This is supported on non-Windows and non-macOS only.

Gets the categories from the desktop file.

Returns

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

This is supported on non-Windows and non-macOS only.

When self was created from a known filename, return it. In some situations such as the DesktopAppInfo returned from from_keyfile(), this function will return None.

Returns

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

This is supported on non-Windows and non-macOS only.

Gets the generic name from the desktop file.

Returns

The value of the GenericName key

This is supported on non-Windows and non-macOS only.

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

Returns

true if hidden, false otherwise.

This is supported on non-Windows and non-macOS only.

Gets the keywords from the desktop file.

Returns

The value of the Keywords key

This is supported on non-Windows and non-macOS and crate feature v2_56 only.

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.

key

the key to look up

Returns

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

This is supported on non-Windows and non-macOS only.

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 AppInfoExt::should_show().

Returns

The value of the NoDisplay key

This is supported on non-Windows and non-macOS only.

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 None, 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 AppInfoExt::should_show() for self will include this check (with None for desktop_env) as well as additional checks.

desktop_env

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.

This is supported on non-Windows and non-macOS only.

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

Returns

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

This is supported on non-Windows and non-macOS only.

Looks up a string value in the keyfile backing self.

The key is looked up in the “Desktop Entry” group.

key

the key to look up

Returns

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

This is supported on non-Windows and non-macOS and crate feature v2_60 only.

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

The key is looked up in the “Desktop Entry” group.

key

the key to look up

Returns

a None-terminated string array or None if the specified key cannot be found. The array should be freed with g_strfreev().

This is supported on non-Windows and non-macOS only.

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

key

the key to look up

Returns

true if the key exists

This is supported on non-Windows and non-macOS only.

Activates the named application action.

You may only call this function on action names that were returned from list_actions().

Note that if the main entry of the desktop file indicates that the application supports startup notification, and launch_context is non-None, 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 AppInfoExt::launch() there is no way to detect failures that occur while using this function.

action_name

the name of the action as from list_actions()

launch_context

a AppLaunchContext

This is supported on non-Windows and non-macOS only.

This function performs the equivalent of AppInfoExt::launch_uris(), but is intended primarily for operating system components that launch applications. Ordinary applications should use AppInfoExt::launch_uris().

If the application is launched via GSpawn, then spawn_flags, user_setup and user_setup_data are used for the call to g_spawn_async(). Additionally, pid_callback (with pid_callback_data) will be called to inform about the PID of the created process. See g_spawn_async_with_pipes() for information on certain parameter conditions that can enable an optimized posix_spawn() codepath to be used.

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

uris

List of URIs

launch_context

a AppLaunchContext

spawn_flags

glib::SpawnFlags, used for each process

user_setup

a GSpawnChildSetupFunc, used once for each process.

user_setup_data

User data for user_setup

pid_callback

Callback for child processes

pid_callback_data

User data for callback

Returns

true on successful launch, false otherwise.

This is supported on non-Windows and non-macOS only.

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.

Returns

a list of strings, always non-None

This is supported on non-Windows and non-macOS only.

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.

interface

the name of the interface

Returns

a list of DesktopAppInfo objects.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Returns the type identifier of Self.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Upcasts an object to a superclass or interface T. Read more

Upcasts an object to a reference of its superclass or interface T. Read more

Tries to downcast to a subclass or interface implementor T. Read more

Tries to downcast to a reference of its subclass or interface implementor T. Read more

Tries to cast to an object of type T. This handles upcasting, downcasting and casting between interface and interface implementors. All checks are performed at runtime, while downcast and upcast will do many checks at compile-time already. Read more

Tries to cast to reference to an object of type T. This handles upcasting, downcasting and casting between interface and interface implementors. All checks are performed at runtime, while downcast and upcast will do many checks at compile-time already. Read more

Casts to T unconditionally. Read more

Casts to &T unconditionally. Read more

Performs the conversion.

Performs the conversion.

Returns true if the object is an instance of (can be cast to) T.

Safety Read more

Safety Read more

Safety Read more

Safety Read more

Safety Read more

Safety Read more

Same as connect but takes a SignalId instead of a signal name.

Same as connect_local but takes a SignalId instead of a signal name.

Same as connect_unsafe but takes a SignalId instead of a signal name.

Emit signal by signal id.

Emit signal with details by signal id.

Emit signal by it’s name.

Same as emit but takes Value for the arguments.

Same as emit_by_name but takes Value for the arguments.

Same as emit_with_details but takes Value for the arguments.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Returns a SendValue clone of self.

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.