Committing patch to fall back to dialog if DISPLAY not set from

Kevin C. Krinke  <kckrinke@opendoorsoftware.com>
This commit is contained in:
Mike Newman 2003-06-09 21:35:39 +00:00
parent 0e4c879656
commit 98772744e9
2 changed files with 81 additions and 0 deletions

View File

@ -1,3 +1,7 @@
2003-06-09 Kevin C. Krinke <kckrinke@opendoorsoftware.com>
* src/gdialog.in: wrap gdialog.real/dialog when not in X-Window
2003-06-09 Mike Newman <mikegtn@gnome.org> 2003-06-09 Mike Newman <mikegtn@gnome.org>
* data/zenity.1, help/C/zenity.xml: Update docs for new file selection * data/zenity.1, help/C/zenity.xml: Update docs for new file selection

View File

@ -20,6 +20,83 @@ my $argn = 0; # counter for walking args
my $args = $#ARGV + 1; # total number of command line arguments my $args = $#ARGV + 1; # total number of command line arguments
my $separator = 0; # set if --separate-output is in use my $separator = 0; # set if --separate-output is in use
# Additon by: Kevin C. Krinke (kck) <kckrinke@opendoorsoftware.com>
#
# gdialog itself supports both the X-Windows interface as well as a console
# interface. Here's a fix to use regular dialog when appropriate.
# This should probably be a more advanced test of some sort, but I don't know
# of any other easy way of detecting and X-Windows environment. If someone does
# know better, please let me know. So for now this works: "no DISPLAY; no X".
unless (defined $ENV{'DISPLAY'} && length($ENV{'DISPLAY'})) {
# reset the command string
$command = "";
# examine all the available/default paths
my $PATHS = ($ENV{'PATH'}||'/bin:/usr/bin:/usr/local/bin:/opt/bin');
BIN: foreach my $PATH (split(/\:/,$PATHS)) {
if (-x $PATH."/gdialog.real") {
# Some GNU/Linux distributions divert binaries when
# other packages are installed. If this exists, chances
# are it's the real gdialog and not the Zenity wrapper.
# gdialog has full support for the Console medium and
# as such is the preference over using the "regular"
# dialog interface.
$command = $PATH."/gdialog.real ";
last BIN;
} elsif (-x $PATH."/dialog") {
# change the command and skip ahead!
$command = $PATH."/dialog ";
last BIN;
}
}
unless ($command) {
# we didn't find the dialog binary, exit(254) with a message
# to STDERR.
print STDERR "missing DISPLAY and a console dialog could".
" not be found.\n";
# exit code 254 is used because 255, 1, 2, 3 are used by Zenity
# and cDialog. This error, is a very _bad_ error so it's semi-
# non-standard at 254.
exit(254);
}
# all is well if we've made it this far
# so join the arguments double-quoting things so that proper shell
# notation is saved.
$command .= '"'.join('" "',@ARGV).'"';
# and fork the process
exec($command);
}
# Got DISPLAY, has X continue as normal...
# End Addtition by: KCK
# this just loads the current arg into $element # this just loads the current arg into $element
sub get_arg () { sub get_arg () {