Factor out utility to launch a given file or folder
This commit is contained in:
parent
e8e3b4f11e
commit
dc75c2b800
|
@ -309,6 +309,7 @@ set( COMMON_SRCS
|
|||
kiway_holder.cpp
|
||||
kiway_player.cpp
|
||||
languages_menu.cpp
|
||||
launch_ext.cpp
|
||||
lib_id.cpp
|
||||
lib_table_base.cpp
|
||||
lib_tree_model.cpp
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com>
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <gestfich.h>
|
||||
#include <launch_ext.h>
|
||||
#include <wx/wx.h>
|
||||
|
||||
|
||||
void LaunchExternal( const wxString& aPath )
|
||||
{
|
||||
#ifdef __WXMAC__
|
||||
wxString msg;
|
||||
|
||||
// Quote in case there are spaces in the path.
|
||||
msg.Printf( "open \"%s\"", aPath );
|
||||
|
||||
system( msg.c_str() );
|
||||
#else
|
||||
wxString path( aPath );
|
||||
// Quote in case there are spaces in the path.
|
||||
AddDelimiterString( path );
|
||||
|
||||
wxLaunchDefaultApplication( path );
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com>
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef LAUNCH_EXT_H
|
||||
#define LAUNCH_EXT_H
|
||||
|
||||
class wxString;
|
||||
|
||||
/**
|
||||
* Launches the given file or folder in the host OS
|
||||
* @param aPath is a path to a file or folder
|
||||
*/
|
||||
void LaunchExternal( const wxString& aPath );
|
||||
|
||||
#endif
|
|
@ -34,6 +34,7 @@
|
|||
#include <kiway.h>
|
||||
#include <kiway_express.h>
|
||||
#include <kiway_player.h>
|
||||
#include <launch_ext.h>
|
||||
#include <panel_hotkeys_editor.h>
|
||||
#include <settings/common_settings.h>
|
||||
#include <tool/action_toolbar.h>
|
||||
|
@ -434,21 +435,7 @@ void KICAD_MANAGER_FRAME::OnOpenFileInTextEditor( wxCommandEvent& event )
|
|||
void KICAD_MANAGER_FRAME::OnBrowseInFileExplorer( wxCommandEvent& event )
|
||||
{
|
||||
// open project directory in host OS's file explorer
|
||||
wxString project_dir = Prj().GetProjectPath();
|
||||
|
||||
#ifdef __WXMAC__
|
||||
wxString msg;
|
||||
|
||||
// Quote in case there are spaces in the path.
|
||||
msg.Printf( "open \"%s\"", project_dir );
|
||||
|
||||
system( msg.c_str() );
|
||||
#else
|
||||
// Quote in case there are spaces in the path.
|
||||
AddDelimiterString( project_dir );
|
||||
|
||||
wxLaunchDefaultApplication( project_dir );
|
||||
#endif
|
||||
LaunchExternal( Prj().GetProjectPath() );
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue