Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
33813ba
feat(linux-browse): switch a table tab between Data and Structure fro…
sedax90 Nov 8, 2026
340e9ca
docs(linux-browse): add the changelog entry
sedax90 Nov 8, 2026
6d73a7c
fix(linux-browse): route table commands by selected view
datlechin Nov 8, 2026
4c31e38
fix(linux-browse): protect structure drafts during reloads
datlechin Nov 8, 2026
4ee4c26
fix(linux-browse): keep table commands reachable in narrow tabs
datlechin Nov 8, 2026
2816b11
refactor(linux-browse): group workspace save requests
datlechin Nov 8, 2026
9fb78f6
test(linux-browse): exercise refresh guards during valid saves
datlechin Nov 8, 2026
e703e58
test(linux-browse): bound structure save frame waits
datlechin Nov 8, 2026
bcc5d79
test(linux-browse): pass the owned window to the frame wait
datlechin Nov 8, 2026
6bd9152
test(linux-browse): report refresh save wait state
datlechin Nov 8, 2026
560c913
test(linux-browse): use typed columns in row save fixtures
datlechin Nov 8, 2026
bc0e6d8
Merge remote-tracking branch 'origin/main' into feat/linux-browse-str…
datlechin Nov 9, 2026
3fb1996
fix(linux-workspace): drop the line-count expectation the shorter upd…
datlechin Nov 9, 2026
75d7a53
Merge remote-tracking branch 'origin/main' into feat/linux-browse-str…
datlechin Nov 9, 2026
1d29b84
Merge remote-tracking branch 'origin/main' into feat/linux-browse-str…
datlechin Nov 9, 2026
eb4f801
Merge remote-tracking branch 'origin/main' into feat/linux-browse-str…
datlechin Nov 9, 2026
6f8ac50
fix(linux-grid): pass the NULL text to the row details field search
datlechin Nov 9, 2026
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
4 changes: 2 additions & 2 deletions linux/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ See [docs/state-management.md](docs/state-management.md) for the patterns and na
Every key the app binds or relies on is one `Accelerator` in `ACCELERATORS` (`crates/app/src/application/accelerators.rs`): the action it fires, its triggers, its `AcceleratorScope` and where the shortcuts dialog lists it.

- **Application** keys go in with `set_accels_for_action` at startup. GtkWindow runs them in the capture phase, before the focused widget, so none of them is a key a text field or a list uses.
- **Local** keys are a `local_shortcut_controller(owner)` on the owner's widget, firing the owner's action group through `NamedAction`: `browse` on a table tab, `grid` on a data grid's column view (two owners, one per phase), `editor` on the SQL editor's source view and, for find and replace, on the whole editor tab, `structure`, `filter`, the sidebar's list, which opens the selected table's menu, the query history's list, which opens the focused row's menu, and a picker row, which opens its menu. A disabled action lets its key go on. Bubble phase leaves a text field inside the owner its own Ctrl+Z and Ctrl+C; the source view's keys run in the capture phase, because GtkTextView binds Ctrl+/ itself.
- **Local** keys are a `local_shortcut_controller(owner)` on the owner's widget, firing the owner's action group through `NamedAction`: `table` for a table tab’s selected view and `browse` for its rows, `grid` on a data grid's column view (two owners, one per phase), `editor` on the SQL editor's source view and, for find and replace, on the whole editor tab, `structure`, `filter`, the sidebar's list, which opens the selected table's menu, the query history's list, which opens the focused row's menu, and a picker row, which opens its menu. A disabled action lets its key go on. Bubble phase leaves a text field inside the owner its own Ctrl+Z and Ctrl+C; the source view's keys run in the capture phase, because GtkTextView binds Ctrl+/ itself.
- **Component** keys are bound by a component's own controller (the grid's inline and detail pane editors), which reads them from the table through `component_trigger` or `component_matches`.
- **Stock** keys belong to GTK or libadwaita: GtkListBase's selection and movement, AdwTabView's tab switching, AdwApplication's Ctrl+?. The workspace removes AdwTabView's Ctrl+Home and Ctrl+End pairs so the lists and the editor in its tabs keep them.

