Solving issue 1206: "Caveats file handling". May also solve issue 1089: "About RT: version window disappears". This patch also cleanup the Gamma tool a little bite. The CAVEATS.txt is optional and may be deleted in future release.

This commit is contained in:
natureh
2012-01-18 00:20:19 +01:00
parent 8703bcd103
commit 66f1376131
17 changed files with 240 additions and 145 deletions

View File

@@ -16,6 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
*/
#include <iomanip>
#include "icmpanel.h"
#include "options.h"
#include "guiutils.h"
@@ -331,7 +332,7 @@ void ICMPanel::adjusterChanged (Adjuster* a, double newval) {
if (listener && freegamma->get_active()) {
Glib::ustring costr = Glib::ustring::format ((int)a->getValue());
Glib::ustring costr = Glib::ustring::format (std::setw(3), std::fixed, std::setprecision(2), newval);
if (a==gampos)
listener->panelChanged (EvGAMPOS, costr);

View File

@@ -49,7 +49,6 @@ void Options::setDefaults () {
windowWidth = 900;
windowHeight = 560;
windowMaximized = false;
firstRun = true;
savesParamsAtExit = true;
saveFormat.format = "jpg";
saveFormat.jpegQuality = 100;
@@ -79,8 +78,8 @@ void Options::setDefaults () {
profilePath = "profiles";
dirBrowserWidth = 200;
dirBrowserHeight = 150;
preferencesWidth = 0;
preferencesHeight = 0;
preferencesWidth = 0;
preferencesHeight = 0;
toolPanelWidth = 300;
browserToolPanelWidth = 300;
browserToolPanelHeight = 300;
@@ -95,7 +94,7 @@ void Options::setDefaults () {
fbShowHidden = false;
fbArrangement = 2; // was 0
multiUser = true;
version = VERSION;
version = "0.0.0.0"; // temporary value; will be correctly set in RTWindow::on_realize
thumbSize = 240; // was 80
thumbSizeTab = 80;
showHistory = true;
@@ -233,14 +232,14 @@ void Options::setDefaults () {
#endif
rtSettings.colorimetricIntent = 1;
rtSettings.monitorProfile = "";
rtSettings.autoMonitorProfile = false;
rtSettings.autoMonitorProfile = false;
rtSettings.LCMSSafeMode = true;
rtSettings.adobe = "RT_Medium_gsRGB"; // put the name of yours profiles (here windows)
rtSettings.prophoto = "RT_Large_gBT709"; // these names appear in the menu "output profile"
rtSettings.prophoto10 = "RT_Large_g10"; // these names appear in the menu "output profile"
rtSettings.srgb10 = "RT_sRGB_g10";
rtSettings.widegamut = "WideGamutRGB";
rtSettings.srgb = "RT_sRGB_gBT709";
rtSettings.srgb = "RT_sRGB";
rtSettings.bruce = "Bruce";
rtSettings.beta = "BetaRGB";
rtSettings.best = "BestRGB";
@@ -296,7 +295,6 @@ if (keyFile.has_group ("General")) {
if (keyFile.has_key ("General", "Theme")) theme = keyFile.get_string ("General", "Theme");
if (keyFile.has_key ("General", "SlimUI")) slimUI = keyFile.get_boolean ("General", "SlimUI");
if (keyFile.has_key ("General", "UseSystemTheme")) useSystemTheme = keyFile.get_boolean ("General", "UseSystemTheme");
if (keyFile.has_key ("General", "FirstRun")) firstRun = keyFile.get_boolean ("General", "FirstRun");
if( keyFile.has_key ("General", "DarkFramesPath")) rtSettings.darkFramesPath = keyFile.get_string("General", "DarkFramesPath");
if( keyFile.has_key ("General", "FlatFieldsPath")) rtSettings.flatFieldsPath = keyFile.get_string("General", "FlatFieldsPath");
if( keyFile.has_key ("General", "Verbose")) rtSettings.verbose = keyFile.get_boolean ( "General", "Verbose");
@@ -435,18 +433,16 @@ if (keyFile.has_group ("Color Management")) {
if (keyFile.has_key ("Color Management", "Intent")) rtSettings.colorimetricIntent = keyFile.get_integer("Color Management", "Intent");
if (keyFile.has_key ("Color Management", "WhiteBalanceSpotSize")) whiteBalanceSpotSize = keyFile.get_integer("Color Management", "WhiteBalanceSpotSize");
if( keyFile.has_key ("Color Management", "GamutICC")) rtSettings.gamutICC = keyFile.get_boolean("Color Management", "GamutICC");
if( keyFile.has_key ("Color Management", "RT_Adobe_RGB")) rtSettings.adobe = keyFile.get_string("Color Management", "RT_Adobe_RGB");
if( keyFile.has_key ("Color Management", "RT_Pro_Photo")) rtSettings.prophoto = keyFile.get_string("Color Management","RT_Pro_Photo");
if( keyFile.has_key ("Color Management", "RT_Pro_Photo10")) rtSettings.prophoto10 = keyFile.get_string("Color Management","RT_Pro_Photo10");
if( keyFile.has_key ("Color Management", "Wide_Gamut")) rtSettings.widegamut = keyFile.get_string("Color Management","Wide_Gamut");
if( keyFile.has_key ("Color Management", "RT_S_rgb")) rtSettings.srgb = keyFile.get_string("Color Management","RT_S_rgb");
if( keyFile.has_key ("Color Management", "RT_S_rgb10")) rtSettings.srgb10 = keyFile.get_string("Color Management","RT_S_rgb10");
if( keyFile.has_key ("Color Management", "B_eta")) rtSettings.beta = keyFile.get_string("Color Management","B_eta");
if( keyFile.has_key ("Color Management", "B_est")) rtSettings.best = keyFile.get_string("Color Management","B_est");
if( keyFile.has_key ("Color Management", "B_ruce")) rtSettings.bruce = keyFile.get_string("Color Management","B_ruce");
if( keyFile.has_key ("Color Management", "GamutICC")) rtSettings.gamutICC = keyFile.get_boolean("Color Management", "GamutICC");
if( keyFile.has_key ("Color Management", "AdobeRGB")) rtSettings.adobe = keyFile.get_string("Color Management", "AdobeRGB");
if( keyFile.has_key ("Color Management", "ProPhoto")) rtSettings.prophoto = keyFile.get_string("Color Management", "ProPhoto");
if( keyFile.has_key ("Color Management", "ProPhoto10")) rtSettings.prophoto10 = keyFile.get_string("Color Management", "ProPhoto10");
if( keyFile.has_key ("Color Management", "WideGamut")) rtSettings.widegamut = keyFile.get_string("Color Management", "WideGamut");
if( keyFile.has_key ("Color Management", "sRGB")) rtSettings.srgb = keyFile.get_string("Color Management", "sRGB");
if( keyFile.has_key ("Color Management", "sRGB10")) rtSettings.srgb10 = keyFile.get_string("Color Management", "sRGB10");
if( keyFile.has_key ("Color Management", "Beta")) rtSettings.beta = keyFile.get_string("Color Management", "Beta");
if( keyFile.has_key ("Color Management", "Best")) rtSettings.best = keyFile.get_string("Color Management", "Best");
if( keyFile.has_key ("Color Management", "Bruce")) rtSettings.bruce = keyFile.get_string("Color Management", "Bruce");
// Disabled (default is true) till issues are sorted out
//if (keyFile.has_key ("Color Management", "LCMSSafeMode")) rtSettings.LCMSSafeMode = keyFile.get_boolean ("Color Management", "LCMSSafeMode");
@@ -492,7 +488,6 @@ int Options::saveToFile (Glib::ustring fname) {
keyFile.set_boolean ("General", "SlimUI", slimUI);
keyFile.set_boolean ("General", "UseSystemTheme", useSystemTheme);
keyFile.set_string ("General", "Version", VERSION);
keyFile.set_boolean ("General", "FirstRun", false);
keyFile.set_string ("General", "DarkFramesPath", rtSettings.darkFramesPath);
keyFile.set_string ("General", "FlatFieldsPath", rtSettings.flatFieldsPath);
keyFile.set_boolean ("General", "Verbose", rtSettings.verbose);
@@ -613,22 +608,20 @@ int Options::saveToFile (Glib::ustring fname) {
keyFile.set_integer ("Crop Settings", "PPI", cropPPI);
keyFile.set_string ("Color Management", "ICCDirectory", rtSettings.iccDirectory);
keyFile.set_string ("Color Management", "ICCDirectory", rtSettings.iccDirectory);
keyFile.set_string ("Color Management", "MonitorProfile", rtSettings.monitorProfile);
keyFile.set_boolean ("Color Management", "AutoMonitorProfile", rtSettings.autoMonitorProfile);
keyFile.set_integer ("Color Management", "Intent", rtSettings.colorimetricIntent);
keyFile.set_integer ("Color Management", "Intent", rtSettings.colorimetricIntent);
keyFile.set_boolean ("Color Management", "LCMSSafeMode", rtSettings.LCMSSafeMode);
keyFile.set_string ("Color Management", "RT_Adobe_RGB", rtSettings.adobe);
keyFile.set_string ("Color Management", "RT_Pro_Photo", rtSettings.prophoto);
keyFile.set_string ("Color Management", "RT_Pro_Photo10", rtSettings.prophoto10);
keyFile.set_string ("Color Management", "Wide_Gamut", rtSettings.widegamut);
keyFile.set_string ("Color Management", "RT_S_rgb", rtSettings.srgb);
keyFile.set_string ("Color Management", "RT_S_rgb10", rtSettings.srgb10);
keyFile.set_string ("Color Management", "B_eta", rtSettings.beta);
keyFile.set_string ("Color Management", "B_est", rtSettings.best);
keyFile.set_string ("Color Management", "B_ruce", rtSettings.bruce);
keyFile.set_string ("Color Management", "AdobeRGB", rtSettings.adobe);
keyFile.set_string ("Color Management", "ProPhoto", rtSettings.prophoto);
keyFile.set_string ("Color Management", "ProPhoto10", rtSettings.prophoto10);
keyFile.set_string ("Color Management", "WideGamut", rtSettings.widegamut);
keyFile.set_string ("Color Management", "sRGB", rtSettings.srgb);
keyFile.set_string ("Color Management", "sRGB10", rtSettings.srgb10);
keyFile.set_string ("Color Management", "Beta", rtSettings.beta);
keyFile.set_string ("Color Management", "Best", rtSettings.best);
keyFile.set_string ("Color Management", "Bruce", rtSettings.bruce);
keyFile.set_integer ("Color Management", "WhiteBalanceSpotSize", whiteBalanceSpotSize);
keyFile.set_boolean ("Color Management", "GamutICC", rtSettings.gamutICC);

View File

@@ -49,7 +49,6 @@ class Options {
void error (int line);
public:
bool firstRun;
bool savesParamsAtExit;
SaveFormat saveFormat,saveFormatBatch;
Glib::ustring savePathTemplate;

View File

@@ -33,6 +33,8 @@ extern Glib::ustring argv0;
Preferences::Preferences (RTWindow *rtwindow):parent(rtwindow) {
splash = NULL;
set_title (M("MAIN_BUTTON_PREFERENCES"));
moptions.copyFrom (&options);
@@ -1296,9 +1298,9 @@ void Preferences::selectStartupDir () {
void Preferences::aboutPressed () {
Splash* splash = new Splash ();
splash = new Splash (*this);
splash->set_transient_for (*this);
splash->set_modal (true);
splash->signal_delete_event().connect( sigc::mem_fun(*this, &Preferences::splashClosed) );
splash->show ();
}
@@ -1478,3 +1480,9 @@ void Preferences::updateFFinfos()
Glib::ustring s = Glib::ustring::compose("%1: %2 %3, %4 %5", M("PREFERENCES_FLATFIELDFOUND"), t1, M("PREFERENCES_FLATFIELDSHOTS"), t2, M("PREFERENCES_FLATFIELDTEMPLATES"));
ffLabel->set_text(s);
}
bool Preferences::splashClosed(GdkEventAny* event) {
delete splash;
splash = NULL;
return true;
}

View File

@@ -51,6 +51,7 @@ class Preferences : public Gtk::Dialog {
protected:
Splash* splash;
Gtk::ComboBoxText* rprofiles;
Gtk::ComboBoxText* iprofiles;
Gtk::ComboBoxText* languages;
@@ -159,6 +160,7 @@ class Preferences : public Gtk::Dialog {
void cacheFormatComboChanged ();
void switchThemeTo (Glib::ustring newTheme, bool slimInterface);
void switchFontTo (Glib::ustring newFont);
bool splashClosed(GdkEventAny* event);
void appendBehavList (Gtk::TreeModel::iterator& parent, Glib::ustring label, int id, bool set);

View File

@@ -16,6 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
*/
#include "rtwindow.h"
#include "options.h"
#include "preferences.h"
@@ -28,6 +29,7 @@ RTWindow::RTWindow ()
,bpanel(NULL)
,epanel(NULL)
,fpanel(NULL)
,splash(NULL)
{
cacheMgr->init ();
@@ -202,6 +204,27 @@ RTWindow::RTWindow ()
if (!isSingleTabMode()&& !simpleEditor) epanel->hide_all();
}
void RTWindow::findVerNumbers(int* numbers, Glib::ustring versionStr) {
numbers[0] = numbers[1] = numbers[2] = numbers[3] = 0;
int n=0;
for (unsigned int i=0; i<versionStr.length(); i++) {
char chr = (char)versionStr.at(i);
if (chr >= '0' && chr <= '9') {
numbers[n] *= 10;
numbers[n] += (int)(chr - '0');
}
else {
n++;
if (n>4) {
printf("Error: malformed version string; \"%s\" must follow this format: xx.xx.xx.xx. Admitting it's a developer version...\n", versionStr.c_str());
// Reseting the already found numbers
numbers[0] = numbers[1] = numbers[2] = numbers[3] = 100;
return;
}
}
}
}
void RTWindow::on_realize () {
Gtk::Window::on_realize ();
@@ -209,6 +232,38 @@ void RTWindow::on_realize () {
fpanel->setAspect();
cursorManager.init (get_window());
// Check if first run of this version, then display the caveats text
if (options.version != versionString) {
int prevVerNbr[4];
int currVerNbr[4];
findVerNumbers(prevVerNbr, options.version);
findVerNumbers(currVerNbr, versionString);
// Now we can update the version parameter with the right value
options.version = versionString;
bool showCaveats = false;
// Check if the current version is newer
if (currVerNbr[0] > prevVerNbr[0]) showCaveats = true;
else if (currVerNbr[1] > prevVerNbr[1]) showCaveats = true;
else if (currVerNbr[2] > prevVerNbr[2]) showCaveats = true;
if (showCaveats) {
// this is a first run!
splash = new Splash (*this);
splash->set_transient_for (*this);
splash->signal_delete_event().connect( sigc::mem_fun(*this, &RTWindow::splashClosed) );
if (splash->hasCaveats()) {
splash->showCaveats();
splash->show ();
}
else {
delete splash;
splash = NULL;
}
}
}
}
bool RTWindow::on_window_state_event(GdkEventWindowState* event) {
@@ -317,7 +372,7 @@ bool RTWindow::selectEditorPanel(const std::string &name) {
bool RTWindow::keyPressed (GdkEventKey* event) {
bool ctrl = event->state & GDK_CONTROL_MASK;
bool shift = event->state & GDK_SHIFT_MASK;
//bool shift = event->state & GDK_SHIFT_MASK;
if (ctrl) {
switch(event->keyval) {
@@ -397,8 +452,6 @@ bool RTWindow::on_delete_event(GdkEventAny* event) {
WhiteBalance::cleanup();
options.firstRun = false;
if (!options.windowMaximized) {
options.windowWidth = get_width();
options.windowHeight = get_height();
@@ -531,3 +584,9 @@ void RTWindow::updateHistogramPosition (int oldPosition, int newPosition) {
((*itr).second)->updateHistogramPosition (oldPosition, newPosition);
}
}
bool RTWindow::splashClosed(GdkEventAny* event) {
delete splash;
splash = NULL;
return true;
}

View File

@@ -25,6 +25,7 @@
#include <set>
#include "progressconnector.h"
#include "editwindow.h"
#include "splash.h"
class RTWindow : public Gtk::Window, public rtengine::ProgressListener{
@@ -34,6 +35,7 @@ class RTWindow : public Gtk::Window, public rtengine::ProgressListener{
std::set<Glib::ustring> filesEdited;
std::map<Glib::ustring, EditorPanel*> epanels;
Splash* splash;
Gtk::ProgressBar prProgBar;
PLDBridge* pldBridge;
bool is_fullscreen;
@@ -42,9 +44,11 @@ class RTWindow : public Gtk::Window, public rtengine::ProgressListener{
Gtk::Image *iFullscreen, *iFullscreen_exit;
bool isSingleTabMode() { return !options.tabbedUI && !EditWindow::isMultiDisplayEnabled(); };
void findVerNumbers(int* numbers, Glib::ustring versionStr);
bool on_expose_event_epanel(GdkEventExpose* event);
bool on_expose_event_fpanel(GdkEventExpose* event);
bool splashClosed(GdkEventAny* event);
public:
RTWindow ();

View File

@@ -70,16 +70,17 @@ bool SplashImage::on_expose_event (GdkEventExpose* event) {
return true;
}
Splash::Splash () {
Splash::Splash (Gtk::Window& parent) : Gtk::Dialog(M("GENERAL_ABOUT"), parent, true) {
set_title (M("GENERAL_ABOUT"));
set_border_width (4);
Gtk::Notebook* nb = Gtk::manage (new Gtk::Notebook ());
caveatsSW = NULL;
nb = Gtk::manage (new Gtk::Notebook ());
get_vbox()->pack_start (*nb);
// Tab 1: the image
splashImage = new SplashImage ();
splashImage = Gtk::manage(new SplashImage ());
nb->append_page (*splashImage, M("ABOUT_TAB_SPLASH"));
splashImage->show ();
@@ -145,13 +146,36 @@ Splash::Splash () {
textBuffer->set_text((Glib::ustring)(ostr.str()));
Gtk::ScrolledWindow *licenseSW = Gtk::manage (new Gtk::ScrolledWindow());
Gtk::TextView *creditsTV = Gtk::manage (new Gtk::TextView (textBuffer));
creditsTV->set_editable(false);
licenseSW->add(*creditsTV);
Gtk::TextView *licenseTV = Gtk::manage (new Gtk::TextView (textBuffer));
licenseTV->set_editable(false);
licenseSW->add(*licenseTV);
nb->append_page (*licenseSW, M("ABOUT_TAB_LICENSE"));
}
}
// Tab 5: the caveats
std::string caveatsFileName = Glib::build_filename (creditsPath, "CAVEATS.txt");
if ( safe_file_test(caveatsFileName, (Glib::FILE_TEST_EXISTS)) ) {
FILE *f = safe_g_fopen (caveatsFileName, "rt");
if (f != NULL) {
char* buffer = new char[1024];
std::ostringstream ostr;
while (fgets (buffer, 1024, f))
ostr << buffer;
delete [] buffer;
fclose (f);
Glib::RefPtr<Gtk::TextBuffer> textBuffer = Gtk::TextBuffer::create();
textBuffer->set_text((Glib::ustring)(ostr.str()));
caveatsSW = Gtk::manage (new Gtk::ScrolledWindow());
Gtk::TextView *caveatsTV = Gtk::manage (new Gtk::TextView (textBuffer));
caveatsTV->set_editable(false);
caveatsSW->add(*caveatsTV);
nb->append_page (*caveatsSW, M("ABOUT_TAB_CAVEATS"));
}
}
set_position (Gtk::WIN_POS_CENTER);
//add_events(Gdk::BUTTON_RELEASE_MASK);
@@ -160,15 +184,12 @@ Splash::Splash () {
nb->set_current_page (0);
show_all_children ();
set_modal (true);
set_keep_above (true);
}
Splash::Splash (int maxtime) {
Splash::Splash (Gtk::Window& parent, int maxtime) : Gtk::Dialog(M("GENERAL_ABOUT"), parent, true) {
set_title (M("GENERAL_ABOUT"));
splashImage = new SplashImage ();
splashImage = Gtk::manage(new SplashImage ());
// add (*splashImage);
get_vbox()->pack_start (*splashImage);
splashImage->show ();
@@ -190,8 +211,16 @@ bool Splash::on_timer () {
return false;
}
/*
* removed as it seem to be too sensitive in some OS
bool Splash::on_button_release_event (GdkEventButton* event) {
hide ();
return true;
}
*/
void Splash::showCaveats() {
if (caveatsSW)
nb->set_current_page(nb->page_num(*caveatsSW));
}

View File

@@ -39,13 +39,17 @@ class Splash : public Gtk::Dialog {
private:
SplashImage* splashImage;
Gtk::Notebook* nb;
Gtk::ScrolledWindow* caveatsSW;
public:
Splash (int maxtime);
Splash ();
Splash (Gtk::Window& parent, int maxtime);
Splash (Gtk::Window& parent);
bool hasCaveats() { return caveatsSW != NULL; };
void showCaveats();
bool on_timer ();
virtual bool on_button_release_event (GdkEventButton* event);
//virtual bool on_button_release_event (GdkEventButton* event);
};
#endif