From e5b5d86145e82f91ac49a4510f0a440269359cf2 Mon Sep 17 00:00:00 2001 From: Oliver Duis Date: Fri, 18 May 2012 07:43:03 +0200 Subject: [PATCH] Two files missing from last commit --- rtgui/lensprofile.cc | 102 +++++++++++++++++++++++++++++++++++++++++++ rtgui/lensprofile.h | 48 ++++++++++++++++++++ 2 files changed, 150 insertions(+) create mode 100644 rtgui/lensprofile.cc create mode 100644 rtgui/lensprofile.h diff --git a/rtgui/lensprofile.cc b/rtgui/lensprofile.cc new file mode 100644 index 000000000..f93670525 --- /dev/null +++ b/rtgui/lensprofile.cc @@ -0,0 +1,102 @@ +/* +* This file is part of RawTherapee. +* +* Copyright (c) 2011 Oliver Duis +* +* 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 +#include "lensprofile.h" +#include "guiutils.h" +#include "../rtengine/safegtk.h" +#include "../rtengine/lcp.h" +#include +#include "rtimage.h" + +using namespace rtengine; +using namespace rtengine::procparams; + +LensProfilePanel::LensProfilePanel () : Gtk::VBox(), FoldableToolPanel(this) +{ + hbLCPFile = Gtk::manage(new Gtk::HBox()); + + lLCPFileHead = Gtk::manage(new Gtk::Label(M("GENERAL_FILE"))); + hbLCPFile->pack_start(*lLCPFileHead, Gtk::PACK_SHRINK, 4); + + fcbLCPFile = Gtk::manage(new MyFileChooserButton(M("TP_LENSPROFILE_LABEL"), Gtk::FILE_CHOOSER_ACTION_OPEN)); + + Gtk::FileFilter filterLCP; + filterLCP.set_name(M("TP_LENSPROFILE_FILEDLGFILTERLCP")); + filterLCP.add_pattern("*.lcp"); + filterLCP.add_pattern("*.LCP"); + fcbLCPFile->add_filter(filterLCP); + + Glib::ustring defDir=lcpStore->getDefaultCommonDirectory(); + if (!defDir.empty()) { +#ifdef WIN32 + fcbLCPFile->set_show_hidden(true); // ProgramData is hidden on Windows +#endif + fcbLCPFile->set_current_folder(defDir); + } + + hbLCPFile->pack_start(*fcbLCPFile); + + btnReset = Gtk::manage(new Gtk::Button()); + btnReset->set_image (*Gtk::manage(new RTImage ("gtk-cancel.png"))); + hbLCPFile->pack_start(*btnReset, Gtk::PACK_SHRINK, 4); + + pack_start(*hbLCPFile, Gtk::PACK_SHRINK, 4); + + conLCPFile = fcbLCPFile->signal_file_set().connect( sigc::mem_fun(*this, &LensProfilePanel::onLCPFileChanged), true); + btnReset->signal_clicked().connect( sigc::mem_fun(*this, &LensProfilePanel::onLCPFileReset), true); +} + +void LensProfilePanel::read(const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited) +{ + disableListener (); + + if (pp->lensProf.lcpFile.length()>0 && lcpStore->isValidLCPFileName(pp->lensProf.lcpFile)) + fcbLCPFile->set_filename (pp->lensProf.lcpFile); + + lcpFileChanged = false; + + enableListener (); +} + +void LensProfilePanel::write( rtengine::procparams::ProcParams* pp, ParamsEdited* pedited) +{ + if (lcpStore->isValidLCPFileName(fcbLCPFile->get_filename())) + pp->lensProf.lcpFile = fcbLCPFile->get_filename(); + else + pp->lensProf.lcpFile = ""; + + if (pedited) pedited->lensProf.lcpFile = lcpFileChanged; +} + +void LensProfilePanel::onLCPFileChanged() +{ + lcpFileChanged=true; + if (listener) + listener->panelChanged (EvLCPFile, Glib::path_get_basename(fcbLCPFile->get_filename())); +} + +void LensProfilePanel::onLCPFileReset() +{ + lcpFileChanged=true; + + fcbLCPFile->unselect_filename(fcbLCPFile->get_filename()); + + if (listener) + listener->panelChanged (EvLCPFile, M("GENERAL_NONE")); +} diff --git a/rtgui/lensprofile.h b/rtgui/lensprofile.h new file mode 100644 index 000000000..8aedb43be --- /dev/null +++ b/rtgui/lensprofile.h @@ -0,0 +1,48 @@ +/* +* This file is part of RawTherapee. +* +* Copyright (c) 2011 Oliver Duis +* +* 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 . +*/ +#ifndef _LENSPROFILE_H_ +#define _LENSPROFILE_H_ + +#include +#include "toolpanel.h" +#include "guiutils.h" + +class LensProfilePanel : public Gtk::VBox, public FoldableToolPanel { + +protected: + + MyFileChooserButton *fcbLCPFile; + Gtk::HBox *hbLCPFile; + Gtk::Button *btnReset; + Gtk::Label *lLCPFileHead; + bool lcpFileChanged; + sigc::connection conLCPFile; + +public: + + LensProfilePanel (); + + void read (const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited=NULL); + void write (rtengine::procparams::ProcParams* pp, ParamsEdited* pedited=NULL); + + void onLCPFileChanged (); + void onLCPFileReset (); +}; + +#endif