diff --git a/linux/changelog.d/4117.added.md b/linux/changelog.d/4117.added.md new file mode 100644 index 0000000000..d42214e84c --- /dev/null +++ b/linux/changelog.d/4117.added.md @@ -0,0 +1 @@ +The sidebar toggle stays in the header while the sidebar shows, so it collapses from there. diff --git a/linux/crates/app/src/ui/workspace/tests/shell.rs b/linux/crates/app/src/ui/workspace/tests/shell.rs index b264b074a4..40eb4cb9ca 100644 --- a/linux/crates/app/src/ui/workspace/tests/shell.rs +++ b/linux/crates/app/src/ui/workspace/tests/shell.rs @@ -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] diff --git a/linux/crates/app/src/ui/workspace/workspace_shell.rs b/linux/crates/app/src/ui/workspace/workspace_shell.rs index 25eb2ae449..e0e37cd61a 100644 --- a/linux/crates/app/src/ui/workspace/workspace_shell.rs +++ b/linux/crates/app/src/ui/workspace/workspace_shell.rs @@ -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))); @@ -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: >k::ToggleButton) -> gtk::ExpressionWatch { - let collapsed = gtk::PropertyExpression::new( - adw::OverlaySplitView::static_type(), - None::<>k::Expression>, - "collapsed", - ); - let shown = gtk::PropertyExpression::new( - adw::OverlaySplitView::static_type(), - None::<>k::Expression>, - "show-sidebar", - ); - let visible = gtk::ClosureExpression::new::( - [collapsed, shown], - glib::closure!(|_: Option, collapsed: bool, shown: bool| collapsed || !shown), - ); - visible.bind(toggle, "visible", Some(split_view)) -} - #[cfg(test)] mod tests { use super::*;