From 36272f0d4c9b16e96dc8c89552f8f155dbaa9cc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 3 Nov 2010 21:04:51 +0000 Subject: [PATCH] * Removed the home-brewn recent menu, and just uses the one libtracker.so provides instead. * This also fixes bug #6774. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39285 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/showimage/ShowImageWindow.cpp | 69 ++++---------------------- src/apps/showimage/ShowImageWindow.h | 3 -- 2 files changed, 10 insertions(+), 62 deletions(-) diff --git a/src/apps/showimage/ShowImageWindow.cpp b/src/apps/showimage/ShowImageWindow.cpp index a65bfbe7b2..544bc44a6d 100644 --- a/src/apps/showimage/ShowImageWindow.cpp +++ b/src/apps/showimage/ShowImageWindow.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -55,58 +56,6 @@ const char* kTypeField = "be:type"; const char* kTranslatorField = "be:translator"; -// #pragma mark -- ShowImageWindow::RecentDocumentsMenu - - -class ShowImageWindow::RecentDocumentsMenu : public BMenu { -public: - RecentDocumentsMenu(const char* title, - menu_layout layout = B_ITEMS_IN_COLUMN); - bool AddDynamicItem(add_state addState); -}; - - -ShowImageWindow::RecentDocumentsMenu::RecentDocumentsMenu(const char* title, - menu_layout layout) - : - BMenu(title, layout) -{ -} - - -bool -ShowImageWindow::RecentDocumentsMenu::AddDynamicItem(add_state addState) -{ - if (addState != B_INITIAL_ADD) - return false; - - while (CountItems() > 0) - delete RemoveItem(0L); - - BMenuItem* item; - BMessage list, *msg; - entry_ref ref; - char name[B_FILE_NAME_LENGTH]; - - be_roster->GetRecentDocuments(&list, 20, NULL, kApplicationSignature); - for (int i = 0; list.FindRef("refs", i, &ref) == B_OK; i++) { - BEntry entry(&ref); - if (entry.Exists() && entry.GetName(name) == B_OK) { - msg = new BMessage(B_REFS_RECEIVED); - msg->AddRef("refs", &ref); - item = new EntryMenuItem(&ref, name, msg, 0, 0); - AddItem(item); - item->SetTarget(be_app, NULL); - } - } - - return false; -} - - -// #pragma mark - - // This is temporary solution for building BString with printf like format. // will be removed in the future. static void @@ -133,7 +82,6 @@ ShowImageWindow::ShowImageWindow(const entry_ref* ref, fNavigator(this), fSavePanel(NULL), fBar(NULL), - fOpenMenu(NULL), fBrowseMenu(NULL), fGoToPageMenu(NULL), fSlideShowDelay(NULL), @@ -317,13 +265,16 @@ void ShowImageWindow::AddMenus(BMenuBar* bar) { BMenu* menu = new BMenu(B_TRANSLATE("File")); - fOpenMenu = new RecentDocumentsMenu(B_TRANSLATE("Open")); - menu->AddItem(fOpenMenu); - fOpenMenu->Superitem()->SetTrigger('O'); - fOpenMenu->Superitem()->SetMessage(new BMessage(MSG_FILE_OPEN)); - fOpenMenu->Superitem()->SetTarget(be_app); - fOpenMenu->Superitem()->SetShortcut('O', 0); + + // Add recent files to "Open File" entry as sub-menu. + BMenuItem* item = new BMenuItem(BRecentFilesList::NewFileListMenu( + B_TRANSLATE("Open"B_UTF8_ELLIPSIS), NULL, NULL, be_app, 10, true, + NULL, kApplicationSignature), new BMessage(MSG_FILE_OPEN)); + item->SetShortcut('O', 0); + item->SetTarget(be_app); + menu->AddItem(item); menu->AddSeparatorItem(); + BMenu* menuSaveAs = new BMenu(B_TRANSLATE("Save as" B_UTF8_ELLIPSIS), B_ITEMS_IN_COLUMN); BTranslationUtils::AddTranslationItems(menuSaveAs, B_TRANSLATOR_BITMAP); diff --git a/src/apps/showimage/ShowImageWindow.h b/src/apps/showimage/ShowImageWindow.h index 0bb632c5a8..59641821df 100644 --- a/src/apps/showimage/ShowImageWindow.h +++ b/src/apps/showimage/ShowImageWindow.h @@ -43,8 +43,6 @@ public: void WindowRedimension(BBitmap* bitmap); private: - class RecentDocumentsMenu; - void _BuildViewMenu(BMenu* menu, bool popupMenu); BMenuItem* _AddItemMenu(BMenu* menu, const char* label, uint32 what, char shortcut, uint32 modifier, @@ -79,7 +77,6 @@ private: ImageFileNavigator fNavigator; BFilePanel* fSavePanel; BMenuBar* fBar; - BMenu* fOpenMenu; BMenu* fBrowseMenu; BMenu* fGoToPageMenu; BMenu* fSlideShowDelay;