mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
gpg: Improve the photo image viewer selection.
* g10/exec.c (w32_system): Add "!ShellExecute" special. * g10/photoid.c (get_default_photo_command): Use the new ShellExecute under Windows and fallbac to 'display' and 'xdg-open' in the Unix case. (show_photos): Flush stdout so that the output is shown before the image pops up. -- For Unix this basically syncs the code with what we have in gpg 1.4. Note that xdg-open may not be used when running as root which we support here. For Windows we now use ShellExecute as this seems to be preferred over "cmd /c start"; however this does not solve the actual problem we had in the bug report. To solve that problem we resort to a wait parameter which defaults to 400ms. This works on my Windows-10 virtualized test box. If we can figure out which simple viewers are commonly installed on Windows we should enhance this patch to test for them. GnuPG-bug-id: 4334 Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
6fc5df1e10
commit
7e5847da0f
3 changed files with 113 additions and 36 deletions
|
@ -262,7 +262,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;
|
||||
|
@ -274,14 +275,21 @@ static const char *get_default_photo_command(void)
|
|||
if(osvi.dwPlatformId==VER_PLATFORM_WIN32_WINDOWS)
|
||||
return "start /w %i";
|
||||
else
|
||||
return "cmd /c start /w %i";
|
||||
return "!ShellExecute 400 %i";
|
||||
#elif defined(__APPLE__)
|
||||
/* OS X. This really needs more than just __APPLE__. */
|
||||
return "open %I";
|
||||
#elif defined(__riscos__)
|
||||
return "Filer_Run %I";
|
||||
#else
|
||||
return "xloadimage -fork -quiet -title 'KeyID 0x%k' stdin";
|
||||
if (!path_access ("xloadimage", X_OK))
|
||||
return "xloadimage -fork -quiet -title 'KeyID 0x%k' stdin";
|
||||
else if (!path_access ("display",X_OK))
|
||||
return "display -title 'KeyID 0x%k' %i";
|
||||
else if (getuid () && !path_access ("xdg-open", X_OK))
|
||||
return "xdg-open %i";
|
||||
else
|
||||
return "/bin/true";
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
@ -312,6 +320,8 @@ show_photos (ctrl_t ctrl, const struct user_attribute *attrs, int count,
|
|||
if (pk)
|
||||
keyid_from_pk (pk, kid);
|
||||
|
||||
es_fflush (es_stdout);
|
||||
|
||||
for(i=0;i<count;i++)
|
||||
if(attrs[i].type==ATTRIB_IMAGE &&
|
||||
parse_image_header(&attrs[i],&args.imagetype,&len))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue