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
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.
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.
This is supported on non-Windows and non-macOS only.
This is supported on non-Windows and non-macOS only.
This is supported on non-Windows and non-macOS and crate feature v2_56
only.
v2_56
only.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.
This is supported on non-Windows and non-macOS only.
This is supported on non-Windows and non-macOS and crate feature v2_60
only.
v2_60
only.This is supported on non-Windows and non-macOS only.
pub fn launch_action<P: IsA<AppLaunchContext>>(
&self,
action_name: &str,
launch_context: Option<&P>
)
This is supported on non-Windows and non-macOS only.
pub fn launch_action<P: IsA<AppLaunchContext>>(
&self,
action_name: &str,
launch_context: Option<&P>
)
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
pub fn launch_uris_as_manager<P: IsA<AppLaunchContext>>(
&self,
uris: &[&str],
launch_context: Option<&P>,
spawn_flags: SpawnFlags,
user_setup: Option<Box_<dyn FnOnce() + 'static>>,
pid_callback: Option<&mut dyn FnMut(&DesktopAppInfo, Pid)>
) -> Result<(), Error>
This is supported on non-Windows and non-macOS only.
pub fn launch_uris_as_manager<P: IsA<AppLaunchContext>>(
&self,
uris: &[&str],
launch_context: Option<&P>,
spawn_flags: SpawnFlags,
user_setup: Option<Box_<dyn FnOnce() + 'static>>,
pid_callback: Option<&mut dyn FnMut(&DesktopAppInfo, Pid)>
) -> Result<(), Error>
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
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
This is supported on non-Windows and non-macOS only.
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
impl<T: ObjectType> PartialEq<T> for DesktopAppInfo
This is supported on non-Windows and non-macOS only.
impl<T: ObjectType> PartialEq<T> for DesktopAppInfo
impl<T: ObjectType> PartialOrd<T> for DesktopAppInfo
This is supported on non-Windows and non-macOS only.
impl<T: ObjectType> PartialOrd<T> for DesktopAppInfo
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
Returns the type identifier of Self
.
Auto Trait Implementations
impl RefUnwindSafe for DesktopAppInfo
impl !Send for DesktopAppInfo
impl !Sync for DesktopAppInfo
impl Unpin for DesktopAppInfo
impl UnwindSafe for DesktopAppInfo
Blanket Implementations
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 true
if the object is an instance of (can be cast to) T
.
pub fn set_properties_from_value(
&self,
property_values: &[(&str, Value)]
) -> Result<(), BoolError>
pub fn set_property<'a, N, V>(
&self,
property_name: N,
value: V
) -> Result<(), BoolError> where
V: ToValue,
N: Into<&'a str>,
pub fn set_property_from_value<'a, N>(
&self,
property_name: N,
value: &Value
) -> Result<(), BoolError> where
N: Into<&'a str>,
Safety Read more
Safety Read more
Safety Read more
Safety Read more
pub fn connect_notify<F>(&self, name: Option<&str>, f: F) -> SignalHandlerId where
F: 'static + Fn(&T, &ParamSpec) + Send + Sync,
pub fn connect_notify_local<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: 'static + Fn(&T, &ParamSpec),
pub unsafe fn connect_notify_unsafe<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: Fn(&T, &ParamSpec),
pub fn has_property<'a, N>(&self, property_name: N, type_: Option<Type>) -> bool where
N: Into<&'a str>,
pub fn find_property<'a, N>(&self, property_name: N) -> Option<ParamSpec> where
N: Into<&'a str>,
pub fn connect<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: Fn(&[Value]) -> Option<Value> + Send + Sync + 'static,
N: Into<&'a str>,
Same as connect
but takes a SignalId
instead of a signal name.
pub fn connect_local<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: Fn(&[Value]) -> Option<Value> + 'static,
N: Into<&'a str>,
Same as connect_local
but takes a SignalId
instead of a signal name.
pub unsafe fn connect_unsafe<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: Fn(&[Value]) -> Option<Value>,
N: Into<&'a str>,
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.
pub fn bind_property<'a, O, N, M>(
&'a self,
source_property: N,
target: &'a O,
target_property: M
) -> BindingBuilder<'a> where
O: ObjectType,
N: Into<&'a str>,
M: Into<&'a str>,
Same as emit
but takes Value
for the arguments.
Same as emit_by_name
but takes Value
for the arguments.
Returns a SendValue
clone of self
.
impl<'a, T, C> FromValueOptional<'a> for T where
C: ValueTypeChecker<Error = ValueTypeMismatchOrNoneError>,
T: FromValue<'a, Checker = C>,