Move get_icon_path into own impl
This commit is contained in:
parent
f577504e39
commit
d28d4a9479
|
@ -30,8 +30,7 @@ use winrt_notification::{Duration, IconCrop, Sound, Toast};
|
||||||
|
|
||||||
pub struct WindowsUIManager;
|
pub struct WindowsUIManager;
|
||||||
|
|
||||||
impl super::UIManager for WindowsUIManager {
|
impl WindowsUIManager {
|
||||||
fn notify(&self, message: &str) {
|
|
||||||
fn get_icon_path() -> io::Result<Box<Path>> {
|
fn get_icon_path() -> io::Result<Box<Path>> {
|
||||||
let path_buf = std::env::current_exe()?.parent().unwrap().to_path_buf();
|
let path_buf = std::env::current_exe()?.parent().unwrap().to_path_buf();
|
||||||
let installed_ico = path_buf.join("icon.ico");
|
let installed_ico = path_buf.join("icon.ico");
|
||||||
|
@ -53,15 +52,18 @@ impl super::UIManager for WindowsUIManager {
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl super::UIManager for WindowsUIManager {
|
||||||
|
fn notify(&self, message: &str) {
|
||||||
// Create and show a window notification
|
// Create and show a window notification
|
||||||
let mut toast: Toast = Toast::new(Toast::POWERSHELL_APP_ID) // TODO: Use an ID assigned during installation.
|
let mut toast: Toast = Toast::new(Toast::POWERSHELL_APP_ID) // TODO: Use an ID assigned during installation.
|
||||||
.title("Espanso")
|
.title("Espanso")
|
||||||
.text1(message)
|
.text1(message)
|
||||||
.duration(Duration::Short);
|
.duration(Duration::Short);
|
||||||
|
|
||||||
if let Ok(p) = get_icon_path() {
|
if let Ok(ref p) = Self::get_icon_path() {
|
||||||
toast = toast.icon(&p, IconCrop::Circular, "espanso");
|
toast = toast.icon(p, IconCrop::Circular, "espanso");
|
||||||
}
|
}
|
||||||
|
|
||||||
toast.show().expect("Unable to toast");
|
toast.show().expect("Unable to toast");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user