Converted to Haiku coding style.

git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@337 94f232f2-1747-11df-bad5-a5bfde151594
This commit is contained in:
stippi
2012-07-03 15:38:18 +02:00
committed by Alexandre Deckner
parent aa5ba348ea
commit 9ccfda9c50
2 changed files with 435 additions and 388 deletions
+190 -144
View File
@@ -25,12 +25,10 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "config.h"
#include "DownloadWindow.h" #include "DownloadWindow.h"
#include "BrowserApp.h" #include <stdio.h>
#include "WebDownload.h"
#include "WebPage.h"
#include <Alert.h> #include <Alert.h>
#include <Bitmap.h> #include <Bitmap.h>
#include <Button.h> #include <Button.h>
@@ -48,7 +46,11 @@
#include <SeparatorView.h> #include <SeparatorView.h>
#include <SpaceLayoutItem.h> #include <SpaceLayoutItem.h>
#include <StatusBar.h> #include <StatusBar.h>
#include <stdio.h>
#include "BrowserApp.h"
#include "WebDownload.h"
#include "WebPage.h"
enum { enum {
REMOVE_FINISHED_DOWNLOADS = 'rmfd', REMOVE_FINISHED_DOWNLOADS = 'rmfd',
@@ -59,28 +61,31 @@ enum {
SAVE_SETTINGS = 'svst' SAVE_SETTINGS = 'svst'
}; };
class IconView : public BView { class IconView : public BView {
public: public:
IconView(const BEntry& entry) IconView(const BEntry& entry)
: BView("Download icon", B_WILL_DRAW) :
, m_iconBitmap(BRect(0, 0, 31, 31), 0, B_RGBA32) BView("Download icon", B_WILL_DRAW),
fIconBitmap(BRect(0, 0, 31, 31), 0, B_RGBA32)
{ {
BNode node(&entry); BNode node(&entry);
BNodeInfo info(&node); BNodeInfo info(&node);
info.GetTrackerIcon(&m_iconBitmap, B_LARGE_ICON); info.GetTrackerIcon(&fIconBitmap, B_LARGE_ICON);
SetDrawingMode(B_OP_OVER); SetDrawingMode(B_OP_OVER);
} }
IconView(BMessage* archive) IconView(BMessage* archive)
: BView("Download icon", B_WILL_DRAW) :
, m_iconBitmap(archive) BView("Download icon", B_WILL_DRAW),
fIconBitmap(archive)
{ {
SetDrawingMode(B_OP_OVER); SetDrawingMode(B_OP_OVER);
} }
status_t saveSettings(BMessage* archive) status_t SaveSettings(BMessage* archive)
{ {
return m_iconBitmap.Archive(archive); return fIconBitmap.Archive(archive);
} }
virtual void AttachedToWindow() virtual void AttachedToWindow()
@@ -90,12 +95,12 @@ public:
virtual void Draw(BRect updateRect) virtual void Draw(BRect updateRect)
{ {
DrawBitmapAsync(&m_iconBitmap); DrawBitmapAsync(&fIconBitmap);
} }
virtual BSize MinSize() virtual BSize MinSize()
{ {
return BSize(m_iconBitmap.Bounds().Width(), m_iconBitmap.Bounds().Height()); return BSize(fIconBitmap.Bounds().Width(), fIconBitmap.Bounds().Height());
} }
virtual BSize PreferredSize() virtual BSize PreferredSize()
@@ -109,13 +114,15 @@ public:
} }
private: private:
BBitmap m_iconBitmap; BBitmap fIconBitmap;
}; };
class SmallButton : public BButton { class SmallButton : public BButton {
public: public:
SmallButton(const char* label, BMessage* message = NULL) SmallButton(const char* label, BMessage* message = NULL)
: BButton(label, message) :
BButton(label, message)
{ {
BFont font; BFont font;
GetFont(&font); GetFont(&font);
@@ -125,34 +132,37 @@ public:
} }
}; };
class DownloadProgressView : public BGridView { class DownloadProgressView : public BGridView {
public: public:
DownloadProgressView(BWebDownload* download) DownloadProgressView(BWebDownload* download)
: BGridView(8, 3) :
, m_download(download) BGridView(8, 3),
, m_url(download->URL()) fDownload(download),
, m_path(download->Path()) fURL(download->URL()),
, m_expectedSize(download->ExpectedSize()) fPath(download->Path()),
fExpectedSize(download->ExpectedSize())
{ {
} }
DownloadProgressView(const BMessage* archive) DownloadProgressView(const BMessage* archive)
: BGridView(8, 3) :
, m_download(NULL) BGridView(8, 3),
, m_url() fDownload(NULL),
, m_path() fURL(),
, m_expectedSize(0) fPath(),
fExpectedSize(0)
{ {
const char* string; const char* string;
if (archive->FindString("path", &string) == B_OK) if (archive->FindString("path", &string) == B_OK)
m_path.SetTo(string); fPath.SetTo(string);
if (archive->FindString("url", &string) == B_OK) if (archive->FindString("url", &string) == B_OK)
m_url = string; fURL = string;
} }
bool init(BMessage* archive = NULL) bool Init(BMessage* archive = NULL)
{ {
BEntry entry(m_path.Path()); BEntry entry(fPath.Path());
if (!entry.Exists() && !archive) if (!entry.Exists() && !archive)
return false; return false;
@@ -160,62 +170,62 @@ public:
SetFlags(Flags() | B_FULL_UPDATE_ON_RESIZE | B_WILL_DRAW); SetFlags(Flags() | B_FULL_UPDATE_ON_RESIZE | B_WILL_DRAW);
BGridLayout* layout = GridLayout(); BGridLayout* layout = GridLayout();
m_statusBar = new BStatusBar("download progress", m_path.Leaf()); fStatusBar = new BStatusBar("download progress", fPath.Leaf());
m_statusBar->SetMaxValue(100); fStatusBar->SetMaxValue(100);
if (archive) { if (archive) {
float value; float value;
if (archive->FindFloat("value", &value) == B_OK) if (archive->FindFloat("value", &value) == B_OK)
m_statusBar->SetTo(value); fStatusBar->SetTo(value);
} }
m_statusBar->SetBarHeight(12); fStatusBar->SetBarHeight(12);
if (entry.Exists()) if (entry.Exists())
m_iconView = new IconView(entry); fIconView = new IconView(entry);
else else
m_iconView = new IconView(archive); fIconView = new IconView(archive);
if (!m_download && m_statusBar->CurrentValue() < 100) if (!fDownload && fStatusBar->CurrentValue() < 100)
m_button1 = new SmallButton("Restart", new BMessage(RESTART_DOWNLOAD)); fTopButton = new SmallButton("Restart", new BMessage(RESTART_DOWNLOAD));
else { else {
m_button1 = new SmallButton("Open", new BMessage(OPEN_DOWNLOAD)); fTopButton = new SmallButton("Open", new BMessage(OPEN_DOWNLOAD));
m_button1->SetEnabled(m_download == NULL); fTopButton->SetEnabled(fDownload == NULL);
} }
if (m_download) if (fDownload)
m_button2 = new SmallButton("Cancel", new BMessage(CANCEL_DOWNLOAD)); fBottomButton = new SmallButton("Cancel", new BMessage(CANCEL_DOWNLOAD));
else { else {
m_button2 = new SmallButton("Remove", new BMessage(REMOVE_DOWNLOAD)); fBottomButton = new SmallButton("Remove", new BMessage(REMOVE_DOWNLOAD));
m_button2->SetEnabled(m_download == NULL); fBottomButton->SetEnabled(fDownload == NULL);
} }
layout->SetInsets(8, 5, 5, 6); layout->SetInsets(8, 5, 5, 6);
layout->AddView(m_iconView, 0, 0, 1, 2); layout->AddView(fIconView, 0, 0, 1, 2);
layout->AddView(m_statusBar, 1, 0, 1, 2); layout->AddView(fStatusBar, 1, 0, 1, 2);
layout->AddView(m_button1, 2, 0); layout->AddView(fTopButton, 2, 0);
layout->AddView(m_button2, 2, 1); layout->AddView(fBottomButton, 2, 1);
return true; return true;
} }
status_t saveSettings(BMessage* archive) status_t SaveSettings(BMessage* archive)
{ {
if (!archive) if (!archive)
return B_BAD_VALUE; return B_BAD_VALUE;
status_t ret = archive->AddString("path", m_path.Path()); status_t ret = archive->AddString("path", fPath.Path());
if (ret == B_OK) if (ret == B_OK)
ret = archive->AddString("url", m_url.String()); ret = archive->AddString("url", fURL.String());
if (ret == B_OK) if (ret == B_OK)
ret = archive->AddFloat("value", m_statusBar->CurrentValue()); ret = archive->AddFloat("value", fStatusBar->CurrentValue());
if (ret == B_OK) if (ret == B_OK)
ret = m_iconView->saveSettings(archive); ret = fIconView->SaveSettings(archive);
return ret; return ret;
} }
virtual void AttachedToWindow() virtual void AttachedToWindow()
{ {
if (m_download) if (fDownload)
m_download->SetProgressListener(BMessenger(this)); fDownload->SetProgressListener(BMessenger(this));
m_button1->SetTarget(this); fTopButton->SetTarget(this);
m_button2->SetTarget(this); fBottomButton->SetTarget(this);
} }
virtual void AllAttached() virtual void AllAttached()
@@ -240,13 +250,13 @@ public:
case B_DOWNLOAD_PROGRESS: { case B_DOWNLOAD_PROGRESS: {
float progress; float progress;
if (message->FindFloat("progress", &progress) == B_OK) if (message->FindFloat("progress", &progress) == B_OK)
m_statusBar->SetTo(progress); fStatusBar->SetTo(progress);
break; break;
} }
case OPEN_DOWNLOAD: { case OPEN_DOWNLOAD: {
// TODO: In case of executable files, ask the user first! // TODO: In case of executable files, ask the user first!
entry_ref ref; entry_ref ref;
status_t status = get_ref_for_path(m_path.Path(), &ref); status_t status = get_ref_for_path(fPath.Path(), &ref);
if (status == B_OK) if (status == B_OK)
status = be_roster->Launch(&ref); status = be_roster->Launch(&ref);
if (status != B_OK && status != B_ALREADY_RUNNING) { if (status != B_OK && status != B_ALREADY_RUNNING) {
@@ -257,12 +267,12 @@ public:
break; break;
} }
case RESTART_DOWNLOAD: case RESTART_DOWNLOAD:
BWebPage::RequestDownload(m_url); BWebPage::RequestDownload(fURL);
break; break;
case CANCEL_DOWNLOAD: case CANCEL_DOWNLOAD:
m_download->Cancel(); fDownload->Cancel();
downloadCanceled(); DownloadCanceled();
break; break;
case REMOVE_DOWNLOAD: { case REMOVE_DOWNLOAD: {
@@ -283,51 +293,53 @@ public:
} }
} }
BWebDownload* download() const BWebDownload* Download() const
{ {
return m_download; return fDownload;
} }
const BString& url() const const BString& URL() const
{ {
return m_url; return fURL;
} }
void downloadFinished() void DownloadFinished()
{ {
m_download = NULL; fDownload = NULL;
m_button1->SetEnabled(true); fTopButton->SetEnabled(true);
m_button2->SetLabel("Remove"); fBottomButton->SetLabel("Remove");
m_button2->SetMessage(new BMessage(REMOVE_DOWNLOAD)); fBottomButton->SetMessage(new BMessage(REMOVE_DOWNLOAD));
m_button2->SetEnabled(true); fBottomButton->SetEnabled(true);
} }
void downloadCanceled() void DownloadCanceled()
{ {
m_download = NULL; fDownload = NULL;
m_button1->SetLabel("Restart"); fTopButton->SetLabel("Restart");
m_button1->SetMessage(new BMessage(RESTART_DOWNLOAD)); fTopButton->SetMessage(new BMessage(RESTART_DOWNLOAD));
m_button1->SetEnabled(true); fTopButton->SetEnabled(true);
m_button2->SetLabel("Remove"); fBottomButton->SetLabel("Remove");
m_button2->SetMessage(new BMessage(REMOVE_DOWNLOAD)); fBottomButton->SetMessage(new BMessage(REMOVE_DOWNLOAD));
m_button2->SetEnabled(true); fBottomButton->SetEnabled(true);
} }
private: private:
IconView* m_iconView; IconView* fIconView;
BStatusBar* m_statusBar; BStatusBar* fStatusBar;
SmallButton* m_button1; SmallButton* fTopButton;
SmallButton* m_button2; SmallButton* fBottomButton;
BWebDownload* m_download; BWebDownload* fDownload;
BString m_url; BString fURL;
BPath m_path; BPath fPath;
off_t m_expectedSize; off_t fExpectedSize;
}; };
class DownloadsContainerView : public BGroupView { class DownloadsContainerView : public BGroupView {
public: public:
DownloadsContainerView() DownloadsContainerView()
: BGroupView(B_VERTICAL) :
BGroupView(B_VERTICAL)
{ {
SetViewColor(245, 245, 245); SetViewColor(245, 245, 245);
AddChild(BSpaceLayoutItem::CreateGlue()); AddChild(BSpaceLayoutItem::CreateGlue());
@@ -356,10 +368,13 @@ protected:
} }
}; };
class DownloadContainerScrollView : public BScrollView { class DownloadContainerScrollView : public BScrollView {
public: public:
DownloadContainerScrollView(BView* target) DownloadContainerScrollView(BView* target)
: BScrollView("Downloads scroll view", target, 0, false, true, B_NO_BORDER) :
BScrollView("Downloads scroll view", target, 0, false, true,
B_NO_BORDER)
{ {
} }
@@ -375,6 +390,7 @@ protected:
} }
}; };
DownloadWindow::DownloadWindow(BRect frame, bool visible) DownloadWindow::DownloadWindow(BRect frame, bool visible)
: BWindow(frame, "Downloads", : BWindow(frame, "Downloads",
B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
@@ -383,18 +399,19 @@ DownloadWindow::DownloadWindow(BRect frame, bool visible)
SetLayout(new BGroupLayout(B_VERTICAL)); SetLayout(new BGroupLayout(B_VERTICAL));
DownloadsContainerView* downloadsGroupView = new DownloadsContainerView(); DownloadsContainerView* downloadsGroupView = new DownloadsContainerView();
m_downloadViewsLayout = downloadsGroupView->GroupLayout(); fDownloadViewsLayout = downloadsGroupView->GroupLayout();
BMenuBar* menuBar = new BMenuBar("Menu bar"); BMenuBar* menuBar = new BMenuBar("Menu bar");
BMenu* menu = new BMenu("Window"); BMenu* menu = new BMenu("Window");
menu->AddItem(new BMenuItem("Hide", new BMessage(B_QUIT_REQUESTED), 'H')); menu->AddItem(new BMenuItem("Hide", new BMessage(B_QUIT_REQUESTED), 'H'));
menuBar->AddItem(menu); menuBar->AddItem(menu);
BScrollView* scrollView = new DownloadContainerScrollView(downloadsGroupView); BScrollView* scrollView = new DownloadContainerScrollView(
downloadsGroupView);
m_removeFinishedButton = new BButton("Remove finished", fRemoveFinishedButton = new BButton("Remove finished",
new BMessage(REMOVE_FINISHED_DOWNLOADS)); new BMessage(REMOVE_FINISHED_DOWNLOADS));
m_removeFinishedButton->SetEnabled(false); fRemoveFinishedButton->SetEnabled(false);
AddChild(BGroupLayoutBuilder(B_VERTICAL) AddChild(BGroupLayoutBuilder(B_VERTICAL)
.Add(menuBar) .Add(menuBar)
@@ -402,46 +419,53 @@ DownloadWindow::DownloadWindow(BRect frame, bool visible)
.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER)) .Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
.Add(BGroupLayoutBuilder(B_HORIZONTAL) .Add(BGroupLayoutBuilder(B_HORIZONTAL)
.AddGlue() .AddGlue()
.Add(m_removeFinishedButton) .Add(fRemoveFinishedButton)
.SetInsets(5, 5, 5, 5) .SetInsets(5, 5, 5, 5)
) )
); );
loadSettings(); _LoadSettings();
// Small trick to get the correct enabled status of the Remove finished button // Small trick to get the correct enabled status of the Remove finished button
downloadFinished(NULL); _DownloadFinished(NULL);
if (!visible) if (!visible)
Hide(); Hide();
Show(); Show();
} }
DownloadWindow::~DownloadWindow() DownloadWindow::~DownloadWindow()
{ {
// Only necessary to save the current progress of unfinished downloads: // Only necessary to save the current progress of unfinished downloads:
saveSettings(); _SaveSettings();
} }
void DownloadWindow::MessageReceived(BMessage* message)
void
DownloadWindow::MessageReceived(BMessage* message)
{ {
switch (message->what) { switch (message->what) {
case B_DOWNLOAD_ADDED: { case B_DOWNLOAD_ADDED: {
BWebDownload* download; BWebDownload* download;
if (message->FindPointer("download", reinterpret_cast<void**>(&download)) == B_OK) if (message->FindPointer("download", reinterpret_cast<void**>(
downloadStarted(download); &download)) == B_OK) {
_DownloadStarted(download);
}
break; break;
} }
case B_DOWNLOAD_REMOVED: { case B_DOWNLOAD_REMOVED: {
BWebDownload* download; BWebDownload* download;
if (message->FindPointer("download", reinterpret_cast<void**>(&download)) == B_OK) if (message->FindPointer("download", reinterpret_cast<void**>(
downloadFinished(download); &download)) == B_OK) {
_DownloadFinished(download);
}
break; break;
} }
case REMOVE_FINISHED_DOWNLOADS: case REMOVE_FINISHED_DOWNLOADS:
removeFinishedDownloads(); _RemoveFinishedDownloads();
break; break;
case SAVE_SETTINGS: case SAVE_SETTINGS:
saveSettings(); _SaveSettings();
break; break;
default: default:
BWindow::MessageReceived(message); BWindow::MessageReceived(message);
@@ -449,111 +473,133 @@ void DownloadWindow::MessageReceived(BMessage* message)
} }
} }
bool DownloadWindow::QuitRequested()
bool
DownloadWindow::QuitRequested()
{ {
if (!IsHidden()) if (!IsHidden())
Hide(); Hide();
return false; return false;
} }
void DownloadWindow::downloadStarted(BWebDownload* download)
void
DownloadWindow::_DownloadStarted(BWebDownload* download)
{ {
int32 finishedCount = 0; int32 finishedCount = 0;
int32 index = 0; int32 index = 0;
for (int32 i = m_downloadViewsLayout->CountItems() - 1; for (int32 i = fDownloadViewsLayout->CountItems() - 1;
BLayoutItem* item = m_downloadViewsLayout->ItemAt(i); i--) { BLayoutItem* item = fDownloadViewsLayout->ItemAt(i); i--) {
DownloadProgressView* view = dynamic_cast<DownloadProgressView*>(item->View()); DownloadProgressView* view = dynamic_cast<DownloadProgressView*>(
item->View());
if (!view) if (!view)
continue; continue;
if (view->url() == download->URL()) { if (view->URL() == download->URL()) {
index = i; index = i;
view->RemoveSelf(); view->RemoveSelf();
delete view; delete view;
} else if (!view->download()) } else if (!view->Download())
finishedCount++; finishedCount++;
} }
m_removeFinishedButton->SetEnabled(finishedCount > 0); fRemoveFinishedButton->SetEnabled(finishedCount > 0);
DownloadProgressView* view = new DownloadProgressView(download); DownloadProgressView* view = new DownloadProgressView(download);
if (!view->init()) if (!view->Init())
return; return;
m_downloadViewsLayout->AddView(index, view); fDownloadViewsLayout->AddView(index, view);
saveSettings(); _SaveSettings();
SetWorkspaces(B_CURRENT_WORKSPACE); SetWorkspaces(B_CURRENT_WORKSPACE);
if (IsHidden()) if (IsHidden())
Show(); Show();
} }
void DownloadWindow::downloadFinished(BWebDownload* download)
void
DownloadWindow::_DownloadFinished(BWebDownload* download)
{ {
int32 finishedCount = 0; int32 finishedCount = 0;
for (int32 i = 0; BLayoutItem* item = m_downloadViewsLayout->ItemAt(i); i++) { for (int32 i = 0;
DownloadProgressView* view = dynamic_cast<DownloadProgressView*>(item->View()); BLayoutItem* item = fDownloadViewsLayout->ItemAt(i); i++) {
DownloadProgressView* view = dynamic_cast<DownloadProgressView*>(
item->View());
if (!view) if (!view)
continue; continue;
if (view->download() == download) { if (view->Download() == download) {
view->downloadFinished(); view->DownloadFinished();
finishedCount++; finishedCount++;
} else if (!view->download()) } else if (!view->Download())
finishedCount++; finishedCount++;
} }
m_removeFinishedButton->SetEnabled(finishedCount > 0); fRemoveFinishedButton->SetEnabled(finishedCount > 0);
if (download) if (download)
saveSettings(); _SaveSettings();
} }
void DownloadWindow::removeFinishedDownloads()
void
DownloadWindow::_RemoveFinishedDownloads()
{ {
for (int32 i = m_downloadViewsLayout->CountItems() - 1; for (int32 i = fDownloadViewsLayout->CountItems() - 1;
BLayoutItem* item = m_downloadViewsLayout->ItemAt(i); i--) { BLayoutItem* item = fDownloadViewsLayout->ItemAt(i); i--) {
DownloadProgressView* view = dynamic_cast<DownloadProgressView*>(item->View()); DownloadProgressView* view = dynamic_cast<DownloadProgressView*>(
item->View());
if (!view) if (!view)
continue; continue;
if (!view->download()) { if (!view->Download()) {
view->RemoveSelf(); view->RemoveSelf();
delete view; delete view;
} }
} }
m_removeFinishedButton->SetEnabled(false); fRemoveFinishedButton->SetEnabled(false);
saveSettings(); _SaveSettings();
} }
void DownloadWindow::saveSettings()
void
DownloadWindow::_SaveSettings()
{ {
BFile file; BFile file;
if (!openSettingsFile(file, B_ERASE_FILE | B_CREATE_FILE | B_WRITE_ONLY)) if (!_OpenSettingsFile(file, B_ERASE_FILE | B_CREATE_FILE | B_WRITE_ONLY))
return; return;
BMessage message; BMessage message;
for (int32 i = m_downloadViewsLayout->CountItems() - 1; for (int32 i = fDownloadViewsLayout->CountItems() - 1;
BLayoutItem* item = m_downloadViewsLayout->ItemAt(i); i--) { BLayoutItem* item = fDownloadViewsLayout->ItemAt(i); i--) {
DownloadProgressView* view = dynamic_cast<DownloadProgressView*>(item->View()); DownloadProgressView* view = dynamic_cast<DownloadProgressView*>(
item->View());
if (!view) if (!view)
continue; continue;
BMessage downloadArchive; BMessage downloadArchive;
if (view->saveSettings(&downloadArchive) == B_OK) if (view->SaveSettings(&downloadArchive) == B_OK)
message.AddMessage("download", &downloadArchive); message.AddMessage("download", &downloadArchive);
} }
message.Flatten(&file); message.Flatten(&file);
} }
void DownloadWindow::loadSettings()
void
DownloadWindow::_LoadSettings()
{ {
BFile file; BFile file;
if (!openSettingsFile(file, B_READ_ONLY)) if (!_OpenSettingsFile(file, B_READ_ONLY))
return; return;
BMessage message; BMessage message;
if (message.Unflatten(&file) != B_OK) if (message.Unflatten(&file) != B_OK)
return; return;
BMessage downloadArchive; BMessage downloadArchive;
for (int32 i = 0; message.FindMessage("download", i, &downloadArchive) == B_OK; i++) { for (int32 i = 0;
DownloadProgressView* view = new DownloadProgressView(&downloadArchive); message.FindMessage("download", i, &downloadArchive) == B_OK;
if (!view->init(&downloadArchive)) i++) {
DownloadProgressView* view = new DownloadProgressView(
&downloadArchive);
if (!view->Init(&downloadArchive))
continue; continue;
m_downloadViewsLayout->AddView(0, view); fDownloadViewsLayout->AddView(0, view);
} }
} }
bool DownloadWindow::openSettingsFile(BFile& file, uint32 mode)
bool
DownloadWindow::_OpenSettingsFile(BFile& file, uint32 mode)
{ {
BPath path; BPath path;
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK
+13 -12
View File
@@ -24,9 +24,9 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef DOWNLOAD_WINDOW_H
#define DOWNLOAD_WINDOW_H
#ifndef DownloadWindow_h
#define DownloadWindow_h
#include <Window.h> #include <Window.h>
@@ -35,26 +35,27 @@ class BFile;
class BGroupLayout; class BGroupLayout;
class BWebDownload; class BWebDownload;
class DownloadWindow : public BWindow { class DownloadWindow : public BWindow {
public: public:
DownloadWindow(BRect frame, bool visible); DownloadWindow(BRect frame, bool visible);
virtual ~DownloadWindow(); virtual ~DownloadWindow();
virtual void MessageReceived(BMessage*); virtual void MessageReceived(BMessage* message);
virtual bool QuitRequested(); virtual bool QuitRequested();
private: private:
void downloadStarted(BWebDownload* download); void _DownloadStarted(BWebDownload* download);
void downloadFinished(BWebDownload* download); void _DownloadFinished(BWebDownload* download);
void removeFinishedDownloads(); void _RemoveFinishedDownloads();
void saveSettings(); void _SaveSettings();
void loadSettings(); void _LoadSettings();
bool openSettingsFile(BFile& file, uint32 mode); bool _OpenSettingsFile(BFile& file, uint32 mode);
private: private:
BGroupLayout* m_downloadViewsLayout; BGroupLayout* fDownloadViewsLayout;
BButton* m_removeFinishedButton; BButton* fRemoveFinishedButton;
}; };
#endif // DownloadWindow_h
#endif // DOWNLOAD_WINDOW_H