From 921105330ad32b70e23dabe4f608a531d7613686 Mon Sep 17 00:00:00 2001 From: Mikolaj Wielgus Date: Tue, 2 Nov 2021 00:44:16 +0100 Subject: [PATCH] Remove printing files from Project Manager --- common/gestfich.cpp | 98 ------------------------------------- include/gestfich.h | 3 -- kicad/kicad_id.h | 1 - kicad/project_tree_item.cpp | 6 --- kicad/project_tree_pane.cpp | 31 ------------ kicad/project_tree_pane.h | 6 --- 6 files changed, 145 deletions(-) diff --git a/common/gestfich.cpp b/common/gestfich.cpp index 4ab5b5b3db..7ad46c0a2f 100644 --- a/common/gestfich.cpp +++ b/common/gestfich.cpp @@ -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( 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 ) { if( !wxCopyFile( aSrcPath, aDestPath ) ) diff --git a/include/gestfich.h b/include/gestfich.h index 9d72d547f9..ce488518ed 100644 --- a/include/gestfich.h +++ b/include/gestfich.h @@ -48,9 +48,6 @@ class EDA_LIST_DIALOG; bool OpenPDF( 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 aDestPath is the full filename of the target diff --git a/kicad/kicad_id.h b/kicad/kicad_id.h index 8f1df1bb42..147afb09c0 100644 --- a/kicad/kicad_id.h +++ b/kicad/kicad_id.h @@ -61,7 +61,6 @@ enum id_kicad_frm { ID_PROJECT_NEWDIR, ID_PROJECT_OPEN_DIR, ID_PROJECT_DELETE, - ID_PROJECT_PRINT, ID_PROJECT_RENAME, ID_EDIT_LOCAL_FILE_IN_TEXT_EDITOR, diff --git a/kicad/project_tree_item.cpp b/kicad/project_tree_item.cpp index bf05af733e..87154f18b8 100644 --- a/kicad/project_tree_item.cpp +++ b/kicad/project_tree_item.cpp @@ -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 ) { wxString sep = wxFileName::GetPathSeparator(); diff --git a/kicad/project_tree_pane.cpp b/kicad/project_tree_pane.cpp index 8268047e68..abd42d588f 100644 --- a/kicad/project_tree_pane.cpp +++ b/kicad/project_tree_pane.cpp @@ -128,7 +128,6 @@ BEGIN_EVENT_TABLE( PROJECT_TREE_PANE, wxSashLayoutWindow ) EVT_MENU( ID_PROJECT_NEWDIR, PROJECT_TREE_PANE::onCreateNewDirectory ) EVT_MENU( ID_PROJECT_OPEN_DIR, PROJECT_TREE_PANE::onOpenDirectory ) 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_IDLE( PROJECT_TREE_PANE::onIdle ) END_EVENT_TABLE() @@ -617,7 +616,6 @@ void PROJECT_TREE_PANE::onRight( wxTreeEvent& Event ) bool can_edit = true; bool can_rename = true; bool can_delete = true; - bool can_print = true; if( selection.size() == 0 ) return; @@ -628,7 +626,6 @@ void PROJECT_TREE_PANE::onRight( wxTreeEvent& Event ) can_switch_to_project = false; can_create_new_directory = false; can_rename = false; - can_print = false; } for( PROJECT_TREE_ITEM* item : selection ) @@ -639,7 +636,6 @@ void PROJECT_TREE_PANE::onRight( wxTreeEvent& Event ) can_switch_to_project = false; can_edit = false; can_rename = false; - can_print = false; continue; } @@ -650,7 +646,6 @@ void PROJECT_TREE_PANE::onRight( wxTreeEvent& Event ) case TREE_FILE_TYPE::LEGACY_PROJECT: case TREE_FILE_TYPE::JSON_PROJECT: can_rename = false; - can_print = false; if( item->GetId() == m_TreeProject->GetRootItem() ) { @@ -668,7 +663,6 @@ void PROJECT_TREE_PANE::onRight( wxTreeEvent& Event ) can_switch_to_project = false; can_edit = false; can_rename = false; - can_print = false; break; default: @@ -676,9 +670,6 @@ void PROJECT_TREE_PANE::onRight( wxTreeEvent& Event ) can_create_new_directory = false; can_open_this_directory = false; - if( !CanPrintFile( full_file_name ) ) - can_print = false; - break; } } @@ -781,19 +772,6 @@ void PROJECT_TREE_PANE::onRight( wxTreeEvent& Event ) #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 ) PopupMenu( &popup_menu ); } @@ -835,15 +813,6 @@ void PROJECT_TREE_PANE::onDeleteFile( wxCommandEvent& event ) } -void PROJECT_TREE_PANE::onPrintFile( wxCommandEvent& event ) -{ - std::vector tree_data = GetSelectedData(); - - for( PROJECT_TREE_ITEM* item_data : tree_data ) - item_data->Print(); -} - - void PROJECT_TREE_PANE::onRenameFile( wxCommandEvent& event ) { wxTreeItemId curr_item = m_TreeProject->GetFocusedItem(); diff --git a/kicad/project_tree_pane.h b/kicad/project_tree_pane.h index 4ecb51fe17..fddc8e8c57 100644 --- a/kicad/project_tree_pane.h +++ b/kicad/project_tree_pane.h @@ -118,12 +118,6 @@ private: */ void onDeleteFile( wxCommandEvent& event ); - /** - * Function onDeleteFile - * Print the selected file or directory in the tree project - */ - void onPrintFile( wxCommandEvent& event ); - /** * Function onRenameFile * Rename the selected file or directory in the tree project