added info + error messages;

fixed the behavior of the Cancel button
This commit is contained in:
fgerlits 2006-02-09 16:23:59 +00:00
parent 5835587c0a
commit c498a95b4d
3 changed files with 59 additions and 2 deletions

View file

@ -159,6 +159,7 @@ OptionsWindow :: OptionsWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
void
OptionsWindow :: onCancelButtonClicked(void) throw ()
{
resetEntries();
onCloseButtonClicked(false);
}
@ -172,6 +173,7 @@ OptionsWindow :: onApplyButtonClicked(void) throw ()
Ptr<OptionsContainer>::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<Glib::ustring>::Ref
errorMessage(new Glib::ustring(
*getResourceUstring("errorMsg") ));
errorMessage->append(e.what());
gLiveSupport->displayMessageWindow(errorMessage);
}
}
}
if (changed) {
try {
Ptr<Glib::ustring>::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<OptionsContainer>::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("");
}
}
}

View file

@ -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.
*

View file

@ -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" }