Skip to content

Commit

Permalink
#55- Refactor to improve the alignment in the key details component
Browse files Browse the repository at this point in the history
  • Loading branch information
piratax007 committed Jul 29, 2022
1 parent 1b86e89 commit 360e5cc
Show file tree
Hide file tree
Showing 4 changed files with 196 additions and 108 deletions.
100 changes: 55 additions & 45 deletions gui/definitions/interface/KeyDetails.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,23 @@
</packing>
</child>
<child>
<object class="GtkBox" id="keyDetailsPublicKeyRow">
<!-- n-columns=2 n-rows=4 -->
<object class="GtkGrid" id="keyDetailsGrid">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkLabel" id="publicKeyPathLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Public key:</property>
<style>
<class name="pathLabel"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
Expand All @@ -52,38 +53,26 @@
</style>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
</packing>
</child>
<style>
<class name="publicKey"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox" id="keyDetailsPrivateKeyRow">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkLabel" id="privateKeyPathLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Private key:</property>
<style>
<class name="pathLabel"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
Expand All @@ -98,42 +87,65 @@
</style>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
</packing>
</child>
<style>
<class name="privateKey"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkBox" id="keyFingerprintRow">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkLabel" id="fingerprintLabel">
<object class="GtkLabel" id="sha1FingerprintLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Fingerprint:</property>
<property name="halign">start</property>
<property name="label" translatable="yes">SHA-1:</property>
<style>
<class name="fingerprintLabel"/>
</style>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="sha1Fingerprint">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="ellipsize">end</property>
<property name="width-chars">20</property>
<property name="selectable">True</property>
<style>
<class name="fingerprint"/>
</style>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">2</property>
</packing>
</child>
<style>
<class name="fingerprint"/>
</style>
<child>
<object class="GtkLabel" id="sha256FingerprintLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">SHA2-256:</property>
<style>
<class name="fingerprintLabel"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
<property name="left-attach">0</property>
<property name="top-attach">3</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="fingerprint">
<object class="GtkLabel" id="sha256Fingerprint">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
Expand All @@ -145,9 +157,8 @@
</style>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="left-attach">1</property>
<property name="top-attach">3</property>
</packing>
</child>
<style>
Expand All @@ -157,7 +168,6 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<style>
Expand Down
21 changes: 17 additions & 4 deletions gui/key_details.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,27 @@ func (kd *keyDetails) setClassForKeyDetails() {
addClass(kd.box, className)
}

func (kd *keyDetails) displayLocations(keyLocations []string, pathLabelName, rowName string) {
type hideable interface {
Hide()
}

func (kd *keyDetails) hideAll(ids ...string) {
for _, id := range ids {
kd.hide(id)
}
}
func (kd *keyDetails) hide(id string) {
l := kd.builder.get(id).(hideable)
l.Hide()
}

func (kd *keyDetails) displayLocations(keyLocations []string, path, pathLabel string) {
if keyLocations != nil {
label := kd.builder.get(pathLabelName).(gtki.Label)
label := kd.builder.get(path).(gtki.Label)
label.SetLabel(keyLocations[0])
label.SetTooltipText(keyLocations[0])
} else {
row := kd.builder.get(rowName).(gtki.Box)
row.Hide()
kd.hideAll(pathLabel, path)
}
}

Expand Down
Loading

0 comments on commit 360e5cc

Please sign in to comment.