Update of /cvsroot/audacity/audacity-src/src
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv32268/src
Modified Files:
AudacityApp.cpp AudacityApp.h LoadModules.cpp LoadModules.h
Log Message:
Some modifications to the main app to connect up the new scripting GUI
delegation stuff.
Index: AudacityApp.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/AudacityApp.h,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- AudacityApp.h 20 May 2009 06:05:38 -0000 1.53
+++ AudacityApp.h 30 May 2009 04:32:02 -0000 1.54
@@ -28,6 +28,8 @@
class IPCServ;
class Importer;
+class CommandHandler;
+class AppCommandEvent;
void SaveWindowSize();
@@ -114,6 +116,8 @@
// Backend for above - returns true for success, false for failure
bool MRUOpen(wxString fileName);
+ void OnReceiveCommand(AppCommandEvent &event);
+
#ifdef __WXMAC__
// In response to Apple Events
virtual void MacOpenFile(const wxString &fileName) ;
@@ -157,12 +161,16 @@
wxLogWindow *mLogger;
private:
+ CommandHandler *mCmdHandler;
FileHistory *mRecentFiles;
wxLocale *mLocale;
wxSingleInstanceChecker *mChecker;
+ void InitCommandHandler();
+ void DeInitCommandHandler();
+
bool InitTempDir();
bool CreateSingleInstanceChecker(wxString dir);
Index: LoadModules.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/LoadModules.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- LoadModules.h 19 Feb 2009 07:06:24 -0000 1.5
+++ LoadModules.h 30 May 2009 04:32:02 -0000 1.6
@@ -15,7 +15,11 @@
#include <wx/dynlib.h>
#include <wx/module.h>
-void LoadModules();
+class CommandHandler;
+
+void LoadModules(CommandHandler &cmdHandler);
+void LoadModule(wxString fname);
+
wxWindow * MakeHijackPanel();
//
Index: LoadModules.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/LoadModules.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- LoadModules.cpp 20 May 2009 06:05:38 -0000 1.10
+++ LoadModules.cpp 30 May 2009 04:32:02 -0000 1.11
@@ -26,13 +26,15 @@
#include "Audacity.h"
#include "AudacityApp.h"
#include "Internat.h"
-#include "BatchCommands.h"
+
+#include "commands/ScriptCommandRelay.h"
#include <NonGuiThread.h> // header from libwidgetextra
#include "LoadModules.h"
#define initFnName "ExtensionModuleInit"
#define scriptFnName "RegScriptServerFunc"
+#define scriptOutFnName "ScriptServerResponseFunc"
#define mainPanelFnName "MainPanelFunc"
typedef wxWindow * pwxWindow;
@@ -63,57 +65,13 @@
return pPanelHijack(0);
}
-//------- Start of stuff related to invoking a batch command ----
-// Our DLL may call commands back in Audacity.
-// It will do that through the ExecCommand function.
-extern "C" {
-
-typedef int (*tpExecScriptServerFunc)( wxString * pOut, wxString * pIn);
-typedef int (*tpRegScriptServerFunc)(tpExecScriptServerFunc pFn);
-
-// This is the function which actually obeys one command.
-AUDACITY_DLL_API int ExecCommand( wxString * pOut, wxString * pIn )
-{
- // Create a Batch that will have just one command in it...
- BatchCommands Batch;
- bool rc;
-
- // Find the command name terminator...ingore line if not found
- int splitAt = pIn->Find(wxT(':'));
- if (splitAt < 0) {
- *pOut= wxT("BAD - Missing ':'?");
- return false;
- }
-
- // Parse and clean
- wxString cmd = pIn->Left(splitAt).Strip(wxString::both);
- wxString parm = pIn->Mid(splitAt + 1).Strip(wxString::trailing);
-
- rc = Batch.ApplyCommand( cmd, parm );
- if( rc )
- {
- *pOut = wxT("OK");
- return rc;
- }
- *pOut = wxT("FAILED to Execute");
- return rc;
-}
-}
-
-// This variable will hold the address of a subroutine in
-// a DLL that starts a thread and reads script commands.
-tpRegScriptServerFunc scriptFn = NULL;
-
-// We pass the ExecFunction to any scripting DLL that needs it
-// right here.
-void RegisterAndRun( )
-{
- wxASSERT( scriptFn != NULL );
- while( true )
- scriptFn(&ExecCommand);
-}
+// This variable will hold the address of a subroutine in a DLL that
+// starts a thread and reads script commands.
+tpRegScriptServerFunc scriptFn;
-//------- End of stuff related to invoking a batch command ----
+// This variable will hold the address of a subroutine in a DLL that
+// recieves responses from the main program.
+tpScriptServerResponseFunc scriptOutFn;
void LoadModule(wxString fname)
{
@@ -140,6 +98,8 @@
if(( scriptFn == NULL ) &&(result>=0 ))
scriptFn =
(tpRegScriptServerFunc)(pDLL->GetSymbol(wxT(scriptFnName)));
+ if(( scriptOutFn == NULL ) &&(result>=0 ))
+ scriptOutFn =
(tpScriptServerResponseFunc)(pDLL->GetSymbol(wxT(scriptOutFnName)));
if((pPanelHijack==NULL ) && (result>=0))
pPanelHijack = (tPanelFn)(pDLL->GetSymbol(wxT(mainPanelFnName)));
@@ -148,7 +108,7 @@
::wxSetWorkingDirectory(saveOldCWD);
}
-void LoadModules()
+void LoadModules(CommandHandler &cmdHandler)
{
wxArrayString audacityPathList = wxGetApp().audacityPathList;
wxArrayString pathList;
@@ -184,9 +144,12 @@
for(i=0; i<files.GetCount(); i++)
LoadModule(files[i]);
// After loading all the modules, we may have a registered scripting
function.
- if( scriptFn )
+ if(scriptFn && scriptOutFn)
{
- NonGuiThread::StartChild( &RegisterAndRun );
+ ScriptCommandRelay::SetCommandHandler(cmdHandler);
+ ScriptCommandRelay::SetRegScriptServerFunc(scriptFn);
+ ScriptCommandRelay::SetScriptServerResponseFunc(scriptOutFn);
+ NonGuiThread::StartChild(&ScriptCommandRelay::Run);
}
}
Index: AudacityApp.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/AudacityApp.cpp,v
retrieving revision 1.233
retrieving revision 1.234
diff -u -d -r1.233 -r1.234
--- AudacityApp.cpp 27 May 2009 15:40:05 -0000 1.233
+++ AudacityApp.cpp 30 May 2009 04:32:02 -0000 1.234
@@ -61,6 +61,8 @@
#include "AudioIO.h"
#include "Benchmark.h"
#include "DirManager.h"
+#include "commands/CommandHandler.h"
+#include "commands/AppCommandEvent.h"
#include "effects/LoadEffects.h"
#include "effects/Contrast.h"
#include "FFmpeg.h"
@@ -478,6 +480,9 @@
EVT_MENU(wxID_FILE, AudacityApp::OnMRUClear)
EVT_MENU_RANGE(wxID_FILE1, wxID_FILE9, AudacityApp::OnMRUFile)
// EVT_MENU_RANGE(6050, 6060, AudacityApp::OnMRUProject)
+
+ // Handle AppCommandEvents (usually from a script)
+ EVT_APP_COMMAND(wxID_ANY, AudacityApp::OnReceiveCommand)
END_EVENT_TABLE()
// Backend for OnMRUFile and OnMRUProject
@@ -740,8 +745,11 @@
// Initialize the ModuleManager
ModuleManager::Initialize();
+ // Initialize the CommandHandler
+ InitCommandHandler();
+
// load audacity plug-in modules
- LoadModules();
+ LoadModules(*mCmdHandler);
// Locale
// wxWindows 2.3 has a much nicer wxLocale API. We can make this code much
@@ -816,6 +824,7 @@
SetExitOnFrameDelete(true);
AudacityProject *project = CreateNewAudacityProject();
+ mCmdHandler->SetProject(project);
wxWindow * pWnd = MakeHijackPanel() ;
if( pWnd )
@@ -1013,6 +1022,26 @@
return TRUE;
}
+void AudacityApp::InitCommandHandler()
+{
+ mCmdHandler = new CommandHandler(*this);
+ //SetNextHandler(mCmdHandler);
+}
+
+void AudacityApp::DeInitCommandHandler()
+{
+ wxASSERT(NULL != mCmdHandler);
+ delete mCmdHandler;
+ mCmdHandler = NULL;
+}
+
+// AppCommandEvent callback - just pass the event on to the CommandHandler
+void AudacityApp::OnReceiveCommand(AppCommandEvent &event)
+{
+ wxASSERT(NULL != mCmdHandler);
+ mCmdHandler->OnReceiveCommand(event);
+}
+
bool AudacityApp::InitCleanSpeech()
{
wxString userdatadir = FileNames::DataDir();
@@ -1380,6 +1409,8 @@
}
}
+ DeInitCommandHandler();
+
mRecentFiles->Save(*gPrefs, wxT("RecentFiles"));
delete mRecentFiles;
------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs