Several files astylized.

This commit is contained in:
Hombre
2017-04-25 22:33:22 +02:00
parent fb5466bc8c
commit 8c309d0f04
9 changed files with 533 additions and 493 deletions

View File

@@ -30,65 +30,63 @@
// DynamicProfilePanel::EditDialog
//-----------------------------------------------------------------------------
DynamicProfilePanel::EditDialog::EditDialog(const Glib::ustring &title,
Gtk::Window &parent):
Gtk::Dialog(title, parent)
DynamicProfilePanel::EditDialog::EditDialog (const Glib::ustring &title, Gtk::Window &parent):
Gtk::Dialog (title, parent)
{
profilepath_ = Gtk::manage(new ProfileStoreComboBox());
Gtk::HBox *hb = Gtk::manage(new Gtk::HBox());
hb->pack_start(*Gtk::manage(new Gtk::Label(M("DYNPROFILEEDITOR_PROFILE"))),
false, false, 4);
hb->pack_start(*profilepath_, true, true, 2);
get_content_area()->pack_start(*hb, Gtk::PACK_SHRINK, 4);
profilepath_ = Gtk::manage (new ProfileStoreComboBox());
Gtk::HBox *hb = Gtk::manage (new Gtk::HBox());
hb->pack_start (*Gtk::manage (new Gtk::Label (M ("DYNPROFILEEDITOR_PROFILE"))), false, false, 4);
hb->pack_start (*profilepath_, true, true, 2);
get_content_area()->pack_start (*hb, Gtk::PACK_SHRINK, 4);
add_optional(M("EXIFFILTER_CAMERA"), has_camera_, camera_);
add_optional(M("EXIFFILTER_LENS"), has_lens_, lens_);
add_range(M("EXIFFILTER_ISO"), iso_min_, iso_max_);
add_range(M("EXIFFILTER_APERTURE"), fnumber_min_, fnumber_max_);
add_range(M("EXIFFILTER_FOCALLEN"), focallen_min_, focallen_max_);
add_range(M("EXIFFILTER_SHUTTER"), shutterspeed_min_, shutterspeed_max_);
add_range(M("EXIFFILTER_EXPOSURECOMPENSATION"), expcomp_min_, expcomp_max_);
add_optional (M ("EXIFFILTER_CAMERA"), has_camera_, camera_);
add_optional (M ("EXIFFILTER_LENS"), has_lens_, lens_);
add_button(M("GENERAL_OK"), 1);
add_button(M("GENERAL_CANCEL"), 2);
add_range (M ("EXIFFILTER_ISO"), iso_min_, iso_max_);
add_range (M ("EXIFFILTER_APERTURE"), fnumber_min_, fnumber_max_);
add_range (M ("EXIFFILTER_FOCALLEN"), focallen_min_, focallen_max_);
add_range (M ("EXIFFILTER_SHUTTER"), shutterspeed_min_, shutterspeed_max_);
add_range (M ("EXIFFILTER_EXPOSURECOMPENSATION"), expcomp_min_, expcomp_max_);
add_button (M ("GENERAL_OK"), 1);
add_button (M ("GENERAL_CANCEL"), 2);
set_ranges();
show_all_children();
}
void DynamicProfilePanel::EditDialog::set_rule(
void DynamicProfilePanel::EditDialog::set_rule (
const DynamicProfileRule &rule)
{
iso_min_->set_value(rule.iso.min);
iso_max_->set_value(rule.iso.max);
iso_min_->set_value (rule.iso.min);
iso_max_->set_value (rule.iso.max);
fnumber_min_->set_value(rule.fnumber.min);
fnumber_max_->set_value(rule.fnumber.max);
fnumber_min_->set_value (rule.fnumber.min);
fnumber_max_->set_value (rule.fnumber.max);
focallen_min_->set_value(rule.focallen.min);
focallen_max_->set_value(rule.focallen.max);
focallen_min_->set_value (rule.focallen.min);
focallen_max_->set_value (rule.focallen.max);
shutterspeed_min_->set_value(rule.shutterspeed.min);
shutterspeed_max_->set_value(rule.shutterspeed.max);
shutterspeed_min_->set_value (rule.shutterspeed.min);
shutterspeed_max_->set_value (rule.shutterspeed.max);
expcomp_min_->set_value(rule.expcomp.min);
expcomp_max_->set_value(rule.expcomp.max);
expcomp_min_->set_value (rule.expcomp.min);
expcomp_max_->set_value (rule.expcomp.max);
has_camera_->set_active(rule.camera.enabled);
camera_->set_text(rule.camera.value);
has_camera_->set_active (rule.camera.enabled);
camera_->set_text (rule.camera.value);
has_lens_->set_active(rule.lens.enabled);
lens_->set_text(rule.lens.value);
has_lens_->set_active (rule.lens.enabled);
lens_->set_text (rule.lens.value);
profilepath_->updateProfileList();
if (!profilepath_->setActiveRowFromFullPath(rule.profilepath)) {
if (!profilepath_->setActiveRowFromFullPath (rule.profilepath)) {
profilepath_->setInternalEntry();
}
}
DynamicProfileRule DynamicProfilePanel::EditDialog::get_rule()
{
@@ -98,7 +96,7 @@ DynamicProfileRule DynamicProfilePanel::EditDialog::get_rule()
ret.fnumber.min = fnumber_min_->get_value();
ret.fnumber.max = fnumber_max_->get_value();
ret.focallen.min = focallen_min_->get_value();
ret.focallen.max = focallen_max_->get_value();
@@ -113,7 +111,7 @@ DynamicProfileRule DynamicProfilePanel::EditDialog::get_rule()
ret.lens.enabled = has_lens_->get_active();
ret.lens.value = lens_->get_text();
ret.profilepath = profilepath_->getFullPathFromActiveRow();
return ret;
@@ -122,20 +120,20 @@ DynamicProfileRule DynamicProfilePanel::EditDialog::get_rule()
void DynamicProfilePanel::EditDialog::set_ranges()
{
DynamicProfileRule default_rule;
iso_min_->set_digits(0);
iso_max_->set_digits(0);
iso_min_->set_increments(1, 10);
iso_max_->set_increments(1, 10);
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_min_->set_value(default_rule.iso.min);
iso_max_->set_value(default_rule.iso.max);
iso_min_->set_digits (0);
iso_max_->set_digits (0);
iso_min_->set_increments (1, 10);
iso_max_->set_increments (1, 10);
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_min_->set_value (default_rule.iso.min);
iso_max_->set_value (default_rule.iso.max);
#define DOIT_(name) \
name ## _min_->set_digits(1); \
name ## _max_->set_digits(1); \
name ## _min_->set_increments(0.1, 1); \
name ## _max_->set_increments(0.1, 1); \
#define DOIT_(name) \
name ## _min_->set_digits(1); \
name ## _max_->set_digits(1); \
name ## _min_->set_increments(0.1, 1); \
name ## _max_->set_increments(0.1, 1); \
name ## _min_->set_range(default_rule. name .min, \
default_rule. name .max); \
name ## _max_->set_range(default_rule. name .min, \
@@ -143,45 +141,42 @@ void DynamicProfilePanel::EditDialog::set_ranges()
name ## _min_->set_value(default_rule. name .min); \
name ## _max_->set_value(default_rule. name .max)
DOIT_(fnumber);
DOIT_(focallen);
DOIT_(shutterspeed);
DOIT_(expcomp);
DOIT_ (fnumber);
DOIT_ (focallen);
DOIT_ (shutterspeed);
DOIT_ (expcomp);
#undef DOIT_
shutterspeed_min_->set_digits(4);
shutterspeed_max_->set_digits(4);
shutterspeed_min_->set_digits (4);
shutterspeed_max_->set_digits (4);
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::HBox *hb = Gtk::manage(new Gtk::HBox());
hb->pack_start(*Gtk::manage(new Gtk::Label(name)), false, false, 4);
from = Gtk::manage(new Gtk::SpinButton());
to = Gtk::manage(new Gtk::SpinButton());
from->set_numeric(true);
to->set_numeric(true);
hb->pack_start(*from, true, true, 2);
hb->pack_start(*Gtk::manage(new Gtk::Label(" - ")),
false, false, 4);
hb->pack_start(*to, true, true, 2);
get_content_area()->pack_start(*hb, Gtk::PACK_SHRINK, 4);
Gtk::HBox *hb = Gtk::manage (new Gtk::HBox());
hb->pack_start (*Gtk::manage (new Gtk::Label (name)), false, false, 4);
from = Gtk::manage (new Gtk::SpinButton());
to = Gtk::manage (new Gtk::SpinButton());
from->set_numeric (true);
to->set_numeric (true);
hb->pack_start (*from, true, true, 2);
hb->pack_start (*Gtk::manage (new Gtk::Label (" - ")), false, false, 4);
hb->pack_start (*to, true, true, 2);
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));
Gtk::HBox *hb = Gtk::manage(new Gtk::HBox());
hb->pack_start(*check, Gtk::PACK_SHRINK, 4);
field = Gtk::manage(new Gtk::Entry());
hb->pack_start(*field, true, true, 2);
get_content_area()->pack_start(*hb, Gtk::PACK_SHRINK, 4);
field->set_tooltip_text(M("DYNPROFILEEDITOR_ENTRY_TOOLTIP"));
check = Gtk::manage (new Gtk::CheckButton (name));
Gtk::HBox *hb = Gtk::manage (new Gtk::HBox());
hb->pack_start (*check, Gtk::PACK_SHRINK, 4);
field = Gtk::manage (new Gtk::Entry());
hb->pack_start (*field, true, true, 2);
get_content_area()->pack_start (*hb, Gtk::PACK_SHRINK, 4);
field->set_tooltip_text (M ("DYNPROFILEEDITOR_ENTRY_TOOLTIP"));
}
@@ -190,121 +185,135 @@ void DynamicProfilePanel::EditDialog::add_optional(const Glib::ustring &name,
//-----------------------------------------------------------------------------
DynamicProfilePanel::DynamicProfilePanel():
vbox_(Gtk::ORIENTATION_VERTICAL),
button_up_(M("DYNPROFILEEDITOR_MOVE_UP")),
button_down_(M("DYNPROFILEEDITOR_MOVE_DOWN")),
button_new_(M("DYNPROFILEEDITOR_NEW")),
button_edit_(M("DYNPROFILEEDITOR_EDIT")),
button_delete_(M("DYNPROFILEEDITOR_DELETE"))
vbox_ (Gtk::ORIENTATION_VERTICAL),
button_up_ (M ("DYNPROFILEEDITOR_MOVE_UP")),
button_down_ (M ("DYNPROFILEEDITOR_MOVE_DOWN")),
button_new_ (M ("DYNPROFILEEDITOR_NEW")),
button_edit_ (M ("DYNPROFILEEDITOR_EDIT")),
button_delete_ (M ("DYNPROFILEEDITOR_DELETE"))
{
add(vbox_);
add (vbox_);
treeview_.set_grid_lines(Gtk::TREE_VIEW_GRID_LINES_VERTICAL);
scrolledwindow_.add(treeview_);
treeview_.set_grid_lines (Gtk::TREE_VIEW_GRID_LINES_VERTICAL);
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(buttonbox_, Gtk::PACK_SHRINK);
vbox_.pack_start (scrolledwindow_);
vbox_.pack_start (buttonbox_, Gtk::PACK_SHRINK);
buttonbox_.pack_start(button_new_, Gtk::PACK_SHRINK);
buttonbox_.pack_start(button_edit_, Gtk::PACK_SHRINK);
buttonbox_.pack_start(button_delete_, Gtk::PACK_SHRINK);
buttonbox_.pack_start(button_up_, Gtk::PACK_SHRINK);
buttonbox_.pack_start(button_down_, Gtk::PACK_SHRINK);
buttonbox_.set_border_width(5);
buttonbox_.set_layout(Gtk::BUTTONBOX_END);
button_up_.signal_clicked().connect(
sigc::mem_fun(*this, &DynamicProfilePanel::on_button_up));
button_down_.signal_clicked().connect(
sigc::mem_fun(*this, &DynamicProfilePanel::on_button_down));
button_new_.signal_clicked().connect(
sigc::mem_fun(*this, &DynamicProfilePanel::on_button_new));
button_edit_.signal_clicked().connect(
sigc::mem_fun(*this, &DynamicProfilePanel::on_button_edit));
button_delete_.signal_clicked().connect(
sigc::mem_fun(*this, &DynamicProfilePanel::on_button_delete));
buttonbox_.pack_start (button_new_, Gtk::PACK_SHRINK);
buttonbox_.pack_start (button_edit_, Gtk::PACK_SHRINK);
buttonbox_.pack_start (button_delete_, Gtk::PACK_SHRINK);
buttonbox_.pack_start (button_up_, Gtk::PACK_SHRINK);
buttonbox_.pack_start (button_down_, Gtk::PACK_SHRINK);
buttonbox_.set_border_width (5);
buttonbox_.set_layout (Gtk::BUTTONBOX_END);
button_up_.signal_clicked().connect (
sigc::mem_fun (*this, &DynamicProfilePanel::on_button_up));
button_down_.signal_clicked().connect (
sigc::mem_fun (*this, &DynamicProfilePanel::on_button_down));
button_new_.signal_clicked().connect (
sigc::mem_fun (*this, &DynamicProfilePanel::on_button_new));
button_edit_.signal_clicked().connect (
sigc::mem_fun (*this, &DynamicProfilePanel::on_button_edit));
button_delete_.signal_clicked().connect (
sigc::mem_fun (*this, &DynamicProfilePanel::on_button_delete));
treemodel_ = Gtk::ListStore::create(columns_);
treeview_.set_model(treemodel_);
treemodel_ = Gtk::ListStore::create (columns_);
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) {
col->set_cell_data_func(
*cell, sigc::mem_fun(
col->set_cell_data_func (
*cell, sigc::mem_fun (
*this, &DynamicProfilePanel::render_profilepath));
}
cell = Gtk::manage(new Gtk::CellRendererText());
cols_count = treeview_.append_column(
M("EXIFFILTER_CAMERA"), *cell);
col = treeview_.get_column(cols_count - 1);
cell = Gtk::manage (new Gtk::CellRendererText());
cols_count = treeview_.append_column (
M ("EXIFFILTER_CAMERA"), *cell);
col = treeview_.get_column (cols_count - 1);
if (col) {
col->set_cell_data_func(
*cell, sigc::mem_fun(
col->set_cell_data_func (
*cell, sigc::mem_fun (
*this, &DynamicProfilePanel::render_camera));
}
cell = Gtk::manage(new Gtk::CellRendererText());
cols_count = treeview_.append_column(M("EXIFFILTER_LENS"), *cell);
col = treeview_.get_column(cols_count - 1);
cell = Gtk::manage (new Gtk::CellRendererText());
cols_count = treeview_.append_column (M ("EXIFFILTER_LENS"), *cell);
col = treeview_.get_column (cols_count - 1);
if (col) {
col->set_cell_data_func(
*cell, sigc::mem_fun(
col->set_cell_data_func (
*cell, sigc::mem_fun (
*this, &DynamicProfilePanel::render_lens));
}
cell = Gtk::manage(new Gtk::CellRendererText());
cols_count = treeview_.append_column(M("EXIFFILTER_ISO"), *cell);
col = treeview_.get_column(cols_count - 1);
cell = Gtk::manage (new Gtk::CellRendererText());
cols_count = treeview_.append_column (M ("EXIFFILTER_ISO"), *cell);
col = treeview_.get_column (cols_count - 1);
if (col) {
col->set_cell_data_func(
*cell, sigc::mem_fun(
col->set_cell_data_func (
*cell, sigc::mem_fun (
*this, &DynamicProfilePanel::render_iso));
}
cell = Gtk::manage(new Gtk::CellRendererText());
cols_count = treeview_.append_column(M("EXIFFILTER_APERTURE"), *cell);
col = treeview_.get_column(cols_count - 1);
cell = Gtk::manage (new Gtk::CellRendererText());
cols_count = treeview_.append_column (M ("EXIFFILTER_APERTURE"), *cell);
col = treeview_.get_column (cols_count - 1);
if (col) {
col->set_cell_data_func(
*cell, sigc::mem_fun(
col->set_cell_data_func (
*cell, sigc::mem_fun (
*this, &DynamicProfilePanel::render_fnumber));
}
cell = Gtk::manage(new Gtk::CellRendererText());
cols_count = treeview_.append_column(M("EXIFFILTER_FOCALLEN"), *cell);
col = treeview_.get_column(cols_count - 1);
cell = Gtk::manage (new Gtk::CellRendererText());
cols_count = treeview_.append_column (M ("EXIFFILTER_FOCALLEN"), *cell);
col = treeview_.get_column (cols_count - 1);
if (col) {
col->set_cell_data_func(
*cell, sigc::mem_fun(
col->set_cell_data_func (
*cell, sigc::mem_fun (
*this, &DynamicProfilePanel::render_focallen));
}
cell = Gtk::manage(new Gtk::CellRendererText());
cols_count = treeview_.append_column(M("EXIFFILTER_SHUTTER"), *cell);
col = treeview_.get_column(cols_count - 1);
cell = Gtk::manage (new Gtk::CellRendererText());
cols_count = treeview_.append_column (M ("EXIFFILTER_SHUTTER"), *cell);
col = treeview_.get_column (cols_count - 1);
if (col) {
col->set_cell_data_func(
*cell, sigc::mem_fun(
col->set_cell_data_func (
*cell, sigc::mem_fun (
*this, &DynamicProfilePanel::render_shutterspeed));
}
cell = Gtk::manage(new Gtk::CellRendererText());
cols_count = treeview_.append_column(
M("EXIFFILTER_EXPOSURECOMPENSATION"), *cell);
col = treeview_.get_column(cols_count - 1);
cell = Gtk::manage (new Gtk::CellRendererText());
cols_count = treeview_.append_column (
M ("EXIFFILTER_EXPOSURECOMPENSATION"), *cell);
col = treeview_.get_column (cols_count - 1);
if (col) {
col->set_cell_data_func(
*cell, sigc::mem_fun(
col->set_cell_data_func (
*cell, sigc::mem_fun (
*this, &DynamicProfilePanel::render_expcomp));
}
show_all_children();
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)
{
row[columns_.iso] = rule.iso;
@@ -317,15 +326,15 @@ void DynamicProfilePanel::update_rule(Gtk::TreeModel::Row row,
row[columns_.profilepath] = rule.profilepath;
}
void DynamicProfilePanel::add_rule(const DynamicProfileRule &rule)
void DynamicProfilePanel::add_rule (const DynamicProfileRule &rule)
{
auto row = *(treemodel_->append());
update_rule(row, rule);
auto row = * (treemodel_->append());
update_rule (row, rule);
}
DynamicProfileRule DynamicProfilePanel::to_rule(Gtk::TreeModel::Row row,
int serial)
DynamicProfileRule DynamicProfilePanel::to_rule (Gtk::TreeModel::Row row,
int serial)
{
DynamicProfileRule ret;
ret.serial_number = serial;
@@ -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)
{
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 pse = ProfileStore::getInstance()->findEntryFromFullPath(value);
auto pse = ProfileStore::getInstance()->findEntryFromFullPath (value);
if (pse != nullptr) {
ct->property_text() = pse->label;
} else {
@@ -369,54 +379,56 @@ void DynamicProfilePanel::render_profilepath(
}
namespace {
namespace
{
template <class V>
Glib::ustring to_str(V n, int precision=1)
Glib::ustring to_str (V n, int precision = 1)
{
std::ostringstream buf;
buf << std::setprecision(precision) << std::fixed << n;
buf << std::setprecision (precision) << std::fixed << n;
return buf.str();
}
} // namespace
void DynamicProfilePanel::render_iso(
void DynamicProfilePanel::render_iso (
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)
{
RENDER_RANGE_(double, fnumber,
[](double f)
{ return std::string("f/") +
rtengine::ImageMetaData::apertureToString(f); });
RENDER_RANGE_ (double, fnumber,
[] (double f) {
return std::string ("f/") +
rtengine::ImageMetaData::apertureToString (f);
});
}
void DynamicProfilePanel::render_focallen(
void DynamicProfilePanel::render_focallen (
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)
{
RENDER_RANGE_(double, shutterspeed,
rtengine::ImageMetaData::shutterToString);
RENDER_RANGE_ (double, shutterspeed,
rtengine::ImageMetaData::shutterToString);
}
void DynamicProfilePanel::render_expcomp(
void DynamicProfilePanel::render_expcomp (
Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator &iter)
{
RENDER_RANGE_(double, expcomp, to_str);
RENDER_RANGE_ (double, expcomp, to_str);
}
#undef RENDER_RANGE_
@@ -431,17 +443,17 @@ void DynamicProfilePanel::render_expcomp(
ct->property_text() = ""; \
}
void DynamicProfilePanel::render_camera(
void DynamicProfilePanel::render_camera (
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)
{
RENDER_OPTIONAL_(lens);
RENDER_OPTIONAL_ (lens);
}
#undef RENDER_OPTIONAL_
@@ -449,28 +461,34 @@ void DynamicProfilePanel::render_lens(
void DynamicProfilePanel::on_button_up()
{
auto s = treeview_.get_selection();
if (!s->count_selected_rows()) {
return;
}
auto it = s->get_selected();
if (it != treemodel_->children().begin()) {
auto it2 = it;
--it2;
treemodel_->iter_swap(it, it2);
treemodel_->iter_swap (it, it2);
}
}
void DynamicProfilePanel::on_button_down()
{
auto s = treeview_.get_selection();
if (!s->count_selected_rows()) {
return;
}
auto it = s->get_selected();
auto it2 = it;
++it2;
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()
{
auto s = treeview_.get_selection();
if (!s->count_selected_rows()) {
return;
}
auto it = s->get_selected();
treemodel_->erase(it);
treemodel_->erase (it);
}
void DynamicProfilePanel::on_button_new()
{
EditDialog d(M("DYNPROFILEEDITOR_NEW_RULE"),
static_cast<Gtk::Window &>(*get_toplevel()));
EditDialog d (M ("DYNPROFILEEDITOR_NEW_RULE"),
static_cast<Gtk::Window &> (*get_toplevel()));
int status = d.run();
if (status == 1) {
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()
{
auto s = treeview_.get_selection();
if (!s->count_selected_rows()) {
return;
}
EditDialog d(M("DYNPROFILEEDITOR_EDIT_RULE"),
static_cast<Gtk::Window &>(*get_toplevel()));
Gtk::TreeModel::Row row = *(s->get_selected());
d.set_rule(to_rule(row));
EditDialog d (M ("DYNPROFILEEDITOR_EDIT_RULE"),
static_cast<Gtk::Window &> (*get_toplevel()));
Gtk::TreeModel::Row row = * (s->get_selected());
d.set_rule (to_rule (row));
int status = d.run();
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;
int serial = 1;
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()) {
printf("Error in saving dynamic profile rules\n");
printf ("Error in saving dynamic profile rules\n");
} 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()));
}
}

View File

@@ -23,17 +23,17 @@
#include "../rtengine/dynamicprofile.h"
#include "profilestorecombobox.h"
class DynamicProfilePanel: public Gtk::VBox {
class DynamicProfilePanel: public Gtk::VBox
{
public:
DynamicProfilePanel();
void save();
private:
void update_rule(Gtk::TreeModel::Row row,
const DynamicProfileRule &rule);
void add_rule(const DynamicProfileRule &rule);
DynamicProfileRule to_rule(Gtk::TreeModel::Row row, int serial=0);
void update_rule (Gtk::TreeModel::Row row, const DynamicProfileRule &rule);
void add_rule (const DynamicProfileRule &rule);
DynamicProfileRule to_rule (Gtk::TreeModel::Row row, int serial = 0);
void on_button_quit();
void on_button_up();
void on_button_down();
@@ -41,18 +41,19 @@ private:
void on_button_edit();
void on_button_delete();
class DynamicProfileColumns: public Gtk::TreeModel::ColumnRecord {
class DynamicProfileColumns: public Gtk::TreeModel::ColumnRecord
{
public:
DynamicProfileColumns()
{
add(iso);
add(fnumber);
add(focallen);
add(shutterspeed);
add(expcomp);
add(camera);
add(lens);
add(profilepath);
add (iso);
add (fnumber);
add (focallen);
add (shutterspeed);
add (expcomp);
add (camera);
add (lens);
add (profilepath);
}
Gtk::TreeModelColumn<DynamicProfileRule::Range<int>> iso;
@@ -66,35 +67,26 @@ private:
};
// cell renderers
void render_iso(Gtk::CellRenderer* cell,
const Gtk::TreeModel::iterator& iter);
void render_fnumber(Gtk::CellRenderer* cell,
const Gtk::TreeModel::iterator& iter);
void render_focallen(Gtk::CellRenderer* cell,
const Gtk::TreeModel::iterator& iter);
void render_shutterspeed(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);
void render_iso (Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter);
void render_fnumber (Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter);
void render_focallen (Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter);
void render_shutterspeed (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:
EditDialog(const Glib::ustring &title, Gtk::Window &parent);
void set_rule(const DynamicProfileRule &rule);
EditDialog (const Glib::ustring &title, Gtk::Window &parent);
void set_rule (const DynamicProfileRule &rule);
DynamicProfileRule get_rule();
private:
void set_ranges();
void add_range(const Glib::ustring &name,
Gtk::SpinButton *&from, Gtk::SpinButton *&to);
void add_optional(const Glib::ustring &name,
Gtk::CheckButton *&check, Gtk::Entry *&field);
void add_range (const Glib::ustring &name, Gtk::SpinButton *&from, Gtk::SpinButton *&to);
void add_optional (const Glib::ustring &name, Gtk::CheckButton *&check, Gtk::Entry *&field);
Gtk::SpinButton *iso_min_;
Gtk::SpinButton *iso_max_;

View File

@@ -87,16 +87,16 @@ Preferences::Preferences (RTWindow *rtwindow)
get_action_area()->pack_end (*ok);
get_action_area()->pack_end (*cancel);
nb->append_page (*getGeneralPanel(), M("PREFERENCES_TAB_GENERAL"));
nb->append_page (*getProcParamsPanel(), M("PREFERENCES_TAB_IMPROC"));
nb->append_page (*getDynProfilePanel(), M("PREFERENCES_TAB_DYNAMICPROFILE"));
nb->append_page (*getFileBrowserPanel(), M("PREFERENCES_TAB_BROWSER"));
nb->append_page (*getGeneralPanel(), M("PREFERENCES_TAB_GENERAL"));
nb->append_page (*getProcParamsPanel(), M("PREFERENCES_TAB_IMPROC"));
nb->append_page (*getDynProfilePanel(), M("PREFERENCES_TAB_DYNAMICPROFILE"));
nb->append_page (*getFileBrowserPanel(), M("PREFERENCES_TAB_BROWSER"));
nb->append_page (*getColorManagementPanel(), M("PREFERENCES_TAB_COLORMGR"));
nb->append_page (*getBatchProcPanel(), M("PREFERENCES_BATCH_PROCESSING"));
nb->append_page (*getPerformancePanel(), M("PREFERENCES_TAB_PERFORMANCE"));
nb->append_page (*getBatchProcPanel(), M("PREFERENCES_BATCH_PROCESSING"));
nb->append_page (*getPerformancePanel(), M("PREFERENCES_TAB_PERFORMANCE"));
// Sounds only on Windows and Linux
#if defined(WIN32) || defined(__linux__)
nb->append_page (*getSoundPanel(), M("PREFERENCES_TAB_SOUND"));
nb->append_page (*getSoundPanel(), M("PREFERENCES_TAB_SOUND"));
#endif
nb->set_current_page (0);

View File

@@ -27,17 +27,17 @@
using namespace rtengine;
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_ellipsize(Pango::ELLIPSIZE_END);
set_alignment (0, 0.5);
set_ellipsize (Pango::ELLIPSIZE_END);
show();
}
ProfileStoreComboBox::ProfileStoreComboBox ()
{
updateProfileList();
setPreferredWidth(50, 120);
setPreferredWidth (50, 120);
}
Glib::ustring ProfileStoreComboBox::getCurrentLabel()
@@ -71,16 +71,16 @@ void ProfileStoreComboBox::refreshProfileList_ (Gtk::TreeModel::Row *parentRow,
for (auto entry : *entryList) {
if (entry->parentFolderId == parentFolderId) { // filtering the entry of the same 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}" ))) {
// creating the new submenu
Gtk::TreeModel::Row newSubMenu;
if (initial) {
newSubMenu = *(refTreeModel->append());
newSubMenu = * (refTreeModel->append());
} else {
newSubMenu = *(refTreeModel->append(parentRow->children()));
newSubMenu = * (refTreeModel->append (parentRow->children()));
}
// creating and assigning the custom Label object
@@ -88,7 +88,7 @@ void ProfileStoreComboBox::refreshProfileList_ (Gtk::TreeModel::Row *parentRow,
newSubMenu[methodColumns.profileStoreEntry] = entry;
#if GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION == 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.profileStoreEntry] = entry;
#endif
@@ -101,9 +101,9 @@ void ProfileStoreComboBox::refreshProfileList_ (Gtk::TreeModel::Row *parentRow,
// creating a menu entry
if (initial) {
newItem = *(refTreeModel->append());
newItem = * (refTreeModel->append());
} else {
newItem = *(refTreeModel->append(parentRow->children()));
newItem = * (refTreeModel->append (parentRow->children()));
}
newItem[methodColumns.label] = entry->label;
@@ -123,27 +123,27 @@ void ProfileStoreComboBox::updateProfileList ()
clear();
refTreeModel.clear();
// Create the Tree model
refTreeModel = Gtk::TreeStore::create(methodColumns);
refTreeModel = Gtk::TreeStore::create (methodColumns);
// Assign the model to the Combobox
set_model(refTreeModel);
set_model (refTreeModel);
// this will lock the profilestore's entry list too
const std::vector<const ProfileStoreEntry*> *entryList = ProfileStore::getInstance()->getFileList();
//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
addRow(ProfileStore::getInstance()->getInternalDefaultPSE());
addRow (ProfileStore::getInstance()->getInternalDefaultPSE());
}
// releasing the profilestore's entry list mutex
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_set() = true;
}
@@ -153,7 +153,7 @@ Gtk::TreeIter ProfileStoreComboBox::findRowFromEntry_ (Gtk::TreeModel::Children
Gtk::TreeModel::Row row;
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;
// Hombre: is there a smarter way of knowing if this row has childs?
const ProfileStoreEntry *pse_ = row[methodColumns.profileStoreEntry];
@@ -191,7 +191,7 @@ Gtk::TreeIter ProfileStoreComboBox::findRowFromFullPath_ (Gtk::TreeModel::Childr
Gtk::TreeModel::Row row;
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;
// Hombre: is there a smarter way of knowing if this row has childs?
const ProfileStoreEntry *pse = row[methodColumns.profileStoreEntry];
@@ -222,27 +222,27 @@ Gtk::TreeIter ProfileStoreComboBox::findRowFromFullPath (Glib::ustring path)
}
if (path == DEFPROFILE_INTERNAL) {
row = findRowFromEntry(profileStore->getInternalDefaultPSE());
row = findRowFromEntry (profileStore->getInternalDefaultPSE());
return row;
}
if (path == DEFPROFILE_DYNAMIC) {
row = findRowFromEntry(profileStore->getInternalDynamicPSE());
row = findRowFromEntry (profileStore->getInternalDynamicPSE());
return row;
}
// removing the filename
Glib::ustring fName = Glib::path_get_basename(path);
Glib::ustring fName = Glib::path_get_basename (path);
if (!fName.empty()) {
path = path.substr(0, path.length() - fName.length());
path = path.substr (0, path.length() - fName.length());
} else {
// path is malformed;
return row;
}
path = Glib::path_get_dirname(path);
int parentFolderId = profileStore->findFolderId(path);
path = Glib::path_get_dirname (path);
int parentFolderId = profileStore->findFolderId (path);
// 1. find the path in the folder list
if (parentFolderId != -1) {
@@ -277,26 +277,26 @@ Glib::ustring ProfileStoreComboBox::getFullPathFromActiveRow()
}
if (currEntry == profileStore->getInternalDefaultPSE()) {
return Glib::ustring(DEFPROFILE_INTERNAL);
return Glib::ustring (DEFPROFILE_INTERNAL);
}
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;
}
bool ProfileStoreComboBox::setActiveRowFromFullPath(Glib::ustring path)
bool ProfileStoreComboBox::setActiveRowFromFullPath (Glib::ustring path)
{
if (!path.empty()) {
Gtk::TreeIter row = findRowFromFullPath(path);
Gtk::TreeIter row = findRowFromFullPath (path);
if (row) {
set_active(row);
set_active (row);
return true;
}
}
@@ -304,13 +304,13 @@ bool ProfileStoreComboBox::setActiveRowFromFullPath(Glib::ustring path)
return false;
}
bool ProfileStoreComboBox::setActiveRowFromEntry(const ProfileStoreEntry *pse)
bool ProfileStoreComboBox::setActiveRowFromEntry (const ProfileStoreEntry *pse)
{
if (pse) {
Gtk::TreeIter row = findRowFromEntry(pse);
Gtk::TreeIter row = findRowFromEntry (pse);
if (row) {
set_active(row);
set_active (row);
return true;
}
}
@@ -320,11 +320,11 @@ bool ProfileStoreComboBox::setActiveRowFromEntry(const ProfileStoreEntry *pse)
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 */
Gtk::TreeIter ProfileStoreComboBox::getRowFromLabel(Glib::ustring name)
Gtk::TreeIter ProfileStoreComboBox::getRowFromLabel (Glib::ustring name)
{
Gtk::TreeIter row;
Gtk::TreeModel::Children childs = refTreeModel->children();
@@ -332,7 +332,7 @@ Gtk::TreeIter ProfileStoreComboBox::getRowFromLabel(Glib::ustring name)
if (!name.empty()) {
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;
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 */
Gtk::TreeIter ProfileStoreComboBox::addRow(const ProfileStoreEntry *profileStoreEntry)
Gtk::TreeIter ProfileStoreComboBox::addRow (const ProfileStoreEntry *profileStoreEntry)
{
Gtk::TreeIter newEntry = refTreeModel->append();
Gtk::TreeModel::Row row = *newEntry;

View File

@@ -42,16 +42,16 @@ public:
const ProfileStoreEntry *entry;
#ifndef NDEBUG
ProfileStoreLabel() : Gtk::Label("*** error ***"), entry(nullptr) {}
ProfileStoreLabel() : Gtk::Label ("*** error ***"), entry (nullptr) {}
#else
ProfileStoreLabel() : Gtk::Label(""), entry(NULL) {}
ProfileStoreLabel() : Gtk::Label (""), entry (NULL) {}
#endif
/** @brief Create a new ProfileStoreLabel
*
* @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);
};
@@ -66,8 +66,8 @@ protected:
Gtk::TreeModelColumn<const ProfileStoreEntry*> profileStoreEntry;
MethodColumns()
{
add(label);
add(profileStoreEntry);
add (label);
add (profileStoreEntry);
}
};
@@ -75,7 +75,7 @@ protected:
MethodColumns methodColumns;
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 findRowFromFullPath_(Gtk::TreeModel::Children childs, int parentFolderId, Glib::ustring &name);
Gtk::TreeIter findRowFromFullPath_ (Gtk::TreeModel::Children childs, int parentFolderId, Glib::ustring &name);
public:
ProfileStoreComboBox();
@@ -88,8 +88,8 @@ public:
bool setActiveRowFromFullPath (Glib::ustring oldPath);
bool setActiveRowFromEntry (const ProfileStoreEntry *pse);
bool setInternalEntry ();
Gtk::TreeIter getRowFromLabel(Glib::ustring name);
Gtk::TreeIter addRow(const ProfileStoreEntry *profileStoreEntry);
Gtk::TreeIter getRowFromLabel (Glib::ustring name);
Gtk::TreeIter addRow (const ProfileStoreEntry *profileStoreEntry);
};
#endif