From 658aafcb6263a23f5422743cebd086be24730606 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Sun, 6 Apr 2008 14:52:43 +0000 Subject: [PATCH] Add recent files to the Open File menu. Add dropped files to the roster's list of recent files. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24831 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/mediaplayer/Jamfile | 3 +++ src/apps/mediaplayer/MainApp.cpp | 3 ++- src/apps/mediaplayer/MainApp.h | 1 + src/apps/mediaplayer/MainWin.cpp | 23 ++++++++++++++++++++--- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/apps/mediaplayer/Jamfile b/src/apps/mediaplayer/Jamfile index c7139f1fd8..bbe7d7a343 100644 --- a/src/apps/mediaplayer/Jamfile +++ b/src/apps/mediaplayer/Jamfile @@ -4,6 +4,9 @@ SetSubDirSupportedPlatformsBeOSCompatible ; AddSubDirSupportedPlatforms libbe_test ; +# for BRecentItems +UsePublicHeaders [ FDirName be_apps Tracker ] ; + # source directories local sourceDirs = playlist diff --git a/src/apps/mediaplayer/MainApp.cpp b/src/apps/mediaplayer/MainApp.cpp index bc3e709fb7..3b59d2bbd9 100644 --- a/src/apps/mediaplayer/MainApp.cpp +++ b/src/apps/mediaplayer/MainApp.cpp @@ -32,13 +32,14 @@ MainApp *gMainApp; +const char* kAppSig = "application/x-vnd.Haiku-MediaPlayer"; static const char* kMediaServerSig = "application/x-vnd.Be.media-server"; static const char* kMediaServerAddOnSig = "application/x-vnd.Be.addon-host"; MainApp::MainApp() - : BApplication("application/x-vnd.Haiku-MediaPlayer"), + : BApplication(kAppSig), fPlayerCount(0), fFirstWindow(NewWindow()), diff --git a/src/apps/mediaplayer/MainApp.h b/src/apps/mediaplayer/MainApp.h index 566a51ffd9..30d49d61d7 100644 --- a/src/apps/mediaplayer/MainApp.h +++ b/src/apps/mediaplayer/MainApp.h @@ -56,5 +56,6 @@ private: }; extern MainApp* gMainApp; +extern const char* kAppSig; #endif diff --git a/src/apps/mediaplayer/MainWin.cpp b/src/apps/mediaplayer/MainWin.cpp index cc3b51a56c..3b8c1bb6d8 100644 --- a/src/apps/mediaplayer/MainWin.cpp +++ b/src/apps/mediaplayer/MainWin.cpp @@ -35,6 +35,8 @@ #include #include #include +#include +#include #include #include #include @@ -347,8 +349,14 @@ MainWin::MessageReceived(BMessage *msg) break; case B_SIMPLE_DATA: printf("MainWin::MessageReceived: B_SIMPLE_DATA\n"); - if (msg->HasRef("refs")) + if (msg->HasRef("refs")) { + // add to recent documents as it's not done with drag-n-drop + entry_ref ref; + for (int32 i = 0; msg->FindRef("refs", i, &ref) == B_OK; i++) { + be_roster->AddToRecentDocuments(&ref, kAppSig); + } _RefsReceived(msg); + } break; case M_MEDIA_SERVER_STARTED: @@ -833,8 +841,17 @@ MainWin::_CreateMenu() fFileMenu->AddItem(new BMenuItem("New Player"B_UTF8_ELLIPSIS, new BMessage(M_FILE_NEWPLAYER), 'N')); fFileMenu->AddSeparatorItem(); - fFileMenu->AddItem(new BMenuItem("Open File"B_UTF8_ELLIPSIS, - new BMessage(M_FILE_OPEN), 'O')); + +// fFileMenu->AddItem(new BMenuItem("Open File"B_UTF8_ELLIPSIS, +// new BMessage(M_FILE_OPEN), 'O')); + // Add recent files + BRecentFilesList recentFiles(10, false, NULL, kAppSig); + BMenuItem *item = new BMenuItem(recentFiles.NewFileListMenu( + "Open File"B_UTF8_ELLIPSIS, new BMessage(B_REFS_RECEIVED), + NULL, this, 10, false, NULL, 0, kAppSig), new BMessage(M_FILE_OPEN)); + item->SetShortcut('O', 0); + fFileMenu->AddItem(item); + fFileMenu->AddItem(new BMenuItem("File Info"B_UTF8_ELLIPSIS, new BMessage(M_FILE_INFO), 'I')); fFileMenu->AddItem(fPlaylistMenu);