Skip to content

Commit

Permalink
Merge pull request #239 from subspace/add-create-wallet-button
Browse files Browse the repository at this point in the history
Add "Create wallet" button next to reward address
  • Loading branch information
nazar-pc authored Jul 24, 2024
2 parents a8ca670 + a6612d4 commit 4db60f8
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 34 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "space-acres"
description = "Space Acres is an opinionated GUI application for farming on Subspace Network"
license = "0BSD"
version = "0.1.28"
version = "0.1.29"
authors = ["Nazar Mokrynskyi <[email protected]>"]
repository = "https://github.com/subspace/space-acres"
edition = "2021"
Expand Down
82 changes: 50 additions & 32 deletions src/frontend/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub enum DirectoryKind {
pub enum ConfigurationInput {
AddFarm,
RewardAddressChanged(String),
CreateWallet,
OpenDirectory(DirectoryKind),
DirectorySelected(PathBuf),
SubstratePortChanged(u16),
Expand Down Expand Up @@ -253,40 +254,50 @@ impl AsyncComponent for ConfigurationView {
set_label: "Rewards address",
},

gtk::Entry {
connect_activate[sender] => move |entry| {
sender.input(ConfigurationInput::RewardAddressChanged(
entry.text().into()
));
},
connect_changed[sender] => move |entry| {
sender.input(ConfigurationInput::RewardAddressChanged(
entry.text().into()
));
gtk::Box {
add_css_class: "linked",

gtk::Entry {
connect_activate[sender] => move |entry| {
sender.input(ConfigurationInput::RewardAddressChanged(
entry.text().into()
));
},
connect_changed[sender] => move |entry| {
sender.input(ConfigurationInput::RewardAddressChanged(
entry.text().into()
));
},
#[track = "model.reward_address.changed_is_valid()"]
set_css_classes: if model.reward_address.is_valid {
&["valid-input"]
} else {
&["invalid-input"]
},
set_hexpand: true,
set_placeholder_text: Some(
"Example: stB4S14whneyomiEa22Fu2PzVoibMB7n5PvBFUwafbCbRkC1K",
),
set_primary_icon_name: Some(icon_name::WALLET2),
set_primary_icon_activatable: false,
set_primary_icon_sensitive: false,
#[track = "model.reward_address.changed_is_valid()"]
set_secondary_icon_name: model.reward_address.icon(),
set_secondary_icon_activatable: false,
set_secondary_icon_sensitive: false,
#[track = "model.reward_address.changed_value()"]
set_text: &model.reward_address,
set_tooltip_markup: Some(
"Use Subwallet or polkadot{.js} extension or any other \
Substrate wallet to create it first (address for any Substrate \
chain in SS58 format works)"
),
},
#[track = "model.reward_address.changed_is_valid()"]
set_css_classes: if model.reward_address.is_valid {
&["valid-input"]
} else {
&["invalid-input"]

gtk::Button {
connect_clicked => ConfigurationInput::CreateWallet,
set_label: "Create wallet",
},
set_placeholder_text: Some(
"Example: stB4S14whneyomiEa22Fu2PzVoibMB7n5PvBFUwafbCbRkC1K",
),
set_primary_icon_name: Some(icon_name::WALLET2),
set_primary_icon_activatable: false,
set_primary_icon_sensitive: false,
#[track = "model.reward_address.changed_is_valid()"]
set_secondary_icon_name: model.reward_address.icon(),
set_secondary_icon_activatable: false,
set_secondary_icon_sensitive: false,
#[track = "model.reward_address.changed_value()"]
set_text: &model.reward_address,
set_tooltip_markup: Some(
"Use Subwallet or polkadot{.js} extension or any other \
Substrate wallet to create it first (address for any Substrate \
chain in SS58 format works)"
),
},
},
},
Expand Down Expand Up @@ -624,6 +635,13 @@ impl ConfigurationView {
// Nothing
});
}
ConfigurationInput::CreateWallet => {
if let Err(error) =
open::that_detached("https://docs.subspace.network/docs/category/wallets")
{
error!(%error, "Failed to open create wallet page in default browser");
}
}
ConfigurationInput::RewardAddressChanged(new_reward_address) => {
let new_reward_address = new_reward_address.trim();
self.reward_address
Expand Down

0 comments on commit 4db60f8

Please sign in to comment.