Skip to content
This repository was archived by the owner on Dec 30, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/api/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ impl GtkSystrayApp {
let mut ai = self.ai.borrow_mut();
ai.set_icon_full(file, "icon");
}

pub fn set_icon_from_name(&self, name: &str) {
let mut ai = self.ai.borrow_mut();
ai.set_icon(name);
}
}

pub struct Window {
Expand Down Expand Up @@ -161,6 +166,14 @@ impl Window {
Ok(())
}

pub fn set_icon_from_name(&self, name: &str) -> Result<(), Error> {
let n = name.to_owned().clone();
run_on_gtk_thread(move |stash: &GtkSystrayApp| {
stash.set_icon_from_name(&n);
});
Ok(())
}

pub fn set_icon_from_resource(&self, resource: &str) -> Result<(), Error> {
panic!("Not implemented on this platform!");
}
Expand Down
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ impl Application {
self.window.set_icon_from_file(file)
}

#[cfg(target_os = "linux")]
pub fn set_icon_from_name(&self, name: &str) -> Result<(), Error> {
self.window.set_icon_from_name(name)
}

pub fn set_icon_from_resource(&self, resource: &str) -> Result<(), Error> {
self.window.set_icon_from_resource(resource)
}
Expand Down