Remove printing files from Project Manager
This commit is contained in:
parent
aa0a00dee7
commit
921105330a
|
@ -211,104 +211,6 @@ void OpenFile( const wxString& file )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool doPrintFile( const wxString& file, bool aDryRun )
|
|
||||||
{
|
|
||||||
wxString ext = wxFileName( file ).GetExt();
|
|
||||||
|
|
||||||
#ifdef __WXMSW__
|
|
||||||
wxFileType* filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( ext );
|
|
||||||
|
|
||||||
if( filetype )
|
|
||||||
{
|
|
||||||
wxString printCommand;
|
|
||||||
wxFileType::MessageParameters params( file );
|
|
||||||
|
|
||||||
filetype->GetPrintCommand( &printCommand, params );
|
|
||||||
|
|
||||||
delete filetype;
|
|
||||||
|
|
||||||
if( !printCommand.IsEmpty() )
|
|
||||||
{
|
|
||||||
if( !aDryRun )
|
|
||||||
wxExecute( printCommand );
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __WXMAC__
|
|
||||||
wxString app;
|
|
||||||
|
|
||||||
if( ext == "ps" || ext == "pdf" )
|
|
||||||
app = "Preview";
|
|
||||||
else if( ext == "csv" )
|
|
||||||
app = "Numbers";
|
|
||||||
else if( ext == "txt" )
|
|
||||||
app = "TextEdit";
|
|
||||||
else if( ext == "rpt" || ext == "pos" || ext == "cmp" || ext == "net" || ext == "kicad_dru" )
|
|
||||||
app = "TextEdit";
|
|
||||||
|
|
||||||
if( !app.IsEmpty() )
|
|
||||||
{
|
|
||||||
if( !aDryRun )
|
|
||||||
{
|
|
||||||
wxString ascript = "osascript ";
|
|
||||||
ascript += "-e 'tell app \"" + app + "\"' ";
|
|
||||||
ascript += "-e ' set srcFileRef to (open POSIX file \"" + EscapeString( file, CTX_QUOTED_STR ) + "\")' ";
|
|
||||||
ascript += "-e ' activate' ";
|
|
||||||
ascript += "-e ' print srcFileRef print dialog true' ";
|
|
||||||
ascript += "-e 'end tell' ";
|
|
||||||
|
|
||||||
wxExecute( ascript );
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __WXGTK__
|
|
||||||
if( ext == "ps" || ext == "pdf"
|
|
||||||
|| ext == "csv"
|
|
||||||
|| ext == "txt"
|
|
||||||
|| ext == "rpt" || ext == "pos" || ext == "cmp" || ext == "net" || ext == "kicad_dru" )
|
|
||||||
{
|
|
||||||
if( !aDryRun )
|
|
||||||
{
|
|
||||||
const wchar_t* args[3];
|
|
||||||
args[0] = wxT( "lp" );
|
|
||||||
args[1] = file.wc_str();
|
|
||||||
args[2] = nullptr;
|
|
||||||
|
|
||||||
wxExecute( const_cast<wchar_t**>( args ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if( !aDryRun )
|
|
||||||
{
|
|
||||||
DisplayError( nullptr, wxString::Format( _( "Cannot print '%s'.\n\nUnknown file type." ),
|
|
||||||
file ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PrintFile( const wxString& file )
|
|
||||||
{
|
|
||||||
doPrintFile( file, false );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool CanPrintFile( const wxString& file )
|
|
||||||
{
|
|
||||||
return doPrintFile( file, true );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void KiCopyFile( const wxString& aSrcPath, const wxString& aDestPath, wxString& aErrors )
|
void KiCopyFile( const wxString& aSrcPath, const wxString& aDestPath, wxString& aErrors )
|
||||||
{
|
{
|
||||||
if( !wxCopyFile( aSrcPath, aDestPath ) )
|
if( !wxCopyFile( aSrcPath, aDestPath ) )
|
||||||
|
|
|
@ -48,9 +48,6 @@ class EDA_LIST_DIALOG;
|
||||||
bool OpenPDF( const wxString& file );
|
bool OpenPDF( const wxString& file );
|
||||||
void OpenFile( const wxString& file );
|
void OpenFile( const wxString& file );
|
||||||
|
|
||||||
void PrintFile( const wxString& file );
|
|
||||||
bool CanPrintFile( const wxString& file );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param aSrcPath is the full filename of the source.
|
* @param aSrcPath is the full filename of the source.
|
||||||
* @param aDestPath is the full filename of the target
|
* @param aDestPath is the full filename of the target
|
||||||
|
|
|
@ -61,7 +61,6 @@ enum id_kicad_frm {
|
||||||
ID_PROJECT_NEWDIR,
|
ID_PROJECT_NEWDIR,
|
||||||
ID_PROJECT_OPEN_DIR,
|
ID_PROJECT_OPEN_DIR,
|
||||||
ID_PROJECT_DELETE,
|
ID_PROJECT_DELETE,
|
||||||
ID_PROJECT_PRINT,
|
|
||||||
ID_PROJECT_RENAME,
|
ID_PROJECT_RENAME,
|
||||||
|
|
||||||
ID_EDIT_LOCAL_FILE_IN_TEXT_EDITOR,
|
ID_EDIT_LOCAL_FILE_IN_TEXT_EDITOR,
|
||||||
|
|
|
@ -148,12 +148,6 @@ void PROJECT_TREE_ITEM::Delete()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PROJECT_TREE_ITEM::Print()
|
|
||||||
{
|
|
||||||
PrintFile( GetFileName() );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PROJECT_TREE_ITEM::Activate( PROJECT_TREE_PANE* aTreePrjFrame )
|
void PROJECT_TREE_ITEM::Activate( PROJECT_TREE_PANE* aTreePrjFrame )
|
||||||
{
|
{
|
||||||
wxString sep = wxFileName::GetPathSeparator();
|
wxString sep = wxFileName::GetPathSeparator();
|
||||||
|
|
|
@ -128,7 +128,6 @@ BEGIN_EVENT_TABLE( PROJECT_TREE_PANE, wxSashLayoutWindow )
|
||||||
EVT_MENU( ID_PROJECT_NEWDIR, PROJECT_TREE_PANE::onCreateNewDirectory )
|
EVT_MENU( ID_PROJECT_NEWDIR, PROJECT_TREE_PANE::onCreateNewDirectory )
|
||||||
EVT_MENU( ID_PROJECT_OPEN_DIR, PROJECT_TREE_PANE::onOpenDirectory )
|
EVT_MENU( ID_PROJECT_OPEN_DIR, PROJECT_TREE_PANE::onOpenDirectory )
|
||||||
EVT_MENU( ID_PROJECT_DELETE, PROJECT_TREE_PANE::onDeleteFile )
|
EVT_MENU( ID_PROJECT_DELETE, PROJECT_TREE_PANE::onDeleteFile )
|
||||||
EVT_MENU( ID_PROJECT_PRINT, PROJECT_TREE_PANE::onPrintFile )
|
|
||||||
EVT_MENU( ID_PROJECT_RENAME, PROJECT_TREE_PANE::onRenameFile )
|
EVT_MENU( ID_PROJECT_RENAME, PROJECT_TREE_PANE::onRenameFile )
|
||||||
EVT_IDLE( PROJECT_TREE_PANE::onIdle )
|
EVT_IDLE( PROJECT_TREE_PANE::onIdle )
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
@ -617,7 +616,6 @@ void PROJECT_TREE_PANE::onRight( wxTreeEvent& Event )
|
||||||
bool can_edit = true;
|
bool can_edit = true;
|
||||||
bool can_rename = true;
|
bool can_rename = true;
|
||||||
bool can_delete = true;
|
bool can_delete = true;
|
||||||
bool can_print = true;
|
|
||||||
|
|
||||||
if( selection.size() == 0 )
|
if( selection.size() == 0 )
|
||||||
return;
|
return;
|
||||||
|
@ -628,7 +626,6 @@ void PROJECT_TREE_PANE::onRight( wxTreeEvent& Event )
|
||||||
can_switch_to_project = false;
|
can_switch_to_project = false;
|
||||||
can_create_new_directory = false;
|
can_create_new_directory = false;
|
||||||
can_rename = false;
|
can_rename = false;
|
||||||
can_print = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for( PROJECT_TREE_ITEM* item : selection )
|
for( PROJECT_TREE_ITEM* item : selection )
|
||||||
|
@ -639,7 +636,6 @@ void PROJECT_TREE_PANE::onRight( wxTreeEvent& Event )
|
||||||
can_switch_to_project = false;
|
can_switch_to_project = false;
|
||||||
can_edit = false;
|
can_edit = false;
|
||||||
can_rename = false;
|
can_rename = false;
|
||||||
can_print = false;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -650,7 +646,6 @@ void PROJECT_TREE_PANE::onRight( wxTreeEvent& Event )
|
||||||
case TREE_FILE_TYPE::LEGACY_PROJECT:
|
case TREE_FILE_TYPE::LEGACY_PROJECT:
|
||||||
case TREE_FILE_TYPE::JSON_PROJECT:
|
case TREE_FILE_TYPE::JSON_PROJECT:
|
||||||
can_rename = false;
|
can_rename = false;
|
||||||
can_print = false;
|
|
||||||
|
|
||||||
if( item->GetId() == m_TreeProject->GetRootItem() )
|
if( item->GetId() == m_TreeProject->GetRootItem() )
|
||||||
{
|
{
|
||||||
|
@ -668,7 +663,6 @@ void PROJECT_TREE_PANE::onRight( wxTreeEvent& Event )
|
||||||
can_switch_to_project = false;
|
can_switch_to_project = false;
|
||||||
can_edit = false;
|
can_edit = false;
|
||||||
can_rename = false;
|
can_rename = false;
|
||||||
can_print = false;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -676,9 +670,6 @@ void PROJECT_TREE_PANE::onRight( wxTreeEvent& Event )
|
||||||
can_create_new_directory = false;
|
can_create_new_directory = false;
|
||||||
can_open_this_directory = false;
|
can_open_this_directory = false;
|
||||||
|
|
||||||
if( !CanPrintFile( full_file_name ) )
|
|
||||||
can_print = false;
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -781,19 +772,6 @@ void PROJECT_TREE_PANE::onRight( wxTreeEvent& Event )
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if( can_print )
|
|
||||||
{
|
|
||||||
popup_menu.AppendSeparator();
|
|
||||||
AddMenuItem( &popup_menu, ID_PROJECT_PRINT,
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
_( "Print..." ),
|
|
||||||
#else
|
|
||||||
_( "Print" ),
|
|
||||||
#endif
|
|
||||||
_( "Print the contents of the file" ), KiBitmap( BITMAPS::print_button ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( popup_menu.GetMenuItemCount() > 0 )
|
if( popup_menu.GetMenuItemCount() > 0 )
|
||||||
PopupMenu( &popup_menu );
|
PopupMenu( &popup_menu );
|
||||||
}
|
}
|
||||||
|
@ -835,15 +813,6 @@ void PROJECT_TREE_PANE::onDeleteFile( wxCommandEvent& event )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PROJECT_TREE_PANE::onPrintFile( wxCommandEvent& event )
|
|
||||||
{
|
|
||||||
std::vector<PROJECT_TREE_ITEM*> tree_data = GetSelectedData();
|
|
||||||
|
|
||||||
for( PROJECT_TREE_ITEM* item_data : tree_data )
|
|
||||||
item_data->Print();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PROJECT_TREE_PANE::onRenameFile( wxCommandEvent& event )
|
void PROJECT_TREE_PANE::onRenameFile( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
wxTreeItemId curr_item = m_TreeProject->GetFocusedItem();
|
wxTreeItemId curr_item = m_TreeProject->GetFocusedItem();
|
||||||
|
|
|
@ -118,12 +118,6 @@ private:
|
||||||
*/
|
*/
|
||||||
void onDeleteFile( wxCommandEvent& event );
|
void onDeleteFile( wxCommandEvent& event );
|
||||||
|
|
||||||
/**
|
|
||||||
* Function onDeleteFile
|
|
||||||
* Print the selected file or directory in the tree project
|
|
||||||
*/
|
|
||||||
void onPrintFile( wxCommandEvent& event );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function onRenameFile
|
* Function onRenameFile
|
||||||
* Rename the selected file or directory in the tree project
|
* Rename the selected file or directory in the tree project
|
||||||
|
|
Loading…
Reference in New Issue