Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions linux/changelog.d/4117.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The sidebar toggle stays in the header while the sidebar shows, so it collapses from there.
35 changes: 24 additions & 11 deletions linux/crates/app/src/ui/workspace/tests/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,23 +174,36 @@ fn show_tabs_opens_and_closes_the_overview_while_a_tab_is_open() {
}

#[gtk4::test]
fn sidebar_toggle_visible_only_when_collapsed_or_hidden() {
fn the_sidebar_toggle_is_always_in_the_header() {
let test = TestWindow::connected("SidebarToggle");
let workspace = test.workspace();
let shell = shell_of(&workspace);
let imp = shell.imp();
let (split, toggle) = (imp.split_view.get(), imp.sidebar_toggle.get());
split.set_collapsed(false);
split.set_show_sidebar(true);
assert!(!toggle.is_visible(), "shown beside a sidebar in view");

split.set_show_sidebar(false);
assert!(toggle.is_visible(), "hidden with the sidebar hidden");

split.set_show_sidebar(true);
split.set_collapsed(true);
assert!(toggle.is_visible(), "hidden with the sidebar collapsed");
crate::test_support::assert_labelled(&toggle).expect("the sidebar toggle is named");
assert_eq!(toggle.tooltip_text().as_deref(), Some("Show Sidebar"));
assert_eq!(toggle.action_name().as_deref(), Some("win.show-sidebar"));

for collapsed in [false, true] {
split.set_collapsed(collapsed);
split.set_show_sidebar(true);
assert!(toggle.is_visible());
assert!(toggle.is_active());

toggle.emit_clicked();
assert!(!split.shows_sidebar());
assert!(!toggle.is_active());
assert!(toggle.is_visible());

toggle.emit_clicked();
assert!(split.shows_sidebar());
assert!(toggle.is_active());

WidgetExt::activate_action(&test.window, "win.show-sidebar", None).expect("win.show-sidebar");
assert!(!split.shows_sidebar());
assert!(!toggle.is_active());
assert!(toggle.is_visible());
}
}

#[gtk4::test]
Expand Down
22 changes: 0 additions & 22 deletions linux/crates/app/src/ui/workspace/workspace_shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ impl WorkspaceShell {
&imp.split_view.get(),
"show-sidebar",
));
follow_sidebar(&imp.split_view, &imp.sidebar_toggle);
window.add_action(&assistant_action(&shell));
imp.walk_hooks.replace(Some(shell.hook_recent_walk(window)));

Expand Down Expand Up @@ -778,27 +777,6 @@ fn with_safe_mode(menu: &gio::MenuModel) -> gio::Menu {
whole
}

/// The toggle shows only while the sidebar is out of view: collapsed
/// into an overlay, or hidden. Beside a shown sidebar it would only hide
/// the list the user is looking at.
fn follow_sidebar(split_view: &adw::OverlaySplitView, toggle: &gtk::ToggleButton) -> gtk::ExpressionWatch {
let collapsed = gtk::PropertyExpression::new(
adw::OverlaySplitView::static_type(),
None::<&gtk::Expression>,
"collapsed",
);
let shown = gtk::PropertyExpression::new(
adw::OverlaySplitView::static_type(),
None::<&gtk::Expression>,
"show-sidebar",
);
let visible = gtk::ClosureExpression::new::<bool>(
[collapsed, shown],
glib::closure!(|_: Option<glib::Object>, collapsed: bool, shown: bool| collapsed || !shown),
);
visible.bind(toggle, "visible", Some(split_view))
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
Loading