From 463105bca5efbff0a09916704664c14e51607782 Mon Sep 17 00:00:00 2001 From: mfranz Date: Sun, 3 Aug 2008 13:41:07 +0000 Subject: [PATCH] add show_widgets() function --- Nasal/gui.nas | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Nasal/gui.nas b/Nasal/gui.nas index b20e02316..86686aa56 100644 --- a/Nasal/gui.nas +++ b/Nasal/gui.nas @@ -353,8 +353,8 @@ var save_flight = func { var load_flight_sel = nil; var load_flight = func { - var load = func { - fgcommand("load", props.Node.new({ file: cmdarg().getValue() })); + var load = func(n) { + fgcommand("load", props.Node.new({ file: n.getValue() })); fgcommand("presets-commit"); } if (load_flight_sel == nil) @@ -434,6 +434,19 @@ var dialog_update = func(dialog, objects...) { } +## +# Searches a dialog tree for widgets with a particular entry and +# sets their according to "show". +# +var show_widgets = func(node, name, show = 1) { + foreach (var n; node.getChildren()) + show_widgets(n, name, show); + if ((var n = node.getNode("name")) != nil and n.getValue() == name) + node.getNode("hide", 1).setBoolValue(!show); +} + + + ######################################################################## # GUI theming ########################################################################