fix(gui): keep the launcher preview at its fixed width

A wrapping label asks for its whole text on one line as its natural
width, so a long location in the preview pane widened it, squeezed the
results list and stretched the window. Cap the preview labels' natural
width, limit detail values to three lines with a tooltip for the full
location, and keep the pane from taking extra width.
This commit is contained in:
nvrl committed 2026-09-28 23:04:48 +02:00
1 parent 9577387c2f
commit 8bd3867cb3
1 file changed
+12
+12
View File
@@ -38,11 +38,17 @@ impl Detail {
.valign(gtk4::Align::Start) .valign(gtk4::Align::Start)
.build(); .build();
title.add_css_class("preview-key"); title.add_css_class("preview-key");
// A wrapping label asks for its whole text on one line as its natural
// width, which would widen the pane and squeeze the results. Capping it
// keeps the pane at its fixed width; long values wrap, then ellipsize.
let value = gtk4::Label::builder() let value = gtk4::Label::builder()
.xalign(0.0) .xalign(0.0)
.hexpand(true) .hexpand(true)
.wrap(true) .wrap(true)
.wrap_mode(gtk4::pango::WrapMode::WordChar) .wrap_mode(gtk4::pango::WrapMode::WordChar)
.max_width_chars(1)
.lines(3)
.ellipsize(gtk4::pango::EllipsizeMode::Middle)
.build(); .build();
value.add_css_class("preview-value"); value.add_css_class("preview-value");
grid.attach(&title, 0, row, 1, 1); grid.attach(&title, 0, row, 1, 1);
@@ -85,6 +91,8 @@ fn action(icon: &str, label: &str, accelerator: &str) -> (gtk4::Button, gtk4::La
.label(label) .label(label)
.xalign(0.0) .xalign(0.0)
.hexpand(true) .hexpand(true)
.max_width_chars(1)
.ellipsize(gtk4::pango::EllipsizeMode::End)
.build(); .build();
content.append(&text); content.append(&text);
let shortcut = gtk4::ShortcutLabel::new(accelerator); let shortcut = gtk4::ShortcutLabel::new(accelerator);
@@ -112,6 +120,7 @@ impl Preview {
.xalign(0.0) .xalign(0.0)
.wrap(true) .wrap(true)
.wrap_mode(gtk4::pango::WrapMode::WordChar) .wrap_mode(gtk4::pango::WrapMode::WordChar)
.max_width_chars(1)
.lines(3) .lines(3)
.ellipsize(gtk4::pango::EllipsizeMode::End) .ellipsize(gtk4::pango::EllipsizeMode::End)
.build(); .build();
@@ -120,6 +129,7 @@ impl Preview {
let kind = gtk4::Label::builder() let kind = gtk4::Label::builder()
.xalign(0.0) .xalign(0.0)
.max_width_chars(1)
.ellipsize(gtk4::pango::EllipsizeMode::End) .ellipsize(gtk4::pango::EllipsizeMode::End)
.build(); .build();
kind.add_css_class("preview-kind"); kind.add_css_class("preview-kind");
@@ -186,6 +196,7 @@ impl Preview {
let root = gtk4::Box::builder() let root = gtk4::Box::builder()
.orientation(gtk4::Orientation::Vertical) .orientation(gtk4::Orientation::Vertical)
.width_request(PREVIEW_WIDTH) .width_request(PREVIEW_WIDTH)
.hexpand(false)
.build(); .build();
root.add_css_class("preview"); root.add_css_class("preview");
root.append(&stack); root.append(&stack);
@@ -242,6 +253,7 @@ impl Preview {
let location = hit.location(); let location = hit.location();
self.location.set(Some(&location)); self.location.set(Some(&location));
self.location.value.set_tooltip_text(Some(&location));
match availability(hit) { match availability(hit) {
Some((icon, class, text)) => { Some((icon, class, text)) => {