Spec M32 — examples/desktop: composing windows with GTK4 from mc (owner's test, 2026-09-03)

Goal: prove that an mc program (and then a taught UI language) can drive a desktop toolkit to compose windows. Toolkit: GTK4 via Homebrew (/opt/homebrew/lib/libgtk-4.1.dylib plus GLib/GObject/ GIO), chosen because its C API uses only integers, pointers and callbacks — everything mc has today (extern, #dylib/[libs]+[externs], &fn, callp). AppKit through objc_msgSend follows after M24 (NSRect travels in v0..v3).

Part A — plain mc binding (examples/desktop/main.mc, lib/gtk.mc) #

Part B — a UI language taught by the surface (examples/desktop/ui.mc, .ui files) #

Using the lx machinery (M22) or a small dedicated module: declarative composition lowered to Part A:

window "Counter" size 360 200 {
    vbox {
        label count "0";
        hbox { button "-" -> on_minus; button "+" -> on_plus; }
        entry name placeholder "your name" -> on_name;
    }
}
fn on_plus() { count.text = itoa(state.n += 1); }

Acceptance #

Edit this page