From 9535153f9e9dc73fe42d12ac94f6f540dcf5f44c Mon Sep 17 00:00:00 2001
From: Ian McInerney <ian.s.mcinerney@ieee.org>
Date: Sat, 27 Mar 2021 19:04:16 +0000
Subject: [PATCH] Move the import graphics menu item to the action

---
 pcbnew/footprint_edit_frame.cpp     | 23 ++++++++---------------
 pcbnew/footprint_edit_frame.h       |  1 -
 pcbnew/menubar_footprint_editor.cpp |  7 ++-----
 pcbnew/menubar_pcb_editor.cpp       |  3 +--
 pcbnew/pcbnew_id.h                  |  1 -
 pcbnew/tools/pcb_actions.cpp        |  8 +-------
 6 files changed, 12 insertions(+), 31 deletions(-)

diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp
index 02c27dd704..c06540632a 100644
--- a/pcbnew/footprint_edit_frame.cpp
+++ b/pcbnew/footprint_edit_frame.cpp
@@ -102,8 +102,6 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
     EVT_UPDATE_UI( ID_ADD_FOOTPRINT_TO_BOARD,
                    FOOTPRINT_EDIT_FRAME::OnUpdateSaveFootprintToBoard )
     EVT_UPDATE_UI( ID_TOOLBARH_PCB_SELECT_LAYER, FOOTPRINT_EDIT_FRAME::OnUpdateLayerSelectBox )
-    EVT_UPDATE_UI( ID_GEN_IMPORT_GRAPHICS_FILE, FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected )
-
 END_EVENT_TABLE()
 
 
@@ -663,12 +661,6 @@ void FOOTPRINT_EDIT_FRAME::CloseFootprintEditor( wxCommandEvent& Event )
 }
 
 
-void FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected( wxUpdateUIEvent& aEvent )
-{
-    aEvent.Enable( GetBoard()->GetFirstFootprint() != NULL );
-}
-
-
 void FOOTPRINT_EDIT_FRAME::OnUpdateLoadFootprintFromBoard( wxUpdateUIEvent& aEvent )
 {
     PCB_EDIT_FRAME* frame = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB_EDITOR, false );
@@ -1043,14 +1035,15 @@ void FOOTPRINT_EDIT_FRAME::setupUIConditions()
                 return IsSearchTreeShown();
             };
 
-    mgr->SetConditions( ACTIONS::highContrastMode,         CHECK( highContrastCond ) );
-    mgr->SetConditions( PCB_ACTIONS::flipBoard,            CHECK( boardFlippedCond ) );
-    mgr->SetConditions( PCB_ACTIONS::toggleFootprintTree,  CHECK( footprintTreeCond ) );
+    mgr->SetConditions( ACTIONS::highContrastMode,          CHECK( highContrastCond ) );
+    mgr->SetConditions( PCB_ACTIONS::flipBoard,             CHECK( boardFlippedCond ) );
+    mgr->SetConditions( PCB_ACTIONS::toggleFootprintTree,   CHECK( footprintTreeCond ) );
 
-    mgr->SetConditions( ACTIONS::print,                    ENABLE( haveFootprintCond ) );
-    mgr->SetConditions( PCB_ACTIONS::exportFootprint,      ENABLE( haveFootprintCond ) );
-    mgr->SetConditions( PCB_ACTIONS::footprintProperties,  ENABLE( haveFootprintCond ) );
-    mgr->SetConditions( PCB_ACTIONS::cleanupGraphics,      ENABLE( haveFootprintCond ) );
+    mgr->SetConditions( ACTIONS::print,                     ENABLE( haveFootprintCond ) );
+    mgr->SetConditions( PCB_ACTIONS::exportFootprint,       ENABLE( haveFootprintCond ) );
+    mgr->SetConditions( PCB_ACTIONS::footprintProperties,   ENABLE( haveFootprintCond ) );
+    mgr->SetConditions( PCB_ACTIONS::cleanupGraphics,       ENABLE( haveFootprintCond ) );
+    mgr->SetConditions( PCB_ACTIONS::placeImportedGraphics, ENABLE( haveFootprintCond ) );
 
 
 // Only enable a tool if the part is edtable
diff --git a/pcbnew/footprint_edit_frame.h b/pcbnew/footprint_edit_frame.h
index 6fde78351d..7f6a32bf73 100644
--- a/pcbnew/footprint_edit_frame.h
+++ b/pcbnew/footprint_edit_frame.h
@@ -144,7 +144,6 @@ public:
      */
     bool SaveLibraryAs( const wxString& aLibraryPath );
 
