2 * This file is part of RawTherapee.
4 * Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
6 * RawTherapee is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * RawTherapee is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef _PROGRESSDIALOG_
20 #define _PROGRESSDIALOG_
22 #include <sigc++/sigc++.h>
26 class PLDBridge
: public rtengine::ProgressListener
{
30 Gtk::ProgressBar
* progBar
;
33 PLDBridge (Gtk::Dialog
* d
, Gtk::Label
* l
, Gtk::ProgressBar
* pb
)
34 : dialog(d
), label(l
), progBar(pb
) {}
36 // progresslistener interface
37 void setProgress (double p
) {
39 progBar
->set_fraction (p
);
42 void setProgressStr (Glib::ustring str
) {
44 Glib::ustring progrstr
;
45 if (str
=="Decoding...")
46 progrstr
= M("PROGRESSBAR_DECODING");
47 else if (str
=="Ready.")
48 progrstr
= M("PROGRESSBAR_READY");
49 else if (str
=="Demosaicing...")
50 progrstr
= M("PROGRESSBAR_DEMOSAICING");
51 else if (str
=="Loading...")
52 progrstr
= M("PROGRESSBAR_LOADING");
53 else if (str
=="Loading PNG file...")
54 progrstr
= M("PROGRESSBAR_LOADPNG");
55 else if (str
=="Loading JPEG file...")
56 progrstr
= M("PROGRESSBAR_LOADJPEG");
57 else if (str
=="Loading TIFF file...")
58 progrstr
= M("PROGRESSBAR_LOADTIFF");
59 else if (str
=="Saving PNG file...")
60 progrstr
= M("PROGRESSBAR_SAVEPNG");
61 else if (str
=="Saving JPEG file...")
62 progrstr
= M("PROGRESSBAR_SAVEJPEG");
63 else if (str
=="Saving TIFF file...")
64 progrstr
= M("PROGRESSBAR_SAVETIFF");
65 else if (str
=="Processing...")
66 progrstr
= M("PROGRESSBAR_PROCESSING");
70 label
->set_text (progrstr
);
73 void setProgressState (int state
) {}
74 void error (Glib::ustring descr
) {}
78 class ProgressDialog
: public Gtk::Dialog
{
80 sigc::signal0
<T
> operation
;
83 Gtk::ProgressBar prProgBar
;
88 void workingThread () {
89 *retval
= operation
.emit ();
97 ProgressDialog (Glib::ustring label
) : Gtk::Dialog (label
, true) {
98 pldBridge
= new PLDBridge (this, &prLabel
, &prProgBar
);
99 get_vbox()->pack_start (prLabel
, Gtk::PACK_SHRINK
, 4);
100 get_vbox()->pack_start (prProgBar
, Gtk::PACK_SHRINK
, 4);
101 set_size_request (300, -1);
102 show_all_children ();
109 rtengine::ProgressListener
* getProgressListener () { return pldBridge
; }
111 void setFunc (const sigc::slot0
<T
>& slot
, T
* rv
) {
113 operation
.connect (slot
);
117 Glib::Thread
*thread
= Glib::Thread::create(sigc::mem_fun(*this, &ProgressDialog
<T
>::workingThread
), 0, true, true, Glib::THREAD_PRIORITY_NORMAL
);
120 gdk_threads_leave ();
122 gdk_threads_enter ();