Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Nov 2013 10:23:38 +0000 (UTC)
From:      Devin Teske <dteske@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r257783 - in head/usr.sbin/bsdconfig: include share
Message-ID:  <201311071023.rA7ANcMn028972@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dteske
Date: Thu Nov  7 10:23:37 2013
New Revision: 257783
URL: http://svnweb.freebsd.org/changeset/base/257783

Log:
  Add an f_show_err() function -- acts pretty much the same as f_show_msg()
  except it stylizes the msgbox widget to indicate an Error has occurred by
  setting an appropriate title and default message.

Modified:
  head/usr.sbin/bsdconfig/include/messages.subr
  head/usr.sbin/bsdconfig/share/common.subr

Modified: head/usr.sbin/bsdconfig/include/messages.subr
==============================================================================
--- head/usr.sbin/bsdconfig/include/messages.subr	Thu Nov  7 10:20:19 2013	(r257782)
+++ head/usr.sbin/bsdconfig/include/messages.subr	Thu Nov  7 10:23:37 2013	(r257783)
@@ -40,6 +40,7 @@ msg_afterstep_desc="Ports to support the
 msg_all="All"
 msg_all_desc="All available packages in all categories."
 msg_always_try_sudo_when_run_as="Always try sudo(8) when run as %s"
+msg_an_unknown_error_occurred="An unknown error occurred"
 msg_arabic_desc="Ported software for Arab countries."
 msg_archivers_desc="Utilities for archiving and unarchiving data."
 msg_armenia="Armenia"

Modified: head/usr.sbin/bsdconfig/share/common.subr
==============================================================================
--- head/usr.sbin/bsdconfig/share/common.subr	Thu Nov  7 10:20:19 2013	(r257782)
+++ head/usr.sbin/bsdconfig/share/common.subr	Thu Nov  7 10:23:37 2013	(r257783)
@@ -358,6 +358,30 @@ f_show_msg()
 	fi
 }
 
+# f_show_err $format [$arguments ...]
+#
+# Display a message in a dialog box with ``Error'' i18n title (overridden by
+# setting msg_error) using printf(1) syntax. If running non-interactively,
+# the process will terminate (using [above] f_die()).
+#
+f_show_err()
+{
+	[ "$nonInteractive" ] && f_die
+
+	local msg
+	msg=$( printf "$@" )
+
+	: ${msg:=${msg_an_unknown_error_occurred:-An unknown error occurred}}
+
+	if [ "$_DIALOG_SUBR" ]; then
+		f_dialog_title "${msg_error:-Error}"
+		f_dialog_msgbox "$msg"
+		f_dialog_title_restore
+	else
+		dialog --title "${msg_error:-Error}" --msgbox "$msg" 0 0
+	fi
+	return $SUCCESS
+}
 
 # f_yesno $format [$arguments ...]
 #



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201311071023.rA7ANcMn028972>