made the Save button insensitive when the playlist has not been changed yet

(sort of related to #1713)
This commit is contained in:
fgerlits 2006-08-01 16:21:37 +00:00
parent 1c1455085c
commit 01fea54c45
2 changed files with 32 additions and 13 deletions

View File

@ -223,6 +223,7 @@ SimplePlaylistManagementWindow :: SimplePlaylistManagementWindow (
set_default_size(480, 350); set_default_size(480, 350);
set_modal(false); set_modal(false);
property_window_position().set_value(Gtk::WIN_POS_NONE); property_window_position().set_value(Gtk::WIN_POS_NONE);
saveButton->set_sensitive(false);
show_all_children(); show_all_children();
@ -281,7 +282,7 @@ SimplePlaylistManagementWindow :: savePlaylist(bool reopen) throw ()
if (reopen) { if (reopen) {
gLiveSupport->openPlaylistForEditing(playlist->getId()); gLiveSupport->openPlaylistForEditing(playlist->getId());
} }
isPlaylistModified = false; setPlaylistModified(false);
Ptr<Glib::ustring>::Ref statusText = formatMessage( Ptr<Glib::ustring>::Ref statusText = formatMessage(
"playlistSavedMsg", "playlistSavedMsg",
@ -325,7 +326,7 @@ SimplePlaylistManagementWindow :: cancelPlaylist(void) throw ()
std::cerr << e.what() << std::endl; std::cerr << e.what() << std::endl;
return false; return false;
} }
isPlaylistModified = false; setPlaylistModified(false);
break; break;
case DialogWindow::yesButton: case DialogWindow::yesButton:
@ -356,7 +357,7 @@ SimplePlaylistManagementWindow :: closeWindow(void) throw ()
statusBar->set_text(""); statusBar->set_text("");
nameEntry->set_text(""); nameEntry->set_text("");
entriesModel->clear(); entriesModel->clear();
isPlaylistModified = false; setPlaylistModified(false);
gLiveSupport->putWindowPosition(shared_from_this()); gLiveSupport->putWindowPosition(shared_from_this());
hide(); hide();
} }
@ -459,7 +460,7 @@ SimplePlaylistManagementWindow :: onTitleEdited(void) throw()
nameEntry->get_text())); nameEntry->get_text()));
if (*title != *playlist->getTitle()) { if (*title != *playlist->getTitle()) {
playlist->setTitle(title); playlist->setTitle(title);
isPlaylistModified = true; setPlaylistModified(true);
} }
showContents(); showContents();
@ -543,7 +544,7 @@ SimplePlaylistManagementWindow :: setFadeIn(
newFadeIn, oldFadeOut )); newFadeIn, oldFadeOut ));
if (isLengthOkay(playlistElement, newFadeInfo)) { if (isLengthOkay(playlistElement, newFadeInfo)) {
playlistElement->setFadeInfo(newFadeInfo); playlistElement->setFadeInfo(newFadeInfo);
isPlaylistModified = true; setPlaylistModified(true);
} }
} }
@ -571,7 +572,7 @@ SimplePlaylistManagementWindow :: setFadeOut(
oldFadeIn, newFadeOut )); oldFadeIn, newFadeOut ));
if (isLengthOkay(playlistElement, newFadeInfo)) { if (isLengthOkay(playlistElement, newFadeInfo)) {
playlistElement->setFadeInfo(newFadeInfo); playlistElement->setFadeInfo(newFadeInfo);
isPlaylistModified = true; setPlaylistModified(true);
} }
} }
@ -597,7 +598,7 @@ SimplePlaylistManagementWindow :: isLengthOkay(
void void
SimplePlaylistManagementWindow :: onPlaylistModified(void) throw() SimplePlaylistManagementWindow :: onPlaylistModified(void) throw()
{ {
isPlaylistModified = true; setPlaylistModified(true);
} }
@ -640,7 +641,7 @@ SimplePlaylistManagementWindow :: onUpItem(void) throw()
Gtk::TreeIter previousItem = currentItem; Gtk::TreeIter previousItem = currentItem;
--previousItem; --previousItem;
swapPlaylistElements(previousItem, currentItem); swapPlaylistElements(previousItem, currentItem);
isPlaylistModified = true; setPlaylistModified(true);
showContents(); showContents();
selectRow(--rowNumber); selectRow(--rowNumber);
} }
@ -660,7 +661,7 @@ SimplePlaylistManagementWindow :: onDownItem(void) throw()
int rowNumber = (*currentItem) int rowNumber = (*currentItem)
[modelColumns.rowNumberColumn]; [modelColumns.rowNumberColumn];
swapPlaylistElements(currentItem, nextItem); swapPlaylistElements(currentItem, nextItem);
isPlaylistModified = true; setPlaylistModified(true);
showContents(); showContents();
selectRow(++rowNumber); selectRow(++rowNumber);
} }
@ -762,7 +763,7 @@ SimplePlaylistManagementWindow :: onRemoveItem(void) throw()
playlist->removePlaylistElement(playlistElement->getId()); playlist->removePlaylistElement(playlistElement->getId());
playlist->eliminateGaps(); playlist->eliminateGaps();
isPlaylistModified = true; setPlaylistModified(true);
showContents(); showContents();
} }
} }
@ -833,3 +834,15 @@ SimplePlaylistManagementWindow :: selectRow(int rowNumber) throw ()
} }
} }
/*------------------------------------------------------------------------------
* Set the value of the isPlaylistModified variable.
*----------------------------------------------------------------------------*/
void
SimplePlaylistManagementWindow :: setPlaylistModified(bool newValue)
throw ()
{
isPlaylistModified = newValue;
saveButton->set_sensitive(newValue);
}

View File

@ -234,7 +234,7 @@ class SimplePlaylistManagementWindow : public GuiWindow
* Signal handler for the "remove" menu item selected from * Signal handler for the "remove" menu item selected from
* the right-click context menu. * the right-click context menu.
*/ */
virtual void void
onRemoveItem(void) throw (); onRemoveItem(void) throw ();
/** /**
@ -274,9 +274,15 @@ class SimplePlaylistManagementWindow : public GuiWindow
* editing again after saving it. * editing again after saving it.
* @return true if the playlist was saved successully. * @return true if the playlist was saved successully.
*/ */
virtual bool bool
savePlaylist(bool reopen) throw (); savePlaylist(bool reopen) throw ();
/**
* Set the value of the isPlaylistModified variable.
*/
void
setPlaylistModified(bool newValue) throw ();
protected: protected:
@ -432,7 +438,7 @@ class SimplePlaylistManagementWindow : public GuiWindow
* @see GLiveSupport::cancelEditedPlaylist() * @see GLiveSupport::cancelEditedPlaylist()
* @see closeWindow() * @see closeWindow()
*/ */
bool virtual bool
cancelPlaylist(void) throw(); cancelPlaylist(void) throw();
}; };