Try harder to find a viable print solution on GTK.
Fixes: lp:1836473 * https://bugs.launchpad.net/kicad/+bug/1836473
This commit is contained in:
parent
64c012c175
commit
678294b8a6
|
@ -269,6 +269,8 @@ void OpenFile( const wxString& file )
|
||||||
|
|
||||||
if( !command.IsEmpty() )
|
if( !command.IsEmpty() )
|
||||||
ProcessExecute( command );
|
ProcessExecute( command );
|
||||||
|
|
||||||
|
DisplayError( NULL, wxString::Format( _( "Cannot print '%s'.\n\nUnknown filetype." ), file ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -276,55 +278,67 @@ void PrintFile( const wxString& file )
|
||||||
{
|
{
|
||||||
wxFileName fileName( file );
|
wxFileName fileName( file );
|
||||||
wxString ext = fileName.GetExt();
|
wxString ext = fileName.GetExt();
|
||||||
wxString command;
|
wxFileType* filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( ext );
|
||||||
|
|
||||||
#ifdef __WXMAC__
|
if( !filetype )
|
||||||
|
return;
|
||||||
|
|
||||||
|
wxString printCommand;
|
||||||
|
wxString openCommand;
|
||||||
wxString application;
|
wxString application;
|
||||||
|
|
||||||
|
wxFileType::MessageParameters params( file );
|
||||||
|
filetype->GetPrintCommand( &printCommand, params );
|
||||||
|
filetype->GetOpenCommand( &openCommand, params );
|
||||||
|
delete filetype;
|
||||||
|
|
||||||
|
if( !printCommand.IsEmpty() )
|
||||||
|
{
|
||||||
|
ProcessExecute( printCommand );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __WXMAC__
|
||||||
if( ext == "ps" || ext == "pdf" )
|
if( ext == "ps" || ext == "pdf" )
|
||||||
application = "Preview";
|
application = "Preview";
|
||||||
else if( ext == "csv" )
|
else if( ext == "csv" )
|
||||||
application = "Numbers";
|
application = "Numbers";
|
||||||
else if( ext == "txt" || ext == "rpt" )
|
else if( ext == "txt" || ext == "rpt" || ext == "pos" || ext == "cmp" || ext == "net" )
|
||||||
application = "TextEdit";
|
application = "TextEdit";
|
||||||
|
|
||||||
if( !application.IsEmpty() )
|
if( !application.IsEmpty() )
|
||||||
{
|
{
|
||||||
command.Printf( "osascript -e 'tell application \"%s\"' "
|
printCommand.Printf( "osascript -e 'tell application \"%s\"' "
|
||||||
"-e ' set srcFileRef to (open POSIX file \"%s\")' "
|
"-e ' set srcFileRef to (open POSIX file \"%s\")' "
|
||||||
"-e ' activate' "
|
"-e ' activate' "
|
||||||
"-e ' print srcFileRef print dialog true' "
|
"-e ' print srcFileRef print dialog true' "
|
||||||
"-e 'end tell' ",
|
"-e 'end tell' ",
|
||||||
application,
|
application,
|
||||||
file );
|
file );
|
||||||
}
|
system( printCommand.c_str() );
|
||||||
else
|
|
||||||
{
|
|
||||||
// Let the Finder find an associated application. Note that this method doesn't
|
|
||||||
// support opening the print dialog, and if the app doesn't support the AppleScript
|
|
||||||
// print command then it won't do that either -- but it's better than nothing.
|
|
||||||
command.Printf( "osascript -e 'tell application \"Finder\"' "
|
|
||||||
"-e ' set srcFileRef to (open POSIX file \"%s\")' "
|
|
||||||
"-e ' print srcFileRef' "
|
|
||||||
"-e 'end tell' ",
|
|
||||||
file );
|
|
||||||
}
|
|
||||||
|
|
||||||
system( command.c_str() );
|
|
||||||
#else
|
|
||||||
wxFileType* filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( ext );
|
|
||||||
|
|
||||||
if( !filetype )
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
wxFileType::MessageParameters params( file );
|
|
||||||
filetype->GetPrintCommand( &command, params );
|
|
||||||
delete filetype;
|
|
||||||
|
|
||||||
if( !command.IsEmpty() )
|
|
||||||
ProcessExecute( command );
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __WXGTK__
|
||||||
|
if( ext == "ps" || ext == "pdf"
|
||||||
|
|| ext == "csv"
|
||||||
|
|| ext == "txt" || ext == "rpt" || ext == "pos" || ext == "cmp" || ext == "net" )
|
||||||
|
{
|
||||||
|
printCommand.Printf( "lp \"%s\"", file );
|
||||||
|
ProcessExecute( printCommand );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// everything else failed; try to open the file
|
||||||
|
if( !openCommand.IsEmpty() )
|
||||||
|
{
|
||||||
|
ProcessExecute( openCommand );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DisplayError( NULL, wxString::Format( _( "Cannot print '%s'.\n\nUnknown filetype." ), file ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue