From 294edc495ea73f9172b3b8262af87c674ec2610e Mon Sep 17 00:00:00 2001 From: cnmcdee Date: Mon, 30 Nov 2026 13:05:47 +0000 Subject: [PATCH] Phase 3: generator emits set_items string form for ToolBar/MenuBar (fixes case 03 ambiguity) --- crates/lightgui-designer/src/selftest.rs | 2 +- crates/lightgui-gen/src/gen.rs | 28 +++++++----------------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/crates/lightgui-designer/src/selftest.rs b/crates/lightgui-designer/src/selftest.rs index 2da5eb5..775f860 100644 --- a/crates/lightgui-designer/src/selftest.rs +++ b/crates/lightgui-designer/src/selftest.rs @@ -680,7 +680,7 @@ pub fn selftest_step(app: &Shared) { "set_size_grip(false)", "set_show_captions(false)", "set_button_width(48)", - "set_items({\"File\", \"Edit\"})", + "set_items(\"File|Edit\")", "win_x, win_y", "override_redirect", "_NET_WM_STATE_FULLSCREEN", diff --git a/crates/lightgui-gen/src/gen.rs b/crates/lightgui-gen/src/gen.rs index b4ac9e7..b7a1d4b 100644 --- a/crates/lightgui-gen/src/gen.rs +++ b/crates/lightgui-gen/src/gen.rs @@ -1522,16 +1522,10 @@ fn emit_widget_props(o: &mut String, w: &Widget, m: &XFrameMap, var: &str, kind: } } else if t == "ToolBar" { if has("items") { - o.push_str(&format!(" {var}.w.set_items({{")); - let mut first = true; - for item in split_on('|', &prop_or(w, "items", "")) { - if !first { - o.push_str(", "); - } - first = false; - o.push_str(&format!("\"{}\"", esc_c(&item))); - } - o.push_str("});\n"); + o.push_str(&format!( + " {var}.w.set_items(\"{}\");\n", + esc_c(&prop_or(w, "items", "")) + )); } if w.props.contains_key("show-captions") { o.push_str(&format!( @@ -1567,16 +1561,10 @@ fn emit_widget_props(o: &mut String, w: &Widget, m: &XFrameMap, var: &str, kind: } } else if t == "MenuBar" { if has("menus") { - o.push_str(&format!(" {var}.w.set_items({{")); - let mut first = true; - for item in split_on('|', &prop_or(w, "menus", "")) { - if !first { - o.push_str(", "); - } - first = false; - o.push_str(&format!("\"{}\"", esc_c(&item))); - } - o.push_str("});\n"); + o.push_str(&format!( + " {var}.w.set_items(\"{}\");\n", + esc_c(&prop_or(w, "menus", "")) + )); } } else if t == "SpinEdit" { let lo = prop_int(w, "minimum", 0);