From 27bb89d687334bd461e807c7acad3955ba546782 Mon Sep 17 00:00:00 2001 From: David Shaw Date: Tue, 11 Apr 2006 19:20:08 +0000 Subject: [PATCH] * options.skel, photoid.c (get_default_photo_command): Find an image viewer at runtime. Seems FC5 doesn't have xloadimage. --- g10/ChangeLog | 5 +++++ g10/options.skel | 7 +++---- g10/photoid.c | 18 ++++++++++++++++-- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/g10/ChangeLog b/g10/ChangeLog index 2a6ad9fe9..664f9fe1d 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,8 @@ +2006-04-11 David Shaw + + * options.skel, photoid.c (get_default_photo_command): Find an + image viewer at runtime. Seems FC5 doesn't have xloadimage. + 2006-04-08 David Shaw * getkey.c (parse_auto_key_locate): Fix dupe-removal code. diff --git a/g10/options.skel b/g10/options.skel index b72c7d523..fa77daa86 100644 --- a/g10/options.skel +++ b/g10/options.skel @@ -182,14 +182,13 @@ keyserver hkp://subkeys.pgp.net # input is the best way to do this as it avoids the time and effort in # generating and then cleaning up a secure temp file. # -# The default program is "xloadimage -fork -quiet -title 'KeyID 0x%k' stdin" -# On Mac OS X and Windows, the default is to use your regular JPEG image -# viewer. +# If no photo-viewer is provided, GnuPG will look for xloadimage, eog, +# or display (ImageMagick). On Mac OS X and Windows, the default is +# to use your regular JPEG image viewer. # # Some other viewers: # photo-viewer "qiv %i" # photo-viewer "ee %i" -# photo-viewer "display -title 'KeyID 0x%k'" # # This one saves a copy of the photo ID in your home directory: # photo-viewer "cat > ~/photoid-for-key-%k.%t" diff --git a/g10/photoid.c b/g10/photoid.c index d2a249167..3676d3869 100644 --- a/g10/photoid.c +++ b/g10/photoid.c @@ -259,7 +259,8 @@ char *image_type_to_string(byte type,int style) } #if !defined(FIXED_PHOTO_VIEWER) && !defined(DISABLE_PHOTO_VIEWER) -static const char *get_default_photo_command(void) +static const char * +get_default_photo_command(void) { #if defined(_WIN32) OSVERSIONINFO osvi; @@ -278,7 +279,14 @@ static const char *get_default_photo_command(void) #elif defined(__riscos__) return "Filer_Run %I"; #else - return "xloadimage -fork -quiet -title 'KeyID 0x%k' stdin"; + if(path_access("xloadimage",X_OK)==0) + return "xloadimage -fork -quiet -title 'KeyID 0x%k' stdin"; + else if(path_access("eog",X_OK)==0) + return "eog %i"; + else if(path_access("display",X_OK)==0) + return "display -title 'KeyID 0x%k' %i"; + else + return ""; #endif } #endif @@ -316,6 +324,12 @@ void show_photos(const struct user_attribute *attrs, opt.photo_viewer=get_default_photo_command(); #endif + if(!*opt.photo_viewer) + { + log_info(_("no photo viewer set\n")); + goto fail; + } + /* make command grow */ command=pct_expando(opt.photo_viewer,&args); if(!command)