Added better handling of failures loading icons, as Cairo generated exception were crashing app under windows. Minor fix to handling missing processing params to not alter the global defaults.

This commit is contained in:
sashavasko
2010-05-13 16:42:43 -05:00
commit 65ea3aff3e
572 changed files with 115958 additions and 0 deletions

109
rtgui/progressdialog.h Normal file
View File

@@ -0,0 +1,109 @@
/*
* This file is part of RawTherapee.
*
* Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
*
* RawTherapee is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* RawTherapee is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _PROGRESSDIALOG_
#define _PROGRESSDIALOG_
#include <sigc++/sigc++.h>
#include <gtkmm.h>
#include <rtengine.h>
#undef THREAD_PRIORITY_NORMAL
class PLDBridge : public rtengine::ProgressListener {
Gtk::Label* label;
Gtk::ProgressBar* progBar;
public:
PLDBridge ( Gtk::Label* l, Gtk::ProgressBar* pb)
: label(l), progBar(pb) {}
// ProgressListener interface
void setProgress (double p) {
gdk_threads_enter ();
progBar->set_fraction (p);
gdk_threads_leave ();
}
void setProgressStr (Glib::ustring str) {
gdk_threads_enter ();
Glib::ustring progrstr;
if (str=="Decoding...")
progrstr = M("PROGRESSBAR_DECODING");
else if (str=="Ready.")
progrstr = M("PROGRESSBAR_READY");
else if (str=="Demosaicing...")
progrstr = M("PROGRESSBAR_DEMOSAICING");
else if (str=="Loading...")
progrstr = M("PROGRESSBAR_LOADING");
else if (str=="Loading PNG file...")
progrstr = M("PROGRESSBAR_LOADPNG");
else if (str=="Loading JPEG file...")
progrstr = M("PROGRESSBAR_LOADJPEG");
else if (str=="Loading TIFF file...")
progrstr = M("PROGRESSBAR_LOADTIFF");
else if (str=="Saving PNG file...")
progrstr = M("PROGRESSBAR_SAVEPNG");
else if (str=="Saving JPEG file...")
progrstr = M("PROGRESSBAR_SAVEJPEG");
else if (str=="Saving TIFF file...")
progrstr = M("PROGRESSBAR_SAVETIFF");
else if (str=="Processing...")
progrstr = M("PROGRESSBAR_PROCESSING");
else
progrstr = str;
label->set_text (progrstr);
gdk_threads_leave ();
}
};
template<class T>
class ProgressConnector {
sigc::slot0<T> slotStart;
sigc::slot0<bool> slotEnd;
T retval;
Glib::Thread *workThread;
void workingThread () {
sigc::signal0<T> op;
sigc::connection conn= op.connect(slotStart);
retval = op.emit ();
conn.disconnect();
Glib::signal_idle().connect(slotEnd);
workThread = 0;
}
public:
ProgressConnector ():workThread( 0 ) { }
void startFunc (const sigc::slot0<T>& startHandler, const sigc::slot0<bool>& endHandler ) {
if( !workThread ){
slotStart = startHandler;
slotEnd = endHandler;
workThread = Glib::Thread::create(sigc::mem_fun(*this, &ProgressConnector<T>::workingThread), 0, true, true, Glib::THREAD_PRIORITY_NORMAL);
}
}
T returnValue(){
return retval;
}
};
#endif