run through astyle

This commit is contained in:
Alberto Griggio 2017-08-22 08:53:17 +02:00
parent 511f6c2a7b
commit b39f072baf
7 changed files with 1911 additions and 1817 deletions

View File

@ -184,6 +184,7 @@ int main(int argc, char **argv)
#if ECLIPSE_ARGS
fname = fname.substr (1, fname.length() - 2);
#endif
if (options.rtSettings.verbose || ( !Glib::file_test (fname, Glib::FILE_TEST_EXISTS ) && !Glib::file_test (fname, Glib::FILE_TEST_IS_DIR))) {
bool stdoutRedirectedtoFile = (GetFileType (GetStdHandle (STD_OUTPUT_HANDLE)) == 0x0001);
bool stderrRedirectedtoFile = (GetFileType (GetStdHandle (STD_ERROR_HANDLE)) == 0x0001);
@ -238,25 +239,28 @@ int main(int argc, char **argv)
}
}
}
#endif
int ret = 0;
// printing RT's version in all case, particularly useful for the 'verbose' mode, but also for the batch processing
std::cout << "RawTherapee, version " << RTVERSION << ", command line" << std::endl;
if (argc > 1) {
ret = processLineParams (argc, argv);
}
else {
} else {
std::cout << "Terminating without anything to do." << std::endl;
}
#ifdef WIN32
if (consoleOpened) {
printf ("Press any key to exit RawTherapee\n");
FlushConsoleInputBuffer (GetStdHandle (STD_INPUT_HANDLE));
getch();
}
#endif
return ret;
@ -281,6 +285,7 @@ bool dontLoadCache( int argc, char **argv )
#if ECLIPSE_ARGS
currParam = currParam.substr (1, currParam.length() - 2);
#endif
if ( currParam.at (0) == '-' && currParam.at (1) == 'q' ) {
return true;
}
@ -315,6 +320,7 @@ int processLineParams( int argc, char **argv )
#if ECLIPSE_ARGS
currParam = currParam.substr (1, currParam.length() - 2);
#endif
if ( currParam.at (0) == '-' ) {
switch ( currParam.at (1) ) {
case 'O':
@ -327,6 +333,7 @@ int processLineParams( int argc, char **argv )
#if ECLIPSE_ARGS
outputPath = outputPath.substr (1, outputPath.length() - 2);
#endif
if (outputPath.substr (0, 9) == "/dev/null") {
outputPath.assign ("/dev/null"); // removing any useless chars or filename
outputDirectory = false;
@ -460,16 +467,17 @@ int processLineParams( int argc, char **argv )
if (Glib::file_test (argument, Glib::FILE_TEST_IS_REGULAR)) {
bool notAll = allExtensions && !options.is_parse_extention (argument);
bool notRetained = !allExtensions && !options.has_retained_extention (argument);
if (notAll || notRetained) {
if (notAll) {
std::cout << "\"" << argument << "\" is not one of the file format to process: skipped" << std::endl;
} else if (notRetained) {
std::cout << "\"" << argument << "\" is not one of the retained file format to process: skipped" << std::endl;
}
}
else {
} else {
inputFiles.emplace_back (argument);
}
continue;
}
@ -477,6 +485,7 @@ int processLineParams( int argc, char **argv )
if (Glib::file_test (argument, Glib::FILE_TEST_IS_DIR)) {
auto dir = Gio::File::create_for_path (argument);
if (!dir || !dir->query_exists()) {
continue;
}
@ -500,6 +509,7 @@ int processLineParams( int argc, char **argv )
} else if (notRetained) {
std::cout << "\"" << fileName << "\" is not one of the retained file format to process: skipped" << std::endl;
}
continue;
}
@ -745,6 +755,7 @@ int processLineParams( int argc, char **argv )
delete rawParams;
rawParams = ProfileStore::getInstance()->loadDynamicProfile (ii->getMetaData());
}
std::cout << " Merging default raw processing profile" << std::endl;
rawParams->applyTo (&currentParams);
} else {
@ -753,6 +764,7 @@ int processLineParams( int argc, char **argv )
delete imgParams;
imgParams = ProfileStore::getInstance()->loadDynamicProfile (ii->getMetaData());
}
std::cout << " Merging default non-raw processing profile" << std::endl;
imgParams->applyTo (&currentParams);
}

