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

feat(gui): showing the total number of validators #474

Merged
merged 2 commits into from
May 24, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
60 changes: 45 additions & 15 deletions cmd/gtk/assets/ui/widget_node.ui
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@
<property name="label-xalign">0.019999999552965164</property>
<property name="shadow-type">in</property>
<child>
<!-- n-columns=2 n-rows=4 -->
<!-- n-columns=2 n-rows=5 -->
<object class="GtkGrid">
<property name="width-request">400</property>
<property name="visible">True</property>
Expand All @@ -263,7 +263,7 @@
<property name="valign">start</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="label" translatable="yes">Number of committee members:</property>
<property name="label" translatable="yes">Committee size:</property>
</object>
<packing>
<property name="left-attach">0</property>
Expand All @@ -282,7 +282,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
<property name="top-attach">4</property>
</packing>
</child>
<child>
Expand All @@ -301,22 +301,22 @@
</packing>
</child>
<child>
<object class="GtkLabel">
<object class="GtkLabel" id="id_label_committee_size">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="label" translatable="yes">Total power:</property>
<property name="selectable">True</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">3</property>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="id_label_committee_size">
<object class="GtkLabel" id="id_label_in_committee">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
Expand All @@ -327,11 +327,11 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
<property name="top-attach">4</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="id_label_in_committee">
<object class="GtkLabel" id="id_label_committee_power">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
Expand All @@ -342,11 +342,11 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="id_label_committee_stake">
<object class="GtkLabel" id="id_label_total_power">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
Expand All @@ -357,11 +357,41 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">2</property>
<property name="top-attach">3</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="id_label_total_stake">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="label" translatable="yes">Total power:</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">3</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="label" translatable="yes">Number of validators:</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="id_label_num_validators">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
Expand All @@ -372,7 +402,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">3</property>
<property name="top-attach">1</property>
</packing>
</child>
</object>
Expand Down
4 changes: 2 additions & 2 deletions cmd/gtk/icons.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var (
iconClose []byte

//go:embed assets/icons/send.svg
sendSeed []byte
iconSend []byte
)

func pixbufToIcon16(pixbuf *gdk.Pixbuf) *gtk.Image {
Expand Down Expand Up @@ -73,6 +73,6 @@ func SeedIcon() *gtk.Image {
}

func SendIcon() *gtk.Image {
pixbuf, _ := gdk.PixbufNewFromDataOnly(sendSeed)
pixbuf, _ := gdk.PixbufNewFromDataOnly(iconSend)
return pixbufToIcon16(pixbuf)
}
8 changes: 6 additions & 2 deletions cmd/gtk/widget_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type widgetNode struct {
labelLastBlockHeight *gtk.Label
labelBlocksLeft *gtk.Label
labelCommitteeSize *gtk.Label
labelValidatorNum *gtk.Label
labelInCommittee *gtk.Label
labelCommitteeStake *gtk.Label
labelTotalStake *gtk.Label
Expand Down Expand Up @@ -56,9 +57,10 @@ func buildWidgetNode(model *nodeModel, genesisTime time.Time) (*widgetNode, erro
labelBlocksLeft: getLabelObj(builder, "id_label_blocks_left"),
progressBarSynced: getProgressBarObj(builder, "id_progress_synced"),
labelCommitteeSize: getLabelObj(builder, "id_label_committee_size"),
labelValidatorNum: getLabelObj(builder, "id_label_num_validators"),
labelInCommittee: getLabelObj(builder, "id_label_in_committee"),
labelCommitteeStake: getLabelObj(builder, "id_label_committee_stake"),
labelTotalStake: getLabelObj(builder, "id_label_total_stake"),
labelCommitteeStake: getLabelObj(builder, "id_label_committee_power"),
labelTotalStake: getLabelObj(builder, "id_label_total_power"),
}

signals := map[string]interface{}{}
Expand Down Expand Up @@ -110,13 +112,15 @@ func (wn *widgetNode) timeout10() bool {
committeeSize := wn.model.node.State().Params().CommitteeSize
committeeStake := wn.model.node.State().CommitteePower()
totalStake := wn.model.node.State().TotalPower()
validatorNum := wn.model.node.State().TotalValidators()
isInCommittee := "No"
if wn.model.node.ConsManager().HasActiveInstance() {
isInCommittee = "Yes"
}

glib.IdleAdd(func() bool {
wn.labelCommitteeSize.SetText(fmt.Sprintf("%v", committeeSize))
wn.labelValidatorNum.SetText(fmt.Sprintf("%v", validatorNum))
wn.labelCommitteeStake.SetText(util.ChangeToString(committeeStake))
wn.labelTotalStake.SetText(util.ChangeToString(totalStake))
wn.labelInCommittee.SetText(fmt.Sprintf("%v", isInCommittee))
Expand Down