made the Cancel button work correctly for RDS entries (part of #722)

This commit is contained in:
fgerlits 2007-01-15 12:07:41 +00:00
parent 6cab754062
commit 89fc941937
7 changed files with 76 additions and 22 deletions

View File

@ -344,7 +344,7 @@ void
OptionsContainer :: writeToFile(void) throw ()
{
if (configFileName) {
if (rdsContainer) {
if (rdsContainer && rdsContainer->isTouched()) {
xmlpp::Element * rootNode = optionsDocument.get_root_node();
xmlpp::Node::NodeList nodes = rootNode->get_children(
RdsContainer::getConfigElementName());

View File

@ -183,6 +183,7 @@ OptionsWindow :: onCancelButtonClicked(void) throw ()
{
resetEntries();
resetKeyBindings();
resetRds();
onCloseButtonClicked(false);
}
@ -907,6 +908,16 @@ OptionsWindow :: resetKeyBindings(void) throw ()
}
/*------------------------------------------------------------------------------
* Reset the RDS settings to their saved state.
*----------------------------------------------------------------------------*/
void
OptionsWindow :: resetRds(void) throw ()
{
rdsView->reset();
}
/*------------------------------------------------------------------------------
* Event handler for clicking on a row in the key bindings table.
*----------------------------------------------------------------------------*/

View File

@ -165,6 +165,12 @@ class OptionsWindow : public GuiWindow
void
resetKeyBindings(void) throw ();
/**
* Reset the RDS settings to their saved state.
*/
void
resetRds(void) throw ();
/**
* Fill the key bindings model from the KeyboardShortcutList.
*/

View File

@ -125,3 +125,14 @@ RdsEntry :: saveChanges(Ptr<GLiveSupport>::Ref gLiveSupport) throw ()
}
}
/*------------------------------------------------------------------------------
* Clear the entries of the widget.
*----------------------------------------------------------------------------*/
void
RdsEntry :: reset(void) throw ()
{
Ptr<const Glib::ustring>::Ref empty(new const Glib::ustring(""));
setOptions(false, empty);
}

View File

@ -156,6 +156,12 @@ class RdsEntry : public Gtk::HBox,
*/
bool
saveChanges(Ptr<GLiveSupport>::Ref gLiveSupport) throw ();
/**
* Clear the entries of the widget.
*/
void
reset(void) throw ();
};

View File

@ -72,6 +72,34 @@ RdsView :: RdsView (Ptr<GLiveSupport>::Ref gLiveSupport,
pack_start(*piEntry, Gtk::PACK_SHRINK, 0);
pack_start(*rtEntry, Gtk::PACK_SHRINK, 10);
reset();
}
/*------------------------------------------------------------------------------
* Save the changes made by the user.
*----------------------------------------------------------------------------*/
bool
RdsView :: saveChanges(void) throw ()
{
bool touched = false;
RdsEntryListType::const_iterator it;
for (it = rdsEntryList.begin(); it != rdsEntryList.end(); ++it) {
Ptr<RdsEntry>::Ref rdsEntry = *it;
touched |= rdsEntry->saveChanges(gLiveSupport);
}
return touched;
}
/*------------------------------------------------------------------------------
* Reset the widget to its saved state.
*----------------------------------------------------------------------------*/
void
RdsView :: reset(void) throw ()
{
RdsEntryListType::const_iterator it;
for (it = rdsEntryList.begin(); it != rdsEntryList.end(); ++it) {
fillEntry(*it);
@ -95,26 +123,8 @@ RdsView :: fillEntry(Ptr<RdsEntry>::Ref entry) throw ()
value = options->getRdsValue(type);
entry->setOptions(enabled, value);
} catch (std::invalid_argument &e) {
// there is no such RDS option; it's OK
entry->reset();
}
}
}
/*------------------------------------------------------------------------------
* Save the changes made by the user.
*----------------------------------------------------------------------------*/
bool
RdsView :: saveChanges(void) throw ()
{
bool touched = false;
RdsEntryListType::const_iterator it;
for (it = rdsEntryList.begin(); it != rdsEntryList.end(); ++it) {
Ptr<RdsEntry>::Ref rdsEntry = *it;
touched |= rdsEntry->saveChanges(gLiveSupport);
}
return touched;
}

View File

@ -66,8 +66,7 @@ using namespace LiveSupport::Widgets;
/**
* The RDS view, a subclass of Gtk::VBox.
* This will be contained in another window, most likely
* as the contents of a notebook tab.
* This will be contained in another window, currently in the OptionsWindow.
*
* The layout of the view is roughly the following:
* <pre><code>
@ -83,6 +82,11 @@ using namespace LiveSupport::Widgets;
* </code></pre>
* where each item has a checkbox [x] with which one can enable or disable it.
*
* On construction, the entries are filled in using the OptionsContainer
* object found in the GLiveSupport object. The OptionsContainer can be
* updated to the new contents of the entries using saveChanges(), and the
* entries can be re-initialized from the OptionsContainer using reset().
*
* @author $Author$
* @version $Revision$
*/
@ -144,6 +148,12 @@ class RdsView : public Gtk::VBox,
*/
bool
saveChanges(void) throw ();
/**
* Reset the widget to its saved state.
*/
void
reset(void) throw ();
};
/* ================================================= external data structures */