Commit 5aaa55c8 authored by Jacobo Aragunde Perez's avatar Jacobo Aragunde Perez Committed by jean-pierre charras

Add patch from Jacobo Aragunde Perez <Log of opened and closed applications in KiCad launcher>

parents 07273ac4 295b5b5d
...@@ -313,15 +313,9 @@ wxString GenDate() ...@@ -313,15 +313,9 @@ wxString GenDate()
} }
bool ProcessExecute( const wxString& aCommandLine, int aFlags ) int ProcessExecute( const wxString& aCommandLine, int aFlags, wxProcess *callback )
{ {
#ifdef __WINDOWS__ return wxExecute( aCommandLine, aFlags, callback );
int pid = wxExecute( aCommandLine );
return pid ? true : false;
#else
wxProcess* process = wxProcess::Open( aCommandLine, aFlags );
return (process != NULL) ? true : false;
#endif
} }
......
...@@ -415,7 +415,8 @@ wxString FindKicadFile( const wxString& shortname ) ...@@ -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; wxString FullFileName;
...@@ -425,19 +426,21 @@ int ExecuteFile( wxWindow* frame, const wxString& ExecFile, const wxString& para ...@@ -425,19 +426,21 @@ int ExecuteFile( wxWindow* frame, const wxString& ExecFile, const wxString& para
#ifdef __WXMAC__ #ifdef __WXMAC__
if( wxFileExists( FullFileName ) || wxDir::Exists( FullFileName ) ) if( wxFileExists( FullFileName ) || wxDir::Exists( FullFileName ) )
{ {
ProcessExecute( wxGetApp().GetExecutablePath() + wxT("/") + ExecFile + wxT(" ") + param ); return ProcessExecute( wxGetApp().GetExecutablePath() + wxT( "/" )
} else { + ExecFile + wxT( " " )
ProcessExecute( wxT("/usr/bin/open ") + param ); + param, wxEXEC_ASYNC, callback );
}
else
{
return ProcessExecute( wxT( "/usr/bin/open " ) + param, wxEXEC_ASYNC, callback );
} }
return 0;
#else #else
if( wxFileExists( FullFileName ) ) if( wxFileExists( FullFileName ) )
{ {
if( !param.IsEmpty() ) if( !param.IsEmpty() )
FullFileName += wxT( " " ) + param; FullFileName += wxT( " " ) + param;
ProcessExecute( FullFileName ); return ProcessExecute( FullFileName, wxEXEC_ASYNC, callback );
return 0;
} }
#endif #endif
wxString msg; wxString msg;
......
...@@ -555,9 +555,13 @@ bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString = NULL ); ...@@ -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 * @param aCommandLine The process and any arguments to it all in a single
* string. * string.
* @param aFlags The same args as allowed for wxExecute() * @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 @@ ...@@ -10,6 +10,7 @@
#define __INCLUDE__GESTFICH_H__ 1 #define __INCLUDE__GESTFICH_H__ 1
#include <wx/filename.h> #include <wx/filename.h>
#include <wx/process.h>
/* Forward class declarations. */ /* Forward class declarations. */
...@@ -79,7 +80,7 @@ EDA_LIST_DIALOG* GetFileNames( char* Directory, char* Mask ); ...@@ -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. * calls the executable file \a ExecFile with the command line parameters \a param.
*/ */
int ExecuteFile( wxWindow* frame, const wxString& ExecFile, int ExecuteFile( wxWindow* frame, const wxString& ExecFile,
const wxString& param = wxEmptyString ); const wxString& param = wxEmptyString, wxProcess *callback = NULL );
/** /**
* Function AddDelimiterString * Function AddDelimiterString
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <macros.h> #include <macros.h>
#include <kicad.h> #include <kicad.h>
#include <appl_wxstruct.h>
#include <tree_project_frame.h> #include <tree_project_frame.h>
#include <class_treeprojectfiles.h> #include <class_treeprojectfiles.h>
#include <class_treeproject_item.h> #include <class_treeproject_item.h>
...@@ -188,6 +189,7 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe ) ...@@ -188,6 +189,7 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe )
wxString sep = wxFileName().GetPathSeparator(); wxString sep = wxFileName().GetPathSeparator();
wxString FullFileName = GetFileName(); wxString FullFileName = GetFileName();
wxTreeItemId id = GetId(); wxTreeItemId id = GetId();
KICAD_MANAGER_FRAME* mainFrame = (KICAD_MANAGER_FRAME*) wxGetApp().GetTopWindow();
AddDelimiterString( FullFileName ); AddDelimiterString( FullFileName );
...@@ -201,16 +203,16 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe ) ...@@ -201,16 +203,16 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe )
break; break;
case TREE_SCHEMA: case TREE_SCHEMA:
ExecuteFile( m_parent, EESCHEMA_EXE, FullFileName ); mainFrame->Execute( m_parent, EESCHEMA_EXE, FullFileName );
break; break;
case TREE_LEGACY_PCB: case TREE_LEGACY_PCB:
case TREE_SEXP_PCB: case TREE_SEXP_PCB:
ExecuteFile( m_parent, PCBNEW_EXE, FullFileName ); mainFrame->Execute( m_parent, PCBNEW_EXE, FullFileName );
break; break;
case TREE_GERBER: case TREE_GERBER:
ExecuteFile( m_parent, GERBVIEW_EXE, FullFileName ); mainFrame->Execute( m_parent, GERBVIEW_EXE, FullFileName );
break; break;
case TREE_PDF: case TREE_PDF:
...@@ -218,7 +220,7 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe ) ...@@ -218,7 +220,7 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe )
break; break;
case TREE_NET: case TREE_NET:
ExecuteFile( m_parent, CVPCB_EXE, FullFileName ); mainFrame->Execute( m_parent, CVPCB_EXE, FullFileName );
break; break;
case TREE_TXT: case TREE_TXT:
...@@ -226,7 +228,7 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe ) ...@@ -226,7 +228,7 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe )
wxString editorname = wxGetApp().GetEditorName(); wxString editorname = wxGetApp().GetEditorName();
if( !editorname.IsEmpty() ) if( !editorname.IsEmpty() )
ExecuteFile( m_parent, editorname, FullFileName ); mainFrame->Execute( m_parent, editorname, FullFileName );
break; break;
} }
...@@ -235,4 +237,5 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe ) ...@@ -235,4 +237,5 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe )
OpenFile( FullFileName ); OpenFile( FullFileName );
break; break;
} }
} }
/***********/ /**
/* 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 #ifndef KICAD_H
#define KICAD_H #define KICAD_H
...@@ -10,6 +35,7 @@ ...@@ -10,6 +35,7 @@
#include <wx/treectrl.h> #include <wx/treectrl.h>
#include <wx/dragimag.h> #include <wx/dragimag.h>
#include <wx/filename.h> #include <wx/filename.h>
#include <wx/process.h>
#include <id.h> #include <id.h>
#include <wxstruct.h> #include <wxstruct.h>
...@@ -182,6 +208,30 @@ public: KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title, ...@@ -182,6 +208,30 @@ public: KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title,
*/ */
void SaveSettings(); 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 #ifdef KICAD_USE_FILES_WATCHER
/** /**
* Called by sending a event with id = ID_INIT_WATCHED_PATHS * Called by sending a event with id = ID_INIT_WATCHED_PATHS
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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. * Copyright (C) 2004-2012 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -186,15 +187,51 @@ void KICAD_MANAGER_FRAME::OnExit( wxCommandEvent& event ) ...@@ -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 ) void KICAD_MANAGER_FRAME::OnRunBitmapConverter( wxCommandEvent& event )
{ {
ExecuteFile( this, BITMAPCONVERTER_EXE, wxEmptyString ); Execute( this, BITMAPCONVERTER_EXE );
} }
void KICAD_MANAGER_FRAME::OnRunPcbCalculator( wxCommandEvent& event ) 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 ) ...@@ -207,9 +244,9 @@ void KICAD_MANAGER_FRAME::OnRunPcbNew( wxCommandEvent& event )
kicad_board.SetExt( KiCadPcbFileExtension ); kicad_board.SetExt( KiCadPcbFileExtension );
if( !legacy_board.FileExists() || kicad_board.FileExists() ) if( !legacy_board.FileExists() || kicad_board.FileExists() )
ExecuteFile( this, PCBNEW_EXE, QuoteFullPath( kicad_board ) ); Execute( this, PCBNEW_EXE, QuoteFullPath( kicad_board ) );
else 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 ) ...@@ -218,18 +255,17 @@ void KICAD_MANAGER_FRAME::OnRunCvpcb( wxCommandEvent& event )
wxFileName fn( m_ProjectFileName ); wxFileName fn( m_ProjectFileName );
fn.SetExt( NetlistFileExtension ); fn.SetExt( NetlistFileExtension );
ExecuteFile( this, CVPCB_EXE, QuoteFullPath( fn ) ); Execute( this, CVPCB_EXE, QuoteFullPath( fn ) );
} }
void KICAD_MANAGER_FRAME::OnRunEeschema( wxCommandEvent& event ) void KICAD_MANAGER_FRAME::OnRunEeschema( wxCommandEvent& event )
{ {
wxFileName fn( m_ProjectFileName ); wxFileName fn( m_ProjectFileName );
fn.SetExt( SchematicFileExtension ); fn.SetExt( SchematicFileExtension );
ExecuteFile( this, EESCHEMA_EXE, QuoteFullPath( fn ) ); Execute( this, EESCHEMA_EXE, QuoteFullPath( fn ) );
}
}
void KICAD_MANAGER_FRAME::OnRunGerbview( wxCommandEvent& event ) void KICAD_MANAGER_FRAME::OnRunGerbview( wxCommandEvent& event )
{ {
...@@ -237,7 +273,7 @@ void KICAD_MANAGER_FRAME::OnRunGerbview( wxCommandEvent& event ) ...@@ -237,7 +273,7 @@ void KICAD_MANAGER_FRAME::OnRunGerbview( wxCommandEvent& event )
wxString path = wxT( "\"" ); wxString path = wxT( "\"" );
path += fn.GetPath( wxPATH_GET_SEPARATOR | wxPATH_GET_VOLUME ) + 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 ) ...@@ -246,7 +282,7 @@ void KICAD_MANAGER_FRAME::OnOpenTextEditor( wxCommandEvent& event )
wxString editorname = wxGetApp().GetEditorName(); wxString editorname = wxGetApp().GetEditorName();
if( !editorname.IsEmpty() ) if( !editorname.IsEmpty() )
ExecuteFile( this, editorname, wxEmptyString ); Execute( this, editorname, wxEmptyString );
} }
...@@ -271,7 +307,7 @@ void KICAD_MANAGER_FRAME::OnOpenFileInTextEditor( wxCommandEvent& event ) ...@@ -271,7 +307,7 @@ void KICAD_MANAGER_FRAME::OnOpenFileInTextEditor( wxCommandEvent& event )
filename += dlg.GetPath() + wxT( "\"" ); filename += dlg.GetPath() + wxT( "\"" );
if( !dlg.GetPath().IsEmpty() && !wxGetApp().GetEditorName().IsEmpty() ) if( !dlg.GetPath().IsEmpty() && !wxGetApp().GetEditorName().IsEmpty() )
ExecuteFile( this, wxGetApp().GetEditorName(), filename ); Execute( this, wxGetApp().GetEditorName(), filename );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment