Add Open Python directory to menus.

Fixes https://gitlab.com/kicad/code/kicad/issues/5115
This commit is contained in:
Jeff Young 2020-08-09 14:37:19 +01:00
parent 3b280e4886
commit c992570427
5 changed files with 60 additions and 15 deletions

View File

@ -741,7 +741,7 @@ void TREE_PROJECT_FRAME::OnRight( wxTreeEvent& Event )
} }
AddMenuItem( &popup_menu, ID_PROJECT_OPEN_DIR, text, help_text, AddMenuItem( &popup_menu, ID_PROJECT_OPEN_DIR, text, help_text,
KiBitmap( directory_browser_xpm ) ); KiBitmap( directory_browser_xpm ) );
} }
if( can_edit ) if( can_edit )

View File

@ -502,6 +502,15 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
submenuActionPlugins->Add( _( "Refresh Plugins" ), submenuActionPlugins->Add( _( "Refresh Plugins" ),
_( "Reload all python plugins and refresh plugin menus" ), _( "Reload all python plugins and refresh plugin menus" ),
ID_TOOLBARH_PCB_ACTION_PLUGIN_REFRESH, reload_xpm ); ID_TOOLBARH_PCB_ACTION_PLUGIN_REFRESH, reload_xpm );
#ifdef __APPLE__
submenuActionPlugins->Add( _( "Reveal Plugin Folder in Finder" ),
_( "Reveals the plugins folder in a Finder window" ),
ID_TOOLBARH_PCB_ACTION_PLUGIN_SHOW_FOLDER, folder_xpm );
#else
submenuActionPlugins->Add( _( "Open Plugin Directory" ),
_( "Opens the directory in the default system file manager" ),
ID_TOOLBARH_PCB_ACTION_PLUGIN_SHOW_FOLDER, folder_xpm );
#endif
submenuActionPlugins->AppendSeparator(); submenuActionPlugins->AppendSeparator();
toolsMenu->AddSeparator(); toolsMenu->AddSeparator();

View File

@ -145,6 +145,7 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
#if defined(KICAD_SCRIPTING) && defined(KICAD_SCRIPTING_ACTION_MENU) #if defined(KICAD_SCRIPTING) && defined(KICAD_SCRIPTING_ACTION_MENU)
EVT_TOOL( ID_TOOLBARH_PCB_ACTION_PLUGIN_REFRESH, PCB_EDIT_FRAME::OnActionPluginRefresh ) EVT_TOOL( ID_TOOLBARH_PCB_ACTION_PLUGIN_REFRESH, PCB_EDIT_FRAME::OnActionPluginRefresh )
EVT_TOOL( ID_TOOLBARH_PCB_ACTION_PLUGIN_SHOW_FOLDER, PCB_EDIT_FRAME::OnActionPluginShowFolder )
#endif #endif
// Tracks and vias sizes general options // Tracks and vias sizes general options
@ -1201,20 +1202,38 @@ void PCB_EDIT_FRAME::RunEeschema()
void PCB_EDIT_FRAME::PythonPluginsReload() void PCB_EDIT_FRAME::PythonPluginsReload()
{ {
// Reload Python plugins if they are newer than // Reload Python plugins if they are newer than the already loaded, and load new plugins
// the already loaded, and load new plugins
#if defined(KICAD_SCRIPTING) #if defined(KICAD_SCRIPTING)
//Reload plugin list: reload Python plugins if they are newer than // Reload plugin list: reload Python plugins if they are newer than the already loaded,
// the already loaded, and load new plugins // and load new plugins
PythonPluginsReloadBase(); PythonPluginsReloadBase();
#if defined(KICAD_SCRIPTING_ACTION_MENU) #if defined(KICAD_SCRIPTING_ACTION_MENU)
// Action plugins can be modified, therefore the plugins menu // Action plugins can be modified, therefore the plugins menu must be updated:
// must be updated: ReCreateMenuBar();
ReCreateMenuBar(); // Recreate top toolbar to add action plugin buttons
// Recreate top toolbar to add action plugin buttons ReCreateHToolbar();
ReCreateHToolbar(); #endif
#endif #endif
}
void PCB_EDIT_FRAME::PythonPluginsShowFolder()
{
#if defined(KICAD_SCRIPTING)
#ifdef __WXMAC__
wxString msg;
// Quote in case there are spaces in the path.
msg.Printf( "open \"%s\"", PYTHON_DEST );
system( msg.c_str() );
#else
// Quote in case there are spaces in the path.
AddDelimiterString( pypath );
wxLaunchDefaultApplication( PYTHON_DEST );
#endif
#endif #endif
} }

View File

@ -168,6 +168,16 @@ protected:
{ {
PythonPluginsReload(); PythonPluginsReload();
} }
/**
* Function OnActionPluginRefresh
* Refresh plugin list (reload Python plugins)
* @param aEvent sent by wx
*/
void OnActionPluginShowFolder( wxCommandEvent& aEvent)
{
PythonPluginsShowFolder();
}
#endif #endif
/** Has meaning only if KICAD_SCRIPTING_WXPYTHON option is /** Has meaning only if KICAD_SCRIPTING_WXPYTHON option is
@ -279,12 +289,18 @@ public:
bool IsContentModified() override; bool IsContentModified() override;
/** /**
* Reload the Python plugins if they are newer than * Reload the Python plugins if they are newer than the already loaded, and load new
* the already loaded, and load new plugins if any * plugins if any.
* Do nothing if KICAD_SCRIPTING is not defined * Do nothing if KICAD_SCRIPTING is not defined.
*/ */
void PythonPluginsReload(); void PythonPluginsReload();
/**
* Open the plugins folder in the default system file browser.
* Do nothing if KICAD_SCRIPTING is not defined.
*/
void PythonPluginsShowFolder();
/** /**
* Update the layer manager and other widgets from the board setup * Update the layer manager and other widgets from the board setup
* (layer and items visibility, colors ...) * (layer and items visibility, colors ...)

View File

@ -91,6 +91,7 @@ enum pcbnew_ids
ID_TOOLBARH_PCB_ACTION_PLUGIN, ID_TOOLBARH_PCB_ACTION_PLUGIN,
ID_TOOLBARH_PCB_ACTION_PLUGIN_REFRESH, ID_TOOLBARH_PCB_ACTION_PLUGIN_REFRESH,
ID_TOOLBARH_PCB_ACTION_PLUGIN_SHOW_FOLDER,
ID_PCB_GEN_CMP_FILE, ID_PCB_GEN_CMP_FILE,
ID_PCB_GEN_BOM_FILE_FROM_BOARD, ID_PCB_GEN_BOM_FILE_FROM_BOARD,