52 changes: 27 additions & 25 deletions source/backend/plugin/CarlaPluginBridge.cpp
Expand Up @@ -52,6 +52,7 @@ static const ExternalMidiNote kExternalMidiNoteFallback = { -1, 0, 0 };

// --------------------------------------------------------------------------------------------------------------------

#ifndef CARLA_OS_WIN
static String findWinePrefix(const String filename, const int recursionLimit = 10)
{
if (recursionLimit == 0 || filename.length() < 5 || ! filename.contains("/"))
Expand All @@ -64,6 +65,7 @@ static String findWinePrefix(const String filename, const int recursionLimit = 1

return findWinePrefix(path, recursionLimit-1);
}
#endif

// --------------------------------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -128,15 +130,15 @@ class CarlaPluginBridgeThread : public CarlaThread
fBridgeBinary(),
fLabel(),
fShmIds(),
#ifndef CARLA_OS_WIN
#ifndef CARLA_OS_WIN
fWinePrefix(),
#endif
#endif
fProcess() {}

void setData(
#ifndef CARLA_OS_WIN
#ifndef CARLA_OS_WIN
const char* const winePrefix,
#endif
#endif
const char* const binaryArchName,
const char* const bridgeBinary,
const char* const label,
Expand All @@ -146,9 +148,9 @@ class CarlaPluginBridgeThread : public CarlaThread
CARLA_SAFE_ASSERT_RETURN(shmIds != nullptr && shmIds[0] != '\0',);
CARLA_SAFE_ASSERT(! isThreadRunning());

#ifndef CARLA_OS_WIN
#ifndef CARLA_OS_WIN
fWinePrefix = winePrefix;
#endif
#endif
fBinaryArchName = binaryArchName;
fBridgeBinary = bridgeBinary;
fShmIds = shmIds;
Expand Down Expand Up @@ -190,7 +192,7 @@ class CarlaPluginBridgeThread : public CarlaThread

StringArray arguments;

#ifndef CARLA_OS_WIN
#ifndef CARLA_OS_WIN
// start with "wine" if needed
if (fBridgeBinary.endsWithIgnoreCase(".exe"))
{
Expand All @@ -212,7 +214,7 @@ class CarlaPluginBridgeThread : public CarlaThread

arguments.add(wineCMD);
}
#endif
#endif

// setup binary arch
ChildProcess::Type childType;
Expand Down Expand Up @@ -245,10 +247,10 @@ class CarlaPluginBridgeThread : public CarlaThread
{
const ScopedEngineEnvironmentLocker _seel(kEngine);

#ifdef CARLA_OS_LINUX
#ifdef CARLA_OS_LINUX
const CarlaScopedEnvVar sev1("LD_LIBRARY_PATH", nullptr);
const CarlaScopedEnvVar sev2("LD_PRELOAD", nullptr);
#endif
#endif

carla_setenv("ENGINE_OPTION_FORCE_STEREO", bool2str(options.forceStereo));
carla_setenv("ENGINE_OPTION_PREFER_PLUGIN_BRIDGES", bool2str(options.preferPluginBridges));
Expand Down Expand Up @@ -318,7 +320,7 @@ class CarlaPluginBridgeThread : public CarlaThread

carla_setenv("ENGINE_BRIDGE_SHM_IDS", fShmIds.toRawUTF8());

#ifndef CARLA_OS_WIN
#ifndef CARLA_OS_WIN
if (fWinePrefix.isNotEmpty())
{
carla_setenv("WINEDEBUG", "-all");
Expand Down Expand Up @@ -354,12 +356,12 @@ class CarlaPluginBridgeThread : public CarlaThread
carla_stdout("Using WINEPREFIX '%s', without RT priorities", fWinePrefix.toRawUTF8());
}
}
#endif
#endif

carla_stdout("Starting plugin bridge, command is:\n%s \"%s\" \"%s\" \"%s\" " P_INT64,
fBridgeBinary.toRawUTF8(), getPluginTypeAsString(kPlugin->getType()), filename.toRawUTF8(), fLabel.toRawUTF8(), kPlugin->getUniqueId());

#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
const File projFolder(kEngine->getCurrentProjectFolder());

if (projFolder.isNotNull())
Expand All @@ -370,7 +372,7 @@ class CarlaPluginBridgeThread : public CarlaThread
oldFolder.setAsCurrentWorkingDirectory();
}
else
#endif
#endif
{
started = fProcess->start(arguments, childType);
}
Expand Down Expand Up @@ -427,9 +429,9 @@ class CarlaPluginBridgeThread : public CarlaThread
String fBridgeBinary;
String fLabel;
String fShmIds;
#ifndef CARLA_OS_WIN
#ifndef CARLA_OS_WIN
String fWinePrefix;
#endif
#endif

CarlaScopedPointer<ChildProcess> fProcess;

Expand Down Expand Up @@ -460,9 +462,9 @@ class CarlaPluginBridge : public CarlaPlugin
fShmRtClientControl(),
fShmNonRtClientControl(),
fShmNonRtServerControl(),
#ifndef CARLA_OS_WIN
#ifndef CARLA_OS_WIN
fWinePrefix(),
#endif
#endif
fReceivingParamText(),
fInfo(),
fUniqueId(0),
Expand All @@ -478,11 +480,11 @@ class CarlaPluginBridge : public CarlaPlugin
{
carla_debug("CarlaPluginBridge::~CarlaPluginBridge()");

#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
// close UI
if (pData->hints & PLUGIN_HAS_CUSTOM_UI)
pData->transientTryCounter = 0;
#endif
#endif

pData->singleMutex.lock();
pData->masterMutex.lock();
Expand Down Expand Up @@ -2754,7 +2756,7 @@ class CarlaPluginBridge : public CarlaPlugin
return false;
}

#ifndef CARLA_OS_WIN
#ifndef CARLA_OS_WIN
// ---------------------------------------------------------------
// set wine prefix

Expand All @@ -2767,7 +2769,7 @@ class CarlaPluginBridge : public CarlaPlugin

if (fWinePrefix.isEmpty())
{
const char* const envWinePrefix(std::getenv("WINEPREFIX"));
const char* const envWinePrefix = std::getenv("WINEPREFIX");

if (envWinePrefix != nullptr && envWinePrefix[0] != '\0')
fWinePrefix = envWinePrefix;
Expand All @@ -2777,7 +2779,7 @@ class CarlaPluginBridge : public CarlaPlugin
fWinePrefix = File::getSpecialLocation(File::userHomeDirectory).getFullPathName() + "/.wine";
}
}
#endif
#endif

// ---------------------------------------------------------------
// init bridge thread
Expand Down Expand Up @@ -2914,9 +2916,9 @@ class CarlaPluginBridge : public CarlaPlugin
BridgeNonRtClientControl fShmNonRtClientControl;
BridgeNonRtServerControl fShmNonRtServerControl;

#ifndef CARLA_OS_WIN
#ifndef CARLA_OS_WIN
String fWinePrefix;
#endif
#endif

class ReceivingParamText {
public:
Expand Down
137 changes: 125 additions & 12 deletions source/backend/utils/PluginDiscovery.cpp
Expand Up @@ -33,6 +33,23 @@ namespace CB = CARLA_BACKEND_NAMESPACE;

// --------------------------------------------------------------------------------------------------------------------

#ifndef CARLA_OS_WIN
static water::String findWinePrefix(const water::String filename, const int recursionLimit = 10)
{
if (recursionLimit == 0 || filename.length() < 5 || ! filename.contains("/"))
return "";

const water::String path(filename.upToLastOccurrenceOf("/", false, false));

if (water::File(path + "/dosdevices").isDirectory())
return path;

return findWinePrefix(path, recursionLimit-1);
}
#endif

// --------------------------------------------------------------------------------------------------------------------

static const char* const gPluginsDiscoveryNullCharPtr = "";

_CarlaPluginDiscoveryMetadata::_CarlaPluginDiscoveryMetadata() noexcept
Expand Down Expand Up @@ -61,6 +78,24 @@ _CarlaPluginDiscoveryInfo::_CarlaPluginDiscoveryInfo() noexcept

// --------------------------------------------------------------------------------------------------------------------

struct CarlaPluginDiscoveryOptions {
#if !defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) && !defined(CARLA_OS_WIN)
struct {
bool autoPrefix;
CarlaString executable;
CarlaString fallbackPrefix;
} wine;
#endif

static CarlaPluginDiscoveryOptions& getInstance() noexcept
{
static CarlaPluginDiscoveryOptions instance;
return instance;
}
};

// --------------------------------------------------------------------------------------------------------------------

class CarlaPluginDiscovery : private CarlaPipeServer
{
public:
Expand Down Expand Up @@ -367,36 +402,59 @@ class CarlaPluginDiscovery : private CarlaPipeServer

void start()
{
using water::File;
using water::String;

fLastMessageTime = carla_gettime_ms();
fPluginsFoundInBinary = false;
fNextSha1Sum.clear();

const char* helperTool;
#ifndef CARLA_OS_WIN
const CarlaPluginDiscoveryOptions& options(CarlaPluginDiscoveryOptions::getInstance());

String helperTool;

switch (fBinaryType)
{
#ifndef CARLA_OS_WIN
case CB::BINARY_WIN32:
helperTool = "wine";
if (options.wine.executable.isNotEmpty())
helperTool = options.wine.executable.buffer();
else
helperTool = "wine";
break;

case CB::BINARY_WIN64:
helperTool = "wine64";
if (options.wine.executable.isNotEmpty())
{
helperTool = options.wine.executable.buffer();

if (helperTool[0] == CARLA_OS_SEP && File(helperTool + "64").existsAsFile())
helperTool += "64";
}
else
{
helperTool = "wine";
}
break;
#endif

default:
helperTool = nullptr;
break;
}
#endif

if (fBinaries.empty())
{
startPipeServer(helperTool, fDiscoveryTool,
getPluginTypeAsString(fPluginType),
":all");
#ifndef CARLA_OS_WIN
if (helperTool.isNotEmpty())
startPipeServer(helperTool.toRawUTF8(), fDiscoveryTool, getPluginTypeAsString(fPluginType), ":all");
else
#endif
startPipeServer(fDiscoveryTool, getPluginTypeAsString(fPluginType), ":all");
}
else
{
const water::File file(fBinaries[fBinaryIndex]);
const water::String filename(file.getFullPathName());
const File file(fBinaries[fBinaryIndex]);
const String filename(file.getFullPathName());

if (fCheckCacheCallback != nullptr)
{
Expand All @@ -410,8 +468,36 @@ class CarlaPluginDiscovery : private CarlaPipeServer
}
}

#ifndef CARLA_OS_WIN
String winePrefix;

if (options.wine.autoPrefix)
winePrefix = findWinePrefix(filename);

if (winePrefix.isEmpty())
{
const char* const envWinePrefix = std::getenv("WINEPREFIX");

if (envWinePrefix != nullptr && envWinePrefix[0] != '\0')
winePrefix = envWinePrefix;
else if (options.wine.fallbackPrefix != nullptr && options.wine.fallbackPrefix[0] != '\0')
winePrefix = options.wine.fallbackPrefix.buffer();
else
winePrefix = File::getSpecialLocation(File::userHomeDirectory).getFullPathName() + "/.wine";
}

const CarlaScopedEnvVar sev1("WINEDEBUG", "-all");
const CarlaScopedEnvVar sev2("WINEPREFIX", winePrefix.toRawUTF8());
#endif

carla_stdout("Scanning \"%s\"...", filename.toRawUTF8());
startPipeServer(helperTool, fDiscoveryTool, getPluginTypeAsString(fPluginType), filename.toRawUTF8());

#ifndef CARLA_OS_WIN
if (helperTool.isNotEmpty())
startPipeServer(helperTool.toRawUTF8(), fDiscoveryTool, getPluginTypeAsString(fPluginType), filename.toRawUTF8());
else
#endif
startPipeServer(fDiscoveryTool, getPluginTypeAsString(fPluginType), filename.toRawUTF8());
}
}

Expand Down Expand Up @@ -696,4 +782,31 @@ void carla_plugin_discovery_stop(const CarlaPluginDiscoveryHandle handle)
delete static_cast<CarlaPluginDiscovery*>(handle);
}

