fixed the "do you want to save?" dialog in the SimplePlaylistMgmtWindow
This commit is contained in:
parent
c9e0aa62ce
commit
387b64e0a5
8 changed files with 76 additions and 35 deletions
|
@ -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<Glib::ustring>::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<const Glib::ustring>::Ref title;
|
||||
Ptr<Playlist>::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<Playlist>::Ref playlist
|
||||
= gLiveSupport->getEditedPlaylist();
|
||||
if (!playlist) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
Ptr<const Glib::ustring>::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<Glib::ustring>::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
|
||||
if (gLiveSupport->getEditedPlaylist()) {
|
||||
DialogWindow::ButtonType result = dialogWindow->run();
|
||||
switch (result) {
|
||||
case DialogWindow::noButton:
|
||||
return;
|
||||
|
||||
case DialogWindow::yesButton:
|
||||
gLiveSupport->cancelEditedPlaylist();
|
||||
hide();
|
||||
statusBar->set_text("");
|
||||
nameEntry->set_text("");
|
||||
entriesModel->clear();
|
||||
break;
|
||||
|
||||
default: std::cerr << "Error: DialogWindow returned " << result
|
||||
<< "; " << DialogWindow::noButton << " or "
|
||||
<< DialogWindow::yesButton << " is expected."
|
||||
<< std::endl;
|
||||
case DialogWindow::yesButton:
|
||||
if (savePlaylist()) {
|
||||
statusBar->set_text("");
|
||||
break;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
case DialogWindow::cancelButton:
|
||||
return;
|
||||
default : // can happen if window is closed
|
||||
return; // with Alt-F4 -- treated as cancel
|
||||
}
|
||||
}
|
||||
|
||||
hide();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
|||
* </code></pre>
|
||||
*
|
||||
* @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<DialogWindow>::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.
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue