diff --git a/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx b/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx index 7294cd369..f682bcbf0 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.16 $ + Version : $Revision: 1.17 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx,v $ ------------------------------------------------------------------------------*/ @@ -104,8 +104,7 @@ SimplePlaylistManagementWindow :: SimplePlaylistManagementWindow ( entriesView->appendColumn(*getResourceUstring("lengthColumnLabel"), modelColumns.lengthColumn, 120); - statusBar = Gtk::manage(new Gtk::Label( - *getResourceUstring("statusBar"))); + statusBar = Gtk::manage(new Gtk::Label("")); } catch (std::invalid_argument &e) { std::cerr << e.what() << std::endl; std::exit(1); @@ -156,13 +155,14 @@ SimplePlaylistManagementWindow :: SimplePlaylistManagementWindow ( Ptr::Ref confirmationMessage; try { confirmationMessage.reset(new Glib::ustring( - *getResourceUstring("sureToExitMsg") )); + *getResourceUstring("savePlaylistDialogMsg") )); } catch (std::invalid_argument &e) { std::cerr << e.what() << std::endl; std::exit(1); } dialogWindow.reset(new DialogWindow(confirmationMessage, + DialogWindow::cancelButton | DialogWindow::noButton | DialogWindow::yesButton, gLiveSupport->getBundle() )); @@ -179,26 +179,27 @@ SimplePlaylistManagementWindow :: ~SimplePlaylistManagementWindow (void) /*------------------------------------------------------------------------------ - * Event handler for the save button getting clicked. + * Save the edited playlist. *----------------------------------------------------------------------------*/ -void -SimplePlaylistManagementWindow :: onSaveButtonClicked (void) throw () +bool +SimplePlaylistManagementWindow :: savePlaylist (void) throw () { try { - Ptr::Ref title; - Ptr::Ref playlist; - - title.reset(new Glib::ustring(nameEntry->get_text())); - // TODO: check for empty title and display "are you sure?" message - - playlist = gLiveSupport->getEditedPlaylist(); + Ptr::Ref playlist + = gLiveSupport->getEditedPlaylist(); if (!playlist) { - return; + return false; + } + + Ptr::Ref title(new Glib::ustring( + nameEntry->get_text())); + if (*title == "") { + statusBar->set_text(*getResourceUstring("emptyTitleErrorMsg")); + return false; } playlist->setTitle(title); - - playlist = gLiveSupport->savePlaylist(); + gLiveSupport->savePlaylist(); Ptr::Ref statusText = formatMessage( "playlistSavedMsg", @@ -208,34 +209,56 @@ SimplePlaylistManagementWindow :: onSaveButtonClicked (void) throw () // clean the entry fields nameEntry->set_text(""); entriesModel->clear(); + return true; } catch (XmlRpcException &e) { statusBar->set_text(e.what()); + return false; } } +/*------------------------------------------------------------------------------ + * Event handler for the save button getting clicked. + *----------------------------------------------------------------------------*/ +void +SimplePlaylistManagementWindow :: onSaveButtonClicked (void) throw () +{ + savePlaylist(); +} + + /*------------------------------------------------------------------------------ * Event handler for the close button getting clicked. *----------------------------------------------------------------------------*/ void SimplePlaylistManagementWindow :: onCloseButtonClicked (void) throw () { - // TODO: only ask if playlist has been modified - DialogWindow::ButtonType result = dialogWindow->run(); - switch (result) { - case DialogWindow::noButton: - return; + if (gLiveSupport->getEditedPlaylist()) { + DialogWindow::ButtonType result = dialogWindow->run(); + switch (result) { + case DialogWindow::noButton: + gLiveSupport->cancelEditedPlaylist(); + statusBar->set_text(""); + nameEntry->set_text(""); + entriesModel->clear(); + break; - case DialogWindow::yesButton: - gLiveSupport->cancelEditedPlaylist(); - hide(); - break; + case DialogWindow::yesButton: + if (savePlaylist()) { + statusBar->set_text(""); + break; + } else { + return; + } - default: std::cerr << "Error: DialogWindow returned " << result - << "; " << DialogWindow::noButton << " or " - << DialogWindow::yesButton << " is expected." - << std::endl; + case DialogWindow::cancelButton: + return; + default : // can happen if window is closed + return; // with Alt-F4 -- treated as cancel + } } + + hide(); } diff --git a/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.h b/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.h index ef192f3ae..775f4e689 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.6 $ + Version : $Revision: 1.7 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.h,v $ ------------------------------------------------------------------------------*/ @@ -87,7 +87,7 @@ using namespace LiveSupport::Widgets; * * * @author $Author: fgerlits $ - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ */ class SimplePlaylistManagementWindow : public WhiteWindow, public LocalizedObject @@ -100,7 +100,7 @@ class SimplePlaylistManagementWindow : public WhiteWindow, * Lists one playlist entry per row. * * @author $Author: fgerlits $ - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ */ class ModelColumns : public ZebraTreeModelColumnRecord { @@ -193,6 +193,14 @@ class SimplePlaylistManagementWindow : public WhiteWindow, */ Ptr::Ref dialogWindow; + /** + * Save the edited playlist. + * + * @return true if the playlist was saved successully. + */ + virtual bool + savePlaylist(void) throw (); + /** * Signal handler for the save button clicked. */ diff --git a/livesupport/products/gLiveSupport/var/es.txt b/livesupport/products/gLiveSupport/var/es.txt index 424b2ce25..01496ded5 100644 --- a/livesupport/products/gLiveSupport/var/es.txt +++ b/livesupport/products/gLiveSupport/var/es.txt @@ -110,6 +110,8 @@ es:table closeButtonLabel:string { "cerrar" } statusBar:string { "barra de estatus" } playlistSavedMsg:string { "lista de reproducción guardada {0}" } + savePlaylistDialogMsg:string { "*** translate me ***" } + emptyTitleErrorMsg:string { "*** translate me ***" } } schedulerWindow:table diff --git a/livesupport/products/gLiveSupport/var/hu.txt b/livesupport/products/gLiveSupport/var/hu.txt index cf48823f8..f3b51dd2b 100644 --- a/livesupport/products/gLiveSupport/var/hu.txt +++ b/livesupport/products/gLiveSupport/var/hu.txt @@ -115,7 +115,8 @@ hu:table closeButtonLabel:string { "bezár" } statusBar:string { "állapotsor" } playlistSavedMessage:string { "a {0} műsor elmentve" } - sureToExitMsg:string { "Biztos, hogy nem akarja elmenteni a műsort?" } + savePlaylistDialogMsg:string { "El szeretné menteni a műsort?" } + emptyTitleErrorMsg:string { "Kérem, adjon meg egy címet!" } } schedulerWindow:table diff --git a/livesupport/products/gLiveSupport/var/nl.txt b/livesupport/products/gLiveSupport/var/nl.txt index 9134660c1..4efa64b17 100644 --- a/livesupport/products/gLiveSupport/var/nl.txt +++ b/livesupport/products/gLiveSupport/var/nl.txt @@ -110,6 +110,8 @@ nl:table closeButtonLabel:string { "sluiten" } statusBar:string { "status balk" } playlistSavedMsg:string { "playlist {0} opgeslagen" } + savePlaylistDialogMsg:string { "*** translate me ***" } + emptyTitleErrorMsg:string { "*** translate me ***" } } schedulerWindow:table diff --git a/livesupport/products/gLiveSupport/var/root.txt b/livesupport/products/gLiveSupport/var/root.txt index 85469e420..ef7970985 100644 --- a/livesupport/products/gLiveSupport/var/root.txt +++ b/livesupport/products/gLiveSupport/var/root.txt @@ -116,7 +116,8 @@ root:table closeButtonLabel:string { "close" } statusBar:string { "status bar" } playlistSavedMsg:string { "saved playlist {0}" } - sureToExitMsg:string { "Do you want to exit without saving?" } + savePlaylistDialogMsg:string { "Would you like to save the playlist?" } + emptyTitleErrorMsg:string { "Please enter a title." } } schedulerWindow:table diff --git a/livesupport/products/gLiveSupport/var/sr_CS.txt b/livesupport/products/gLiveSupport/var/sr_CS.txt index 78a0756fb..318d1fa07 100644 --- a/livesupport/products/gLiveSupport/var/sr_CS.txt +++ b/livesupport/products/gLiveSupport/var/sr_CS.txt @@ -110,6 +110,8 @@ sr_CS:table closeButtonLabel:string { "zatvori" } statusBar:string { "status bar" } playlistSavedMsg:string { "sačuvana plej lista {0}" } + savePlaylistDialogMsg:string { "*** translate me ***" } + emptyTitleErrorMsg:string { "*** translate me ***" } } schedulerWindow:table diff --git a/livesupport/products/gLiveSupport/var/sr_CS_CYRILLIC.txt b/livesupport/products/gLiveSupport/var/sr_CS_CYRILLIC.txt index 6095a8983..313ee34a9 100644 --- a/livesupport/products/gLiveSupport/var/sr_CS_CYRILLIC.txt +++ b/livesupport/products/gLiveSupport/var/sr_CS_CYRILLIC.txt @@ -109,6 +109,8 @@ sr_CS_CYRILLIC:table closeButtonLabel:string { "затвори" } statusBar:string { "статус бар" } playlistSavedMsg:string { "сачувана плеј листа {0}" } + savePlaylistDialogMsg:string { "*** translate me ***" } + emptyTitleErrorMsg:string { "*** translate me ***" } } schedulerWindow:table