Skip to content

Commit

Permalink
Updates to new user workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
yeastplume committed Apr 23, 2024
1 parent ebe44d6 commit f80b565
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 37 deletions.
6 changes: 4 additions & 2 deletions crates/core/src/fs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Mutex<PathBuf>> = Lazy::new(|| {
// Returns the location of the config directory. Will create if it doesn't
// exist.
Expand All @@ -24,7 +26,7 @@ pub static CONFIG_DIR: Lazy<Mutex<PathBuf>> = 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)
}
Expand All @@ -36,7 +38,7 @@ pub static CONFIG_DIR: Lazy<Mutex<PathBuf>> = 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.");

Expand Down
8 changes: 2 additions & 6 deletions crates/core/src/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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";
Expand All @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions crates/core/src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ 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
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
Expand All @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion locale/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
49 changes: 25 additions & 24 deletions src/gui/element/wallet/setup/wallet_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)))
Expand Down

0 comments on commit f80b565

Please sign in to comment.