From c4ff6b2a2d87de82b9da066cec17557907e86d0f Mon Sep 17 00:00:00 2001 From: fgerlits Date: Mon, 14 Aug 2006 17:16:57 +0000 Subject: [PATCH] fixing #1434 --- .../gLiveSupport/src/SchedulerWindow.cxx | 30 ++++++++++++++++++- .../gLiveSupport/src/SchedulerWindow.h | 7 +++++ .../src/products/gLiveSupport/var/root.txt | 4 +-- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/livesupport/src/products/gLiveSupport/src/SchedulerWindow.cxx b/livesupport/src/products/gLiveSupport/src/SchedulerWindow.cxx index cf752d3a2..51db63d16 100644 --- a/livesupport/src/products/gLiveSupport/src/SchedulerWindow.cxx +++ b/livesupport/src/products/gLiveSupport/src/SchedulerWindow.cxx @@ -115,6 +115,21 @@ SchedulerWindow :: SchedulerWindow ( showContents(); show_all_children(); + + // set up the dialog window + Ptr::Ref confirmationMessage; + try { + confirmationMessage.reset(new Glib::ustring( + *getResourceUstring("stopCurrentlyPlayingDialogMsg") )); + } catch (std::invalid_argument &e) { + std::cerr << e.what() << std::endl; + std::exit(1); + } + + dialogWindow.reset(new DialogWindow(confirmationMessage, + DialogWindow::noButton | + DialogWindow::yesButton, + gLiveSupport->getBundle() )); } @@ -382,6 +397,18 @@ SchedulerWindow :: onDeleteItem(void) throw () void SchedulerWindow :: onStopCurrentlyPlayingButtonClicked(void) throw () { + DialogWindow::ButtonType result = dialogWindow->run(); + switch (result) { + case DialogWindow::yesButton: break; + + case DialogWindow::noButton: return; + break; + + // can happen if the window is closed with Alt-F4 -- treated as No + default : return; + break; + } + Ptr::Ref sessionId = gLiveSupport->getSessionId(); Ptr::Ref scheduler = gLiveSupport->getScheduler(); @@ -390,7 +417,8 @@ SchedulerWindow :: onStopCurrentlyPlayingButtonClicked(void) throw () scheduler->stopCurrentlyPlaying(sessionId); } catch (XmlRpcException &e) { - // TODO: signal error here + Ptr::Ref errorMessage(new Glib::ustring(e.what())); + gLiveSupport->displayMessageWindow(errorMessage); } } diff --git a/livesupport/src/products/gLiveSupport/src/SchedulerWindow.h b/livesupport/src/products/gLiveSupport/src/SchedulerWindow.h index ae37b2aa6..ef707d01b 100644 --- a/livesupport/src/products/gLiveSupport/src/SchedulerWindow.h +++ b/livesupport/src/products/gLiveSupport/src/SchedulerWindow.h @@ -50,6 +50,7 @@ #include "LiveSupport/Core/Ptr.h" #include "LiveSupport/Core/LocalizedObject.h" +#include "LiveSupport/Widgets/DialogWindow.h" #include "GuiWindow.h" #include "GLiveSupport.h" @@ -207,6 +208,12 @@ class SchedulerWindow : public GuiWindow */ Gtk::Button * closeButton; + /** + * The "are you sure you want to stop the currently playing item?" + * dialog window. + */ + Ptr::Ref dialogWindow; + /** * Signal handler for when a date is selected in the calendar. */ diff --git a/livesupport/src/products/gLiveSupport/var/root.txt b/livesupport/src/products/gLiveSupport/var/root.txt index 260ab0c96..9524496b8 100644 --- a/livesupport/src/products/gLiveSupport/var/root.txt +++ b/livesupport/src/products/gLiveSupport/var/root.txt @@ -170,8 +170,8 @@ root:table stopCurrentlyPlayingText:string { "Currently playing in scheduler:" } - stopCurrentlyPlayingButtonLabel:string - { "Stop" } + stopCurrentlyPlayingButtonLabel:string { "Stop" } + stopCurrentlyPlayingDialogMsg:string { "Are you sure?" } closeButtonLabel:string { "Close" } }