From 6cab7540628dbe01e597edfd32c82eb09f7fa326 Mon Sep 17 00:00:00 2001 From: fgerlits Date: Mon, 15 Jan 2007 10:56:14 +0000 Subject: [PATCH] load and save the RDS settings from the config file (part of #722) --- .../src/modules/core/src/OptionsContainer.cxx | 2 +- .../gLiveSupport/src/OptionsWindow.cxx | 14 ++++++++-- .../products/gLiveSupport/src/OptionsWindow.h | 12 +++++++++ .../products/gLiveSupport/src/RdsEntry.cxx | 4 +-- .../src/products/gLiveSupport/src/RdsEntry.h | 16 +++++++++-- .../src/products/gLiveSupport/src/RdsView.cxx | 27 +++++++++++++++++++ .../src/products/gLiveSupport/src/RdsView.h | 8 ++++++ 7 files changed, 76 insertions(+), 7 deletions(-) diff --git a/campcaster/src/modules/core/src/OptionsContainer.cxx b/campcaster/src/modules/core/src/OptionsContainer.cxx index 7dc2cf464..543798596 100644 --- a/campcaster/src/modules/core/src/OptionsContainer.cxx +++ b/campcaster/src/modules/core/src/OptionsContainer.cxx @@ -344,7 +344,7 @@ void OptionsContainer :: writeToFile(void) throw () { if (configFileName) { - if (rdsContainer && rdsContainer->isTouched()) { + if (rdsContainer) { xmlpp::Element * rootNode = optionsDocument.get_root_node(); xmlpp::Node::NodeList nodes = rootNode->get_children( RdsContainer::getConfigElementName()); diff --git a/campcaster/src/products/gLiveSupport/src/OptionsWindow.cxx b/campcaster/src/products/gLiveSupport/src/OptionsWindow.cxx index 308f52235..e234b5fff 100644 --- a/campcaster/src/products/gLiveSupport/src/OptionsWindow.cxx +++ b/campcaster/src/products/gLiveSupport/src/OptionsWindow.cxx @@ -39,7 +39,6 @@ #include "LiveSupport/Widgets/Button.h" #include "LiveSupport/Widgets/ScrolledNotebook.h" #include "LiveSupport/Widgets/EntryBin.h" -#include "RdsView.h" #include "OptionsWindow.h" @@ -196,6 +195,7 @@ OptionsWindow :: onApplyButtonClicked(void) throw () { bool changed = saveChangesInStringEntryFields(); saveChangesInKeyBindings(); // no need to restart + saveChangesInRds(); // no need to restart if (changed) { 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. *----------------------------------------------------------------------------*/ @@ -819,7 +829,7 @@ OptionsWindow :: constructRdsSection(void) throw () std::exit(1); } - Gtk::VBox * rdsView = Gtk::manage(new RdsView(gLiveSupport, rdsBundle)); + rdsView = Gtk::manage(new RdsView(gLiveSupport, rdsBundle)); return rdsView; } diff --git a/campcaster/src/products/gLiveSupport/src/OptionsWindow.h b/campcaster/src/products/gLiveSupport/src/OptionsWindow.h index ceac8c73b..cdbf97b43 100644 --- a/campcaster/src/products/gLiveSupport/src/OptionsWindow.h +++ b/campcaster/src/products/gLiveSupport/src/OptionsWindow.h @@ -61,6 +61,7 @@ #include "GLiveSupport.h" #include "MasterPanelUserInfoWidget.h" #include "BackupView.h" +#include "RdsView.h" namespace LiveSupport { namespace GLiveSupport { @@ -201,6 +202,12 @@ class OptionsWindow : public GuiWindow void saveChangesInKeyBindings(void) throw (); + /** + * Save the changes in the RDS settings. + */ + void + saveChangesInRds(void) throw (); + /** * Construct the "Sound" section. * @@ -416,6 +423,11 @@ class OptionsWindow : public GuiWindow */ BackupView * backupView; + /** + * The RdsView shown in the RDS section. + */ + RdsView * rdsView; + public: /** diff --git a/campcaster/src/products/gLiveSupport/src/RdsEntry.cxx b/campcaster/src/products/gLiveSupport/src/RdsEntry.cxx index c7c98c272..dbfe551a5 100644 --- a/campcaster/src/products/gLiveSupport/src/RdsEntry.cxx +++ b/campcaster/src/products/gLiveSupport/src/RdsEntry.cxx @@ -91,8 +91,8 @@ RdsEntry :: RdsEntry(Ptr::Ref bundle, * Set the state of the widget. *----------------------------------------------------------------------------*/ void -RdsEntry :: setValue(bool enabled, - Ptr::Ref value) throw () +RdsEntry :: setOptions(bool enabled, + Ptr::Ref value) throw () { checkBox->set_active(enabled); entryBin->set_text(*value); diff --git a/campcaster/src/products/gLiveSupport/src/RdsEntry.h b/campcaster/src/products/gLiveSupport/src/RdsEntry.h index a09acc8a9..4c792fd6a 100644 --- a/campcaster/src/products/gLiveSupport/src/RdsEntry.h +++ b/campcaster/src/products/gLiveSupport/src/RdsEntry.h @@ -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::Ref + getType(void) throw () + { + return type; + } + /** * Set the state of the widget. * @@ -132,8 +144,8 @@ class RdsEntry : public Gtk::HBox, * @param value the new contents of the entryBin. */ void - setValue(bool enabled, - Ptr::Ref value) throw (); + setOptions(bool enabled, + Ptr::Ref value) throw (); /** * Save the changes made by the user. diff --git a/campcaster/src/products/gLiveSupport/src/RdsView.cxx b/campcaster/src/products/gLiveSupport/src/RdsView.cxx index 0e7cdba42..472cd7fcc 100644 --- a/campcaster/src/products/gLiveSupport/src/RdsView.cxx +++ b/campcaster/src/products/gLiveSupport/src/RdsView.cxx @@ -71,6 +71,33 @@ RdsView :: RdsView (Ptr::Ref gLiveSupport, pack_start(*psEntry, Gtk::PACK_SHRINK, 10); pack_start(*piEntry, Gtk::PACK_SHRINK, 0); 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::Ref entry) throw () +{ + Ptr::Ref options = gLiveSupport->getOptionsContainer(); + + if (options) { + Ptr::Ref type = entry->getType(); + try { + bool enabled = options->getRdsEnabled(type); + Ptr::Ref + value = options->getRdsValue(type); + entry->setOptions(enabled, value); + } catch (std::invalid_argument &e) { + // there is no such RDS option; it's OK + } + } } diff --git a/campcaster/src/products/gLiveSupport/src/RdsView.h b/campcaster/src/products/gLiveSupport/src/RdsView.h index fc9a0bf3c..518523383 100644 --- a/campcaster/src/products/gLiveSupport/src/RdsView.h +++ b/campcaster/src/products/gLiveSupport/src/RdsView.h @@ -100,6 +100,14 @@ class RdsView : public Gtk::VBox, */ RdsEntryListType rdsEntryList; + /** + * Fill in the entry from the OptionsContainer. + * + * @param entry the RdsEntry to be filled in. + */ + void + fillEntry(Ptr::Ref entry) throw (); + protected: /**