← Back to team overview

kicad-developers team mailing list archive

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

 

Fabrizio,

You have this in the wrong part of if( !Pgm().UseSystemPdfBrowser() )
statement.  Use want it in the else{} (the system pdf browser) section.
Don't worry about it.  I will fix it and commit it.

Thanks,

Wayne

On 6/7/2017 11:37 AM, Fabrizio Tappero wrote:
> Hi Wayne,
> I guess this is what you want
> cheers
> Fabrizio
> 
> 
> pdf-vieweer-inside-main-k.patch
> From 544416795fed2492b3ffa96b4b2c92285ce5071e Mon Sep 17 00:00:00 2001
> From: Fabrizio Tappero <fabrizio.tappero@xxxxxxxxx
> <mailto:fabrizio.tappero@xxxxxxxxx>>
> Date: Wed, 7 Jun 2017 17:35:37 +0200
> Subject: [PATCH] read and use default linux pdf viewer inside main kicad
>  windows when pdf is double-clicked
> 
> ---
>  common/gestfich.cpp | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/common/gestfich.cpp b/common/gestfich.cpp
> index b68ec68..b54003f 100644
> --- a/common/gestfich.cpp
> +++ b/common/gestfich.cpp
> @@ -352,7 +352,10 @@ bool OpenPDF( const wxString& file )
>      if( !Pgm().UseSystemPdfBrowser() )    //  Run the preferred PDF Browser
>      {
>          AddDelimiterString( filename );
> -        command = Pgm().GetPdfBrowserName() + wxT( " " ) + filename;
> +        if (wxLaunchDefaultApplication( filename ))
> +        {
> +            return true;
> +        }
>      }
>      else
>      {
> -- 
> 2.7.4
> 
> 
> 
> 
> On Wed, Jun 7, 2017 at 5:11 PM, Wayne Stambaugh <stambaughw@xxxxxxxxx
> <mailto:stambaughw@xxxxxxxxx>> wrote:
> 
>     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>
>     > <mailto: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
>     <https://launchpad.net/~kicad-developers>
>     > Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
>     <mailto:kicad-developers@xxxxxxxxxxxxxxxxxxx>
>     > Unsubscribe : https://launchpad.net/~kicad-developers
>     <https://launchpad.net/~kicad-developers>
>     > More help   : https://help.launchpad.net/ListHelp
>     <https://help.launchpad.net/ListHelp>
>     >
> 
>     _______________________________________________
>     Mailing list: https://launchpad.net/~kicad-developers
>     <https://launchpad.net/~kicad-developers>
>     Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
>     <mailto:kicad-developers@xxxxxxxxxxxxxxxxxxx>
>     Unsubscribe : https://launchpad.net/~kicad-developers
>     <https://launchpad.net/~kicad-developers>
>     More help   : https://help.launchpad.net/ListHelp
>     <https://help.launchpad.net/ListHelp>
> 
> 


References