From f80b565da91b7a011b6d30cfcb2d956565e62487 Mon Sep 17 00:00:00 2001 From: Yeastplume Date: Tue, 23 Apr 2024 13:09:52 +0100 Subject: [PATCH] Updates to new user workflow --- crates/core/src/fs/mod.rs | 6 ++- crates/core/src/node/mod.rs | 8 +--- crates/core/src/wallet/mod.rs | 7 +-- locale/de.json | 2 +- locale/en.json | 2 +- src/gui/element/wallet/setup/wallet_setup.rs | 49 ++++++++++---------- 6 files changed, 37 insertions(+), 37 deletions(-) diff --git a/crates/core/src/fs/mod.rs b/crates/core/src/fs/mod.rs index 6746926..7976a1d 100644 --- a/crates/core/src/fs/mod.rs +++ b/crates/core/src/fs/mod.rs @@ -16,6 +16,8 @@ pub use save::PersistentData; #[cfg(feature = "default")] pub use theme::{import_theme, load_user_themes}; +pub const GRINGUI_CONFIG_DIR: &str = ".grin-gui"; + pub static CONFIG_DIR: Lazy> = Lazy::new(|| { // Returns the location of the config directory. Will create if it doesn't // exist. @@ -24,7 +26,7 @@ pub static CONFIG_DIR: Lazy> = Lazy::new(|| { #[cfg(not(windows))] { let home = env::var("HOME").expect("user home directory not found."); - let config_dir = PathBuf::from(&home).join(".grin/gui"); + let config_dir = PathBuf::from(&home).join(&format!("{}/gui", GRINGUI_CONFIG_DIR)); Mutex::new(config_dir) } @@ -36,7 +38,7 @@ pub static CONFIG_DIR: Lazy> = Lazy::new(|| { #[cfg(windows)] { let config_dir = dirs_next::home_dir() - .map(|path| path.join(".grin")) + .map(|path| path.join(GRINGUI_CONFIG_DIR)) .map(|path| path.join("gui")) .expect("user home directory not found."); diff --git a/crates/core/src/node/mod.rs b/crates/core/src/node/mod.rs index 5cef49b..c6ea5f2 100644 --- a/crates/core/src/node/mod.rs +++ b/crates/core/src/node/mod.rs @@ -15,7 +15,7 @@ use std::time::Duration; use chrono::prelude::Utc; -use crate::logger; +use crate::{fs::GRINGUI_CONFIG_DIR, logger}; pub use global::ChainTypes; @@ -30,10 +30,6 @@ pub use grin_core::core::{amount_from_hr_string, amount_to_hr_string}; pub use grin_keychain::Identifier; pub use grin_servers::ServerStats; -/// TODO - this differs from the default directory in 5.x, -/// need to reconcile this with existing installs somehow -const GRIN_HOME: &str = ".grin"; - pub const GRIN_TOP_LEVEL_DIR: &str = "grin_node"; pub const GRIN_DEFAULT_DIR: &str = "default"; @@ -51,7 +47,7 @@ fn get_grin_node_default_path(chain_type: &global::ChainTypes) -> PathBuf { Some(p) => p, None => PathBuf::new(), }; - grin_path.push(GRIN_HOME); + grin_path.push(GRINGUI_CONFIG_DIR); grin_path.push(chain_type.shortname()); grin_path.push(GRIN_TOP_LEVEL_DIR); grin_path.push(GRIN_DEFAULT_DIR); diff --git a/crates/core/src/wallet/mod.rs b/crates/core/src/wallet/mod.rs index d355e35..8294055 100644 --- a/crates/core/src/wallet/mod.rs +++ b/crates/core/src/wallet/mod.rs @@ -37,6 +37,8 @@ pub use grin_wallet_libwallet::contract::proofs::InvoiceProof; use crate::error::GrinWalletInterfaceError; use crate::logger; +use crate::fs::GRINGUI_CONFIG_DIR; + use std::convert::TryFrom; /// Wallet configuration file name @@ -44,7 +46,6 @@ pub const WALLET_CONFIG_FILE_NAME: &str = "grin-wallet.toml"; const WALLET_LOG_FILE_NAME: &str = "grin-wallet.log"; -const GRIN_HOME: &str = ".grin"; /// Wallet data directory pub const GRIN_WALLET_DIR: &str = "wallet_data"; /// Wallet top level directory @@ -65,7 +66,7 @@ pub fn get_grin_wallet_default_path(chain_type: &global::ChainTypes) -> PathBuf Some(p) => p, None => PathBuf::new(), }; - grin_path.push(GRIN_HOME); + grin_path.push(GRINGUI_CONFIG_DIR); grin_path.push(chain_type.shortname()); grin_path.push(GRIN_WALLET_TOP_LEVEL_DIR); grin_path.push(GRIN_WALLET_DEFAULT_DIR); @@ -79,7 +80,7 @@ pub fn create_grin_wallet_path(chain_type: &global::ChainTypes, sub_dir: &str) - Some(p) => p, None => PathBuf::new(), }; - grin_path.push(GRIN_HOME); + grin_path.push(GRINGUI_CONFIG_DIR); grin_path.push(chain_type.shortname()); grin_path.push(GRIN_WALLET_TOP_LEVEL_DIR); grin_path.push(sub_dir); diff --git a/locale/de.json b/locale/de.json index 1839d76..43f37f3 100644 --- a/locale/de.json +++ b/locale/de.json @@ -224,7 +224,7 @@ "info-awaiting-confirmation": "Awaiting Confirmation", "info-awaiting-finalization": "Awaiting Finalization", "info-locked": "Locked", - "wallet-default-name": "Default", + "wallet-default-name": "My Grin Wallet", "wallet-create-tx": "Start", "wallet-apply-tx": "Continue", "wallet-create-contract": "Create Contract", diff --git a/locale/en.json b/locale/en.json index 102987e..e064cd7 100644 --- a/locale/en.json +++ b/locale/en.json @@ -208,7 +208,7 @@ "status-line-title-main": "Status Mainnet", "status-line-title-test": "Status Testnet", "wallet-list": "Wallets", - "wallet-default-name": "Default", + "wallet-default-name": "My Grin Wallet", "yes": "Yes", "no": "No", "cancel": "Cancel", diff --git a/src/gui/element/wallet/setup/wallet_setup.rs b/src/gui/element/wallet/setup/wallet_setup.rs index 2b4e4de..278bbdd 100644 --- a/src/gui/element/wallet/setup/wallet_setup.rs +++ b/src/gui/element/wallet/setup/wallet_setup.rs @@ -6,6 +6,7 @@ use std::path::PathBuf; use { super::super::super::{ BUTTON_HEIGHT, BUTTON_WIDTH, DEFAULT_FONT_SIZE, DEFAULT_HEADER_FONT_SIZE, DEFAULT_PADDING, + DEFAULT_SUB_HEADER_FONT_SIZE, }, crate::gui::{GrinGui, Interaction, Message}, crate::localization::localized_string, @@ -297,6 +298,24 @@ pub fn data_container<'a>( DEFAULT_PADDING as u16, // bottom 0, // left ])); + let display_name = Text::new(localized_string("display-name")) + .size(DEFAULT_SUB_HEADER_FONT_SIZE) + .horizontal_alignment(alignment::Horizontal::Left); + + let display_name_container = + Container::new(display_name).style(grin_gui_core::theme::ContainerStyle::NormalBackground); + + let display_name_input = TextInput::new( + default_display_name, + &state.advanced_options_state.display_name_value, + ) + .on_input(|s| { + Interaction::WalletSetupWalletViewInteraction(LocalViewInteraction::DisplayName(s)) + }) + .size(DEFAULT_FONT_SIZE) + .padding(6) + .width(Length::Fixed(200.0)) + .style(grin_gui_core::theme::TextInputStyle::AddonsQuery); let password_column = { let password_input = TextInput::new( @@ -365,7 +384,7 @@ pub fn data_container<'a>( }; let description = Text::new(localized_string("setup-grin-wallet-enter-password")) - .size(DEFAULT_FONT_SIZE) + .size(DEFAULT_SUB_HEADER_FONT_SIZE) .horizontal_alignment(alignment::Horizontal::Center); let description_container = Container::new(description).style(grin_gui_core::theme::ContainerStyle::NormalBackground); @@ -437,27 +456,8 @@ pub fn data_container<'a>( // ** start hideable advanced options //let display_name_label = - let display_name = Text::new(localized_string("display-name")) - .size(DEFAULT_FONT_SIZE) - .horizontal_alignment(alignment::Horizontal::Left); - - let display_name_container = - Container::new(display_name).style(grin_gui_core::theme::ContainerStyle::NormalBackground); - - let display_name_input = TextInput::new( - default_display_name, - &state.advanced_options_state.display_name_value, - ) - .on_input(|s| { - Interaction::WalletSetupWalletViewInteraction(LocalViewInteraction::DisplayName(s)) - }) - .size(DEFAULT_FONT_SIZE) - .padding(6) - .width(Length::Fixed(200.0)) - .style(grin_gui_core::theme::TextInputStyle::AddonsQuery); - let tld = Text::new(localized_string("top-level-domain")) - .size(DEFAULT_FONT_SIZE) + .size(DEFAULT_SUB_HEADER_FONT_SIZE) .horizontal_alignment(alignment::Horizontal::Left); let tld_container = @@ -509,9 +509,6 @@ pub fn data_container<'a>( let is_testnet_row = Row::new().push(is_testnet_checkbox.map(Message::Interaction)); let advanced_options_column = Column::new() - .push(display_name_container) - .push(display_name_input.map(Message::Interaction)) - .push(Space::new(Length::Fixed(0.0), Length::Fixed(5.0))) .push(tld_container) .spacing(DEFAULT_PADDING) .push(folder_select_row) @@ -584,6 +581,10 @@ pub fn data_container<'a>( .push(cancel_container); let mut column = Column::new() + .push(display_name_container) + .push(Space::new(Length::Fixed(0.0), Length::Fixed(unit_spacing))) + .push(display_name_input.map(Message::Interaction)) + .push(Space::new(Length::Fixed(0.0), Length::Fixed(5.0))) .push(Space::new(Length::Fixed(0.0), Length::Fixed(unit_spacing))) .push(description_container) .push(Space::new(Length::Fixed(0.0), Length::Fixed(unit_spacing)))