[haiku-webkit-commits] r342 - in webkit/trunk/WebKit/haiku: API WebPositive

  • From: webkit@xxxxxxxxxxxxxxx
  • To: haiku-webkit-commits@xxxxxxxxxxxxx
  • Date: Tue, 23 Mar 2010 13:06:34 +0000

Author: stippi
Date: Tue Mar 23 13:06:33 2010
New Revision: 342
URL: http://mmlr.dyndns.org/changeset/342

Log:
* Finished testing of downloads interaction with listener and removed debug
   output.
 * Optimized download restoration at program start and moved it into download
   window thread in order not to block app startup.
 * Downloads which have been removed meanwhile, are displayed with dimmed icon,
   and the option to Restart it is given.

Modified:
   webkit/trunk/WebKit/haiku/API/WebDownloadPrivate.cpp
   webkit/trunk/WebKit/haiku/WebPositive/DownloadWindow.cpp

Modified: webkit/trunk/WebKit/haiku/API/WebDownloadPrivate.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/API/WebDownloadPrivate.cpp        Tue Mar 23 
00:02:05 2010        (r341)
+++ webkit/trunk/WebKit/haiku/API/WebDownloadPrivate.cpp        Tue Mar 23 
13:06:33 2010        (r342)
@@ -55,7 +55,6 @@
     , m_file()
     , m_lastProgressReportTime(0)
 {
-printf("%p->WebDownloadPrivate(const ResourceRequest& request)\n", this);
 }
 
 WebDownloadPrivate::WebDownloadPrivate(ResourceHandle* handle,
@@ -71,7 +70,6 @@
     , m_file()
     , m_lastProgressReportTime(0)
 {
-printf("%p->WebDownloadPrivate(ResourceHandle* handle)\n", this);
        m_resourceHandle->setClient(this);
        // Call the hook manually to figure out the details of the request
        didReceiveResponse(handle, response);
@@ -79,7 +77,6 @@
 
 void WebDownloadPrivate::didReceiveResponse(ResourceHandle*, const 
ResourceResponse& response)
 {
-printf("%p->WebDownloadPrivate::didReceiveResponse()\n", this);
     if (!response.isNull()) {
        if (!response.suggestedFilename().isEmpty())
             m_filename = response.suggestedFilename();
@@ -146,7 +143,6 @@
 
 void WebDownloadPrivate::start(const BPath& path)
 {
-printf("%p->Start(%s)\n", m_webDownload, path.Path());
        if (path.InitCheck() == B_OK)
                m_path = path;
 }
@@ -158,7 +154,6 @@
 
 void WebDownloadPrivate::setProgressListener(const BMessenger& listener)
 {
-printf("%p->setProgressListener()\n", this);
        m_progressListener = listener;
 }
 
@@ -179,7 +174,6 @@
 
 void WebDownloadPrivate::createFile()
 {
-printf("%p->createFile()\n", this);
     m_path.Append(m_filename.String());
        if (m_file.SetTo(m_path.Path(), B_CREATE_FILE | B_ERASE_FILE | 
B_WRITE_ONLY) == B_OK) {
                BNodeInfo info(&m_file);
@@ -188,7 +182,6 @@
        }
 
     if (m_progressListener.IsValid()) {
-printf("  sending notification\n");
         BMessage message(B_DOWNLOAD_STARTED);
         message.AddString("path", m_path.Path());
         m_progressListener.SendMessage(&message);

Modified: webkit/trunk/WebKit/haiku/WebPositive/DownloadWindow.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/WebPositive/DownloadWindow.cpp    Tue Mar 23 
00:02:05 2010        (r341)
+++ webkit/trunk/WebKit/haiku/WebPositive/DownloadWindow.cpp    Tue Mar 23 
13:06:33 2010        (r342)
@@ -54,6 +54,8 @@
 
 
 enum {
+       INIT = 'init',
+       OPEN_DOWNLOADS_FOLDER = 'odnf',
        REMOVE_FINISHED_DOWNLOADS = 'rmfd',
        OPEN_DOWNLOAD = 'opdn',
        RESTART_DOWNLOAD = 'rsdn',
@@ -65,10 +67,21 @@
 
 class IconView : public BView {
 public:
+       IconView(const BEntry& entry)
+               :
+               BView("Download icon", B_WILL_DRAW),
+               fIconBitmap(BRect(0, 0, 31, 31), 0, B_RGBA32),
+               fDimmedIcon(false)
+       {
+               SetDrawingMode(B_OP_OVER);
+               SetTo(entry);
+       }
+
        IconView()
                :
                BView("Download icon", B_WILL_DRAW),
-               fIconBitmap(BRect(0, 0, 31, 31), 0, B_RGBA32)
+               fIconBitmap(BRect(0, 0, 31, 31), 0, B_RGBA32),
+               fDimmedIcon(false)
        {
                SetDrawingMode(B_OP_OVER);
                memset(fIconBitmap.Bits(), 0, fIconBitmap.BitsLength());
@@ -77,7 +90,8 @@
        IconView(BMessage* archive)
                :
                BView("Download icon", B_WILL_DRAW),
-               fIconBitmap(archive)
+               fIconBitmap(archive),
+               fDimmedIcon(true)
        {
                SetDrawingMode(B_OP_OVER);
        }
@@ -90,6 +104,14 @@
                Invalidate();
        }
 
+       void SetIconDimmed(bool iconDimmed)
+       {
+               if (fDimmedIcon != iconDimmed) {
+                       fDimmedIcon = iconDimmed;
+                       Invalidate();
+               }
+       }
+
        status_t SaveSettings(BMessage* archive)
        {
                return fIconBitmap.Archive(archive);
@@ -102,6 +124,11 @@
 
        virtual void Draw(BRect updateRect)
        {
+               if (fDimmedIcon) {
+                       SetDrawingMode(B_OP_ALPHA);
+                       SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY);
+                       SetHighColor(0, 0, 0, 100);
+               }
                DrawBitmapAsync(&fIconBitmap);
        }
 
@@ -121,7 +148,8 @@
        }
 
 private:
-       BBitmap fIconBitmap;
+       BBitmap fIconBitmap;
+       bool    fDimmedIcon;
 };
 
 
@@ -183,12 +211,18 @@
                fStatusBar->SetMaxValue(100);
                fStatusBar->SetBarHeight(12);
 
-               if (archive)
-                       fIconView = new IconView(archive);
-               else
+               // fPath is only valid when constructed from archive (fDownload 
== NULL)
+               BEntry entry(fPath.Path());
+
+               if (archive) {
+                       if (!entry.Exists())
+                               fIconView = new IconView(archive);
+                       else
+                               fIconView = new IconView(entry);
+               } else
                        fIconView = new IconView();
 
-               if (!fDownload && fStatusBar->CurrentValue() < 100)
+               if (!fDownload && (fStatusBar->CurrentValue() < 100 || 
!entry.Exists()))
                        fTopButton = new SmallButton("Restart", new 
BMessage(RESTART_DOWNLOAD));
                else {
                        fTopButton = new SmallButton("Open", new 
BMessage(OPEN_DOWNLOAD));
@@ -258,7 +292,6 @@
                                fPath.SetTo(path);
                                BEntry entry(fPath.Path());
                                fIconView->SetTo(entry);
-printf("B_DOWNLOAD_STARTED: %s\n", fPath.Leaf());
                                fStatusBar->Reset(fPath.Leaf());
                                break;
                        };
@@ -428,7 +461,9 @@
        fDownloadViewsLayout = downloadsGroupView->GroupLayout();
 
        BMenuBar* menuBar = new BMenuBar("Menu bar");
-       BMenu* menu = new BMenu("Window");
+       BMenu* menu = new BMenu("Downloads");
+       menu->AddItem(new BMenuItem("Open downloads folder",
+               new BMessage(OPEN_DOWNLOADS_FOLDER)));
        menu->AddItem(new BMenuItem("Hide", new BMessage(B_QUIT_REQUESTED), 
'H'));
        menuBar->AddItem(menu);
 
@@ -450,9 +485,7 @@
                )
        );
 
-       _LoadSettings();
-       // Small trick to get the correct enabled status of the Remove finished 
button
-       _DownloadFinished(NULL);
+       PostMessage(INIT);
 
        if (!visible)
                Hide();
@@ -471,6 +504,14 @@
 DownloadWindow::MessageReceived(BMessage* message)
 {
        switch (message->what) {
+               case INIT:
+               {
+                       _LoadSettings();
+                       // Small trick to get the correct enabled status of the 
Remove
+                       // finished button
+                       _DownloadFinished(NULL);
+                       break;
+               }
                case B_DOWNLOAD_ADDED:
                {
                        BWebDownload* download;
@@ -489,6 +530,22 @@
                        }
                        break;
                }
+               case OPEN_DOWNLOADS_FOLDER:
+               {
+                       entry_ref ref;
+                       status_t status = 
get_ref_for_path(fDownloadPath.String(), &ref);
+                       if (status == B_OK)
+                               status = be_roster->Launch(&ref);
+                       if (status != B_OK && status != B_ALREADY_RUNNING) {
+                               BString errorString("The downloads folder could 
not be "
+                                       "opened.\n\n");
+                               errorString << "Error: " << strerror(status);
+                               BAlert* alert = new BAlert("Error opening 
downloads folder",
+                                       errorString.String(), "OK");
+                               alert->Go(NULL);
+                       }
+                       break;
+               }
                case REMOVE_FINISHED_DOWNLOADS:
                        _RemoveFinishedDownloads();
                        break;

Other related posts:

  • » [haiku-webkit-commits] r342 - in webkit/trunk/WebKit/haiku: API WebPositive - webkit