Elide the npubs in the approval dialog

The "Signing as" identity field and the Details "Peer" row were the last two
npubs still wrapping instead of eliding in the middle. The identity field is
a stacked name/npub pair rather than a row, so it needed the label's own
ellipsize set; a wrapping label reports the full npub width, so the ellipsis
also keeps the dialog at 480 instead of being pushed wider.
This commit is contained in:
raucao committed 2026-11-26 12:38:19 +04:00
1 parent 6b40ceb854
commit 5b5edfd6f4
2 files changed
+15 -4

No files matched your search

+2 -1
View File
@@ -596,7 +596,8 @@ UI lives in `data/resources/ui/*.blp` (Blueprint) and is compiled to `.ui` by
label in the row's own widget tree and sets `MIDDLE`; `set_subtitle` does not
reset it, so once at construction is enough. The row then elides the middle
at whatever width it gets. Every npub byline/row uses it (identities, Apps
details, "Signing as", the approval dialog's client key) — and a wrapped npub
details, "Signing as" in the Connect and approval dialogs, the approval
dialog's client key and peer) — and a wrapped npub
is also what made the "Connect an app" dialog clip its bottom: the scroller
measures natural height at the *unwrapped* width (trap 15), so a long token
must stay on one line.
+13 -3
View File
@@ -506,7 +506,10 @@ fn more_details(question: &Question) -> gtk::ListBox {
}
Request::Encrypt { method, peer, .. } | Request::Decrypt { method, peer, .. } => {
row.add_row(&plain::row("Method", method));
row.add_row(&plain::row("Peer", peer));
let peer_row = plain::row("Peer", peer);
peer_row.set_subtitle_lines(1);
plain::middle_ellipsis(&peer_row);
row.add_row(&peer_row);
}
}
@@ -535,12 +538,19 @@ fn identity_field(identity: &crate::signer::approval::SigningKey) -> gtk::Box {
.as_deref()
.map(str::trim)
.filter(|name| !name.is_empty());
// The npub is a long token: one line, ellipsized in the middle like every
// other npub, rather than wrapping. A wrapping label reports the full npub
// width and pushes the dialog wider; with the ellipsis, `plain`'s
// `max_width_chars` cap takes effect and the dialog stays at 480.
let npub_label = plain(&npub);
npub_label.set_wrap(false);
npub_label.set_ellipsize(gtk::pango::EllipsizeMode::Middle);
match name {
Some(name) => {
value.append(&plain(name));
value.append(&plain(&npub));
value.append(&npub_label);
}
None => value.append(&plain(&npub)),
None => value.append(&npub_label),
}
field_widget("Signing as", &value)
}