void carla_plugin_discovery_set_option(const EngineOption option, const int value, const char* const valueStr)
{
switch (option)
{
#if !defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) && !defined(CARLA_OS_WIN)
case CB::ENGINE_OPTION_WINE_EXECUTABLE:
if (valueStr != nullptr && valueStr[0] != '\0')
CarlaPluginDiscoveryOptions::getInstance().wine.executable = valueStr;
else
CarlaPluginDiscoveryOptions::getInstance().wine.executable.clear();
break;
case CB::ENGINE_OPTION_WINE_AUTO_PREFIX:
CARLA_SAFE_ASSERT_RETURN(value == 0 || value == 1,);
CarlaPluginDiscoveryOptions::getInstance().wine.autoPrefix = value != 0;
break;
case CB::ENGINE_OPTION_WINE_FALLBACK_PREFIX:
if (valueStr != nullptr && valueStr[0] != '\0')
CarlaPluginDiscoveryOptions::getInstance().wine.fallbackPrefix = valueStr;
else
CarlaPluginDiscoveryOptions::getInstance().wine.fallbackPrefix.clear();
break;
#endif
default:
break;
}
}

// --------------------------------------------------------------------------------------------------------------------
32 changes: 25 additions & 7 deletions source/frontend/CarlaFrontend.h
Expand Up @@ -20,6 +20,7 @@
#include "CarlaBackend.h"

