merge 'options-save-raise-exception-on-failure' into 'dev'

This commit is contained in:
Alberto Griggio
2017-08-22 16:39:06 +02:00
8 changed files with 1034 additions and 950 deletions

View File

@@ -21,6 +21,7 @@
#include <gtkmm.h>
#include "../rtengine/rtengine.h"
#include <exception>
#define STARTUPDIR_CURRENT 0
#define STARTUPDIR_HOME 1
@@ -42,17 +43,16 @@
// Special name for the Dynamic profile
#define DEFPROFILE_DYNAMIC "Dynamic"
struct SaveFormat
{
struct SaveFormat {
SaveFormat() :
format("jpg"),
pngBits(8),
pngCompression(6),
jpegQuality(90),
jpegSubSamp(2),
tiffBits(8),
tiffUncompressed(true),
saveParams(true)
format ("jpg"),
pngBits (8),
pngCompression (6),
jpegQuality (90),
jpegSubSamp (2),
tiffBits (8),
tiffUncompressed (true),
saveParams (true)
{
}
@@ -73,14 +73,31 @@ enum prevdemo_t {PD_Sidecar = 1, PD_Fast = 0};
class Options
{
public:
class Error: public std::exception
{
public:
Error (const Glib::ustring &msg): msg_ (msg) {}
const char *what() const throw()
{
return msg_.c_str();
}
const Glib::ustring &get_msg() const throw()
{
return msg_;
}
private:
Glib::ustring msg_;
};
private:
bool defProfRawMissing;
bool defProfImgMissing;
Glib::ustring userProfilePath;
Glib::ustring globalProfilePath;
bool checkProfilePath(Glib::ustring &path);
bool checkDirPath(Glib::ustring &path, Glib::ustring errString);
bool checkProfilePath (Glib::ustring &path);
bool checkDirPath (Glib::ustring &path, Glib::ustring errString);
void updatePaths();
int getString (const char* src, char* dst);
void error (int line);
@@ -95,8 +112,8 @@ private:
* @param destination destination variable to store to
* @return @c true if @p destination was changed
*/
bool safeDirGet(const Glib::KeyFile& keyFile, const Glib::ustring& section,
const Glib::ustring& entryName, Glib::ustring& destination);
bool safeDirGet (const Glib::KeyFile& keyFile, const Glib::ustring& section,
const Glib::ustring& entryName, Glib::ustring& destination);
public:
@@ -326,10 +343,10 @@ public:
Options* copyFrom (Options* other);
void filterOutParsedExtensions ();
void setDefaults ();
int readFromFile (Glib::ustring fname);
int saveToFile (Glib::ustring fname);
static bool load (bool lightweight = false);
static void save ();
void readFromFile (Glib::ustring fname);
void saveToFile (Glib::ustring fname);
static void load (bool lightweight = false);
static void save();
// if multiUser=false, send back the global profile path
Glib::ustring getPreferredProfilePath();
@@ -341,10 +358,10 @@ public:
{
return globalProfilePath;
}
Glib::ustring findProfilePath(Glib::ustring &profName);
Glib::ustring findProfilePath (Glib::ustring &profName);
bool is_parse_extention (Glib::ustring fname);
bool has_retained_extention (Glib::ustring fname);
bool is_extention_enabled(Glib::ustring ext);
bool is_extention_enabled (Glib::ustring ext);
bool is_defProfRawMissing()
{
return defProfRawMissing;
@@ -353,11 +370,11 @@ public:
{
return defProfImgMissing;
}
void setDefProfRawMissing(bool value)
void setDefProfRawMissing (bool value)
{
defProfRawMissing = value;
}
void setDefProfImgMissing(bool value)
void setDefProfImgMissing (bool value)
{
defProfImgMissing = value;
}