Complete project files:
[list]
[] http://dl.dropbox.com/u/5916264/TestIntrojucer.zip[/]
[] http://dl.dropbox.com/u/5916264/PluginLister.zip[/][/list]
First, the basic “Plugin Lister”:
Main.cpp
/*
==============================================================================
This file was auto-generated by the Introjucer!
It contains the basic startup code for a Juce application.
==============================================================================
*/
#include "../JuceLibraryCode/JuceHeader.h"
//==============================================================================
class PluginListerApplication : public JUCEApplication
{
public:
//==============================================================================
PluginListerApplication()
: recursiveScan(true)
{
}
~PluginListerApplication()
{
}
void scanPlugins(int iFormatIndex, bool iHardScan)
{
juce::AudioPluginFormat* paCurrentFormat = juce::AudioPluginFormatManager::getInstance()->getFormat(iFormatIndex);
jassert(paCurrentFormat);
juce::PluginDirectoryScanner aScanner(pluginList, *paCurrentFormat, searchPath,
recursiveScan, juce::File::nonexistent );
DBG( aScanner.getNextPluginFileThatWillBeScanned() );
while(aScanner.scanNextFile(!iHardScan))
{
DBG( aScanner.getNextPluginFileThatWillBeScanned() );
DBG( aScanner.getProgress() );
}
}
void scanAllPlugins(bool iHardScan = false)
{
int aTotalFormats = juce::AudioPluginFormatManager::getInstance()->getNumFormats();
for( int i = 0; i < aTotalFormats; i++ )
{
scanPlugins(i, iHardScan);
}
}
//==============================================================================
void initialise (const String& commandLine)
{
// Add default plugin formats if not already done
if( !juce::AudioPluginFormatManager::getInstance()->getNumFormats() )
{
juce::AudioPluginFormatManager::getInstance()->addDefaultFormats();
}
scanAllPlugins();
setApplicationReturnValue(0);
systemRequestedQuit();
}
void shutdown()
{
juce::AudioPluginFormatManager::deleteInstance();
}
//==============================================================================
void systemRequestedQuit()
{
quit();
}
//==============================================================================
const String getApplicationName()
{
return "PluginLister";
}
const String getApplicationVersion()
{
return ProjectInfo::versionString;
}
bool moreThanOneInstanceAllowed()
{
return true;
}
void anotherInstanceStarted (const String& commandLine)
{
}
private:
juce::KnownPluginList pluginList;
juce::FileSearchPath searchPath;
bool recursiveScan;
};
//==============================================================================
// This macro generates the main() routine that starts the app.
START_JUCE_APPLICATION(PluginListerApplication)
Then, the TestIntrojucer simple UI that allows to give the path to the PluginLister binary and run it with or without command line arguments:
Main.cpp
/*
==============================================================================
This file was auto-generated by the Introjucer!
It contains the basic startup code for a Juce application.
==============================================================================
*/
#include "../JuceLibraryCode/JuceHeader.h"
#include "MainWindow.h"
//==============================================================================
class TestIntrojucerApplication : public JUCEApplication
{
public:
//==============================================================================
TestIntrojucerApplication()
{
}
~TestIntrojucerApplication()
{
}
//==============================================================================
void initialise (const String& commandLine)
{
// Do your application's initialisation code here..
mainWindow = new MainAppWindow();
}
void shutdown()
{
// Do your application's shutdown code here..
mainWindow = 0;
}
//==============================================================================
void systemRequestedQuit()
{
quit();
}
//==============================================================================
const String getApplicationName()
{
return "TestIntrojucer";
}
const String getApplicationVersion()
{
return ProjectInfo::versionString;
}
bool moreThanOneInstanceAllowed()
{
return true;
}
void anotherInstanceStarted (const String& commandLine)
{
}
private:
ScopedPointer <MainAppWindow> mainWindow;
};
//==============================================================================
// This macro generates the main() routine that starts the app.
START_JUCE_APPLICATION(TestIntrojucerApplication)
MainWindow.h
[code]/*
This file was auto-generated!
It contains the basic outline for a simple desktop window.
==============================================================================
*/
#ifndef MAINWINDOW_H_CCC83D1E
#define MAINWINDOW_H_CCC83D1E
#include “…/JuceLibraryCode/JuceHeader.h”
//==============================================================================
class MainAppWindow : public DocumentWindow,
public ButtonListener
{
public:
//==============================================================================
MainAppWindow();
~MainAppWindow();
void closeButtonPressed();
void buttonClicked (Button* buttonThatWasClicked);
/* Note: Be careful when overriding DocumentWindow methods - the base class
uses a lot of them, so by overriding you might break its functionality.
It's best to do all your work in you content component instead, but if
you really have to override any DocumentWindow methods, make sure your
implementation calls the superclass's method.
*/
private:
juce::ScopedPointerjuce::Component contentComponent;
juce::ScopedPointerjuce::TextEditor pathToBinary;
juce::ScopedPointerjuce::ToggleButton invokeOption;
juce::ScopedPointer scanButton;
void scanPlugins();
//==============================================================================
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainAppWindow)
};
#endif // MAINWINDOW_H_CCC83D1E
[/code]
MainWindow.cpp
[code]/*
This file was auto-generated!
It contains the basic outline for a simple desktop window.
==============================================================================
*/
#include “MainWindow.h”
//==============================================================================
MainAppWindow::MainAppWindow()
: DocumentWindow (JUCEApplication::getInstance()->getApplicationName(),
Colours::lightgrey,
DocumentWindow::allButtons),
contentComponent( new juce::Component() ),
scanButton(0)
{
contentComponent->addAndMakeVisible( pathToBinary = new TextEditor() );
pathToBinary->setText("/Users/adrien/Library/Developer/Xcode/DerivedData/PluginLister-byjyaxznnscaoibqtwahtfrerpyb/Build/Products/Debug/PluginLister.app/Contents/MacOS/PluginLister");
pathToBinary->setBounds(0, 30, 500, 20);
contentComponent->addAndMakeVisible( invokeOption = new ToggleButton(L"startAsProcess with parameters") );
invokeOption->setBounds(0, 50, 500, 50);
contentComponent->addAndMakeVisible( scanButton = new TextButton(L"scan button") );
scanButton->setButtonText(L"Scan");
scanButton->addListener(this);
scanButton->setBounds(0, 100, 500, 50);
centreWithSize(500, 200);
contentComponent->setSize( getWidth(), getHeight() );
contentComponent->setVisible(true);
setContentNonOwned( contentComponent, true );
setVisible(true);
}
MainAppWindow::~MainAppWindow()
{
}
void MainAppWindow::buttonClicked(Button* buttonThatWasClicked)
{
if (buttonThatWasClicked == scanButton)
{
scanPlugins();
}
}
//
void MainAppWindow::closeButtonPressed()
{
JUCEApplication::getInstance()->systemRequestedQuit();
}
void MainAppWindow::scanPlugins()
{
juce::File aPluginFile(pathToBinary->getText());
juce::String aParameters("-test_parameter -dummy option");
if( invokeOption->getToggleState() )
{
aPluginFile.startAsProcess( aParameters );
}
else
{
aPluginFile.startAsProcess();
}
}
[/code]
If anybody wants to try it out themselves…