diff --git a/livesupport/products/gLiveSupport/src/GLiveSupport.cxx b/livesupport/products/gLiveSupport/src/GLiveSupport.cxx index 88a2d20a2..65e5df55e 100644 --- a/livesupport/products/gLiveSupport/src/GLiveSupport.cxx +++ b/livesupport/products/gLiveSupport/src/GLiveSupport.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.59 $ + Version : $Revision: 1.60 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.cxx,v $ ------------------------------------------------------------------------------*/ @@ -443,6 +443,7 @@ LiveSupport :: GLiveSupport :: GLiveSupport :: logout(void) throw () { if (sessionId.get() != 0) { + cancelEditedPlaylist(); stopCueAudio(); storeScratchpadContents(); scratchpadContents->clear(); @@ -700,24 +701,19 @@ GLiveSupport :: addToPlaylist(Ptr::Ref id) /*------------------------------------------------------------------------------ * Save the currently edited playlist in storage *----------------------------------------------------------------------------*/ -Ptr::Ref +void LiveSupport :: GLiveSupport :: GLiveSupport :: savePlaylist(void) throw (XmlRpcException) { - Ptr::Ref playlist; - if (editedPlaylist) { if (editedPlaylist->isLocked()) { editedPlaylist->deleteSavedCopy(); storage->savePlaylist(sessionId, editedPlaylist); - playlist = storage->getPlaylist(sessionId, editedPlaylist->getId()); - addToScratchpad(playlist); + addToScratchpad(editedPlaylist); // update with new version } editedPlaylist.reset(); } - - return playlist; } diff --git a/livesupport/products/gLiveSupport/src/GLiveSupport.h b/livesupport/products/gLiveSupport/src/GLiveSupport.h index a2d0542be..f18023252 100644 --- a/livesupport/products/gLiveSupport/src/GLiveSupport.h +++ b/livesupport/products/gLiveSupport/src/GLiveSupport.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.43 $ + Version : $Revision: 1.44 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.h,v $ ------------------------------------------------------------------------------*/ @@ -102,7 +102,7 @@ class MasterPanelWindow; * respective documentation. * * @author $Author: fgerlits $ - * @version $Revision: 1.43 $ + * @version $Revision: 1.44 $ * @see LocalizedObject#getBundle(const xmlpp::Element &) * @see AuthenticationClientFactory * @see StorageClientFactory @@ -547,13 +547,14 @@ class GLiveSupport : public LocalizedConfigurable, * Save the currently edited playlist in storage. * This call has to be preceeded by a call to openPlaylistForEditing() * or addToPlaylist(). + * After this call, the playlist is no longer being edited. If you + * want to continue editing, open the playlist for editing again. * - * @return the audio clip that was saved. * @exception XmlRpcException on upload failures. * @see #openPlaylistForEditing * @see #addToPlaylist */ - Ptr::Ref + void savePlaylist(void) throw (XmlRpcException); /** diff --git a/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx b/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx index bfc3ff29f..3524c3f91 100644 --- a/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx +++ b/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.21 $ + Version : $Revision: 1.22 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx,v $ ------------------------------------------------------------------------------*/ @@ -69,7 +69,8 @@ SimplePlaylistManagementWindow :: SimplePlaylistManagementWindow ( Colors::White, WidgetFactory::getInstance()->getWhiteWindowCorners()), LocalizedObject(bundle), - gLiveSupport(gLiveSupport) + gLiveSupport(gLiveSupport), + isPlaylistModified(false) { Ptr::Ref wf = WidgetFactory::getInstance(); @@ -128,6 +129,23 @@ SimplePlaylistManagementWindow :: SimplePlaylistManagementWindow ( entriesView->signalCellEdited().connect(sigc::mem_fun( *this, &SimplePlaylistManagementWindow::onFadeInfoEdited )); + // construct the "lock fades" check button + Ptr::Ref lockFadesCheckButtonLabel; + try { + lockFadesCheckButtonLabel = getResourceUstring( + "lockFadesCheckButtonLabel"); + } catch (std::invalid_argument &e) { + std::cerr << e.what() << std::endl; + std::exit(1); + } + Gtk::CheckButton * lockFadesCheckButton = Gtk::manage(new Gtk::CheckButton( + *lockFadesCheckButtonLabel )); + lockFadesCheckButton->set_active(true); + areFadesLocked = true; + lockFadesCheckButton->signal_toggled().connect(sigc::mem_fun( + *this, + &SimplePlaylistManagementWindow::onLockFadesCheckButtonClicked )); + // set up the layout Gtk::VBox * mainBox = Gtk::manage(new Gtk::VBox); @@ -142,6 +160,8 @@ SimplePlaylistManagementWindow :: SimplePlaylistManagementWindow ( mainBox->pack_start(*entriesScrolledWindow, Gtk::PACK_EXPAND_WIDGET, 5); + mainBox->pack_start(*lockFadesCheckButton, Gtk::PACK_SHRINK, 5); + Gtk::ButtonBox * buttonBox = Gtk::manage(new Gtk::HButtonBox( Gtk::BUTTONBOX_END, 5)); buttonBox->pack_start(*saveButton); @@ -218,16 +238,15 @@ SimplePlaylistManagementWindow :: savePlaylist (void) throw () playlist->setTitle(title); gLiveSupport->savePlaylist(); + gLiveSupport->openPlaylistForEditing(playlist->getId()); + isPlaylistModified = false; Ptr::Ref statusText = formatMessage( "playlistSavedMsg", *playlist->getTitle()); statusBar->set_text(*statusText); - - // clean the entry fields - nameEntry->set_text(""); - entriesModel->clear(); return true; + } catch (XmlRpcException &e) { statusBar->set_text(e.what()); return false; @@ -236,50 +255,81 @@ SimplePlaylistManagementWindow :: savePlaylist (void) throw () /*------------------------------------------------------------------------------ - * Event handler for the save button getting clicked. + * Signal handler for the save button getting clicked. *----------------------------------------------------------------------------*/ void -SimplePlaylistManagementWindow :: onSaveButtonClicked (void) throw () +SimplePlaylistManagementWindow :: onSaveButtonClicked(void) throw () { savePlaylist(); } /*------------------------------------------------------------------------------ - * Event handler for the close button getting clicked. + * Cancel the edited playlist (no questions asked). *----------------------------------------------------------------------------*/ void -SimplePlaylistManagementWindow :: onCloseButtonClicked (void) throw () +SimplePlaylistManagementWindow :: cancelPlaylist(void) throw () +{ + gLiveSupport->cancelEditedPlaylist(); + closeWindow(); +} + + +/*------------------------------------------------------------------------------ + * Signal handler for the close button getting clicked. + *----------------------------------------------------------------------------*/ +void +SimplePlaylistManagementWindow :: onCloseButtonClicked(void) throw () { if (gLiveSupport->getEditedPlaylist()) { - DialogWindow::ButtonType result = dialogWindow->run(); - switch (result) { - case DialogWindow::noButton: - gLiveSupport->cancelEditedPlaylist(); - statusBar->set_text(""); - nameEntry->set_text(""); - entriesModel->clear(); - break; + if (!isPlaylistModified) { + cancelPlaylist(); + } else { + DialogWindow::ButtonType result = dialogWindow->run(); + switch (result) { + case DialogWindow::noButton: cancelPlaylist(); + break; - case DialogWindow::yesButton: - if (savePlaylist()) { - statusBar->set_text(""); - break; - } else { - return; - } + case DialogWindow::yesButton: if (savePlaylist()) { + closeWindow(); + } + break; - case DialogWindow::cancelButton: - return; - default : // can happen if window is closed - return; // with Alt-F4 -- treated as cancel + case DialogWindow::cancelButton: break; + + default : break; + // can happen if window is closed + } // with Alt-F4 -- treated as cancel } } +} + +/*------------------------------------------------------------------------------ + * Clean and close the window. + *----------------------------------------------------------------------------*/ +void +SimplePlaylistManagementWindow :: closeWindow(void) throw () +{ + statusBar->set_text(""); + nameEntry->set_text(""); + entriesModel->clear(); + isPlaylistModified = false; hide(); } +/*------------------------------------------------------------------------------ + * Signal handler for the "lock fades" check button toggled. + *----------------------------------------------------------------------------*/ +void +SimplePlaylistManagementWindow :: onLockFadesCheckButtonClicked(void) + throw () +{ + areFadesLocked = !areFadesLocked; +} + + /*------------------------------------------------------------------------------ * Show the contents of the currently edited playlist. *----------------------------------------------------------------------------*/ @@ -349,8 +399,13 @@ SimplePlaylistManagementWindow :: onFadeInfoEdited( std::vector rowNumberVector = path.get_indices(); int rowNumber = rowNumberVector.at(0); - Ptr::Ref newTime(new time_duration( - duration_from_string(newText) )); + Ptr::Ref newTime; + try { + newTime.reset(new time_duration(duration_from_string(newText))); + } catch (boost::bad_lexical_cast &e) { + showContents(); // bad time format; restore previous state + return; + } Ptr::Ref playlist = gLiveSupport->getEditedPlaylist(); Playlist::const_iterator iter = playlist->begin(); @@ -363,16 +418,14 @@ SimplePlaylistManagementWindow :: onFadeInfoEdited( switch (columnId) { case fadeInColumnId : setFadeIn(playlistElement, newTime); - if (iter != playlist->begin()) { - --iter; + if (areFadesLocked && iter-- != playlist->begin()) { Ptr::Ref prevPlaylistElement = iter->second; setFadeOut(prevPlaylistElement, newTime); } break; case fadeOutColumnId : setFadeOut(playlistElement, newTime); - ++iter; - if (iter != playlist->end()) { + if (areFadesLocked && ++iter != playlist->end()) { Ptr::Ref nextPlaylistElement = iter->second; setFadeIn(nextPlaylistElement, newTime); } @@ -392,22 +445,26 @@ SimplePlaylistManagementWindow :: onFadeInfoEdited( * Auxilliary function: set the fade in of a playlist element. *----------------------------------------------------------------------------*/ void -GLiveSupport :: setFadeIn(Ptr::Ref playlistElement, +SimplePlaylistManagementWindow :: setFadeIn( + Ptr::Ref playlistElement, Ptr::Ref newFadeIn) throw() { Ptr::Ref oldFadeInfo = playlistElement->getFadeInfo(); Ptr::Ref oldFadeOut; if (oldFadeInfo) { - oldFadeOut = oldFadeInfo->getFadeOut(); + if (*oldFadeInfo->getFadeIn() == *newFadeIn) { + return; + } + oldFadeOut = oldFadeInfo->getFadeOut(); } else { oldFadeOut.reset(new time_duration(0,0,0,0)); } - Ptr::Ref newFadeInfo(new FadeInfo( newFadeIn, oldFadeOut )); if (isLengthOkay(playlistElement, newFadeInfo)) { playlistElement->setFadeInfo(newFadeInfo); + isPlaylistModified = true; } } @@ -416,13 +473,17 @@ GLiveSupport :: setFadeIn(Ptr::Ref playlistElement, * Auxilliary function: set the fade out of a playlist element. *----------------------------------------------------------------------------*/ void -GLiveSupport :: setFadeOut(Ptr::Ref playlistElement, - Ptr::Ref newFadeOut) +SimplePlaylistManagementWindow :: setFadeOut( + Ptr::Ref playlistElement, + Ptr::Ref newFadeOut) throw() { Ptr::Ref oldFadeInfo = playlistElement->getFadeInfo(); Ptr::Ref oldFadeIn; if (oldFadeInfo) { + if (*oldFadeInfo->getFadeOut() == *newFadeOut) { + return; + } oldFadeIn = oldFadeInfo->getFadeIn(); } else { oldFadeIn.reset(new time_duration(0,0,0,0)); @@ -431,6 +492,7 @@ GLiveSupport :: setFadeOut(Ptr::Ref playlistElement, oldFadeIn, newFadeOut )); if (isLengthOkay(playlistElement, newFadeInfo)) { playlistElement->setFadeInfo(newFadeInfo); + isPlaylistModified = true; } } @@ -439,12 +501,13 @@ GLiveSupport :: setFadeOut(Ptr::Ref playlistElement, * Auxilliary function: check that fades are not longer than the whole clip. *----------------------------------------------------------------------------*/ inline bool -GLiveSupport :: isLengthOkay(Ptr::Ref playlistElement, - Ptr::Ref newFadeInfo) +SimplePlaylistManagementWindow :: isLengthOkay( + Ptr::Ref playlistElement, + Ptr::Ref newFadeInfo) throw() { time_duration totalFades = *newFadeInfo->getFadeIn() + *newFadeInfo->getFadeOut(); - return (totalFades < *playlistElement->getPlayable()->getPlaylength()); + return (totalFades <= *playlistElement->getPlayable()->getPlaylength()); } diff --git a/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.h b/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.h index 0dad2d98f..4a21cac88 100644 --- a/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.h +++ b/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.10 $ + Version : $Revision: 1.11 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.h,v $ ------------------------------------------------------------------------------*/ @@ -81,13 +81,14 @@ using namespace LiveSupport::Widgets; * | | +-- entry2 ----------------------------+ | | * | | ... | | * | +------------------------------------------+ | + * | +- lock fades checkbox -+ | * | +- save button -+ +- close button -+ | * | +-- status bar ----------------------------+ | * +----------------------------------------------+ * * * @author $Author: fgerlits $ - * @version $Revision: 1.10 $ + * @version $Revision: 1.11 $ */ class SimplePlaylistManagementWindow : public WhiteWindow, public LocalizedObject @@ -108,6 +109,46 @@ class SimplePlaylistManagementWindow : public WhiteWindow, int columnId, const Glib::ustring & newText) throw(); + /** + * Set the fade in of a playlist element. + */ + void + setFadeIn(Ptr::Ref playlistElement, + Ptr::Ref newFadeIn) throw(); + + /** + * Set the fade out of a playlist element. + */ + void + setFadeOut(Ptr::Ref playlistElement, + Ptr::Ref newFadeOut) throw(); + + /** + * Check that fades are not longer than the whole clip. + * + * @return true if (fadeIn + fadeOut <= playlength). + */ + bool + isLengthOkay(Ptr::Ref playlistElement, + Ptr::Ref newFadeInfo) throw(); + + /** + * Cancel the edited playlist. + * Cancel the edited playlist in GLiveSupport, and close the window. + * + * @see GLiveSupport::cancelEditedPlaylist() + * @see closeWindow() + */ + void + cancelPlaylist(void) throw(); + + /** + * Clean and close the window. + * Set all widgets to empty and close the window. + */ + void + closeWindow(void) throw(); + protected: @@ -116,7 +157,7 @@ class SimplePlaylistManagementWindow : public WhiteWindow, * Lists one playlist entry per row. * * @author $Author: fgerlits $ - * @version $Revision: 1.10 $ + * @version $Revision: 1.11 $ */ class ModelColumns : public ZebraTreeModelColumnRecord { @@ -221,6 +262,18 @@ class SimplePlaylistManagementWindow : public WhiteWindow, */ Ptr::Ref dialogWindow; + /** + * A flag set to true when the edited playlist is modified. + */ + bool isPlaylistModified; + + /** + * A flag controlled by the "lock fades" check button. + * This determines whether the fade-out of a clip is assumed to + * be equal to the fade-in of the next clip. + */ + bool areFadesLocked; + /** * Save the edited playlist. * @@ -241,6 +294,12 @@ class SimplePlaylistManagementWindow : public WhiteWindow, virtual void onCloseButtonClicked(void) throw (); + /** + * Signal handler for the "lock fades" check button toggled. + */ + virtual void + onLockFadesCheckButtonClicked(void) throw (); + public: /** @@ -273,27 +332,6 @@ class SimplePlaylistManagementWindow : public WhiteWindow, /* ====================================================== function prototypes */ - /** - * Auxilliary function: set the fade in of a playlist element. - */ - void - setFadeIn(Ptr::Ref playlistElement, - Ptr::Ref newFadeIn) throw(); - - /** - * Auxilliary function: set the fade out of a playlist element. - */ - void - setFadeOut(Ptr::Ref playlistElement, - Ptr::Ref newFadeOut) throw(); - - /** - * Auxilliary function: check that fades are not longer than - * the whole clip. - */ - bool - isLengthOkay(Ptr::Ref playlistElement, - Ptr::Ref newFadeInfo) throw(); } // namespace GLiveSupport } // namespace LiveSupport diff --git a/livesupport/products/gLiveSupport/var/root.txt b/livesupport/products/gLiveSupport/var/root.txt index 470c27870..1bf22d8ff 100644 --- a/livesupport/products/gLiveSupport/var/root.txt +++ b/livesupport/products/gLiveSupport/var/root.txt @@ -117,6 +117,8 @@ root:table nameLabel:string { "Name" } saveButtonLabel:string { "Save" } closeButtonLabel:string { "Close" } + lockFadesCheckButtonLabel:string + { "Lock fade-out to following fade-in" } statusBar:string { "status bar" } playlistSavedMsg:string { "Saved playlist ''{0}''." } savePlaylistDialogMsg:string { "Do you want to save the playlist?" }