Skip to content

Commit 59ce1b0

Browse files
authored
fix(linux): seek paging, lazy tab restore, grid speed, narrow bottom bar (#3468)
Signed-off-by: Dat Ngo Quoc <datlechin@gmail.com>
1 parent b2427d3 commit 59ce1b0

61 files changed

Lines changed: 2311 additions & 331 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎linux/crates/app/src/services/cell_overlay.rs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ pub struct CellOverlay {
1717
pub error_flash: bool,
1818
}
1919

20+
/// What tints a cell, without its pending value: every bind asks this
21+
/// of every cell, and copying a value or scanning every edit to tint
22+
/// one would grow with the edits held.
23+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
24+
pub struct CellMarks {
25+
pub row_deleted: bool,
26+
pub state: CellState,
27+
pub error_flash: bool,
28+
}
29+
2030
#[cfg(test)]
2131
impl CellOverlay {
2232
/// The value the cell shows over `fetched`, a cell left to the

‎linux/crates/app/src/services/change_tracker.rs‎

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use tablepro_core::meta::RowIdentity;
1111
use tablepro_core::save::{ChangeSet, RowChange, RowUpdate};
1212
use tablepro_core::{ColumnInfo, Value};
1313

14-
use super::cell_overlay::CellOverlay;
14+
use super::cell_overlay::{CellMarks, CellOverlay};
1515
use super::column_relayout::{ColumnRelayout, Misfit};
1616
use super::save_batch::{SaveBatch, SaveTarget};
1717
use super::touch::Touch;
@@ -510,6 +510,14 @@ impl TabChangeTracker {
510510
}
511511
}
512512

513+
pub fn cell_marks(&self, row_key: &RowKey, col: usize) -> CellMarks {
514+
CellMarks {
515+
row_deleted: self.deletes.contains_key(row_key),
516+
state: self.cell_state(row_key, col),
517+
error_flash: self.is_error_row(row_key),
518+
}
519+
}
520+
513521
fn cell_state(&self, row_key: &RowKey, col: usize) -> CellState {
514522
if matches!(row_key, RowKey::Draft(_)) {
515523
return CellState::InsertDraft;
@@ -1148,6 +1156,24 @@ mod tests {
11481156
assert_eq!(t.pending_count(), 2);
11491157
}
11501158

1159+
#[test]
1160+
fn cell_marks_tint_a_cell_by_its_own_edit_and_its_rows_delete() {
1161+
let mut t = TabChangeTracker::default();
1162+
let (edited, deleted) = (rk(&[Value::Int(1)]), rk(&[Value::Int(2)]));
1163+
t.track_cell_edit(edited.clone(), 1, Value::Text("a".into()), Value::Text("b".into()));
1164+
delete(&mut t, deleted.clone(), vec![Value::Int(2), Value::Text("c".into())]);
1165+
let draft = RowKey::Draft(insert(&mut t, vec![Value::Null, Value::Null]));
1166+
1167+
let marks = |key: &RowKey, col| {
1168+
let marks = t.cell_marks(key, col);
1169+
(marks.row_deleted, marks.state)
1170+
};
1171+
assert_eq!(marks(&edited, 1), (false, CellState::Modified));
1172+
assert_eq!(marks(&edited, 0), (false, CellState::Clean));
1173+
assert_eq!(marks(&deleted, 0), (true, CellState::Clean));
1174+
assert_eq!(marks(&draft, 0), (false, CellState::InsertDraft));
1175+
}
1176+
11511177
#[test]
11521178
fn delete_marks_row_pending() {
11531179
let mut t = TabChangeTracker::default();

‎linux/crates/app/src/services/tab_tracker_handle.rs‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use tablepro_core::dml::BuildSqlError;
55
use tablepro_core::edit::CellInput;
66
use tablepro_core::{ColumnInfo, Value};
77

8-
use super::cell_overlay::CellOverlay;
8+
use super::cell_overlay::{CellMarks, CellOverlay};
99
use super::change_tracker::{DraftRow, ErrorFlash, RowKey, RowState, TabChangeTracker, TrackedChanges};
1010
use super::save_batch::{SaveBatch, SaveTarget};
1111
use super::tracker_delta::TrackerDelta;
@@ -23,6 +23,10 @@ impl TabTrackerHandle {
2323
self.0.borrow().cell_overlay(row_key, col)
2424
}
2525

26+
pub fn cell_marks(&self, row_key: &RowKey, col: usize) -> CellMarks {
27+
self.0.borrow().cell_marks(row_key, col)
28+
}
29+
2630
pub fn row_state(&self, row_key: &RowKey) -> RowState {
2731
self.0.borrow().row_state(row_key)
2832
}

‎linux/crates/app/src/ui/browse_tab/browse_actions.rs‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use gtk4 as gtk;
2-
use gtk4::gio;
32
use gtk4::prelude::*;
43
use gtk4::subclass::prelude::*;
4+
use gtk4::{gio, glib};
55

66
use super::{
77
BrowseModel, BrowseTab, BrowseTabInput, ClipboardInput, EditInput, PagingInput, SaveInput, SelectionInput,
@@ -24,6 +24,10 @@ pub(super) struct BrowseActions {
2424
pub(super) delete_rows: gio::SimpleAction,
2525
pub(super) copy_rows: gio::SimpleAction,
2626
pub(super) clear_selection: gio::SimpleAction,
27+
/// The More menu's Count Rows, on where the pager offers it.
28+
pub(super) count_rows: gio::SimpleAction,
29+
/// The More menu's page sizes, its state the size the tab reads.
30+
pub(super) page_size: gio::SimpleAction,
2731
}
2832

2933
impl BrowseActions {
@@ -43,7 +47,7 @@ impl BrowseActions {
4347
/// The tab's `browse` group, the tab's own keys for it and the keys its
4448
/// buttons announce. The grid's keys go on each column view the tab
4549
/// builds, through `install_grid_shortcuts`.
46-
pub(super) fn install_browse_actions(tab: &BrowseTab) -> BrowseActions {
50+
pub(super) fn install_browse_actions(tab: &BrowseTab, page_size: u64) -> BrowseActions {
4751
let group = gio::SimpleActionGroup::new();
4852
let add = |name: &str, input: fn() -> BrowseTabInput| {
4953
let action = gio::SimpleAction::new(name, None);
@@ -57,6 +61,16 @@ pub(super) fn install_browse_actions(tab: &BrowseTab) -> BrowseActions {
5761
action
5862
};
5963
add("filter", || PagingInput::ToggleFilterStrip.into());
64+
add("export", || ClipboardInput::Export(None).into());
65+
let page_size =
66+
gio::SimpleAction::new_stateful("page-size", Some(glib::VariantTy::UINT64), &page_size.to_variant());
67+
let weak = tab.downgrade();
68+
page_size.connect_change_state(move |_, size| {
69+
if let (Some(tab), Some(size)) = (weak.upgrade(), size.and_then(u64::from_variant)) {
70+
tab.send(PagingInput::PageSizeChanged(size));
71+
}
72+
});
73+
group.add_action(&page_size);
6074
add("refresh", || PagingInput::RequestRefresh.into());
6175
add("paste-rows", || ClipboardInput::PasteNotSupported.into());
6276
let previous = add("previous-page", || PagingInput::PrevPage.into());
@@ -80,6 +94,8 @@ pub(super) fn install_browse_actions(tab: &BrowseTab) -> BrowseActions {
8094
delete_rows,
8195
copy_rows: add("copy-rows", || ClipboardInput::CopySelectedRowsAsTsv.into()),
8296
clear_selection: add("clear-selection", || SelectionInput::ClearSelection.into()),
97+
count_rows: add("count-rows", || PagingInput::CountRows.into()),
98+
page_size,
8399
};
84100
for action in [
85101
&actions.save,
@@ -89,6 +105,7 @@ pub(super) fn install_browse_actions(tab: &BrowseTab) -> BrowseActions {
89105
&actions.delete_rows,
90106
&actions.copy_rows,
91107
&actions.clear_selection,
108+
&actions.count_rows,
92109
] {
93110
action.set_enabled(false);
94111
}

0 commit comments

Comments
 (0)