From 58905c15a03e85cbc72659c168869fc550c9518c Mon Sep 17 00:00:00 2001 From: sedax90 <5001801+sedax90@users.noreply.github.com> Date: Sun, 8 Nov 2026 13:50:30 +0100 Subject: [PATCH 1/6] feat(linux-workspace): show the connection's Safe Mode level in the header --- linux/crates/app/src/ui/icons.rs | 3 +++ .../app/src/ui/session_window/tests/mod.rs | 27 +++++++++++++++++++ .../src/ui/session_window/window_actions.rs | 3 +++ .../app/src/ui/workspace/workspace_shell.rs | 27 ++++++++++++++++++- .../src/ui/workspace/workspace_shell_imp.rs | 2 ++ linux/data/resources/ui/workspace-shell.ui | 8 ++++++ 6 files changed, 69 insertions(+), 1 deletion(-) diff --git a/linux/crates/app/src/ui/icons.rs b/linux/crates/app/src/ui/icons.rs index aa2c179ddf..b984c3d17f 100644 --- a/linux/crates/app/src/ui/icons.rs +++ b/linux/crates/app/src/ui/icons.rs @@ -7,6 +7,8 @@ pub const APPLICATIONS_ENGINEERING: &str = "applications-engineering-symbolic"; pub const APPLICATIONS_SCIENCE: &str = "applications-science-symbolic"; /// Bundled: a speech bubble, for the AI assistant. pub const ASSISTANT: &str = "assistant-symbolic"; +/// An open lock, for a connection that asks only before what destroys. +pub const CHANGES_ALLOW: &str = "changes-allow-symbolic"; pub const CHANGES_PREVENT: &str = "changes-prevent-symbolic"; pub const COMPUTER: &str = "computer-symbolic"; pub const DIALOG_ERROR: &str = "dialog-error-symbolic"; @@ -88,6 +90,7 @@ pub const ALL: &[&str] = &[ APPLICATIONS_ENGINEERING, APPLICATIONS_SCIENCE, ASSISTANT, + CHANGES_ALLOW, CHANGES_PREVENT, COMPUTER, DIALOG_ERROR, diff --git a/linux/crates/app/src/ui/session_window/tests/mod.rs b/linux/crates/app/src/ui/session_window/tests/mod.rs index 86d2581e36..c64da03259 100644 --- a/linux/crates/app/src/ui/session_window/tests/mod.rs +++ b/linux/crates/app/src/ui/session_window/tests/mod.rs @@ -526,6 +526,33 @@ fn read_only_from_the_main_menu_saves_it_and_connects_again_read_only() { wait_until(WAIT, || ticked_level(&test).as_deref() == Some("read-only")).expect("Read-Only ticked"); } +/// The header's lock names the level of the connection in front, as the +/// macOS toolbar's does, and is not there without one. +#[gtk4::test] +fn the_header_lock_follows_the_front_connections_level() { + let test = TestWindow::connected("SafeModeButton"); + let button = test.window.shell().expect("the shell").imp().safe_mode_button.get(); + + assert!(button.is_visible()); + assert_eq!(button.icon_name().as_deref(), Some("changes-allow-symbolic")); + assert_eq!(button.tooltip_text().as_deref(), Some("Safe Mode: Off")); + + pick_level(&test, "confirm-writes"); + wait_until(WAIT, || { + button.tooltip_text().as_deref() == Some("Safe Mode: Confirm Writes") + }) + .expect("the lock to name the new level"); + assert_eq!(button.icon_name().as_deref(), Some("changes-prevent-symbolic")); + + let picker = TestWindow::picker("SafeModeButtonPicker"); + assert!( + picker + .window + .shell() + .is_none_or(|shell| !shell.imp().safe_mode_button.is_visible()) + ); +} + #[gtk4::test] fn the_levels_are_off_without_a_session() { let test = TestWindow::picker("SafeModePicker"); diff --git a/linux/crates/app/src/ui/session_window/window_actions.rs b/linux/crates/app/src/ui/session_window/window_actions.rs index f5a3c22ef3..0715668101 100644 --- a/linux/crates/app/src/ui/session_window/window_actions.rs +++ b/linux/crates/app/src/ui/session_window/window_actions.rs @@ -150,6 +150,9 @@ pub(super) fn show_safe_mode(window: &adw::ApplicationWindow, level: Option().and_then(SessionWindow::shell) { + shell.show_safe_mode(level); + } if let Some(level) = level { action.set_state(&crate::ui::safe_mode::action_target(level).to_variant()); } diff --git a/linux/crates/app/src/ui/workspace/workspace_shell.rs b/linux/crates/app/src/ui/workspace/workspace_shell.rs index 25eb2ae449..ecf8f5340a 100644 --- a/linux/crates/app/src/ui/workspace/workspace_shell.rs +++ b/linux/crates/app/src/ui/workspace/workspace_shell.rs @@ -98,6 +98,7 @@ impl WorkspaceShell { menu_button.set_menu_model(Some(&with_safe_mode(&menu))); } imp.sidebar_header.pack_end(&menu_button); + imp.safe_mode_button.set_menu_model(Some(&safe_mode_levels())); super::workspace_actions::install(window, &shell); imp.history_gate @@ -534,6 +535,25 @@ impl WorkspaceShell { /// Show the front's banners and assistant, and name what follows its /// data model after it. The expressions of `bind_front` do the rest. + /// The header's lock names the front connection's Safe Mode level and + /// opens the levels, or leaves with no session in front. + pub(crate) fn show_safe_mode(&self, level: Option) { + let button = self.imp().safe_mode_button.get(); + button.set_visible(level.is_some()); + let Some(level) = level else { + return; + }; + button.set_icon_name(match level { + tablepro_core::SafeModeLevel::Off => crate::ui::icons::CHANGES_ALLOW, + tablepro_core::SafeModeLevel::ConfirmWrites | tablepro_core::SafeModeLevel::ReadOnly => { + crate::ui::icons::CHANGES_PREVENT + } + }); + let said = gettext_f("Safe Mode: {level}", &[("level", &crate::ui::safe_mode::label(level))]); + button.set_tooltip_text(Some(&said)); + button.update_property(&[gtk::accessible::Property::Label(&said)]); + } + fn on_front_changed(&self) { let imp = self.imp(); if let Some(front) = self.front() { @@ -760,7 +780,7 @@ fn tab_menu() -> gio::Menu { /// The main menu with the session's Safe Mode levels on top, as radio /// items of the window's stateful `safe-mode` action. -fn with_safe_mode(menu: &gio::MenuModel) -> gio::Menu { +fn safe_mode_levels() -> gio::Menu { let levels = gio::Menu::new(); for level in tablepro_core::SafeModeLevel::ALL { let item = gio::MenuItem::new(Some(&crate::ui::safe_mode::menu_label(level)), None); @@ -770,6 +790,11 @@ fn with_safe_mode(menu: &gio::MenuModel) -> gio::Menu { ); levels.append_item(&item); } + levels +} + +fn with_safe_mode(menu: &gio::MenuModel) -> gio::Menu { + let levels = safe_mode_levels(); let section = gio::Menu::new(); section.append_submenu(Some(&gettext("_Safe Mode")), &levels); let whole = gio::Menu::new(); diff --git a/linux/crates/app/src/ui/workspace/workspace_shell_imp.rs b/linux/crates/app/src/ui/workspace/workspace_shell_imp.rs index 0b88179f47..0f0e1e02ad 100644 --- a/linux/crates/app/src/ui/workspace/workspace_shell_imp.rs +++ b/linux/crates/app/src/ui/workspace/workspace_shell_imp.rs @@ -83,6 +83,8 @@ pub struct WorkspaceShell { #[template_child] pub assistant_toggle: TemplateChild, #[template_child] + pub safe_mode_button: TemplateChild, + #[template_child] pub tab_button: TemplateChild, #[template_child] pub export_operations_button: TemplateChild, diff --git a/linux/data/resources/ui/workspace-shell.ui b/linux/data/resources/ui/workspace-shell.ui index 040ecb5aee..80694bb2ca 100644 --- a/linux/data/resources/ui/workspace-shell.ui +++ b/linux/data/resources/ui/workspace-shell.ui @@ -150,6 +150,14 @@ + + + + changes-allow-symbolic + false + + assistant-symbolic From db6aefd447a264d11a6d9909adadccd5a0f621cd Mon Sep 17 00:00:00 2001 From: sedax90 <5001801+sedax90@users.noreply.github.com> Date: Sun, 8 Nov 2026 13:51:54 +0100 Subject: [PATCH 2/6] docs(linux-workspace): add the changelog entry --- linux/changelog.d/4124.added.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 linux/changelog.d/4124.added.md diff --git a/linux/changelog.d/4124.added.md b/linux/changelog.d/4124.added.md new file mode 100644 index 0000000000..e5c64958c4 --- /dev/null +++ b/linux/changelog.d/4124.added.md @@ -0,0 +1 @@ +The header has a lock that shows the connection's Safe Mode level and changes it. From 520978e07489c3d56b40f4db763193955ab1f1b3 Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Sun, 8 Nov 2026 23:32:59 +0700 Subject: [PATCH 3/6] test(linux-workspace): cover header safe mode across sessions --- linux/crates/app/src/ui/icons.rs | 1 - .../app/src/ui/session_window/tests/mod.rs | 30 +++++++++++++++++-- .../src/ui/session_window/tests/sessions.rs | 9 ++++++ .../app/src/ui/workspace/workspace_shell.rs | 9 +----- linux/data/resources/ui/workspace-shell.ui | 2 -- 5 files changed, 38 insertions(+), 13 deletions(-) diff --git a/linux/crates/app/src/ui/icons.rs b/linux/crates/app/src/ui/icons.rs index b984c3d17f..c6951bbc82 100644 --- a/linux/crates/app/src/ui/icons.rs +++ b/linux/crates/app/src/ui/icons.rs @@ -7,7 +7,6 @@ pub const APPLICATIONS_ENGINEERING: &str = "applications-engineering-symbolic"; pub const APPLICATIONS_SCIENCE: &str = "applications-science-symbolic"; /// Bundled: a speech bubble, for the AI assistant. pub const ASSISTANT: &str = "assistant-symbolic"; -/// An open lock, for a connection that asks only before what destroys. pub const CHANGES_ALLOW: &str = "changes-allow-symbolic"; pub const CHANGES_PREVENT: &str = "changes-prevent-symbolic"; pub const COMPUTER: &str = "computer-symbolic"; diff --git a/linux/crates/app/src/ui/session_window/tests/mod.rs b/linux/crates/app/src/ui/session_window/tests/mod.rs index c64da03259..405a5f5c9f 100644 --- a/linux/crates/app/src/ui/session_window/tests/mod.rs +++ b/linux/crates/app/src/ui/session_window/tests/mod.rs @@ -526,13 +526,29 @@ fn read_only_from_the_main_menu_saves_it_and_connects_again_read_only() { wait_until(WAIT, || ticked_level(&test).as_deref() == Some("read-only")).expect("Read-Only ticked"); } -/// The header's lock names the level of the connection in front, as the -/// macOS toolbar's does, and is not there without one. #[gtk4::test] fn the_header_lock_follows_the_front_connections_level() { let test = TestWindow::connected("SafeModeButton"); let button = test.window.shell().expect("the shell").imp().safe_mode_button.get(); + crate::test_support::assert_labelled(&button).expect("the lock has an accessible name"); + let menu = button.menu_model().expect("the level chooser"); + assert_eq!(menu.n_items(), 3); + for (index, target) in ["off", "confirm-writes", "read-only"].into_iter().enumerate() { + let index = i32::try_from(index).expect("three levels"); + assert_eq!( + menu.item_attribute_value(index, gio::MENU_ATTRIBUTE_ACTION, None) + .and_then(|value| value.get::()) + .as_deref(), + Some("win.safe-mode") + ); + assert_eq!( + menu.item_attribute_value(index, gio::MENU_ATTRIBUTE_TARGET, None) + .and_then(|value| value.get::()) + .as_deref(), + Some(target) + ); + } assert!(button.is_visible()); assert_eq!(button.icon_name().as_deref(), Some("changes-allow-symbolic")); assert_eq!(button.tooltip_text().as_deref(), Some("Safe Mode: Off")); @@ -544,6 +560,16 @@ fn the_header_lock_follows_the_front_connections_level() { .expect("the lock to name the new level"); assert_eq!(button.icon_name().as_deref(), Some("changes-prevent-symbolic")); + pick_level(&test, "read-only"); + wait_until(WAIT, || ticked_level(&test).as_deref() == Some("read-only")).expect("Read-Only after reconnect"); + let shell = test.window.shell().expect("the reopened shell"); + let button = shell.imp().safe_mode_button.get(); + assert_eq!(button.tooltip_text().as_deref(), Some("Safe Mode: Read-Only")); + assert_eq!(button.icon_name().as_deref(), Some("changes-prevent-symbolic")); + crate::test_support::assert_labelled(&button).expect("the reopened lock is named"); + shell.show_safe_mode(None); + assert!(!button.is_visible()); + let picker = TestWindow::picker("SafeModeButtonPicker"); assert!( picker diff --git a/linux/crates/app/src/ui/session_window/tests/sessions.rs b/linux/crates/app/src/ui/session_window/tests/sessions.rs index e184a61059..9ae9238464 100644 --- a/linux/crates/app/src/ui/session_window/tests/sessions.rs +++ b/linux/crates/app/src/ui/session_window/tests/sessions.rs @@ -336,6 +336,15 @@ fn a_safe_mode_level_goes_to_the_session_it_was_picked_for() { Some(tablepro_core::SafeModeLevel::Off), "the level moved another connection" ); + let button = shell.imp().safe_mode_button.get(); + wait_until(WAIT, || button.tooltip_text().as_deref() == Some("Safe Mode: Off")) + .expect("the header to keep naming the other session"); + shell.tab_view().set_selected_page(&first_tab); + wait_until(WAIT, || { + button.tooltip_text().as_deref() == Some("Safe Mode: Confirm Writes") + }) + .expect("the header to follow the selected session"); + assert_eq!(super::ticked_level(&test).as_deref(), Some("confirm-writes")); } #[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 ecf8f5340a..75365c6b86 100644 --- a/linux/crates/app/src/ui/workspace/workspace_shell.rs +++ b/linux/crates/app/src/ui/workspace/workspace_shell.rs @@ -533,10 +533,6 @@ impl WorkspaceShell { self.notify_front(); } - /// Show the front's banners and assistant, and name what follows its - /// data model after it. The expressions of `bind_front` do the rest. - /// The header's lock names the front connection's Safe Mode level and - /// opens the levels, or leaves with no session in front. pub(crate) fn show_safe_mode(&self, level: Option) { let button = self.imp().safe_mode_button.get(); button.set_visible(level.is_some()); @@ -550,8 +546,7 @@ impl WorkspaceShell { } }); let said = gettext_f("Safe Mode: {level}", &[("level", &crate::ui::safe_mode::label(level))]); - button.set_tooltip_text(Some(&said)); - button.update_property(&[gtk::accessible::Property::Label(&said)]); + describe_icon_button(&button, &said, None); } fn on_front_changed(&self) { @@ -778,8 +773,6 @@ fn tab_menu() -> gio::Menu { menu } -/// The main menu with the session's Safe Mode levels on top, as radio -/// items of the window's stateful `safe-mode` action. fn safe_mode_levels() -> gio::Menu { let levels = gio::Menu::new(); for level in tablepro_core::SafeModeLevel::ALL { diff --git a/linux/data/resources/ui/workspace-shell.ui b/linux/data/resources/ui/workspace-shell.ui index 80694bb2ca..6a432987d0 100644 --- a/linux/data/resources/ui/workspace-shell.ui +++ b/linux/data/resources/ui/workspace-shell.ui @@ -151,8 +151,6 @@ - changes-allow-symbolic false From 52481d8d487260487936e85163c7444ff667a761 Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Sun, 8 Nov 2026 23:34:14 +0700 Subject: [PATCH 4/6] fix(linux-workspace): name safe mode before a session opens --- linux/crates/app/src/ui/workspace/workspace_shell.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/linux/crates/app/src/ui/workspace/workspace_shell.rs b/linux/crates/app/src/ui/workspace/workspace_shell.rs index 75365c6b86..1f466ea2d1 100644 --- a/linux/crates/app/src/ui/workspace/workspace_shell.rs +++ b/linux/crates/app/src/ui/workspace/workspace_shell.rs @@ -42,6 +42,7 @@ glib::wrapper! { pub(super) fn describe_buttons(shell: &WorkspaceShell) { let imp = shell.imp(); describe_icon_button(&imp.table_search_toggle.get(), &gettext("Search"), None); + describe_icon_button(&imp.safe_mode_button.get(), &gettext("Safe Mode"), None); describe_icon_button( &imp.refresh_tables_button.get(), &gettext("Refresh"), From d87bc1441a8f95cf4cb8fdb8f66a8fc9fbdc60f6 Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Tue, 10 Nov 2026 04:36:05 +0700 Subject: [PATCH 5/6] fix(linux-workspace): leave the Safe Mode lock out of the narrow header --- .../app/src/ui/workspace/tests/shell.rs | 23 +++++++++++++++++++ .../src/ui/workspace/workspace_shell_imp.rs | 2 ++ linux/data/resources/ui/workspace-shell.ui | 14 ++++++++--- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/linux/crates/app/src/ui/workspace/tests/shell.rs b/linux/crates/app/src/ui/workspace/tests/shell.rs index 2b04b90626..ff8a962f99 100644 --- a/linux/crates/app/src/ui/workspace/tests/shell.rs +++ b/linux/crates/app/src/ui/workspace/tests/shell.rs @@ -233,6 +233,29 @@ fn narrow_window_swaps_tab_bar_for_tab_button() { wait_until(WAIT, || button.popover().is_some_and(|menu| menu.is_mapped())).expect("the narrow menu opens"); } +#[gtk4::test] +fn the_safe_mode_lock_leaves_the_narrow_header_to_the_session_menu() { + for (name, width, height, shown) in [("NarrowLock", 360, 294, false), ("WideLock", 1200, 760, true)] { + let test = sized(name, width, height); + let workspace = test.workspace(); + let shell = shell_of(&workspace); + let imp = shell.imp(); + let narrow = (!shown).then(|| imp.narrow_breakpoint.get()); + wait_until(Duration::from_secs(2), || { + imp.breakpoint_bin.width() > 0 && imp.breakpoint_bin.current_breakpoint() == narrow + }) + .expect("the breakpoint for the width"); + wait_until(WAIT, || imp.safe_mode_button.is_visible()).expect("the connection's level"); + assert_eq!(imp.safe_mode_slot.is_visible(), shown, "{name}"); + shell.show_safe_mode(Some(tablepro_core::SafeModeLevel::ReadOnly)); + assert_eq!( + imp.safe_mode_slot.is_visible(), + shown, + "a level change kept the {name} layout" + ); + } +} + #[gtk4::test] fn wide_window_shows_tab_bar() { let test = sized("Wide", 1200, 760); diff --git a/linux/crates/app/src/ui/workspace/workspace_shell_imp.rs b/linux/crates/app/src/ui/workspace/workspace_shell_imp.rs index 82cb13e0d2..1a96a32da8 100644 --- a/linux/crates/app/src/ui/workspace/workspace_shell_imp.rs +++ b/linux/crates/app/src/ui/workspace/workspace_shell_imp.rs @@ -87,6 +87,8 @@ pub struct WorkspaceShell { #[template_child] pub assistant_toggle: TemplateChild, #[template_child] + pub safe_mode_slot: TemplateChild, + #[template_child] pub safe_mode_button: TemplateChild, #[template_child] pub tab_button: TemplateChild, diff --git a/linux/data/resources/ui/workspace-shell.ui b/linux/data/resources/ui/workspace-shell.ui index 8f69e961ce..cd558698eb 100644 --- a/linux/data/resources/ui/workspace-shell.ui +++ b/linux/data/resources/ui/workspace-shell.ui @@ -45,6 +45,8 @@ false + + false @@ -182,9 +184,15 @@ - - changes-allow-symbolic - false + + + + + changes-allow-symbolic + false + + From a8e5286819503d5bd8c4e79db7713cd22eddca75 Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Tue, 10 Nov 2026 15:47:57 +0700 Subject: [PATCH 6/6] test(linux-workspace): wait for the lock's own flag while the narrow slot hides it --- linux/crates/app/src/ui/workspace/tests/shell.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/linux/crates/app/src/ui/workspace/tests/shell.rs b/linux/crates/app/src/ui/workspace/tests/shell.rs index ff8a962f99..dde902900f 100644 --- a/linux/crates/app/src/ui/workspace/tests/shell.rs +++ b/linux/crates/app/src/ui/workspace/tests/shell.rs @@ -245,11 +245,12 @@ fn the_safe_mode_lock_leaves_the_narrow_header_to_the_session_menu() { imp.breakpoint_bin.width() > 0 && imp.breakpoint_bin.current_breakpoint() == narrow }) .expect("the breakpoint for the width"); - wait_until(WAIT, || imp.safe_mode_button.is_visible()).expect("the connection's level"); - assert_eq!(imp.safe_mode_slot.is_visible(), shown, "{name}"); + // is_visible also reads the slot, which the narrow breakpoint hides. + wait_until(WAIT, || imp.safe_mode_button.get_visible()).expect("the connection's level"); + assert_eq!(imp.safe_mode_button.is_visible(), shown, "{name}"); shell.show_safe_mode(Some(tablepro_core::SafeModeLevel::ReadOnly)); assert_eq!( - imp.safe_mode_slot.is_visible(), + imp.safe_mode_button.is_visible(), shown, "a level change kept the {name} layout" );