Several files astylized.
This commit is contained in:
parent
fb5466bc8c
commit
8c309d0f04
@ -25,7 +25,8 @@
|
|||||||
using namespace rtengine;
|
using namespace rtengine;
|
||||||
using namespace rtengine::procparams;
|
using namespace rtengine::procparams;
|
||||||
|
|
||||||
namespace {
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
const int ISO_MAX = 512000;
|
const int ISO_MAX = 512000;
|
||||||
const double FNUMBER_MAX = 100.0;
|
const double FNUMBER_MAX = 100.0;
|
||||||
@ -38,14 +39,15 @@ const double EXPCOMP_MAX = 20.0;
|
|||||||
|
|
||||||
DynamicProfileRules dynamicProfileRules;
|
DynamicProfileRules dynamicProfileRules;
|
||||||
|
|
||||||
bool DynamicProfileRule::Optional::operator()(const Glib::ustring &val) const
|
bool DynamicProfileRule::Optional::operator() (const Glib::ustring &val) const
|
||||||
{
|
{
|
||||||
if (!enabled) {
|
if (!enabled) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (value.find("re:") == 0) {
|
|
||||||
|
if (value.find ("re:") == 0) {
|
||||||
// this is a regexp
|
// this is a regexp
|
||||||
return Glib::Regex::match_simple(value.substr(3), val, Glib::REGEX_CASELESS);
|
return Glib::Regex::match_simple (value.substr (3), val, Glib::REGEX_CASELESS);
|
||||||
} else {
|
} else {
|
||||||
// normal string comparison
|
// normal string comparison
|
||||||
return value.casefold() == val.casefold();
|
return value.casefold() == val.casefold();
|
||||||
@ -54,42 +56,44 @@ bool DynamicProfileRule::Optional::operator()(const Glib::ustring &val) const
|
|||||||
|
|
||||||
|
|
||||||
DynamicProfileRule::DynamicProfileRule():
|
DynamicProfileRule::DynamicProfileRule():
|
||||||
serial_number(0),
|
serial_number (0),
|
||||||
iso(0, ISO_MAX),
|
iso (0, ISO_MAX),
|
||||||
fnumber(0, FNUMBER_MAX),
|
fnumber (0, FNUMBER_MAX),
|
||||||
focallen(0, FOCALLEN_MAX),
|
focallen (0, FOCALLEN_MAX),
|
||||||
shutterspeed(0, SHUTTERSPEED_MAX),
|
shutterspeed (0, SHUTTERSPEED_MAX),
|
||||||
expcomp(EXPCOMP_MIN, EXPCOMP_MAX)
|
expcomp (EXPCOMP_MIN, EXPCOMP_MAX)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool DynamicProfileRule::operator<(const DynamicProfileRule &other) const
|
bool DynamicProfileRule::operator< (const DynamicProfileRule &other) const
|
||||||
{
|
{
|
||||||
return serial_number < other.serial_number;
|
return serial_number < other.serial_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool DynamicProfileRule::matches(const rtengine::ImageMetaData *im) const
|
bool DynamicProfileRule::matches (const rtengine::ImageMetaData *im) const
|
||||||
{
|
{
|
||||||
return (iso(im->getISOSpeed())
|
return (iso (im->getISOSpeed())
|
||||||
&& fnumber(im->getFNumber())
|
&& fnumber (im->getFNumber())
|
||||||
&& focallen(im->getFocalLen())
|
&& focallen (im->getFocalLen())
|
||||||
&& shutterspeed(im->getShutterSpeed())
|
&& shutterspeed (im->getShutterSpeed())
|
||||||
&& expcomp(im->getExpComp())
|
&& expcomp (im->getExpComp())
|
||||||
&& camera(im->getCamera())
|
&& camera (im->getCamera())
|
||||||
&& lens(im->getLens()));
|
&& lens (im->getLens()));
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
void get_int_range(DynamicProfileRule::Range<int> &dest,
|
void get_int_range (DynamicProfileRule::Range<int> &dest,
|
||||||
const Glib::KeyFile &kf, const Glib::ustring &group,
|
const Glib::KeyFile &kf, const Glib::ustring &group,
|
||||||
const Glib::ustring &key)
|
const Glib::ustring &key)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
int min = kf.get_integer(group, key + "_min");
|
int min = kf.get_integer (group, key + "_min");
|
||||||
int max = kf.get_integer(group, key + "_max");
|
int max = kf.get_integer (group, key + "_max");
|
||||||
|
|
||||||
if (min <= max) {
|
if (min <= max) {
|
||||||
dest.min = min;
|
dest.min = min;
|
||||||
dest.max = max;
|
dest.max = max;
|
||||||
@ -99,13 +103,14 @@ void get_int_range(DynamicProfileRule::Range<int> &dest,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void get_double_range(DynamicProfileRule::Range<double> &dest,
|
void get_double_range (DynamicProfileRule::Range<double> &dest,
|
||||||
const Glib::KeyFile &kf, const Glib::ustring &group,
|
const Glib::KeyFile &kf, const Glib::ustring &group,
|
||||||
const Glib::ustring &key)
|
const Glib::ustring &key)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
double min = kf.get_double(group, key + "_min");
|
double min = kf.get_double (group, key + "_min");
|
||||||
double max = kf.get_double(group, key + "_max");
|
double max = kf.get_double (group, key + "_max");
|
||||||
|
|
||||||
if (min <= max) {
|
if (min <= max) {
|
||||||
dest.min = min;
|
dest.min = min;
|
||||||
dest.max = max;
|
dest.max = max;
|
||||||
@ -115,14 +120,15 @@ void get_double_range(DynamicProfileRule::Range<double> &dest,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void get_optional(DynamicProfileRule::Optional &dest,
|
void get_optional (DynamicProfileRule::Optional &dest,
|
||||||
const Glib::KeyFile &kf, const Glib::ustring &group,
|
const Glib::KeyFile &kf, const Glib::ustring &group,
|
||||||
const Glib::ustring &key)
|
const Glib::ustring &key)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
bool e = kf.get_boolean(group, key + "_enabled");
|
bool e = kf.get_boolean (group, key + "_enabled");
|
||||||
|
|
||||||
if (e) {
|
if (e) {
|
||||||
Glib::ustring s = kf.get_string(group, key + "_value");
|
Glib::ustring s = kf.get_string (group, key + "_value");
|
||||||
dest.enabled = e;
|
dest.enabled = e;
|
||||||
dest.value = s;
|
dest.value = s;
|
||||||
}
|
}
|
||||||
@ -130,28 +136,28 @@ void get_optional(DynamicProfileRule::Optional &dest,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_int_range(Glib::KeyFile &kf, const Glib::ustring &group,
|
void set_int_range (Glib::KeyFile &kf, const Glib::ustring &group,
|
||||||
const Glib::ustring &key,
|
const Glib::ustring &key,
|
||||||
const DynamicProfileRule::Range<int> &val)
|
const DynamicProfileRule::Range<int> &val)
|
||||||
{
|
{
|
||||||
kf.set_integer(group, key + "_min", val.min);
|
kf.set_integer (group, key + "_min", val.min);
|
||||||
kf.set_integer(group, key + "_max", val.max);
|
kf.set_integer (group, key + "_max", val.max);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_double_range(Glib::KeyFile &kf, const Glib::ustring &group,
|
void set_double_range (Glib::KeyFile &kf, const Glib::ustring &group,
|
||||||
const Glib::ustring &key,
|
const Glib::ustring &key,
|
||||||
const DynamicProfileRule::Range<double> &val)
|
const DynamicProfileRule::Range<double> &val)
|
||||||
{
|
{
|
||||||
kf.set_double(group, key + "_min", val.min);
|
kf.set_double (group, key + "_min", val.min);
|
||||||
kf.set_double(group, key + "_max", val.max);
|
kf.set_double (group, key + "_max", val.max);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_optional(Glib::KeyFile &kf, const Glib::ustring &group,
|
void set_optional (Glib::KeyFile &kf, const Glib::ustring &group,
|
||||||
const Glib::ustring &key,
|
const Glib::ustring &key,
|
||||||
const DynamicProfileRule::Optional &val)
|
const DynamicProfileRule::Optional &val)
|
||||||
{
|
{
|
||||||
kf.set_boolean(group, key + "_enabled", val.enabled);
|
kf.set_boolean (group, key + "_enabled", val.enabled);
|
||||||
kf.set_string(group, key + "_value", val.value);
|
kf.set_string (group, key + "_value", val.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
@ -160,48 +166,57 @@ bool DynamicProfileRules::loadRules()
|
|||||||
{
|
{
|
||||||
dynamicRules.clear();
|
dynamicRules.clear();
|
||||||
Glib::KeyFile kf;
|
Glib::KeyFile kf;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!kf.load_from_file(Glib::build_filename(Options::rtdir, "dynamicprofile.cfg"))) {
|
if (!kf.load_from_file (Glib::build_filename (Options::rtdir, "dynamicprofile.cfg"))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (Glib::Error &e) {
|
} catch (Glib::Error &e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.rtSettings.verbose) {
|
if (options.rtSettings.verbose) {
|
||||||
printf("loading dynamic profiles...\n");
|
printf ("loading dynamic profiles...\n");
|
||||||
}
|
|
||||||
auto groups = kf.get_groups();
|
|
||||||
for (auto group : groups) {
|
|
||||||
// groups are of the form "rule N", where N is a positive integer
|
|
||||||
if (group.find("rule ") != 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
std::istringstream buf(group.c_str() + 5);
|
|
||||||
int serial = 0;
|
|
||||||
if (!(buf >> serial) || !buf.eof()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (options.rtSettings.verbose) {
|
|
||||||
printf(" loading rule %d\n", serial);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dynamicRules.emplace_back(DynamicProfileRule());
|
auto groups = kf.get_groups();
|
||||||
|
|
||||||
|
for (auto group : groups) {
|
||||||
|
// groups are of the form "rule N", where N is a positive integer
|
||||||
|
if (group.find ("rule ") != 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::istringstream buf (group.c_str() + 5);
|
||||||
|
int serial = 0;
|
||||||
|
|
||||||
|
if (! (buf >> serial) || !buf.eof()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.rtSettings.verbose) {
|
||||||
|
printf (" loading rule %d\n", serial);
|
||||||
|
}
|
||||||
|
|
||||||
|
dynamicRules.emplace_back (DynamicProfileRule());
|
||||||
DynamicProfileRule &rule = dynamicRules.back();
|
DynamicProfileRule &rule = dynamicRules.back();
|
||||||
rule.serial_number = serial;
|
rule.serial_number = serial;
|
||||||
get_int_range(rule.iso, kf, group, "iso");
|
get_int_range (rule.iso, kf, group, "iso");
|
||||||
get_double_range(rule.fnumber, kf, group, "fnumber");
|
get_double_range (rule.fnumber, kf, group, "fnumber");
|
||||||
get_double_range(rule.focallen, kf, group, "focallen");
|
get_double_range (rule.focallen, kf, group, "focallen");
|
||||||
get_double_range(rule.shutterspeed, kf, group, "shutterspeed");
|
get_double_range (rule.shutterspeed, kf, group, "shutterspeed");
|
||||||
get_double_range(rule.expcomp, kf, group, "expcomp");
|
get_double_range (rule.expcomp, kf, group, "expcomp");
|
||||||
get_optional(rule.camera, kf, group, "camera");
|
get_optional (rule.camera, kf, group, "camera");
|
||||||
get_optional(rule.lens, kf, group, "lens");
|
get_optional (rule.lens, kf, group, "lens");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
rule.profilepath = kf.get_string(group, "profilepath");
|
rule.profilepath = kf.get_string (group, "profilepath");
|
||||||
} catch (Glib::KeyFileError &) {
|
} catch (Glib::KeyFileError &) {
|
||||||
dynamicRules.pop_back();
|
dynamicRules.pop_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::sort(dynamicRules.begin(), dynamicRules.end());
|
|
||||||
|
std::sort (dynamicRules.begin(), dynamicRules.end());
|
||||||
rulesLoaded = true;
|
rulesLoaded = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -209,23 +224,26 @@ bool DynamicProfileRules::loadRules()
|
|||||||
bool DynamicProfileRules::storeRules()
|
bool DynamicProfileRules::storeRules()
|
||||||
{
|
{
|
||||||
if (options.rtSettings.verbose) {
|
if (options.rtSettings.verbose) {
|
||||||
printf("saving dynamic profiles...\n");
|
printf ("saving dynamic profiles...\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
Glib::KeyFile kf;
|
Glib::KeyFile kf;
|
||||||
|
|
||||||
for (auto &rule : dynamicRules) {
|
for (auto &rule : dynamicRules) {
|
||||||
std::ostringstream buf;
|
std::ostringstream buf;
|
||||||
buf << "rule " << rule.serial_number;
|
buf << "rule " << rule.serial_number;
|
||||||
Glib::ustring group = buf.str();
|
Glib::ustring group = buf.str();
|
||||||
set_int_range(kf, group, "iso", rule.iso);
|
set_int_range (kf, group, "iso", rule.iso);
|
||||||
set_double_range(kf, group, "fnumber", rule.fnumber);
|
set_double_range (kf, group, "fnumber", rule.fnumber);
|
||||||
set_double_range(kf, group, "focallen", rule.focallen);
|
set_double_range (kf, group, "focallen", rule.focallen);
|
||||||
set_double_range(kf, group, "shutterspeed", rule.shutterspeed);
|
set_double_range (kf, group, "shutterspeed", rule.shutterspeed);
|
||||||
set_double_range(kf, group, "expcomp", rule.expcomp);
|
set_double_range (kf, group, "expcomp", rule.expcomp);
|
||||||
set_optional(kf, group, "camera", rule.camera);
|
set_optional (kf, group, "camera", rule.camera);
|
||||||
set_optional(kf, group, "lens", rule.lens);
|
set_optional (kf, group, "lens", rule.lens);
|
||||||
kf.set_string(group, "profilepath", rule.profilepath);
|
kf.set_string (group, "profilepath", rule.profilepath);
|
||||||
}
|
}
|
||||||
return kf.save_to_file(Glib::build_filename(Options::rtdir, "dynamicprofile.cfg"));
|
|
||||||
|
return kf.save_to_file (Glib::build_filename (Options::rtdir, "dynamicprofile.cfg"));
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<DynamicProfileRule> &DynamicProfileRules::getRules() const
|
const std::vector<DynamicProfileRule> &DynamicProfileRules::getRules() const
|
||||||
@ -233,7 +251,7 @@ const std::vector<DynamicProfileRule> &DynamicProfileRules::getRules() const
|
|||||||
return dynamicRules;
|
return dynamicRules;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicProfileRules::setRules(const std::vector<DynamicProfileRule> &r)
|
void DynamicProfileRules::setRules (const std::vector<DynamicProfileRule> &r)
|
||||||
{
|
{
|
||||||
dynamicRules = r;
|
dynamicRules = r;
|
||||||
}
|
}
|
||||||
|
@ -23,15 +23,16 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include "../rtgui/options.h"
|
#include "../rtgui/options.h"
|
||||||
|
|
||||||
class DynamicProfileRule {
|
class DynamicProfileRule
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
template <class T>
|
template <class T>
|
||||||
struct Range {
|
struct Range {
|
||||||
T min;
|
T min;
|
||||||
T max;
|
T max;
|
||||||
explicit Range(T l=T(), T u=T()): min(l), max(u) {}
|
explicit Range (T l = T(), T u = T()): min (l), max (u) {}
|
||||||
|
|
||||||
bool operator()(T val) const
|
bool operator() (T val) const
|
||||||
{
|
{
|
||||||
return val >= min && val <= max;
|
return val >= min && val <= max;
|
||||||
}
|
}
|
||||||
@ -40,15 +41,15 @@ public:
|
|||||||
struct Optional {
|
struct Optional {
|
||||||
Glib::ustring value;
|
Glib::ustring value;
|
||||||
bool enabled;
|
bool enabled;
|
||||||
explicit Optional(const Glib::ustring v="", bool e=false):
|
explicit Optional (const Glib::ustring v = "", bool e = false):
|
||||||
value(v), enabled(e) {}
|
value (v), enabled (e) {}
|
||||||
|
|
||||||
bool operator()(const Glib::ustring &val) const;
|
bool operator() (const Glib::ustring &val) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
DynamicProfileRule();
|
DynamicProfileRule();
|
||||||
bool matches(const rtengine::ImageMetaData *im) const;
|
bool matches (const rtengine::ImageMetaData *im) const;
|
||||||
bool operator<(const DynamicProfileRule &other) const;
|
bool operator< (const DynamicProfileRule &other) const;
|
||||||
|
|
||||||
int serial_number;
|
int serial_number;
|
||||||
Range<int> iso;
|
Range<int> iso;
|
||||||
@ -61,7 +62,8 @@ public:
|
|||||||
Glib::ustring profilepath;
|
Glib::ustring profilepath;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DynamicProfileRules {
|
class DynamicProfileRules
|
||||||
|
{
|
||||||
protected:
|
protected:
|
||||||
/** cache for dynamic profile rules */
|
/** cache for dynamic profile rules */
|
||||||
std::vector<DynamicProfileRule> dynamicRules;
|
std::vector<DynamicProfileRule> dynamicRules;
|
||||||
@ -71,7 +73,7 @@ public:
|
|||||||
bool loadRules();
|
bool loadRules();
|
||||||
bool storeRules();
|
bool storeRules();
|
||||||
const std::vector<DynamicProfileRule> &getRules() const;
|
const std::vector<DynamicProfileRule> &getRules() const;
|
||||||
void setRules(const std::vector<DynamicProfileRule> &r);
|
void setRules (const std::vector<DynamicProfileRule> &r);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _DYNAMICPROFILE_H_
|
#endif // _DYNAMICPROFILE_H_
|
||||||
|
@ -25,10 +25,10 @@
|
|||||||
using namespace rtengine;
|
using namespace rtengine;
|
||||||
using namespace rtengine::procparams;
|
using namespace rtengine::procparams;
|
||||||
|
|
||||||
ProfileStore::ProfileStore () : storeState(STORESTATE_NOTINITIALIZED), internalDefaultProfile(nullptr), internalDefaultEntry(nullptr), internalDynamicEntry(nullptr), loadAll(true)
|
ProfileStore::ProfileStore () : storeState (STORESTATE_NOTINITIALIZED), internalDefaultProfile (nullptr), internalDefaultEntry (nullptr), internalDynamicEntry (nullptr), loadAll (true)
|
||||||
{
|
{
|
||||||
internalDefaultProfile = new AutoPartialProfile();
|
internalDefaultProfile = new AutoPartialProfile();
|
||||||
internalDefaultProfile->set(true);
|
internalDefaultProfile->set (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfileStore* ProfileStore::getInstance()
|
ProfileStore* ProfileStore::getInstance()
|
||||||
@ -65,7 +65,7 @@ ProfileStore::~ProfileStore ()
|
|||||||
storeState = STORESTATE_DELETED;
|
storeState = STORESTATE_DELETED;
|
||||||
|
|
||||||
{
|
{
|
||||||
MyMutex::MyLock lock(parseMutex);
|
MyMutex::MyLock lock (parseMutex);
|
||||||
|
|
||||||
clearProfileList ();
|
clearProfileList ();
|
||||||
partProfiles.clear ();
|
partProfiles.clear ();
|
||||||
@ -107,14 +107,14 @@ void ProfileStore::_parseProfiles ()
|
|||||||
clearFileList();
|
clearFileList();
|
||||||
clearProfileList ();
|
clearProfileList ();
|
||||||
|
|
||||||
folders.push_back("<<< ROOT >>>"); // Fake path, so parentFolderId == 0 will be used to attach a ProfileStoreEntry to the root container, not sub-menu
|
folders.push_back ("<<< ROOT >>>"); // Fake path, so parentFolderId == 0 will be used to attach a ProfileStoreEntry to the root container, not sub-menu
|
||||||
|
|
||||||
Glib::ustring p1 = options.getUserProfilePath();
|
Glib::ustring p1 = options.getUserProfilePath();
|
||||||
Glib::ustring p2 = options.getGlobalProfilePath();
|
Glib::ustring p2 = options.getGlobalProfilePath();
|
||||||
bool displayLevel0 = options.useBundledProfiles && !p1.empty() && !p2.empty() && p1 != p2;
|
bool displayLevel0 = options.useBundledProfiles && !p1.empty() && !p2.empty() && p1 != p2;
|
||||||
|
|
||||||
Glib::ustring virtualPath("${U}");
|
Glib::ustring virtualPath ("${U}");
|
||||||
Glib::ustring currDir("${U}");
|
Glib::ustring currDir ("${U}");
|
||||||
parseDir (p1, virtualPath, currDir, 0, 0, displayLevel0);
|
parseDir (p1, virtualPath, currDir, 0, 0, displayLevel0);
|
||||||
|
|
||||||
if (displayLevel0) {
|
if (displayLevel0) {
|
||||||
@ -124,35 +124,35 @@ void ProfileStore::_parseProfiles ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// sort profiles
|
// sort profiles
|
||||||
std::sort(entries.begin(), entries.end(), SortProfiles() );
|
std::sort (entries.begin(), entries.end(), SortProfiles() );
|
||||||
|
|
||||||
// entries and partProfiles are empty, but the entry and profiles already exist (they have survived to clearFileList and clearProfileList)
|
// entries and partProfiles are empty, but the entry and profiles already exist (they have survived to clearFileList and clearProfileList)
|
||||||
if (!internalDefaultEntry) {
|
if (!internalDefaultEntry) {
|
||||||
internalDefaultEntry = new ProfileStoreEntry(Glib::ustring("(") + M("PROFILEPANEL_PINTERNAL") + Glib::ustring(")"), PSET_FILE, 0, 0);
|
internalDefaultEntry = new ProfileStoreEntry (Glib::ustring ("(") + M ("PROFILEPANEL_PINTERNAL") + Glib::ustring (")"), PSET_FILE, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
entries.push_back(internalDefaultEntry);
|
entries.push_back (internalDefaultEntry);
|
||||||
partProfiles[internalDefaultEntry] = internalDefaultProfile;
|
partProfiles[internalDefaultEntry] = internalDefaultProfile;
|
||||||
|
|
||||||
if (!internalDynamicEntry) {
|
if (!internalDynamicEntry) {
|
||||||
internalDynamicEntry = new ProfileStoreEntry(Glib::ustring("(") + M("PROFILEPANEL_PDYNAMIC") + Glib::ustring(")"), PSET_FILE, 0, 0);
|
internalDynamicEntry = new ProfileStoreEntry (Glib::ustring ("(") + M ("PROFILEPANEL_PDYNAMIC") + Glib::ustring (")"), PSET_FILE, 0, 0);
|
||||||
// do not add it to the entries. This is here only for the preferences dialog
|
// do not add it to the entries. This is here only for the preferences dialog
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the default profiles has been found.
|
// Check if the default profiles has been found.
|
||||||
if (findEntryFromFullPathU(options.defProfRaw) == nullptr) {
|
if (findEntryFromFullPathU (options.defProfRaw) == nullptr) {
|
||||||
options.setDefProfRawMissing(true);
|
options.setDefProfRawMissing (true);
|
||||||
|
|
||||||
if (options.rtSettings.verbose) {
|
if (options.rtSettings.verbose) {
|
||||||
printf("WARNING: Default profile \"%s\" for raw images not found!\n", options.defProfRaw.c_str());
|
printf ("WARNING: Default profile \"%s\" for raw images not found!\n", options.defProfRaw.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (findEntryFromFullPathU(options.defProfImg) == nullptr) {
|
if (findEntryFromFullPathU (options.defProfImg) == nullptr) {
|
||||||
options.setDefProfImgMissing(true);
|
options.setDefProfImgMissing (true);
|
||||||
|
|
||||||
if (options.rtSettings.verbose) {
|
if (options.rtSettings.verbose) {
|
||||||
printf("WARNING: Default profile \"%s\" for standard images not found!\n", options.defProfImg.c_str());
|
printf ("WARNING: Default profile \"%s\" for standard images not found!\n", options.defProfImg.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -163,23 +163,23 @@ bool ProfileStore::parseDir (Glib::ustring& realPath, Glib::ustring& virtualPath
|
|||||||
bool fileFound = false;
|
bool fileFound = false;
|
||||||
|
|
||||||
// reload the available profiles from the profile dir
|
// reload the available profiles from the profile dir
|
||||||
if (!realPath.empty() && Glib::file_test(realPath, Glib::FILE_TEST_EXISTS) && Glib::file_test (realPath, Glib::FILE_TEST_IS_DIR)) {
|
if (!realPath.empty() && Glib::file_test (realPath, Glib::FILE_TEST_EXISTS) && Glib::file_test (realPath, Glib::FILE_TEST_IS_DIR)) {
|
||||||
unsigned int folder = 0; // folder's own Id
|
unsigned int folder = 0; // folder's own Id
|
||||||
|
|
||||||
// add this entry to the folder list
|
// add this entry to the folder list
|
||||||
folders.push_back(virtualPath);
|
folders.push_back (virtualPath);
|
||||||
folder = (unsigned int)(folders.size()) - 1;
|
folder = (unsigned int) (folders.size()) - 1;
|
||||||
|
|
||||||
if (level > 0 || displayLevel0) {
|
if (level > 0 || displayLevel0) {
|
||||||
// replace the virtual folder name by a localized text
|
// replace the virtual folder name by a localized text
|
||||||
if (currDir == "${U}") {
|
if (currDir == "${U}") {
|
||||||
currDir = M("PROFILEPANEL_MYPROFILES");
|
currDir = M ("PROFILEPANEL_MYPROFILES");
|
||||||
} else if (currDir == "${G}") {
|
} else if (currDir == "${G}") {
|
||||||
currDir = M("PROFILEPANEL_GLOBALPROFILES");
|
currDir = M ("PROFILEPANEL_GLOBALPROFILES");
|
||||||
}
|
}
|
||||||
|
|
||||||
// add this localized text to the file list
|
// add this localized text to the file list
|
||||||
entries.push_back( new ProfileStoreEntry(currDir, PSET_FOLDER, parentId, folder) );
|
entries.push_back ( new ProfileStoreEntry (currDir, PSET_FOLDER, parentId, folder) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// walking through the directory
|
// walking through the directory
|
||||||
@ -193,22 +193,22 @@ bool ProfileStore::parseDir (Glib::ustring& realPath, Glib::ustring& virtualPath
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Glib::ustring fname = Glib::build_filename(realPath, currDir);
|
Glib::ustring fname = Glib::build_filename (realPath, currDir);
|
||||||
|
|
||||||
if (Glib::file_test (fname, Glib::FILE_TEST_IS_DIR)) {
|
if (Glib::file_test (fname, Glib::FILE_TEST_IS_DIR)) {
|
||||||
Glib::ustring vp(Glib::build_filename(virtualPath, currDir));
|
Glib::ustring vp (Glib::build_filename (virtualPath, currDir));
|
||||||
Glib::ustring rp(Glib::build_filename(realPath, currDir));
|
Glib::ustring rp (Glib::build_filename (realPath, currDir));
|
||||||
fileFound = parseDir (rp, vp, currDir, folder, level + 1, 0);
|
fileFound = parseDir (rp, vp, currDir, folder, level + 1, 0);
|
||||||
} else {
|
} else {
|
||||||
size_t lastdot = currDir.find_last_of ('.');
|
size_t lastdot = currDir.find_last_of ('.');
|
||||||
|
|
||||||
if (lastdot != Glib::ustring::npos && lastdot == currDir.length() - 4 && currDir.substr(lastdot).casefold() == paramFileExtension) {
|
if (lastdot != Glib::ustring::npos && lastdot == currDir.length() - 4 && currDir.substr (lastdot).casefold() == paramFileExtension) {
|
||||||
// file found
|
// file found
|
||||||
if( options.rtSettings.verbose ) {
|
if ( options.rtSettings.verbose ) {
|
||||||
printf ("Processing file %s...", fname.c_str());
|
printf ("Processing file %s...", fname.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
Glib::ustring name = currDir.substr(0, lastdot);
|
Glib::ustring name = currDir.substr (0, lastdot);
|
||||||
|
|
||||||
// create the partial profile
|
// create the partial profile
|
||||||
AutoPartialProfile *pProf = new AutoPartialProfile();
|
AutoPartialProfile *pProf = new AutoPartialProfile();
|
||||||
@ -217,18 +217,18 @@ bool ProfileStore::parseDir (Glib::ustring& realPath, Glib::ustring& virtualPath
|
|||||||
if (!res && pProf->pparams->ppVersion >= 220) {
|
if (!res && pProf->pparams->ppVersion >= 220) {
|
||||||
fileFound = true;
|
fileFound = true;
|
||||||
|
|
||||||
if( options.rtSettings.verbose ) {
|
if ( options.rtSettings.verbose ) {
|
||||||
printf ("OK\n");
|
printf ("OK\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// adding this file to the list
|
// adding this file to the list
|
||||||
ProfileStoreEntry* filePSE = new ProfileStoreEntry(name, PSET_FILE, folder, 0);
|
ProfileStoreEntry* filePSE = new ProfileStoreEntry (name, PSET_FILE, folder, 0);
|
||||||
entries.push_back(filePSE);
|
entries.push_back (filePSE);
|
||||||
|
|
||||||
// map the partial profile
|
// map the partial profile
|
||||||
partProfiles[filePSE] = pProf;
|
partProfiles[filePSE] = pProf;
|
||||||
//partProfiles.insert( std::pair<ProfileStoreEntry*, rtengine::procparams::AutoPartialProfile*> (filePSE, pProf) );
|
//partProfiles.insert( std::pair<ProfileStoreEntry*, rtengine::procparams::AutoPartialProfile*> (filePSE, pProf) );
|
||||||
} else if( options.rtSettings.verbose ) {
|
} else if ( options.rtSettings.verbose ) {
|
||||||
printf ("failed!\n");
|
printf ("failed!\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -247,7 +247,7 @@ bool ProfileStore::parseDir (Glib::ustring& realPath, Glib::ustring& virtualPath
|
|||||||
return fileFound;
|
return fileFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ProfileStore::findFolderId(const Glib::ustring &path)
|
int ProfileStore::findFolderId (const Glib::ustring &path)
|
||||||
{
|
{
|
||||||
// initialization must have been done when calling this
|
// initialization must have been done when calling this
|
||||||
for (std::vector<Glib::ustring>::iterator i = folders.begin(); i != folders.end(); ++i) {
|
for (std::vector<Glib::ustring>::iterator i = folders.begin(); i != folders.end(); ++i) {
|
||||||
@ -265,7 +265,7 @@ int ProfileStore::findFolderId(const Glib::ustring &path)
|
|||||||
* but have to begin with a virtual location ( ${G} or ${U} )
|
* but have to begin with a virtual location ( ${G} or ${U} )
|
||||||
* Will return null on invalid path or if the entry can't be found
|
* Will return null on invalid path or if the entry can't be found
|
||||||
*/
|
*/
|
||||||
const ProfileStoreEntry* ProfileStore::findEntryFromFullPathU(Glib::ustring path)
|
const ProfileStoreEntry* ProfileStore::findEntryFromFullPathU (Glib::ustring path)
|
||||||
{
|
{
|
||||||
if (path.empty()) {
|
if (path.empty()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -281,37 +281,37 @@ const ProfileStoreEntry* ProfileStore::findEntryFromFullPathU(Glib::ustring path
|
|||||||
|
|
||||||
// consistently apply casefold() to make sure dot position is correct
|
// consistently apply casefold() to make sure dot position is correct
|
||||||
const Glib::ustring casefolded_path = path.casefold();
|
const Glib::ustring casefolded_path = path.casefold();
|
||||||
const Glib::ustring::size_type lastdot_pos = casefolded_path.find_last_of('.');
|
const Glib::ustring::size_type lastdot_pos = casefolded_path.find_last_of ('.');
|
||||||
|
|
||||||
if (
|
if (
|
||||||
lastdot_pos != Glib::ustring::npos
|
lastdot_pos != Glib::ustring::npos
|
||||||
&& lastdot_pos <= casefolded_path.size() - 4
|
&& lastdot_pos <= casefolded_path.size() - 4
|
||||||
&& !casefolded_path.compare(lastdot_pos, 4, paramFileExtension)
|
&& !casefolded_path.compare (lastdot_pos, 4, paramFileExtension)
|
||||||
) {
|
) {
|
||||||
// removing the extension
|
// removing the extension
|
||||||
// now use dot position without casefold()
|
// now use dot position without casefold()
|
||||||
path = path.substr(0, path.find_last_of('.'));
|
path = path.substr (0, path.find_last_of ('.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// dir separator may come from options file and may be \ or /, we convert them to G_DIR_SEPARATOR_S
|
// dir separator may come from options file and may be \ or /, we convert them to G_DIR_SEPARATOR_S
|
||||||
if (path.size() > 4 && (path[4] == '/' || path[4] == '\\')) {
|
if (path.size() > 4 && (path[4] == '/' || path[4] == '\\')) {
|
||||||
path = path.substr(0, 4) + G_DIR_SEPARATOR_S + path.substr(5);
|
path = path.substr (0, 4) + G_DIR_SEPARATOR_S + path.substr (5);
|
||||||
}
|
}
|
||||||
|
|
||||||
// removing the filename
|
// removing the filename
|
||||||
Glib::ustring fName = Glib::path_get_basename(path);
|
Glib::ustring fName = Glib::path_get_basename (path);
|
||||||
|
|
||||||
if (!fName.empty()) {
|
if (!fName.empty()) {
|
||||||
path = path.substr(0, path.length() - fName.length());
|
path = path.substr (0, path.length() - fName.length());
|
||||||
} else {
|
} else {
|
||||||
// path is malformed, returning NULL;
|
// path is malformed, returning NULL;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
path = Glib::path_get_dirname(path);
|
path = Glib::path_get_dirname (path);
|
||||||
|
|
||||||
// 1. find the path in the folder list
|
// 1. find the path in the folder list
|
||||||
int parentFolderId = findFolderId(path);
|
int parentFolderId = findFolderId (path);
|
||||||
|
|
||||||
if (parentFolderId == -1) {
|
if (parentFolderId == -1) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -330,10 +330,10 @@ const ProfileStoreEntry* ProfileStore::findEntryFromFullPathU(Glib::ustring path
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Protected version of findEntryFromFullPathU */
|
/** Protected version of findEntryFromFullPathU */
|
||||||
const ProfileStoreEntry* ProfileStore::findEntryFromFullPath(Glib::ustring path)
|
const ProfileStoreEntry* ProfileStore::findEntryFromFullPath (Glib::ustring path)
|
||||||
{
|
{
|
||||||
MyMutex::MyLock lock(parseMutex);
|
MyMutex::MyLock lock (parseMutex);
|
||||||
return findEntryFromFullPathU(path);
|
return findEntryFromFullPathU (path);
|
||||||
}
|
}
|
||||||
|
|
||||||
const PartialProfile* ProfileStore::getProfile (Glib::ustring path)
|
const PartialProfile* ProfileStore::getProfile (Glib::ustring path)
|
||||||
@ -343,13 +343,13 @@ const PartialProfile* ProfileStore::getProfile (Glib::ustring path)
|
|||||||
parseProfiles();
|
parseProfiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
const ProfileStoreEntry *pse = findEntryFromFullPath(path);
|
const ProfileStoreEntry *pse = findEntryFromFullPath (path);
|
||||||
|
|
||||||
if (!pse) {
|
if (!pse) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return getProfile(pse);
|
return getProfile (pse);
|
||||||
}
|
}
|
||||||
|
|
||||||
const PartialProfile* ProfileStore::getProfile (const ProfileStoreEntry* entry)
|
const PartialProfile* ProfileStore::getProfile (const ProfileStoreEntry* entry)
|
||||||
@ -359,20 +359,20 @@ const PartialProfile* ProfileStore::getProfile (const ProfileStoreEntry* entry)
|
|||||||
parseProfiles();
|
parseProfiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
MyMutex::MyLock lock(parseMutex);
|
MyMutex::MyLock lock (parseMutex);
|
||||||
|
|
||||||
if (entry == internalDefaultEntry) {
|
if (entry == internalDefaultEntry) {
|
||||||
return internalDefaultProfile;
|
return internalDefaultProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<const ProfileStoreEntry*, rtengine::procparams::AutoPartialProfile*>::iterator iter = partProfiles.find(entry);
|
std::map<const ProfileStoreEntry*, rtengine::procparams::AutoPartialProfile*>::iterator iter = partProfiles.find (entry);
|
||||||
|
|
||||||
if (iter != partProfiles.end()) {
|
if (iter != partProfiles.end()) {
|
||||||
return iter->second;
|
return iter->second;
|
||||||
} else {
|
} else {
|
||||||
// This shouldn't happen!
|
// This shouldn't happen!
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
printf("WARNING! Profile not found!\n");
|
printf ("WARNING! Profile not found!\n");
|
||||||
#endif
|
#endif
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -440,10 +440,10 @@ const PartialProfile* ProfileStore::getDefaultPartialProfile (bool isRaw)
|
|||||||
return pProf;
|
return pProf;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Glib::ustring ProfileStore::getPathFromId(int folderId)
|
const Glib::ustring ProfileStore::getPathFromId (int folderId)
|
||||||
{
|
{
|
||||||
// initialization must have been done when calling this
|
// initialization must have been done when calling this
|
||||||
return folders.at(folderId);
|
return folders.at (folderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -469,60 +469,63 @@ void ProfileStore::clearProfileList()
|
|||||||
partProfiles.clear();
|
partProfiles.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileStore::addListener(ProfileStoreListener *listener)
|
void ProfileStore::addListener (ProfileStoreListener *listener)
|
||||||
{
|
{
|
||||||
listeners.push_back(listener);
|
listeners.push_back (listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileStore::removeListener(ProfileStoreListener *listener)
|
void ProfileStore::removeListener (ProfileStoreListener *listener)
|
||||||
{
|
{
|
||||||
listeners.remove(listener);
|
listeners.remove (listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileStore::dumpFolderList()
|
void ProfileStore::dumpFolderList()
|
||||||
{
|
{
|
||||||
printf("Folder list:\n------------\n");
|
printf ("Folder list:\n------------\n");
|
||||||
|
|
||||||
for (unsigned int i = 0; i < folders.size(); i++) {
|
for (unsigned int i = 0; i < folders.size(); i++) {
|
||||||
printf(" #%3ud - %s\n", i, folders.at(i).c_str());
|
printf (" #%3ud - %s\n", i, folders.at (i).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\n");
|
printf ("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
PartialProfile *ProfileStore::loadDynamicProfile(const ImageMetaData *im)
|
PartialProfile *ProfileStore::loadDynamicProfile (const ImageMetaData *im)
|
||||||
{
|
{
|
||||||
if (storeState == STORESTATE_NOTINITIALIZED) {
|
if (storeState == STORESTATE_NOTINITIALIZED) {
|
||||||
parseProfiles();
|
parseProfiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
PartialProfile *ret = new PartialProfile(true, true);
|
PartialProfile *ret = new PartialProfile (true, true);
|
||||||
|
|
||||||
if (!rulesLoaded) {
|
if (!rulesLoaded) {
|
||||||
loadRules();
|
loadRules();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto rule : dynamicRules) {
|
for (auto rule : dynamicRules) {
|
||||||
if (rule.matches(im)) {
|
if (rule.matches (im)) {
|
||||||
if (options.rtSettings.verbose) {
|
if (options.rtSettings.verbose) {
|
||||||
printf("found matching profile %s\n", rule.profilepath.c_str());
|
printf ("found matching profile %s\n", rule.profilepath.c_str());
|
||||||
}
|
}
|
||||||
const PartialProfile *p = getProfile(rule.profilepath);
|
|
||||||
|
const PartialProfile *p = getProfile (rule.profilepath);
|
||||||
|
|
||||||
if (p != nullptr) {
|
if (p != nullptr) {
|
||||||
p->applyTo(ret->pparams);
|
p->applyTo (ret->pparams);
|
||||||
} else {
|
} else {
|
||||||
printf("ERROR loading matching profile from: %s\n", rule.profilepath.c_str());
|
printf ("ERROR loading matching profile from: %s\n", rule.profilepath.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfileStoreEntry::ProfileStoreEntry() : label(""), type(PSET_FOLDER), parentFolderId(0), folderId(0) {}
|
ProfileStoreEntry::ProfileStoreEntry() : label (""), type (PSET_FOLDER), parentFolderId (0), folderId (0) {}
|
||||||
|
|
||||||
ProfileStoreEntry::ProfileStoreEntry(Glib::ustring label, PSEType type, unsigned short parentFolder, unsigned short folder) : label(label), type(type), parentFolderId(parentFolder), folderId(folder) {}
|
ProfileStoreEntry::ProfileStoreEntry (Glib::ustring label, PSEType type, unsigned short parentFolder, unsigned short folder) : label (label), type (type), parentFolderId (parentFolder), folderId (folder) {}
|
||||||
|
|
||||||
void ProfileStoreEntry::setValues(Glib::ustring label, PSEType type, unsigned short parentFolder, unsigned short folder)
|
void ProfileStoreEntry::setValues (Glib::ustring label, PSEType type, unsigned short parentFolder, unsigned short folder)
|
||||||
{
|
{
|
||||||
this->label = label;
|
this->label = label;
|
||||||
this->type = type;
|
this->type = type;
|
||||||
|
@ -81,7 +81,7 @@ public:
|
|||||||
* @param parentFolder index of the elements's path in the folder list
|
* @param parentFolder index of the elements's path in the folder list
|
||||||
* @param folder index of the folder's own path in the folder list
|
* @param folder index of the folder's own path in the folder list
|
||||||
*/
|
*/
|
||||||
ProfileStoreEntry(Glib::ustring label, PSEType type, unsigned short parentFolder, unsigned short folder);
|
ProfileStoreEntry (Glib::ustring label, PSEType type, unsigned short parentFolder, unsigned short folder);
|
||||||
|
|
||||||
/** @brief Set the values of the object after its instantiation
|
/** @brief Set the values of the object after its instantiation
|
||||||
* @param label Label to be used in menu or combobox; also used as profile's filename
|
* @param label Label to be used in menu or combobox; also used as profile's filename
|
||||||
@ -89,7 +89,7 @@ public:
|
|||||||
* @param parentFolder index of the elements's path in the folder list
|
* @param parentFolder index of the elements's path in the folder list
|
||||||
* @param folder index of the folder's own path in the folder list
|
* @param folder index of the folder's own path in the folder list
|
||||||
*/
|
*/
|
||||||
void setValues(Glib::ustring label, PSEType type, unsigned short parentFolder, unsigned short folder);
|
void setValues (Glib::ustring label, PSEType type, unsigned short parentFolder, unsigned short folder);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ class ProfileStore : public rtengine::NonCopyable, public DynamicProfileRules
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
struct SortProfiles {
|
struct SortProfiles {
|
||||||
bool operator ()(const ProfileStoreEntry* const a1, const ProfileStoreEntry* const a2)
|
bool operator () (const ProfileStoreEntry* const a1, const ProfileStoreEntry* const a2)
|
||||||
{
|
{
|
||||||
return a1->parentFolderId == a2->parentFolderId ? a1->label < a2->label : a1->parentFolderId < a2->parentFolderId;
|
return a1->parentFolderId == a2->parentFolderId ? a1->label < a2->label : a1->parentFolderId < a2->parentFolderId;
|
||||||
}
|
}
|
||||||
@ -156,7 +156,7 @@ private:
|
|||||||
void _parseProfiles ();
|
void _parseProfiles ();
|
||||||
void clearFileList ();
|
void clearFileList ();
|
||||||
void clearProfileList ();
|
void clearProfileList ();
|
||||||
const ProfileStoreEntry* findEntryFromFullPathU(Glib::ustring path);
|
const ProfileStoreEntry* findEntryFromFullPathU (Glib::ustring path);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -167,15 +167,15 @@ public:
|
|||||||
|
|
||||||
bool init (bool loadAll = true);
|
bool init (bool loadAll = true);
|
||||||
void parseProfiles ();
|
void parseProfiles ();
|
||||||
int findFolderId(const Glib::ustring &path);
|
int findFolderId (const Glib::ustring &path);
|
||||||
const ProfileStoreEntry* findEntryFromFullPath(Glib::ustring path);
|
const ProfileStoreEntry* findEntryFromFullPath (Glib::ustring path);
|
||||||
const rtengine::procparams::PartialProfile* getProfile (Glib::ustring path);
|
const rtengine::procparams::PartialProfile* getProfile (Glib::ustring path);
|
||||||
const rtengine::procparams::PartialProfile* getProfile (const ProfileStoreEntry* entry);
|
const rtengine::procparams::PartialProfile* getProfile (const ProfileStoreEntry* entry);
|
||||||
const std::vector<const ProfileStoreEntry*>* getFileList ();
|
const std::vector<const ProfileStoreEntry*>* getFileList ();
|
||||||
void releaseFileList ();
|
void releaseFileList ();
|
||||||
const rtengine::procparams::ProcParams* getDefaultProcParams (bool isRaw);
|
const rtengine::procparams::ProcParams* getDefaultProcParams (bool isRaw);
|
||||||
const rtengine::procparams::PartialProfile* getDefaultPartialProfile (bool isRaw);
|
const rtengine::procparams::PartialProfile* getDefaultPartialProfile (bool isRaw);
|
||||||
const Glib::ustring getPathFromId(int folderId);
|
const Glib::ustring getPathFromId (int folderId);
|
||||||
const ProfileStoreEntry* getInternalDefaultPSE()
|
const ProfileStoreEntry* getInternalDefaultPSE()
|
||||||
{
|
{
|
||||||
return internalDefaultEntry;
|
return internalDefaultEntry;
|
||||||
@ -186,10 +186,10 @@ public:
|
|||||||
return internalDynamicEntry;
|
return internalDynamicEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addListener(ProfileStoreListener *listener);
|
void addListener (ProfileStoreListener *listener);
|
||||||
void removeListener(ProfileStoreListener *listener);
|
void removeListener (ProfileStoreListener *listener);
|
||||||
|
|
||||||
rtengine::procparams::PartialProfile* loadDynamicProfile(const rtengine::ImageMetaData *im);
|
rtengine::procparams::PartialProfile* loadDynamicProfile (const rtengine::ImageMetaData *im);
|
||||||
|
|
||||||
void dumpFolderList();
|
void dumpFolderList();
|
||||||
};
|
};
|
||||||
|
@ -30,28 +30,26 @@
|
|||||||
// DynamicProfilePanel::EditDialog
|
// DynamicProfilePanel::EditDialog
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
DynamicProfilePanel::EditDialog::EditDialog(const Glib::ustring &title,
|
DynamicProfilePanel::EditDialog::EditDialog (const Glib::ustring &title, Gtk::Window &parent):
|
||||||
Gtk::Window &parent):
|
Gtk::Dialog (title, parent)
|
||||||
Gtk::Dialog(title, parent)
|
|
||||||
{
|
{
|
||||||
profilepath_ = Gtk::manage(new ProfileStoreComboBox());
|
profilepath_ = Gtk::manage (new ProfileStoreComboBox());
|
||||||
Gtk::HBox *hb = Gtk::manage(new Gtk::HBox());
|
Gtk::HBox *hb = Gtk::manage (new Gtk::HBox());
|
||||||
hb->pack_start(*Gtk::manage(new Gtk::Label(M("DYNPROFILEEDITOR_PROFILE"))),
|
hb->pack_start (*Gtk::manage (new Gtk::Label (M ("DYNPROFILEEDITOR_PROFILE"))), false, false, 4);
|
||||||
false, false, 4);
|
hb->pack_start (*profilepath_, true, true, 2);
|
||||||
hb->pack_start(*profilepath_, true, true, 2);
|
get_content_area()->pack_start (*hb, Gtk::PACK_SHRINK, 4);
|
||||||
get_content_area()->pack_start(*hb, Gtk::PACK_SHRINK, 4);
|
|
||||||
|
|
||||||
add_optional(M("EXIFFILTER_CAMERA"), has_camera_, camera_);
|
add_optional (M ("EXIFFILTER_CAMERA"), has_camera_, camera_);
|
||||||
add_optional(M("EXIFFILTER_LENS"), has_lens_, lens_);
|
add_optional (M ("EXIFFILTER_LENS"), has_lens_, lens_);
|
||||||
|
|
||||||
add_range(M("EXIFFILTER_ISO"), iso_min_, iso_max_);
|
add_range (M ("EXIFFILTER_ISO"), iso_min_, iso_max_);
|
||||||
add_range(M("EXIFFILTER_APERTURE"), fnumber_min_, fnumber_max_);
|
add_range (M ("EXIFFILTER_APERTURE"), fnumber_min_, fnumber_max_);
|
||||||
add_range(M("EXIFFILTER_FOCALLEN"), focallen_min_, focallen_max_);
|
add_range (M ("EXIFFILTER_FOCALLEN"), focallen_min_, focallen_max_);
|
||||||
add_range(M("EXIFFILTER_SHUTTER"), shutterspeed_min_, shutterspeed_max_);
|
add_range (M ("EXIFFILTER_SHUTTER"), shutterspeed_min_, shutterspeed_max_);
|
||||||
add_range(M("EXIFFILTER_EXPOSURECOMPENSATION"), expcomp_min_, expcomp_max_);
|
add_range (M ("EXIFFILTER_EXPOSURECOMPENSATION"), expcomp_min_, expcomp_max_);
|
||||||
|
|
||||||
add_button(M("GENERAL_OK"), 1);
|
add_button (M ("GENERAL_OK"), 1);
|
||||||
add_button(M("GENERAL_CANCEL"), 2);
|
add_button (M ("GENERAL_CANCEL"), 2);
|
||||||
|
|
||||||
set_ranges();
|
set_ranges();
|
||||||
|
|
||||||
@ -59,37 +57,37 @@ DynamicProfilePanel::EditDialog::EditDialog(const Glib::ustring &title,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DynamicProfilePanel::EditDialog::set_rule(
|
void DynamicProfilePanel::EditDialog::set_rule (
|
||||||
const DynamicProfileRule &rule)
|
const DynamicProfileRule &rule)
|
||||||
{
|
{
|
||||||
iso_min_->set_value(rule.iso.min);
|
iso_min_->set_value (rule.iso.min);
|
||||||
iso_max_->set_value(rule.iso.max);
|
iso_max_->set_value (rule.iso.max);
|
||||||
|
|
||||||
fnumber_min_->set_value(rule.fnumber.min);
|
fnumber_min_->set_value (rule.fnumber.min);
|
||||||
fnumber_max_->set_value(rule.fnumber.max);
|
fnumber_max_->set_value (rule.fnumber.max);
|
||||||
|
|
||||||
focallen_min_->set_value(rule.focallen.min);
|
focallen_min_->set_value (rule.focallen.min);
|
||||||
focallen_max_->set_value(rule.focallen.max);
|
focallen_max_->set_value (rule.focallen.max);
|
||||||
|
|
||||||
shutterspeed_min_->set_value(rule.shutterspeed.min);
|
shutterspeed_min_->set_value (rule.shutterspeed.min);
|
||||||
shutterspeed_max_->set_value(rule.shutterspeed.max);
|
shutterspeed_max_->set_value (rule.shutterspeed.max);
|
||||||
|
|
||||||
expcomp_min_->set_value(rule.expcomp.min);
|
expcomp_min_->set_value (rule.expcomp.min);
|
||||||
expcomp_max_->set_value(rule.expcomp.max);
|
expcomp_max_->set_value (rule.expcomp.max);
|
||||||
|
|
||||||
has_camera_->set_active(rule.camera.enabled);
|
has_camera_->set_active (rule.camera.enabled);
|
||||||
camera_->set_text(rule.camera.value);
|
camera_->set_text (rule.camera.value);
|
||||||
|
|
||||||
has_lens_->set_active(rule.lens.enabled);
|
has_lens_->set_active (rule.lens.enabled);
|
||||||
lens_->set_text(rule.lens.value);
|
lens_->set_text (rule.lens.value);
|
||||||
|
|
||||||
profilepath_->updateProfileList();
|
profilepath_->updateProfileList();
|
||||||
if (!profilepath_->setActiveRowFromFullPath(rule.profilepath)) {
|
|
||||||
|
if (!profilepath_->setActiveRowFromFullPath (rule.profilepath)) {
|
||||||
profilepath_->setInternalEntry();
|
profilepath_->setInternalEntry();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DynamicProfileRule DynamicProfilePanel::EditDialog::get_rule()
|
DynamicProfileRule DynamicProfilePanel::EditDialog::get_rule()
|
||||||
{
|
{
|
||||||
DynamicProfileRule ret;
|
DynamicProfileRule ret;
|
||||||
@ -122,14 +120,14 @@ DynamicProfileRule DynamicProfilePanel::EditDialog::get_rule()
|
|||||||
void DynamicProfilePanel::EditDialog::set_ranges()
|
void DynamicProfilePanel::EditDialog::set_ranges()
|
||||||
{
|
{
|
||||||
DynamicProfileRule default_rule;
|
DynamicProfileRule default_rule;
|
||||||
iso_min_->set_digits(0);
|
iso_min_->set_digits (0);
|
||||||
iso_max_->set_digits(0);
|
iso_max_->set_digits (0);
|
||||||
iso_min_->set_increments(1, 10);
|
iso_min_->set_increments (1, 10);
|
||||||
iso_max_->set_increments(1, 10);
|
iso_max_->set_increments (1, 10);
|
||||||
iso_min_->set_range(default_rule.iso.min, default_rule.iso.max);
|
iso_min_->set_range (default_rule.iso.min, default_rule.iso.max);
|
||||||
iso_max_->set_range(default_rule.iso.min, default_rule.iso.max);
|
iso_max_->set_range (default_rule.iso.min, default_rule.iso.max);
|
||||||
iso_min_->set_value(default_rule.iso.min);
|
iso_min_->set_value (default_rule.iso.min);
|
||||||
iso_max_->set_value(default_rule.iso.max);
|
iso_max_->set_value (default_rule.iso.max);
|
||||||
|
|
||||||
#define DOIT_(name) \
|
#define DOIT_(name) \
|
||||||
name ## _min_->set_digits(1); \
|
name ## _min_->set_digits(1); \
|
||||||
@ -143,45 +141,42 @@ void DynamicProfilePanel::EditDialog::set_ranges()
|
|||||||
name ## _min_->set_value(default_rule. name .min); \
|
name ## _min_->set_value(default_rule. name .min); \
|
||||||
name ## _max_->set_value(default_rule. name .max)
|
name ## _max_->set_value(default_rule. name .max)
|
||||||
|
|
||||||
DOIT_(fnumber);
|
DOIT_ (fnumber);
|
||||||
DOIT_(focallen);
|
DOIT_ (focallen);
|
||||||
DOIT_(shutterspeed);
|
DOIT_ (shutterspeed);
|
||||||
DOIT_(expcomp);
|
DOIT_ (expcomp);
|
||||||
#undef DOIT_
|
#undef DOIT_
|
||||||
shutterspeed_min_->set_digits(4);
|
shutterspeed_min_->set_digits (4);
|
||||||
shutterspeed_max_->set_digits(4);
|
shutterspeed_max_->set_digits (4);
|
||||||
|
|
||||||
profilepath_->setInternalEntry();
|
profilepath_->setInternalEntry();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DynamicProfilePanel::EditDialog::add_range(const Glib::ustring &name,
|
void DynamicProfilePanel::EditDialog::add_range (const Glib::ustring &name,
|
||||||
Gtk::SpinButton *&from, Gtk::SpinButton *&to)
|
Gtk::SpinButton *&from, Gtk::SpinButton *&to)
|
||||||
{
|
{
|
||||||
Gtk::HBox *hb = Gtk::manage(new Gtk::HBox());
|
Gtk::HBox *hb = Gtk::manage (new Gtk::HBox());
|
||||||
hb->pack_start(*Gtk::manage(new Gtk::Label(name)), false, false, 4);
|
hb->pack_start (*Gtk::manage (new Gtk::Label (name)), false, false, 4);
|
||||||
from = Gtk::manage(new Gtk::SpinButton());
|
from = Gtk::manage (new Gtk::SpinButton());
|
||||||
to = Gtk::manage(new Gtk::SpinButton());
|
to = Gtk::manage (new Gtk::SpinButton());
|
||||||
from->set_numeric(true);
|
from->set_numeric (true);
|
||||||
to->set_numeric(true);
|
to->set_numeric (true);
|
||||||
hb->pack_start(*from, true, true, 2);
|
hb->pack_start (*from, true, true, 2);
|
||||||
hb->pack_start(*Gtk::manage(new Gtk::Label(" - ")),
|
hb->pack_start (*Gtk::manage (new Gtk::Label (" - ")), false, false, 4);
|
||||||
false, false, 4);
|
hb->pack_start (*to, true, true, 2);
|
||||||
hb->pack_start(*to, true, true, 2);
|
get_content_area()->pack_start (*hb, Gtk::PACK_SHRINK, 4);
|
||||||
get_content_area()->pack_start(*hb, Gtk::PACK_SHRINK, 4);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DynamicProfilePanel::EditDialog::add_optional (const Glib::ustring &name, Gtk::CheckButton *&check, Gtk::Entry *&field)
|
||||||
void DynamicProfilePanel::EditDialog::add_optional(const Glib::ustring &name,
|
|
||||||
Gtk::CheckButton *&check, Gtk::Entry *&field)
|
|
||||||
{
|
{
|
||||||
check = Gtk::manage (new Gtk::CheckButton(name));
|
check = Gtk::manage (new Gtk::CheckButton (name));
|
||||||
Gtk::HBox *hb = Gtk::manage(new Gtk::HBox());
|
Gtk::HBox *hb = Gtk::manage (new Gtk::HBox());
|
||||||
hb->pack_start(*check, Gtk::PACK_SHRINK, 4);
|
hb->pack_start (*check, Gtk::PACK_SHRINK, 4);
|
||||||
field = Gtk::manage(new Gtk::Entry());
|
field = Gtk::manage (new Gtk::Entry());
|
||||||
hb->pack_start(*field, true, true, 2);
|
hb->pack_start (*field, true, true, 2);
|
||||||
get_content_area()->pack_start(*hb, Gtk::PACK_SHRINK, 4);
|
get_content_area()->pack_start (*hb, Gtk::PACK_SHRINK, 4);
|
||||||
field->set_tooltip_text(M("DYNPROFILEEDITOR_ENTRY_TOOLTIP"));
|
field->set_tooltip_text (M ("DYNPROFILEEDITOR_ENTRY_TOOLTIP"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -190,121 +185,135 @@ void DynamicProfilePanel::EditDialog::add_optional(const Glib::ustring &name,
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
DynamicProfilePanel::DynamicProfilePanel():
|
DynamicProfilePanel::DynamicProfilePanel():
|
||||||
vbox_(Gtk::ORIENTATION_VERTICAL),
|
vbox_ (Gtk::ORIENTATION_VERTICAL),
|
||||||
button_up_(M("DYNPROFILEEDITOR_MOVE_UP")),
|
button_up_ (M ("DYNPROFILEEDITOR_MOVE_UP")),
|
||||||
button_down_(M("DYNPROFILEEDITOR_MOVE_DOWN")),
|
button_down_ (M ("DYNPROFILEEDITOR_MOVE_DOWN")),
|
||||||
button_new_(M("DYNPROFILEEDITOR_NEW")),
|
button_new_ (M ("DYNPROFILEEDITOR_NEW")),
|
||||||
button_edit_(M("DYNPROFILEEDITOR_EDIT")),
|
button_edit_ (M ("DYNPROFILEEDITOR_EDIT")),
|
||||||
button_delete_(M("DYNPROFILEEDITOR_DELETE"))
|
button_delete_ (M ("DYNPROFILEEDITOR_DELETE"))
|
||||||
{
|
{
|
||||||
add(vbox_);
|
add (vbox_);
|
||||||
|
|
||||||
treeview_.set_grid_lines(Gtk::TREE_VIEW_GRID_LINES_VERTICAL);
|
treeview_.set_grid_lines (Gtk::TREE_VIEW_GRID_LINES_VERTICAL);
|
||||||
scrolledwindow_.add(treeview_);
|
scrolledwindow_.add (treeview_);
|
||||||
|
|
||||||
scrolledwindow_.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
|
scrolledwindow_.set_policy (Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
|
||||||
|
|
||||||
vbox_.pack_start(scrolledwindow_);
|
vbox_.pack_start (scrolledwindow_);
|
||||||
vbox_.pack_start(buttonbox_, Gtk::PACK_SHRINK);
|
vbox_.pack_start (buttonbox_, Gtk::PACK_SHRINK);
|
||||||
|
|
||||||
buttonbox_.pack_start(button_new_, Gtk::PACK_SHRINK);
|
buttonbox_.pack_start (button_new_, Gtk::PACK_SHRINK);
|
||||||
buttonbox_.pack_start(button_edit_, Gtk::PACK_SHRINK);
|
buttonbox_.pack_start (button_edit_, Gtk::PACK_SHRINK);
|
||||||
buttonbox_.pack_start(button_delete_, Gtk::PACK_SHRINK);
|
buttonbox_.pack_start (button_delete_, Gtk::PACK_SHRINK);
|
||||||
buttonbox_.pack_start(button_up_, Gtk::PACK_SHRINK);
|
buttonbox_.pack_start (button_up_, Gtk::PACK_SHRINK);
|
||||||
buttonbox_.pack_start(button_down_, Gtk::PACK_SHRINK);
|
buttonbox_.pack_start (button_down_, Gtk::PACK_SHRINK);
|
||||||
buttonbox_.set_border_width(5);
|
buttonbox_.set_border_width (5);
|
||||||
buttonbox_.set_layout(Gtk::BUTTONBOX_END);
|
buttonbox_.set_layout (Gtk::BUTTONBOX_END);
|
||||||
button_up_.signal_clicked().connect(
|
button_up_.signal_clicked().connect (
|
||||||
sigc::mem_fun(*this, &DynamicProfilePanel::on_button_up));
|
sigc::mem_fun (*this, &DynamicProfilePanel::on_button_up));
|
||||||
button_down_.signal_clicked().connect(
|
button_down_.signal_clicked().connect (
|
||||||
sigc::mem_fun(*this, &DynamicProfilePanel::on_button_down));
|
sigc::mem_fun (*this, &DynamicProfilePanel::on_button_down));
|
||||||
button_new_.signal_clicked().connect(
|
button_new_.signal_clicked().connect (
|
||||||
sigc::mem_fun(*this, &DynamicProfilePanel::on_button_new));
|
sigc::mem_fun (*this, &DynamicProfilePanel::on_button_new));
|
||||||
button_edit_.signal_clicked().connect(
|
button_edit_.signal_clicked().connect (
|
||||||
sigc::mem_fun(*this, &DynamicProfilePanel::on_button_edit));
|
sigc::mem_fun (*this, &DynamicProfilePanel::on_button_edit));
|
||||||
button_delete_.signal_clicked().connect(
|
button_delete_.signal_clicked().connect (
|
||||||
sigc::mem_fun(*this, &DynamicProfilePanel::on_button_delete));
|
sigc::mem_fun (*this, &DynamicProfilePanel::on_button_delete));
|
||||||
|
|
||||||
treemodel_ = Gtk::ListStore::create(columns_);
|
treemodel_ = Gtk::ListStore::create (columns_);
|
||||||
treeview_.set_model(treemodel_);
|
treeview_.set_model (treemodel_);
|
||||||
|
|
||||||
|
auto cell = Gtk::manage (new Gtk::CellRendererText());
|
||||||
|
int cols_count = treeview_.append_column ( M ("DYNPROFILEEDITOR_PROFILE"), *cell);
|
||||||
|
auto col = treeview_.get_column (cols_count - 1);
|
||||||
|
|
||||||
auto cell = Gtk::manage(new Gtk::CellRendererText());
|
|
||||||
int cols_count = treeview_.append_column(
|
|
||||||
M("DYNPROFILEEDITOR_PROFILE"), *cell);
|
|
||||||
auto col = treeview_.get_column(cols_count - 1);
|
|
||||||
if (col) {
|
if (col) {
|
||||||
col->set_cell_data_func(
|
col->set_cell_data_func (
|
||||||
*cell, sigc::mem_fun(
|
*cell, sigc::mem_fun (
|
||||||
*this, &DynamicProfilePanel::render_profilepath));
|
*this, &DynamicProfilePanel::render_profilepath));
|
||||||
}
|
}
|
||||||
cell = Gtk::manage(new Gtk::CellRendererText());
|
|
||||||
cols_count = treeview_.append_column(
|
cell = Gtk::manage (new Gtk::CellRendererText());
|
||||||
M("EXIFFILTER_CAMERA"), *cell);
|
cols_count = treeview_.append_column (
|
||||||
col = treeview_.get_column(cols_count - 1);
|
M ("EXIFFILTER_CAMERA"), *cell);
|
||||||
|
col = treeview_.get_column (cols_count - 1);
|
||||||
|
|
||||||
if (col) {
|
if (col) {
|
||||||
col->set_cell_data_func(
|
col->set_cell_data_func (
|
||||||
*cell, sigc::mem_fun(
|
*cell, sigc::mem_fun (
|
||||||
*this, &DynamicProfilePanel::render_camera));
|
*this, &DynamicProfilePanel::render_camera));
|
||||||
}
|
}
|
||||||
cell = Gtk::manage(new Gtk::CellRendererText());
|
|
||||||
cols_count = treeview_.append_column(M("EXIFFILTER_LENS"), *cell);
|
cell = Gtk::manage (new Gtk::CellRendererText());
|
||||||
col = treeview_.get_column(cols_count - 1);
|
cols_count = treeview_.append_column (M ("EXIFFILTER_LENS"), *cell);
|
||||||
|
col = treeview_.get_column (cols_count - 1);
|
||||||
|
|
||||||
if (col) {
|
if (col) {
|
||||||
col->set_cell_data_func(
|
col->set_cell_data_func (
|
||||||
*cell, sigc::mem_fun(
|
*cell, sigc::mem_fun (
|
||||||
*this, &DynamicProfilePanel::render_lens));
|
*this, &DynamicProfilePanel::render_lens));
|
||||||
}
|
}
|
||||||
cell = Gtk::manage(new Gtk::CellRendererText());
|
|
||||||
cols_count = treeview_.append_column(M("EXIFFILTER_ISO"), *cell);
|
cell = Gtk::manage (new Gtk::CellRendererText());
|
||||||
col = treeview_.get_column(cols_count - 1);
|
cols_count = treeview_.append_column (M ("EXIFFILTER_ISO"), *cell);
|
||||||
|
col = treeview_.get_column (cols_count - 1);
|
||||||
|
|
||||||
if (col) {
|
if (col) {
|
||||||
col->set_cell_data_func(
|
col->set_cell_data_func (
|
||||||
*cell, sigc::mem_fun(
|
*cell, sigc::mem_fun (
|
||||||
*this, &DynamicProfilePanel::render_iso));
|
*this, &DynamicProfilePanel::render_iso));
|
||||||
}
|
}
|
||||||
cell = Gtk::manage(new Gtk::CellRendererText());
|
|
||||||
cols_count = treeview_.append_column(M("EXIFFILTER_APERTURE"), *cell);
|
cell = Gtk::manage (new Gtk::CellRendererText());
|
||||||
col = treeview_.get_column(cols_count - 1);
|
cols_count = treeview_.append_column (M ("EXIFFILTER_APERTURE"), *cell);
|
||||||
|
col = treeview_.get_column (cols_count - 1);
|
||||||
|
|
||||||
if (col) {
|
if (col) {
|
||||||
col->set_cell_data_func(
|
col->set_cell_data_func (
|
||||||
*cell, sigc::mem_fun(
|
*cell, sigc::mem_fun (
|
||||||
*this, &DynamicProfilePanel::render_fnumber));
|
*this, &DynamicProfilePanel::render_fnumber));
|
||||||
}
|
}
|
||||||
cell = Gtk::manage(new Gtk::CellRendererText());
|
|
||||||
cols_count = treeview_.append_column(M("EXIFFILTER_FOCALLEN"), *cell);
|
cell = Gtk::manage (new Gtk::CellRendererText());
|
||||||
col = treeview_.get_column(cols_count - 1);
|
cols_count = treeview_.append_column (M ("EXIFFILTER_FOCALLEN"), *cell);
|
||||||
|
col = treeview_.get_column (cols_count - 1);
|
||||||
|
|
||||||
if (col) {
|
if (col) {
|
||||||
col->set_cell_data_func(
|
col->set_cell_data_func (
|
||||||
*cell, sigc::mem_fun(
|
*cell, sigc::mem_fun (
|
||||||
*this, &DynamicProfilePanel::render_focallen));
|
*this, &DynamicProfilePanel::render_focallen));
|
||||||
}
|
}
|
||||||
cell = Gtk::manage(new Gtk::CellRendererText());
|
|
||||||
cols_count = treeview_.append_column(M("EXIFFILTER_SHUTTER"), *cell);
|
cell = Gtk::manage (new Gtk::CellRendererText());
|
||||||
col = treeview_.get_column(cols_count - 1);
|
cols_count = treeview_.append_column (M ("EXIFFILTER_SHUTTER"), *cell);
|
||||||
|
col = treeview_.get_column (cols_count - 1);
|
||||||
|
|
||||||
if (col) {
|
if (col) {
|
||||||
col->set_cell_data_func(
|
col->set_cell_data_func (
|
||||||
*cell, sigc::mem_fun(
|
*cell, sigc::mem_fun (
|
||||||
*this, &DynamicProfilePanel::render_shutterspeed));
|
*this, &DynamicProfilePanel::render_shutterspeed));
|
||||||
}
|
}
|
||||||
cell = Gtk::manage(new Gtk::CellRendererText());
|
|
||||||
cols_count = treeview_.append_column(
|
cell = Gtk::manage (new Gtk::CellRendererText());
|
||||||
M("EXIFFILTER_EXPOSURECOMPENSATION"), *cell);
|
cols_count = treeview_.append_column (
|
||||||
col = treeview_.get_column(cols_count - 1);
|
M ("EXIFFILTER_EXPOSURECOMPENSATION"), *cell);
|
||||||
|
col = treeview_.get_column (cols_count - 1);
|
||||||
|
|
||||||
if (col) {
|
if (col) {
|
||||||
col->set_cell_data_func(
|
col->set_cell_data_func (
|
||||||
*cell, sigc::mem_fun(
|
*cell, sigc::mem_fun (
|
||||||
*this, &DynamicProfilePanel::render_expcomp));
|
*this, &DynamicProfilePanel::render_expcomp));
|
||||||
}
|
}
|
||||||
|
|
||||||
show_all_children();
|
show_all_children();
|
||||||
|
|
||||||
for (auto &r : ProfileStore::getInstance()->getRules()) {
|
for (auto &r : ProfileStore::getInstance()->getRules()) {
|
||||||
add_rule(r);
|
add_rule (r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DynamicProfilePanel::update_rule(Gtk::TreeModel::Row row,
|
void DynamicProfilePanel::update_rule (Gtk::TreeModel::Row row,
|
||||||
const DynamicProfileRule &rule)
|
const DynamicProfileRule &rule)
|
||||||
{
|
{
|
||||||
row[columns_.iso] = rule.iso;
|
row[columns_.iso] = rule.iso;
|
||||||
@ -317,14 +326,14 @@ void DynamicProfilePanel::update_rule(Gtk::TreeModel::Row row,
|
|||||||
row[columns_.profilepath] = rule.profilepath;
|
row[columns_.profilepath] = rule.profilepath;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicProfilePanel::add_rule(const DynamicProfileRule &rule)
|
void DynamicProfilePanel::add_rule (const DynamicProfileRule &rule)
|
||||||
{
|
{
|
||||||
auto row = *(treemodel_->append());
|
auto row = * (treemodel_->append());
|
||||||
update_rule(row, rule);
|
update_rule (row, rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DynamicProfileRule DynamicProfilePanel::to_rule(Gtk::TreeModel::Row row,
|
DynamicProfileRule DynamicProfilePanel::to_rule (Gtk::TreeModel::Row row,
|
||||||
int serial)
|
int serial)
|
||||||
{
|
{
|
||||||
DynamicProfileRule ret;
|
DynamicProfileRule ret;
|
||||||
@ -341,13 +350,14 @@ DynamicProfileRule DynamicProfilePanel::to_rule(Gtk::TreeModel::Row row,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DynamicProfilePanel::render_profilepath(
|
void DynamicProfilePanel::render_profilepath (
|
||||||
Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator &iter)
|
Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator &iter)
|
||||||
{
|
{
|
||||||
auto row = *iter;
|
auto row = *iter;
|
||||||
Gtk::CellRendererText *ct = static_cast<Gtk::CellRendererText *>(cell);
|
Gtk::CellRendererText *ct = static_cast<Gtk::CellRendererText *> (cell);
|
||||||
auto value = row[columns_.profilepath];
|
auto value = row[columns_.profilepath];
|
||||||
auto pse = ProfileStore::getInstance()->findEntryFromFullPath(value);
|
auto pse = ProfileStore::getInstance()->findEntryFromFullPath (value);
|
||||||
|
|
||||||
if (pse != nullptr) {
|
if (pse != nullptr) {
|
||||||
ct->property_text() = pse->label;
|
ct->property_text() = pse->label;
|
||||||
} else {
|
} else {
|
||||||
@ -369,54 +379,56 @@ void DynamicProfilePanel::render_profilepath(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
template <class V>
|
template <class V>
|
||||||
Glib::ustring to_str(V n, int precision=1)
|
Glib::ustring to_str (V n, int precision = 1)
|
||||||
{
|
{
|
||||||
std::ostringstream buf;
|
std::ostringstream buf;
|
||||||
buf << std::setprecision(precision) << std::fixed << n;
|
buf << std::setprecision (precision) << std::fixed << n;
|
||||||
return buf.str();
|
return buf.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void DynamicProfilePanel::render_iso(
|
void DynamicProfilePanel::render_iso (
|
||||||
Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator &iter)
|
Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator &iter)
|
||||||
{
|
{
|
||||||
RENDER_RANGE_(int, iso, to_str);
|
RENDER_RANGE_ (int, iso, to_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DynamicProfilePanel::render_fnumber(
|
void DynamicProfilePanel::render_fnumber (
|
||||||
Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator &iter)
|
Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator &iter)
|
||||||
{
|
{
|
||||||
RENDER_RANGE_(double, fnumber,
|
RENDER_RANGE_ (double, fnumber,
|
||||||
[](double f)
|
[] (double f) {
|
||||||
{ return std::string("f/") +
|
return std::string ("f/") +
|
||||||
rtengine::ImageMetaData::apertureToString(f); });
|
rtengine::ImageMetaData::apertureToString (f);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DynamicProfilePanel::render_focallen(
|
void DynamicProfilePanel::render_focallen (
|
||||||
Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator &iter)
|
Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator &iter)
|
||||||
{
|
{
|
||||||
RENDER_RANGE_(double, focallen, to_str);
|
RENDER_RANGE_ (double, focallen, to_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DynamicProfilePanel::render_shutterspeed(
|
void DynamicProfilePanel::render_shutterspeed (
|
||||||
Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator &iter)
|
Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator &iter)
|
||||||
{
|
{
|
||||||
RENDER_RANGE_(double, shutterspeed,
|
RENDER_RANGE_ (double, shutterspeed,
|
||||||
rtengine::ImageMetaData::shutterToString);
|
rtengine::ImageMetaData::shutterToString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DynamicProfilePanel::render_expcomp(
|
void DynamicProfilePanel::render_expcomp (
|
||||||
Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator &iter)
|
Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator &iter)
|
||||||
{
|
{
|
||||||
RENDER_RANGE_(double, expcomp, to_str);
|
RENDER_RANGE_ (double, expcomp, to_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef RENDER_RANGE_
|
#undef RENDER_RANGE_
|
||||||
@ -431,17 +443,17 @@ void DynamicProfilePanel::render_expcomp(
|
|||||||
ct->property_text() = ""; \
|
ct->property_text() = ""; \
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicProfilePanel::render_camera(
|
void DynamicProfilePanel::render_camera (
|
||||||
Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator &iter)
|
Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator &iter)
|
||||||
{
|
{
|
||||||
RENDER_OPTIONAL_(camera);
|
RENDER_OPTIONAL_ (camera);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DynamicProfilePanel::render_lens(
|
void DynamicProfilePanel::render_lens (
|
||||||
Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator &iter)
|
Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator &iter)
|
||||||
{
|
{
|
||||||
RENDER_OPTIONAL_(lens);
|
RENDER_OPTIONAL_ (lens);
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef RENDER_OPTIONAL_
|
#undef RENDER_OPTIONAL_
|
||||||
@ -449,28 +461,34 @@ void DynamicProfilePanel::render_lens(
|
|||||||
void DynamicProfilePanel::on_button_up()
|
void DynamicProfilePanel::on_button_up()
|
||||||
{
|
{
|
||||||
auto s = treeview_.get_selection();
|
auto s = treeview_.get_selection();
|
||||||
|
|
||||||
if (!s->count_selected_rows()) {
|
if (!s->count_selected_rows()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto it = s->get_selected();
|
auto it = s->get_selected();
|
||||||
|
|
||||||
if (it != treemodel_->children().begin()) {
|
if (it != treemodel_->children().begin()) {
|
||||||
auto it2 = it;
|
auto it2 = it;
|
||||||
--it2;
|
--it2;
|
||||||
treemodel_->iter_swap(it, it2);
|
treemodel_->iter_swap (it, it2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicProfilePanel::on_button_down()
|
void DynamicProfilePanel::on_button_down()
|
||||||
{
|
{
|
||||||
auto s = treeview_.get_selection();
|
auto s = treeview_.get_selection();
|
||||||
|
|
||||||
if (!s->count_selected_rows()) {
|
if (!s->count_selected_rows()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto it = s->get_selected();
|
auto it = s->get_selected();
|
||||||
auto it2 = it;
|
auto it2 = it;
|
||||||
++it2;
|
++it2;
|
||||||
|
|
||||||
if (it2 != treemodel_->children().end()) {
|
if (it2 != treemodel_->children().end()) {
|
||||||
treemodel_->iter_swap(it, it2);
|
treemodel_->iter_swap (it, it2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -478,22 +496,25 @@ void DynamicProfilePanel::on_button_down()
|
|||||||
void DynamicProfilePanel::on_button_delete()
|
void DynamicProfilePanel::on_button_delete()
|
||||||
{
|
{
|
||||||
auto s = treeview_.get_selection();
|
auto s = treeview_.get_selection();
|
||||||
|
|
||||||
if (!s->count_selected_rows()) {
|
if (!s->count_selected_rows()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto it = s->get_selected();
|
auto it = s->get_selected();
|
||||||
treemodel_->erase(it);
|
treemodel_->erase (it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DynamicProfilePanel::on_button_new()
|
void DynamicProfilePanel::on_button_new()
|
||||||
{
|
{
|
||||||
EditDialog d(M("DYNPROFILEEDITOR_NEW_RULE"),
|
EditDialog d (M ("DYNPROFILEEDITOR_NEW_RULE"),
|
||||||
static_cast<Gtk::Window &>(*get_toplevel()));
|
static_cast<Gtk::Window &> (*get_toplevel()));
|
||||||
int status = d.run();
|
int status = d.run();
|
||||||
|
|
||||||
if (status == 1) {
|
if (status == 1) {
|
||||||
DynamicProfileRule rule = d.get_rule();
|
DynamicProfileRule rule = d.get_rule();
|
||||||
add_rule(rule);
|
add_rule (rule);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -501,16 +522,19 @@ void DynamicProfilePanel::on_button_new()
|
|||||||
void DynamicProfilePanel::on_button_edit()
|
void DynamicProfilePanel::on_button_edit()
|
||||||
{
|
{
|
||||||
auto s = treeview_.get_selection();
|
auto s = treeview_.get_selection();
|
||||||
|
|
||||||
if (!s->count_selected_rows()) {
|
if (!s->count_selected_rows()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
EditDialog d(M("DYNPROFILEEDITOR_EDIT_RULE"),
|
|
||||||
static_cast<Gtk::Window &>(*get_toplevel()));
|
EditDialog d (M ("DYNPROFILEEDITOR_EDIT_RULE"),
|
||||||
Gtk::TreeModel::Row row = *(s->get_selected());
|
static_cast<Gtk::Window &> (*get_toplevel()));
|
||||||
d.set_rule(to_rule(row));
|
Gtk::TreeModel::Row row = * (s->get_selected());
|
||||||
|
d.set_rule (to_rule (row));
|
||||||
int status = d.run();
|
int status = d.run();
|
||||||
|
|
||||||
if (status == 1) {
|
if (status == 1) {
|
||||||
update_rule(row, d.get_rule());
|
update_rule (row, d.get_rule());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -519,15 +543,16 @@ void DynamicProfilePanel::save()
|
|||||||
{
|
{
|
||||||
std::vector<DynamicProfileRule> rules;
|
std::vector<DynamicProfileRule> rules;
|
||||||
int serial = 1;
|
int serial = 1;
|
||||||
|
|
||||||
for (auto row : treemodel_->children()) {
|
for (auto row : treemodel_->children()) {
|
||||||
rules.emplace_back(to_rule(row, serial++));
|
rules.emplace_back (to_rule (row, serial++));
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfileStore::getInstance()->setRules(rules);
|
ProfileStore::getInstance()->setRules (rules);
|
||||||
|
|
||||||
if (!ProfileStore::getInstance()->storeRules()) {
|
if (!ProfileStore::getInstance()->storeRules()) {
|
||||||
printf("Error in saving dynamic profile rules\n");
|
printf ("Error in saving dynamic profile rules\n");
|
||||||
} else if (options.rtSettings.verbose) {
|
} else if (options.rtSettings.verbose) {
|
||||||
printf("Saved %d dynamic profile rules\n", int(rules.size()));
|
printf ("Saved %d dynamic profile rules\n", int (rules.size()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,16 +23,16 @@
|
|||||||
#include "../rtengine/dynamicprofile.h"
|
#include "../rtengine/dynamicprofile.h"
|
||||||
#include "profilestorecombobox.h"
|
#include "profilestorecombobox.h"
|
||||||
|
|
||||||
class DynamicProfilePanel: public Gtk::VBox {
|
class DynamicProfilePanel: public Gtk::VBox
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
DynamicProfilePanel();
|
DynamicProfilePanel();
|
||||||
void save();
|
void save();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void update_rule(Gtk::TreeModel::Row row,
|
void update_rule (Gtk::TreeModel::Row row, const DynamicProfileRule &rule);
|
||||||
const DynamicProfileRule &rule);
|
void add_rule (const DynamicProfileRule &rule);
|
||||||
void add_rule(const DynamicProfileRule &rule);
|
DynamicProfileRule to_rule (Gtk::TreeModel::Row row, int serial = 0);
|
||||||
DynamicProfileRule to_rule(Gtk::TreeModel::Row row, int serial=0);
|
|
||||||
|
|
||||||
void on_button_quit();
|
void on_button_quit();
|
||||||
void on_button_up();
|
void on_button_up();
|
||||||
@ -41,18 +41,19 @@ private:
|
|||||||
void on_button_edit();
|
void on_button_edit();
|
||||||
void on_button_delete();
|
void on_button_delete();
|
||||||
|
|
||||||
class DynamicProfileColumns: public Gtk::TreeModel::ColumnRecord {
|
class DynamicProfileColumns: public Gtk::TreeModel::ColumnRecord
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
DynamicProfileColumns()
|
DynamicProfileColumns()
|
||||||
{
|
{
|
||||||
add(iso);
|
add (iso);
|
||||||
add(fnumber);
|
add (fnumber);
|
||||||
add(focallen);
|
add (focallen);
|
||||||
add(shutterspeed);
|
add (shutterspeed);
|
||||||
add(expcomp);
|
add (expcomp);
|
||||||
add(camera);
|
add (camera);
|
||||||
add(lens);
|
add (lens);
|
||||||
add(profilepath);
|
add (profilepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
Gtk::TreeModelColumn<DynamicProfileRule::Range<int>> iso;
|
Gtk::TreeModelColumn<DynamicProfileRule::Range<int>> iso;
|
||||||
@ -66,35 +67,26 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// cell renderers
|
// cell renderers
|
||||||
void render_iso(Gtk::CellRenderer* cell,
|
void render_iso (Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter);
|
||||||
const Gtk::TreeModel::iterator& iter);
|
void render_fnumber (Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter);
|
||||||
void render_fnumber(Gtk::CellRenderer* cell,
|
void render_focallen (Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter);
|
||||||
const Gtk::TreeModel::iterator& iter);
|
void render_shutterspeed (Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter);
|
||||||
void render_focallen(Gtk::CellRenderer* cell,
|
void render_expcomp (Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter);
|
||||||
const Gtk::TreeModel::iterator& iter);
|
void render_camera (Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter);
|
||||||
void render_shutterspeed(Gtk::CellRenderer* cell,
|
void render_lens (Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter);
|
||||||
const Gtk::TreeModel::iterator& iter);
|
void render_profilepath (Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter);
|
||||||
void render_expcomp(Gtk::CellRenderer* cell,
|
|
||||||
const Gtk::TreeModel::iterator& iter);
|
|
||||||
void render_camera(Gtk::CellRenderer* cell,
|
|
||||||
const Gtk::TreeModel::iterator& iter);
|
|
||||||
void render_lens(Gtk::CellRenderer* cell,
|
|
||||||
const Gtk::TreeModel::iterator& iter);
|
|
||||||
void render_profilepath(Gtk::CellRenderer* cell,
|
|
||||||
const Gtk::TreeModel::iterator& iter);
|
|
||||||
|
|
||||||
class EditDialog: public Gtk::Dialog {
|
class EditDialog: public Gtk::Dialog
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
EditDialog(const Glib::ustring &title, Gtk::Window &parent);
|
EditDialog (const Glib::ustring &title, Gtk::Window &parent);
|
||||||
void set_rule(const DynamicProfileRule &rule);
|
void set_rule (const DynamicProfileRule &rule);
|
||||||
DynamicProfileRule get_rule();
|
DynamicProfileRule get_rule();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void set_ranges();
|
void set_ranges();
|
||||||
void add_range(const Glib::ustring &name,
|
void add_range (const Glib::ustring &name, Gtk::SpinButton *&from, Gtk::SpinButton *&to);
|
||||||
Gtk::SpinButton *&from, Gtk::SpinButton *&to);
|
void add_optional (const Glib::ustring &name, Gtk::CheckButton *&check, Gtk::Entry *&field);
|
||||||
void add_optional(const Glib::ustring &name,
|
|
||||||
Gtk::CheckButton *&check, Gtk::Entry *&field);
|
|
||||||
|
|
||||||
Gtk::SpinButton *iso_min_;
|
Gtk::SpinButton *iso_min_;
|
||||||
Gtk::SpinButton *iso_max_;
|
Gtk::SpinButton *iso_max_;
|
||||||
|
@ -27,17 +27,17 @@
|
|||||||
using namespace rtengine;
|
using namespace rtengine;
|
||||||
using namespace rtengine::procparams;
|
using namespace rtengine::procparams;
|
||||||
|
|
||||||
ProfileStoreLabel::ProfileStoreLabel(const ProfileStoreEntry *entry) : Gtk::Label(entry->label), entry(entry)
|
ProfileStoreLabel::ProfileStoreLabel (const ProfileStoreEntry *entry) : Gtk::Label (entry->label), entry (entry)
|
||||||
{
|
{
|
||||||
set_alignment(0, 0.5);
|
set_alignment (0, 0.5);
|
||||||
set_ellipsize(Pango::ELLIPSIZE_END);
|
set_ellipsize (Pango::ELLIPSIZE_END);
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfileStoreComboBox::ProfileStoreComboBox ()
|
ProfileStoreComboBox::ProfileStoreComboBox ()
|
||||||
{
|
{
|
||||||
updateProfileList();
|
updateProfileList();
|
||||||
setPreferredWidth(50, 120);
|
setPreferredWidth (50, 120);
|
||||||
}
|
}
|
||||||
|
|
||||||
Glib::ustring ProfileStoreComboBox::getCurrentLabel()
|
Glib::ustring ProfileStoreComboBox::getCurrentLabel()
|
||||||
@ -71,16 +71,16 @@ void ProfileStoreComboBox::refreshProfileList_ (Gtk::TreeModel::Row *parentRow,
|
|||||||
for (auto entry : *entryList) {
|
for (auto entry : *entryList) {
|
||||||
if (entry->parentFolderId == parentFolderId) { // filtering the entry of the same folder
|
if (entry->parentFolderId == parentFolderId) { // filtering the entry of the same folder
|
||||||
if (entry->type == PSET_FOLDER) {
|
if (entry->type == PSET_FOLDER) {
|
||||||
Glib::ustring folderPath( ProfileStore::getInstance()->getPathFromId(entry->folderId) );
|
Glib::ustring folderPath ( ProfileStore::getInstance()->getPathFromId (entry->folderId) );
|
||||||
|
|
||||||
if (options.useBundledProfiles || ((folderPath != "${G}" ) && (folderPath != "${U}" ))) {
|
if (options.useBundledProfiles || ((folderPath != "${G}" ) && (folderPath != "${U}" ))) {
|
||||||
// creating the new submenu
|
// creating the new submenu
|
||||||
Gtk::TreeModel::Row newSubMenu;
|
Gtk::TreeModel::Row newSubMenu;
|
||||||
|
|
||||||
if (initial) {
|
if (initial) {
|
||||||
newSubMenu = *(refTreeModel->append());
|
newSubMenu = * (refTreeModel->append());
|
||||||
} else {
|
} else {
|
||||||
newSubMenu = *(refTreeModel->append(parentRow->children()));
|
newSubMenu = * (refTreeModel->append (parentRow->children()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// creating and assigning the custom Label object
|
// creating and assigning the custom Label object
|
||||||
@ -88,7 +88,7 @@ void ProfileStoreComboBox::refreshProfileList_ (Gtk::TreeModel::Row *parentRow,
|
|||||||
newSubMenu[methodColumns.profileStoreEntry] = entry;
|
newSubMenu[methodColumns.profileStoreEntry] = entry;
|
||||||
#if GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION == 18
|
#if GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION == 18
|
||||||
// HACK: Workaround for bug in Gtk+ 3.18...
|
// HACK: Workaround for bug in Gtk+ 3.18...
|
||||||
Gtk::TreeModel::Row menuHeader = *(refTreeModel->append(newSubMenu->children()));
|
Gtk::TreeModel::Row menuHeader = * (refTreeModel->append (newSubMenu->children()));
|
||||||
menuHeader[methodColumns.label] = "-";
|
menuHeader[methodColumns.label] = "-";
|
||||||
menuHeader[methodColumns.profileStoreEntry] = entry;
|
menuHeader[methodColumns.profileStoreEntry] = entry;
|
||||||
#endif
|
#endif
|
||||||
@ -101,9 +101,9 @@ void ProfileStoreComboBox::refreshProfileList_ (Gtk::TreeModel::Row *parentRow,
|
|||||||
|
|
||||||
// creating a menu entry
|
// creating a menu entry
|
||||||
if (initial) {
|
if (initial) {
|
||||||
newItem = *(refTreeModel->append());
|
newItem = * (refTreeModel->append());
|
||||||
} else {
|
} else {
|
||||||
newItem = *(refTreeModel->append(parentRow->children()));
|
newItem = * (refTreeModel->append (parentRow->children()));
|
||||||
}
|
}
|
||||||
|
|
||||||
newItem[methodColumns.label] = entry->label;
|
newItem[methodColumns.label] = entry->label;
|
||||||
@ -123,27 +123,27 @@ void ProfileStoreComboBox::updateProfileList ()
|
|||||||
clear();
|
clear();
|
||||||
refTreeModel.clear();
|
refTreeModel.clear();
|
||||||
// Create the Tree model
|
// Create the Tree model
|
||||||
refTreeModel = Gtk::TreeStore::create(methodColumns);
|
refTreeModel = Gtk::TreeStore::create (methodColumns);
|
||||||
// Assign the model to the Combobox
|
// Assign the model to the Combobox
|
||||||
set_model(refTreeModel);
|
set_model (refTreeModel);
|
||||||
|
|
||||||
// this will lock the profilestore's entry list too
|
// this will lock the profilestore's entry list too
|
||||||
const std::vector<const ProfileStoreEntry*> *entryList = ProfileStore::getInstance()->getFileList();
|
const std::vector<const ProfileStoreEntry*> *entryList = ProfileStore::getInstance()->getFileList();
|
||||||
|
|
||||||
//profileStore.dumpFolderList();
|
//profileStore.dumpFolderList();
|
||||||
refreshProfileList_ (NULL, entryList->at(0)->parentFolderId, true, entryList);
|
refreshProfileList_ (NULL, entryList->at (0)->parentFolderId, true, entryList);
|
||||||
|
|
||||||
if (entryList->at(0)->parentFolderId != 0) {
|
if (entryList->at (0)->parentFolderId != 0) {
|
||||||
// special case for the Internal default entry
|
// special case for the Internal default entry
|
||||||
addRow(ProfileStore::getInstance()->getInternalDefaultPSE());
|
addRow (ProfileStore::getInstance()->getInternalDefaultPSE());
|
||||||
}
|
}
|
||||||
|
|
||||||
// releasing the profilestore's entry list mutex
|
// releasing the profilestore's entry list mutex
|
||||||
ProfileStore::getInstance()->releaseFileList();
|
ProfileStore::getInstance()->releaseFileList();
|
||||||
|
|
||||||
pack_start(methodColumns.label, false);
|
pack_start (methodColumns.label, false);
|
||||||
|
|
||||||
Gtk::CellRendererText* cellRenderer = dynamic_cast<Gtk::CellRendererText*>(get_first_cell());
|
Gtk::CellRendererText* cellRenderer = dynamic_cast<Gtk::CellRendererText*> (get_first_cell());
|
||||||
cellRenderer->property_ellipsize() = Pango::ELLIPSIZE_MIDDLE;
|
cellRenderer->property_ellipsize() = Pango::ELLIPSIZE_MIDDLE;
|
||||||
cellRenderer->property_ellipsize_set() = true;
|
cellRenderer->property_ellipsize_set() = true;
|
||||||
}
|
}
|
||||||
@ -153,7 +153,7 @@ Gtk::TreeIter ProfileStoreComboBox::findRowFromEntry_ (Gtk::TreeModel::Children
|
|||||||
Gtk::TreeModel::Row row;
|
Gtk::TreeModel::Row row;
|
||||||
Gtk::TreeIter rowInSubLevel;
|
Gtk::TreeIter rowInSubLevel;
|
||||||
|
|
||||||
for(Gtk::TreeModel::Children::iterator iter = childs.begin(); iter != childs.end(); ++iter) {
|
for (Gtk::TreeModel::Children::iterator iter = childs.begin(); iter != childs.end(); ++iter) {
|
||||||
row = *iter;
|
row = *iter;
|
||||||
// Hombre: is there a smarter way of knowing if this row has childs?
|
// Hombre: is there a smarter way of knowing if this row has childs?
|
||||||
const ProfileStoreEntry *pse_ = row[methodColumns.profileStoreEntry];
|
const ProfileStoreEntry *pse_ = row[methodColumns.profileStoreEntry];
|
||||||
@ -191,7 +191,7 @@ Gtk::TreeIter ProfileStoreComboBox::findRowFromFullPath_ (Gtk::TreeModel::Childr
|
|||||||
Gtk::TreeModel::Row row;
|
Gtk::TreeModel::Row row;
|
||||||
Gtk::TreeIter rowInSubLevel;
|
Gtk::TreeIter rowInSubLevel;
|
||||||
|
|
||||||
for(Gtk::TreeModel::Children::iterator iter = childs.begin(); iter != childs.end(); ++iter) {
|
for (Gtk::TreeModel::Children::iterator iter = childs.begin(); iter != childs.end(); ++iter) {
|
||||||
row = *iter;
|
row = *iter;
|
||||||
// Hombre: is there a smarter way of knowing if this row has childs?
|
// Hombre: is there a smarter way of knowing if this row has childs?
|
||||||
const ProfileStoreEntry *pse = row[methodColumns.profileStoreEntry];
|
const ProfileStoreEntry *pse = row[methodColumns.profileStoreEntry];
|
||||||
@ -222,27 +222,27 @@ Gtk::TreeIter ProfileStoreComboBox::findRowFromFullPath (Glib::ustring path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (path == DEFPROFILE_INTERNAL) {
|
if (path == DEFPROFILE_INTERNAL) {
|
||||||
row = findRowFromEntry(profileStore->getInternalDefaultPSE());
|
row = findRowFromEntry (profileStore->getInternalDefaultPSE());
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path == DEFPROFILE_DYNAMIC) {
|
if (path == DEFPROFILE_DYNAMIC) {
|
||||||
row = findRowFromEntry(profileStore->getInternalDynamicPSE());
|
row = findRowFromEntry (profileStore->getInternalDynamicPSE());
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
// removing the filename
|
// removing the filename
|
||||||
Glib::ustring fName = Glib::path_get_basename(path);
|
Glib::ustring fName = Glib::path_get_basename (path);
|
||||||
|
|
||||||
if (!fName.empty()) {
|
if (!fName.empty()) {
|
||||||
path = path.substr(0, path.length() - fName.length());
|
path = path.substr (0, path.length() - fName.length());
|
||||||
} else {
|
} else {
|
||||||
// path is malformed;
|
// path is malformed;
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
path = Glib::path_get_dirname(path);
|
path = Glib::path_get_dirname (path);
|
||||||
int parentFolderId = profileStore->findFolderId(path);
|
int parentFolderId = profileStore->findFolderId (path);
|
||||||
|
|
||||||
// 1. find the path in the folder list
|
// 1. find the path in the folder list
|
||||||
if (parentFolderId != -1) {
|
if (parentFolderId != -1) {
|
||||||
@ -277,26 +277,26 @@ Glib::ustring ProfileStoreComboBox::getFullPathFromActiveRow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (currEntry == profileStore->getInternalDefaultPSE()) {
|
if (currEntry == profileStore->getInternalDefaultPSE()) {
|
||||||
return Glib::ustring(DEFPROFILE_INTERNAL);
|
return Glib::ustring (DEFPROFILE_INTERNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currEntry == profileStore->getInternalDynamicPSE()) {
|
if (currEntry == profileStore->getInternalDynamicPSE()) {
|
||||||
return Glib::ustring(DEFPROFILE_DYNAMIC);
|
return Glib::ustring (DEFPROFILE_DYNAMIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
path = Glib::build_filename(profileStore->getPathFromId(currEntry->parentFolderId), currEntry->label);
|
path = Glib::build_filename (profileStore->getPathFromId (currEntry->parentFolderId), currEntry->label);
|
||||||
}
|
}
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProfileStoreComboBox::setActiveRowFromFullPath(Glib::ustring path)
|
bool ProfileStoreComboBox::setActiveRowFromFullPath (Glib::ustring path)
|
||||||
{
|
{
|
||||||
if (!path.empty()) {
|
if (!path.empty()) {
|
||||||
Gtk::TreeIter row = findRowFromFullPath(path);
|
Gtk::TreeIter row = findRowFromFullPath (path);
|
||||||
|
|
||||||
if (row) {
|
if (row) {
|
||||||
set_active(row);
|
set_active (row);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -304,13 +304,13 @@ bool ProfileStoreComboBox::setActiveRowFromFullPath(Glib::ustring path)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProfileStoreComboBox::setActiveRowFromEntry(const ProfileStoreEntry *pse)
|
bool ProfileStoreComboBox::setActiveRowFromEntry (const ProfileStoreEntry *pse)
|
||||||
{
|
{
|
||||||
if (pse) {
|
if (pse) {
|
||||||
Gtk::TreeIter row = findRowFromEntry(pse);
|
Gtk::TreeIter row = findRowFromEntry (pse);
|
||||||
|
|
||||||
if (row) {
|
if (row) {
|
||||||
set_active(row);
|
set_active (row);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -320,11 +320,11 @@ bool ProfileStoreComboBox::setActiveRowFromEntry(const ProfileStoreEntry *pse)
|
|||||||
|
|
||||||
bool ProfileStoreComboBox::setInternalEntry ()
|
bool ProfileStoreComboBox::setInternalEntry ()
|
||||||
{
|
{
|
||||||
return setActiveRowFromEntry(ProfileStore::getInstance()->getInternalDefaultPSE());
|
return setActiveRowFromEntry (ProfileStore::getInstance()->getInternalDefaultPSE());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief Get the row from the first level of the tree that match the provided name */
|
/** @brief Get the row from the first level of the tree that match the provided name */
|
||||||
Gtk::TreeIter ProfileStoreComboBox::getRowFromLabel(Glib::ustring name)
|
Gtk::TreeIter ProfileStoreComboBox::getRowFromLabel (Glib::ustring name)
|
||||||
{
|
{
|
||||||
Gtk::TreeIter row;
|
Gtk::TreeIter row;
|
||||||
Gtk::TreeModel::Children childs = refTreeModel->children();
|
Gtk::TreeModel::Children childs = refTreeModel->children();
|
||||||
@ -332,7 +332,7 @@ Gtk::TreeIter ProfileStoreComboBox::getRowFromLabel(Glib::ustring name)
|
|||||||
if (!name.empty()) {
|
if (!name.empty()) {
|
||||||
Gtk::TreeModel::Row currRow;
|
Gtk::TreeModel::Row currRow;
|
||||||
|
|
||||||
for(Gtk::TreeModel::Children::iterator iter = childs.begin(); iter != childs.end(); ++iter) {
|
for (Gtk::TreeModel::Children::iterator iter = childs.begin(); iter != childs.end(); ++iter) {
|
||||||
currRow = *iter;
|
currRow = *iter;
|
||||||
const ProfileStoreEntry *pse = currRow[methodColumns.profileStoreEntry];
|
const ProfileStoreEntry *pse = currRow[methodColumns.profileStoreEntry];
|
||||||
|
|
||||||
@ -347,7 +347,7 @@ Gtk::TreeIter ProfileStoreComboBox::getRowFromLabel(Glib::ustring name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @brief Add a new row to the first level of the tree */
|
/** @brief Add a new row to the first level of the tree */
|
||||||
Gtk::TreeIter ProfileStoreComboBox::addRow(const ProfileStoreEntry *profileStoreEntry)
|
Gtk::TreeIter ProfileStoreComboBox::addRow (const ProfileStoreEntry *profileStoreEntry)
|
||||||
{
|
{
|
||||||
Gtk::TreeIter newEntry = refTreeModel->append();
|
Gtk::TreeIter newEntry = refTreeModel->append();
|
||||||
Gtk::TreeModel::Row row = *newEntry;
|
Gtk::TreeModel::Row row = *newEntry;
|
||||||
|
@ -42,16 +42,16 @@ public:
|
|||||||
const ProfileStoreEntry *entry;
|
const ProfileStoreEntry *entry;
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
ProfileStoreLabel() : Gtk::Label("*** error ***"), entry(nullptr) {}
|
ProfileStoreLabel() : Gtk::Label ("*** error ***"), entry (nullptr) {}
|
||||||
#else
|
#else
|
||||||
ProfileStoreLabel() : Gtk::Label(""), entry(NULL) {}
|
ProfileStoreLabel() : Gtk::Label (""), entry (NULL) {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** @brief Create a new ProfileStoreLabel
|
/** @brief Create a new ProfileStoreLabel
|
||||||
*
|
*
|
||||||
* @param entry Pointer to the ProfileStoreEntry object, be it a directory or a file
|
* @param entry Pointer to the ProfileStoreEntry object, be it a directory or a file
|
||||||
*/
|
*/
|
||||||
explicit ProfileStoreLabel(const ProfileStoreEntry *entry);
|
explicit ProfileStoreLabel (const ProfileStoreEntry *entry);
|
||||||
ProfileStoreLabel (const ProfileStoreLabel &other);
|
ProfileStoreLabel (const ProfileStoreLabel &other);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -66,8 +66,8 @@ protected:
|
|||||||
Gtk::TreeModelColumn<const ProfileStoreEntry*> profileStoreEntry;
|
Gtk::TreeModelColumn<const ProfileStoreEntry*> profileStoreEntry;
|
||||||
MethodColumns()
|
MethodColumns()
|
||||||
{
|
{
|
||||||
add(label);
|
add (label);
|
||||||
add(profileStoreEntry);
|
add (profileStoreEntry);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ protected:
|
|||||||
MethodColumns methodColumns;
|
MethodColumns methodColumns;
|
||||||
void refreshProfileList_ (Gtk::TreeModel::Row *parentRow, int parentFolderId, bool initial, const std::vector<const ProfileStoreEntry*> *entryList);
|
void refreshProfileList_ (Gtk::TreeModel::Row *parentRow, int parentFolderId, bool initial, const std::vector<const ProfileStoreEntry*> *entryList);
|
||||||
Gtk::TreeIter findRowFromEntry_ (Gtk::TreeModel::Children childs, const ProfileStoreEntry *pse);
|
Gtk::TreeIter findRowFromEntry_ (Gtk::TreeModel::Children childs, const ProfileStoreEntry *pse);
|
||||||
Gtk::TreeIter findRowFromFullPath_(Gtk::TreeModel::Children childs, int parentFolderId, Glib::ustring &name);
|
Gtk::TreeIter findRowFromFullPath_ (Gtk::TreeModel::Children childs, int parentFolderId, Glib::ustring &name);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ProfileStoreComboBox();
|
ProfileStoreComboBox();
|
||||||
@ -88,8 +88,8 @@ public:
|
|||||||
bool setActiveRowFromFullPath (Glib::ustring oldPath);
|
bool setActiveRowFromFullPath (Glib::ustring oldPath);
|
||||||
bool setActiveRowFromEntry (const ProfileStoreEntry *pse);
|
bool setActiveRowFromEntry (const ProfileStoreEntry *pse);
|
||||||
bool setInternalEntry ();
|
bool setInternalEntry ();
|
||||||
Gtk::TreeIter getRowFromLabel(Glib::ustring name);
|
Gtk::TreeIter getRowFromLabel (Glib::ustring name);
|
||||||
Gtk::TreeIter addRow(const ProfileStoreEntry *profileStoreEntry);
|
Gtk::TreeIter addRow (const ProfileStoreEntry *profileStoreEntry);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user