← Back to team overview

kicad-developers team mailing list archive

Re: [PATCH] properly read default PDF viewer and use (under Linux Debian)

 

Oops!  I didn't see this post before I sent my last post.  Please ignore
it.  There is a slight problem with your patch.  You should check the
return value of wxLaunchDefaultApplication and take the appropriate
action.  In your patch, if wxLaunchDefaultApplication cannot launch the
pdf viewer, it fails silently.  A better solution would be:

        if( wxLaunchDefaultApplication( file ) )
            return true;

This would leave the command string empty and display the error message
if wxLaunchDefaultApplication fails.

Please make this change and I will commit your patch.

Thanks,

Wayne

On 6/7/2017 10:50 AM, Fabrizio Tappero wrote:
> Hi guys
> 
> the following patch fix the problem of detecting the default PDF viewer
> and use it to open PDF files (under Linux Debian) in the kicad main
> window when you double click on a PDF doc.
> 
> It would be great to test it under windows and OSX.
> 
> cheers
> Fabrizio
> 
> 
> 
> 
> 
> From b3aa02b874476ae9f25311b4525e03b635091ed1 Mon Sep 17 00:00:00 2001
> From: Fabrizio Tappero <fabrizio.tappero@xxxxxxxxx
> <mailto:fabrizio.tappero@xxxxxxxxx>>
> Date: Wed, 7 Jun 2017 16:43:16 +0200
> Subject: [PATCH] default pdf reader is now properly detected unider Linux
> 
> ---
>  common/gestfich.cpp | 11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/common/gestfich.cpp b/common/gestfich.cpp
> index 3a09576..b68ec68 100644
> --- a/common/gestfich.cpp
> +++ b/common/gestfich.cpp
> @@ -344,7 +344,7 @@ wxString KicadDatasPath()
>  
>  bool OpenPDF( const wxString& file )
>  {
> -    wxString command;
> +    wxString command = "";
>      wxString filename = file;
>  
>      Pgm().ReadPdfBrowserInfos();
> @@ -356,12 +356,9 @@ bool OpenPDF( const wxString& file )
>      }
>      else
>      {
> -        wxFileType* filetype =
> wxTheMimeTypesManager->GetFileTypeFromExtension( wxT( "pdf" ) );
> -
> -        if( filetype )
> -            command = filetype->GetOpenCommand( filename );
> -
> -        delete filetype;
> +        AddDelimiterString( filename );
> +        wxLaunchDefaultApplication( filename );
> +        return true;
>      }
>  
>      if( !command.IsEmpty() )
> -- 
> 2.7.4
> 
> 
> 
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help   : https://help.launchpad.net/ListHelp
> 


Follow ups

References