Cleanups and simplifications, espc. batch queue
This commit is contained in:
@@ -119,9 +119,8 @@ void BatchQueue::addEntries ( std::vector<BatchQueueEntry*> &entries, bool head)
|
||||
saveBatchQueue( );
|
||||
}
|
||||
|
||||
arrangeFiles ();
|
||||
queue_draw ();
|
||||
notifyListener ();
|
||||
redraw();
|
||||
notifyListener (false);
|
||||
}
|
||||
|
||||
bool BatchQueue::saveBatchQueue( )
|
||||
@@ -206,10 +205,8 @@ void BatchQueue::loadBatchQueue( )
|
||||
}
|
||||
}
|
||||
|
||||
arrangeFiles ();
|
||||
queue_draw ();
|
||||
|
||||
notifyListener();
|
||||
redraw();
|
||||
notifyListener(false);
|
||||
}
|
||||
|
||||
Glib::ustring BatchQueue::getTempFilenameForParams( const Glib::ustring filename )
|
||||
@@ -265,7 +262,7 @@ void BatchQueue::cancelItems (std::vector<ThumbBrowserEntryBase*>* items) {
|
||||
}
|
||||
|
||||
redraw ();
|
||||
notifyListener ();
|
||||
notifyListener (false);
|
||||
}
|
||||
|
||||
void BatchQueue::headItems (std::vector<ThumbBrowserEntryBase*>* items) {
|
||||
@@ -369,7 +366,6 @@ void BatchQueue::startProcessing () {
|
||||
}
|
||||
|
||||
rtengine::ProcessingJob* BatchQueue::imageReady (rtengine::IImage16* img) {
|
||||
GThreadLock lock;
|
||||
|
||||
// save image img
|
||||
Glib::ustring fname;
|
||||
@@ -407,16 +403,14 @@ rtengine::ProcessingJob* BatchQueue::imageReady (rtengine::IImage16* img) {
|
||||
if (processing->thumbnail) {
|
||||
processing->thumbnail->imageDeveloped ();
|
||||
processing->thumbnail->imageRemovedFromQueue ();
|
||||
if (listener)
|
||||
listener->imageProcessingReady (processing->filename);
|
||||
}
|
||||
}
|
||||
// save temporary params file name: delete as last thing
|
||||
Glib::ustring processedParams = processing->savedParamsFile;
|
||||
|
||||
// delete from the queue
|
||||
delete processing;
|
||||
processing = NULL;
|
||||
delete processing; processing = NULL;
|
||||
bool queueEmptied=false;
|
||||
{
|
||||
// TODO: Check for Linux
|
||||
#ifdef WIN32
|
||||
@@ -427,8 +421,7 @@ rtengine::ProcessingJob* BatchQueue::imageReady (rtengine::IImage16* img) {
|
||||
|
||||
// return next job
|
||||
if (fd.size()==0) {
|
||||
if (listener)
|
||||
listener->queueEmpty ();
|
||||
queueEmptied=true;
|
||||
}
|
||||
else if (listener && listener->canStartNext ()) {
|
||||
BatchQueueEntry* next = (BatchQueueEntry*)fd[0];
|
||||
@@ -445,7 +438,7 @@ rtengine::ProcessingJob* BatchQueue::imageReady (rtengine::IImage16* img) {
|
||||
// remove button set
|
||||
next->removeButtonSet ();
|
||||
}
|
||||
if( saveBatchQueue( ) ){
|
||||
if (saveBatchQueue( )) {
|
||||
safe_g_remove( processedParams );
|
||||
// Delete all files in directory \batch when finished, just to be sure to remove zombies
|
||||
if( fd.size()==0 ){
|
||||
@@ -460,7 +453,7 @@ rtengine::ProcessingJob* BatchQueue::imageReady (rtengine::IImage16* img) {
|
||||
}
|
||||
|
||||
redraw ();
|
||||
notifyListener ();
|
||||
notifyListener (queueEmptied);
|
||||
|
||||
return processing ? processing->job : NULL;
|
||||
}
|
||||
@@ -622,21 +615,23 @@ void BatchQueue::buttonPressed (LWButton* button, int actionCode, void* actionDa
|
||||
struct NLParams {
|
||||
BatchQueueListener* listener;
|
||||
int qsize;
|
||||
bool queueEmptied;
|
||||
};
|
||||
|
||||
int bqnotifylistenerUI (void* data) {
|
||||
NLParams* params = (NLParams*)data;
|
||||
params->listener->queueSizeChanged (params->qsize);
|
||||
params->listener->queueSizeChanged (params->qsize, params->queueEmptied);
|
||||
delete params;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void BatchQueue::notifyListener () {
|
||||
void BatchQueue::notifyListener (bool queueEmptied) {
|
||||
|
||||
if (listener) {
|
||||
NLParams* params = new NLParams;
|
||||
params->listener = listener;
|
||||
params->qsize = fd.size();
|
||||
params->queueEmptied = queueEmptied;
|
||||
g_idle_add (bqnotifylistenerUI, params);
|
||||
}
|
||||
}
|
||||
|
@@ -28,9 +28,7 @@
|
||||
class BatchQueueListener {
|
||||
|
||||
public:
|
||||
virtual void queueSizeChanged (int qsize) =0;
|
||||
virtual void imageProcessingReady (Glib::ustring fname) =0;
|
||||
virtual void queueEmpty () =0;
|
||||
virtual void queueSizeChanged (int qsize, bool queueEmptied) =0;
|
||||
virtual bool canStartNext () =0;
|
||||
};
|
||||
|
||||
@@ -57,7 +55,7 @@ class BatchQueue : public ThumbBrowserBase,
|
||||
Glib::ustring autoCompleteFileName (const Glib::ustring& fileName, const Glib::ustring& format);
|
||||
Glib::ustring getTempFilenameForParams( const Glib::ustring filename );
|
||||
bool saveBatchQueue( );
|
||||
void notifyListener ();
|
||||
void notifyListener (bool queueEmptied);
|
||||
|
||||
public:
|
||||
BatchQueue ();
|
||||
|
@@ -179,14 +179,17 @@ void BatchQueuePanel::updateTab (int qsize)
|
||||
}
|
||||
}
|
||||
|
||||
void BatchQueuePanel::queueSizeChanged (int qsize)
|
||||
void BatchQueuePanel::queueSizeChanged (int qsize, bool queueEmptied)
|
||||
{
|
||||
updateTab ( qsize);
|
||||
}
|
||||
|
||||
void BatchQueuePanel::imageProcessingReady (Glib::ustring fname) {
|
||||
if (queueEmptied) {
|
||||
stopBatchProc ();
|
||||
fdir->set_sensitive (true);
|
||||
fformat->set_sensitive (true);
|
||||
|
||||
parent->imageDeveloped (fname);
|
||||
SoundManager::playSoundAsync(options.sndBatchQueueDone);
|
||||
}
|
||||
}
|
||||
|
||||
void BatchQueuePanel::startBatchProc () {
|
||||
@@ -201,11 +204,12 @@ void BatchQueuePanel::startBatchProc () {
|
||||
if (batchQueue->hasJobs()) {
|
||||
fdir->set_sensitive (false);
|
||||
fformat->set_sensitive (false);
|
||||
saveOptions();
|
||||
saveOptions();
|
||||
batchQueue->startProcessing ();
|
||||
}
|
||||
else
|
||||
stopBatchProc ();
|
||||
|
||||
updateTab (batchQueue->getEntries().size());
|
||||
}
|
||||
|
||||
@@ -228,15 +232,6 @@ void BatchQueuePanel::addBatchQueueJobs ( std::vector<BatchQueueEntry*> &entries
|
||||
startBatchProc ();
|
||||
}
|
||||
|
||||
void BatchQueuePanel::queueEmpty () {
|
||||
|
||||
stopBatchProc ();
|
||||
fdir->set_sensitive (true);
|
||||
fformat->set_sensitive (true);
|
||||
|
||||
SoundManager::playSoundAsync(options.sndBatchQueueDone);
|
||||
}
|
||||
|
||||
bool BatchQueuePanel::canStartNext () {
|
||||
|
||||
if (start->get_active ())
|
||||
|
@@ -57,9 +57,7 @@ class BatchQueuePanel : public Gtk::VBox,
|
||||
void addBatchQueueJobs (std::vector<BatchQueueEntry*> &entries , bool head=false);
|
||||
|
||||
// batchqueuelistener interface
|
||||
void queueSizeChanged (int qsize);
|
||||
void imageProcessingReady (Glib::ustring fname);
|
||||
void queueEmpty ();
|
||||
void queueSizeChanged (int qsize, bool queueEmptied);
|
||||
bool canStartNext ();
|
||||
|
||||
void startBatchProc ();
|
||||
|
@@ -970,7 +970,7 @@ int refreshThumbImagesUI (void* data) {
|
||||
}
|
||||
|
||||
void FileBrowser::_thumbRearrangementNeeded () {
|
||||
refreshThumbImages ();
|
||||
refreshThumbImages (); // arrangeFiles is NOT enough
|
||||
}
|
||||
|
||||
void FileBrowser::thumbRearrangementNeeded () {
|
||||
|
@@ -239,7 +239,7 @@ void FileBrowserEntry::_updateImage (rtengine::IImage8* img, double s, rtengine:
|
||||
if (rotated)
|
||||
parent->thumbRearrangementNeeded();
|
||||
else if (redrawRequests==0)
|
||||
parent->redrawNeeded (this);
|
||||
parent->redrawNeeded (this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -641,17 +641,14 @@ void FileCatalog::previewsFinished (int dir_id) {
|
||||
}
|
||||
|
||||
void FileCatalog::setEnabled (bool e) {
|
||||
|
||||
enabled = e;
|
||||
}
|
||||
|
||||
void FileCatalog::redrawAll () {
|
||||
|
||||
fileBrowser->queue_draw ();
|
||||
}
|
||||
|
||||
void FileCatalog::refreshAll () {
|
||||
|
||||
void FileCatalog::refreshThumbImages () {
|
||||
fileBrowser->refreshThumbImages ();
|
||||
}
|
||||
|
||||
|
@@ -177,12 +177,13 @@ class FileCatalog : public Gtk::VBox,
|
||||
// filterpanel interface
|
||||
void exifFilterChanged ();
|
||||
|
||||
Glib::ustring lastSelectedDir () { return selectedDirectory; }
|
||||
Glib::ustring lastSelectedDir () { return selectedDirectory; }
|
||||
void setEnabled (bool e); // if not enabled, it does not open image
|
||||
void enableTabMode(bool enable); // sets progress bar
|
||||
|
||||
// accessors for FileBrowser
|
||||
void redrawAll ();
|
||||
void refreshAll ();
|
||||
void refreshThumbImages ();
|
||||
void refreshHeight ();
|
||||
|
||||
void openRequested (std::vector<Thumbnail*> tbe);
|
||||
|
@@ -217,7 +217,7 @@ bool FilePanel::addBatchQueueJobs ( std::vector<BatchQueueEntry*> &entries ) {
|
||||
void FilePanel::optionsChanged () {
|
||||
|
||||
tpc->optionsChanged ();
|
||||
fileCatalog->refreshAll ();
|
||||
fileCatalog->refreshThumbImages ();
|
||||
}
|
||||
|
||||
bool FilePanel::handleShortcutKey (GdkEventKey* event) {
|
||||
|
@@ -331,11 +331,6 @@ bool RTWindow::keyPressed (GdkEventKey* event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void RTWindow::imageDeveloped (Glib::ustring fname) {
|
||||
|
||||
// fpanel->refreshThumbnail (fname);
|
||||
}
|
||||
|
||||
void RTWindow::addBatchQueueJob (BatchQueueEntry* bqe, bool head) {
|
||||
|
||||
std::vector<BatchQueueEntry*> entries;
|
||||
|
@@ -60,7 +60,6 @@ class RTWindow : public Gtk::Window, public rtengine::ProgressListener{
|
||||
bool on_window_state_event(GdkEventWindowState* event);
|
||||
void on_mainNB_switch_page(GtkNotebookPage* page, guint page_num);
|
||||
|
||||
void imageDeveloped (Glib::ustring fname); // called by the batchqueue when it finishes an image
|
||||
void showPreferences ();
|
||||
void on_realize ();
|
||||
void toggle_fullscreen ();
|
||||
|
@@ -60,7 +60,7 @@ void ThumbBrowserEntryBase::updateBackBuffer () {
|
||||
backBuffer = Gdk::Pixmap::create (w->get_window(), exp_width, exp_height);
|
||||
|
||||
// If thumbnail is hidden by a filter drawing to it will crash
|
||||
int backbuffer_w =0, backbuffer_h = 0;
|
||||
int backbuffer_w=0, backbuffer_h=0;
|
||||
backBuffer->get_size(backbuffer_w, backbuffer_h);
|
||||
// if either with or height is zero then return early
|
||||
if (backbuffer_w * backbuffer_h == 0) return;
|
||||
@@ -338,23 +338,19 @@ void ThumbBrowserEntryBase::drawFrame (Cairo::RefPtr<Cairo::Context> cr, const G
|
||||
|
||||
void ThumbBrowserEntryBase::draw () {
|
||||
|
||||
if (!drawable)
|
||||
if (!drawable || !parent)
|
||||
return;
|
||||
|
||||
Glib::RWLock::ReaderLock l(lockRW);
|
||||
Glib::RWLock::ReaderLock l(lockRW); // No resizes, position moves etc. inbetween
|
||||
|
||||
int bbWidth, bbHeight;
|
||||
if (backBuffer)
|
||||
backBuffer->get_size (bbWidth, bbHeight);
|
||||
|
||||
|
||||
if (!backBuffer || selected!=bbSelected || framed!=bbFramed || preview!=bbPreview
|
||||
|| exp_width!=bbWidth || exp_height!=bbHeight || getIconsOnImageArea ()!=bbIcons)
|
||||
updateBackBuffer ();
|
||||
|
||||
if (!parent)
|
||||
return;
|
||||
|
||||
Gtk::Widget* w = parent->getDrawingArea ();
|
||||
|
||||
Glib::RefPtr<Gdk::GC> gc_ = Gdk::GC::create (w->get_window());
|
||||
|
@@ -53,7 +53,7 @@ protected:
|
||||
int width; // minimal width
|
||||
int height; // minimal height
|
||||
// set by arrangeFiles() of thumbbrowser
|
||||
int exp_width; // arranged width
|
||||
int exp_width; // arranged width (backbuffer dimensions)
|
||||
int exp_height; // arranged height
|
||||
int startx; // x coord. in the widget
|
||||
int starty; // y coord. in the widget
|
||||
@@ -72,6 +72,7 @@ protected:
|
||||
void drawFrame (Cairo::RefPtr<Cairo::Context> cr, const Gdk::Color& bg, const Gdk::Color& fg);
|
||||
void getTextSizes (int& w, int& h);
|
||||
|
||||
// called during updateBackBuffer for custom overlays
|
||||
virtual void customBackBufferUpdate (Cairo::RefPtr<Cairo::Context> c) {}
|
||||
|
||||
public:
|
||||
|
Reference in New Issue
Block a user