add left window controls placement support

This commit is contained in:
yggverse 2026-03-08 16:21:56 +02:00
parent 6fb7e70213
commit 81b57f92ac
2 changed files with 24 additions and 7 deletions

View file

@ -27,10 +27,20 @@ impl Bar for Box {
.orientation(Orientation::Horizontal) .orientation(Orientation::Horizontal)
.spacing(8) .spacing(8)
.build(); .build();
// left controls placement
if gtk::Settings::default().is_some_and(|s| {
s.gtk_decoration_layout()
.is_some_and(|l| l.starts_with("close"))
}) {
g_box.append(&Control::left().window_controls);
g_box.append(&MenuButton::menu((browser_action, window_action)));
g_box.append(&TabBar::tab(window_action, view))
// default layout
} else {
g_box.append(&TabBar::tab(window_action, view)); g_box.append(&TabBar::tab(window_action, view));
g_box.append(&MenuButton::menu((browser_action, window_action))); g_box.append(&MenuButton::menu((browser_action, window_action)));
g_box.append(&Control::new().window_controls); g_box.append(&Control::right().window_controls)
}
g_box g_box
} }
} }

View file

@ -8,13 +8,12 @@ pub struct Control {
impl Default for Control { impl Default for Control {
fn default() -> Self { fn default() -> Self {
Self::new() Self::right()
} }
} }
impl Control { impl Control {
// Construct pub fn right() -> Self {
pub fn new() -> Self {
Self { Self {
window_controls: WindowControls::builder() window_controls: WindowControls::builder()
.margin_end(MARGIN) .margin_end(MARGIN)
@ -22,4 +21,12 @@ impl Control {
.build(), .build(),
} }
} }
pub fn left() -> Self {
Self {
window_controls: WindowControls::builder()
.margin_end(MARGIN)
.side(PackType::Start)
.build(),
}
}
} }