summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsdconfig/share
diff options
context:
space:
mode:
authordteske <dteske@FreeBSD.org>2013-06-02 20:02:50 +0000
committerdteske <dteske@FreeBSD.org>2013-06-02 20:02:50 +0000
commite9cea3453922d1975e0825166772ffe465661dab (patch)
tree2c9bf92c5092f58cc207f2fd3418feab48459fea /usr.sbin/bsdconfig/share
parentdb074b4e6ec9f60ba7d39270d7bd41bd4d5f6ba8 (diff)
downloadFreeBSD-src-e9cea3453922d1975e0825166772ffe465661dab.zip
FreeBSD-src-e9cea3453922d1975e0825166772ffe465661dab.tar.gz
Standardize the way functions build their arguments leading up to a dialog
invocation. Specifically, "top-load" your arguments and in the order in- which they will be displayed. For example, many [if not all] widgets display information in the following order, top-to-bottom (visually): + backtitle (displayed behind the widget at top-left) + title (at the top of the `window') + prompt text (just below the title and above whatever widget you choose) + Depending on widget, _one_ of the following: - menu list - radio list - check list - text input box with initial text - [Xdialog(1)] 2x or 3x text input boxes - [dialog(1)] a multi-part form - progress bar - etc. (many more widget choices) + buttons (right below the selected widget) + [dialog(1)] the hline (displayed at bottom of `window') NOTE: Xdialog(1) accepts and silently ignores --hline When building local arguments for your dialog invocation, if the value can't be cleanly loaded into a local, add "# Calculated below" to the end of the local declaration while retaining the block order of argument declarations. Move other local declarations that are not associated with this top-loading the dialog arguments to right-above where they are first-used. Also, standardize on the names of the arguments. For example, always use $prompt (instead of sometimes $msg and sometimes $prompt); use $menu_list or $shell_list or $radio_list for those respective widgets; ad nauseum. While we're doing this, flush-out full arguments for many invocations that were passing NULL strings (making it unapparent if you were staring at this one invocation what argument that NULL string was supposed to represent). Last, while we're in startup/rcconf let's remove the unnecessary use of a GLOBAL (RCCONF_MENU_LIST) for the menu_list.
Diffstat (limited to 'usr.sbin/bsdconfig/share')
-rw-r--r--usr.sbin/bsdconfig/share/media/any.subr6
-rw-r--r--usr.sbin/bsdconfig/share/media/ftp.subr3
-rw-r--r--usr.sbin/bsdconfig/share/media/options.subr7
-rw-r--r--usr.sbin/bsdconfig/share/mustberoot.subr17
-rwxr-xr-xusr.sbin/bsdconfig/share/packages/packages.subr54
5 files changed, 49 insertions, 38 deletions
diff --git a/usr.sbin/bsdconfig/share/media/any.subr b/usr.sbin/bsdconfig/share/media/any.subr
index 3841300..e54af4b 100644
--- a/usr.sbin/bsdconfig/share/media/any.subr
+++ b/usr.sbin/bsdconfig/share/media/any.subr
@@ -68,10 +68,7 @@ f_media_get_type()
local title="$DIALOG_TITLE" btitle="$DIALOG_BACKTITLE"
f_dialog_title_restore
local prompt="$msg_choose_installation_media_description"
- local hline="$hline_choose_help_for_more_information_on_media_types"
- local menu_list
-
- menu_list="
+ local menu_list="
'1 $msg_cd_dvd' '$msg_install_from_a_freebsd_cd_dvd'
'2 $msg_ftp' '$msg_install_from_an_ftp_server'
'3 $msg_ftp_passive'
@@ -85,6 +82,7 @@ f_media_get_type()
'A $msg_usb' '$msg_install_from_a_usb_drive'
'X $msg_options' '$msg_view_set_various_media_options'
" # END-QUOTE
+ local hline="$hline_choose_help_for_more_information_on_media_types"
local height width rows
eval f_dialog_menu_size height width rows \
diff --git a/usr.sbin/bsdconfig/share/media/ftp.subr b/usr.sbin/bsdconfig/share/media/ftp.subr
index 5164bf2..e6cea0f 100644
--- a/usr.sbin/bsdconfig/share/media/ftp.subr
+++ b/usr.sbin/bsdconfig/share/media/ftp.subr
@@ -72,9 +72,7 @@ f_dialog_menu_media_ftp()
f_dialog_title "$msg_please_select_a_freebsd_ftp_distribution_site"
local title="$DIALOG_TITLE" btitle="$DIALOG_BACKTITLE"
f_dialog_title_restore
-
local prompt="$msg_please_select_the_site_closest_to_you_or_other"
- local hline="$msg_select_a_site_thats_close"
local menu_list="
'$msg_main_site' 'ftp.freebsd.org'
'URL' '$msg_specify_some_other_ftp_site'
@@ -228,6 +226,7 @@ f_dialog_menu_media_ftp()
' $msg_usa #14' 'ftp14.us.freebsd.org'
' $msg_usa #15' 'ftp15.us.freebsd.org'
" # END-QUOTE
+ local hline="$msg_select_a_site_thats_close"
local height width rows
eval f_dialog_menu_size height width rows \
diff --git a/usr.sbin/bsdconfig/share/media/options.subr b/usr.sbin/bsdconfig/share/media/options.subr
index b7bf2e8..b73d004 100644
--- a/usr.sbin/bsdconfig/share/media/options.subr
+++ b/usr.sbin/bsdconfig/share/media/options.subr
@@ -53,9 +53,10 @@ f_media_options_menu()
f_dialog_title "$msg_options_editor"
local title="$DIALOG_TITLE" btitle="$DIALOG_BACKTITLE"
f_dialog_title_restore
- local prompt=""
+ local prompt=
+ local menu_list # Calculated below
+ local defaultitem=
local hline="$hline_arrows_tab_enter"
- local menu_list cp
#
# A hack so that the dialogs below are always interactive in a script
@@ -66,7 +67,7 @@ f_media_options_menu()
unset $VAR_NONINTERACTIVE
fi
- local defaultitem=
+ local cp
while :; do
menu_list=""
diff --git a/usr.sbin/bsdconfig/share/mustberoot.subr b/usr.sbin/bsdconfig/share/mustberoot.subr
index bf8dd67..0b134f8 100644
--- a/usr.sbin/bsdconfig/share/mustberoot.subr
+++ b/usr.sbin/bsdconfig/share/mustberoot.subr
@@ -77,7 +77,7 @@ SECURE_DIVULGE_UNKNOWN_USER=
#
f_become_root_via_sudo()
{
- local msg hline height width rows
+ local prompt hline height width rows msg
[ "$( id -u )" = "0" ] && return $SUCCESS
@@ -90,18 +90,19 @@ f_become_root_via_sudo()
#
local checkpath="${HOME%/}/.bsdconfig_uses_sudo"
if [ ! -e "$checkpath" ]; then
+ prompt=$( printf "$msg_you_are_not_root_but" bsdconfig )
msg=$( printf "$msg_always_try_sudo_when_run_as" "$USER" )
local menu_list="
'X' '$msg_cancel_exit'
'1' '$msg'
'2' '$msg_try_sudo_only_this_once'
" # END-QUOTE
- msg=$( printf "$msg_you_are_not_root_but" bsdconfig )
hline="$hline_arrows_tab_enter"
+
eval f_dialog_menu_size height width rows \
\"\$DIALOG_TITLE\" \
\"\$DIALOG_BACKTITLE\" \
- \"\$msg\" \
+ \"\$prompt\" \
\"\$hline\" \
$menu_list
@@ -112,7 +113,7 @@ f_become_root_via_sudo()
--hline \"\$hline\" \
--ok-label \"\$msg_ok\" \
--cancel-label \"\$msg_cancel\" \
- --menu \"\$msg\" \
+ --menu \"\$prompt\" \
$height $width $rows \
$menu_list \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
@@ -147,12 +148,12 @@ f_become_root_via_sudo()
#
# sudo(8) access denied. Prompt for their password.
#
- msg="$msg_please_enter_password"
+ prompt="$msg_please_enter_password"
hline="$hline_alnum_punc_tab_enter"
f_dialog_inputbox_size height width \
"$DIALOG_TITLE" \
"$DIALOG_BACKTITLE" \
- "$msg" \
+ "$prompt" \
"$hline"
#
@@ -168,7 +169,7 @@ f_become_root_via_sudo()
--hline "$hline" \
--ok-label "$msg_ok" \
--cancel-label "$msg_cancel" \
- --password --inputbox "$msg" \
+ --password --inputbox "$prompt" \
$height $width \
2>&1 > /dev/null )
retval=$?
@@ -184,7 +185,7 @@ f_become_root_via_sudo()
--ok-label "$msg_ok" \
--cancel-label "$msg_cancel" \
--insecure \
- --passwordbox "$msg" \
+ --passwordbox "$prompt" \
$height $width \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
) || exit $?
diff --git a/usr.sbin/bsdconfig/share/packages/packages.subr b/usr.sbin/bsdconfig/share/packages/packages.subr
index 3bc37b5..dae80a1 100755
--- a/usr.sbin/bsdconfig/share/packages/packages.subr
+++ b/usr.sbin/bsdconfig/share/packages/packages.subr
@@ -277,25 +277,26 @@ f_package_calculate_rundeps()
#
f_package_menu_categories()
{
- local var_to_get="$1" defaultitem="$2" category_list menu_list
+ local var_to_get="$1" defaultitem="$2"
+ local prompt="$msg_please_select_a_category_to_display"
+ local menu_list="
+ '> $msg_review' '$msg_review_desc' '$msg_review_help'
+ " # End-Quote
+ local hline=
f_package_calculate_rundeps
# updates package mark variables and SELECTED_PACKAGES
f_package_calculate_totals
# creates _{varcat}_ninstalled and _{varcat}_nselected
+ local category_list
debug= f_getvar "$var_to_get" category_list || return $FAILURE
# Accent the category menu list with ninstalled/nselected
eval f_package_accent_category_menu category_list $category_list
- local prompt="$msg_please_select_a_category_to_display"
- local hline=""
-
- menu_list="
- '> $msg_review' '$msg_review_desc' '$msg_review_help'
- $category_list
- " # End-Quote
+ # Add list of categories to menu list
+ menu_list="$menu_list $category_list"
local height width rows
eval f_dialog_menu_with_help_size height width rows \
@@ -365,22 +366,26 @@ f_package_index_get_page()
#
f_package_menu_select()
{
- local category="$1" page="${2:-1}" defaultitem="$3"
- local varcat npkgs=0 npages menu_list
+ local category="$1" page="${2:-1}"
+ local prompt= # Calculated below
+ local menu_list # Calculated below
+ local defaultitem="$3"
+ local hline="$hline_arrows_tab_punc_enter"
f_isinteger "$page" || return $FAILURE
+ local varcat
f_str2varname "$category" varcat
- f_package_index_get_page "$category" $page index_page
# Get number of packages for this category
+ local npkgs=0
case "$category" in
"$msg_all"|"") npkgs="${_npkgs:-0}";;
*) f_getvar _npkgs_$varcat npkgs
esac
# Calculate number of pages
- npages=$(( ${npkgs:=0} / $PACKAGE_MENU_PAGESIZE ))
+ local npages=$(( ${npkgs:=0} / $PACKAGE_MENU_PAGESIZE ))
# Add a page to the pagecount if not evenly divisible
[ $(( $npages * $PACKAGE_MENU_PAGESIZE )) -lt $npkgs ] &&
@@ -407,6 +412,9 @@ f_package_menu_select()
next_page="$next_page*"
fi
+ local index_page
+ f_package_index_get_page "$category" $page index_page
+
menu_list="
${add_prev:+'> $previous_page' '' ${SHOW_DESC:+''}}
${add_next:+'> $next_page' '' ${SHOW_DESC:+''}}
@@ -446,7 +454,6 @@ f_package_menu_select()
${add_next:+'> $next_page' '' ${SHOW_DESC:+''}}
" # End-Quote
- local prompt=""
# Accept/Translate i18n "All" but other category names must
# match tree definitions from INDEX, ports, FTP, etc.
case "$category" in
@@ -456,7 +463,6 @@ f_package_menu_select()
prompt="$prompt $( printf "$msg_page_of_npages" \
"$page" "$npages" )"
- local hline="$hline_arrows_tab_punc_enter"
local mheight mwidth mrows
f_dialog_menu${SHOW_DESC:+_with_help}_size mheight mwidth mrows \
\"\$DIALOG_TITLE\" \"\$DIALOG_BACKTITLE\" \
@@ -509,14 +515,16 @@ f_package_menu_select()
#
f_package_menu_deselect()
{
- local package="$1" prompt menu_list
- prompt=$( printf "$msg_what_would_you_like_to_do_with" "$package" )
- local hline="$hline_alnum_arrows_punc_tab_enter"
- menu_list="
+ local package="$1"
+ local prompt # Calculated below
+ local menu_list="
'X $msg_installed' '$msg_installed_desc'
'R $msg_reinstall' '$msg_reinstall_desc'
'U $msg_uninstall' '$msg_uninstall_desc'
" # End-Quote
+ local hline="$hline_alnum_arrows_punc_tab_enter"
+
+ prompt=$( printf "$msg_what_would_you_like_to_do_with" "$package" )
local height width rows
eval f_dialog_menu_size height width rows \
@@ -551,12 +559,16 @@ f_package_menu_deselect()
#
f_package_review()
{
- local prompt package varpkg mark menu_list=
- prompt=$( printf "$msg_reviewing_selected_packages" \
- "$_All_nselected" )
+ local prompt # Calculated below
+ local menu_list # Calculated below
local hline="$hline_alnum_arrows_punc_tab_enter"
+
f_dprintf "f_package_review: SELECTED_PACKAGES=[%s]" \
"$SELECTED_PACKAGES"
+
+ prompt=$( printf "$msg_reviewing_selected_packages" "$_All_nselected" )
+
+ local package varpkg mark
for package in $SELECTED_PACKAGES; do
mark=
f_str2varname "$package" varpkg
OpenPOWER on IntegriCloud