Cherry-picking some external run routines
Mostly from c6bcb85562
but trees have
diverged sufficiently that there are others mixed in. This removes the
system() call on MacOS when opening a directory
This commit is contained in:
parent
8e9e1a618b
commit
f3e9e3497b
|
@ -327,6 +327,7 @@ set( COMMON_SRCS
|
|||
kiway_express.cpp
|
||||
kiway_holder.cpp
|
||||
kiway_player.cpp
|
||||
launch_ext.cpp
|
||||
lib_id.cpp
|
||||
lib_table_base.cpp
|
||||
lib_table_keywords.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>
|
||||
|
||||
|
||||
void LaunchExternal( const wxString& aPath )
|
||||
{
|
||||
#ifdef __WXMAC__
|
||||
wxExecute( wxString::Format( "open \"%s\"", aPath ) );
|
||||
#else
|
||||
wxString path( aPath );
|
||||
|
||||
#if !wxCHECK_VERSION( 3, 1, 0 )
|
||||
// Quote in case there are spaces in the path.
|
||||
// Not needed on 3.1.4, but needed in 3.0 versions
|
||||
// Moreover, on Linux, on 3.1.4 wx version, adding quotes breaks
|
||||
// wxLaunchDefaultApplication
|
||||
AddDelimiterString( path );
|
||||
#endif
|
||||
|
||||
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
|
|
@ -40,6 +40,7 @@
|
|||
#include <build_version.h>
|
||||
#include <dialog_configure_paths.h>
|
||||
#include <dialog_edit_library_tables.h>
|
||||
#include <launch_ext.h>
|
||||
#include "pgm_kicad.h"
|
||||
#include "tree_project_frame.h"
|
||||
|
||||
|
@ -536,21 +537,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