From 2046cb8b2b74007b587c7f5b639a55bc3c983867 Mon Sep 17 00:00:00 2001 From: fgerlits Date: Fri, 12 Jan 2007 15:58:08 +0000 Subject: [PATCH] more RDS stuff (part of #722) --- .../LiveSupport/Core/OptionsContainer.h | 33 +++- .../include/LiveSupport/Core/RdsContainer.h | 27 ++- .../core/include/LiveSupport/Core/RdsItem.h | 2 +- .../src/modules/core/src/OptionsContainer.cxx | 32 +++- .../src/modules/core/src/RdsContainer.cxx | 38 ++++- .../src/modules/core/src/RdsContainerTest.cxx | 6 +- .../src/products/gLiveSupport/etc/Makefile.in | 4 +- .../gLiveSupport/src/OptionsWindow.cxx | 25 +++ .../products/gLiveSupport/src/OptionsWindow.h | 8 + .../products/gLiveSupport/src/RdsEntry.cxx | 127 ++++++++++++++ .../src/products/gLiveSupport/src/RdsEntry.h | 160 ++++++++++++++++++ .../src/products/gLiveSupport/src/RdsView.cxx | 93 ++++++++++ .../src/products/gLiveSupport/src/RdsView.h | 151 +++++++++++++++++ .../src/products/gLiveSupport/var/root.txt | 8 + 14 files changed, 679 insertions(+), 35 deletions(-) create mode 100644 campcaster/src/products/gLiveSupport/src/RdsEntry.cxx create mode 100644 campcaster/src/products/gLiveSupport/src/RdsEntry.h create mode 100644 campcaster/src/products/gLiveSupport/src/RdsView.cxx create mode 100644 campcaster/src/products/gLiveSupport/src/RdsView.h diff --git a/campcaster/src/modules/core/include/LiveSupport/Core/OptionsContainer.h b/campcaster/src/modules/core/include/LiveSupport/Core/OptionsContainer.h index 83ca8c9c8..7cbee8a87 100644 --- a/campcaster/src/modules/core/include/LiveSupport/Core/OptionsContainer.h +++ b/campcaster/src/modules/core/include/LiveSupport/Core/OptionsContainer.h @@ -232,29 +232,44 @@ class OptionsContainer throw (std::invalid_argument); /** - * Set the value of an RDS string. + * Set the value of the RDS options. * The key can be any of the RDS data codes, like PS, PI, PTY, RT, * etc. If there is already a value set for this code, it gets * overwritten, otherwise a new key-value pair is added. * - * @param key which setting to modify - * @param value the new value of the RDS setting + * @param key which setting to modify + * @param value the new value of the RDS setting + * @param enabled the new enabled/disabled state of the + * RDS setting */ void - setRdsString(Ptr::Ref key, - Ptr::Ref value) throw (); + setRdsOptions(Ptr::Ref key, + Ptr::Ref value, + bool enabled) throw (); /** * Get the value of an RDS string. * The key can be any of the RDS data codes, like PS, PI, PTY, RT, - * etc. If there is no value set for this code, a zero pointer is - * returned. + * etc. * * @param key which setting to modify - * @return the value of the RDS setting, or a 0 pointer + * @return the value of the RDS setting + * @exception std::invalid_argument if there is no such RDS option. */ Ptr::Ref - getRdsString(Ptr::Ref key) throw (); + getRdsValue(Ptr::Ref key) + throw (std::invalid_argument); + + /** + * Get the enabled/disabled state of an RDS option. + * + * @param key which setting to modify + * @return true if the RDS option is enabled, false otherwise. + * @exception std::invalid_argument if there is no such RDS option. + */ + bool + getRdsEnabled(Ptr::Ref key) + throw (std::invalid_argument); /** * Save the options to a file. diff --git a/campcaster/src/modules/core/include/LiveSupport/Core/RdsContainer.h b/campcaster/src/modules/core/include/LiveSupport/Core/RdsContainer.h index dcb67ddd0..772c50e10 100644 --- a/campcaster/src/modules/core/include/LiveSupport/Core/RdsContainer.h +++ b/campcaster/src/modules/core/include/LiveSupport/Core/RdsContainer.h @@ -164,7 +164,7 @@ class RdsContainer : public Configurable throw (std::invalid_argument); /** - * Set the value of an RDS string. + * Set the value of the RDS options. * The key can be any of the RDS data codes, like PS, PI, PTY, RT, * etc. If there is already a value set for this code, it gets * overwritten, otherwise a new key-value pair is added. @@ -173,20 +173,33 @@ class RdsContainer : public Configurable * @param value the new value of the RDS setting. */ void - setRdsString(Ptr::Ref key, - Ptr::Ref value) throw (); + setRdsOptions(Ptr::Ref key, + Ptr::Ref value, + bool enabled) throw (); /** * Get the value of an RDS string. * The key can be any of the RDS data codes, like PS, PI, PTY, RT, - * etc. If there is no value set for this code, a zero pointer is - * returned. + * etc. * * @param key which setting to modify. - * @return the value of the RDS setting, or a 0 pointer. + * @return the value of the RDS setting. + * @exception std::invalid_argument if there is no such RDS option. */ Ptr::Ref - getRdsString(Ptr::Ref key) throw (); + getRdsValue(Ptr::Ref key) + throw (std::invalid_argument); + + /** + * Get the enabled/disabled state of an RDS option. + * + * @param key which setting to modify. + * @return true if the RDS option is enabled, false otherwise. + * @exception std::invalid_argument if there is no such RDS option. + */ + bool + getRdsEnabled(Ptr::Ref key) + throw (std::invalid_argument); /** * Convert the object to XML. diff --git a/campcaster/src/modules/core/include/LiveSupport/Core/RdsItem.h b/campcaster/src/modules/core/include/LiveSupport/Core/RdsItem.h index 993d291b2..ed707e6a5 100644 --- a/campcaster/src/modules/core/include/LiveSupport/Core/RdsItem.h +++ b/campcaster/src/modules/core/include/LiveSupport/Core/RdsItem.h @@ -224,7 +224,7 @@ class RdsItem : public Configurable * @return true if the RDS item is enabled, false if not. */ bool - isEnabled(void) throw () + getEnabled(void) throw () { return enabled; } diff --git a/campcaster/src/modules/core/src/OptionsContainer.cxx b/campcaster/src/modules/core/src/OptionsContainer.cxx index f337ccd29..7dc2cf464 100644 --- a/campcaster/src/modules/core/src/OptionsContainer.cxx +++ b/campcaster/src/modules/core/src/OptionsContainer.cxx @@ -168,15 +168,16 @@ OptionsContainer :: setKeyboardShortcutItem( * Set the value of an RDS string. *----------------------------------------------------------------------------*/ void -OptionsContainer :: setRdsString(Ptr::Ref key, - Ptr::Ref value) +OptionsContainer :: setRdsOptions(Ptr::Ref key, + Ptr::Ref value, + bool enabled) throw () { if (!rdsContainer) { rdsContainer.reset(new RdsContainer()); } - rdsContainer->setRdsString(key, value); + rdsContainer->setRdsOptions(key, value, enabled); } @@ -184,14 +185,29 @@ OptionsContainer :: setRdsString(Ptr::Ref key, * Get the value of an RDS string. *----------------------------------------------------------------------------*/ Ptr::Ref -OptionsContainer :: getRdsString(Ptr::Ref key) - throw () +OptionsContainer :: getRdsValue(Ptr::Ref key) + throw (std::invalid_argument) { - Ptr::Ref value; if (rdsContainer) { - value = rdsContainer->getRdsString(key); + return rdsContainer->getRdsValue(key); + } else { + throw std::invalid_argument("no RDS container found"); + } +} + + +/*------------------------------------------------------------------------------ + * Get the enabled/disabled state of an RDS option. + *----------------------------------------------------------------------------*/ +bool +OptionsContainer :: getRdsEnabled(Ptr::Ref key) + throw (std::invalid_argument) +{ + if (rdsContainer) { + return rdsContainer->getRdsEnabled(key); + } else { + throw std::invalid_argument("no RDS container found"); } - return value; } diff --git a/campcaster/src/modules/core/src/RdsContainer.cxx b/campcaster/src/modules/core/src/RdsContainer.cxx index dee5b06f8..7ad9e429a 100644 --- a/campcaster/src/modules/core/src/RdsContainer.cxx +++ b/campcaster/src/modules/core/src/RdsContainer.cxx @@ -85,11 +85,12 @@ RdsContainer :: configure(const xmlpp::Element & element) /*------------------------------------------------------------------------------ - * Set the value of an RDS string. + * Set the RDS options. *----------------------------------------------------------------------------*/ void -RdsContainer :: setRdsString(Ptr::Ref key, - Ptr::Ref value) +RdsContainer :: setRdsOptions(Ptr::Ref key, + Ptr::Ref value, + bool enabled) throw () { RdsItemListType::const_iterator it; @@ -100,12 +101,13 @@ RdsContainer :: setRdsString(Ptr::Ref key, if (*rdsItem->getKey() == *key) { found = true; rdsItem->setValue(value); + rdsItem->setEnabled(enabled); break; } } if (!found) { - Ptr::Ref rdsItem(new RdsItem(key, value)); + Ptr::Ref rdsItem(new RdsItem(key, value, enabled)); rdsItemList.push_back(rdsItem); } @@ -117,8 +119,8 @@ RdsContainer :: setRdsString(Ptr::Ref key, * Get the value of an RDS string. *----------------------------------------------------------------------------*/ Ptr::Ref -RdsContainer :: getRdsString(Ptr::Ref key) - throw () +RdsContainer :: getRdsValue(Ptr::Ref key) + throw (std::invalid_argument) { RdsItemListType::const_iterator it; for(it = rdsItemList.begin(); it != rdsItemList.end(); ++it) { @@ -128,8 +130,28 @@ RdsContainer :: getRdsString(Ptr::Ref key) } } - Ptr::Ref nullPointer; - return nullPointer; + Glib::ustring safeKey = key ? *key : "(null)"; + throw std::invalid_argument("RDS option " + safeKey + "not found."); +} + + +/*------------------------------------------------------------------------------ + * Get the enabled/disabled state of an RDS option. + *----------------------------------------------------------------------------*/ +bool +RdsContainer :: getRdsEnabled(Ptr::Ref key) + throw (std::invalid_argument) +{ + RdsItemListType::const_iterator it; + for(it = rdsItemList.begin(); it != rdsItemList.end(); ++it) { + Ptr::Ref rdsItem = *it; + if (*rdsItem->getKey() == *key) { + return rdsItem->getEnabled(); + } + } + + Glib::ustring safeKey = key ? *key : "(null)"; + throw std::invalid_argument("RDS option " + safeKey + "not found."); } diff --git a/campcaster/src/modules/core/src/RdsContainerTest.cxx b/campcaster/src/modules/core/src/RdsContainerTest.cxx index 9d2bae893..f3a48412c 100644 --- a/campcaster/src/modules/core/src/RdsContainerTest.cxx +++ b/campcaster/src/modules/core/src/RdsContainerTest.cxx @@ -124,8 +124,12 @@ RdsContainerTest :: firstTest(void) throw (CPPUNIT_NS::Exception) { Ptr::Ref key(new const Glib::ustring("PS")); - Ptr::Ref value = rdsContainer->getRdsString(key); + + Ptr::Ref value = rdsContainer->getRdsValue(key); CPPUNIT_ASSERT(value); CPPUNIT_ASSERT(*value == "BBC Four"); + + bool enabled = rdsContainer->getRdsEnabled(key); + CPPUNIT_ASSERT(enabled); } diff --git a/campcaster/src/products/gLiveSupport/etc/Makefile.in b/campcaster/src/products/gLiveSupport/etc/Makefile.in index ad3a5b04f..147beba62 100644 --- a/campcaster/src/products/gLiveSupport/etc/Makefile.in +++ b/campcaster/src/products/gLiveSupport/etc/Makefile.in @@ -279,7 +279,9 @@ G_LIVESUPPORT_OBJS = ${TMP_DIR}/GLiveSupport.o \ ${TMP_DIR}/ExportFormatRadioButtons.o \ ${TMP_DIR}/TransportList.o \ ${TMP_DIR}/RestoreBackupWindow.o \ - ${TMP_DIR}/TaskbarIcons.o + ${TMP_DIR}/TaskbarIcons.o \ + ${TMP_DIR}/RdsView.o \ + ${TMP_DIR}/RdsEntry.o G_LIVESUPPORT_RES = ${TMP_DIR}/${RESOURCE_BUNDLE_NAME}_root.res \ ${TMP_DIR}/${RESOURCE_BUNDLE_NAME}_en.res \ diff --git a/campcaster/src/products/gLiveSupport/src/OptionsWindow.cxx b/campcaster/src/products/gLiveSupport/src/OptionsWindow.cxx index 982e121dd..308f52235 100644 --- a/campcaster/src/products/gLiveSupport/src/OptionsWindow.cxx +++ b/campcaster/src/products/gLiveSupport/src/OptionsWindow.cxx @@ -39,6 +39,7 @@ #include "LiveSupport/Widgets/Button.h" #include "LiveSupport/Widgets/ScrolledNotebook.h" #include "LiveSupport/Widgets/EntryBin.h" +#include "RdsView.h" #include "OptionsWindow.h" @@ -102,6 +103,7 @@ OptionsWindow :: OptionsWindow (Ptr::Ref gLiveSupport, if (canBackup) { backupSectionBox = constructBackupSection(); } + Gtk::Box * rdsSectionBox = constructRdsSection(); Gtk::Box * aboutSectionBox = constructAboutSection(); try { @@ -117,6 +119,8 @@ OptionsWindow :: OptionsWindow (Ptr::Ref gLiveSupport, mainNotebook->appendPage(*backupSectionBox, *getResourceUstring("backupSectionLabel")); } + mainNotebook->appendPage(*rdsSectionBox, + *getResourceUstring("rdsSectionLabel")); mainNotebook->appendPage(*aboutSectionBox, *getResourceUstring("aboutSectionLabel")); @@ -799,6 +803,27 @@ OptionsWindow :: constructBackupSection(void) throw () } +/*------------------------------------------------------------------------------ + * Construct the "RDS" section. + *----------------------------------------------------------------------------*/ +Gtk::VBox* +OptionsWindow :: constructRdsSection(void) throw () +{ + Ptr::Ref rdsBundle; + try { + rdsBundle = gLiveSupport->getBundle("rdsView"); + + } catch (std::invalid_argument &e) { + // TODO: signal error + std::cerr << e.what() << std::endl; + std::exit(1); + } + + Gtk::VBox * rdsView = Gtk::manage(new RdsView(gLiveSupport, rdsBundle)); + return rdsView; +} + + /*------------------------------------------------------------------------------ * Construct the "About" section. *----------------------------------------------------------------------------*/ diff --git a/campcaster/src/products/gLiveSupport/src/OptionsWindow.h b/campcaster/src/products/gLiveSupport/src/OptionsWindow.h index 12696d4c7..ceac8c73b 100644 --- a/campcaster/src/products/gLiveSupport/src/OptionsWindow.h +++ b/campcaster/src/products/gLiveSupport/src/OptionsWindow.h @@ -242,6 +242,14 @@ class OptionsWindow : public GuiWindow Gtk::VBox* constructBackupSection(void) throw (); + /** + * Construct the "RDS" section. + * + * @return a pointer to the new box (already Gtk::manage()'ed) + */ + Gtk::VBox* + constructRdsSection(void) throw (); + /** * Construct the "About" section. * diff --git a/campcaster/src/products/gLiveSupport/src/RdsEntry.cxx b/campcaster/src/products/gLiveSupport/src/RdsEntry.cxx new file mode 100644 index 000000000..c7c98c272 --- /dev/null +++ b/campcaster/src/products/gLiveSupport/src/RdsEntry.cxx @@ -0,0 +1,127 @@ +/*------------------------------------------------------------------------------ + + Copyright (c) 2004 Media Development Loan Fund + + This file is part of the Campcaster project. + http://campcaster.campware.org/ + To report bugs, send an e-mail to bugs@campware.org + + Campcaster is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + Campcaster is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Campcaster; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + + Author : $Author$ + Version : $Revision$ + Location : $URL$ + +------------------------------------------------------------------------------*/ + +/* ============================================================ include files */ + +#ifdef HAVE_CONFIG_H +#include "configure.h" +#endif + +#include "LiveSupport/Widgets/WidgetFactory.h" + +#include "RdsEntry.h" + + +using namespace LiveSupport::Core; +using namespace LiveSupport::Widgets; +using namespace LiveSupport::GLiveSupport; + +/* =================================================== local data structures */ + + +/* ================================================ local constants & macros */ + + +/* =============================================== local function prototypes */ + + +/* ============================================================= module code */ + +/*------------------------------------------------------------------------------ + * Constructor. + *----------------------------------------------------------------------------*/ +RdsEntry :: RdsEntry(Ptr::Ref bundle, + const Glib::ustring & type, + int width) + throw () + : LocalizedObject(bundle) +{ + this->type.reset(new const Glib::ustring(type)); + + Ptr::Ref wf = WidgetFactory::getInstance(); + + checkBox = Gtk::manage(new Gtk::CheckButton()); + + Gtk::Label * label; + Glib::ustring labelKey = type + "rdsLabel"; + try { + label = Gtk::manage(new Gtk::Label(*getResourceUstring(labelKey))); + + } catch (std::invalid_argument &e) { + std::cerr << e.what() << std::endl; + std::exit(1); + } + + entryBin = Gtk::manage(wf->createEntryBin()); +// entryBin->? // set the size somehow + + pack_start(*checkBox, Gtk::PACK_SHRINK, 5); + pack_start(*label, Gtk::PACK_SHRINK, 5); + pack_start(*entryBin, Gtk::PACK_EXPAND_WIDGET, 5); +} + + +/*------------------------------------------------------------------------------ + * Set the state of the widget. + *----------------------------------------------------------------------------*/ +void +RdsEntry :: setValue(bool enabled, + Ptr::Ref value) throw () +{ + checkBox->set_active(enabled); + entryBin->set_text(*value); + + checkBoxSaved = enabled; + entryBinSaved = value; +} + + +/*------------------------------------------------------------------------------ + * Save the changes made by the user. + *----------------------------------------------------------------------------*/ +bool +RdsEntry :: saveChanges(Ptr::Ref gLiveSupport) throw () +{ + bool checkBoxNow = checkBox->get_active(); + Ptr::Ref + entryBinNow(new const Glib::ustring(entryBin->get_text())); + + if (!entryBinSaved || checkBoxNow != checkBoxSaved + || entryBinNow != entryBinSaved) { + Ptr::Ref optionsContainer = + gLiveSupport->getOptionsContainer(); + optionsContainer->setRdsOptions(type, entryBinNow, checkBoxNow); + checkBoxSaved = checkBoxNow; + entryBinSaved = entryBinNow; + return true; + } else { + return false; + } +} + diff --git a/campcaster/src/products/gLiveSupport/src/RdsEntry.h b/campcaster/src/products/gLiveSupport/src/RdsEntry.h new file mode 100644 index 000000000..a09acc8a9 --- /dev/null +++ b/campcaster/src/products/gLiveSupport/src/RdsEntry.h @@ -0,0 +1,160 @@ +/*------------------------------------------------------------------------------ + + Copyright (c) 2004 Media Development Loan Fund + + This file is part of the Campcaster project. + http://campcaster.campware.org/ + To report bugs, send an e-mail to bugs@campware.org + + Campcaster is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + Campcaster is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Campcaster; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + + Author : $Author$ + Version : $Revision$ + Location : $URL$ + +------------------------------------------------------------------------------*/ +#ifndef RdsEntry_h +#define RdsEntry_h + +#ifndef __cplusplus +#error This is a C++ include file +#endif + + +/* ============================================================ include files */ + +#ifdef HAVE_CONFIG_H +#include "configure.h" +#endif + +#include +#include + +#include "LiveSupport/Core/Ptr.h" +#include "LiveSupport/Core/LocalizedObject.h" +#include "LiveSupport/Widgets/EntryBin.h" +#include "GLiveSupport.h" + + +namespace LiveSupport { +namespace GLiveSupport { + +using namespace LiveSupport::Core; +using namespace LiveSupport::Widgets; +using namespace LiveSupport::GLiveSupport; + +/* ================================================================ constants */ + + +/* =================================================================== macros */ + + +/* =============================================================== data types */ + +/** + * A single RDS input field. + * + * @author $Author$ + * @version $Revision$ + */ +class RdsEntry : public Gtk::HBox, + public LocalizedObject +{ + private: + /** + * The RDS type of the object (PS, PI, RT, etc). + */ + Ptr::Ref type; + + /** + * The saved state of the checkbox. + */ + bool checkBoxSaved; + + /** + * The saved contents of the entry bin. + */ + Ptr::Ref entryBinSaved; + + + protected: + /** + * The enable/disable checkbox. + */ + Gtk::CheckButton * checkBox; + + /** + * The entry field. + */ + EntryBin * entryBin; + + + public: + /** + * Constructor. + * The type parameter is a string of 2 or 3 upper-case characters, + * see http://en.wikipedia.org/wiki/Radio_Data_System. + * + * @param bundle the resource bundle holding the localized + * resources for this window. + * @param type the type of RDS data (PS, PI, RT, etc). + * @param width the width of the entry, in characters. + */ + RdsEntry(Ptr::Ref bundle, + const Glib::ustring & type, + int width) throw (); + + /** + * A virtual destructor. + */ + virtual + ~RdsEntry(void) throw () + { + } + + /** + * Set the state of the widget. + * + * @param enabled the new state of the checkBox. + * @param value the new contents of the entryBin. + */ + void + setValue(bool enabled, + Ptr::Ref value) throw (); + + /** + * Save the changes made by the user. + * + * @param gLiveSupport the GLiveSupport object holding the + * RDS options to be modified. + * @return true if any changes were saved; false otherwise. + */ + bool + saveChanges(Ptr::Ref gLiveSupport) throw (); +}; + + +/* ================================================= external data structures */ + + +/* ====================================================== function prototypes */ + + +} // namespace GLiveSupport +} // namespace LiveSupport + +#endif // LiveSupport_GLiveSupport_RdsEntry_h + diff --git a/campcaster/src/products/gLiveSupport/src/RdsView.cxx b/campcaster/src/products/gLiveSupport/src/RdsView.cxx new file mode 100644 index 000000000..0e7cdba42 --- /dev/null +++ b/campcaster/src/products/gLiveSupport/src/RdsView.cxx @@ -0,0 +1,93 @@ +/*------------------------------------------------------------------------------ + + Copyright (c) 2004 Media Development Loan Fund + + This file is part of the Campcaster project. + http://campcaster.campware.org/ + To report bugs, send an e-mail to bugs@campware.org + + Campcaster is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + Campcaster is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Campcaster; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + + Author : $Author$ + Version : $Revision$ + Location : $URL$ + +------------------------------------------------------------------------------*/ + +/* ============================================================ include files */ + +#ifdef HAVE_CONFIG_H +#include "configure.h" +#endif + +#include "RdsView.h" + + +using namespace LiveSupport::Core; +using namespace LiveSupport::Widgets; +using namespace LiveSupport::GLiveSupport; + +/* =================================================== local data structures */ + + +/* ================================================ local constants & macros */ + + +/* =============================================== local function prototypes */ + + +/* ============================================================= module code */ + +/*------------------------------------------------------------------------------ + * Constructor. + *----------------------------------------------------------------------------*/ +RdsView :: RdsView (Ptr::Ref gLiveSupport, + Ptr::Ref bundle) + throw () + : LocalizedObject(bundle), + gLiveSupport(gLiveSupport) +{ + Ptr::Ref psEntry(new RdsEntry(getBundle(), "PS", 8)); + Ptr::Ref piEntry(new RdsEntry(getBundle(), "PI", 4)); + Ptr::Ref rtEntry(new RdsEntry(getBundle(), "RT", 32)); + + rdsEntryList.push_back(psEntry); + rdsEntryList.push_back(piEntry); + rdsEntryList.push_back(rtEntry); + + pack_start(*psEntry, Gtk::PACK_SHRINK, 10); + pack_start(*piEntry, Gtk::PACK_SHRINK, 0); + pack_start(*rtEntry, Gtk::PACK_SHRINK, 10); +} + + +/*------------------------------------------------------------------------------ + * 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::Ref rdsEntry = *it; + touched |= rdsEntry->saveChanges(gLiveSupport); + } + + return touched; +} + diff --git a/campcaster/src/products/gLiveSupport/src/RdsView.h b/campcaster/src/products/gLiveSupport/src/RdsView.h new file mode 100644 index 000000000..fc9a0bf3c --- /dev/null +++ b/campcaster/src/products/gLiveSupport/src/RdsView.h @@ -0,0 +1,151 @@ +/*------------------------------------------------------------------------------ + + Copyright (c) 2004 Media Development Loan Fund + + This file is part of the Campcaster project. + http://campcaster.campware.org/ + To report bugs, send an e-mail to bugs@campware.org + + Campcaster is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + Campcaster is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Campcaster; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + + Author : $Author$ + Version : $Revision$ + Location : $URL$ + +------------------------------------------------------------------------------*/ +#ifndef RdsView_h +#define RdsView_h + +#ifndef __cplusplus +#error This is a C++ include file +#endif + + +/* ============================================================ include files */ + +#ifdef HAVE_CONFIG_H +#include "configure.h" +#endif + +#include +#include + +#include "LiveSupport/Core/Ptr.h" +#include "LiveSupport/Core/LocalizedObject.h" +#include "LiveSupport/Widgets/Button.h" +#include "LiveSupport/Widgets/ScrolledWindow.h" +#include "RdsEntry.h" +#include "GLiveSupport.h" + +namespace LiveSupport { +namespace GLiveSupport { + +using namespace LiveSupport::Core; +using namespace LiveSupport::Widgets; + +/* ================================================================ constants */ + + +/* =================================================================== macros */ + + +/* =============================================================== data types */ + +/** + * The RDS view, a subclass of Gtk::VBox. + * This will be contained in another window, most likely + * as the contents of a notebook tab. + * + * The layout of the view is roughly the following: + *

+ *  +--- RDS view -----------------------------------+
+ *  |                    ___________                 |
+ *  | [x] Station name: |___________|                |
+ *  |                  ________                      |
+ *  | [x] Station ID: |________|                     |
+ *  |                  ___________________________   |
+ *  | [ ] Clip info:  |___________________________|  |
+ *  |                                                |
+ *  +------------------------------------------------+
+ *  
+ * where each item has a checkbox [x] with which one can enable or disable it. + * + * @author $Author$ + * @version $Revision$ + */ +class RdsView : public Gtk::VBox, + public LocalizedObject +{ + private: + /** + * The type for the list of entry widgets. + */ + typedef std::vector::Ref> RdsEntryListType; + + /** + * The list of the entry widgets. + */ + RdsEntryListType rdsEntryList; + + + protected: + /** + * The GLiveSupport object, holding the state of the application. + */ + Ptr::Ref gLiveSupport; + + + public: + /** + * Constructor. + * + * @param gLiveSupport the gLiveSupport object, containing + * all the vital info. + * @param bundle the resource bundle holding the localized + * resources for this window. + */ + RdsView(Ptr::Ref gLiveSupport, + Ptr::Ref bundle) + throw (); + + /** + * Virtual destructor. + */ + virtual + ~RdsView(void) throw () + { + } + + /** + * Save the changes made by the user. + * + * @return true if any changes were saved; false otherwise. + */ + bool + saveChanges(void) throw (); +}; + +/* ================================================= external data structures */ + + +/* ====================================================== function prototypes */ + + +} // namespace GLiveSupport +} // namespace LiveSupport + +#endif // RdsView_h + diff --git a/campcaster/src/products/gLiveSupport/var/root.txt b/campcaster/src/products/gLiveSupport/var/root.txt index 97204ea6f..4a61920f7 100644 --- a/campcaster/src/products/gLiveSupport/var/root.txt +++ b/campcaster/src/products/gLiveSupport/var/root.txt @@ -276,6 +276,7 @@ root:table serversSectionLabel:string { "Servers" } schedulerSectionLabel:string { "Scheduler" } backupSectionLabel:string { "Backup" } + rdsSectionLabel:string { "RDS" } aboutSectionLabel:string { "About" } cancelButtonLabel:string { "Cancel" } @@ -352,6 +353,13 @@ root:table backupErrorMsg:string { "Backup error: " } } + rdsView:table + { + PSrdsLabel:string { "Station name:" } + PIrdsLabel:string { "Station code:" } + RTrdsLabel:string { "Clip info:" } + } + dateTimeChooserWindow:table { windowTitle:string { "Select the date and time" }