View File

@ -125,6 +125,7 @@ int processLineParams( int argc, char **argv )
#if ECLIPSE_ARGS
currParam = currParam.substr (1, currParam.length() - 2);
#endif
if ( currParam.at (0) == '-' ) {
switch ( currParam.at (1) ) {
#ifdef WIN32
@ -132,14 +133,17 @@ int processLineParams( int argc, char **argv )
case 'w': // This case is handled outside this function
break;
#endif
case 'v':
return 0;
#ifndef __APPLE__ // TODO agriggio - there seems to be already some "single instance app" support for OSX in rtwindow. Disabling it here until I understand how to merge the two
case 'R':
if (!gimpPlugin) {
remote = true;
}
break;
#endif
@ -150,6 +154,7 @@ int processLineParams( int argc, char **argv )
remote = false;
break;
}
// no break here on purpose
case 'h':
@ -195,6 +200,7 @@ int processLineParams( int argc, char **argv )
argv2 = Glib::ustring (fname_to_utf8 (argv[iArg]));
break;
}
if (!gimpPlugin) {
break;
}
@ -259,16 +265,20 @@ RTWindow *create_rt_window()
Glib::RefPtr<Glib::Regex> regex = Glib::Regex::create (THEMEREGEXSTR, Glib::RegexCompileFlags::REGEX_CASELESS);
Glib::ustring filename = Glib::build_filename (argv0, "themes", options.theme + ".css");
if (!regex->match (options.theme + ".css") || !Glib::file_test (filename, Glib::FILE_TEST_EXISTS)) {
options.theme = "RawTherapee-GTK";
// We're not testing GTK_MAJOR_VERSION == 3 here, since this branch requires Gtk3 only
if (GTK_MINOR_VERSION < 20) {
options.theme = options.theme + "3-_19";
} else {
options.theme = options.theme + "3-20_";
}
filename = Glib::build_filename (argv0, "themes", options.theme + ".css");
}
cssRT = Gtk::CssProvider::create();
try {
@ -327,7 +337,8 @@ RTWindow *create_rt_window()
}
class RTApplication: public Gtk::Application {
class RTApplication: public Gtk::Application
{
public:
RTApplication():
Gtk::Application ("com.rawtherapee.application",
@ -341,6 +352,7 @@ public:
if (rtWindow) {
delete rtWindow;
}
cleanup_rt();
}
@ -385,6 +397,7 @@ private:
for (const auto &f : files) {
Thumbnail *thm = cacheMgr->getEntry (f->get_path());
if (thm) {
d->entries.push_back (thm);
d->lastfilename = f->get_path();
@ -393,8 +406,7 @@ private:
if (!d->entries.empty()) {
const auto doit =
[](gpointer data) -> gboolean
{
[] (gpointer data) -> gboolean {
Data *d = static_cast<Data *> (data);
d->filecatalog->openRequested (d->entries);
d->filecatalog->selectImage (d->lastfilename, true);
@ -405,6 +417,7 @@ private:
} else {
delete d;
}
rtWindow->present();
}
}
@ -486,6 +499,7 @@ int main(int argc, char **argv)
if (argc > 1) {
int ret = processLineParams ( argc, argv);
if (options.rtSettings.verbose || (!remote && !Glib::file_test (argv1, Glib::FILE_TEST_EXISTS ) && !Glib::file_test (argv1, Glib::FILE_TEST_IS_DIR))) {
bool stdoutRedirectedtoFile = (GetFileType (GetStdHandle (STD_OUTPUT_HANDLE)) == 0x0001);
bool stderrRedirectedtoFile = (GetFileType (GetStdHandle (STD_ERROR_HANDLE)) == 0x0001);
@ -576,6 +590,7 @@ int main(int argc, char **argv)
printf ("Error: argv1 doesn't exist\n");
return 1;
}
if (argv2.empty()) {
printf ("Error: -gimp requires two arguments\n");
return 1;
@ -585,13 +600,16 @@ int main(int argc, char **argv)
}
int ret = 0;
if (remote) {
char *app_argv[2] = { const_cast<char *> (argv0.c_str()) };
int app_argc = 1;
if (!argv1.empty()) {
app_argc = 2;
app_argv[1] = const_cast<char *> (argv1.c_str());
}
RTApplication app;
ret = app.run (app_argc, app_argv);
} else {
@ -614,6 +632,7 @@ int main(int argc, char **argv)
ret = -2;
}
}
cleanup_rt();
} else {
Gtk::Main m (&argc, &argv);

View File

@ -1831,6 +1831,7 @@ void Options::readFromFile (Glib::ustring fname)
if (keyFile.has_key ("Fast Export", "fastexport_resize_height" )) {
fastexport_resize_height = keyFile.get_integer ("Fast Export", "fastexport_resize_height" );
}
if (keyFile.has_key ("Fast Export", "fastexport_use_fast_pipeline" )) {
fastexport_use_fast_pipeline = keyFile.get_integer ("Fast Export", "fastexport_use_fast_pipeline" );
}
@ -1864,15 +1865,19 @@ void Options::readFromFile (Glib::ustring fname)
}
} catch (Glib::Error &err) {
Glib::ustring msg = Glib::ustring::compose ("Options::readFromFile / Error code %1 while reading values from \"%2\":\n%3", err.code(), fname, err.what());
if (options.rtSettings.verbose) {
printf ("%s\n", msg.c_str());
}
throw Error (msg);
} catch (...) {
Glib::ustring msg = Glib::ustring::compose ("Options::readFromFile / Unknown exception while trying to load \"%1\"!", fname);
if (options.rtSettings.verbose) {
printf ("%s\n", msg.c_str());
}
throw Error (msg);
}
}

View File

@ -43,8 +43,7 @@
// Special name for the Dynamic profile
#define DEFPROFILE_DYNAMIC "Dynamic"
struct SaveFormat
{
struct SaveFormat {
SaveFormat() :
format ("jpg"),
pngBits (8),
@ -75,11 +74,18 @@ enum prevdemo_t {PD_Sidecar = 1, PD_Fast = 0};
class Options
{
public:
class Error: public std::exception {
class Error: public std::exception
{
public:
Error (const Glib::ustring &msg): msg_ (msg) {}
const char *what() const throw() { return msg_.c_str(); }
const Glib::ustring &get_msg() const throw() { return msg_; }
const char *what() const throw()
{
return msg_.c_str();
}
const Glib::ustring &get_msg() const throw()
{
return msg_;
}
private:
Glib::ustring msg_;

View File

@ -125,6 +125,7 @@ int Preferences::getThemeRowNumber(Glib::ustring& longThemeFName)
}
}
}
return -1;
}
@ -742,6 +743,7 @@ Gtk::Widget* Preferences::getColorManagementPanel ()
monProfile->set_active (0);
const std::vector<Glib::ustring> profiles = rtengine::ICCStore::getInstance ()->getProfiles (rtengine::ICCStore::ProfileType::MONITOR);
for (const auto profile : profiles) {
if (profile.find ("file:") != 0) {
monProfile->append (profile);
@ -811,8 +813,10 @@ Gtk::Widget* Preferences::getColorManagementPanel ()
prtProfile->set_active (0);
const std::vector<Glib::ustring> prtprofiles = rtengine::ICCStore::getInstance ()->getProfiles (rtengine::ICCStore::ProfileType::PRINTER);
for (const auto prtprofile : prtprofiles)
for (const auto prtprofile : prtprofiles) {
prtProfile->append (prtprofile);
}
// same order as the enum
prtIntent->append (M ("PREFERENCES_INTENT_PERCEPTUAL"));
@ -1042,6 +1046,7 @@ Gtk::Widget* Preferences::getGeneralPanel ()
fontButton = Gtk::manage ( new Gtk::FontButton ());
setExpandAlignProperties (fontButton, false, false, Gtk::ALIGN_FILL, Gtk::ALIGN_BASELINE);
fontButton->set_use_size (true);
if (options.fontFamily == "default") {
fontButton->set_font_name (Glib::ustring::compose ("%1 %2", initialFontFamily, initialFontSize));
} else {
@ -1056,6 +1061,7 @@ Gtk::Widget* Preferences::getGeneralPanel ()
colorPickerFontButton = Gtk::manage ( new Gtk::FontButton ());
setExpandAlignProperties (fontButton, false, false, Gtk::ALIGN_FILL, Gtk::ALIGN_BASELINE);
colorPickerFontButton->set_use_size (true);
if (options.fontFamily == "default") {
colorPickerFontButton->set_font_name (Glib::ustring::compose ("%1 %2", initialFontFamily, initialFontSize));
} else {
@ -1530,23 +1536,27 @@ void Preferences::parseThemeDir (Glib::ustring dirname)
if (!minMinor.empty()) {
guint64 minMinorVal = g_ascii_strtoll (minMinor.c_str(), 0, 0);
if ((guint64)GTK_MINOR_VERSION >= minMinorVal) {
keepIt = true;
}
}
if (!maxMinor.empty()) {
guint64 maxMinorVal = g_ascii_strtoll (maxMinor.c_str(), 0, 0);
if ((guint64)GTK_MINOR_VERSION <= maxMinorVal) {
keepIt = true;
}
}
if (keepIt) {
themeFNames.push_back (ThemeFilename (matchInfo.fetch (1), sname.substr (0, sname.size() - 4)));
}
}
}
std::sort(themeFNames.begin(), themeFNames.end(), [] (const ThemeFilename& firstDir, const ThemeFilename& secondDir)
{
std::sort (themeFNames.begin(), themeFNames.end(), [] (const ThemeFilename & firstDir, const ThemeFilename & secondDir) {
return firstDir.longFName < secondDir.longFName;
});
@ -1600,12 +1610,14 @@ void Preferences::storePreferences ()
moptions.navGuideBrush[3] = butNavGuideCol->get_alpha() / 65535.0;
Pango::FontDescription fd (fontButton->get_font_name());
if (newFont) {
moptions.fontFamily = fd.get_family();
moptions.fontSize = fd.get_size() / Pango::SCALE;
}
Pango::FontDescription cpfd (colorPickerFontButton->get_font_name());
if (newCPFont) {
moptions.CPFontFamily = cpfd.get_family();
moptions.CPFontSize = cpfd.get_size() / Pango::SCALE;
@ -1646,38 +1658,47 @@ void Preferences::storePreferences ()
} else {
moptions.rtSettings.printerProfile = prtProfile->get_active_text ();
}
switch (prtIntent->get_active_row_number ()) {
default:
case 0:
moptions.rtSettings.printerIntent = rtengine::RI_PERCEPTUAL;
break;
case 1:
moptions.rtSettings.printerIntent = rtengine::RI_RELATIVE;
break;
case 2:
moptions.rtSettings.printerIntent = rtengine::RI_ABSOLUTE;
break;
}
moptions.rtSettings.printerBPC = prtBPC->get_active ();
#if !defined(__APPLE__) // monitor profile not supported on apple
if (!monProfile->get_active_row_number()) {
moptions.rtSettings.monitorProfile = "";
} else {
moptions.rtSettings.monitorProfile = monProfile->get_active_text ();
}
switch (monIntent->get_active_row_number ()) {
default:
case 0:
moptions.rtSettings.monitorIntent = rtengine::RI_PERCEPTUAL;
break;
case 1:
moptions.rtSettings.monitorIntent = rtengine::RI_RELATIVE;
break;
case 2:
moptions.rtSettings.monitorIntent = rtengine::RI_ABSOLUTE;
break;
}
moptions.rtSettings.monitorBPC = monBPC->get_active ();
//#if defined(WIN32)
moptions.rtSettings.autoMonitorProfile = cbAutoMonProfile->get_active ();
@ -1799,34 +1820,42 @@ void Preferences::fillPreferences ()
ctiffserialize->set_active (moptions.serializeTiffRead);
setActiveTextOrIndex (*prtProfile, moptions.rtSettings.printerProfile, 0);
switch (moptions.rtSettings.printerIntent) {
default:
case rtengine::RI_PERCEPTUAL:
prtIntent->set_active (0);
break;
case rtengine::RI_RELATIVE:
prtIntent->set_active (1);
break;
case rtengine::RI_ABSOLUTE:
prtIntent->set_active (2);
break;
}
prtBPC->set_active (moptions.rtSettings.printerBPC);
#if !defined(__APPLE__) // monitor profile not supported on apple
setActiveTextOrIndex (*monProfile, moptions.rtSettings.monitorProfile, 0);
switch (moptions.rtSettings.monitorIntent) {
default:
case rtengine::RI_PERCEPTUAL:
monIntent->set_active (0);
break;
case rtengine::RI_RELATIVE:
monIntent->set_active (1);
break;
case rtengine::RI_ABSOLUTE:
monIntent->set_active (2);
break;
}
monBPC->set_active (moptions.rtSettings.monitorBPC);
//#if defined(WIN32)
cbAutoMonProfile->set_active (moptions.rtSettings.autoMonitorProfile);
@ -2066,12 +2095,14 @@ void Preferences::okPressed ()
workflowUpdate();
options.copyFrom (&moptions);
options.filterOutParsedExtensions();
try {
Options::save ();
} catch (Options::Error &e) {
Gtk::MessageDialog msgd (getToplevelWindow (this), e.get_msg(), true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_CLOSE, true);
msgd.run();
}
dynProfilePanel->save();
hide ();
}
@ -2087,6 +2118,7 @@ void Preferences::cancelPressed ()
// set the initial font back
Pango::FontDescription fd (fontButton->get_font_name());
if (fd.get_family() != options.fontFamily && (fd.get_size() / Pango::SCALE) != options.fontSize) {
if (options.fontFamily == "default") {
switchFontTo (initialFontFamily, initialFontSize);
@ -2221,8 +2253,9 @@ void Preferences::iccDirChanged ()
monProfile->append (M ("PREFERENCES_PROFILE_NONE"));
for (const auto& profile : profiles)
for (const auto& profile : profiles) {
monProfile->append (profile);
}
setActiveTextOrIndex (*monProfile, currentSelection, 0);
}
@ -2324,8 +2357,7 @@ void Preferences::switchFontTo(const Glib::ustring &newFontFamily, const int new
} catch (...) {
printf ("Error: Can't find the font named \"%s\"\n", newFontFamily.c_str());
}
}
else {
} else {
if (fontcss) {
fontcss = Gtk::CssProvider::create();
Glib::RefPtr<Gdk::Screen> screen = Gdk::Screen::get_default();
@ -2368,8 +2400,7 @@ void Preferences::workflowUpdate ()
if ( moptions.rtSettings.printerProfile != options.rtSettings.printerProfile
|| moptions.rtSettings.printerBPC != options.rtSettings.printerBPC
||moptions.rtSettings.printerIntent != options.rtSettings.printerIntent)
{
|| moptions.rtSettings.printerIntent != options.rtSettings.printerIntent) {
// Update the position of the Histogram
parent->updateProfiles (moptions.rtSettings.printerProfile, moptions.rtSettings.printerIntent, moptions.rtSettings.printerBPC);
}
@ -2401,12 +2432,16 @@ void Preferences::delExtPressed ()
void Preferences::moveExtUpPressed ()
{
const Glib::RefPtr<Gtk::TreeSelection> selection = extensions->get_selection ();
if (!selection)
if (!selection) {
return;
}
const Gtk::TreeModel::iterator selected = selection->get_selected ();
if (!selected || selected == extensionModel->children ().begin ())
if (!selected || selected == extensionModel->children ().begin ()) {
return;
}
Gtk::TreeModel::iterator previous = selected;
--previous;
@ -2416,17 +2451,23 @@ void Preferences::moveExtUpPressed ()
void Preferences::moveExtDownPressed ()
{
const Glib::RefPtr<Gtk::TreeSelection> selection = extensions->get_selection ();
if (!selection)
if (!selection) {
return;
}
const Gtk::TreeModel::iterator selected = selection->get_selected ();
if (!selected)
if (!selected) {
return;
}
Gtk::TreeModel::iterator next = selected;
if (++next)
if (++next) {
extensionModel->iter_swap (selected, next);
}
}
void Preferences::clearProfilesPressed ()
{

View File

@ -130,12 +130,14 @@ RTWindow::RTWindow ()
Gdk::Rectangle lMonitorRect;
get_screen()->get_monitor_geometry (std::min (options.windowMonitor, Gdk::Screen::get_default()->get_n_monitors() - 1), lMonitorRect);
if (options.windowMaximized) {
move (lMonitorRect.get_x(), lMonitorRect.get_y());
maximize();
} else {
unmaximize();
resize (options.windowWidth, options.windowHeight);
if (options.windowX <= lMonitorRect.get_x() + lMonitorRect.get_width() && options.windowY <= lMonitorRect.get_y() + lMonitorRect.get_height()) {
move (options.windowX, options.windowY);
} else {
@ -273,6 +275,7 @@ RTWindow::RTWindow ()
if (!argv1.empty() && !remote) {
Thumbnail* thm = cacheMgr->getEntry (argv1);
if (thm) {
fpanel->fileCatalog->openRequested ({thm});
}
@ -316,6 +319,7 @@ void RTWindow::on_realize ()
std::regex pat ("(^[0-9.]+).*");
std::smatch sm;
std::vector<std::string> vMajor;
for (const auto &v : vs) {
if (std::regex_match (v, sm, pat)) {
if (sm.size() == 2) {
@ -361,6 +365,7 @@ bool RTWindow::on_window_state_event(GdkEventWindowState* event)
if (event->changed_mask & GDK_WINDOW_STATE_MAXIMIZED) {
options.windowMaximized = event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED;
}
return Gtk::Widget::on_window_state_event (event);
}
@ -679,6 +684,7 @@ bool RTWindow::on_delete_event(GdkEventAny* event)
Gtk::MessageDialog msgd (getToplevelWindow (this), e.get_msg(), true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_CLOSE, true);
msgd.run();
}
hide();
on_delete_has_run = true;
@ -692,9 +698,11 @@ void RTWindow::showPreferences ()
delete pref;
fpanel->optionsChanged ();
if (epanel) {
epanel->defaultMonitorProfileChanged (options.rtSettings.monitorProfile, options.rtSettings.autoMonitorProfile);
}
for (const auto &p : epanels) {
p.second->defaultMonitorProfileChanged (options.rtSettings.monitorProfile, options.rtSettings.autoMonitorProfile);
}
@ -800,6 +808,7 @@ void RTWindow::updateProfiles(const Glib::ustring &printerProfile, rtengine::Ren
void RTWindow::updateTPVScrollbar (bool hide)
{
fpanel->updateTPVScrollbar (hide);
if (epanel) {
epanel->updateTPVScrollbar (hide);
}
@ -812,6 +821,7 @@ void RTWindow::updateTPVScrollbar (bool hide)
void RTWindow::updateTabsUsesIcons (bool useIcons)
{
fpanel->updateTabsUsesIcons (useIcons);
if (epanel) {
epanel->updateTabsUsesIcons (useIcons);
}
@ -836,6 +846,7 @@ void RTWindow::updateHistogramPosition (int oldPosition, int newPosition)
if (epanel) {
epanel->updateHistogramPosition (oldPosition, newPosition);
}
for (auto panel : epanels) {
panel.second->updateHistogramPosition (oldPosition, newPosition);
}