-    void OnUpdateModuleSelected( wxUpdateUIEvent& aEvent );
     void OnUpdateLoadFootprintFromBoard( wxUpdateUIEvent& aEvent );
     void OnUpdateSaveFootprintToBoard( wxUpdateUIEvent& aEvent );
 
diff --git a/pcbnew/menubar_footprint_editor.cpp b/pcbnew/menubar_footprint_editor.cpp
index 4931ad8217..e53cf7d12d 100644
--- a/pcbnew/menubar_footprint_editor.cpp
+++ b/pcbnew/menubar_footprint_editor.cpp
@@ -69,11 +69,8 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
     submenuImport->SetTitle( _( "Import" ) );
     submenuImport->SetIcon( BITMAPS::import );
 
-    submenuImport->Add( PCB_ACTIONS::importFootprint, ACTION_MENU::NORMAL, _( "Footprint..." ) );
-    submenuImport->Add( _( "&Graphics..." ),
-                        _( "Import 2D drawing file to current footprint" ),
-                        ID_GEN_IMPORT_GRAPHICS_FILE,
-                        BITMAPS::import_vector );
+    submenuImport->Add( PCB_ACTIONS::importFootprint,        ACTION_MENU::NORMAL, _( "Footprint..." ) );
+    submenuImport->Add( PCB_ACTIONS::placeImportedGraphics,  ACTION_MENU::NORMAL, _( "Graphics..." ) );
 
     fileMenu->Add( submenuImport );
 
diff --git a/pcbnew/menubar_pcb_editor.cpp b/pcbnew/menubar_pcb_editor.cpp
index 7e48261a86..8ecaf36567 100644
--- a/pcbnew/menubar_pcb_editor.cpp
+++ b/pcbnew/menubar_pcb_editor.cpp
@@ -109,8 +109,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
 
     submenuImport->Add( PCB_ACTIONS::importNetlist,          ACTION_MENU::NORMAL, _( "Netlist..." ) );
     submenuImport->Add( PCB_ACTIONS::importSpecctraSession,  ACTION_MENU::NORMAL, _( "Specctra Session..." ) );
-    submenuImport->Add( _( "Graphics..." ), _( "Import 2D drawing file" ),
-                        ID_GEN_IMPORT_GRAPHICS_FILE, BITMAPS::import_vector );
+    submenuImport->Add( PCB_ACTIONS::placeImportedGraphics,  ACTION_MENU::NORMAL, _( "Graphics..." ) );
 
     if( Kiface().IsSingle() )
     {
diff --git a/pcbnew/pcbnew_id.h b/pcbnew/pcbnew_id.h
index 68bb6fb763..c1846d69fb 100644
--- a/pcbnew/pcbnew_id.h
+++ b/pcbnew/pcbnew_id.h
@@ -86,7 +86,6 @@ enum pcbnew_ids
     ID_GEN_EXPORT_FILE_STEP,
     ID_GEN_EXPORT_FILE_HYPERLYNX,
     ID_GEN_EXPORT_FILE_GENCADFORMAT,
-    ID_GEN_IMPORT_GRAPHICS_FILE,
 
     ID_TOOLBARH_PCB_ACTION_PLUGIN,
     ID_TOOLBARH_PCB_ACTION_PLUGIN_REFRESH,
diff --git a/pcbnew/tools/pcb_actions.cpp b/pcbnew/tools/pcb_actions.cpp
index 4fc4b0a778..b13bcd0869 100644
--- a/pcbnew/tools/pcb_actions.cpp
+++ b/pcbnew/tools/pcb_actions.cpp
@@ -35,12 +35,6 @@
 
 OPT<TOOL_EVENT> PCB_ACTIONS::TranslateLegacyId( int aId )
 {
-    switch( aId )
-    {
-    case ID_GEN_IMPORT_GRAPHICS_FILE:
-        return PCB_ACTIONS::placeImportedGraphics.MakeEvent();
-    }
-
     return OPT<TOOL_EVENT>();
 }
 
@@ -194,7 +188,7 @@ TOOL_ACTION PCB_ACTIONS::drawSimilarZone( "pcbnew.InteractiveDrawing.similarZone
 TOOL_ACTION PCB_ACTIONS::placeImportedGraphics( "pcbnew.InteractiveDrawing.placeImportedGraphics",
         AS_GLOBAL,
         MD_SHIFT + MD_CTRL + 'F', LEGACY_HK_NAME( "Place DXF" ),
-        _( "Place Imported Graphics" ), "",
+        _( "Import Graphics..." ), _( "Import 2D drawing file" ),
         BITMAPS::import_vector, AF_ACTIVATE );
 
 TOOL_ACTION PCB_ACTIONS::setAnchor( "pcbnew.InteractiveDrawing.setAnchor",