Expand Down Expand Up @@ -150,7 +150,7 @@ pub enum WorkspaceTab {
}
```

A table's structure opens in a Structure tab of its own. Saving a new table closes its Structure tab and opens a Table tab on it. A schema's ER diagram opens in a Diagram tab, one per schema: it reads each table's columns, foreign keys and indexes on one connection lease, two tables at a time, and draws the cards and lines on a canvas of its own (`crates/app/src/ui/diagram/`), with a focusable `DiagramNode` where each card is so the keyboard and a screen reader reach the tables. Its record keeps the schema and where the user moved tables, so a restore reads the tables again, lays them out and puts the moved ones back.
A table's structure opens inside its Table tab or in an Edit Structure tab of its own ([state-management.md](docs/state-management.md#tabs)). Saving a new table closes its Structure tab and opens a Table tab on it. A schema's ER diagram opens in a Diagram tab, one per schema: it reads each table's columns, foreign keys and indexes on one connection lease, two tables at a time, and draws the cards and lines on a canvas of its own (`crates/app/src/ui/diagram/`), with a focusable `DiagramNode` where each card is so the keyboard and a screen reader reach the tables. Its record keeps the schema and where the user moved tables, so a restore reads the tables again, lays them out and puts the moved ones back.

Each tab is a gtk-rs widget with a composite template, which the `AdwTabView` adopts. The workspace keeps a `HashMap<Uuid, WorkspaceTab>` keyed by the tab's UUID; the canonical display order comes from `tab_view.pages()` (drag-reorderable). A `TabIndex` maps each `AdwTabPage` to its tab's UUID, so close and right-click actions can recover it. `TabFactory` builds every tab from a `TabSpec`, whether the sidebar, the overview's new-tab button, a restore or a reopen asks for it. Every tab's title comes from its `TabIdentity` through `resolve_tab_title`, and the window's from the tab in front through `resolve_window_title`. A tab that closing would lose something in shows `document-modified-symbolic` as its page icon, as GNOME Text Editor does; its title never changes for it.

Expand Down
1 change: 1 addition & 0 deletions linux/changelog.d/4108.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Switch between Data and Structure from a table tab’s bottom bar while keeping unsaved changes in each view.
4 changes: 2 additions & 2 deletions linux/crates/app/src/application/accelerators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ pub const ACCELERATORS: &[Accelerator] = &[
local(
BrowseTab,
BUBBLE,
"browse.refresh",
"table.refresh",
&["F5", "<Primary>r"],
Listed(BrowseTable),
),
local(BrowseTab, BUBBLE, "browse.save", &["<Primary>s"], Listed(BrowseTable)),
local(BrowseTab, BUBBLE, "table.save", &["<Primary>s"], Listed(BrowseTable)),
local(BrowseTab, BUBBLE, "browse.undo", &["<Primary>z"], Listed(BrowseTable)),
local(
BrowseTab,
Expand Down
29 changes: 26 additions & 3 deletions linux/crates/app/src/ui/browse_tab/browse_actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,13 @@ pub(super) fn install_browse_actions(tab: &BrowseTab, page_size: u64) -> BrowseA
}
});
group.add_action(&page_size);
add("refresh", || PagingInput::RequestRefresh.into());
let first = add("first-page", || PagingInput::FirstPage.into());
let previous = add("previous-page", || PagingInput::PrevPage.into());
let next = add("next-page", || PagingInput::NextPage.into());
tab.imp().pager_bar.follow_page_actions(ACTION_GROUP, &previous, &next);
let last = add("last-page", || PagingInput::LastPage.into());
tab.imp()
.pager_bar
.follow_page_actions(ACTION_GROUP, &first, &previous, &next, &last);
let actions = BrowseActions {
save: add("save", || SaveInput::CommitSave.into()),
undo: add("undo", || GridInput::Undo.into()),
Expand All @@ -76,8 +79,10 @@ pub(super) fn install_browse_actions(tab: &BrowseTab, page_size: u64) -> BrowseA
for action in [&actions.save, &actions.undo, &actions.redo, &actions.count_rows] {
action.set_enabled(false);
}
tab.imp().pending_bar.announce_save_keys(ACTION_GROUP, &actions.save);
tab.imp().pending_bar.announce_save_keys("table", &actions.save);
tab.insert_action_group(ACTION_GROUP, Some(&group));
let _ = tab.imp().browse_actions.set(group);
install_view_actions(tab);
tab.add_controller(local_shortcut_controller(ShortcutOwner::BrowseTab));
actions
}
Expand All @@ -101,3 +106,21 @@ pub(super) fn describe_buttons(tab: &BrowseTab) {
announce_key_shortcuts(&imp.filter_button.get(), "browse.filter");
announce_key_shortcuts(&imp.details_toggle.get(), "grid.show-details");
}

fn install_view_actions(tab: &BrowseTab) {
let group = gio::SimpleActionGroup::new();
for (name, callback) in [
("save", BrowseTab::save_selected_view as fn(&BrowseTab)),
("refresh", BrowseTab::refresh_selected_view),
] {
let action = gio::SimpleAction::new(name, None);
let weak = tab.downgrade();
action.connect_activate(move |_, _| {
if let Some(tab) = weak.upgrade() {
callback(&tab);
}
});
group.add_action(&action);
}
tab.insert_action_group("table", Some(&group));
}
25 changes: 23 additions & 2 deletions linux/crates/app/src/ui/browse_tab/data_handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,27 @@ impl BrowseModel {
self.begin_read(fx);
self.reload_from_columns(ColumnFreshness::Refetch);
}
DataInput::Renamed(name) => {
self.grid.commit_edit();
self.sequencer.cancel_all();
self.table = name;
if let Some(connection) = self.connection_id {
self.filter_settings.set_filters(
connection,
self.schema.as_deref(),
&self.table,
self.current_filter.clone(),
);
}
self.grid.rename_table(&self.table);
let delta = self.tracker.set_target(SaveTarget {
table: self.table_ref(),
columns: self.current_columns.clone(),
});
self.grid.apply_delta(&delta);
self.reload(fx);
fx.output(BrowseTabOutput::StateChanged);
}
DataInput::Command(command) => self.on_command(*command, fx),
DataInput::LinkChanged(generation) => self.on_link_changed(generation, fx),
DataInput::SchemaChanged => {
Expand Down Expand Up @@ -113,8 +134,8 @@ impl BrowseModel {
/// The grid's actions reach the tab's buttons only while its rows are
/// on screen: rows behind the loading or the error page are not what
/// the table holds under the tab's filter.
fn show_grid_actions(&mut self) {
let shown = self.load.has_content();
pub(super) fn show_grid_actions(&mut self) {
let shown = self.load.has_content() && self.this.upgrade().is_some_and(|tab| !tab.shows_structure());
if self.grid_actions_shown == shown {
return;
}
Expand Down
1 change: 1 addition & 0 deletions linux/crates/app/src/ui/browse_tab/data_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use super::BrowseCommand;
#[derive(Debug)]
pub(crate) enum DataInput {
Start,
Renamed(String),
// Replies own page data; keep that payload out of every queued input.
Command(Box<BrowseCommand>),
LinkChanged(LinkGeneration),
Expand Down
13 changes: 13 additions & 0 deletions linux/crates/app/src/ui/browse_tab/imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ pub struct BrowseTab {
#[template_child]
pub no_pk_banner: TemplateChild<adw::Banner>,
#[template_child]
pub view_stack: TemplateChild<adw::ViewStack>,
#[template_child]
pub structure_host: TemplateChild<adw::Bin>,
#[template_child]
pub view_toggle: TemplateChild<adw::InlineViewSwitcher>,
#[template_child]
pub data_start: TemplateChild<gtk::Box>,
#[template_child]
pub data_end: TemplateChild<gtk::Box>,
#[template_child]
pub inner_stack: TemplateChild<gtk::Stack>,
#[template_child]
pub loading_page: TemplateChild<adw::StatusPage>,
Expand Down Expand Up @@ -65,6 +75,8 @@ pub struct BrowseTab {
/// The tab's one grid, reachable while an input is being handled
/// and the model is borrowed.
pub(super) grid: OnceCell<DataGrid>,
pub(super) browse_actions: OnceCell<gtk::gio::SimpleActionGroup>,
pub(super) structure_requested: Cell<bool>,
pub(super) model: RefCell<Option<BrowseModel>>,
pub(super) queue: RefCell<VecDeque<BrowseTabInput>>,
pub(super) dispatching: Cell<bool>,
Expand Down Expand Up @@ -111,6 +123,7 @@ impl ObjectImpl for BrowseTab {
.param_types([bool::static_type()])
.build(),
Signal::builder("save-requested").build(),
Signal::builder("structure-requested").build(),
Signal::builder("loading-changed")
.param_types([bool::static_type()])
.build(),
Expand Down
13 changes: 10 additions & 3 deletions linux/crates/app/src/ui/browse_tab/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ pub(super) fn build(tab: &BrowseTab, init: &LayoutInit<'_>) -> BrowseTabWidgets
}
}

/// What the bottom bar holds past the tab's breakpoint, where it has no
/// room for it.
fn more_menu(page_sizes: &[u64]) -> gio::Menu {
let export = gio::MenuItem::new(Some(&gettext("_Export Rows…")), Some("browse.export"));
// The window's Export Results key reaches this tab's Export.
Expand All @@ -80,8 +78,17 @@ fn more_menu(page_sizes: &[u64]) -> gio::Menu {
item.set_action_and_target_value(Some("browse.page-size"), Some(&size.to_variant()));
sizes.append_item(&item);
}
let rows = gio::Menu::new();
rows.append(Some(&gettext("_Insert Row")), Some("grid.insert-row"));
rows.append(Some(&gettext("_Delete Selected Rows")), Some("grid.delete-rows"));
rows.append(Some(&gettext("_Row Details")), Some("grid.show-details"));
let pages = gio::Menu::new();
pages.append(Some(&gettext("First _Page")), Some("browse.first-page"));
pages.append(Some(&gettext("_Last Page")), Some("browse.last-page"));
let menu = gio::Menu::new();
menu.append_section(None, &actions);
menu.append_section(None, &rows);
menu.append_section(None, &pages);
menu.append_section(Some(&gettext("Rows per Page")), &sizes);
menu
}
Expand Down Expand Up @@ -159,7 +166,7 @@ pub(super) fn grid(tab: &BrowseTab, init: GridInit) -> DataGrid {
grid.set_hexpand(true);
let imp = tab.imp();
imp.grid_holder.append(&grid);
imp.action_bar.pack_start(&grid.selection_summary());
imp.data_start.append(&grid.selection_summary());
let _ = imp.grid.set(grid.clone());
connect_grid(tab, &grid);
grid
Expand Down
76 changes: 76 additions & 0 deletions linux/crates/app/src/ui/browse_tab/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,10 @@ impl BrowseTab {
.unwrap_or_default()
}

pub fn rename_table(&self, name: &str) {
self.send(DataInput::Renamed(name.to_owned()));
}

pub fn table(&self) -> String {
self.read(|model| model.table.clone()).unwrap_or_default()
}
Expand Down Expand Up @@ -388,6 +392,78 @@ impl BrowseTab {
self.connect_closure("save-requested", false, glib::closure_local!(move |tab: &Self| f(tab)))
}

pub fn connect_structure_requested<F: Fn(&Self) + 'static>(&self, f: F) -> glib::SignalHandlerId {
self.connect_closure(
"structure-requested",
false,
glib::closure_local!(move |tab: &Self| f(tab)),
)
}

pub fn offer_structure(&self) {
let imp = self.imp();
imp.view_toggle.set_visible(true);
let tab = self.downgrade();
imp.view_stack.connect_visible_child_name_notify(move |_| {
if let Some(tab) = tab.upgrade() {
tab.follow_selected_view();
}
});
}

pub fn set_structure(&self, structure: &crate::ui::structure_tab::StructureTab) {
libadwaita::prelude::BinExt::set_child(&*self.imp().structure_host, Some(structure));
}

pub fn structure_tab(&self) -> Option<crate::ui::structure_tab::StructureTab> {
libadwaita::prelude::BinExt::child(&*self.imp().structure_host)?
.downcast()
.ok()
}

pub fn shows_structure(&self) -> bool {
self.imp().view_stack.visible_child_name().as_deref() == Some("structure")
}

fn follow_selected_view(&self) {
let imp = self.imp();
let structure = self.shows_structure();
// Finish an open cell before hiding its editor, so close and Save see the draft.
if structure {
self.commit_cell_edit();
}
if structure && !imp.structure_requested.replace(true) {
self.emit_by_name::<()>("structure-requested", &[]);
}
imp.data_start.set_visible(!structure);
imp.data_end.set_visible(!structure);
let actions = imp.browse_actions.get().filter(|_| !structure);
self.insert_action_group("browse", actions);
if let Some(model) = imp.model.borrow_mut().as_mut() {
model.show_grid_actions();
}
}

fn save_selected_view(&self) {
if self.shows_structure() {
if let Some(structure) = self.structure_tab() {
let _ = structure.activate_action("structure.save", None);
}
} else {
let _ = self.activate_action("browse.save", None);
}
}

fn refresh_selected_view(&self) {
if self.shows_structure() {
if let Some(structure) = self.structure_tab() {
structure.request_refresh();
}
} else {
self.send(PagingInput::RequestRefresh);
}
}

/// F5 asked the window to read the tab again.
pub fn connect_refresh_requested<F: Fn(&Self) + 'static>(&self, f: F) -> glib::SignalHandlerId {
self.connect_closure(
Expand Down
Loading
Loading