This commit is contained in:
fgerlits 2006-11-27 16:50:55 +00:00
parent 9edd10a58c
commit f54fd605c0
12 changed files with 65 additions and 14 deletions

View File

@ -187,10 +187,13 @@ class WidgetFactory :
* Convert an integer to a string. * Convert an integer to a string.
* *
* @param number the number to be converted. * @param number the number to be converted.
* @param minLength the minimum length of the result; smaller
* numbers get padded with zeroes (optional).
* @return the string value of the number (in base 10). * @return the string value of the number (in base 10).
*/ */
static Glib::ustring static Glib::ustring
itoa(int number) throw (); itoa(int number,
int minLength = 0) throw ();
public: public:
@ -320,11 +323,14 @@ class WidgetFactory :
* *
* @param lowerLimit the lowest entry in the combo box. * @param lowerLimit the lowest entry in the combo box.
* @param upperLimit the highest entry in the combo box. * @param upperLimit the highest entry in the combo box.
* @param minLength the minimum length of the entries; smaller
* numbers get padded with zeroes (optional).
* @return a combo box, that holds numeric entries. * @return a combo box, that holds numeric entries.
*/ */
ComboBoxText * ComboBoxText *
createNumericComboBoxText(int lowerLimit, createNumericComboBoxText(int lowerLimit,
int upperLimit) throw (); int upperLimit,
int minLength = 0) throw ();
/** /**
* Create and return a blue singular container. * Create and return a blue singular container.

View File

@ -511,14 +511,15 @@ WidgetFactory :: createOperatorComboBoxText(
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
ComboBoxText * ComboBoxText *
WidgetFactory :: createNumericComboBoxText(int lowerLimit, WidgetFactory :: createNumericComboBoxText(int lowerLimit,
int upperLimit) int upperLimit,
int minLength)
throw () throw ()
{ {
ComboBoxText * comboBox = new ComboBoxText(comboBoxLeftImage, ComboBoxText * comboBox = new ComboBoxText(comboBoxLeftImage,
comboBoxCenterImage, comboBoxCenterImage,
comboBoxRightImage); comboBoxRightImage);
for (int i = lowerLimit; i <= upperLimit; ++i) { for (int i = lowerLimit; i <= upperLimit; ++i) {
comboBox->append_text(itoa(i)); comboBox->append_text(itoa(i, minLength));
} }
return comboBox; return comboBox;
} }
@ -707,9 +708,14 @@ WidgetFactory :: createDateTimeChooserWindow(Ptr<ResourceBundle>::Ref bundle)
* Convert an integer to a string. * Convert an integer to a string.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
Glib::ustring Glib::ustring
WidgetFactory :: itoa(int number) throw () WidgetFactory :: itoa(int number,
int minLength) throw ()
{ {
std::ostringstream stream; std::ostringstream stream;
if (minLength > 0) {
stream << std::setw(minLength)
<< std::setfill('0');
}
stream << number; stream << number;
Glib::ustring string = stream.str(); Glib::ustring string = stream.str();
return string; return string;

View File

@ -78,6 +78,8 @@ SchedulePlaylistWindow :: SchedulePlaylistWindow (
"hourLabel"))); "hourLabel")));
minuteLabel = Gtk::manage(new Gtk::Label(*getResourceUstring( minuteLabel = Gtk::manage(new Gtk::Label(*getResourceUstring(
"minuteLabel"))); "minuteLabel")));
secondLabel = Gtk::manage(new Gtk::Label(*getResourceUstring(
"secondLabel")));
scheduleButton = Gtk::manage(wf->createButton( scheduleButton = Gtk::manage(wf->createButton(
*getResourceUstring("scheduleButtonLabel"))); *getResourceUstring("scheduleButtonLabel")));
closeButton = Gtk::manage(wf->createButton( closeButton = Gtk::manage(wf->createButton(
@ -90,18 +92,21 @@ SchedulePlaylistWindow :: SchedulePlaylistWindow (
playlistLabel = Gtk::manage(new Gtk::Label(*playlist->getTitle())); playlistLabel = Gtk::manage(new Gtk::Label(*playlist->getTitle()));
calendar = Gtk::manage(new Gtk::Calendar()); calendar = Gtk::manage(new Gtk::Calendar());
hourEntry = Gtk::manage(wf->createNumericComboBoxText(0, 23)); hourEntry = Gtk::manage(wf->createNumericComboBoxText(0, 23));
minuteEntry = Gtk::manage(wf->createNumericComboBoxText(0, 59)); minuteEntry = Gtk::manage(wf->createNumericComboBoxText(0, 59, 2));
secondEntry = Gtk::manage(wf->createNumericComboBoxText(0, 59, 2));
layout = Gtk::manage(new Gtk::Table()); layout = Gtk::manage(new Gtk::Table());
layout->attach(*playlistLabel, 0, 4, 0, 1); layout->attach(*playlistLabel, 0, 6, 0, 1);
layout->attach(*calendar, 0, 4, 1, 2); layout->attach(*calendar, 0, 6, 1, 2);
layout->attach(*hourLabel, 0, 1, 2, 3); layout->attach(*hourLabel, 0, 1, 2, 3);
layout->attach(*hourEntry, 1, 2, 2, 3); layout->attach(*hourEntry, 1, 2, 2, 3);
layout->attach(*minuteLabel, 2, 3, 2, 3); layout->attach(*minuteLabel, 2, 3, 2, 3);
layout->attach(*minuteEntry, 3, 4, 2, 3); layout->attach(*minuteEntry, 3, 4, 2, 3);
layout->attach(*scheduleButton, 2, 4, 3, 4); layout->attach(*secondLabel, 4, 5, 2, 3);
layout->attach(*closeButton , 2, 4, 4, 5); layout->attach(*secondEntry, 5, 6, 2, 3);
layout->attach(*scheduleButton, 4, 6, 3, 4);
layout->attach(*closeButton , 4, 6, 4, 5);
// register the signal handler for the schedule getting clicked. // register the signal handler for the schedule getting clicked.
scheduleButton->signal_clicked().connect(sigc::mem_fun(*this, scheduleButton->signal_clicked().connect(sigc::mem_fun(*this,
@ -142,9 +147,19 @@ SchedulePlaylistWindow :: onScheduleButtonClicked (void) throw ()
Ptr<std::string>::Ref timeStr(new std::string( Ptr<std::string>::Ref timeStr(new std::string(
hourEntry->get_active_text())); hourEntry->get_active_text()));
*timeStr += ":"; *timeStr += ":";
*timeStr += minuteEntry->get_active_text(); Glib::ustring minutes = minuteEntry->get_active_text();
*timeStr += ":00.00"; if (minutes == "") {
minutes = "00";
}
*timeStr += minutes;
*timeStr += ":";
Glib::ustring seconds = secondEntry->get_active_text();
if (seconds == "") {
seconds = "00";
}
*timeStr += seconds;
*timeStr += ".00";
Ptr<posix_time::ptime>::Ref selectedTime; Ptr<posix_time::ptime>::Ref selectedTime;
try { try {

View File

@ -134,6 +134,16 @@ class SchedulePlaylistWindow : public GuiWindow
*/ */
ComboBoxText * minuteEntry; ComboBoxText * minuteEntry;
/**
* The second label.
*/
Gtk::Label * secondLabel;
/**
* The second entry field.
*/
ComboBoxText * secondEntry;
/** /**
* The schedule button. * The schedule button.
*/ */

