From c6d2f9af2ca4b7b1ba866080c8caa7fa29a8e458 Mon Sep 17 00:00:00 2001 From: Philippe Saint-Pierre Date: Sat, 5 Mar 2011 22:13:12 +0000 Subject: [PATCH] Screenshot * Consider the message that the FilePanel returns and add the path to the output destination MenuField. Ticket #6886 git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40826 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/screenshot/ScreenshotWindow.cpp | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/apps/screenshot/ScreenshotWindow.cpp b/src/apps/screenshot/ScreenshotWindow.cpp index 22ece00ab9..660d3896c0 100644 --- a/src/apps/screenshot/ScreenshotWindow.cpp +++ b/src/apps/screenshot/ScreenshotWindow.cpp @@ -327,6 +327,19 @@ ScreenshotWindow::MessageReceived(BMessage* message) break; } + case B_REFS_RECEIVED: + { + entry_ref ref; + if (message->FindRef("refs", &ref) == B_OK) { + BEntry entry(&ref, true); + BPath path; + entry.GetPath(&path); + BString label(path.Path()); + _AddItemToPathMenu(path.Path(), label, 3, true); + } + break; + } + case B_CANCEL: fLastSelectedPath->SetMarked(true); break; @@ -501,6 +514,24 @@ void ScreenshotWindow::_AddItemToPathMenu(const char* path, BString& label, int32 index, bool markItem) { + /* Make sure that item won't be a duplicata of an existing one */ + for (int32 i = fOutputPathMenu->CountItems(); i > 0; --i) { + BMenuItem* menuItem = fOutputPathMenu->ItemAt(i - 1); + BMessage* message = menuItem->Message(); + const char* pathFromItem; + if (message != NULL && message->what == kLocationChanged) { + if (message->FindString("path", &pathFromItem) == B_OK) { + if (!strcmp(path, pathFromItem)) { + if (markItem) { + fOutputPathMenu->ItemAt(i - 1)->SetMarked(true); + fLastSelectedPath = fOutputPathMenu->ItemAt(i - 1); + } + return; + } + } + } + } + BMessage* message = new BMessage(kLocationChanged); message->AddString("path", path);