Merge pull request #16 from YGGverse/fix-left-window-buttons-placement

add left window controls placement support
This commit is contained in:
oooo-ps 2026-03-08 16:25:43 +02:00 committed by GitHub
commit 71f2597bf5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 7 deletions

View file

@ -27,10 +27,20 @@ impl Bar for Box {
.orientation(Orientation::Horizontal)
.spacing(8)
.build();
g_box.append(&TabBar::tab(window_action, view));
g_box.append(&MenuButton::menu((browser_action, window_action)));
g_box.append(&Control::new().window_controls);
// 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(&MenuButton::menu((browser_action, window_action)));
g_box.append(&Control::right().window_controls)
}
g_box
}
}

View file

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