Add icon and title to modulo forms
This commit is contained in:
parent
510a886b08
commit
695c44c691
|
@ -53,6 +53,11 @@ pub fn update_icon(enabled: bool) {
|
|||
// TODO: add update icon on macOS
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
pub fn get_icon_path() -> Option<PathBuf> {
|
||||
None
|
||||
}
|
||||
|
||||
// LINUX IMPLEMENTATION
|
||||
#[cfg(target_os = "linux")]
|
||||
pub fn new(
|
||||
|
@ -68,6 +73,11 @@ pub fn update_icon(enabled: bool) {
|
|||
// No icon on Linux
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub fn get_icon_path() -> Option<PathBuf> {
|
||||
None
|
||||
}
|
||||
|
||||
// WINDOWS IMPLEMENTATION
|
||||
#[cfg(target_os = "windows")]
|
||||
pub fn new(
|
||||
|
@ -83,6 +93,11 @@ pub fn update_icon(enabled: bool) {
|
|||
windows::update_icon(enabled);
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
pub fn get_icon_path() -> Option<PathBuf> {
|
||||
Some(windows::get_icon_path(&get_data_dir()))
|
||||
}
|
||||
|
||||
// espanso directories
|
||||
|
||||
static WARING_INIT: Once = Once::new();
|
||||
|
|
|
@ -28,6 +28,7 @@ use std::sync::atomic::AtomicBool;
|
|||
use std::sync::atomic::Ordering::Acquire;
|
||||
use std::sync::mpsc::Sender;
|
||||
use std::sync::Arc;
|
||||
use std::path::{Path, PathBuf};
|
||||
use widestring::{U16CStr, U16CString};
|
||||
|
||||
const BMP_BINARY: &[u8] = include_bytes!("../res/win/espanso.bmp");
|
||||
|
@ -66,7 +67,7 @@ impl WindowsContext {
|
|||
);
|
||||
}
|
||||
|
||||
let espanso_ico_image = espanso_dir.join("espanso.ico");
|
||||
let espanso_ico_image = get_icon_path(&espanso_dir);
|
||||
if espanso_ico_image.exists() {
|
||||
info!("ICO already initialized, skipping.");
|
||||
} else {
|
||||
|
@ -141,6 +142,10 @@ impl super::Context for WindowsContext {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_icon_path(espanso_dir: &Path) -> PathBuf {
|
||||
espanso_dir.join("espanso.ico")
|
||||
}
|
||||
|
||||
// Native bridge code
|
||||
|
||||
pub fn update_icon(enabled: bool) {
|
||||
|
|
|
@ -53,12 +53,17 @@ impl super::Extension for FormExtension {
|
|||
};
|
||||
|
||||
let mut form_config = Mapping::new();
|
||||
form_config.insert(Value::from("title"), Value::from("espanso"));
|
||||
form_config.insert(Value::from("layout"), Value::from(layout));
|
||||
|
||||
if let Some(fields) = params.get(&Value::from("fields")) {
|
||||
form_config.insert(Value::from("fields"), fields.clone());
|
||||
}
|
||||
|
||||
if let Some(icon_path) = crate::context::get_icon_path() {
|
||||
form_config.insert(Value::from("icon"), Value::from(icon_path.to_string_lossy().to_string()));
|
||||
}
|
||||
|
||||
let serialized_config: String =
|
||||
serde_yaml::to_string(&form_config).expect("unable to serialize form config");
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ impl ModuloManager {
|
|||
}
|
||||
}
|
||||
Err(error) => {
|
||||
error!("error while sending body to modulo");
|
||||
error!("error while sending body to modulo: {}", error);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue
Block a user