Skip to content

GTK4: SplitView FFIs (splitview_create, splitview_add_child) not wired — co-blocks docs/examples/ui/layout/snippets.ts on Linux CI #218

Description

@proggeramlug

Context

docs/examples/ui/layout/snippets.ts imports SplitView and splitViewAddChild from perry/ui to demonstrate the split-pane layout pattern. The example compiles + links cleanly on macOS (NSSplitView) but fails on the GTK4-on-Ubuntu doc-tests CI runner with:

/usr/bin/ld: perry_llvm_*.ll:(.text+...): undefined reference to `perry_ui_splitview_create'
/usr/bin/ld: perry_llvm_*.ll:(.text+...): undefined reference to `perry_ui_splitview_add_child'

Co-blocker (alongside #217's overlay/reorder FFIs) for the gtk4 doc-tests gate on origin/main.

What's missing

FFI macOS GTK4 mapping
perry_ui_splitview_create NSSplitView widget gtk::Paned::new(Orientation::Horizontal)
perry_ui_splitview_add_child addArrangedSubview: Paned::set_start_child(&child) for first call, set_end_child(&child) for second

Implementation notes

  • gtk::Paned is GTK4's split-pane primitive. It supports exactly two children (start_child + end_child), unlike NSSplitView which can hold N. Most uses of SplitView in TS pass exactly 2 children, but the API allows more.
  • Decision needed: cap GTK4's splitview_add_child at 2 (third+ call → no-op or error), or nest Paneds recursively to support N children. The simplest+correct first cut is the 2-child cap, with a runtime warn if a third child arrives.
  • Default orientation: macOS NSSplitView defaults to vertical-divider (horizontal arrangement). Match that with Orientation::Horizontal on Paned.
  • The handle/separator is automatic on Paned; no need to wire a separate setOrientation API for the first cut unless it already exists on macOS.

Acceptance

  • Both FFIs exported as #[no_mangle] pub extern "C" fn in crates/perry-ui-gtk4/src/lib.rs.
  • If splitview rows exist in crates/perry-ui/src/styling_matrix.rs, flip the GTK4 cells from Missing to Wired. Verify ./target/release/styling-matrix --check is clean.
  • cargo build --release -p perry-ui-gtk4 succeeds.
  • docs/examples/ui/layout/snippets.ts compiles + links cleanly on Linux (in conjunction with GTK4: 4 widget overlay/reorder FFIs not wired — blocks docs/examples/ui/layout/snippets.ts on Linux CI #217's overlay/reorder fix).
  • PR body explicitly notes the 2-child cap on GTK4 vs N-child on macOS, so it's discoverable when someone hits the limit.

Pointers

  • macOS implementations: search crates/perry-ui-macos/src/ for perry_ui_splitview_create / _add_child.
  • Existing GTK4 multi-child container patterns: search crates/perry-ui-gtk4/src/ for vstack_create / hstack_create / add_child — same shape, just Paned instead of Box.
  • Failing doc-test: docs/examples/ui/layout/snippets.ts.

Related

Estimated size

Small — ~30-50 LOC. The 2-vs-N child caveat is the only design decision worth flagging in the PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew capability or improvement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions