style(ui): fix formatting
This commit is contained in:
parent
a8a5ef16a2
commit
638863170c
|
@ -235,7 +235,7 @@ impl From<RawUIEvent> for Option<UIEvent> {
|
|||
UI_EVENT_TYPE_CONTEXT_MENU_CLICK => {
|
||||
return Some(UIEvent::ContextMenuClick(raw.context_menu_id));
|
||||
}
|
||||
UI_EVENT_TYPE_HEARTBEAT => {
|
||||
UI_EVENT_TYPE_HEARTBEAT => {
|
||||
return Some(UIEvent::Heartbeat);
|
||||
}
|
||||
_ => {}
|
||||
|
|
|
@ -58,26 +58,28 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_context_menu_serializes_correctly() {
|
||||
let menu = Menu { items: vec![
|
||||
MenuItem::Simple(SimpleMenuItem {
|
||||
id: 0,
|
||||
label: "Open".to_string()
|
||||
}),
|
||||
MenuItem::Separator,
|
||||
MenuItem::Sub(SubMenuItem {
|
||||
label: "Sub".to_string(),
|
||||
items: vec![
|
||||
MenuItem::Simple(SimpleMenuItem {
|
||||
label: "Sub 1".to_string(),
|
||||
id: 1,
|
||||
}),
|
||||
MenuItem::Simple(SimpleMenuItem {
|
||||
label: "Sub 2".to_string(),
|
||||
id: 2,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
]};
|
||||
let menu = Menu {
|
||||
items: vec![
|
||||
MenuItem::Simple(SimpleMenuItem {
|
||||
id: 0,
|
||||
label: "Open".to_string(),
|
||||
}),
|
||||
MenuItem::Separator,
|
||||
MenuItem::Sub(SubMenuItem {
|
||||
label: "Sub".to_string(),
|
||||
items: vec![
|
||||
MenuItem::Simple(SimpleMenuItem {
|
||||
label: "Sub 1".to_string(),
|
||||
id: 1,
|
||||
}),
|
||||
MenuItem::Simple(SimpleMenuItem {
|
||||
label: "Sub 2".to_string(),
|
||||
id: 2,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
};
|
||||
|
||||
assert_eq!(
|
||||
menu.to_json().unwrap(),
|
||||
|
|
|
@ -17,14 +17,20 @@
|
|||
* along with espanso. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use std::{path::{PathBuf}, sync::{Arc, Mutex, mpsc::{Sender, channel}}};
|
||||
use std::{
|
||||
path::PathBuf,
|
||||
sync::{
|
||||
mpsc::{channel, Sender},
|
||||
Arc, Mutex,
|
||||
},
|
||||
};
|
||||
|
||||
use anyhow::{Result, anyhow, bail};
|
||||
use anyhow::{anyhow, bail, Result};
|
||||
use lazy_static::lazy_static;
|
||||
use log::{error, warn};
|
||||
use std::os::windows::process::CommandExt;
|
||||
use std::process::Command;
|
||||
use winrt_notification::{IconCrop, Toast};
|
||||
use std::os::windows::process::CommandExt;
|
||||
|
||||
const ESPANSO_APP_USER_MODEL_ID: &str = "{5E3B6C0F-1A4D-45C4-8872-D8174702101A}";
|
||||
|
||||
|
@ -36,7 +42,9 @@ pub fn initialize_notification_thread(notification_icon_path: PathBuf) -> Result
|
|||
let (sender, receiver) = channel::<String>();
|
||||
|
||||
{
|
||||
let mut lock = SEND_CHANNEL.lock().map_err(|e| anyhow!("failed to define shared notification sender: {}", e))?;
|
||||
let mut lock = SEND_CHANNEL
|
||||
.lock()
|
||||
.map_err(|e| anyhow!("failed to define shared notification sender: {}", e))?;
|
||||
*lock = Some(sender);
|
||||
}
|
||||
|
||||
|
@ -68,12 +76,14 @@ pub fn initialize_notification_thread(notification_icon_path: PathBuf) -> Result
|
|||
}
|
||||
|
||||
pub fn show_notification(msg: &str) -> Result<()> {
|
||||
let mut lock = SEND_CHANNEL.lock().map_err(|e| anyhow!("unable to acquire notification send channel: {}", e))?;
|
||||
let mut lock = SEND_CHANNEL
|
||||
.lock()
|
||||
.map_err(|e| anyhow!("unable to acquire notification send channel: {}", e))?;
|
||||
match &mut *lock {
|
||||
Some(sender) => {
|
||||
sender.send(msg.to_string())?;
|
||||
Ok(())
|
||||
},
|
||||
}
|
||||
None => bail!("notification sender not available"),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user