1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-24 11:29:10 +00:00

Add new f_yesno/f_noyes wrapper functions (which take printf(1) syntax).

This commit is contained in:
Devin Teske 2013-01-14 01:15:25 +00:00
parent 3c91c65a2b
commit 27ff90aa87
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=245402
5 changed files with 51 additions and 15 deletions

View File

@ -456,9 +456,8 @@ f_dialog_menu_netdev_edit()
# Re/Apply the settings if desired
#
if [ ! "$dhcp" ]; then
f_dialog_yesno "Would you like to bring the $interface" \
"interface up right now?"
if [ $? -eq $SUCCESS ]; then
if f_yesno "$msg_bring_interface_up" "$interface"
then
f_show_info "$msg_bring_interface_up" "$interface"
local dr="$( f_sysrc_get defaultrouter )" err

View File

@ -201,10 +201,8 @@ f_dialog_input_hostname()
f_show_msg "$msg_activate_hostname_x11warning" \
"$( hostname )" "$hostname"
else
f_dialog_yesno "$(
printf "$msg_activate_hostname" \
"$( hostname )" "$hostname" \
)" \
f_yesno "$msg_activate_hostname" \
"$( hostname )" "$hostname" \
&& hostname "$hostname"
fi
fi

View File

@ -129,11 +129,8 @@ f_dialog_input_defaultrouter()
#
if [ "$( f_route_get_default )" != "$defaultrouter" ]; then
f_dialog_clear
f_dialog_yesno "$(
printf "$msg_activate_default_router" \
"$( f_route_get_default )" "$defaultrouter"
)"
f_yesno "$msg_activate_default_router" \
"$( f_route_get_default )" "$defaultrouter"
if [ $? -eq $SUCCESS ]; then
local err

View File

@ -214,6 +214,50 @@ f_show_msg()
fi
}
# f_yesno $fmt [ $opts ... ]
#
# Display a message in a dialog yes/no box using printf(1) syntax.
#
f_yesno()
{
local msg
msg=$( printf "$@" )
#
# Use f_dialog_yesno from dialog.subr if possible, otherwise fall
# back to dialog(1) (without options, making it obvious when using
# un-aided system dialog).
#
if f_have f_dialog_yesno; then
f_dialog_yesno "$msg"
else
dialog --yesno "$msg" 0 0
fi
}
# f_noyes $fmt [ $opts ... ]
#
# Display a message in a dialog yes/no box using printf(1) syntax.
# NOTE: THis is just like the f_yesno function except "No" is default.
#
f_noyes()
{
local msg
msg=$( printf "$@" )
#
# Use f_dialog_noyes from dialog.subr if possible, otherwise fall
# back to dialog(1) (without options, making it obvious when using
# un-aided system dialog).
#
if f_have f_dialog_noyes; then
f_dialog_noyes "$msg"
else
dialog --defaultno --yesno "$msg" 0 0
fi
}
# f_show_help $file
#
# Display a language help-file. Automatically takes $LANG and $LC_ALL into

View File

@ -210,9 +210,7 @@ dialog_menu_delete()
[ $# -ge 1 ] || return $FAILURE
if [ $# -eq 1 ]; then
msg=$( printf "$msg_are_you_sure_you_want_to_delete" \
"$delete_vars" )
f_dialog_noyes "$msg"
f_noyes "$msg_are_you_sure_you_want_to_delete" "$delete_vars"
return $?
fi