diff --git a/ChangeLog b/ChangeLog index 665dce8..3476015 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2003-06-09 Kevin C. Krinke + + * src/gdialog.in: wrap gdialog.real/dialog when not in X-Window + 2003-06-09 Mike Newman * data/zenity.1, help/C/zenity.xml: Update docs for new file selection diff --git a/src/gdialog.in b/src/gdialog.in index a27c0e9..48699d8 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) +# +# 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 () {