diff --git a/livesupport/src/products/gLiveSupport/src/OptionsWindow.cxx b/livesupport/src/products/gLiveSupport/src/OptionsWindow.cxx index 3471cc3ed..ef9ea1f56 100644 --- a/livesupport/src/products/gLiveSupport/src/OptionsWindow.cxx +++ b/livesupport/src/products/gLiveSupport/src/OptionsWindow.cxx @@ -159,6 +159,7 @@ OptionsWindow :: OptionsWindow (Ptr::Ref gLiveSupport, void OptionsWindow :: onCancelButtonClicked(void) throw () { + resetEntries(); onCloseButtonClicked(false); } @@ -172,6 +173,7 @@ OptionsWindow :: onApplyButtonClicked(void) throw () Ptr::Ref optionsContainer = gLiveSupport->getOptionsContainer(); + bool changed = false; StringEntryListType::const_iterator it; for (it = stringEntryList.begin(); it != stringEntryList.end(); ++it) { @@ -186,11 +188,29 @@ OptionsWindow :: onApplyButtonClicked(void) throw () if (*oldValue != *newValue) { try { optionsContainer->setOptionItem(optionItem, newValue); + changed = true; } catch (std::invalid_argument &e) { - // TODO: signal error + Ptr::Ref + errorMessage(new Glib::ustring( + *getResourceUstring("errorMsg") )); + errorMessage->append(e.what()); + gLiveSupport->displayMessageWindow(errorMessage); } } } + + if (changed) { + try { + Ptr::Ref + restartMessage(new Glib::ustring( + *getResourceUstring("needToRestartMsg") )); + gLiveSupport->displayMessageWindow(restartMessage); + } catch (std::invalid_argument &e) { + // TODO: signal error + std::cerr << e.what() << std::endl; + std::exit(1); + } + } } @@ -212,7 +232,8 @@ void OptionsWindow :: onCloseButtonClicked(bool needConfirm) throw () { if (needConfirm) { - //TODO: add confirmation dialog + // TODO: add confirmation dialog + // and either save changes or cancel them } gLiveSupport->putWindowPosition(shared_from_this()); hide(); @@ -495,3 +516,28 @@ OptionsWindow :: constructAboutSection(void) throw () return section; } + +/*------------------------------------------------------------------------------ + * Reset all user entries to their saved state. + *----------------------------------------------------------------------------*/ +void +OptionsWindow :: resetEntries() throw () +{ + Ptr::Ref optionsContainer + = gLiveSupport->getOptionsContainer(); + + StringEntryListType::iterator it; + for (it = stringEntryList.begin(); it != stringEntryList.end(); ++it) { + OptionsContainer::OptionItemString optionItem = it->first; + EntryBin * entry = it->second; + + try { + entry->set_text(*optionsContainer->getOptionItem(optionItem)); + + } catch (std::invalid_argument &e) { + // TODO: signal error? + entry->set_text(""); + } + } +} + diff --git a/livesupport/src/products/gLiveSupport/src/OptionsWindow.h b/livesupport/src/products/gLiveSupport/src/OptionsWindow.h index 49e1023d2..35f675749 100644 --- a/livesupport/src/products/gLiveSupport/src/OptionsWindow.h +++ b/livesupport/src/products/gLiveSupport/src/OptionsWindow.h @@ -154,6 +154,12 @@ class OptionsWindow : public WhiteWindow, public LocalizedObject createEntry(OptionsContainer::OptionItemString optionItem) throw (); + /** + * Reset all user entries to their saved state. + */ + void + resetEntries(void) throw (); + /** * Construct the "Sound" section. * diff --git a/livesupport/src/products/gLiveSupport/var/root.txt b/livesupport/src/products/gLiveSupport/var/root.txt index 2fa57641f..049a62de7 100644 --- a/livesupport/src/products/gLiveSupport/var/root.txt +++ b/livesupport/src/products/gLiveSupport/var/root.txt @@ -221,6 +221,11 @@ root:table { windowTitle:string { "LiveSupport Options Window" } + needToRestartMsg:string { "You will need to restart the " + "application\nfor the new settings " + "to take effect." } + errorMsg:string { "Could not save the options: " } + soundSectionLabel:string { "Sound" } serversSectionLabel:string { "Servers" } aboutSectionLabel:string { "About" }