From cbefddfea2a3b9e2f162323a582c6c5626b8bd55 Mon Sep 17 00:00:00 2001 From: Maxim Orlovsky Date: Fri, 21 Jul 2023 14:49:09 +0200 Subject: [PATCH] pay: connect pay and payto dialogs --- src/view/wallet/component.rs | 5 ++++- src/view/wallet/payto/payto.glade | 7 ++++++- src/view/wallet/payto/widget.rs | 27 ++++++++++++++++++++++++--- src/view/wallet/widget.rs | 4 ++-- 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/view/wallet/component.rs b/src/view/wallet/component.rs index 6ed552d..b24f7dc 100644 --- a/src/view/wallet/component.rs +++ b/src/view/wallet/component.rs @@ -574,7 +574,10 @@ impl Component { payto::Msg::Response(ResponseType::Cancel) => { self.payto_widgets.hide(); } - payto::Msg::Response(_) => {} + payto::Msg::Response(ResponseType::Other(1000)) => { + self.payto_widgets.hide(); + self.update_pay(pay::Msg::Show); + } _ => {} // Changes which update wallet tx } } diff --git a/src/view/wallet/payto/payto.glade b/src/view/wallet/payto/payto.glade index 01b6527..604695c 100644 --- a/src/view/wallet/payto/payto.glade +++ b/src/view/wallet/payto/payto.glade @@ -6,6 +6,11 @@ False center dialog + + cancel_btn + compose_btn + batch_btn + False @@ -233,7 +238,7 @@ - Batch + Advanced... True True True diff --git a/src/view/wallet/payto/widget.rs b/src/view/wallet/payto/widget.rs index 30d4b04..3938717 100644 --- a/src/view/wallet/payto/widget.rs +++ b/src/view/wallet/payto/widget.rs @@ -11,9 +11,10 @@ use gladis::Gladis; use gtk::prelude::*; -use gtk::{Button, Dialog, Entry, HeaderBar, InfoBar, Label, ToggleButton}; +use gtk::{Button, Dialog, Entry, HeaderBar, InfoBar, Label, ResponseType, ToggleButton}; use relm::Relm; +use super::Msg; use crate::view::wallet; // Create the structure that holds the widgets used in the view. @@ -36,7 +37,12 @@ pub struct Widgets { } impl Widgets { - pub fn init_ui(&self, model: &wallet::ViewModel) {} + pub fn init_ui(&self, model: &wallet::ViewModel) { + self.header_bar.set_subtitle(Some(&format!( + "{:.08} BTC available", + model.wallet().state().balance as f64 / 100_000_000.0 + ))); + } pub fn show(&self) { self.dialog.show() } pub fn hide(&self) { self.dialog.hide() } @@ -44,5 +50,20 @@ impl Widgets { pub fn to_root(&self) -> Dialog { self.dialog.clone() } pub fn as_root(&self) -> &Dialog { &self.dialog } - pub fn connect(&self, relm: &Relm) {} + pub fn connect(&self, relm: &Relm) { + connect!( + relm, + self.dialog, + connect_response(_, resp), + wallet::Msg::PayTo(Msg::Response(resp)) + ); + self.dialog.set_response_sensitive(ResponseType::Ok, true); + + connect!( + relm, + self.dialog, + connect_delete_event(_, _), + return (None, Inhibit(true)) + ); + } } diff --git a/src/view/wallet/widget.rs b/src/view/wallet/widget.rs index f603c7c..adcd252 100644 --- a/src/view/wallet/widget.rs +++ b/src/view/wallet/widget.rs @@ -29,7 +29,7 @@ use relm::Relm; use wallet::hd::SegmentIndexes; use super::asset_row::{self, AssetModel}; -use super::{pay, ElectrumState, Msg, ViewModel}; +use super::{payto, ElectrumState, Msg, ViewModel}; use crate::model::UI as UIColorTrait; use crate::view::{launch, APP_ICON, APP_ICON_TOOL}; use crate::worker::exchange::{Exchange, Fiat}; @@ -165,7 +165,7 @@ impl Widgets { relm, self.pay_btn, connect_clicked(_), - Msg::Pay(pay::Msg::Show) + Msg::PayTo(payto::Msg::Show) ); connect!(relm, self.refresh_btn, connect_clicked(_), Msg::Refresh); connect!(relm, self.redefine_mi, connect_activate(_), Msg::Duplicate);