Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(GUI): update total balance on wallet timeout #1204

Merged
merged 2 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/gtk/assets/ui/widget_wallet.ui
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
</packing>
</child>
<child>
<object class="GtkLabel" id="id_lable_wallet_total_balance">
<object class="GtkLabel" id="id_label_wallet_total_balance">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
Expand Down
37 changes: 20 additions & 17 deletions cmd/gtk/widget_wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ var uiWidgetWallet []byte
type widgetWallet struct {
*gtk.Box

treeView *gtk.TreeView
model *walletModel
treeViewWallet *gtk.TreeView
labelTotalBalance *gtk.Label
model *walletModel
}

// Add a column to the tree view (during the initialization of the tree view).
Expand All @@ -50,11 +51,11 @@ func buildWidgetWallet(model *walletModel) (*widgetWallet, error) {
}

box := getBoxObj(builder, "id_box_wallet")
treeView := getTreeViewObj(builder, "id_treeview_addresses")
treeViewWallet := getTreeViewObj(builder, "id_treeview_addresses")
labelName := getLabelObj(builder, "id_label_wallet_name")
labelLocation := getLabelObj(builder, "id_label_wallet_location")
labelEncrypted := getLabelObj(builder, "id_label_wallet_encrypted")
labelTotalBalance := getLabelObj(builder, "id_lable_wallet_total_balance")
labelTotalBalance := getLabelObj(builder, "id_label_wallet_total_balance")

getToolButtonObj(builder, "id_button_new_address").SetIconWidget(AddIcon())
getToolButtonObj(builder, "id_button_change_password").SetIconWidget(PasswordIcon())
Expand All @@ -76,18 +77,19 @@ func buildWidgetWallet(model *walletModel) (*widgetWallet, error) {
colStake := createColumn("Stake", IDAddressesColumnStake)
colScore := createColumn("Availability Score", IDAddressesColumnAvailabilityScore)

treeView.AppendColumn(colNo)
treeView.AppendColumn(colAddress)
treeView.AppendColumn(colLabel)
treeView.AppendColumn(colBalance)
treeView.AppendColumn(colStake)
treeView.AppendColumn(colScore)
treeView.SetModel(model.ToTreeModel())
treeViewWallet.AppendColumn(colNo)
treeViewWallet.AppendColumn(colAddress)
treeViewWallet.AppendColumn(colLabel)
treeViewWallet.AppendColumn(colBalance)
treeViewWallet.AppendColumn(colStake)
treeViewWallet.AppendColumn(colScore)
treeViewWallet.SetModel(model.ToTreeModel())

w := &widgetWallet{
Box: box,
treeView: treeView,
model: model,
Box: box,
treeViewWallet: treeViewWallet,
labelTotalBalance: labelTotalBalance,
model: model,
}

menu, err := gtk.MenuNew()
Expand Down Expand Up @@ -132,8 +134,8 @@ func buildWidgetWallet(model *walletModel) (*widgetWallet, error) {
})
menu.Append(item)

treeView.Connect("button-press-event",
func(treeView *gtk.TreeView, event *gdk.Event) bool {
treeViewWallet.Connect("button-press-event",
func(treeViewWallet *gtk.TreeView, event *gdk.Event) bool {
eventButton := gdk.EventButtonNewFromEvent(event)
if eventButton.Type() == gdk.EVENT_BUTTON_PRESS &&
eventButton.Button() == gdk.BUTTON_SECONDARY {
Expand Down Expand Up @@ -177,6 +179,7 @@ func (ww *widgetWallet) onShowSeed() {

func (ww *widgetWallet) timeout() bool {
ww.model.rebuildModel()
ww.labelTotalBalance.SetText(ww.model.wallet.TotalBalance().String())

return true
}
Expand Down Expand Up @@ -213,7 +216,7 @@ func (ww *widgetWallet) onShowPrivateKey() {
}

func (ww *widgetWallet) getSelectedAddress() string {
selection, err := ww.treeView.GetSelection()
selection, err := ww.treeViewWallet.GetSelection()
fatalErrorCheck(err)

if selection != nil {
Expand Down
Loading