* Added new Playlist notification ImportFailed().

The PlaylistListView will trigger it when the import command
   failed (happens for example when none of the files are
   media files).
 * Moved displaying the according alert from the import fommand
   into the MainWindow. Show the window if necessary. This fixes
   MediaPlayer just idling in the Deskbar without any window
   in this case, since the MainWindow is shown after the first
   call to _SetupWindow() since some time. But _SetupWindow() is
   not invoked when no file could be opened.
 * Removed some meanwhile useless debug output. 


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38757 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2010-09-21 14:47:21 +00:00
parent fdc0a66ed6
commit ebd866299d
10 changed files with 63 additions and 17 deletions
+3
View File
@@ -77,6 +77,9 @@ ControllerView::MessageReceived(BMessage* message)
_CheckSkippable();
break;
case MSG_PLAYLIST_IMPORT_FAILED:
break;
default:
TransportControlGroup::MessageReceived(message);
}
+1 -4
View File
@@ -247,7 +247,6 @@ MainApp::ArgvReceived(int32 argc, char** argv)
BMessage message(B_REFS_RECEIVED);
for (int i = 1; i < argc; i++) {
printf("MainApp::ArgvReceived %s\n", argv[i]);
BPath path;
if (argv[i][0] != '/')
path.SetTo(cwd, argv[i]);
@@ -262,10 +261,8 @@ MainApp::ArgvReceived(int32 argc, char** argv)
message.AddRef("refs", &ref);
}
if (message.HasRef("refs")) {
printf("MainApp::ArgvReceived calling RefsReceived\n");
if (message.HasRef("refs"))
RefsReceived(&message);
}
}
+9 -2
View File
@@ -533,11 +533,9 @@ MainWin::MessageReceived(BMessage* msg)
}
case B_REFS_RECEIVED:
printf("MainWin::MessageReceived: B_REFS_RECEIVED\n");
_RefsReceived(msg);
break;
case B_SIMPLE_DATA:
printf("MainWin::MessageReceived: B_SIMPLE_DATA\n");
if (msg->HasRef("refs"))
_RefsReceived(msg);
break;
@@ -604,6 +602,15 @@ MainWin::MessageReceived(BMessage* msg)
}
break;
}
case MSG_PLAYLIST_IMPORT_FAILED:
{
BAlert* alert = new BAlert("Nothing to Play", "None of the files "
"you wanted to play appear to be media files.", "OK");
alert->Go();
_ShowIfNeeded();
break;
}
// ControllerObserver messages
case MSG_CONTROLLER_FILE_FINISHED:
+1 -1
View File
@@ -8,7 +8,7 @@ resource app_version {
variety = B_APPV_BETA,
internal = 0,
short_info = "MediaPlayer",
long_info = "MediaPlayer ©2006-2009 Haiku, Inc."
long_info = "MediaPlayer ©2006-2010 Haiku, Inc."
};
resource app_flags B_SINGLE_LAUNCH;
@@ -9,7 +9,6 @@
#include <new>
#include <stdio.h>
#include <Alert.h>
#include <Autolock.h>
#include "Playlist.h"
@@ -43,12 +42,8 @@ ImportPLItemsCommand::ImportPLItemsCommand(Playlist* playlist,
temp.AppendRefs(refsMessage);
fNewCount = temp.CountItems();
if (fNewCount <= 0) {
BAlert* alert = new BAlert("Nothing to Play", "None of the files "
"you wanted to play appear to be media files.", "OK");
alert->Go(NULL);
if (fNewCount <= 0)
return;
}
fNewItems = new (nothrow) PlaylistItem*[fNewCount];
if (!fNewItems)
@@ -53,6 +53,7 @@ void Playlist::Listener::ItemAdded(PlaylistItem* item, int32 index) {}
void Playlist::Listener::ItemRemoved(int32 index) {}
void Playlist::Listener::ItemsSorted() {}
void Playlist::Listener::CurrentItemChanged(int32 newIndex) {}
void Playlist::Listener::ImportFailed() {}
// #pragma mark -
@@ -537,6 +538,14 @@ Playlist::AppendPlaylistToPlaylist(const entry_ref& ref, Playlist* playlist)
}
void
Playlist::NotifyImportFailed()
{
BAutolock _(this);
_NotifyImportFailed();
}
// #pragma mark - private
@@ -664,3 +673,14 @@ Playlist::_NotifyCurrentItemChanged(int32 newIndex) const
}
}
void
Playlist::_NotifyImportFailed() const
{
BList listeners(fListeners);
int32 count = listeners.CountItems();
for (int32 i = 0; i < count; i++) {
Listener* listener = (Listener*)listeners.ItemAtFast(i);
listener->ImportFailed();
}
}
+5
View File
@@ -55,6 +55,8 @@ public:
virtual void ItemsSorted();
virtual void CurrentItemChanged(int32 newIndex);
virtual void ImportFailed();
};
public:
@@ -106,6 +108,8 @@ public:
static void AppendPlaylistToPlaylist(const entry_ref& ref,
Playlist* playlist);
void NotifyImportFailed();
private:
Playlist(const Playlist& other);
Playlist& operator=(const Playlist& other);
@@ -122,6 +126,7 @@ private:
void _NotifyItemRemoved(int32 index) const;
void _NotifyItemsSorted() const;
void _NotifyCurrentItemChanged(int32 newIndex) const;
void _NotifyImportFailed() const;
private:
BList fItems;
@@ -320,6 +320,8 @@ PlaylistListView::MessageReceived(BMessage* message)
_SetCurrentPlaylistIndex(index);
break;
}
case MSG_PLAYLIST_IMPORT_FAILED:
break;
// ControllerObserver messages
case MSG_CONTROLLER_PLAYBACK_STATE_CHANGED:
@@ -442,8 +444,10 @@ PlaylistListView::DrawListItem(BView* owner, int32 index, BRect frame) const
void
PlaylistListView::RefsReceived(BMessage* message, int32 appendIndex)
{
fCommandStack->Perform(new (nothrow) ImportPLItemsCommand(fPlaylist,
message, appendIndex));
if (fCommandStack->Perform(new (nothrow) ImportPLItemsCommand(fPlaylist,
message, appendIndex)) != B_OK) {
fPlaylist->NotifyImportFailed();
}
}
@@ -1,10 +1,12 @@
/*
* Copyright 2007-2009 Stephan Aßmus <superstippi@gmx.de>.
* Copyright 2007-2010 Stephan Aßmus <superstippi@gmx.de>.
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include "PlaylistObserver.h"
#include <stdio.h>
#include <Message.h>
@@ -59,3 +61,13 @@ PlaylistObserver::CurrentItemChanged(int32 newIndex)
DeliverMessage(message);
}
void
PlaylistObserver::ImportFailed()
{
BMessage message(MSG_PLAYLIST_IMPORT_FAILED);
DeliverMessage(message);
}
@@ -12,7 +12,8 @@ enum {
MSG_PLAYLIST_ITEM_ADDED = 'plia',
MSG_PLAYLIST_ITEM_REMOVED = 'plir',
MSG_PLAYLIST_ITEMS_SORTED = 'plis',
MSG_PLAYLIST_CURRENT_ITEM_CHANGED = 'plcc'
MSG_PLAYLIST_CURRENT_ITEM_CHANGED = 'plcc',
MSG_PLAYLIST_IMPORT_FAILED = 'plif'
};
class PlaylistObserver : public Playlist::Listener, public AbstractLOAdapter {
@@ -26,6 +27,8 @@ public:
virtual void ItemsSorted();
virtual void CurrentItemChanged(int32 newIndex);
virtual void ImportFailed();
};
#endif // PLAYLIST_OBSERVER_H