View File

@ -178,6 +178,7 @@ es:table
hourLabel:string { "hora: " } hourLabel:string { "hora: " }
minuteLabel:string { "minuto: " } minuteLabel:string { "minuto: " }
secondLabel:string { "seconds: " }
scheduleButtonLabel:string { "programado" } scheduleButtonLabel:string { "programado" }
closeButtonLabel:string { "cerrar" } closeButtonLabel:string { "cerrar" }
} }

View File

@ -174,6 +174,7 @@ hu:table
hourLabel:string { "óra: " } hourLabel:string { "óra: " }
minuteLabel:string { "perc: " } minuteLabel:string { "perc: " }
secondLabel:string { "másodperc: " }
scheduleButtonLabel:string { "időzít" } scheduleButtonLabel:string { "időzít" }
closeButtonLabel:string { "bezár" } closeButtonLabel:string { "bezár" }
} }

View File

@ -176,6 +176,7 @@ nl:table
hourLabel:string { "uur: " } hourLabel:string { "uur: " }
minuteLabel:string { "minuten: " } minuteLabel:string { "minuten: " }
secondLabel:string { "seconds: " }
scheduleButtonLabel:string { "schedule" } scheduleButtonLabel:string { "schedule" }
closeButtonLabel:string { "sluiten" } closeButtonLabel:string { "sluiten" }
} }

View File

@ -176,6 +176,7 @@ pl:table
hourLabel:string { "godzina: " } hourLabel:string { "godzina: " }
minuteLabel:string { "minuta: " } minuteLabel:string { "minuta: " }
secondLabel:string { "seconds: " }
scheduleButtonLabel:string { "zaprogramuj" } scheduleButtonLabel:string { "zaprogramuj" }
closeButtonLabel:string { "zamknij" } closeButtonLabel:string { "zamknij" }
} }

