Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
03e7ef4
feat(linux-grid): add row numbers, row height and NULL text preferences
sedax90 Nov 8, 2026
390a0a3
feat(linux-grid): let the data grid have its own cell font
sedax90 Nov 8, 2026
8c415d7
feat(linux-grid): choose the format Copy writes for several rows
sedax90 Nov 8, 2026
ff5eae3
fix(linux-grid): show the chosen NULL text in editable cells too
sedax90 Nov 8, 2026
e13f6f5
Merge branch 'feat/linux-grid-display-settings' into feat/linux-grid-…
sedax90 Nov 8, 2026
4db6483
Merge branch 'feat/linux-grid-font' into feat/linux-row-copy-format
sedax90 Nov 8, 2026
ab70c2d
fix(linux-grid): share live display preferences across grids
datlechin Nov 8, 2026
1d3f362
fix(linux-grid): merge updated NULL display behavior
datlechin Nov 8, 2026
b0f30c2
feat(linux-grid): scope cell fonts to each grid
datlechin Nov 8, 2026
76e860b
Merge branch 'feat/linux-grid-font' of https://github.com/sedax90/Tab…
datlechin Nov 8, 2026
1ad8564
fix(linux-grid): synchronize row copy format preferences
datlechin Nov 8, 2026
c0da2cf
fix(linux-grid): keep display preferences when resetting columns
datlechin Nov 8, 2026
c03b4eb
test(linux-grid): load native styles for row height checks
datlechin Nov 8, 2026
45b2c6f
fix(linux-grid): merge display reset and test fixture fixes
datlechin Nov 8, 2026
a19f02a
fix(linux-grid): merge display reset and test fixture fixes
datlechin Nov 8, 2026
f0b3070
test(linux-grid): isolate settings notification contexts
datlechin Nov 8, 2026
36f6505
test(linux-grid): merge isolated settings contexts
datlechin Nov 8, 2026
d702bda
test(linux-grid): merge isolated settings contexts
datlechin Nov 8, 2026
65b6a7f
fix(linux-grid): type the settings test shutdown channel
datlechin Nov 8, 2026
1f2ca73
fix(linux-grid): merge the settings test channel type
datlechin Nov 8, 2026
4b52c85
fix(linux-grid): merge the settings test channel type
datlechin Nov 8, 2026
068db68
test(linux-grid): assert copied JSON without unordered maps
datlechin Nov 8, 2026
1d48659
Merge branch 'main' into feat/linux-grid-font
datlechin Nov 9, 2026
41df39f
fix(linux-grid): pass the NULL text to the row details search
datlechin Nov 9, 2026
8425752
Merge remote-tracking branch 'origin/main' into feat/linux-grid-font
datlechin Nov 9, 2026
8973772
Merge branch 'feat/linux-grid-font' into feat/linux-row-copy-format
datlechin Nov 9, 2026
5a0e6d9
Merge branch 'main' into feat/linux-row-copy-format
datlechin Nov 9, 2026
fb2017d
Merge remote-tracking branch 'origin/main' into feat/linux-row-copy-f…
datlechin Nov 10, 2026
b2a4b9c
Merge remote-tracking branch 'origin/main' into feat/linux-row-copy-f…
datlechin Nov 10, 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
1 change: 1 addition & 0 deletions linux/changelog.d/4137.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Preferences can set the format Copy writes when several rows are selected, as TSV, JSON, CSV or Markdown.
19 changes: 17 additions & 2 deletions linux/crates/app/src/ui/data_grid/copy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use gtk4::{self as gtk, glib};
use tablepro_core::column::{ColumnInfo, ResultColumn};
use tablepro_core::edit::CellInput;
use tablepro_core::{FilterRule, Value};
use tablepro_linux_platform::settings::RowCopyFormat;

use super::grid_actions::{add, add_for_column, enable};
use super::selection::Resolved;
Expand Down Expand Up @@ -165,15 +166,29 @@ impl ShownColumns {
}
}

/// Copy: the target cell's value when one row is in play, else the rows.
fn copy(grid: &DataGrid) {
let Some(target) = grid.target() else {
return;
};
let column = target.cell.as_ref().map(|(_, column)| *column);
match (copy_scope(target.rows.len(), column), &target.cell) {
(CopyScope::Value(column), Some((row, _))) => copy_value(grid, row, column),
_ => copy_rows(grid, &target.rows, CopyKind::Rows),
_ => copy_rows(grid, &target.rows, preferred_format(grid)),
}
}

fn preferred_format(grid: &DataGrid) -> CopyKind {
match grid
.config()
.map(|config| config.settings.row_copy_format())
.unwrap_or_default()
{
RowCopyFormat::Rows => CopyKind::Rows,
RowCopyFormat::RowsWithHeaders => CopyKind::RowsWithHeaders,
RowCopyFormat::Json => CopyKind::Json,
RowCopyFormat::Csv => CopyKind::Csv,
RowCopyFormat::CsvWithHeaders => CopyKind::CsvWithHeaders,
RowCopyFormat::Markdown => CopyKind::Markdown,
}
}

