load and save the RDS settings from the config file (part of #722)

This commit is contained in:
fgerlits 2007-01-15 10:56:14 +00:00
parent 2046cb8b2b
commit 6cab754062
7 changed files with 76 additions and 7 deletions

View file

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

View file

@ -39,7 +39,6 @@
#include "LiveSupport/Widgets/Button.h" #include "LiveSupport/Widgets/Button.h"
#include "LiveSupport/Widgets/ScrolledNotebook.h" #include "LiveSupport/Widgets/ScrolledNotebook.h"
#include "LiveSupport/Widgets/EntryBin.h" #include "LiveSupport/Widgets/EntryBin.h"
#include "RdsView.h"
#include "OptionsWindow.h" #include "OptionsWindow.h"
@ -196,6 +195,7 @@ OptionsWindow :: onApplyButtonClicked(void) throw ()
{ {
bool changed = saveChangesInStringEntryFields(); bool changed = saveChangesInStringEntryFields();
saveChangesInKeyBindings(); // no need to restart saveChangesInKeyBindings(); // no need to restart
saveChangesInRds(); // no need to restart
if (changed) { if (changed) {
try { try {
@ -315,6 +315,16 @@ OptionsWindow :: saveChangesInKeyBindings(void) throw ()
} }
/*------------------------------------------------------------------------------
* Save the changes in the RDS settings.
*----------------------------------------------------------------------------*/
void
OptionsWindow :: saveChangesInRds(void) throw ()
{
rdsView->saveChanges();
}
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Event handler for the OK button. * Event handler for the OK button.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
@ -819,7 +829,7 @@ OptionsWindow :: constructRdsSection(void) throw ()
std::exit(1); std::exit(1);
} }
Gtk::VBox * rdsView = Gtk::manage(new RdsView(gLiveSupport, rdsBundle)); rdsView = Gtk::manage(new RdsView(gLiveSupport, rdsBundle));
return rdsView; return rdsView;
} }

View file

@ -61,6 +61,7 @@
#include "GLiveSupport.h" #include "GLiveSupport.h"
#include "MasterPanelUserInfoWidget.h" #include "MasterPanelUserInfoWidget.h"
#include "BackupView.h" #include "BackupView.h"
#include "RdsView.h"
namespace LiveSupport { namespace LiveSupport {
namespace GLiveSupport { namespace GLiveSupport {
@ -201,6 +202,12 @@ class OptionsWindow : public GuiWindow
void void
saveChangesInKeyBindings(void) throw (); saveChangesInKeyBindings(void) throw ();
/**
* Save the changes in the RDS settings.
*/
void
saveChangesInRds(void) throw ();
/** /**
* Construct the "Sound" section. * Construct the "Sound" section.
* *
@ -416,6 +423,11 @@ class OptionsWindow : public GuiWindow
*/ */
BackupView * backupView; BackupView * backupView;
/**
* The RdsView shown in the RDS section.
*/
RdsView * rdsView;
public: public:
/** /**

View file

@ -91,7 +91,7 @@ RdsEntry :: RdsEntry(Ptr<ResourceBundle>::Ref bundle,
* Set the state of the widget. * Set the state of the widget.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
RdsEntry :: setValue(bool enabled, RdsEntry :: setOptions(bool enabled,
Ptr<const Glib::ustring>::Ref value) throw () Ptr<const Glib::ustring>::Ref value) throw ()
{ {
checkBox->set_active(enabled); checkBox->set_active(enabled);

View file

@ -125,6 +125,18 @@ class RdsEntry : public Gtk::HBox,
{ {
} }
/**
* Get the type of the widget.
* Returns the RDS option type (PS, PI, RT, ...).
*
* @return the "type" parameter passed to the constructor.
*/
Ptr<const Glib::ustring>::Ref
getType(void) throw ()
{
return type;
}
/** /**
* Set the state of the widget. * Set the state of the widget.
* *
@ -132,7 +144,7 @@ class RdsEntry : public Gtk::HBox,
* @param value the new contents of the entryBin. * @param value the new contents of the entryBin.
*/ */
void void
setValue(bool enabled, setOptions(bool enabled,
Ptr<const Glib::ustring>::Ref value) throw (); Ptr<const Glib::ustring>::Ref value) throw ();
/** /**

View file

@ -71,6 +71,33 @@ RdsView :: RdsView (Ptr<GLiveSupport>::Ref gLiveSupport,
pack_start(*psEntry, Gtk::PACK_SHRINK, 10); pack_start(*psEntry, Gtk::PACK_SHRINK, 10);
pack_start(*piEntry, Gtk::PACK_SHRINK, 0); pack_start(*piEntry, Gtk::PACK_SHRINK, 0);
pack_start(*rtEntry, Gtk::PACK_SHRINK, 10); pack_start(*rtEntry, Gtk::PACK_SHRINK, 10);
RdsEntryListType::const_iterator it;
for (it = rdsEntryList.begin(); it != rdsEntryList.end(); ++it) {
fillEntry(*it);
}
}
/*------------------------------------------------------------------------------
* Fill in the entry from the OptionsContainer.
*----------------------------------------------------------------------------*/
void
RdsView :: fillEntry(Ptr<RdsEntry>::Ref entry) throw ()
{
Ptr<OptionsContainer>::Ref options = gLiveSupport->getOptionsContainer();
if (options) {
Ptr<const Glib::ustring>::Ref type = entry->getType();
try {
bool enabled = options->getRdsEnabled(type);
Ptr<const Glib::ustring>::Ref
value = options->getRdsValue(type);
entry->setOptions(enabled, value);
} catch (std::invalid_argument &e) {
// there is no such RDS option; it's OK
}
}
} }

View file

@ -100,6 +100,14 @@ class RdsView : public Gtk::VBox,
*/ */
RdsEntryListType rdsEntryList; RdsEntryListType rdsEntryList;
/**
* Fill in the entry from the OptionsContainer.
*
* @param entry the RdsEntry to be filled in.
*/
void
fillEntry(Ptr<RdsEntry>::Ref entry) throw ();
protected: protected:
/** /**