* Cleanup, no functional change.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36219 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2010-04-13 14:23:10 +00:00
parent ef9dbf80c1
commit 72d2b96592
@@ -1,5 +1,5 @@
/* /*
* Copyright 2007-2009, Haiku. All rights reserved. * Copyright 2007-2010, Haiku. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -7,6 +7,7 @@
* Fredrik Modéen <[email protected]> * Fredrik Modéen <[email protected]>
*/ */
#include "PlaylistWindow.h" #include "PlaylistWindow.h"
#include <stdio.h> #include <stdio.h>
@@ -34,6 +35,7 @@
#include "PlaylistListView.h" #include "PlaylistListView.h"
#include "RWLocker.h" #include "RWLocker.h"
// TODO: // TODO:
// Maintaining a playlist file on disk is a bit tricky. The playlist ref should // Maintaining a playlist file on disk is a bit tricky. The playlist ref should
// be discarded when the user // be discarded when the user
@@ -58,16 +60,37 @@ enum {
M_PLAYLIST_REMOVE = 'rmov' M_PLAYLIST_REMOVE = 'rmov'
}; };
#define SPACE 5
static void
display_save_alert(const char* message)
{
BAlert* alert = new BAlert("Save error", message, "OK", NULL, NULL,
B_WIDTH_AS_USUAL, B_STOP_ALERT);
alert->Go(NULL);
}
static void
display_save_alert(status_t error)
{
BString errorMessage("Saving the playlist failed.\n\nError: ");
errorMessage << strerror(error);
display_save_alert(errorMessage.String());
}
// #pragma mark -
PlaylistWindow::PlaylistWindow(BRect frame, Playlist* playlist, PlaylistWindow::PlaylistWindow(BRect frame, Playlist* playlist,
Controller* controller) Controller* controller)
: BWindow(frame, "Playlist", B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, :
BWindow(frame, "Playlist", B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
B_ASYNCHRONOUS_CONTROLS), B_ASYNCHRONOUS_CONTROLS),
fPlaylist(playlist), fPlaylist(playlist),
fLocker(new RWLocker("command stack lock")), fLocker(new RWLocker("command stack lock")),
fCommandStack(new CommandStack(fLocker)), fCommandStack(new CommandStack(fLocker)),
fCommandStackListener(this) fCommandStackListener(this)
{ {
frame = Bounds(); frame = Bounds();
@@ -142,8 +165,13 @@ PlaylistWindow::MessageReceived(BMessage* message)
case B_REFS_RECEIVED: case B_REFS_RECEIVED:
// Used for when we open a playlist from playlist window // Used for when we open a playlist from playlist window
message->AddInt32("append_index", APPEND_INDEX_REPLACE_PLAYLIST); if (!message->HasInt32("append_index")) {
case B_SIMPLE_DATA: { message->AddInt32("append_index",
APPEND_INDEX_REPLACE_PLAYLIST);
}
// supposed to fall through
case B_SIMPLE_DATA:
{
// only accept this message when it comes from the // only accept this message when it comes from the
// player window, _not_ when it is dropped in this window // player window, _not_ when it is dropped in this window
// outside of the playlist! // outside of the playlist!
@@ -154,7 +182,8 @@ PlaylistWindow::MessageReceived(BMessage* message)
break; break;
} }
case M_PLAYLIST_OPEN: { case M_PLAYLIST_OPEN:
{
BMessenger target(this); BMessenger target(this);
BMessage result(B_REFS_RECEIVED); BMessage result(B_REFS_RECEIVED);
BMessage appMessage(M_SHOW_OPEN_PANEL); BMessage appMessage(M_SHOW_OPEN_PANEL);
@@ -165,15 +194,15 @@ PlaylistWindow::MessageReceived(BMessage* message)
be_app->PostMessage(&appMessage); be_app->PostMessage(&appMessage);
break; break;
} }
case M_PLAYLIST_SAVE: {
case M_PLAYLIST_SAVE:
if (fSavedPlaylistRef != entry_ref()) { if (fSavedPlaylistRef != entry_ref()) {
_SavePlaylist(fSavedPlaylistRef); _SavePlaylist(fSavedPlaylistRef);
break; break;
} else {
// FALL THROUGH
} }
} // supposed to fall through
case M_PLAYLIST_SAVE_AS: { case M_PLAYLIST_SAVE_AS:
{
BMessenger target(this); BMessenger target(this);
BMessage result(M_PLAYLIST_SAVE_RESULT); BMessage result(M_PLAYLIST_SAVE_RESULT);
BMessage appMessage(M_SHOW_SAVE_PANEL); BMessage appMessage(M_SHOW_SAVE_PANEL);
@@ -184,10 +213,10 @@ PlaylistWindow::MessageReceived(BMessage* message)
be_app->PostMessage(&appMessage); be_app->PostMessage(&appMessage);
break; break;
} }
case M_PLAYLIST_SAVE_RESULT: {
case M_PLAYLIST_SAVE_RESULT:
_SavePlaylist(message); _SavePlaylist(message);
break; break;
}
case M_PLAYLIST_EMPTY: case M_PLAYLIST_EMPTY:
fListView->RemoveAll(); fListView->RemoveAll();
@@ -200,8 +229,6 @@ PlaylistWindow::MessageReceived(BMessage* message)
break; break;
case M_PLAYLIST_REMOVE_AND_PUT_INTO_TRASH: case M_PLAYLIST_REMOVE_AND_PUT_INTO_TRASH:
{ {
printf("M_PLAYLIST_REMOVE_AND_PUT_INTO_TRASH\n");
message->PrintToStream();
int32 index; int32 index;
if (message->FindInt32("playlist index", &index) == B_OK) if (message->FindInt32("playlist index", &index) == B_OK)
fListView->RemoveToTrash(index); fListView->RemoveToTrash(index);
@@ -289,24 +316,6 @@ PlaylistWindow::_ObjectChanged(const Notifier* object)
} }
static void
display_save_alert(const char* message)
{
BAlert* alert = new BAlert("Save error", message, "OK", NULL, NULL,
B_WIDTH_AS_USUAL, B_STOP_ALERT);
alert->Go(NULL);
}
static void
display_save_alert(status_t error)
{
BString errorMessage("Saving the playlist failed.\n\nError: ");
errorMessage << strerror(error);
display_save_alert(errorMessage.String());
}
void void
PlaylistWindow::_SavePlaylist(const BMessage* message) PlaylistWindow::_SavePlaylist(const BMessage* message)
{ {