Expand Down
47 changes: 47 additions & 0 deletions linux/crates/app/src/ui/data_grid/copy/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use crate::ui::data_grid::{DataGrid, GridCell, GridRequest};
use crate::ui::export::ExportSource;

const BEFORE: &str = "nothing copied yet";
const TWO_TEXT_ROWS_JSON: &str = "[\n{\"id\":1,\"name\":\"A\"},\n{\"id\":2,\"name\":\"B\"}\n]";

/// What a copy test drives: a grid and the requests it made.
trait Copies {
Expand Down Expand Up @@ -747,3 +748,49 @@ fn the_text_copies_take_the_columns_on_screen() {
assert_eq!(lines, "{\"id\":1,\"name\":\"Ada\"}\n{\"id\":2,\"name\":\"Grace\"}\n");
assert_eq!(one_row, "1, 'Ada', 2, 'Grace'");
}

#[gtk4::test]
fn copy_writes_several_rows_in_the_preferred_format() {
use tablepro_linux_platform::settings::RowCopyFormat;

let grid = Grid::open(two_text_columns(), two_text_values());
select_all(&grid);
let settings = &grid.grid.config().expect("a configured grid").settings;
for format in RowCopyFormat::ALL {
settings.set_row_copy_format(format.nick()).expect("store the format");

let text = copied(&grid, || activate(&grid.grid, "copy"));

match format {
RowCopyFormat::Rows => assert_eq!(text, "1\tA\n2\tB\n"),
RowCopyFormat::RowsWithHeaders => assert_eq!(text, "id\tname\n1\tA\n2\tB\n"),
RowCopyFormat::Csv => assert_eq!(text, "1,A\n2,B\n"),
RowCopyFormat::CsvWithHeaders => assert_eq!(text, "id,name\n1,A\n2,B\n"),
RowCopyFormat::Markdown => assert_eq!(text, "| id | name |\n| --- | --- |\n| 1 | A |\n| 2 | B |"),
RowCopyFormat::Json => assert_eq!(text, TWO_TEXT_ROWS_JSON),
}
}
}

#[gtk4::test]
fn preferred_row_format_preserves_single_cell_copy_and_explicit_formats() {
let grid = Grid::open(two_text_columns(), two_text_values());
grid.grid
.config()
.expect("a configured grid")
.settings
.set_row_copy_format("json")
.expect("store the format");
grid.grid.selection().select_item(0, true);
grid.focus(0, 1);

assert_eq!(copied(&grid, || activate(&grid.grid, "copy")), "A");

select_all(&grid);
assert_eq!(
copied(&grid, || activate(&grid.grid, "copy-csv-headers")),
"id,name\n1,A\n2,B\n"
);
let text = copied(&grid, || activate(&grid.grid, "copy"));
assert_eq!(text, TWO_TEXT_ROWS_JSON);
}
74 changes: 59 additions & 15 deletions linux/crates/app/src/ui/preferences_dialog/data_browser_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use gtk4::prelude::*;
use gtk4::subclass::prelude::*;
use libadwaita as adw;
use tablepro_linux_platform::AppSettings;
use tablepro_linux_platform::settings::{GridRowHeight, keys};
use tablepro_linux_platform::settings::{GridRowHeight, RowCopyFormat, keys};

mod imp {
use libadwaita::prelude::*;
Expand All @@ -30,6 +30,8 @@ mod imp {
#[template_child]
pub row_numbers_row: TemplateChild<adw::SwitchRow>,
#[template_child]
pub row_copy_format_row: TemplateChild<adw::ComboRow>,
#[template_child]
pub row_height_row: TemplateChild<adw::ComboRow>,
#[template_child]
pub null_display_row: TemplateChild<adw::EntryRow>,
Expand Down Expand Up @@ -112,23 +114,41 @@ impl DataBrowserGroup {
Some(description.to_str().to_variant())
})
.build();
gio_settings
.bind(keys::GRID_ROW_HEIGHT, &imp.row_height_row.get(), "selected")
.mapping(|variant, _| {
let height = variant.str()?;
let index = GridRowHeight::ALL
.iter()
.position(|candidate| candidate.nick() == height)?;
Some((index as u32).to_value())
})
.set_mapping(|value, _| {
let index = value.get::<u32>().ok()?;
Some(GridRowHeight::ALL.get(index as usize)?.nick().to_variant())
})
.build();
bind_choice(
&imp.row_height_row.get(),
gio_settings,
keys::GRID_ROW_HEIGHT,
GridRowHeight::ALL.map(GridRowHeight::nick),
);
bind_choice(
&imp.row_copy_format_row.get(),
gio_settings,
keys::ROW_COPY_FORMAT,
RowCopyFormat::ALL.map(RowCopyFormat::nick),
);
}
}

