feat(core): progress in the launcher implementation
This commit is contained in:
parent
da67a46e2b
commit
2cfb1be487
|
@ -27,14 +27,10 @@ use espanso_ipc::IPCClient;
|
|||
use espanso_path::Paths;
|
||||
use log::{error, info, warn};
|
||||
|
||||
use crate::{
|
||||
exit_code::{
|
||||
use crate::{VERSION, exit_code::{
|
||||
DAEMON_ALREADY_RUNNING, DAEMON_GENERAL_ERROR, DAEMON_LEGACY_ALREADY_RUNNING, DAEMON_SUCCESS,
|
||||
WORKER_EXIT_ALL_PROCESSES, WORKER_RESTART, WORKER_SUCCESS,
|
||||
},
|
||||
ipc::{create_ipc_client_to_worker, IPCEvent},
|
||||
lock::{acquire_daemon_lock, acquire_legacy_lock, acquire_worker_lock},
|
||||
};
|
||||
}, ipc::{create_ipc_client_to_worker, IPCEvent}, lock::{acquire_daemon_lock, acquire_legacy_lock, acquire_worker_lock}};
|
||||
|
||||
use super::{CliModule, CliModuleArgs};
|
||||
|
||||
|
@ -54,8 +50,6 @@ pub fn new() -> CliModule {
|
|||
}
|
||||
}
|
||||
|
||||
const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
|
||||
fn daemon_main(args: CliModuleArgs) -> i32 {
|
||||
let paths = args.paths.expect("missing paths in daemon main");
|
||||
let config_store = args
|
||||
|
|
|
@ -17,8 +17,12 @@
|
|||
* along with espanso. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use espanso_modulo::wizard::{WizardHandlers, WizardOptions};
|
||||
|
||||
use super::{CliModule, CliModuleArgs};
|
||||
|
||||
mod util;
|
||||
|
||||
// TODO: test also with modulo feature disabled
|
||||
|
||||
pub fn new() -> CliModule {
|
||||
|
@ -38,7 +42,37 @@ fn launcher_main(args: CliModuleArgs) -> i32 {
|
|||
let cli_args = args.cli_args.expect("missing cli_args in launcher main");
|
||||
let icon_paths = crate::icon::load_icon_paths(&paths.runtime).expect("unable to load icon paths");
|
||||
|
||||
espanso_modulo::wizard::show();
|
||||
// TODO: should move wizard to "init" subcommand?
|
||||
|
||||
let is_legacy_version_page_enabled = util::is_legacy_version_running(&paths.runtime);
|
||||
let runtime_dir_clone = paths.runtime.clone();
|
||||
let is_legacy_version_running_handler = Box::new(move || {
|
||||
util::is_legacy_version_running(&runtime_dir_clone)
|
||||
});
|
||||
|
||||
espanso_modulo::wizard::show(WizardOptions {
|
||||
version: crate::VERSION.to_string(),
|
||||
is_welcome_page_enabled: true, // TODO
|
||||
is_move_bundle_page_enabled: false, // TODO
|
||||
is_legacy_version_page_enabled,
|
||||
is_migrate_page_enabled: true, // TODO,
|
||||
is_add_path_page_enabled: true, // TODO
|
||||
is_accessibility_page_enabled: true, // TODO
|
||||
window_icon_path: icon_paths
|
||||
.wizard_icon
|
||||
.map(|path| path.to_string_lossy().to_string()),
|
||||
accessibility_image_1_path: None,
|
||||
accessibility_image_2_path: None,
|
||||
handlers: WizardHandlers {
|
||||
is_legacy_version_running: Some(is_legacy_version_running_handler),
|
||||
backup_and_migrate: None,
|
||||
add_to_path: None,
|
||||
enable_accessibility: None,
|
||||
is_accessibility_enabled: None,
|
||||
},
|
||||
});
|
||||
|
||||
// TODO: enable "Add to PATH" page only when NOT in portable mode
|
||||
|
||||
0
|
||||
}
|
||||
|
|
31
espanso/src/cli/launcher/util.rs
Normal file
31
espanso/src/cli/launcher/util.rs
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* This file is part of espanso.
|
||||
*
|
||||
* Copyright (C) 2019-2021 Federico Terzi
|
||||
*
|
||||
* espanso is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* espanso is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with espanso. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use crate::lock::acquire_legacy_lock;
|
||||
|
||||
pub fn is_legacy_version_running(runtime_path: &Path) -> bool {
|
||||
let legacy_lock_file = acquire_legacy_lock(runtime_path);
|
||||
if legacy_lock_file.is_none() {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
|
@ -42,6 +42,7 @@ const MAC_SYSTEM_DISABLED_BINARY: &[u8] = include_bytes!("res/macos/iconsystemdi
|
|||
pub struct IconPaths {
|
||||
pub form_icon: Option<PathBuf>,
|
||||
pub search_icon: Option<PathBuf>,
|
||||
pub wizard_icon: Option<PathBuf>,
|
||||
|
||||
pub tray_icon_normal: Option<PathBuf>,
|
||||
pub tray_icon_disabled: Option<PathBuf>,
|
||||
|
@ -55,6 +56,7 @@ pub fn load_icon_paths(runtime_dir: &Path) -> Result<IconPaths> {
|
|||
Ok(IconPaths {
|
||||
form_icon: Some(extract_icon(WINDOWS_LOGO_ICO_BINARY, &runtime_dir.join("form.ico"))?),
|
||||
search_icon: Some(extract_icon(ICON_BINARY, &runtime_dir.join("search.png"))?),
|
||||
wizard_icon: Some(extract_icon(WINDOWS_LOGO_ICO_BINARY, &runtime_dir.join("wizard.ico"))?),
|
||||
tray_icon_normal: Some(extract_icon(WINDOWS_NORMAL_DARK_ICO_BINARY, &runtime_dir.join("normal.ico"))?),
|
||||
tray_icon_disabled: Some(extract_icon(WINDOWS_DISABLED_DARK_ICO_BINARY, &runtime_dir.join("disabled.ico"))?),
|
||||
logo: Some(extract_icon(ICON_BINARY, &runtime_dir.join("icon.png"))?),
|
||||
|
|
BIN
espanso/src/res/accessibility_1.png
Normal file
BIN
espanso/src/res/accessibility_1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
BIN
espanso/src/res/accessibility_2.png
Normal file
BIN
espanso/src/res/accessibility_2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 62 KiB |
Loading…
Reference in New Issue
Block a user