diff --git a/rtgui/editorpanel.cc b/rtgui/editorpanel.cc index c94ac2be5..a3915b297 100644 --- a/rtgui/editorpanel.cc +++ b/rtgui/editorpanel.cc @@ -18,7 +18,7 @@ */ #include #include -#include +#include #include #include #include @@ -514,11 +514,9 @@ bool EditorPanel::idle_saveImage (ProgressConnector *pc, Gl if( img ) saveImage( img, fname, sf, findNewNameIfNeeded); else{ - gdk_threads_enter (); Glib::ustring msg_ = Glib::ustring("") + fname + ": Error during image processing\n"; Gtk::MessageDialog msgd (*parent, msg_, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); msgd.run (); - gdk_threads_leave (); saveimgas->set_sensitive(true); sendtogimp->set_sensitive(true); @@ -575,11 +573,9 @@ bool EditorPanel::idle_imageSaved(ProgressConnector *pc,rtengine::IImage16* pparams.save (removeExtension (fname) + ".out.pp2"); } }else{ - gdk_threads_enter (); Glib::ustring msg_ = Glib::ustring("") + fname + ": Error during image saving\n"; Gtk::MessageDialog msgd (*parent, msg_, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); msgd.run (); - gdk_threads_leave (); } saveimgas->set_sensitive(true); sendtogimp->set_sensitive(true); @@ -687,11 +683,9 @@ bool EditorPanel::idle_sendToGimp( ProgressConnector *pc){ ld->startFunc (sigc::bind(sigc::mem_fun(img, &rtengine::IImage16::saveAsTIFF), fileName, sf.tiffBits, sf.tiffUncompressed), sigc::bind(sigc::mem_fun(*this,&EditorPanel::idle_sentToGimp), ld, img, fileName)); }else{ - gdk_threads_enter(); Glib::ustring msg_ = Glib::ustring(" Error during image processing\n"); Gtk::MessageDialog msgd (*parent, msg_, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); msgd.run (); - gdk_threads_leave (); saveimgas->set_sensitive(true); sendtogimp->set_sensitive(true); } @@ -752,13 +746,11 @@ bool EditorPanel::idle_sentToGimp(ProgressConnector *pc,rtengine::IImage16* } if (!success) { - gdk_threads_enter (); Gtk::MessageDialog* msgd = new Gtk::MessageDialog (*parent, M("MAIN_MSG_CANNOTSTARTEDITOR"), false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); msgd->set_secondary_text (M("MAIN_MSG_CANNOTSTARTEDITOR_SECONDARY")); msgd->set_title (M("MAIN_BUTTON_SENDTOEDITOR")); msgd->run (); delete msgd; - gdk_threads_leave (); } } diff --git a/rtgui/editorpanel.h b/rtgui/editorpanel.h index 2e2a1e992..47079fa4f 100644 --- a/rtgui/editorpanel.h +++ b/rtgui/editorpanel.h @@ -31,7 +31,7 @@ #include #include #include -#include +#include class EditorPanel; struct EditorPanelIdleHelper { diff --git a/rtgui/filepanel.cc b/rtgui/filepanel.cc index 47ba5d2f8..ecbb5bb11 100644 --- a/rtgui/filepanel.cc +++ b/rtgui/filepanel.cc @@ -151,11 +151,9 @@ bool FilePanel::imageLoaded( Thumbnail* thm, ProgressConnectoraddEditorPanel (epanel,Glib::path_get_basename (thm->getFileName())); epanel->open(thm, pc->returnValue() ); }else { - gdk_threads_enter (); Glib::ustring msg_ = Glib::ustring("") + M("MAIN_MSG_CANNOTLOAD") + " \"" + thm->getFileName() + "\" .\n"; Gtk::MessageDialog msgd (msg_, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); msgd.run (); - gdk_threads_leave (); } delete pc; diff --git a/rtgui/filepanel.h b/rtgui/filepanel.h index 86fa47d17..3e0b30e93 100644 --- a/rtgui/filepanel.h +++ b/rtgui/filepanel.h @@ -29,7 +29,7 @@ #include #include #include -#include +#include class RTWindow; class FilePanel : public Gtk::HPaned, diff --git a/rtgui/progressdialog.h b/rtgui/progressconnector.h similarity index 85% rename from rtgui/progressdialog.h rename to rtgui/progressconnector.h index e43a7137d..f69cba4b6 100644 --- a/rtgui/progressdialog.h +++ b/rtgui/progressconnector.h @@ -16,8 +16,8 @@ * You should have received a copy of the GNU General Public License * along with RawTherapee. If not, see . */ -#ifndef _PROGRESSDIALOG_ -#define _PROGRESSDIALOG_ +#ifndef _PROGRESSCONNECTOR_ +#define _PROGRESSCONNECTOR_ #include #include @@ -76,17 +76,23 @@ class PLDBridge : public rtengine::ProgressListener { template class ProgressConnector { - sigc::slot0 slotStart; - sigc::slot0 slotEnd; + sigc::signal0 opStart; + sigc::signal0 opEnd; T retval; Glib::Thread *workThread; + + static int emitEndSignal (void* data) { + gdk_threads_enter (); + sigc::signal0* opEnd = (sigc::signal0*) data; + int r = opEnd->emit (); + delete opEnd; + gdk_threads_leave (); + return r; + } void workingThread () { - sigc::signal0 op; - sigc::connection conn= op.connect(slotStart); - retval = op.emit (); - conn.disconnect(); - Glib::signal_idle().connect(slotEnd); + retval = opStart.emit (); + g_idle_add (ProgressConnector::emitEndSignal, new sigc::signal0 (opEnd)); workThread = 0; } @@ -96,8 +102,8 @@ class ProgressConnector { void startFunc (const sigc::slot0& startHandler, const sigc::slot0& endHandler ) { if( !workThread ){ - slotStart = startHandler; - slotEnd = endHandler; + opStart.connect (startHandler); + opEnd.connect (endHandler); workThread = Glib::Thread::create(sigc::mem_fun(*this, &ProgressConnector::workingThread), 0, true, true, Glib::THREAD_PRIORITY_NORMAL); } } diff --git a/rtgui/progressdialog.cc b/rtgui/progressdialog.cc deleted file mode 100644 index 871e00bcb..000000000 --- a/rtgui/progressdialog.cc +++ /dev/null @@ -1,56 +0,0 @@ -/* - * This file is part of RawTherapee. - * - * Copyright (c) 2004-2010 Gabor Horvath - * - * 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 . - */ -#include - -template -ProgressDialog::ProgressDialog (const sigc::slot0& slot) { - - set_deletable (false); - operation.connect (slot); -} - -template -void ProgressDialog::start () { - - T ret = operation.emit (); -} - -template -void ProgressDialog::finish () { - - gtk_threads_enter (); - hide (); - gtk_threads_leave (); -} - -template -void ProgressDialog::setProgress (double p) { -} - -template -void ProgressDialog::setProgressStr (Glib::ustring str) { -} - -template -void ProgressDialog::setProgressState (int state) { -} - -template -void ProgressDialog::error (Glib::ustring descr) { -} diff --git a/rtgui/rtwindow.h b/rtgui/rtwindow.h index fec9fa462..6ec0b1114 100644 --- a/rtgui/rtwindow.h +++ b/rtgui/rtwindow.h @@ -24,7 +24,7 @@ #include #include #include -#include +#include class RTWindow : public Gtk::Window, public rtengine::ProgressListener{