fn bind_choice<const N: usize>(
row: &adw::ComboRow,
settings: &gio::Settings,
key: &'static str,
words: [&'static str; N],
) {
settings
.bind(key, row, "selected")
.mapping(move |variant, _| {
let word = variant.str()?;
let index = words.iter().position(|candidate| *candidate == word)?;
Some((index as u32).to_value())
})
.set_mapping(move |value, _| {
let index = value.get::<u32>().ok()?;
Some(words.get(index as usize)?.to_variant())
})
.build();
}

#[cfg(test)]
mod tests {
use libadwaita::prelude::*;
Expand Down Expand Up @@ -258,4 +278,28 @@ mod tests {
assert!(first.imp().grid_system_font_row.is_active());
assert!(!second.imp().grid_font_row.is_sensitive());
}

#[gtk4::test]
fn copy_format_rows_follow_every_choice_from_both_windows() {
let settings = MemorySettings::new();
let first = bound_group(&settings);
let second = bound_group(&settings);

for (index, format) in RowCopyFormat::ALL.into_iter().enumerate() {
first.imp().row_copy_format_row.set_selected(index as u32);
assert_eq!(settings.get().row_copy_format(), format);
assert_eq!(second.imp().row_copy_format_row.selected(), index as u32);
}
for (index, format) in RowCopyFormat::ALL.into_iter().enumerate().rev() {
settings
.get()
.set_row_copy_format(format.nick())
.expect("store copy format");
assert_eq!(first.imp().row_copy_format_row.selected(), index as u32);
assert_eq!(second.imp().row_copy_format_row.selected(), index as u32);
}
second.imp().row_copy_format_row.set_selected(2);
assert_eq!(first.imp().row_copy_format_row.selected(), 2);
assert_eq!(settings.get().row_copy_format(), RowCopyFormat::Json);
}
}
48 changes: 48 additions & 0 deletions linux/crates/platform/src/settings/grid_preferences.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,58 @@ impl GridRowHeight {
}
}

#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub enum RowCopyFormat {
#[default]
Rows,
RowsWithHeaders,
Json,
Csv,
CsvWithHeaders,
Markdown,
}

impl RowCopyFormat {
pub const ALL: [Self; 6] = [
Self::Rows,
Self::RowsWithHeaders,
Self::Json,
Self::Csv,
Self::CsvWithHeaders,
Self::Markdown,
];

pub fn from_nick(nick: &str) -> Self {
match nick {
"rows-headers" => Self::RowsWithHeaders,
"json" => Self::Json,
"csv" => Self::Csv,
"csv-headers" => Self::CsvWithHeaders,
"markdown" => Self::Markdown,
_ => Self::Rows,
}
}

pub fn nick(self) -> &'static str {
match self {
Self::Rows => "rows",
Self::RowsWithHeaders => "rows-headers",
Self::Json => "json",
Self::Csv => "csv",
Self::CsvWithHeaders => "csv-headers",
Self::Markdown => "markdown",
}
}
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct GridPreferenceValues {
pub show_row_numbers: bool,
pub show_alternate_rows: bool,
pub row_height: GridRowHeight,
pub null_display: String,
pub font: EditorFont,
pub row_copy_format: RowCopyFormat,
}

impl Default for GridPreferenceValues {
Expand All @@ -64,13 +109,15 @@ impl Default for GridPreferenceValues {
row_height: GridRowHeight::Normal,
null_display: "NULL".to_owned(),
font: EditorFont::System,
row_copy_format: RowCopyFormat::Rows,
}
}
}