#ifdef __cplusplus
using CARLA_BACKEND_NAMESPACE::PluginType;
extern "C" {
#endif

Expand All @@ -31,6 +32,15 @@ typedef struct {
const char* labelSetup;
} JackAppDialogResults;

typedef struct _HostSettings {
bool showPluginBridges;
bool showWineBridges;
bool useSystemIcons;
bool wineAutoPrefix;
const char* wineExecutable;
const char* wineFallbackPrefix;
} HostSettings;

typedef struct {
uint build;
uint type;
Expand All @@ -55,20 +65,28 @@ struct PluginListDialog;

// --------------------------------------------------------------------------------------------------------------------

CARLA_API void
CARLA_PLUGIN_EXPORT void
carla_frontend_createAndExecAboutJuceDialog(void* parent);

CARLA_API const JackAppDialogResults*
CARLA_PLUGIN_EXPORT const JackAppDialogResults*
carla_frontend_createAndExecJackAppDialog(void* parent, const char* projectFilename);

CARLA_API PluginListDialog*
carla_frontend_createPluginListDialog(void* parent);
CARLA_PLUGIN_EXPORT PluginListDialog*
carla_frontend_createPluginListDialog(void* parent, const HostSettings* hostSettings);

CARLA_PLUGIN_EXPORT void
carla_frontend_destroyPluginListDialog(PluginListDialog* dialog);

// TODO get favorites

CARLA_PLUGIN_EXPORT void
carla_frontend_setPluginListDialogPath(PluginListDialog* dialog, int ptype, const char* path);

CARLA_API const PluginListDialogResults*
CARLA_PLUGIN_EXPORT const PluginListDialogResults*
carla_frontend_execPluginListDialog(PluginListDialog* dialog);

CARLA_API const PluginListDialogResults*
carla_frontend_createAndExecPluginListDialog(void* parent/*, const HostSettings& hostSettings*/);
// CARLA_PLUGIN_EXPORT const PluginListDialogResults*
// carla_frontend_createAndExecPluginListDialog(void* parent, const HostSettings* hostSettings);

// --------------------------------------------------------------------------------------------------------------------

Expand Down
43 changes: 33 additions & 10 deletions source/frontend/carla_frontend.py
Expand Up @@ -23,7 +23,7 @@
# Imports (ctypes)

from ctypes import (
c_bool, c_char, c_char_p, c_uint, c_uint64, c_void_p, cast,
c_bool, c_char, c_char_p, c_int, c_uint, c_uint64, c_void_p, cast,
cdll, Structure,
POINTER
)
Expand Down Expand Up @@ -53,6 +53,16 @@ class JackApplicationDialogResults(Structure):
("labelSetup", c_char_p)
]

class HostSettings(Structure):
_fields_ = [
("showPluginBridges", c_bool),
("showWineBridges", c_bool),
("useSystemIcons", c_bool),
("wineAutoPrefix", c_bool),
("wineExecutable", c_char_p),
("wineFallbackPrefix", c_char_p),
]

class PluginListDialogResults(Structure):
_fields_ = [
("build", c_uint),
Expand Down Expand Up @@ -87,15 +97,18 @@ def __init__(self, filename):
self.lib.carla_frontend_createAndExecJackAppDialog.argtypes = (c_void_p, c_char_p)
self.lib.carla_frontend_createAndExecJackAppDialog.restype = POINTER(JackApplicationDialogResults)

self.lib.carla_frontend_createPluginListDialog.argtypes = (c_void_p,)
self.lib.carla_frontend_createPluginListDialog.argtypes = (c_void_p, POINTER(HostSettings))
self.lib.carla_frontend_createPluginListDialog.restype = c_void_p

self.lib.carla_frontend_destroyPluginListDialog.argtypes = (c_void_p,)
self.lib.carla_frontend_destroyPluginListDialog.restype = None

self.lib.carla_frontend_setPluginListDialogPath.argtypes = (c_void_p, c_int, c_char_p)
self.lib.carla_frontend_setPluginListDialogPath.restype = None

self.lib.carla_frontend_execPluginListDialog.argtypes = (c_void_p,)
self.lib.carla_frontend_execPluginListDialog.restype = POINTER(PluginListDialogResults)

self.lib.carla_frontend_createAndExecPluginListDialog.argtypes = (c_void_p,)
self.lib.carla_frontend_createAndExecPluginListDialog.restype = POINTER(PluginListDialogResults)

# --------------------------------------------------------------------------------------------------------

def createAndExecAboutJuceDialog(self, parent):
Expand All @@ -105,13 +118,23 @@ def createAndExecJackAppDialog(self, parent, projectFilename):
return structToDictOrNull(self.lib.carla_frontend_createAndExecJackAppDialog(unwrapinstance(parent),
projectFilename.encode("utf-8")))

def createPluginListDialog(self, parent, useSystemIcons):
return self.lib.carla_frontend_createPluginListDialog(unwrapinstance(parent))
def createPluginListDialog(self, parent, hostSettings):
hostSettingsC = HostSettings()
hostSettingsC.showPluginBridges = hostSettings['showPluginBridges']
hostSettingsC.showWineBridges = hostSettings['showWineBridges']
hostSettingsC.useSystemIcons = hostSettings['useSystemIcons']
hostSettingsC.wineAutoPrefix = hostSettings['wineAutoPrefix']
hostSettingsC.wineExecutable = hostSettings['wineExecutable'].encode("utf-8")
hostSettingsC.wineFallbackPrefix = hostSettings['wineFallbackPrefix'].encode("utf-8")
return self.lib.carla_frontend_createPluginListDialog(unwrapinstance(parent), hostSettingsC)

def destroyPluginListDialog(self, dialog):
self.lib.carla_frontend_destroyPluginListDialog(dialog)

def setPluginListDialogPath(self, dialog, ptype, path):
self.lib.carla_frontend_setPluginListDialogPath(dialog, ptype, path.encode("utf-8"))

def execPluginListDialog(self, dialog):
return structToDictOrNull(self.lib.carla_frontend_execPluginListDialog(dialog))

def createAndExecPluginListDialog(self, parent, useSystemIcons):
return structToDictOrNull(self.lib.carla_frontend_createAndExecPluginListDialog(unwrapinstance(parent)))

# ------------------------------------------------------------------------------------------------------------
266 changes: 180 additions & 86 deletions source/frontend/carla_host.py

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions source/frontend/carla_shared.py
Expand Up @@ -204,6 +204,10 @@

CARLA_KEY_ENGINE_DRIVER_PREFIX = "Engine/Driver-"
CARLA_KEY_ENGINE_AUDIO_DRIVER = "Engine/AudioDriver" # str
CARLA_KEY_ENGINE_AUDIO_DEVICE = "Engine/AudioDevice" # str
CARLA_KEY_ENGINE_BUFFER_SIZE = "Engine/BufferSize" # int
CARLA_KEY_ENGINE_SAMPLE_RATE = "Engine/SampleRate" # int
CARLA_KEY_ENGINE_TRIPLE_BUFFER = "Engine/TripleBuffer" # bool
CARLA_KEY_ENGINE_PROCESS_MODE = "Engine/ProcessMode" # enum
CARLA_KEY_ENGINE_TRANSPORT_MODE = "Engine/TransportMode" # enum
CARLA_KEY_ENGINE_TRANSPORT_EXTRA = "Engine/TransportExtra" # str
Expand Down
111 changes: 77 additions & 34 deletions source/frontend/pluginlist/pluginlistdialog.cpp
Expand Up @@ -33,7 +33,6 @@

#include "CarlaBackendUtils.hpp"
#include "CarlaJuceUtils.hpp"
#include "CarlaFrontend.h"
#include "CarlaUtils.h"

#include "CarlaString.hpp"
Expand All @@ -42,22 +41,6 @@

CARLA_BACKEND_USE_NAMESPACE

// --------------------------------------------------------------------------------------------------------------------
// Carla Settings keys

#define CARLA_KEY_PATHS_LADSPA "Paths/LADSPA"
#define CARLA_KEY_PATHS_DSSI "Paths/DSSI"
#define CARLA_KEY_PATHS_LV2 "Paths/LV2"
#define CARLA_KEY_PATHS_VST2 "Paths/VST2"
#define CARLA_KEY_PATHS_VST3 "Paths/VST3"
#define CARLA_KEY_PATHS_CLAP "Paths/CLAP"
#define CARLA_KEY_PATHS_SF2 "Paths/SF2"
#define CARLA_KEY_PATHS_SFZ "Paths/SFZ"
#define CARLA_KEY_PATHS_JSFX "Paths/JSFX"

// --------------------------------------------------------------------------------------------------------------------
// Carla Settings defaults

// --------------------------------------------------------------------------------------------------------------------
// getenv with a fallback value if unset

Expand Down Expand Up @@ -381,11 +364,11 @@ struct PluginPaths {
static inline
int fontMetricsHorizontalAdvance(const QFontMetrics& fontMetrics, const QString& string)
{
#if QT_VERSION >= 0x50b00
#if QT_VERSION >= 0x50b00
return fontMetrics.horizontalAdvance(string);
#else
#else
return fontMetrics.width(string);
#endif
#endif
}

// --------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -692,6 +675,7 @@ struct PluginListDialog::PrivateData {
carla_plugin_discovery_stop(handle);
}

#ifndef CARLA_FRONTEND_ONLY_EMBEDDABLE_PLUGINS
bool nextTool()
{
if (handle != nullptr)
Expand Down Expand Up @@ -771,6 +755,7 @@ struct PluginListDialog::PrivateData {
tool += ".exe";
#endif
}
#endif // CARLA_FRONTEND_ONLY_EMBEDDABLE_PLUGINS
} discovery;

PluginPaths paths;
Expand Down Expand Up @@ -825,13 +810,20 @@ struct PluginListDialog::PrivateData {
// --------------------------------------------------------------------------------------------------------------------
// Plugin List Dialog

PluginListDialog::PluginListDialog(QWidget* const parent, const HostSettings& hostSettings)
PluginListDialog::PluginListDialog(QWidget* const parent, const HostSettings* const hostSettings)
: QDialog(parent),
p(new PrivateData)
{
ui.setupUi(this);

// p->hostSettings = hostSettings;
// ----------------------------------------------------------------------------------------------------------------
// Set-up global discovery options

#ifndef CARLA_OS_WIN
carla_plugin_discovery_set_option(ENGINE_OPTION_WINE_AUTO_PREFIX, hostSettings->wineAutoPrefix, nullptr);
carla_plugin_discovery_set_option(ENGINE_OPTION_WINE_EXECUTABLE, 0, hostSettings->wineExecutable);
carla_plugin_discovery_set_option(ENGINE_OPTION_WINE_FALLBACK_PREFIX, 0, hostSettings->wineFallbackPrefix);
#endif

// ----------------------------------------------------------------------------------------------------------------
// Set-up GUI
Expand Down Expand Up @@ -917,7 +909,7 @@ PluginListDialog::PluginListDialog(QWidget* const parent, const HostSettings& ho
// ----------------------------------------------------------------------------------------------------------------
// Set-up Icons

if (hostSettings.useSystemIcons)
if (hostSettings->useSystemIcons)
{
#if 0
ui.b_add.setIcon(getIcon('list-add', 16, 'svgz'))
Expand Down Expand Up @@ -1090,6 +1082,44 @@ bool PluginListDialog::checkPluginCache(const char* const filename, const char*
return true;
}

void PluginListDialog::setPluginPath(const PluginType ptype, const char* const path)
{
switch (ptype)
{
case PLUGIN_LV2:
p->paths.lv2 = path;
break;
case PLUGIN_VST2:
p->paths.vst2 = path;
break;
case PLUGIN_VST3:
p->paths.vst3 = path;
break;
case PLUGIN_CLAP:
p->paths.clap = path;
break;
#ifndef CARLA_FRONTEND_ONLY_EMBEDDABLE_PLUGINS
case PLUGIN_LADSPA:
p->paths.ladspa = path;
break;
case PLUGIN_DSSI:
p->paths.dssi = path;
break;
case PLUGIN_SF2:
p->paths.sf2 = path;
break;
case PLUGIN_SFZ:
p->paths.sfz = path;
break;
case PLUGIN_JSFX:
p->paths.jsfx = path;
break;
#endif
default:
break;
}
}

// --------------------------------------------------------------------------------------------------------------------
// protected methods

Expand Down Expand Up @@ -1239,7 +1269,9 @@ void PluginListDialog::timerEvent(QTimerEvent* const event)
#endif
default:
// discovery complete
#ifndef CARLA_FRONTEND_ONLY_EMBEDDABLE_PLUGINS
if (! p->discovery.nextTool())
#endif
refreshPluginsStop();
}

Expand Down Expand Up @@ -1489,7 +1521,7 @@ void PluginListDialog::loadSettings()
#endif
}

// -----------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// private slots

void PluginListDialog::cellClicked(const int row, const int column)
Expand Down Expand Up @@ -1994,12 +2026,24 @@ void PluginListDialog::saveSettings()
// --------------------------------------------------------------------------------------------------------------------

PluginListDialog*
carla_frontend_createPluginListDialog(void* const parent)
carla_frontend_createPluginListDialog(void* const parent, const HostSettings* const hostSettings)
{
const HostSettings hostSettings = {};
return new PluginListDialog(reinterpret_cast<QWidget*>(parent), hostSettings);
}

void
carla_frontend_destroyPluginListDialog(PluginListDialog* const dialog)
{
dialog->close();
delete dialog;
}

void
carla_frontend_setPluginListDialogPath(PluginListDialog* const dialog, const int ptype, const char* const path)
{
dialog->setPluginPath(static_cast<PluginType>(ptype), path);
}

const PluginListDialogResults*
carla_frontend_execPluginListDialog(PluginListDialog* const dialog)
{
Expand Down Expand Up @@ -2046,13 +2090,12 @@ carla_frontend_execPluginListDialog(PluginListDialog* const dialog)

// --------------------------------------------------------------------------------------------------------------------

const PluginListDialogResults*
carla_frontend_createAndExecPluginListDialog(void* const parent/*, const HostSettings& hostSettings*/)
{
const HostSettings hostSettings = {};
PluginListDialog gui(reinterpret_cast<QWidget*>(parent), hostSettings);

return carla_frontend_execPluginListDialog(&gui);
}
// const PluginListDialogResults*
// carla_frontend_createAndExecPluginListDialog(void* const parent, const HostSettings* const hostSettings)
// {
// PluginListDialog gui(reinterpret_cast<QWidget*>(parent), hostSettings);
//
// return carla_frontend_execPluginListDialog(&gui);
// }

// --------------------------------------------------------------------------------------------------------------------
12 changes: 5 additions & 7 deletions source/frontend/pluginlist/pluginlistdialog.hpp
Expand Up @@ -6,6 +6,8 @@

#pragma once

#include "CarlaFrontend.h"

#ifdef __clang__
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wdeprecated-copy-with-user-provided-copy"
Expand All @@ -26,14 +28,9 @@

#include "ui_pluginlistdialog.h"

struct HostSettings {
bool showPluginBridges;
bool showWineBridges;
bool useSystemIcons;
};

class QSafeSettings;
typedef struct _CarlaPluginDiscoveryInfo CarlaPluginDiscoveryInfo;
typedef struct _HostSettings HostSettings;
struct PluginInfo;

// --------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -63,12 +60,13 @@ class PluginListDialog : public QDialog
// public methods

public:
explicit PluginListDialog(QWidget* parent, const HostSettings& hostSettings);
explicit PluginListDialog(QWidget* parent, const HostSettings* hostSettings);
~PluginListDialog() override;

const PluginInfo& getSelectedPluginInfo() const;
void addPluginInfo(const CarlaPluginDiscoveryInfo* info, const char* sha1sum);
bool checkPluginCache(const char* filename, const char* sha1sum);
void setPluginPath(PluginType ptype, const char* path);

// ----------------------------------------------------------------------------------------------------------------
// protected methods
Expand Down