diff options
author | Mike Newman <MikeGTN@src.gnome.org> | 2003-06-09 21:35:39 +0000 |
---|---|---|
committer | Mike Newman <MikeGTN@src.gnome.org> | 2003-06-09 21:35:39 +0000 |
commit | 98772744e904127cda466f1b5be3969ae5fbdcc2 (patch) | |
tree | 7d1b95196b8240f058a0c777724526e9a91096a2 | |
parent | Allow multiple file selections. (diff) | |
download | zenity-98772744e904127cda466f1b5be3969ae5fbdcc2.tar.gz zenity-98772744e904127cda466f1b5be3969ae5fbdcc2.tar.bz2 zenity-98772744e904127cda466f1b5be3969ae5fbdcc2.zip |
Committing patch to fall back to dialog if DISPLAY not set from
Kevin C. Krinke <kckrinke@opendoorsoftware.com>
-rw-r--r-- | ChangeLog | 4 | ||||
-rwxr-xr-x | src/gdialog.in | 77 |
2 files changed, 81 insertions, 0 deletions
@@ -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> * data/zenity.1, help/C/zenity.xml: Update docs for new file selection diff --git a/src/gdialog.in b/src/gdialog.in index a27c0e9a..48699d8c 100755 --- a/src/gdialog.in +++ b/src/gdialog.in @@ -20,6 +20,83 @@ my $argn = 0; # counter for walking args my $args = $#ARGV + 1; # total number of command line arguments 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 sub get_arg () { |