summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsdconfig/timezone
diff options
context:
space:
mode:
authordteske <dteske@FreeBSD.org>2013-06-02 09:02:12 +0000
committerdteske <dteske@FreeBSD.org>2013-06-02 09:02:12 +0000
commit373aa5232d0043556e802e93d9f70bec70f121c7 (patch)
tree826a3cea2f1f978a5386dfa3b219f0c60dccae42 /usr.sbin/bsdconfig/timezone
parent5b05f067655217732e94ad77b1c57a3cb7a3945e (diff)
downloadFreeBSD-src-373aa5232d0043556e802e93d9f70bec70f121c7.zip
FreeBSD-src-373aa5232d0043556e802e93d9f70bec70f121c7.tar.gz
Improve the dialog(1) API in dialog.subr by adding f_dialog_default_store()
and f_dialog_default_fetch(). Operating similar to functions introduced by SVN r251236 and r251242, these functions operate as a pair for helping track the default-item data (for the --menu, --checklist, and --radiolist widgets). This replaces the direct usage of a global to store the data with an abstract method for readability and to centralize the code.
Diffstat (limited to 'usr.sbin/bsdconfig/timezone')
-rwxr-xr-xusr.sbin/bsdconfig/timezone/timezone22
1 files changed, 13 insertions, 9 deletions
diff --git a/usr.sbin/bsdconfig/timezone/timezone b/usr.sbin/bsdconfig/timezone/timezone
index 89e8c7f..44bba7c 100755
--- a/usr.sbin/bsdconfig/timezone/timezone
+++ b/usr.sbin/bsdconfig/timezone/timezone
@@ -83,6 +83,7 @@ dialog_menu_main()
local title="$DIALOG_TITLE"
local btitle="$DIALOG_BACKTITLE"
local prompt="$msg_select_region"
+ local defaultitem= # Calculated below
local height width rows
eval f_dialog_menu_size height width rows \
@@ -92,22 +93,25 @@ dialog_menu_main()
\"\" \
$continent_menu_list
+ # Obtain default-item from previously stored selection
+ f_dialog_default_fetch defaultitem
+
local menu_choice
menu_choice=$( eval $DIALOG \
- --title \"\$title\" \
- --backtitle \"\$btitle\" \
- --ok-label \"\$msg_ok\" \
- --cancel-label \"\$msg_cancel\" \
- --default-item \"\$DEFAULTITEM_$$\" \
- --menu \"\$prompt\" \
- $height $width $rows \
- $continent_menu_list \
+ --title \"\$title\" \
+ --backtitle \"\$btitle\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --default-item \"\$defaultitem\" \
+ --menu \"\$prompt\" \
+ $height $width $rows \
+ $continent_menu_list \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
f_dialog_data_sanitize menu_choice
f_dialog_menutag_store "$menu_choice"
- setvar DEFAULTITEM_$$ "$menu_choice"
+ f_dialog_default_store "$menu_choice"
return $retval
}
OpenPOWER on IntegriCloud