Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Jul 21, 2023
1 parent 6431bae commit 9cedab9
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/view/wallet/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/view/wallet/payto/payto.glade
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
<property name="can-focus">False</property>
<property name="window-position">center</property>
<property name="type-hint">dialog</property>
<action-widgets>
<action-widget response="cancel">cancel_btn</action-widget>
<action-widget response="ok" default="true">compose_btn</action-widget>
<action-widget response="1000" default="true">batch_btn</action-widget>
</action-widgets>
<child internal-child="vbox">
<object class="GtkBox">
<property name="can-focus">False</property>
Expand Down Expand Up @@ -233,7 +238,7 @@
</child>
<child>
<object class="GtkButton" id="batch_btn">
<property name="label" translatable="yes">Batch</property>
<property name="label" translatable="yes">Advanced...</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
Expand Down
27 changes: 24 additions & 3 deletions src/view/wallet/payto/widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -36,13 +37,33 @@ 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() }

pub fn to_root(&self) -> Dialog { self.dialog.clone() }
pub fn as_root(&self) -> &Dialog { &self.dialog }

pub fn connect(&self, relm: &Relm<wallet::Component>) {}
pub fn connect(&self, relm: &Relm<wallet::Component>) {
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))
);
}
}
4 changes: 2 additions & 2 deletions src/view/wallet/widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 9cedab9

Please sign in to comment.