Solving issue 872: "RT file-open/save windows should remember last used dir", on behalf of Johannes Wienke
This commit is contained in:
@@ -29,7 +29,7 @@
|
||||
|
||||
extern Glib::ustring argv0;
|
||||
|
||||
CurveEditorGroup::CurveEditorGroup (Glib::ustring groupLabel) : cl(NULL), cp(NULL) {
|
||||
CurveEditorGroup::CurveEditorGroup (Glib::ustring& curveDir, Glib::ustring groupLabel) : curveDir(curveDir), cl(NULL), cp(NULL) {
|
||||
curveEditors.clear();
|
||||
displayedCurve = 0;
|
||||
numberOfPackedCurve = 0;
|
||||
@@ -64,12 +64,12 @@ CurveEditor* CurveEditorGroup::addCurve(CurveType cType, Glib::ustring curveLabe
|
||||
switch (cType) {
|
||||
case (CT_Diagonal):
|
||||
if (!diagonalSubGroup) {
|
||||
diagonalSubGroup = new DiagonalCurveEditorSubGroup(this);
|
||||
diagonalSubGroup = new DiagonalCurveEditorSubGroup(this, curveDir);
|
||||
}
|
||||
return (static_cast<CurveEditor*>(diagonalSubGroup->addCurve(curveLabel)));
|
||||
case (CT_Flat):
|
||||
if (!flatSubGroup) {
|
||||
flatSubGroup = new FlatCurveEditorSubGroup(this);
|
||||
flatSubGroup = new FlatCurveEditorSubGroup(this, curveDir);
|
||||
}
|
||||
return (static_cast<CurveEditor*>(flatSubGroup->addCurve(curveLabel, periodic)));
|
||||
default:
|
||||
@@ -294,16 +294,17 @@ void CurveEditorGroup::setUnChanged (bool uc, CurveEditor* ce) {
|
||||
}
|
||||
}
|
||||
|
||||
CurveEditorSubGroup::CurveEditorSubGroup(Glib::ustring& curveDir) :
|
||||
curveDir(curveDir) {
|
||||
}
|
||||
|
||||
Glib::ustring CurveEditorSubGroup::outputFile () {
|
||||
|
||||
Gtk::FileChooserDialog dialog(M("CURVEEDITOR_SAVEDLGLABEL"), Gtk::FILE_CHOOSER_ACTION_SAVE);
|
||||
// if (options.multiUser)
|
||||
// dialog.set_current_folder (Options::rtdir + "/" + options.profilePath);
|
||||
// else
|
||||
// dialog.set_current_folder (argv0 + "/" + options.profilePath);
|
||||
FileChooserLastFolderPersister persister(&dialog, curveDir);
|
||||
|
||||
dialog.add_button(Gtk::StockID("gtk-cancel"), Gtk::RESPONSE_CANCEL);
|
||||
dialog.add_button(Gtk::StockID("gtk-save"), Gtk::RESPONSE_OK);
|
||||
dialog.add_button(Gtk::StockID("gtk-save"), Gtk::RESPONSE_APPLY);
|
||||
|
||||
Gtk::FileFilter filter_pp;
|
||||
filter_pp.set_name(M("CURVEEDITOR_FILEDLGFILTERCURVE"));
|
||||
@@ -323,7 +324,7 @@ Glib::ustring CurveEditorSubGroup::outputFile () {
|
||||
|
||||
fname = dialog.get_filename();
|
||||
|
||||
if (result==Gtk::RESPONSE_OK) {
|
||||
if (result==Gtk::RESPONSE_APPLY) {
|
||||
|
||||
if (getExtension (fname)!="rtc")
|
||||
fname = fname + ".rtc";
|
||||
@@ -350,9 +351,10 @@ Glib::ustring CurveEditorSubGroup::outputFile () {
|
||||
Glib::ustring CurveEditorSubGroup::inputFile () {
|
||||
|
||||
Gtk::FileChooserDialog dialog(M("CURVEEDITOR_LOADDLGLABEL"), Gtk::FILE_CHOOSER_ACTION_OPEN);
|
||||
FileChooserLastFolderPersister persister(&dialog, curveDir);
|
||||
|
||||
dialog.add_button(Gtk::StockID("gtk-cancel"), Gtk::RESPONSE_CANCEL);
|
||||
dialog.add_button(Gtk::StockID("gtk-open"), Gtk::RESPONSE_OK);
|
||||
dialog.add_button(Gtk::StockID("gtk-apply"), Gtk::RESPONSE_APPLY);
|
||||
|
||||
Gtk::FileFilter filter_pp;
|
||||
filter_pp.set_name(M("CURVEEDITOR_FILEDLGFILTERCURVE"));
|
||||
@@ -367,7 +369,7 @@ Glib::ustring CurveEditorSubGroup::inputFile () {
|
||||
int result = dialog.run();
|
||||
|
||||
Glib::ustring fname;
|
||||
if (result==Gtk::RESPONSE_OK) {
|
||||
if (result==Gtk::RESPONSE_APPLY) {
|
||||
fname = dialog.get_filename();
|
||||
if (Glib::file_test (fname, Glib::FILE_TEST_EXISTS))
|
||||
return fname;
|
||||
|
@@ -46,6 +46,9 @@ class CurveEditorGroup : public Gtk::VBox, public CurveListener {
|
||||
friend class DiagonalCurveEditorSubGroup;
|
||||
friend class FlatCurveEditorSubGroup;
|
||||
|
||||
private:
|
||||
Glib::ustring& curveDir;
|
||||
|
||||
protected:
|
||||
Gtk::Label* curveGroupLabel;
|
||||
Gtk::Button* curve_reset;
|
||||
@@ -60,7 +63,12 @@ protected:
|
||||
unsigned int numberOfPackedCurve;
|
||||
|
||||
public:
|
||||
CurveEditorGroup(Glib::ustring groupLabel = "");
|
||||
/**
|
||||
* @param curveDir The folder used by load and save dialogs for the curve.
|
||||
* This variable will be updated with actions in the
|
||||
* dialogs.
|
||||
*/
|
||||
CurveEditorGroup(Glib::ustring& curveDir, Glib::ustring groupLabel = "");
|
||||
~CurveEditorGroup();
|
||||
void newLine();
|
||||
void curveListComplete();
|
||||
@@ -88,6 +96,9 @@ class CurveEditorSubGroup {
|
||||
|
||||
friend class CurveEditorGroup;
|
||||
|
||||
private:
|
||||
Glib::ustring& curveDir;
|
||||
|
||||
protected:
|
||||
int valLinear;
|
||||
int valUnchanged;
|
||||
@@ -100,6 +111,14 @@ public:
|
||||
virtual void setColorProvider (ColorProvider* p) = 0;
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* @param curveDir The folder used by load and save dialogs for the curve.
|
||||
* This variable will be updated with actions in the
|
||||
* dialogs.
|
||||
*/
|
||||
CurveEditorSubGroup(Glib::ustring& curveDir);
|
||||
|
||||
Glib::ustring outputFile ();
|
||||
Glib::ustring inputFile ();
|
||||
|
||||
|
@@ -30,6 +30,7 @@ DarkFrame::DarkFrame () : Gtk::VBox(), FoldableToolPanel(this)
|
||||
{
|
||||
hbdf = Gtk::manage(new Gtk::HBox());
|
||||
darkFrameFile = Gtk::manage(new MyFileChooserButton(M("TP_DARKFRAME_LABEL"), Gtk::FILE_CHOOSER_ACTION_OPEN));
|
||||
darkFrameFilePersister.reset(new FileChooserLastFolderPersister(darkFrameFile, options.lastDarkframeDir));
|
||||
dfLabel = Gtk::manage(new Gtk::Label(M("GENERAL_FILE")));
|
||||
btnReset = Gtk::manage(new Gtk::Button());
|
||||
btnReset->set_image (*Gtk::manage(new RTImage ("gtk-cancel.png")));
|
||||
@@ -59,8 +60,6 @@ void DarkFrame::read(const rtengine::procparams::ProcParams* pp, const ParamsEdi
|
||||
}
|
||||
if (safe_file_test (pp->raw.dark_frame, Glib::FILE_TEST_EXISTS))
|
||||
darkFrameFile->set_filename (pp->raw.dark_frame);
|
||||
else if( !options.rtSettings.darkFramesPath.empty() )
|
||||
darkFrameFile->set_current_folder( options.rtSettings.darkFramesPath );
|
||||
hbdf->set_sensitive( !pp->raw.df_autoselect );
|
||||
|
||||
lastDFauto = pp->raw.df_autoselect;
|
||||
@@ -139,8 +138,8 @@ void DarkFrame::darkFrameReset()
|
||||
//darkFrameFile->set_current_name("");
|
||||
darkFrameFile->set_filename ("");
|
||||
|
||||
if( !options.rtSettings.darkFramesPath.empty() )
|
||||
darkFrameFile->set_current_folder( options.rtSettings.darkFramesPath );
|
||||
if (!options.lastDarkframeDir.empty())
|
||||
darkFrameFile->set_current_folder(options.lastDarkframeDir);
|
||||
|
||||
dfInfo->set_text("");
|
||||
if (listener)
|
||||
|
@@ -19,6 +19,7 @@
|
||||
#ifndef _DARKFRAME_H_
|
||||
#define _DARKFRAME_H_
|
||||
|
||||
#include <auto_ptr.h>
|
||||
#include <gtkmm.h>
|
||||
#include "toolpanel.h"
|
||||
#include "../rtengine/rawimage.h"
|
||||
@@ -35,6 +36,7 @@ class DarkFrame : public Gtk::VBox, public FoldableToolPanel {
|
||||
protected:
|
||||
|
||||
MyFileChooserButton *darkFrameFile;
|
||||
std::auto_ptr<FileChooserLastFolderPersister> darkFrameFilePersister;
|
||||
Gtk::HBox *hbdf;
|
||||
Gtk::Button *btnReset;
|
||||
Gtk::Label *dfLabel;
|
||||
|
@@ -31,7 +31,7 @@
|
||||
#include "curveeditor.h"
|
||||
#include "diagonalcurveeditorsubgroup.h"
|
||||
|
||||
DiagonalCurveEditorSubGroup::DiagonalCurveEditorSubGroup (CurveEditorGroup* prt) {
|
||||
DiagonalCurveEditorSubGroup::DiagonalCurveEditorSubGroup (CurveEditorGroup* prt, Glib::ustring& curveDir) : CurveEditorSubGroup(curveDir) {
|
||||
|
||||
valLinear = (int)DCT_Linear;
|
||||
valUnchanged = (int)DCT_Unchanged;
|
||||
|
@@ -59,7 +59,7 @@ protected:
|
||||
int activeParamControl;
|
||||
|
||||
public:
|
||||
DiagonalCurveEditorSubGroup(CurveEditorGroup* prt);
|
||||
DiagonalCurveEditorSubGroup(CurveEditorGroup* prt, Glib::ustring& curveDir);
|
||||
virtual ~DiagonalCurveEditorSubGroup();
|
||||
|
||||
DiagonalCurveEditor* addCurve(Glib::ustring curveLabel = "");
|
||||
|
@@ -598,11 +598,10 @@ void FileBrowser::menuItemActivated (Gtk::MenuItem* m) {
|
||||
if( !mselected.empty() ){
|
||||
rtengine::procparams::ProcParams pp=mselected[0]->thumbnail->getProcParams();
|
||||
Gtk::FileChooserDialog fc("Dark Frame",Gtk::FILE_CHOOSER_ACTION_OPEN );
|
||||
FileChooserLastFolderPersister persister(&fc, options.lastDarkframeDir);
|
||||
fc.add_button( Gtk::StockID("gtk-cancel"), Gtk::RESPONSE_CANCEL);
|
||||
fc.add_button( Gtk::StockID("gtk-apply"), Gtk::RESPONSE_APPLY);
|
||||
if( pp.raw.dark_frame.empty())
|
||||
fc.set_current_folder( options.rtSettings.darkFramesPath );
|
||||
else
|
||||
if(!pp.raw.dark_frame.empty())
|
||||
fc.set_filename( pp.raw.dark_frame );
|
||||
if( fc.run() == Gtk::RESPONSE_APPLY ){
|
||||
for (size_t i=0; i<mselected.size(); i++){
|
||||
@@ -638,11 +637,10 @@ void FileBrowser::menuItemActivated (Gtk::MenuItem* m) {
|
||||
if( !mselected.empty() ){
|
||||
rtengine::procparams::ProcParams pp=mselected[0]->thumbnail->getProcParams();
|
||||
Gtk::FileChooserDialog fc("Flat Field",Gtk::FILE_CHOOSER_ACTION_OPEN );
|
||||
FileChooserLastFolderPersister persister(&fc, options.lastFlatfieldDir);
|
||||
fc.add_button( Gtk::StockID("gtk-cancel"), Gtk::RESPONSE_CANCEL);
|
||||
fc.add_button( Gtk::StockID("gtk-apply"), Gtk::RESPONSE_APPLY);
|
||||
if( pp.raw.ff_file.empty())
|
||||
fc.set_current_folder( options.rtSettings.flatFieldsPath );
|
||||
else
|
||||
if(!pp.raw.ff_file.empty())
|
||||
fc.set_filename( pp.raw.ff_file );
|
||||
if( fc.run() == Gtk::RESPONSE_APPLY ){
|
||||
for (size_t i=0; i<mselected.size(); i++){
|
||||
|
@@ -30,7 +30,7 @@
|
||||
#include "curveeditor.h"
|
||||
#include "flatcurveeditorsubgroup.h"
|
||||
|
||||
FlatCurveEditorSubGroup::FlatCurveEditorSubGroup (CurveEditorGroup* prt) {
|
||||
FlatCurveEditorSubGroup::FlatCurveEditorSubGroup (CurveEditorGroup* prt, Glib::ustring& curveDir) : CurveEditorSubGroup(curveDir) {
|
||||
|
||||
valLinear = (int)FCT_Linear;
|
||||
valUnchanged = (int)FCT_Unchanged;
|
||||
|
@@ -37,7 +37,7 @@ protected:
|
||||
Gtk::Button* loadCPoints;
|
||||
|
||||
public:
|
||||
FlatCurveEditorSubGroup(CurveEditorGroup* prt);
|
||||
FlatCurveEditorSubGroup(CurveEditorGroup* prt, Glib::ustring& curveDir);
|
||||
virtual ~FlatCurveEditorSubGroup();
|
||||
|
||||
FlatCurveEditor* addCurve(Glib::ustring curveLabel = "", bool periodic = true);
|
||||
|
@@ -30,6 +30,7 @@ FlatField::FlatField () : Gtk::VBox(), FoldableToolPanel(this)
|
||||
{
|
||||
hbff = Gtk::manage(new Gtk::HBox());
|
||||
flatFieldFile = Gtk::manage(new MyFileChooserButton(M("TP_FLATFIELD_LABEL"), Gtk::FILE_CHOOSER_ACTION_OPEN));
|
||||
flatFieldFilePersister.reset(new FileChooserLastFolderPersister(flatFieldFile, options.lastFlatfieldDir));
|
||||
ffLabel = Gtk::manage(new Gtk::Label(M("GENERAL_FILE")));
|
||||
flatFieldFileReset = Gtk::manage(new Gtk::Button());
|
||||
flatFieldFileReset->set_image (*Gtk::manage(new RTImage ("gtk-cancel.png")));
|
||||
@@ -80,8 +81,6 @@ void FlatField::read(const rtengine::procparams::ProcParams* pp, const ParamsEdi
|
||||
}
|
||||
if (safe_file_test (pp->raw.ff_file, Glib::FILE_TEST_EXISTS))
|
||||
flatFieldFile->set_filename (pp->raw.ff_file);
|
||||
else if( !options.rtSettings.flatFieldsPath.empty() )
|
||||
flatFieldFile->set_current_folder( options.rtSettings.flatFieldsPath );
|
||||
hbff->set_sensitive( !pp->raw.ff_AutoSelect );
|
||||
|
||||
lastFFAutoSelect = pp->raw.ff_AutoSelect;
|
||||
@@ -176,8 +175,8 @@ void FlatField::flatFieldFile_Reset()
|
||||
//flatFieldFile->set_current_name("");
|
||||
flatFieldFile->set_filename ("");
|
||||
|
||||
if( !options.rtSettings.flatFieldsPath.empty() )
|
||||
flatFieldFile->set_current_folder( options.rtSettings.flatFieldsPath );
|
||||
if (!options.lastFlatfieldDir.empty())
|
||||
flatFieldFile->set_current_folder(options.lastFlatfieldDir);
|
||||
|
||||
ffInfo->set_text("");
|
||||
if (listener)
|
||||
|
@@ -19,6 +19,7 @@
|
||||
#ifndef _FLATFIELD_H_
|
||||
#define _FLATFIELD_H_
|
||||
|
||||
#include <auto_ptr.h>
|
||||
#include <gtkmm.h>
|
||||
#include "adjuster.h"
|
||||
#include "toolpanel.h"
|
||||
@@ -36,6 +37,7 @@ class FlatField : public Gtk::VBox, public AdjusterListener, public FoldableTool
|
||||
protected:
|
||||
|
||||
MyFileChooserButton *flatFieldFile;
|
||||
std::auto_ptr<FileChooserLastFolderPersister> flatFieldFilePersister;
|
||||
Gtk::Label *ffLabel;
|
||||
Gtk::Label *ffInfo;
|
||||
Gtk::Button *flatFieldFileReset;
|
||||
|
@@ -22,6 +22,8 @@
|
||||
#include "../rtengine/utils.h"
|
||||
#include "rtimage.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
bool removeIfThere (Gtk::Container* cont, Gtk::Widget* w, bool increference) {
|
||||
@@ -402,6 +404,33 @@ bool MyFileChooserButton::on_scroll_event (GdkEventScroll* event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FileChooserLastFolderPersister::FileChooserLastFolderPersister(
|
||||
Gtk::FileChooser* chooser, Glib::ustring& folderVariable) :
|
||||
chooser(chooser), folderVariable(folderVariable) {
|
||||
assert(chooser != NULL);
|
||||
|
||||
selectionChangedConnetion = chooser->signal_selection_changed().connect(
|
||||
sigc::mem_fun(*this,
|
||||
&FileChooserLastFolderPersister::selectionChanged));
|
||||
|
||||
if (!folderVariable.empty()) {
|
||||
chooser->set_current_folder(folderVariable);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
FileChooserLastFolderPersister::~FileChooserLastFolderPersister() {
|
||||
|
||||
}
|
||||
|
||||
void FileChooserLastFolderPersister::selectionChanged() {
|
||||
|
||||
if (!chooser->get_current_folder().empty()) {
|
||||
folderVariable = chooser->get_current_folder();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TextOrIcon::TextOrIcon (Glib::ustring fname, Glib::ustring labelTx, Glib::ustring tooltipTx, TOITypes type) {
|
||||
|
||||
imgIcon = 0;
|
||||
|
@@ -138,6 +138,40 @@ public:
|
||||
MyFileChooserButton (const Glib::ustring& title, Gtk::FileChooserAction action=Gtk::FILE_CHOOSER_ACTION_OPEN);
|
||||
};
|
||||
|
||||
/**
|
||||
* A class which maintains the last folder for a FileChooserDialog or Button by
|
||||
* caching it in a a variable (which can be persisted externally).
|
||||
* Each time the user selects a file or folder, the provided variable is updated
|
||||
* with the associated folder. The path found in the variable is set in the
|
||||
* dialog instance at constructions time of this object.
|
||||
*/
|
||||
class FileChooserLastFolderPersister: public Glib::Object {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Installs this persister on the provided GtkFileChooser instance and
|
||||
* applies the current folder found in @p folderVariable for the dialog.
|
||||
*
|
||||
* @param chooser file chooser to maintain
|
||||
* @param folderVariable variable storage to use for this dialog
|
||||
*/
|
||||
FileChooserLastFolderPersister(Gtk::FileChooser* chooser, Glib::ustring& folderVariable);
|
||||
|
||||
virtual ~FileChooserLastFolderPersister();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* Signal handler for the GtkFileChooser selection action.
|
||||
*/
|
||||
void selectionChanged();
|
||||
|
||||
Gtk::FileChooser* chooser;
|
||||
Glib::ustring& folderVariable;
|
||||
sigc::connection selectionChangedConnetion;
|
||||
|
||||
};
|
||||
|
||||
enum TOITypes {
|
||||
TOI_TEXT,
|
||||
TOI_ICON
|
||||
|
@@ -27,7 +27,7 @@ using namespace rtengine::procparams;
|
||||
|
||||
HSVEqualizer::HSVEqualizer () : Gtk::VBox(), FoldableToolPanel(this) {
|
||||
|
||||
curveEditorG = new CurveEditorGroup (M("TP_HSVEQUALIZER_CHANNEL"));
|
||||
curveEditorG = new CurveEditorGroup (options.lastHsvCurvesDir, M("TP_HSVEQUALIZER_CHANNEL"));
|
||||
curveEditorG->setCurveListener (this);
|
||||
curveEditorG->setColorProvider (this);
|
||||
|
||||
|
@@ -30,14 +30,13 @@ using namespace rtengine::procparams;
|
||||
|
||||
extern Options options;
|
||||
|
||||
Glib::ustring ICMPanel::lastICCWorkDir;
|
||||
|
||||
ICMPanel::ICMPanel () : Gtk::VBox(), FoldableToolPanel(this), iunchanged(NULL), icmplistener(NULL) {
|
||||
|
||||
// set_border_width (4);
|
||||
|
||||
ipDialog = Gtk::manage (new MyFileChooserButton (M("TP_ICM_INPUTDLGLABEL"), Gtk::FILE_CHOOSER_ACTION_OPEN));
|
||||
ipDialog->set_tooltip_text (M("TP_ICM_INPUTCUSTOM_TOOLTIP"));
|
||||
ipDialogPersister.reset(new FileChooserLastFolderPersister(ipDialog, options.lastIccDir));
|
||||
|
||||
Gtk::Label* ilab = Gtk::manage (new Gtk::Label ());
|
||||
ilab->set_alignment (0.0, 0.5);
|
||||
@@ -188,8 +187,6 @@ ICMPanel::ICMPanel () : Gtk::VBox(), FoldableToolPanel(this), iunchanged(NULL),
|
||||
ipDialog->add_filter (filter_icc);
|
||||
ipDialog->add_filter (filter_any);
|
||||
|
||||
ipDialog->set_current_folder ( lastICCWorkDir.empty() ? options.rtSettings.iccDirectory : lastICCWorkDir);
|
||||
|
||||
oldip = "";
|
||||
|
||||
wnames->signal_changed().connect( sigc::mem_fun(*this, &ICMPanel::wpChanged) );
|
||||
@@ -309,9 +306,6 @@ void ICMPanel::write (ProcParams* pp, ParamsEdited* pedited) {
|
||||
pp->icm.input = ""; // just a directory
|
||||
|
||||
Glib::ustring p=Glib::path_get_dirname(ipDialog->get_filename ());
|
||||
if (p!=options.rtSettings.iccDirectory) {
|
||||
lastICCWorkDir=p;
|
||||
}
|
||||
}
|
||||
|
||||
pp->icm.working = wnames->get_active_text ();
|
||||
@@ -476,12 +470,12 @@ void ICMPanel::setRawMeta (bool raw, const rtengine::ImageData* pMeta) {
|
||||
enableListener ();
|
||||
}
|
||||
|
||||
void ICMPanel::ipSelectionChanged () {
|
||||
void ICMPanel::ipSelectionChanged() {
|
||||
|
||||
if (ipDialog->get_filename () == "")
|
||||
return;
|
||||
if (ipDialog->get_filename() == "")
|
||||
return;
|
||||
|
||||
ipChanged ();
|
||||
ipChanged();
|
||||
}
|
||||
|
||||
void ICMPanel::saveReferencePressed () {
|
||||
@@ -489,6 +483,7 @@ void ICMPanel::saveReferencePressed () {
|
||||
if (!icmplistener)
|
||||
return;
|
||||
Gtk::FileChooserDialog dialog(M("TP_ICM_SAVEREFERENCEDLGLABEL"), Gtk::FILE_CHOOSER_ACTION_SAVE);
|
||||
FileChooserLastFolderPersister persister(&dialog, options.lastProfilingReferenceDir);
|
||||
|
||||
dialog.add_button(Gtk::StockID("gtk-cancel"), Gtk::RESPONSE_CANCEL);
|
||||
dialog.add_button(Gtk::StockID("gtk-save"), Gtk::RESPONSE_OK);
|
||||
|
@@ -19,6 +19,8 @@
|
||||
#ifndef _ICMPANEL_
|
||||
#define _ICMPANEL_
|
||||
|
||||
#include <auto_ptr.h>
|
||||
|
||||
#include <gtkmm.h>
|
||||
#include "adjuster.h"
|
||||
#include "guiutils.h"
|
||||
@@ -58,13 +60,13 @@ class ICMPanel : public Gtk::VBox, public AdjusterListener, public FoldableToolP
|
||||
Gtk::RadioButton* ofromfile;
|
||||
Gtk::RadioButton* iunchanged;
|
||||
MyFileChooserButton* ipDialog;
|
||||
std::auto_ptr<FileChooserLastFolderPersister> ipDialogPersister;
|
||||
Gtk::RadioButton::Group opts;
|
||||
Gtk::Button* saveRef;
|
||||
sigc::connection ipc;
|
||||
Glib::ustring oldip;
|
||||
ICMPanelListener* icmplistener;
|
||||
|
||||
static Glib::ustring lastICCWorkDir;
|
||||
bool enableLastICCWorkDirChange;
|
||||
|
||||
public:
|
||||
|
@@ -67,7 +67,7 @@ LCurve::LCurve () : Gtk::VBox(), FoldableToolPanel(this) {
|
||||
hsep3->show ();
|
||||
pack_start (*hsep3);
|
||||
|
||||
curveEditorG = new CurveEditorGroup ();
|
||||
curveEditorG = new CurveEditorGroup (options.lastLabCurvesDir);
|
||||
curveEditorG->setCurveListener (this);
|
||||
curveEditorG->setColorProvider (this);
|
||||
|
||||
|
@@ -339,7 +339,7 @@ int processLineParams( int argc, char **argv )
|
||||
}
|
||||
else {
|
||||
options.saveUsePathTemplate = true;
|
||||
if (!options.savePathTemplate.length())
|
||||
if (options.savePathTemplate.empty())
|
||||
// If the save path template is empty, we use its default value
|
||||
options.savePathTemplate = "%p1/converted/%f";
|
||||
}
|
||||
|
@@ -36,6 +36,9 @@
|
||||
#include <Shlobj.h>
|
||||
#endif
|
||||
|
||||
Glib::ustring Options::rtdir;
|
||||
Glib::ustring Options::cacheBaseDir;
|
||||
|
||||
Options options;
|
||||
Glib::ustring versionString = VERSION;
|
||||
Glib::ustring paramFileExtension = ".pp3";
|
||||
@@ -135,17 +138,30 @@ void Options::updatePaths() {
|
||||
if(checkDirPath (tmpPath, "Error: no global profiles' directory found!\n")) {
|
||||
globalProfilePath = tmpPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Glib::ustring preferredPath = getPreferredProfilePath();
|
||||
// Paths are updated only if the user or global profile path is set
|
||||
if (lastRgbCurvesDir.empty() || !safe_file_test (lastRgbCurvesDir, Glib::FILE_TEST_EXISTS) || !safe_file_test (lastRgbCurvesDir, Glib::FILE_TEST_IS_DIR))
|
||||
lastRgbCurvesDir = preferredPath;
|
||||
if (lastLabCurvesDir.empty() || !safe_file_test (lastLabCurvesDir, Glib::FILE_TEST_EXISTS) || !safe_file_test (lastLabCurvesDir, Glib::FILE_TEST_IS_DIR))
|
||||
lastLabCurvesDir = preferredPath;
|
||||
if (lastHsvCurvesDir.empty() || !safe_file_test (lastHsvCurvesDir, Glib::FILE_TEST_EXISTS) || !safe_file_test (lastHsvCurvesDir, Glib::FILE_TEST_IS_DIR))
|
||||
lastHsvCurvesDir = preferredPath;
|
||||
if (lastToneCurvesDir.empty() || !safe_file_test (lastToneCurvesDir, Glib::FILE_TEST_EXISTS) || !safe_file_test (lastToneCurvesDir, Glib::FILE_TEST_IS_DIR))
|
||||
lastToneCurvesDir = preferredPath;
|
||||
if (lastProfilingReferenceDir.empty() || !safe_file_test (lastProfilingReferenceDir, Glib::FILE_TEST_EXISTS) || !safe_file_test (lastProfilingReferenceDir, Glib::FILE_TEST_IS_DIR))
|
||||
lastProfilingReferenceDir = preferredPath;
|
||||
}
|
||||
|
||||
Glib::ustring Options::getPreferredProfilePath() {
|
||||
if (!userProfilePath.empty())
|
||||
return userProfilePath;
|
||||
else if (!globalProfilePath.empty())
|
||||
return globalProfilePath;
|
||||
else
|
||||
return "";
|
||||
if (!userProfilePath.empty())
|
||||
return userProfilePath;
|
||||
else if (!globalProfilePath.empty())
|
||||
return globalProfilePath;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
Glib::ustring Options::findProfilePath(Glib::ustring &profName) {
|
||||
@@ -198,9 +214,7 @@ void Options::setDefaults () {
|
||||
adjusterDelay = 0;
|
||||
startupDir = STARTUPDIR_LAST; // was STARTUPDIR_HOME ; an empty startupPath is now correctly handled (open in the Home dir)
|
||||
startupPath = "";
|
||||
profilePath = "profiles";
|
||||
useBundledProfiles = true;
|
||||
loadSaveProfilePath = "";
|
||||
dirBrowserWidth = 200;
|
||||
dirBrowserHeight = 150;
|
||||
preferencesWidth = 0;
|
||||
@@ -219,6 +233,8 @@ void Options::setDefaults () {
|
||||
fbShowHidden = false;
|
||||
fbArrangement = 2; // was 0
|
||||
multiUser = true;
|
||||
profilePath = "profiles";
|
||||
loadSaveProfilePath = ""; // will be corrected in load as otherwise construction fails
|
||||
version = "0.0.0.0"; // temporary value; will be correctly set in RTWindow::on_realize
|
||||
thumbSize = 240; // was 80
|
||||
thumbSizeTab = 80;
|
||||
@@ -401,6 +417,21 @@ void Options::setDefaults () {
|
||||
rtSettings.best = "BestRGB";
|
||||
rtSettings.verbose = false;
|
||||
rtSettings.gamutICC = true;
|
||||
|
||||
lastIccDir = rtSettings.iccDirectory;
|
||||
lastDarkframeDir = rtSettings.darkFramesPath;
|
||||
lastFlatfieldDir = rtSettings.flatFieldsPath;
|
||||
|
||||
// There is no reasonable default for curves. We can still suppose that they will take place
|
||||
// in a subdirectory of the user's own ProcParams presets, i.e. in a subdirectory
|
||||
// of the one pointed to by the "profile" field.
|
||||
// The following fields will then be initialized when "profile" will have its final value,
|
||||
// at the end of the "updatePaths" method.
|
||||
lastRgbCurvesDir = "";
|
||||
lastLabCurvesDir = "";
|
||||
lastHsvCurvesDir = "";
|
||||
lastToneCurvesDir = "";
|
||||
lastProfilingReferenceDir = "";
|
||||
}
|
||||
|
||||
Options* Options::copyFrom (Options* other) {
|
||||
@@ -647,11 +678,33 @@ if (keyFile.has_group ("Fast Export")) {
|
||||
if (keyFile.has_key ("Fast Export", "fastexport_resize_width" )) fastexport_resize_width = keyFile.get_integer ("Fast Export", "fastexport_resize_width" );
|
||||
if (keyFile.has_key ("Fast Export", "fastexport_resize_height" )) fastexport_resize_height = keyFile.get_integer ("Fast Export", "fastexport_resize_height" );
|
||||
}
|
||||
|
||||
if (keyFile.has_group ("Dialogs")) {
|
||||
safeDirGet(keyFile, "Dialogs", "LastIccDir", lastIccDir);
|
||||
safeDirGet(keyFile, "Dialogs", "LastDarkframeDir", lastDarkframeDir);
|
||||
safeDirGet(keyFile, "Dialogs", "LastFlatfieldDir", lastFlatfieldDir);
|
||||
safeDirGet(keyFile, "Dialogs", "LastRgbCurvesDir", lastRgbCurvesDir);
|
||||
safeDirGet(keyFile, "Dialogs", "LastLabCurvesDir", lastLabCurvesDir);
|
||||
safeDirGet(keyFile, "Dialogs", "LastHsvCurvesDir", lastHsvCurvesDir);
|
||||
safeDirGet(keyFile, "Dialogs", "LastToneCurvesDir", lastToneCurvesDir);
|
||||
safeDirGet(keyFile, "Dialogs", "LastProfilingReferenceDir", lastProfilingReferenceDir);
|
||||
}
|
||||
|
||||
filterOutParsedExtensions ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Options::safeDirGet(const rtengine::SafeKeyFile& keyFile, const Glib::ustring& section,
|
||||
const Glib::ustring& entryName, Glib::ustring& destination)
|
||||
{
|
||||
if (keyFile.has_key(section, entryName) && !keyFile.get_string(section, entryName).empty()) {
|
||||
destination = keyFile.get_string(section, entryName);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Options::saveToFile (Glib::ustring fname) {
|
||||
|
||||
rtengine::SafeKeyFile keyFile;
|
||||
@@ -855,6 +908,14 @@ int Options::saveToFile (Glib::ustring fname) {
|
||||
keyFile.set_integer ("Fast Export", "fastexport_resize_width" , fastexport_resize_width );
|
||||
keyFile.set_integer ("Fast Export", "fastexport_resize_height" , fastexport_resize_height );
|
||||
|
||||
keyFile.set_string ("Dialogs", "LastIccDir", lastIccDir);
|
||||
keyFile.set_string ("Dialogs", "LastDarkframeDir", lastDarkframeDir);
|
||||
keyFile.set_string ("Dialogs", "LastFlatfieldDir", lastFlatfieldDir);
|
||||
keyFile.set_string ("Dialogs", "LastRgbCurvesDir", lastRgbCurvesDir);
|
||||
keyFile.set_string ("Dialogs", "LastLabCurvesDir", lastLabCurvesDir);
|
||||
keyFile.set_string ("Dialogs", "LastHsvCurvesDir", lastHsvCurvesDir);
|
||||
keyFile.set_string ("Dialogs", "LastToneCurvesDir", lastToneCurvesDir);
|
||||
keyFile.set_string ("Dialogs", "LastProfilingReferenceDir", lastProfilingReferenceDir);
|
||||
|
||||
FILE *f = safe_g_fopen (fname, "wt");
|
||||
if (f==NULL)
|
||||
@@ -866,11 +927,6 @@ int Options::saveToFile (Glib::ustring fname) {
|
||||
}
|
||||
}
|
||||
|
||||
// User's settings directory, including images' profiles if used
|
||||
Glib::ustring Options::rtdir;
|
||||
// User's cached datas' directory
|
||||
Glib::ustring Options::cacheBaseDir;
|
||||
|
||||
void Options::load () {
|
||||
|
||||
// Find the application data path
|
||||
@@ -922,7 +978,7 @@ void Options::load () {
|
||||
options.updatePaths();
|
||||
|
||||
// Check default Raw and Img procparams existence
|
||||
if (!options.defProfRaw.length())
|
||||
if (options.defProfRaw.empty())
|
||||
options.defProfRaw = DEFPROFILE_INTERNAL;
|
||||
else {
|
||||
Glib::ustring tmpFName = options.findProfilePath(options.defProfRaw);
|
||||
@@ -936,7 +992,7 @@ void Options::load () {
|
||||
}
|
||||
}
|
||||
|
||||
if (!options.defProfImg.length())
|
||||
if (options.defProfImg.empty())
|
||||
options.defProfImg = DEFPROFILE_INTERNAL;
|
||||
else {
|
||||
Glib::ustring tmpFName = options.findProfilePath(options.defProfImg);
|
||||
@@ -1003,7 +1059,7 @@ bool Options::has_retained_extention (Glib::ustring fname) {
|
||||
|
||||
Glib::ustring ext = getExtension(fname).lowercase();
|
||||
|
||||
if (ext.length()) {
|
||||
if (!ext.empty()) {
|
||||
// there is an extension to the filename
|
||||
|
||||
// look out if it has one of the retained extensions
|
||||
|
@@ -49,6 +49,10 @@ class SaveFormat {
|
||||
enum ThFileType {FT_Invalid=-1, FT_None=0, FT_Raw=1, FT_Jpeg=2, FT_Tiff=3, FT_Png=4, FT_Custom=5, FT_Tiff16=6, FT_Png16=7, FT_Custom16=8};
|
||||
enum PPLoadLocation {PLL_Cache=0, PLL_Input=1};
|
||||
|
||||
namespace rtengine {
|
||||
class SafeKeyFile;
|
||||
}
|
||||
|
||||
class Options {
|
||||
|
||||
private:
|
||||
@@ -61,6 +65,19 @@ class Options {
|
||||
void updatePaths();
|
||||
int getString (const char* src, char* dst);
|
||||
void error (int line);
|
||||
/**
|
||||
* Safely reads a directory from the configuration file and only applies it
|
||||
* to the provided destination variable if there is a non-empty string in
|
||||
* the configuration.
|
||||
*
|
||||
* @param keyFile file to read configuration from
|
||||
* @param section name of the section in the configuration file
|
||||
* @param entryName name of the entry in the configuration file
|
||||
* @param destination destination variable to store to
|
||||
* @return @c true if @p destination was changed
|
||||
*/
|
||||
bool safeDirGet(const rtengine::SafeKeyFile& keyFile, const Glib::ustring& section,
|
||||
const Glib::ustring& entryName, Glib::ustring& destination);
|
||||
|
||||
public:
|
||||
bool savesParamsAtExit;
|
||||
@@ -212,6 +229,16 @@ class Options {
|
||||
int fastexport_resize_width;
|
||||
int fastexport_resize_height;
|
||||
|
||||
// Dialog settings
|
||||
Glib::ustring lastIccDir;
|
||||
Glib::ustring lastDarkframeDir;
|
||||
Glib::ustring lastFlatfieldDir;
|
||||
Glib::ustring lastRgbCurvesDir;
|
||||
Glib::ustring lastLabCurvesDir;
|
||||
Glib::ustring lastHsvCurvesDir;
|
||||
Glib::ustring lastToneCurvesDir;
|
||||
Glib::ustring lastProfilingReferenceDir;
|
||||
|
||||
Options ();
|
||||
|
||||
Options* copyFrom (Options* other);
|
||||
|
@@ -125,10 +125,7 @@ void ProfilePanel::save_clicked (GdkEventButton* event) {
|
||||
return;
|
||||
|
||||
Gtk::FileChooserDialog dialog(M("PROFILEPANEL_SAVEDLGLABEL"), Gtk::FILE_CHOOSER_ACTION_SAVE);
|
||||
if (options.loadSaveProfilePath.length())
|
||||
dialog.set_current_folder (options.loadSaveProfilePath);
|
||||
else
|
||||
dialog.set_current_folder (options.getPreferredProfilePath());
|
||||
FileChooserLastFolderPersister persister( &dialog, options.loadSaveProfilePath );
|
||||
|
||||
//Add response buttons the the dialog:
|
||||
dialog.add_button(Gtk::StockID("gtk-cancel"), Gtk::RESPONSE_CANCEL);
|
||||
@@ -158,7 +155,6 @@ void ProfilePanel::save_clicked (GdkEventButton* event) {
|
||||
if (result==Gtk::RESPONSE_OK) {
|
||||
|
||||
std::string fname = dialog.get_filename();
|
||||
options.loadSaveProfilePath = Glib::path_get_dirname(fname);
|
||||
|
||||
bool hasext = true;
|
||||
size_t dotpos = fname.find_last_of ('.');
|
||||
@@ -265,10 +261,7 @@ void ProfilePanel::load_clicked (GdkEventButton* event) {
|
||||
return;
|
||||
|
||||
Gtk::FileChooserDialog dialog(M("PROFILEPANEL_LOADDLGLABEL"), Gtk::FILE_CHOOSER_ACTION_OPEN);
|
||||
if (options.loadSaveProfilePath.length())
|
||||
dialog.set_current_folder (options.loadSaveProfilePath);
|
||||
else
|
||||
dialog.set_current_folder (options.getPreferredProfilePath());
|
||||
FileChooserLastFolderPersister persister( &dialog, options.loadSaveProfilePath );
|
||||
|
||||
//Add response buttons the the dialog:
|
||||
dialog.add_button(Gtk::StockID("gtk-cancel"), Gtk::RESPONSE_CANCEL);
|
||||
@@ -291,7 +284,6 @@ void ProfilePanel::load_clicked (GdkEventButton* event) {
|
||||
|
||||
if (result==Gtk::RESPONSE_OK) {
|
||||
Glib::ustring fname = dialog.get_filename();
|
||||
options.loadSaveProfilePath = Glib::path_get_dirname(fname);
|
||||
|
||||
if (event->state & Gdk::CONTROL_MASK) {
|
||||
// opening the partial paste dialog window
|
||||
|
@@ -24,7 +24,7 @@ using namespace rtengine::procparams;
|
||||
|
||||
RGBCurves::RGBCurves () : Gtk::VBox(), FoldableToolPanel(this) {
|
||||
|
||||
curveEditorG = new CurveEditorGroup (M("TP_RGBCURVES_CHANNEL"));
|
||||
curveEditorG = new CurveEditorGroup (options.lastRgbCurvesDir, M("TP_RGBCURVES_CHANNEL"));
|
||||
curveEditorG->setCurveListener (this);
|
||||
curveEditorG->setColorProvider (this);
|
||||
|
||||
|
@@ -85,7 +85,7 @@ ToneCurve::ToneCurve () : Gtk::VBox(), FoldableToolPanel(this) {
|
||||
//----------- Curve ------------------------------
|
||||
pack_start (*Gtk::manage (new Gtk::HSeparator()));
|
||||
|
||||
curveEditorG = new CurveEditorGroup (M("TP_EXPOSURE_CURVEEDITOR"));
|
||||
curveEditorG = new CurveEditorGroup (options.lastToneCurvesDir, M("TP_EXPOSURE_CURVEEDITOR"));
|
||||
curveEditorG->setCurveListener (this);
|
||||
|
||||
shape = static_cast<DiagonalCurveEditor*>(curveEditorG->addCurve(CT_Diagonal, ""));
|
||||
|
Reference in New Issue
Block a user