Skip to main content

DesktopApp

Struct DesktopApp 

Source
pub struct DesktopApp {
    pub id: String,
    pub name: String,
    pub exec: String,
    pub terminal: bool,
    pub mime_types: Vec<String>,
    pub path: PathBuf,
    pub icon: Option<String>,
}
Expand description

A program, as its desktop entry describes it.

Fields§

§id: String

The desktop file id (org.gnome.TextEditor.desktop): the entry’s path below applications, folders joined with -. mimeapps.list names programs by it.

§name: String

The program’s name in the person’s language when the entry has one.

§exec: String

The Exec line, with the key file’s escapes resolved.

§terminal: bool

Whether the program runs inside a terminal.

§mime_types: Vec<String>

The kinds the program says it opens.

§path: PathBuf

Where the desktop entry is.

§icon: Option<String>

The program’s icon name, when it has one.

Implementations§

Source§

impl DesktopApp

Source

pub fn command(&self, file: &Path) -> Option<Vec<OsString>>

The command that opens file with this program, program first: the Exec line with its field codes filled in. None when the line is empty or malformed.

No shell is involved; the file is always one argument, whatever its name holds.

Source§

impl DesktopApp

Source

pub fn can_start(&self, graphical: bool) -> bool

Whether this program can start here: a terminal program always can, a graphical one only in a graphical session (see graphical_session). A menu shows the others dimmed.

Source

pub fn launch<Msg: Send + 'static>( &self, file: &Path, graphical: bool, on_done: impl FnOnce(Launched) -> Msg + Send + 'static, ) -> Result<Command<Msg>, LaunchError>

The command that opens file with this program, delivering on_done with how it ended.

A terminal program (Terminal=true) goes through a Handoff: the application steps aside, the program owns the terminal, and the screen comes back when it ends. A graphical one goes through Open::program and starts quietly beside the application. graphical says whether there is a graphical session; without one a graphical program is refused instead of tried. The arguments are those of DesktopApp::command, so no shell is involved.

Either way the program runs in the file’s folder, as desktop file managers start it: relative paths, “Save as” and a shell opened from the program begin beside the file, not wherever the application happened to be started. A file given without a folder leaves the application’s own.

In a Harness nothing runs: the handoff or the opening is recorded, and a test reads it, folder included, from handoffs() or opens().

§Errors

LaunchError::NoGraphicalSession for a graphical program without a graphical session, LaunchError::NoCommand when the Exec line gives no command.

Trait Implementations§

Source§

impl Clone for DesktopApp

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DesktopApp

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for DesktopApp

Source§

impl PartialEq for DesktopApp

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for DesktopApp

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.