Turn almost all Listeners into abstract interfaces

This commit is contained in:
Flössie
2018-10-09 20:32:40 +02:00
parent 2a9d3896bb
commit 2125f42116
159 changed files with 1385 additions and 939 deletions

View File

@@ -39,6 +39,27 @@
using namespace std;
using namespace rtengine;
namespace
{
struct NLParams {
BatchQueueListener* listener;
int qsize;
bool queueEmptied;
bool queueError;
Glib::ustring queueErrorMessage;
};
int bqnotifylistenerUI (void* data)
{
NLParams* params = static_cast<NLParams*>(data);
params->listener->queueSizeChanged (params->qsize, params->queueEmptied, params->queueError, params->queueErrorMessage);
delete params;
return 0;
}
}
BatchQueue::BatchQueue (FileCatalog* aFileCatalog) : processing(nullptr), fileCatalog(aFileCatalog), sequence(0), listener(nullptr)
{
@@ -580,9 +601,54 @@ void BatchQueue::startProcessing ()
}
}
rtengine::ProcessingJob* BatchQueue::imageReady (rtengine::IImagefloat* img)
void BatchQueue::setProgress(double p)
{
if (processing) {
processing->progress = p;
}
// No need to acquire the GUI, setProgressUI will do it
const auto func = [](gpointer data) -> gboolean {
static_cast<BatchQueue*>(data)->redraw();
return FALSE;
};
idle_register.add(func, this);
}
void BatchQueue::setProgressStr(const Glib::ustring& str)
{
}
void BatchQueue::setProgressState(bool inProcessing)
{
}
void BatchQueue::error(const Glib::ustring& descr)
{
if (processing && processing->processing) {
// restore failed thumb
BatchQueueButtonSet* bqbs = new BatchQueueButtonSet (processing);
bqbs->setButtonListener (this);
processing->addButtonSet (bqbs);
processing->processing = false;
processing->job = rtengine::ProcessingJob::create(processing->filename, processing->thumbnail->getType() == FT_Raw, processing->params);
processing = nullptr;
redraw ();
}
if (listener) {
NLParams* params = new NLParams;
params->listener = listener;
params->queueEmptied = false;
params->queueError = true;
params->queueErrorMessage = descr;
idle_register.add(bqnotifylistenerUI, params);
}
}
rtengine::ProcessingJob* BatchQueue::imageReady(rtengine::IImagefloat* img)
{
// save image img
Glib::ustring fname;
SaveFormat saveFormat;
@@ -892,22 +958,6 @@ Glib::ustring BatchQueue::autoCompleteFileName (const Glib::ustring& fileName, c
return "";
}
void BatchQueue::setProgress (double p)
{
if (processing) {
processing->progress = p;
}
// No need to acquire the GUI, setProgressUI will do it
const auto func = [](gpointer data) -> gboolean {
static_cast<BatchQueue*>(data)->redraw();
return FALSE;
};
idle_register.add(func, this);
}
void BatchQueue::buttonPressed (LWButton* button, int actionCode, void* actionData)
{
@@ -923,22 +973,6 @@ void BatchQueue::buttonPressed (LWButton* button, int actionCode, void* actionDa
}
}
struct NLParams {
BatchQueueListener* listener;
int qsize;
bool queueEmptied;
bool queueError;
Glib::ustring queueErrorMessage;
};
int bqnotifylistenerUI (void* data)
{
NLParams* params = static_cast<NLParams*>(data);
params->listener->queueSizeChanged (params->qsize, params->queueEmptied, params->queueError, params->queueErrorMessage);
delete params;
return 0;
}
void BatchQueue::notifyListener (bool queueEmptied)
{
@@ -960,27 +994,3 @@ void BatchQueue::redrawNeeded (LWButton* button)
GThreadLock lock;
queue_draw ();
}
void BatchQueue::error (Glib::ustring msg)
{
if (processing && processing->processing) {
// restore failed thumb
BatchQueueButtonSet* bqbs = new BatchQueueButtonSet (processing);
bqbs->setButtonListener (this);
processing->addButtonSet (bqbs);
processing->processing = false;
processing->job = rtengine::ProcessingJob::create(processing->filename, processing->thumbnail->getType() == FT_Raw, processing->params);
processing = nullptr;
redraw ();
}
if (listener) {
NLParams* params = new NLParams;
params->listener = listener;
params->queueEmptied = false;
params->queueError = true;
params->queueErrorMessage = msg;
idle_register.add(bqnotifylistenerUI, params);
}
}