fix header row widget

This commit is contained in:
yggverse 2025-03-26 05:32:23 +02:00
parent 1c29639468
commit 1dd7aafb0c

View file

@ -5,7 +5,7 @@ use adw::{
ActionRowExt, ExpanderRowExt, PreferencesDialogExt, PreferencesGroupExt, PreferencesPageExt, ActionRowExt, ExpanderRowExt, PreferencesDialogExt, PreferencesGroupExt, PreferencesPageExt,
}, },
}; };
use gtk::glib::gformat; use gtk::{Align, glib::gformat};
pub trait Dialog { pub trait Dialog {
fn info(profile: &Profile, info: &Info) -> Self; fn info(profile: &Profile, info: &Info) -> Self;
@ -61,8 +61,6 @@ impl Dialog for PreferencesDialog {
t += l; t += l;
g.add(&{ g.add(&{
let e = adw::ExpanderRow::builder() let e = adw::ExpanderRow::builder()
/* @TODO this class does not work with `ExpanderRow`
.css_classes(["property"]) */
.enable_expansion(true) .enable_expansion(true)
.expanded(false) .expanded(false)
.subtitle(l.bytes()) .subtitle(l.bytes())
@ -70,20 +68,23 @@ impl Dialog for PreferencesDialog {
.title("Header") .title("Header")
.build(); .build();
e.add_row( e.add_row(
&gtk::Label::builder() &ActionRow::builder()
.css_classes(["dim-label", "caption"]) .css_classes(["property"])
.ellipsize(gtk::pango::EllipsizeMode::None) .title_selectable(true)
.halign(gtk::Align::Start) .title(h.escape_default().to_string()) // escape \r\n
.label(h) .build(),
.margin_bottom(2)
.margin_end(12)
.margin_start(12)
.margin_top(14)
.selectable(true)
.valign(gtk::Align::Center)
.wrap(false)
.build(), // @TODO replace with `ActionRow` after fix empty subtitle issue
); );
{
use gtk::prelude::{ListBoxRowExt, WidgetExt};
e.child().map(|c| {
c.first_child().map(|c| {
c.first_child().map_or_else(
|| println!("Deprecated child order!"),
|c| c.add_css_class("property"),
)
})
}); // @TODO unstable!
}
e e
}) })
} }
@ -230,8 +231,8 @@ impl Dialog for PreferencesDialog {
]) ])
.label(c.to_string()) .label(c.to_string())
.sensitive(false) .sensitive(false)
.valign(gtk::Align::Center) .valign(Align::Center)
.halign(gtk::Align::Center) .halign(Align::Center)
.build() .build()
}); });
// show total redirection time in ms // show total redirection time in ms