View File

@ -176,6 +176,7 @@ root:table
hourLabel:string { "hour: " } hourLabel:string { "hour: " }
minuteLabel:string { "minute: " } minuteLabel:string { "minute: " }
secondLabel:string { "seconds: " }
scheduleButtonLabel:string { "schedule" } scheduleButtonLabel:string { "schedule" }
closeButtonLabel:string { "close" } closeButtonLabel:string { "close" }
} }

View File

@ -171,6 +171,7 @@ sr_CS:table
hourLabel:string { "sat: " } hourLabel:string { "sat: " }
minuteLabel:string { "minut: " } minuteLabel:string { "minut: " }
secondLabel:string { "seconds: " }
scheduleButtonLabel:string { "programiraj" } scheduleButtonLabel:string { "programiraj" }
closeButtonLabel:string { "zatvori" } closeButtonLabel:string { "zatvori" }
} }

View File

@ -171,6 +171,7 @@ sr_CS_CYRILLIC:table
hourLabel:string { "сат: " } hourLabel:string { "сат: " }
minuteLabel:string { "минут: " } minuteLabel:string { "минут: " }
secondLabel:string { "seconds: " }
scheduleButtonLabel:string { "програмирај" } scheduleButtonLabel:string { "програмирај" }
closeButtonLabel:string { "затвори" } closeButtonLabel:string { "затвори" }
} }

View File

@ -92,6 +92,7 @@ PlaylistEvent :: PlaylistEvent(
void void
PlaylistEvent :: initialize(void) throw (std::exception) PlaylistEvent :: initialize(void) throw (std::exception)
{ {
std::cerr << "PlaylistEvent :: initialize BEGIN\n";
if (state != created) { if (state != created) {
throw std::logic_error("PlaylistEvent in bad state"); throw std::logic_error("PlaylistEvent in bad state");
} }
@ -102,6 +103,7 @@ PlaylistEvent :: initialize(void) throw (std::exception)
->getId())); ->getId()));
try { try {
playlist = storage->acquirePlaylist(sessionId, playlistId); playlist = storage->acquirePlaylist(sessionId, playlistId);
std::cerr << "PlaylistEvent :: initialize acquired playlist\n";
} catch (Core::XmlRpcException &e) { } catch (Core::XmlRpcException &e) {
std::string errorMessage = "storage server error: "; std::string errorMessage = "storage server error: ";
errorMessage += e.what(); errorMessage += e.what();
@ -130,6 +132,7 @@ PlaylistEvent :: deInitialize(void) throw ()
} }
playlist.reset(); playlist.reset();
state = deInitialized; state = deInitialized;
std::cerr << "PlaylistEvent :: deInitialize END\n";
} }
@ -139,6 +142,7 @@ PlaylistEvent :: deInitialize(void) throw ()
void void
PlaylistEvent :: start(void) throw () PlaylistEvent :: start(void) throw ()
{ {
std::cerr << "PlaylistEvent :: start BEGIN\n";
if (state != initialized) { if (state != initialized) {
// TODO: handle error? // TODO: handle error?
return; return;
@ -147,6 +151,7 @@ PlaylistEvent :: start(void) throw ()
try { try {
audioPlayer->open(*playlist->getUri()); audioPlayer->open(*playlist->getUri());
audioPlayer->start(); audioPlayer->start();
std::cerr << "PlaylistEvent :: audio player started\n";
playLog->addPlayLogEntry(playlist->getId(), TimeConversion::now()); playLog->addPlayLogEntry(playlist->getId(), TimeConversion::now());
} catch (std::invalid_argument &e) { } catch (std::invalid_argument &e) {
@ -166,6 +171,7 @@ PlaylistEvent :: start(void) throw ()
void void
PlaylistEvent :: stop(void) throw () PlaylistEvent :: stop(void) throw ()
{ {
std::cerr << "PlaylistEvent :: stop BEGIN\n";
if (state != running) { if (state != running) {
// TODO: handle error? // TODO: handle error?
return; return;
@ -174,6 +180,7 @@ PlaylistEvent :: stop(void) throw ()
try { try {
audioPlayer->stop(); audioPlayer->stop();
audioPlayer->close(); audioPlayer->close();
std::cerr << "PlaylistEvent :: audio player stopped\n";
} catch (std::logic_error &e) { } catch (std::logic_error &e) {
// TODO: handle error // TODO: handle error
// NOTE: this may not be an error, because the user may have stopped // NOTE: this may not be an error, because the user may have stopped