From 1c1455085c3cc6f643c52391b15b317f39e86339 Mon Sep 17 00:00:00 2001 From: fgerlits Date: Tue, 1 Aug 2006 16:04:59 +0000 Subject: [PATCH] fixing #1713 --- .../gLiveSupport/src/GLiveSupport.cxx | 10 ++++----- .../products/gLiveSupport/src/GLiveSupport.h | 13 ++++++++++-- .../src/SimplePlaylistManagementWindow.cxx | 21 ++++++++++++++++--- .../src/SimplePlaylistManagementWindow.h | 13 +++++++++++- 4 files changed, 46 insertions(+), 11 deletions(-) diff --git a/livesupport/src/products/gLiveSupport/src/GLiveSupport.cxx b/livesupport/src/products/gLiveSupport/src/GLiveSupport.cxx index 71b9ec117..a861875ff 100644 --- a/livesupport/src/products/gLiveSupport/src/GLiveSupport.cxx +++ b/livesupport/src/products/gLiveSupport/src/GLiveSupport.cxx @@ -951,13 +951,15 @@ GLiveSupport :: setNowPlaying(Ptr::Ref playable) /*------------------------------------------------------------------------------ * Open a playlist for editing. *----------------------------------------------------------------------------*/ -Ptr::Ref +void LiveSupport :: GLiveSupport :: GLiveSupport :: openPlaylistForEditing(Ptr::Ref playlistId) throw (XmlRpcException) { - cancelEditedPlaylist(); - + if (masterPanel->cancelEditedPlaylist() == false) { + return; // the user canceled the operation + } + if (!playlistId.get()) { playlistId = storage->createPlaylist(sessionId); } else { @@ -983,8 +985,6 @@ GLiveSupport :: openPlaylistForEditing(Ptr::Ref playlistId) editedPlaylist->createSavedCopy(); masterPanel->updateSimplePlaylistMgmtWindow(); - - return editedPlaylist; } diff --git a/livesupport/src/products/gLiveSupport/src/GLiveSupport.h b/livesupport/src/products/gLiveSupport/src/GLiveSupport.h index 7b0162f8b..dd48107f6 100644 --- a/livesupport/src/products/gLiveSupport/src/GLiveSupport.h +++ b/livesupport/src/products/gLiveSupport/src/GLiveSupport.h @@ -724,7 +724,16 @@ class GLiveSupport : public LocalizedConfigurable, * Create a new playlist or Open a playlist for editing. * The opened playlist can be later accessed by getEditedPlaylist(). * Always release the opened playlist by calling - * releaseEditedPlaylist() + * releaseEditedPlaylist(). + * + * If the argument is 0, a new playlist is created in the storage. + * + * After a call to this function, getEditedPlaylist() is guaranteed + * to return a non-0 value. + * + * If there is a playlist being edited, the + * SimplePlaylistManagementWindow's confirmation message is displayed. + * If the user presses "Cancel", then this function does nothing. * * @param playlistId the id of the playlist to open for editing. * if a reference to 0, create a new playlist. @@ -733,7 +742,7 @@ class GLiveSupport : public LocalizedConfigurable, * @see #getEditedPlaylist * @see #releaseEditedPlaylist */ - Ptr::Ref + void openPlaylistForEditing( Ptr::Ref playlistId = Ptr::Ref()) diff --git a/livesupport/src/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx b/livesupport/src/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx index 779d246e2..6942d1a43 100644 --- a/livesupport/src/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx +++ b/livesupport/src/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx @@ -214,9 +214,9 @@ SimplePlaylistManagementWindow :: SimplePlaylistManagementWindow ( // Register the signal handlers for the buttons saveButton->signal_clicked().connect(sigc::mem_fun(*this, - &SimplePlaylistManagementWindow::onSaveButtonClicked)); + &SimplePlaylistManagementWindow::onSaveButtonClicked)); closeButton->signal_clicked().connect(sigc::mem_fun(*this, - &SimplePlaylistManagementWindow::onCloseButtonClicked)); + &SimplePlaylistManagementWindow::onBottomCloseButtonClicked)); // show set_name(windowName); @@ -325,6 +325,7 @@ SimplePlaylistManagementWindow :: cancelPlaylist(void) throw () std::cerr << e.what() << std::endl; return false; } + isPlaylistModified = false; break; case DialogWindow::yesButton: @@ -361,6 +362,18 @@ SimplePlaylistManagementWindow :: closeWindow(void) throw () } +/*------------------------------------------------------------------------------ + * Signal handler for the save button getting clicked. + *----------------------------------------------------------------------------*/ +void +SimplePlaylistManagementWindow :: onBottomCloseButtonClicked(void) throw () +{ + if (cancelPlaylist()) { + closeWindow(); + } +} + + /*------------------------------------------------------------------------------ * Signal handler for the "lock fades" check button toggled. *----------------------------------------------------------------------------*/ @@ -432,7 +445,9 @@ SimplePlaylistManagementWindow :: onTitleEdited(void) throw() Ptr::Ref playlist = gLiveSupport->getEditedPlaylist(); if (!playlist) { try { - playlist = gLiveSupport->openPlaylistForEditing(); + gLiveSupport->openPlaylistForEditing(); + playlist = gLiveSupport->getEditedPlaylist(); + } catch (XmlRpcException &e) { std::cerr << "error in SimplePlaylistManagementWindow::" "onTitleEdited(): " diff --git a/livesupport/src/products/gLiveSupport/src/SimplePlaylistManagementWindow.h b/livesupport/src/products/gLiveSupport/src/SimplePlaylistManagementWindow.h index 57a76e55c..3ed60508b 100644 --- a/livesupport/src/products/gLiveSupport/src/SimplePlaylistManagementWindow.h +++ b/livesupport/src/products/gLiveSupport/src/SimplePlaylistManagementWindow.h @@ -183,11 +183,22 @@ class SimplePlaylistManagementWindow : public GuiWindow selectRow(int rowNumber) throw (); /** - * Signal handler for the save button clicked. + * Signal handler for a click on the save button. */ void onSaveButtonClicked(void) throw (); + /** + * Signal handler for a click on the close button at the bottom + * right corner. + * This cancels the edited playlist; the normal close button (X) + * at the upper right corner hides the window only. + * If the playlist has been modified, a confirmation message will + * be displayed. + */ + void + onBottomCloseButtonClicked(void) throw (); + /** * Signal handler for the "lock fades" check button toggled. */