impl GridPreferenceValues {
fn read(settings: &gio::Settings) -> Self {
Self {
row_copy_format: RowCopyFormat::from_nick(&settings.string(keys::ROW_COPY_FORMAT)),
show_row_numbers: settings.boolean(keys::SHOW_ROW_NUMBERS),
show_alternate_rows: settings.boolean(keys::SHOW_ALTERNATE_ROWS),
row_height: GridRowHeight::from_nick(&settings.string(keys::GRID_ROW_HEIGHT)),
Expand Down Expand Up @@ -148,6 +195,7 @@ impl GridPreferences {
| keys::NULL_DISPLAY
| keys::GRID_USE_SYSTEM_FONT
| keys::GRID_FONT
| keys::ROW_COPY_FORMAT
) && let Some(preferences) = weak.upgrade()
{
preferences.update(GridPreferenceValues::read(settings));
Expand Down
1 change: 1 addition & 0 deletions linux/crates/platform/src/settings/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub const USE_SYSTEM_FONT: &str = "use-system-font";
pub const CUSTOM_FONT: &str = "custom-font";
pub const GRID_USE_SYSTEM_FONT: &str = "grid-use-system-font";
pub const GRID_FONT: &str = "grid-font";
pub const ROW_COPY_FORMAT: &str = "row-copy-format";
pub const STYLE_SCHEME: &str = "style-scheme";
pub const VIM_KEYBINDINGS: &str = "vim-keybindings";
pub const CONNECT_DIALOG_DRIVER: &str = "connect-dialog-driver";
Expand Down
10 changes: 9 additions & 1 deletion linux/crates/platform/src/settings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use tablepro_core::export::{CsvDecimal, CsvDelimiter, CsvLineBreak, CsvOptions,

pub use editor_font::EditorFont;
pub use error::SettingsError;
pub use grid_preferences::{GridPreferenceValues, GridPreferences, GridRowHeight};
pub use grid_preferences::{GridPreferenceValues, GridPreferences, GridRowHeight, RowCopyFormat};
pub use window_geometry::WindowGeometry;

/// The provider setting's value while the assistant is off.
Expand Down Expand Up @@ -115,6 +115,14 @@ impl AppSettings {
self.set_string(keys::GRID_ROW_HEIGHT, height)
}

pub fn row_copy_format(&self) -> RowCopyFormat {
self.grid_preferences().snapshot().row_copy_format
}

pub fn set_row_copy_format(&self, format: &str) -> Result<(), SettingsError> {
self.set_string(keys::ROW_COPY_FORMAT, format)
}

pub fn null_display(&self) -> String {
self.grid_preferences().snapshot().null_display.clone()
}
Expand Down
26 changes: 26 additions & 0 deletions linux/crates/platform/tests/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,3 +533,29 @@ async fn grid_font_uses_the_shared_snapshot_and_preserves_the_editor_font() -> T
assert_eq!(calls.get(), 3);
Ok(())
}

#[glib::async_test]
async fn row_copy_format_publishes_every_format_through_the_shared_model() -> TestResult {
use std::cell::RefCell;
use std::rc::Rc;
use tablepro_linux_platform::settings::RowCopyFormat;

let fixture = Fixture::new()?;
let preferences = fixture.settings.grid_preferences();
let original = preferences.snapshot();
let observed = Rc::new(RefCell::new(Vec::new()));
let updates = observed.clone();
preferences.connect_changed(move |preferences| updates.borrow_mut().push(preferences.snapshot().row_copy_format));

assert_eq!(fixture.settings.row_copy_format(), RowCopyFormat::Rows);
for format in RowCopyFormat::ALL {
fixture.settings.set_row_copy_format(format.nick())?;
assert_eq!(fixture.settings.row_copy_format(), format);
assert_eq!(preferences.snapshot().row_copy_format, format);
assert_eq!(RowCopyFormat::from_nick(format.nick()), format);
}
assert_eq!(observed.borrow().as_slice(), &RowCopyFormat::ALL[1..]);
assert_eq!(original.row_copy_format, RowCopyFormat::Rows);
assert_eq!(RowCopyFormat::from_nick("unknown"), RowCopyFormat::Rows);
Ok(())
}
14 changes: 14 additions & 0 deletions linux/data/app.tablepro.TablePro.gschema.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,20 @@
<description>How much room a data grid row takes around its text.</description>
</key>

<key name="row-copy-format" type="s">
<choices>
<choice value="rows"/>
<choice value="rows-headers"/>
<choice value="json"/>
<choice value="csv"/>
<choice value="csv-headers"/>
<choice value="markdown"/>
</choices>
<default>"rows"</default>
<summary>Format of copied rows</summary>
<description>The format Copy writes when several rows are selected.</description>
</key>

<key name="null-display" type="s">
<default>"NULL"</default>
<summary>Text for a NULL value</summary>
Expand Down
18 changes: 18 additions & 0 deletions linux/data/resources/ui/preferences-data-browser-group.ui
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,24 @@
</property>
</object>
</child>
<child>
<object class="AdwComboRow" id="row_copy_format_row">
<property name="title" translatable="yes">Copy Rows As</property>
<property name="subtitle" translatable="yes">The format Copy writes when several rows are selected</property>
<property name="model">
<object class="GtkStringList">
<items>
<item translatable="yes">TSV</item>
<item translatable="yes">TSV with Headers</item>
<item translatable="yes">JSON</item>
<item translatable="yes">CSV</item>
<item translatable="yes">CSV with Headers</item>
<item translatable="yes">Markdown</item>
</items>
</object>
</property>
</object>
</child>
<child>
<object class="AdwEntryRow" id="null_display_row">
<property name="title" translatable="yes">Text for NULL</property>
Expand Down
Loading
Loading