Add patch from Jacobo Aragunde Perez <Log of opened and closed applications in KiCad launcher>
This commit is contained in:
parent
07273ac439
commit
295b5b5dea
|
@ -313,15 +313,9 @@ wxString GenDate()
|
|||
}
|
||||
|
||||
|
||||
bool ProcessExecute( const wxString& aCommandLine, int aFlags )
|
||||
int ProcessExecute( const wxString& aCommandLine, int aFlags, wxProcess *callback )
|
||||
{
|
||||
#ifdef __WINDOWS__
|
||||
int pid = wxExecute( aCommandLine );
|
||||
return pid ? true : false;
|
||||
#else
|
||||
wxProcess* process = wxProcess::Open( aCommandLine, aFlags );
|
||||
return (process != NULL) ? true : false;
|
||||
#endif
|
||||
return wxExecute( aCommandLine, aFlags, callback );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -415,7 +415,8 @@ wxString FindKicadFile( const wxString& shortname )
|
|||
}
|
||||
|
||||
|
||||
int ExecuteFile( wxWindow* frame, const wxString& ExecFile, const wxString& param )
|
||||
int ExecuteFile( wxWindow* frame, const wxString& ExecFile, const wxString& param,
|
||||
wxProcess *callback )
|
||||
{
|
||||
wxString FullFileName;
|
||||
|
||||
|
@ -425,19 +426,21 @@ int ExecuteFile( wxWindow* frame, const wxString& ExecFile, const wxString& para
|
|||
#ifdef __WXMAC__
|
||||
if( wxFileExists( FullFileName ) || wxDir::Exists( FullFileName ) )
|
||||
{
|
||||
ProcessExecute( wxGetApp().GetExecutablePath() + wxT("/") + ExecFile + wxT(" ") + param );
|
||||
} else {
|
||||
ProcessExecute( wxT("/usr/bin/open ") + param );
|
||||
return ProcessExecute( wxGetApp().GetExecutablePath() + wxT( "/" )
|
||||
+ ExecFile + wxT( " " )
|
||||
+ param, wxEXEC_ASYNC, callback );
|
||||
}
|
||||
else
|
||||
{
|
||||
return ProcessExecute( wxT( "/usr/bin/open " ) + param, wxEXEC_ASYNC, callback );
|
||||
}
|
||||
return 0;
|
||||
#else
|
||||
if( wxFileExists( FullFileName ) )
|
||||
{
|
||||
if( !param.IsEmpty() )
|
||||
FullFileName += wxT( " " ) + param;
|
||||
|
||||
ProcessExecute( FullFileName );
|
||||
return 0;
|
||||
return ProcessExecute( FullFileName, wxEXEC_ASYNC, callback );
|
||||
}
|
||||
#endif
|
||||
wxString msg;
|
||||
|
|
|
@ -555,9 +555,13 @@ bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString = NULL );
|
|||
* @param aCommandLine The process and any arguments to it all in a single
|
||||
* string.
|
||||
* @param aFlags The same args as allowed for wxExecute()
|
||||
* @return bool - true if success, else false
|
||||
* @param callback wxProcess implementing OnTerminate to be run when the
|
||||
child process finishes
|
||||
* @return int - pid of process, 0 in case of error (like return values of
|
||||
* wxExecute())
|
||||
*/
|
||||
bool ProcessExecute( const wxString& aCommandLine, int aFlags = wxEXEC_ASYNC );
|
||||
int ProcessExecute( const wxString& aCommandLine, int aFlags = wxEXEC_ASYNC,
|
||||
wxProcess *callback = NULL );
|
||||
|
||||
|
||||
/*******************/
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#define __INCLUDE__GESTFICH_H__ 1
|
||||
|
||||
#include <wx/filename.h>
|
||||
#include <wx/process.h>
|
||||
|
||||
|
||||
/* Forward class declarations. */
|
||||
|
@ -79,7 +80,7 @@ EDA_LIST_DIALOG* GetFileNames( char* Directory, char* Mask );
|
|||
* calls the executable file \a ExecFile with the command line parameters \a param.
|
||||
*/
|
||||
int ExecuteFile( wxWindow* frame, const wxString& ExecFile,
|
||||
const wxString& param = wxEmptyString );
|
||||
const wxString& param = wxEmptyString, wxProcess *callback = NULL );
|
||||
|
||||
/**
|
||||
* Function AddDelimiterString
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <macros.h>
|
||||
|
||||
#include <kicad.h>
|
||||
#include <appl_wxstruct.h>
|
||||
#include <tree_project_frame.h>
|
||||
#include <class_treeprojectfiles.h>
|
||||
#include <class_treeproject_item.h>
|
||||
|
@ -188,6 +189,7 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe )
|
|||
wxString sep = wxFileName().GetPathSeparator();
|
||||
wxString FullFileName = GetFileName();
|
||||
wxTreeItemId id = GetId();
|
||||
KICAD_MANAGER_FRAME* mainFrame = (KICAD_MANAGER_FRAME*) wxGetApp().GetTopWindow();
|
||||
|
||||
AddDelimiterString( FullFileName );
|
||||
|
||||
|
@ -201,16 +203,16 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe )
|
|||
break;
|
||||
|
||||
case TREE_SCHEMA:
|
||||
ExecuteFile( m_parent, EESCHEMA_EXE, FullFileName );
|
||||
mainFrame->Execute( m_parent, EESCHEMA_EXE, FullFileName );
|
||||
break;
|
||||
|
||||
case TREE_LEGACY_PCB:
|
||||
case TREE_SEXP_PCB:
|
||||
ExecuteFile( m_parent, PCBNEW_EXE, FullFileName );
|
||||
mainFrame->Execute( m_parent, PCBNEW_EXE, FullFileName );
|
||||
break;
|
||||
|
||||
case TREE_GERBER:
|
||||
ExecuteFile( m_parent, GERBVIEW_EXE, FullFileName );
|
||||
mainFrame->Execute( m_parent, GERBVIEW_EXE, FullFileName );
|
||||
break;
|
||||
|
||||
case TREE_PDF:
|
||||
|
@ -218,7 +220,7 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe )
|
|||
break;
|
||||
|
||||
case TREE_NET:
|
||||
ExecuteFile( m_parent, CVPCB_EXE, FullFileName );
|
||||
mainFrame->Execute( m_parent, CVPCB_EXE, FullFileName );
|
||||
break;
|
||||
|
||||
case TREE_TXT:
|
||||
|
@ -226,7 +228,7 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe )
|
|||
wxString editorname = wxGetApp().GetEditorName();
|
||||
|
||||
if( !editorname.IsEmpty() )
|
||||
ExecuteFile( m_parent, editorname, FullFileName );
|
||||
mainFrame->Execute( m_parent, editorname, FullFileName );
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -235,4 +237,5 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe )
|
|||
OpenFile( FullFileName );
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,31 @@
|
|||
/***********/
|
||||
/* kicad.h */
|
||||
/***********/
|
||||
/**
|
||||
* @file kicad/kicad.h
|
||||
* @brief KICAD_MANAGER_FRAME is the KiCad main frame.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2013 CERN (www.cern.ch)
|
||||
* Copyright (C) 2013 KiCad Developers, see CHANGELOG.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 2
|
||||
* 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, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifndef KICAD_H
|
||||
#define KICAD_H
|
||||
|
@ -10,6 +35,7 @@
|
|||
#include <wx/treectrl.h>
|
||||
#include <wx/dragimag.h>
|
||||
#include <wx/filename.h>
|
||||
#include <wx/process.h>
|
||||
|
||||
#include <id.h>
|
||||
#include <wxstruct.h>
|
||||
|
@ -182,6 +208,30 @@ public: KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title,
|
|||
*/
|
||||
void SaveSettings();
|
||||
|
||||
/**
|
||||
* Function Execute
|
||||
* opens another KiCad application and logs a message.
|
||||
* @param frame = owner frame.
|
||||
* @param execFile = name of the executable file.
|
||||
* @param param = parameters to be passed to the executable.
|
||||
*/
|
||||
void Execute( wxWindow* frame, const wxString& execFile,
|
||||
const wxString& param = wxEmptyString );
|
||||
|
||||
class PROCESS_TERMINATE_EVENT_HANDLER : public wxProcess
|
||||
{
|
||||
private:
|
||||
wxString appName;
|
||||
|
||||
public:
|
||||
PROCESS_TERMINATE_EVENT_HANDLER( const wxString& appName ) :
|
||||
appName(appName)
|
||||
{
|
||||
}
|
||||
|
||||
void OnTerminate( int pid, int status );
|
||||
};
|
||||
|
||||
#ifdef KICAD_USE_FILES_WATCHER
|
||||
/**
|
||||
* Called by sending a event with id = ID_INIT_WATCHED_PATHS
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2012 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
||||
* Copyright (C) 2013 CERN (www.cern.ch)
|
||||
* Copyright (C) 2004-2012 KiCad Developers, see change_log.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -186,15 +187,51 @@ void KICAD_MANAGER_FRAME::OnExit( wxCommandEvent& event )
|
|||
}
|
||||
|
||||
|
||||
void KICAD_MANAGER_FRAME::PROCESS_TERMINATE_EVENT_HANDLER::
|
||||
OnTerminate( int pid, int status )
|
||||
{
|
||||
|
||||
wxString msg;
|
||||
|
||||
msg.Printf( appName + _( " closed [pid=%d]\n" ), pid );
|
||||
( (KICAD_MANAGER_FRAME*) wxGetApp().GetTopWindow() )->PrintMsg( msg );
|
||||
|
||||
delete this;
|
||||
}
|
||||
|
||||
|
||||
void KICAD_MANAGER_FRAME::Execute( wxWindow* frame, const wxString& execFile,
|
||||
const wxString& param )
|
||||
{
|
||||
|
||||
PROCESS_TERMINATE_EVENT_HANDLER* callback;
|
||||
long pid;
|
||||
wxString msg;
|
||||
|
||||
callback = new PROCESS_TERMINATE_EVENT_HANDLER( execFile );
|
||||
pid = ExecuteFile( frame, execFile, param, callback );
|
||||
|
||||
if( pid > 0 )
|
||||
{
|
||||
msg.Printf( execFile + _( " opened [pid=%ld]\n" ), pid );
|
||||
PrintMsg( msg );
|
||||
}
|
||||
else
|
||||
{
|
||||
delete callback;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void KICAD_MANAGER_FRAME::OnRunBitmapConverter( wxCommandEvent& event )
|
||||
{
|
||||
ExecuteFile( this, BITMAPCONVERTER_EXE, wxEmptyString );
|
||||
Execute( this, BITMAPCONVERTER_EXE );
|
||||
}
|
||||
|
||||
|
||||
void KICAD_MANAGER_FRAME::OnRunPcbCalculator( wxCommandEvent& event )
|
||||
{
|
||||
ExecuteFile( this, PCB_CALCULATOR_EXE, wxEmptyString );
|
||||
Execute( this, PCB_CALCULATOR_EXE );
|
||||
}
|
||||
|
||||
|
||||
|
@ -207,9 +244,9 @@ void KICAD_MANAGER_FRAME::OnRunPcbNew( wxCommandEvent& event )
|
|||
kicad_board.SetExt( KiCadPcbFileExtension );
|
||||
|
||||
if( !legacy_board.FileExists() || kicad_board.FileExists() )
|
||||
ExecuteFile( this, PCBNEW_EXE, QuoteFullPath( kicad_board ) );
|
||||
Execute( this, PCBNEW_EXE, QuoteFullPath( kicad_board ) );
|
||||
else
|
||||
ExecuteFile( this, PCBNEW_EXE, QuoteFullPath( legacy_board ) );
|
||||
Execute( this, PCBNEW_EXE, QuoteFullPath( legacy_board ) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -218,18 +255,17 @@ void KICAD_MANAGER_FRAME::OnRunCvpcb( wxCommandEvent& event )
|
|||
wxFileName fn( m_ProjectFileName );
|
||||
|
||||
fn.SetExt( NetlistFileExtension );
|
||||
ExecuteFile( this, CVPCB_EXE, QuoteFullPath( fn ) );
|
||||
Execute( this, CVPCB_EXE, QuoteFullPath( fn ) );
|
||||
}
|
||||
|
||||
|
||||
void KICAD_MANAGER_FRAME::OnRunEeschema( wxCommandEvent& event )
|
||||
{
|
||||
wxFileName fn( m_ProjectFileName );
|
||||
|
||||
fn.SetExt( SchematicFileExtension );
|
||||
ExecuteFile( this, EESCHEMA_EXE, QuoteFullPath( fn ) );
|
||||
}
|
||||
Execute( this, EESCHEMA_EXE, QuoteFullPath( fn ) );
|
||||
|
||||
}
|
||||
|
||||
void KICAD_MANAGER_FRAME::OnRunGerbview( wxCommandEvent& event )
|
||||
{
|
||||
|
@ -237,7 +273,7 @@ void KICAD_MANAGER_FRAME::OnRunGerbview( wxCommandEvent& event )
|
|||
wxString path = wxT( "\"" );
|
||||
path += fn.GetPath( wxPATH_GET_SEPARATOR | wxPATH_GET_VOLUME ) + wxT( "\"" );
|
||||
|
||||
ExecuteFile( this, GERBVIEW_EXE, path );
|
||||
Execute( this, GERBVIEW_EXE, path );
|
||||
}
|
||||
|
||||
|
||||
|
@ -246,7 +282,7 @@ void KICAD_MANAGER_FRAME::OnOpenTextEditor( wxCommandEvent& event )
|
|||
wxString editorname = wxGetApp().GetEditorName();
|
||||
|
||||
if( !editorname.IsEmpty() )
|
||||
ExecuteFile( this, editorname, wxEmptyString );
|
||||
Execute( this, editorname, wxEmptyString );
|
||||
}
|
||||
|
||||
|
||||
|
@ -271,7 +307,7 @@ void KICAD_MANAGER_FRAME::OnOpenFileInTextEditor( wxCommandEvent& event )
|
|||
filename += dlg.GetPath() + wxT( "\"" );
|
||||
|
||||
if( !dlg.GetPath().IsEmpty() && !wxGetApp().GetEditorName().IsEmpty() )
|
||||
ExecuteFile( this, wxGetApp().GetEditorName(), filename );
|
||||
Execute( this, wxGetApp().GetEditorName(), filename );
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue