[haiku-commits] r40826 - haiku/trunk/src/apps/screenshot

  • From: stpere@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 5 Mar 2011 23:13:13 +0100 (CET)

Author: stpere
Date: 2011-03-05 23:13:12 +0100 (Sat, 05 Mar 2011)
New Revision: 40826
Changeset: http://dev.haiku-os.org/changeset/40826
Ticket: http://dev.haiku-os.org/ticket/6886

Modified:
   haiku/trunk/src/apps/screenshot/ScreenshotWindow.cpp
Log:
Screenshot

 * Consider the message that the FilePanel returns and add the path to the 
output destination MenuField.

Ticket #6886


Modified: haiku/trunk/src/apps/screenshot/ScreenshotWindow.cpp
===================================================================
--- haiku/trunk/src/apps/screenshot/ScreenshotWindow.cpp        2011-03-05 
21:08:28 UTC (rev 40825)
+++ haiku/trunk/src/apps/screenshot/ScreenshotWindow.cpp        2011-03-05 
22:13:12 UTC (rev 40826)
@@ -327,6 +327,19 @@
                        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 @@
 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);
 


Other related posts: