#[repr(transparent)]
pub struct DesktopAppInfo { /* private fields */ }
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().

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

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

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

Available 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

Available 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

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

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

Available on non-Windows and non-macOS only.

Gets the generic name from the desktop file.

Returns

The value of the GenericName key

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

Available on non-Windows and non-macOS only.

Gets the keywords from the desktop file.

Returns

The value of the Keywords key

Available 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

Available 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

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

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

Available 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

Available 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().

Available 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

Available 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

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

Available 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

Available 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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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

Returns the type of the object.

Returns the ObjectClass of the object. Read more

Returns the class of the object.

Returns the class of the object in the given type T. Read more

Returns the interface T of the object. Read more

Similar to Self::set_property but fails instead of panicking.

Sets the property property_name of the object to value value. Read more

Similar to Self::set_property but fails instead of panicking.

Sets the property property_name of the object to value value. Read more

Similar to Self::set_properties but fails instead of panicking.

Sets multiple properties of the object at once. Read more

Similar to Self::set_properties_from_value but fails instead of panicking.

Sets multiple properties of the object at once. Read more

Similar to Self::property but fails instead of panicking.

Gets the property property_name of the object and cast it to the type V. Read more

Similar to Self::property_value but fails instead of panicking.

Gets the property property_name of the object. Read more

Check if the object has a property property_name of the given type_. Read more

Get the type of the property property_name of this object. Read more

Get the ParamSpec of the property property_name of this object.

Return all ParamSpec of the properties of this object.

Freeze all property notifications until the return guard object is dropped. Read more

Set arbitrary data on this object with the given key. Read more

Return previously set arbitrary data of this object with the given key. Read more

Retrieve previously set arbitrary data of this object with the given key. Read more

Set arbitrary data on this object with the given key. Read more

Return previously set arbitrary data of this object with the given key. Read more

Retrieve previously set arbitrary data of this object with the given key. Read more

Block a given signal handler. Read more

Unblock a given signal handler.

Stop emission of the currently emitted signal.

Stop emission of the currently emitted signal by the (possibly detailed) signal name.

Similar to Self::connect but fails instead of panicking.

Connect to the signal signal_name on this object. Read more

Similar to Self::connect_id but fails instead of panicking.

Connect to the signal signal_id on this object. Read more

Similar to Self::connect_local but fails instead of panicking.

Connect to the signal signal_name on this object. Read more

Similar to Self::connect_local_id but fails instead of panicking.

Connect to the signal signal_id on this object. Read more

Similar to Self::connect_unsafe but fails instead of panicking.

Connect to the signal signal_name on this object. Read more

Similar to Self::connect_unsafe_id but fails instead of panicking.

Similar to Self::connect_closure but fails instead of panicking.

Connect a closure to the signal signal_name on this object. Read more

Similar to Self::connect_closure_id but fails instead of panicking.

Connect a closure to the signal signal_id on this object. Read more

Limits the lifetime of closure to the lifetime of the object. When the object’s reference count drops to zero, the closure will be invalidated. An invalidated closure will ignore any calls to Closure::invoke. Read more

Connect to the signal signal_id on this object. Read more

Similar to Self::emit but fails instead of panicking.

Emit signal by signal id. Read more

Similar to Self::emit_with_values but fails instead of panicking.

Same as Self::emit but takes Value for the arguments.

Similar to Self::emit_by_name but fails instead of panicking.

Emit signal by its name. Read more

Similar to Self::emit_by_name_with_values but fails instead of panicking.

Emit signal by its name. Read more

Similar to Self::emit_by_name_with_details but fails instead of panicking.

Emit signal by its name with details. Read more

Similar to Self::emit_by_name_with_details_and_values but fails instead of panicking.

Emit signal by its name with details. Read more

Similar to Self::emit_with_details but fails instead of panicking.

Emit signal by signal id with details. Read more

Similar to Self::emit_with_details_and_values but fails instead of panicking.

Emit signal by signal id with details. Read more

Disconnect a previously connected signal handler.

Connect to the notify signal of the object. Read more

Connect to the notify signal of the object. Read more

Connect to the notify signal of the object. Read more

Notify that the given property has changed its value. Read more

Notify that the given property has changed its value. Read more

Downgrade this object to a weak reference.

Bind property source_property on this object to the target_property on the target object. Read more

Returns the strong reference count of this object.

Ensures that the type has been registered with the type system.

The resulting type after obtaining ownership.

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

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

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.