Clean-up
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31935 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -11,7 +11,7 @@ GenericThread::GenericThread(const char* thread_name, int32 priority,
|
|||||||
BMessage* message)
|
BMessage* message)
|
||||||
:
|
:
|
||||||
fThreadDataStore(message),
|
fThreadDataStore(message),
|
||||||
fThreadId(spawn_thread (_ThreadFunction, thread_name, priority, this)),
|
fThreadId(spawn_thread(_ThreadFunction, thread_name, priority, this)),
|
||||||
fExecuteUnitSem(create_sem(1, "fExecuteUnitSem")),
|
fExecuteUnitSem(create_sem(1, "fExecuteUnitSem")),
|
||||||
fQuitRequested(false),
|
fQuitRequested(false),
|
||||||
fThreadIsPaused(false)
|
fThreadIsPaused(false)
|
||||||
@@ -62,7 +62,7 @@ GenericThread::ThreadFunction()
|
|||||||
// Subclass and override
|
// Subclass and override
|
||||||
|
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
ExecuteUnitFailed (status);
|
ExecuteUnitFailed(status);
|
||||||
// Subclass and override
|
// Subclass and override
|
||||||
|
|
||||||
EndUnit();
|
EndUnit();
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public:
|
|||||||
status_t Kill();
|
status_t Kill();
|
||||||
|
|
||||||
void ExitWithReturnValue(status_t returnValue);
|
void ExitWithReturnValue(status_t returnValue);
|
||||||
status_t SetExitCallback(void (* callback)(void*),
|
status_t SetExitCallback(void (*callback)(void*),
|
||||||
void* data);
|
void* data);
|
||||||
status_t WaitForThread(status_t* exitValue);
|
status_t WaitForThread(status_t* exitValue);
|
||||||
|
|
||||||
|
|||||||
@@ -1,176 +1,159 @@
|
|||||||
// license: public domain
|
// license: public domain
|
||||||
// authors: [email protected]
|
// authors: [email protected]
|
||||||
|
|
||||||
#include <TrackerAddOn.h>
|
|
||||||
#include <Roster.h>
|
|
||||||
#include <Debug.h>
|
|
||||||
|
|
||||||
#include "ZipOMatic.h"
|
#include "ZipOMatic.h"
|
||||||
|
|
||||||
|
#include <Roster.h>
|
||||||
|
#include <TrackerAddOn.h>
|
||||||
|
|
||||||
#include "ZipOMaticMisc.h"
|
#include "ZipOMaticMisc.h"
|
||||||
#include "ZipOMaticWindow.h"
|
#include "ZipOMaticWindow.h"
|
||||||
|
|
||||||
extern "C" void
|
|
||||||
process_refs(entry_ref dir_ref, BMessage * msg, void *)
|
|
||||||
{
|
|
||||||
msg->AddRef("dir_ref", & dir_ref);
|
|
||||||
|
|
||||||
status_t status = B_OK;
|
extern "C" void
|
||||||
type_code ref_type = B_REF_TYPE;
|
process_refs(entry_ref dirRef, BMessage* message, void*)
|
||||||
int32 ref_count = 0;
|
{
|
||||||
|
status_t status = B_OK;
|
||||||
|
type_code refType = B_REF_TYPE;
|
||||||
|
int32 refCount = 0;
|
||||||
|
|
||||||
status = msg->GetInfo("refs", & ref_type, & ref_count);
|
status = message->GetInfo("refs", &refType, &refCount);
|
||||||
if (status != B_OK || ref_count < 1)
|
if (status != B_OK || refCount < 1)
|
||||||
be_roster->Launch (ZIPOMATIC_APP_SIG);
|
be_roster->Launch(ZIPOMATIC_APP_SIG);
|
||||||
else
|
else
|
||||||
be_roster->Launch (ZIPOMATIC_APP_SIG, msg );
|
be_roster->Launch(ZIPOMATIC_APP_SIG, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
|
||||||
|
int
|
||||||
|
main()
|
||||||
{
|
{
|
||||||
ZipOMatic app;
|
ZipOMatic app;
|
||||||
app.Run();
|
app.Run();
|
||||||
|
|
||||||
return (0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZipOMatic::ZipOMatic (void)
|
|
||||||
: BApplication (ZIPOMATIC_APP_SIG),
|
ZipOMatic::ZipOMatic()
|
||||||
m_got_refs (false)
|
:
|
||||||
|
BApplication(ZIPOMATIC_APP_SIG),
|
||||||
|
fGotRefs(false)
|
||||||
{
|
{
|
||||||
PRINT(("ZipOMatic::ZipOMatic()\n"));
|
|
||||||
|
|
||||||
// void
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ZipOMatic::~ZipOMatic (void)
|
|
||||||
|
ZipOMatic::~ZipOMatic()
|
||||||
{
|
{
|
||||||
PRINT(("ZipOMatic::~ZipOMatic()\n"));
|
|
||||||
|
|
||||||
fflush(stdout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ZipOMatic::RefsReceived (BMessage * a_message)
|
ZipOMatic::RefsReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
PRINT(("ZipOMatic::RefsReceived()\n"));
|
|
||||||
|
|
||||||
if (IsLaunching())
|
if (IsLaunching())
|
||||||
m_got_refs = true;
|
fGotRefs = true;
|
||||||
|
|
||||||
BMessage * msg = new BMessage (* a_message);
|
BMessage* msg = new BMessage(*message);
|
||||||
|
|
||||||
UseExistingOrCreateNewWindow(msg);
|
_UseExistingOrCreateNewWindow(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ZipOMatic::ReadyToRun (void)
|
ZipOMatic::ReadyToRun()
|
||||||
{
|
{
|
||||||
PRINT(("ZipOMatic::ReadyToRun()\n"));
|
if (!fGotRefs)
|
||||||
|
_UseExistingOrCreateNewWindow();
|
||||||
if (m_got_refs)
|
|
||||||
{
|
|
||||||
// nothing - wait on window(s) to finish
|
|
||||||
}
|
|
||||||
else
|
|
||||||
UseExistingOrCreateNewWindow();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ZipOMatic::MessageReceived (BMessage * a_message)
|
ZipOMatic::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
PRINT(("ZipOMatic::MessageReceived()\n"));
|
switch (message->what) {
|
||||||
|
|
||||||
switch(a_message->what)
|
|
||||||
{
|
|
||||||
case ZIPPO_WINDOW_QUIT:
|
case ZIPPO_WINDOW_QUIT:
|
||||||
|
snooze(200000);
|
||||||
snooze (200000);
|
if (CountWindows() == 0)
|
||||||
if (CountWindows() == 0)
|
Quit();
|
||||||
Quit();
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
case B_SILENT_RELAUNCH:
|
case B_SILENT_RELAUNCH:
|
||||||
|
_SilentRelaunch();
|
||||||
SilentRelaunch();
|
break;
|
||||||
break;
|
|
||||||
|
default:
|
||||||
default: BApplication::MessageReceived(a_message); break;
|
BApplication::MessageReceived(message);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ZipOMatic::QuitRequested (void)
|
ZipOMatic::QuitRequested (void)
|
||||||
{
|
{
|
||||||
// intelligent (?) closing of the windows
|
// Overriding BApplication's default behaviour on purpose
|
||||||
//
|
// so we can have multiple zippers pause in unison.
|
||||||
// overriding BApplication::QuitRequested();
|
|
||||||
|
|
||||||
if (CountWindows() <= 0)
|
if (CountWindows() <= 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
BList window_list (5);
|
BList list(5);
|
||||||
int32 window_count = 0;
|
BWindow* window;
|
||||||
BWindow * window;
|
|
||||||
|
|
||||||
// build list of windows
|
for (int32 i = 0;; i++) {
|
||||||
while (1)
|
window = WindowAt(i);
|
||||||
{
|
|
||||||
window = WindowAt(window_count++);
|
|
||||||
if (window == NULL)
|
if (window == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
window_list.AddItem(window);
|
list.AddItem(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ask windows to quit
|
while (true) {
|
||||||
while (1)
|
window = (BWindow*) list.RemoveItem(int32(0));
|
||||||
{
|
|
||||||
window = (BWindow *) window_list.RemoveItem(int32(0));
|
|
||||||
if (window == NULL)
|
if (window == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (window->Lock())
|
if (window->Lock()) {
|
||||||
{
|
|
||||||
window->PostMessage(B_QUIT_REQUESTED);
|
window->PostMessage(B_QUIT_REQUESTED);
|
||||||
window->Unlock();
|
window->Unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PRINT(("CountWindows(): %ld\n", CountWindows()));
|
|
||||||
|
|
||||||
if (CountWindows() <= 0)
|
if (CountWindows() <= 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false; // default: stay alive
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ZipOMatic::SilentRelaunch (void)
|
ZipOMatic::_SilentRelaunch()
|
||||||
{
|
{
|
||||||
UseExistingOrCreateNewWindow();
|
_UseExistingOrCreateNewWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
ZipOMatic::UseExistingOrCreateNewWindow (BMessage * a_message)
|
|
||||||
{
|
|
||||||
int32 window_count = 0;
|
|
||||||
ZippoWindow * window;
|
|
||||||
bool found_non_busy_window = false;
|
|
||||||
|
|
||||||
while (1)
|
void
|
||||||
{
|
ZipOMatic::_UseExistingOrCreateNewWindow(BMessage* message)
|
||||||
window = dynamic_cast<ZippoWindow *>(WindowAt(window_count++));
|
{
|
||||||
|
int32 windowCount = 0;
|
||||||
|
ZippoWindow* window;
|
||||||
|
bool foundNonBusyWindow = false;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
window = dynamic_cast<ZippoWindow*>(WindowAt(windowCount++));
|
||||||
if (window == NULL)
|
if (window == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (window->Lock())
|
if (window->Lock()) {
|
||||||
{
|
if (!window->IsZipping()) {
|
||||||
if (! window->IsZipping())
|
foundNonBusyWindow = true;
|
||||||
{
|
if (message != NULL)
|
||||||
found_non_busy_window = true;
|
window->PostMessage(message);
|
||||||
if (a_message != NULL)
|
|
||||||
window->PostMessage(a_message);
|
|
||||||
window->Activate();
|
window->Activate();
|
||||||
window->Unlock();
|
window->Unlock();
|
||||||
break;
|
break;
|
||||||
@@ -179,9 +162,10 @@ ZipOMatic::UseExistingOrCreateNewWindow (BMessage * a_message)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! found_non_busy_window)
|
if (!foundNonBusyWindow)
|
||||||
{
|
{
|
||||||
ZippoWindow * m_window = new ZippoWindow(a_message);
|
ZippoWindow * window = new ZippoWindow(message);
|
||||||
m_window->Show();
|
window->Show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,28 +1,29 @@
|
|||||||
#ifndef _ZIPOMATIC_H_
|
#ifndef _ZIPOMATIC_H_
|
||||||
#define _ZIPOMATIC_H_
|
#define _ZIPOMATIC_H_
|
||||||
|
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
|
|
||||||
|
|
||||||
class ZipOMatic : public BApplication
|
class ZipOMatic : public BApplication
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ZipOMatic (void);
|
ZipOMatic();
|
||||||
~ZipOMatic (void);
|
~ZipOMatic();
|
||||||
|
|
||||||
virtual void ReadyToRun (void);
|
virtual void ReadyToRun();
|
||||||
virtual void RefsReceived (BMessage * a_message);
|
virtual void RefsReceived(BMessage* message);
|
||||||
virtual void MessageReceived (BMessage * a_message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
virtual bool QuitRequested (void);
|
virtual bool QuitRequested();
|
||||||
|
|
||||||
void SilentRelaunch (void);
|
|
||||||
void UseExistingOrCreateNewWindow (BMessage * a_message = NULL);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void _SilentRelaunch();
|
||||||
|
void _UseExistingOrCreateNewWindow(BMessage*
|
||||||
|
message = NULL);
|
||||||
|
|
||||||
bool m_got_refs;
|
bool fGotRefs;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _ZIPOMATIC_H_
|
#endif // _ZIPOMATIC_H_
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ resource app_version {
|
|||||||
internal = 1,
|
internal = 1,
|
||||||
|
|
||||||
short_info = "ZipOMatic",
|
short_info = "ZipOMatic",
|
||||||
long_info = "ZipOMatic, Copyright 2003-2008 Haiku Inc."
|
long_info = "ZipOMatic, Copyright 2003-2009 Haiku Inc."
|
||||||
};
|
};
|
||||||
|
|
||||||
resource file_types message {
|
resource file_types message {
|
||||||
|
|||||||
@@ -1,96 +1,105 @@
|
|||||||
// license: public domain
|
// license: public domain
|
||||||
// authors: [email protected]
|
// authors: [email protected]
|
||||||
|
|
||||||
|
|
||||||
#include "ZipOMaticActivity.h"
|
#include "ZipOMaticActivity.h"
|
||||||
|
|
||||||
Activity::Activity (BRect a_rect, const char * a_name, uint32 a_resizing_mode, uint32 a_flags)
|
|
||||||
: BView (a_rect, a_name, a_resizing_mode, a_flags),
|
Activity::Activity(BRect frame, const char* name, uint32 resizingMode,
|
||||||
m_is_running (false),
|
uint32 flags)
|
||||||
m_barberpole_bitmap (NULL)
|
:
|
||||||
|
BView(frame, name, resizingMode, flags),
|
||||||
|
fIsRunning(false),
|
||||||
|
fBitmap(NULL)
|
||||||
{
|
{
|
||||||
SetViewColor(B_TRANSPARENT_COLOR);
|
SetViewColor(B_TRANSPARENT_COLOR);
|
||||||
|
|
||||||
m_pattern.data[0] = 0x0f;
|
fPattern.data[0] = 0x0f;
|
||||||
m_pattern.data[1] = 0x1e;
|
fPattern.data[1] = 0x1e;
|
||||||
m_pattern.data[2] = 0x3c;
|
fPattern.data[2] = 0x3c;
|
||||||
m_pattern.data[3] = 0x78;
|
fPattern.data[3] = 0x78;
|
||||||
m_pattern.data[4] = 0xf0;
|
fPattern.data[4] = 0xf0;
|
||||||
m_pattern.data[5] = 0xe1;
|
fPattern.data[5] = 0xe1;
|
||||||
m_pattern.data[6] = 0xc3;
|
fPattern.data[6] = 0xc3;
|
||||||
m_pattern.data[7] = 0x87;
|
fPattern.data[7] = 0x87;
|
||||||
|
|
||||||
CreateBitmap();
|
_CreateBitmap();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Activity::~Activity()
|
Activity::~Activity()
|
||||||
{
|
{
|
||||||
// subviews are deleted by superclass
|
delete fBitmap;
|
||||||
|
|
||||||
delete m_barberpole_bitmap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Activity::Start()
|
Activity::Start()
|
||||||
{
|
{
|
||||||
m_is_running = true;
|
fIsRunning = true;
|
||||||
Window()->SetPulseRate(100000);
|
Window()->SetPulseRate(100000);
|
||||||
SetFlags(Flags() | B_PULSE_NEEDED);
|
SetFlags(Flags() | B_PULSE_NEEDED);
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Activity::Pause()
|
Activity::Pause()
|
||||||
{
|
{
|
||||||
Window()->SetPulseRate(500000);
|
Window()->SetPulseRate(500000);
|
||||||
SetFlags(Flags() & (~ B_PULSE_NEEDED));
|
SetFlags(Flags() & (~B_PULSE_NEEDED));
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Activity::Stop()
|
Activity::Stop()
|
||||||
{
|
{
|
||||||
m_is_running = false;
|
fIsRunning = false;
|
||||||
Window()->SetPulseRate(500000);
|
Window()->SetPulseRate(500000);
|
||||||
SetFlags(Flags() & (~ B_PULSE_NEEDED));
|
SetFlags(Flags() & (~B_PULSE_NEEDED));
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Activity::IsRunning()
|
Activity::IsRunning()
|
||||||
{
|
{
|
||||||
return m_is_running;
|
return fIsRunning;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Activity::Pulse()
|
Activity::Pulse()
|
||||||
{
|
{
|
||||||
uchar tmp = m_pattern.data[7];
|
uchar tmp = fPattern.data[7];
|
||||||
|
|
||||||
for (int j = 7; j > 0; --j)
|
for (int j = 7; j > 0; --j)
|
||||||
{
|
fPattern.data[j] = fPattern.data[j-1];
|
||||||
m_pattern.data[j] = m_pattern.data[j-1];
|
|
||||||
}
|
|
||||||
|
|
||||||
m_pattern.data[0] = tmp;
|
fPattern.data[0] = tmp;
|
||||||
|
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Activity::Draw(BRect a_rect)
|
Activity::Draw(BRect rect)
|
||||||
{
|
{
|
||||||
DrawIntoBitmap(IsRunning());
|
_DrawOnBitmap(IsRunning());
|
||||||
SetDrawingMode(B_OP_COPY);
|
SetDrawingMode(B_OP_COPY);
|
||||||
DrawBitmap(m_barberpole_bitmap);
|
DrawBitmap(fBitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Activity::DrawIntoBitmap (bool running)
|
|
||||||
{
|
|
||||||
if (m_barberpole_bitmap->Lock())
|
|
||||||
{
|
|
||||||
BRect a_rect = m_barberpole_bitmap->Bounds();
|
|
||||||
|
|
||||||
m_barberpole_bitmap_view->SetDrawingMode(B_OP_COPY);
|
void
|
||||||
|
Activity::_DrawOnBitmap(bool running)
|
||||||
|
{
|
||||||
|
if (fBitmap->Lock())
|
||||||
|
{
|
||||||
|
BRect rect = fBitmap->Bounds();
|
||||||
|
|
||||||
|
fBitmapView->SetDrawingMode(B_OP_COPY);
|
||||||
|
|
||||||
rgb_color color;
|
rgb_color color;
|
||||||
color.red = 0;
|
color.red = 0;
|
||||||
@@ -101,11 +110,11 @@ void Activity::DrawIntoBitmap (bool running)
|
|||||||
if (running)
|
if (running)
|
||||||
color.blue = 200;
|
color.blue = 200;
|
||||||
|
|
||||||
m_barberpole_bitmap_view->SetHighColor(color);
|
fBitmapView->SetHighColor(color);
|
||||||
|
|
||||||
// draw the pole
|
// draw the pole
|
||||||
a_rect.InsetBy(2,2);
|
rect.InsetBy(2,2);
|
||||||
m_barberpole_bitmap_view->FillRect(a_rect, m_pattern);
|
fBitmapView->FillRect(rect, fPattern);
|
||||||
|
|
||||||
// draw frame
|
// draw frame
|
||||||
|
|
||||||
@@ -113,98 +122,105 @@ void Activity::DrawIntoBitmap (bool running)
|
|||||||
color.red = 150;
|
color.red = 150;
|
||||||
color.green = 150;
|
color.green = 150;
|
||||||
color.blue = 150;
|
color.blue = 150;
|
||||||
m_barberpole_bitmap_view->SetHighColor(color);
|
fBitmapView->SetHighColor(color);
|
||||||
m_barberpole_bitmap_view->SetDrawingMode(B_OP_OVER);
|
fBitmapView->SetDrawingMode(B_OP_OVER);
|
||||||
BPoint point_a = m_barberpole_bitmap->Bounds().LeftTop();
|
BPoint point_a = fBitmap->Bounds().LeftTop();
|
||||||
BPoint point_b = m_barberpole_bitmap->Bounds().LeftBottom();
|
BPoint point_b = fBitmap->Bounds().LeftBottom();
|
||||||
point_b.y -= 1;
|
point_b.y -= 1;
|
||||||
m_barberpole_bitmap_view->StrokeLine(point_a, point_b);
|
fBitmapView->StrokeLine(point_a, point_b);
|
||||||
point_a.x += 1;
|
point_a.x += 1;
|
||||||
point_b.x += 1;
|
point_b.x += 1;
|
||||||
point_b.y -= 1;
|
point_b.y -= 1;
|
||||||
m_barberpole_bitmap_view->StrokeLine(point_a, point_b);
|
fBitmapView->StrokeLine(point_a, point_b);
|
||||||
|
|
||||||
// top
|
// top
|
||||||
point_a = m_barberpole_bitmap->Bounds().LeftTop();
|
point_a = fBitmap->Bounds().LeftTop();
|
||||||
point_b = m_barberpole_bitmap->Bounds().RightTop();
|
point_b = fBitmap->Bounds().RightTop();
|
||||||
point_b.x -= 1;
|
point_b.x -= 1;
|
||||||
m_barberpole_bitmap_view->StrokeLine(point_a, point_b);
|
fBitmapView->StrokeLine(point_a, point_b);
|
||||||
point_a.y += 1;
|
point_a.y += 1;
|
||||||
point_b.y += 1;
|
point_b.y += 1;
|
||||||
point_b.x -= 1;
|
point_b.x -= 1;
|
||||||
m_barberpole_bitmap_view->StrokeLine(point_a, point_b);
|
fBitmapView->StrokeLine(point_a, point_b);
|
||||||
|
|
||||||
// right
|
// right
|
||||||
color.red = 255;
|
color.red = 255;
|
||||||
color.green = 255;
|
color.green = 255;
|
||||||
color.blue = 255;
|
color.blue = 255;
|
||||||
m_barberpole_bitmap_view->SetHighColor(color);
|
fBitmapView->SetHighColor(color);
|
||||||
point_a = m_barberpole_bitmap->Bounds().RightTop();
|
point_a = fBitmap->Bounds().RightTop();
|
||||||
point_b = m_barberpole_bitmap->Bounds().RightBottom();
|
point_b = fBitmap->Bounds().RightBottom();
|
||||||
m_barberpole_bitmap_view->StrokeLine(point_a, point_b);
|
fBitmapView->StrokeLine(point_a, point_b);
|
||||||
point_a.y += 1;
|
point_a.y += 1;
|
||||||
point_a.x -= 1;
|
point_a.x -= 1;
|
||||||
point_b.x -= 1;
|
point_b.x -= 1;
|
||||||
m_barberpole_bitmap_view->StrokeLine(point_a, point_b);
|
fBitmapView->StrokeLine(point_a, point_b);
|
||||||
|
|
||||||
// bottom
|
// bottom
|
||||||
point_a = m_barberpole_bitmap->Bounds().LeftBottom();
|
point_a = fBitmap->Bounds().LeftBottom();
|
||||||
point_b = m_barberpole_bitmap->Bounds().RightBottom();
|
point_b = fBitmap->Bounds().RightBottom();
|
||||||
m_barberpole_bitmap_view->StrokeLine(point_a, point_b);
|
fBitmapView->StrokeLine(point_a, point_b);
|
||||||
point_a.x += 1;
|
point_a.x += 1;
|
||||||
point_a.y -= 1;
|
point_a.y -= 1;
|
||||||
point_b.y -= 1;
|
point_b.y -= 1;
|
||||||
m_barberpole_bitmap_view->StrokeLine(point_a, point_b);
|
fBitmapView->StrokeLine(point_a, point_b);
|
||||||
|
|
||||||
// some blending
|
// some blending
|
||||||
color.red = 150;
|
color.red = 150;
|
||||||
color.green = 150;
|
color.green = 150;
|
||||||
color.blue = 150;
|
color.blue = 150;
|
||||||
m_barberpole_bitmap_view->SetHighColor(color);
|
fBitmapView->SetHighColor(color);
|
||||||
m_barberpole_bitmap_view->SetDrawingMode(B_OP_SUBTRACT);
|
fBitmapView->SetDrawingMode(B_OP_SUBTRACT);
|
||||||
m_barberpole_bitmap_view->StrokeRect(a_rect);
|
fBitmapView->StrokeRect(rect);
|
||||||
|
|
||||||
a_rect.InsetBy(1,1);
|
rect.InsetBy(1,1);
|
||||||
LightenBitmapHighColor(& color);
|
_LightenBitmapHighColor(& color);
|
||||||
m_barberpole_bitmap_view->StrokeRect(a_rect);
|
fBitmapView->StrokeRect(rect);
|
||||||
|
|
||||||
a_rect.InsetBy(1,1);
|
rect.InsetBy(1,1);
|
||||||
LightenBitmapHighColor(& color);
|
_LightenBitmapHighColor(& color);
|
||||||
m_barberpole_bitmap_view->StrokeRect(a_rect);
|
fBitmapView->StrokeRect(rect);
|
||||||
|
|
||||||
a_rect.InsetBy(1,1);
|
rect.InsetBy(1,1);
|
||||||
LightenBitmapHighColor(& color);
|
_LightenBitmapHighColor(& color);
|
||||||
m_barberpole_bitmap_view->StrokeRect(a_rect);
|
fBitmapView->StrokeRect(rect);
|
||||||
|
|
||||||
a_rect.InsetBy(1,1);
|
rect.InsetBy(1,1);
|
||||||
LightenBitmapHighColor(& color);
|
_LightenBitmapHighColor(& color);
|
||||||
m_barberpole_bitmap_view->StrokeRect(a_rect);
|
fBitmapView->StrokeRect(rect);
|
||||||
|
|
||||||
m_barberpole_bitmap_view->Sync();
|
fBitmapView->Sync();
|
||||||
m_barberpole_bitmap->Unlock();
|
fBitmap->Unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Activity::LightenBitmapHighColor (rgb_color * a_color)
|
|
||||||
|
void
|
||||||
|
Activity::_LightenBitmapHighColor(rgb_color* color)
|
||||||
{
|
{
|
||||||
a_color->red -= 30;
|
color->red -= 30;
|
||||||
a_color->green -= 30;
|
color->green -= 30;
|
||||||
a_color->blue -= 30;
|
color->blue -= 30;
|
||||||
|
|
||||||
m_barberpole_bitmap_view->SetHighColor(* a_color);
|
fBitmapView->SetHighColor(*color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Activity::CreateBitmap (void)
|
|
||||||
|
void
|
||||||
|
Activity::_CreateBitmap(void)
|
||||||
{
|
{
|
||||||
BRect barberpole_rect = Bounds();
|
BRect rect = Bounds();
|
||||||
m_barberpole_bitmap = new BBitmap(barberpole_rect, B_CMAP8, true);
|
fBitmap = new BBitmap(rect, B_CMAP8, true);
|
||||||
m_barberpole_bitmap_view = new BView(Bounds(), "buffer", B_FOLLOW_NONE, 0);
|
fBitmapView = new BView(Bounds(), "buffer", B_FOLLOW_NONE, 0);
|
||||||
m_barberpole_bitmap->AddChild(m_barberpole_bitmap_view);
|
fBitmap->AddChild(fBitmapView);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Activity::FrameResized (float a_width, float a_height)
|
|
||||||
|
void
|
||||||
|
Activity::FrameResized(float width, float height)
|
||||||
{
|
{
|
||||||
delete m_barberpole_bitmap;
|
delete fBitmap;
|
||||||
CreateBitmap();
|
_CreateBitmap();
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,39 +3,37 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <Window.h>
|
|
||||||
#include <View.h>
|
|
||||||
#include <Box.h>
|
#include <Box.h>
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
|
#include <View.h>
|
||||||
|
#include <Window.h>
|
||||||
|
|
||||||
|
|
||||||
class Activity : public BView
|
class Activity : public BView
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Activity (BRect a_rect, const char * a_name, uint32 a_resizing_mode,
|
Activity(BRect frame, const char* name,
|
||||||
uint32 a_flags);
|
uint32 resizing_mode, uint32 flags);
|
||||||
~Activity ();
|
~Activity();
|
||||||
|
|
||||||
void Start ();
|
void Start();
|
||||||
void Pause ();
|
void Pause();
|
||||||
void Stop ();
|
void Stop();
|
||||||
bool IsRunning ();
|
bool IsRunning();
|
||||||
virtual void Pulse ();
|
virtual void Pulse();
|
||||||
virtual void Draw (BRect a_draw);
|
virtual void Draw(BRect draw);
|
||||||
virtual void FrameResized (float a_width, float a_height);
|
virtual void FrameResized(float width, float height);
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
void CreateBitmap (void);
|
void _CreateBitmap();
|
||||||
void LightenBitmapHighColor (rgb_color * a_color);
|
void _LightenBitmapHighColor(rgb_color* color);
|
||||||
void DrawIntoBitmap (bool running);
|
void _DrawOnBitmap(bool running);
|
||||||
|
|
||||||
bool m_is_running;
|
|
||||||
pattern m_pattern;
|
|
||||||
|
|
||||||
BBitmap * m_barberpole_bitmap;
|
|
||||||
BView * m_barberpole_bitmap_view;
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
|
bool fIsRunning;
|
||||||
|
pattern fPattern;
|
||||||
|
BBitmap* fBitmap;
|
||||||
|
BView* fBitmapView;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // _ACTIVITY_H_
|
||||||
|
|
||||||
|
|||||||
@@ -1,22 +1,21 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2006, Haiku, Inc. All Rights Reserved.
|
* Copyright 2003-2009, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Jonas Sundström, jonas.sundstrom@kirilla.com
|
* Jonas Sundström, [email protected]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "ZipOMaticMisc.h"
|
#include "ZipOMaticMisc.h"
|
||||||
|
|
||||||
#include <Debug.h>
|
|
||||||
#include <Path.h>
|
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <Debug.h>
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
find_and_create_directory(directory_which which, BVolume* volume,
|
FindAndCreateDirectory(directory_which which, BVolume* volume,
|
||||||
const char* relativePath, BPath* fullPath)
|
const char* relativePath, BPath* fullPath)
|
||||||
{
|
{
|
||||||
BPath path;
|
BPath path;
|
||||||
@@ -46,7 +45,7 @@ find_and_create_directory(directory_which which, BVolume* volume,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
error_message(const char* text, int32 status)
|
ErrorMessage(const char* text, int32 status)
|
||||||
{
|
{
|
||||||
PRINT(("%s: %s\n", text, strerror(status)));
|
PRINT(("%s: %s\n", text, strerror(status)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2006, Haiku, Inc. All Rights Reserved.
|
* Copyright 2003-2009, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Jonas Sundström, jonas.sundstrom@kirilla.com
|
* Jonas Sundström, [email protected]
|
||||||
*/
|
*/
|
||||||
#ifndef ZIPOMATIC_MISC_H
|
#ifndef ZIPOMATIC_MISC_H
|
||||||
#define ZIPOMATIC_MISC_H
|
#define ZIPOMATIC_MISC_H
|
||||||
@@ -11,18 +11,19 @@
|
|||||||
|
|
||||||
#include <Directory.h>
|
#include <Directory.h>
|
||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
|
#include <Path.h>
|
||||||
class BPath;
|
#include <Volume.h>
|
||||||
class BVolume;
|
|
||||||
|
|
||||||
|
|
||||||
#define ZIPOMATIC_APP_SIG "application/x-vnd.haiku.zip-o-matic"
|
#define ZIPOMATIC_APP_SIG "application/x-vnd.haiku.zip-o-matic"
|
||||||
#define ZIPOMATIC_APP_NAME "ZipOMatic"
|
|
||||||
|
|
||||||
#define ZIPPO_WINDOW_QUIT 'winq'
|
#define ZIPPO_WINDOW_QUIT 'winq'
|
||||||
|
|
||||||
status_t find_and_create_directory(directory_which which, BVolume* volume = NULL,
|
status_t FindAndCreateDirectory(directory_which which,
|
||||||
const char* relativePath = NULL, BPath* fullPath = NULL);
|
BVolume* volume = NULL, const char* relativePath = NULL,
|
||||||
void error_message(const char* text, int32 status);
|
BPath* fullPath = NULL);
|
||||||
|
|
||||||
|
void ErrorMessage(const char* text, int32 status);
|
||||||
|
|
||||||
#endif // ZIPOMATIC_MISC_H
|
#endif // ZIPOMATIC_MISC_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,42 +1,45 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2006, Haiku, Inc. All Rights Reserved.
|
* Copyright 2003-2009, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Jonas Sundström, jonas.sundstrom@kirilla.com
|
* Jonas Sundström, [email protected]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// TODO: proper locking <<---------
|
// TODO: proper locking <<---------
|
||||||
|
|
||||||
#include "ZipOMaticMisc.h"
|
|
||||||
#include "ZipOMaticSettings.h"
|
#include "ZipOMaticSettings.h"
|
||||||
|
|
||||||
#include <Debug.h>
|
#include <Debug.h>
|
||||||
#include <VolumeRoster.h>
|
|
||||||
#include <FindDirectory.h>
|
|
||||||
#include <Directory.h>
|
#include <Directory.h>
|
||||||
#include <Path.h>
|
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
|
#include <Path.h>
|
||||||
|
#include <VolumeRoster.h>
|
||||||
|
|
||||||
|
#include "ZipOMaticMisc.h"
|
||||||
|
|
||||||
|
|
||||||
ZippoSettings::ZippoSettings()
|
ZippoSettings::ZippoSettings()
|
||||||
:
|
:
|
||||||
fBaseDir(B_USER_SETTINGS_DIRECTORY)
|
fBaseDir(B_USER_SETTINGS_DIRECTORY)
|
||||||
{
|
{
|
||||||
PRINT(("ZippoSettings()\n"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ZippoSettings::ZippoSettings(BMessage& message)
|
ZippoSettings::ZippoSettings(BMessage& message)
|
||||||
: BMessage(message),
|
:
|
||||||
|
BMessage(message),
|
||||||
fBaseDir(B_USER_SETTINGS_DIRECTORY)
|
fBaseDir(B_USER_SETTINGS_DIRECTORY)
|
||||||
{
|
{
|
||||||
PRINT(("ZippoSettings(a_message)\n"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ZippoSettings::~ZippoSettings()
|
ZippoSettings::~ZippoSettings()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -46,17 +49,16 @@ ZippoSettings::SetTo(const char* filename, BVolume* volume,
|
|||||||
{
|
{
|
||||||
status_t status = B_OK;
|
status_t status = B_OK;
|
||||||
|
|
||||||
// copy to members
|
|
||||||
fBaseDir = baseDir;
|
fBaseDir = baseDir;
|
||||||
fRelativePath = relativePath;
|
fRelativePath = relativePath;
|
||||||
fFilename = filename;
|
fFilename = filename;
|
||||||
|
|
||||||
// sanity check
|
|
||||||
if (volume == NULL) {
|
if (volume == NULL) {
|
||||||
BVolumeRoster volumeRoster;
|
BVolumeRoster volumeRoster;
|
||||||
volumeRoster.GetBootVolume(&fVolume);
|
volumeRoster.GetBootVolume(&fVolume);
|
||||||
} else
|
} else {
|
||||||
fVolume = *volume;
|
fVolume = *volume;
|
||||||
|
}
|
||||||
|
|
||||||
status = fVolume.InitCheck();
|
status = fVolume.InitCheck();
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
@@ -77,8 +79,6 @@ ZippoSettings::InitCheck()
|
|||||||
status_t
|
status_t
|
||||||
ZippoSettings::ReadSettings()
|
ZippoSettings::ReadSettings()
|
||||||
{
|
{
|
||||||
PRINT(("ZippoSettings::ReadSettings()\n"));
|
|
||||||
|
|
||||||
BFile file;
|
BFile file;
|
||||||
status_t status = _GetSettingsFile(&file, B_READ_ONLY);
|
status_t status = _GetSettingsFile(&file, B_READ_ONLY);
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
@@ -91,8 +91,6 @@ ZippoSettings::ReadSettings()
|
|||||||
status_t
|
status_t
|
||||||
ZippoSettings::WriteSettings()
|
ZippoSettings::WriteSettings()
|
||||||
{
|
{
|
||||||
PRINT(("ZippoSettings::WriteSettings()\n"));
|
|
||||||
|
|
||||||
BFile file;
|
BFile file;
|
||||||
status_t status = _GetSettingsFile(&file, B_WRITE_ONLY | B_ERASE_FILE);
|
status_t status = _GetSettingsFile(&file, B_WRITE_ONLY | B_ERASE_FILE);
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
@@ -106,7 +104,7 @@ status_t
|
|||||||
ZippoSettings::_GetSettingsFile(BFile* file, uint32 openMode)
|
ZippoSettings::_GetSettingsFile(BFile* file, uint32 openMode)
|
||||||
{
|
{
|
||||||
BPath path;
|
BPath path;
|
||||||
status_t status = find_and_create_directory(fBaseDir, &fVolume,
|
status_t status = FindAndCreateDirectory(fBaseDir, &fVolume,
|
||||||
fRelativePath.String(), &path);
|
fRelativePath.String(), &path);
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2006, Haiku, Inc. All Rights Reserved.
|
* Copyright 2003-2009, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Jonas Sundström, jonas.sundstrom@kirilla.com
|
* Jonas Sundström, [email protected]
|
||||||
*/
|
*/
|
||||||
#ifndef ZIPOMATIC_SETTINGS_H
|
#ifndef _ZIPOMATIC_SETTINGS_H
|
||||||
#define ZIPOMATIC_SETTINGS_H
|
#define _ZIPOMATIC_SETTINGS_H
|
||||||
|
|
||||||
|
|
||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
@@ -16,27 +16,28 @@
|
|||||||
|
|
||||||
|
|
||||||
class ZippoSettings : public BMessage {
|
class ZippoSettings : public BMessage {
|
||||||
public:
|
public:
|
||||||
ZippoSettings();
|
ZippoSettings();
|
||||||
ZippoSettings(BMessage& message);
|
ZippoSettings(BMessage& message);
|
||||||
~ZippoSettings();
|
~ZippoSettings();
|
||||||
|
|
||||||
status_t SetTo(const char* filename, BVolume* volume = NULL,
|
status_t SetTo(const char* filename, BVolume* volume = NULL,
|
||||||
directory_which baseDir = B_USER_SETTINGS_DIRECTORY,
|
directory_which baseDir =
|
||||||
const char* relativePath = NULL);
|
B_USER_SETTINGS_DIRECTORY,
|
||||||
|
const char* relativePath = NULL);
|
||||||
|
status_t InitCheck();
|
||||||
|
|
||||||
|
status_t ReadSettings();
|
||||||
|
status_t WriteSettings();
|
||||||
|
|
||||||
status_t InitCheck();
|
private:
|
||||||
|
status_t _GetSettingsFile(BFile* file, uint32 openMode);
|
||||||
|
|
||||||
status_t ReadSettings();
|
BVolume fVolume;
|
||||||
status_t WriteSettings();
|
directory_which fBaseDir;
|
||||||
|
BString fRelativePath;
|
||||||
private:
|
BString fFilename;
|
||||||
status_t _GetSettingsFile(BFile* file, uint32 openMode);
|
|
||||||
|
|
||||||
BVolume fVolume;
|
|
||||||
directory_which fBaseDir;
|
|
||||||
BString fRelativePath;
|
|
||||||
BString fFilename;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ZIPOMATIC_SETTINGS_H
|
#endif // _ZIPOMATIC_SETTINGS_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,87 +1,82 @@
|
|||||||
// license: public domain
|
// license: public domain
|
||||||
// authors: jonas.sundstrom@kirilla.com
|
// authors: Jonas Sundström, jonas@kirilla.com
|
||||||
|
|
||||||
|
|
||||||
#include "ZipOMaticActivity.h"
|
|
||||||
#include "ZipOMaticView.h"
|
#include "ZipOMaticView.h"
|
||||||
|
|
||||||
ZippoView::ZippoView (BRect a_rect)
|
|
||||||
: BBox (a_rect, "zipomatic_view", B_FOLLOW_ALL,
|
ZippoView::ZippoView(BRect rect)
|
||||||
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP,
|
:
|
||||||
B_PLAIN_BORDER),
|
BBox(rect, "zipomatic_view", B_FOLLOW_ALL,
|
||||||
m_stop_button (NULL)
|
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, B_PLAIN_BORDER),
|
||||||
|
fStopButton(NULL)
|
||||||
{
|
{
|
||||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
|
||||||
// "Stop" button
|
fStopButton = new BButton(
|
||||||
BRect button_rect (a_rect.right-82, a_rect.bottom-32, a_rect.right-12, a_rect.bottom-12);
|
BRect(rect.right-82, rect.bottom-32, rect.right-12, rect.bottom-12),
|
||||||
m_stop_button = new BButton(button_rect,"stop_button","Stop", new BMessage(B_QUIT_REQUESTED), B_FOLLOW_RIGHT);
|
"stop_button", "Stop", new BMessage(B_QUIT_REQUESTED), B_FOLLOW_RIGHT);
|
||||||
m_stop_button->SetEnabled(false);
|
fStopButton->SetEnabled(false);
|
||||||
AddChild(m_stop_button);
|
AddChild(fStopButton);
|
||||||
|
|
||||||
// activity view
|
BRect activity_rect(rect.left+14, rect.top+15, rect.right-15, rect.top+31);
|
||||||
BRect activity_rect (a_rect.left+14, a_rect.top+15, a_rect.right-15, a_rect.top+31);
|
fActivityView = new Activity(activity_rect, "activity_view",
|
||||||
m_activity_view = new Activity (activity_rect, "activity_view", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS);
|
B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW | B_FRAME_EVENTS);
|
||||||
AddChild(m_activity_view);
|
AddChild(fActivityView);
|
||||||
|
|
||||||
// text views
|
BRect archive_rect(rect.left+14, rect.top+30, rect.right-15, rect.top+47);
|
||||||
BRect archive_rect (a_rect.left+14, a_rect.top+30, a_rect.right-15, a_rect.top+47);
|
fArchiveNameView = new BStringView(archive_rect, "archive_text", " ",
|
||||||
m_archive_name_view = new BStringView (archive_rect, "archive_text", " ", B_FOLLOW_LEFT_RIGHT);
|
B_FOLLOW_LEFT_RIGHT);
|
||||||
AddChild (m_archive_name_view);
|
AddChild(fArchiveNameView);
|
||||||
|
|
||||||
BRect ouput_rect (a_rect.left+14, a_rect.top+47, a_rect.right-15, a_rect.top+66);
|
|
||||||
m_zip_output_view = new BStringView (ouput_rect, "output_text", "Drop files to zip.", B_FOLLOW_LEFT_RIGHT);
|
|
||||||
AddChild (m_zip_output_view);
|
|
||||||
|
|
||||||
|
BRect ouput_rect(rect.left+14, rect.top+47, rect.right-15, rect.top+66);
|
||||||
|
fZipOutputView = new BStringView(ouput_rect, "output_text",
|
||||||
|
"Drop files to zip.", B_FOLLOW_LEFT_RIGHT);
|
||||||
|
AddChild(fZipOutputView);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZippoView::Draw (BRect a_update_rect)
|
|
||||||
{
|
|
||||||
BBox::Draw(a_update_rect);
|
|
||||||
// fBox->DrawBitmap(fIconBitmap,BPoint(178,26));
|
|
||||||
|
|
||||||
const rgb_color grey_accent = {128,128,128,255};
|
void ZippoView::Draw(BRect rect)
|
||||||
const rgb_color darker_grey = {108,108,108,255};
|
{
|
||||||
const rgb_color plain_white = {255,255,255,255};
|
BBox::Draw(rect);
|
||||||
const rgb_color deep_black = {255,255,255,255};
|
|
||||||
|
const rgb_color grey_accent = {128,128,128,255};
|
||||||
|
const rgb_color darker_grey = {108,108,108,255};
|
||||||
|
const rgb_color plain_white = {255,255,255,255};
|
||||||
|
const rgb_color black = {0, 0, 0, 255};
|
||||||
|
|
||||||
// "preflet" bottom, right grey accent lines
|
// "preflet" bottom, right grey accent lines
|
||||||
|
|
||||||
SetHighColor(grey_accent);
|
SetHighColor(grey_accent);
|
||||||
|
|
||||||
StrokeLine (BPoint(Bounds().right, Bounds().top),
|
StrokeLine(BPoint(Bounds().right, Bounds().top),
|
||||||
BPoint(Bounds().right, Bounds().bottom));
|
BPoint(Bounds().right, Bounds().bottom));
|
||||||
|
|
||||||
StrokeLine (BPoint(Bounds().left, Bounds().bottom),
|
StrokeLine(BPoint(Bounds().left, Bounds().bottom),
|
||||||
BPoint(Bounds().right, Bounds().bottom));
|
BPoint(Bounds().right, Bounds().bottom));
|
||||||
|
|
||||||
// divider
|
// divider
|
||||||
SetHighColor(darker_grey);
|
SetHighColor(darker_grey);
|
||||||
StrokeLine (BPoint(Bounds().left+15, Bounds().top+71),
|
StrokeLine(BPoint(Bounds().left+15, Bounds().top+71),
|
||||||
BPoint(Bounds().right-16, Bounds().top+71));
|
BPoint(Bounds().right-16, Bounds().top+71));
|
||||||
|
|
||||||
SetHighColor(plain_white);
|
SetHighColor(plain_white);
|
||||||
StrokeLine (BPoint(Bounds().left+15, Bounds().top+72),
|
StrokeLine(BPoint(Bounds().left+15, Bounds().top+72),
|
||||||
BPoint(Bounds().right-16, Bounds().top+72));
|
BPoint(Bounds().right-16, Bounds().top+72));
|
||||||
|
|
||||||
// text
|
SetHighColor(black);
|
||||||
SetHighColor(deep_black);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZippoView::AllAttached (void)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void ZippoView::FrameMoved (BPoint a_point)
|
void
|
||||||
{
|
ZippoView::FrameMoved(BPoint point)
|
||||||
Invalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ZippoView::FrameResized (float a_width, float a_height)
|
|
||||||
{
|
{
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ZippoView::FrameResized(float width, float height)
|
||||||
|
{
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,27 +5,23 @@
|
|||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
#include <StringView.h>
|
#include <StringView.h>
|
||||||
|
|
||||||
class Activity;
|
#include "ZipOMaticActivity.h"
|
||||||
|
|
||||||
|
|
||||||
class ZippoView : public BBox
|
class ZippoView : public BBox
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ZippoView (BRect frame);
|
ZippoView(BRect frame);
|
||||||
|
|
||||||
virtual void Draw (BRect frame);
|
virtual void Draw(BRect frame);
|
||||||
virtual void AllAttached (void);
|
virtual void FrameMoved(BPoint point);
|
||||||
virtual void FrameMoved (BPoint a_point);
|
virtual void FrameResized(float width, float height);
|
||||||
virtual void FrameResized (float a_width, float a_height);
|
|
||||||
|
|
||||||
BButton * m_stop_button;
|
BButton* fStopButton;
|
||||||
Activity * m_activity_view;
|
Activity* fActivityView;
|
||||||
|
BStringView* fArchiveNameView;
|
||||||
BStringView * m_archive_name_view;
|
BStringView* fZipOutputView;
|
||||||
BStringView * m_zip_output_view;
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __ZIPPO_VIEW_H__
|
#endif // __ZIPPO_VIEW_H__
|
||||||
|
|
||||||
|
|||||||
@@ -1,336 +1,304 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2006, Haiku, Inc. All Rights Reserved.
|
* Copyright 2003-2009, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Jonas Sundström, jonas.sundstrom@kirilla.com
|
* Jonas Sundström, [email protected]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <Debug.h>
|
#include "ZipOMaticWindow.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Roster.h>
|
|
||||||
#include <InterfaceKit.h>
|
|
||||||
#include <String.h>
|
|
||||||
#include <FindDirectory.h>
|
|
||||||
#include <Directory.h>
|
#include <Directory.h>
|
||||||
#include <Path.h>
|
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
|
#include <FindDirectory.h>
|
||||||
|
#include <InterfaceKit.h>
|
||||||
|
#include <Path.h>
|
||||||
|
#include <Roster.h>
|
||||||
|
#include <String.h>
|
||||||
|
|
||||||
#include "ZipOMatic.h"
|
#include "ZipOMatic.h"
|
||||||
#include "ZipOMaticActivity.h"
|
#include "ZipOMaticActivity.h"
|
||||||
#include "ZipOMaticMisc.h"
|
#include "ZipOMaticMisc.h"
|
||||||
#include "ZipOMaticView.h"
|
#include "ZipOMaticView.h"
|
||||||
#include "ZipOMaticWindow.h"
|
|
||||||
#include "ZipperThread.h"
|
#include "ZipperThread.h"
|
||||||
|
|
||||||
|
|
||||||
ZippoWindow::ZippoWindow(BMessage * a_message)
|
ZippoWindow::ZippoWindow(BMessage* message)
|
||||||
: BWindow(BRect(200,200,430,310), "Zip-O-Matic", B_TITLED_WINDOW, B_NOT_V_RESIZABLE), // | B_NOT_ZOOMABLE),
|
:
|
||||||
m_zippo_settings (),
|
BWindow(BRect(200, 200, 430, 310), "Zip-O-Matic", B_TITLED_WINDOW,
|
||||||
m_zipper_thread (NULL),
|
B_NOT_V_RESIZABLE),
|
||||||
m_got_refs_at_window_startup (false),
|
fView(NULL),
|
||||||
m_zipping_was_stopped (false),
|
fSettings(),
|
||||||
m_alert_invoker_message (new BMessage ('alrt')),
|
fThread(NULL),
|
||||||
m_alert_window_invoker (new BInvoker (m_alert_invoker_message, NULL, this))
|
fWindowGotRefs(false),
|
||||||
|
fZippingWasStopped(false),
|
||||||
|
fWindowInvoker(new BInvoker(new BMessage('alrt'), NULL, this))
|
||||||
{
|
{
|
||||||
PRINT(("ZippoWindow()\n"));
|
status_t status = B_OK;
|
||||||
|
|
||||||
// Settings
|
status = fSettings.SetTo("ZipOMatic.msg");
|
||||||
status_t status = B_OK;
|
|
||||||
|
|
||||||
status = m_zippo_settings.SetTo("ZipOMatic.msg");
|
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
error_message("ZippoWindow() - m_zippo_settings.SetTo()", status);
|
ErrorMessage("fSettings.SetTo()", status);
|
||||||
|
|
||||||
status = m_zippo_settings.InitCheck();
|
status = fSettings.InitCheck();
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
error_message("ZippoWindow() - m_zippo_settings.InitCheck()", status);
|
ErrorMessage("fSettings.InitCheck()", status);
|
||||||
|
|
||||||
// Interface
|
fView = new ZippoView(Bounds());
|
||||||
zippoview = new ZippoView(Bounds());
|
AddChild(fView);
|
||||||
|
|
||||||
AddChild (zippoview);
|
|
||||||
|
|
||||||
SetSizeLimits(Bounds().Width(), 15000, Bounds().Height(), Bounds().Height());
|
SetSizeLimits(Bounds().Width(), 15000, Bounds().Height(),
|
||||||
|
Bounds().Height());
|
||||||
|
|
||||||
// Settings, (on-screen location of window)
|
_ReadSettings();
|
||||||
ReadSettings();
|
|
||||||
|
|
||||||
// Start zipper thread
|
if (message != NULL)
|
||||||
if (a_message != NULL)
|
|
||||||
{
|
{
|
||||||
m_got_refs_at_window_startup = true;
|
fWindowGotRefs = true;
|
||||||
StartZipping (a_message);
|
_StartZipping(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ZippoWindow::~ZippoWindow()
|
ZippoWindow::~ZippoWindow()
|
||||||
{
|
{
|
||||||
PRINT(("ZippoWindow::~ZippoWindow()\n"));
|
delete fWindowInvoker;
|
||||||
|
|
||||||
//delete m_alert_invoker_message;
|
|
||||||
delete m_alert_window_invoker;
|
|
||||||
|
|
||||||
// anything left to clean up?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ZippoWindow::MessageReceived (BMessage * a_message)
|
ZippoWindow::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
switch(a_message->what)
|
switch (message->what) {
|
||||||
{
|
|
||||||
|
|
||||||
case B_REFS_RECEIVED:
|
case B_REFS_RECEIVED:
|
||||||
StartZipping (a_message);
|
_StartZipping(message);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_SIMPLE_DATA:
|
case B_SIMPLE_DATA:
|
||||||
if (IsZipping())
|
if (IsZipping()) {
|
||||||
{
|
message->what = B_REFS_RECEIVED;
|
||||||
a_message->what = B_REFS_RECEIVED;
|
be_app_messenger.SendMessage(message);
|
||||||
be_app_messenger.SendMessage(a_message);
|
} else {
|
||||||
}
|
_StartZipping(message);
|
||||||
else
|
}
|
||||||
StartZipping (a_message);
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
case 'exit': // thread has finished (finished, quit, killed, we don't know)
|
case 'exit':
|
||||||
// reset window state
|
// thread has finished - (finished, quit, killed, we don't know)
|
||||||
{
|
fThread = NULL;
|
||||||
m_zipper_thread = NULL;
|
fView->fActivityView->Stop();
|
||||||
zippoview->m_activity_view->Stop();
|
fView->fStopButton->SetEnabled(false);
|
||||||
zippoview->m_stop_button->SetEnabled(false);
|
fView->fArchiveNameView->SetText(" ");
|
||||||
zippoview->m_archive_name_view->SetText(" ");
|
if (fZippingWasStopped)
|
||||||
if (m_zipping_was_stopped)
|
fView->fZipOutputView->SetText("Stopped");
|
||||||
zippoview->m_zip_output_view->SetText("Stopped");
|
else
|
||||||
else
|
fView->fZipOutputView->SetText("Archive created OK");
|
||||||
zippoview->m_zip_output_view->SetText("Archive created OK");
|
|
||||||
|
_CloseWindowOrKeepOpen();
|
||||||
CloseWindowOrKeepOpen();
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'exrr': // thread has finished
|
case 'exrr': // thread has finished - badly
|
||||||
// reset window state
|
fThread = NULL;
|
||||||
|
fView->fActivityView->Stop();
|
||||||
m_zipper_thread = NULL;
|
fView->fStopButton->SetEnabled(false);
|
||||||
zippoview->m_activity_view->Stop();
|
fView->fArchiveNameView->SetText("");
|
||||||
zippoview->m_stop_button->SetEnabled(false);
|
fView->fZipOutputView->SetText("Error creating archive");
|
||||||
zippoview->m_archive_name_view->SetText("");
|
break;
|
||||||
zippoview->m_zip_output_view->SetText("Error creating archive");
|
|
||||||
//CloseWindowOrKeepOpen();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'strt':
|
case 'strt':
|
||||||
{
|
{
|
||||||
BString archive_filename;
|
BString string;
|
||||||
if (a_message->FindString("archive_filename", & archive_filename) == B_OK)
|
if (message->FindString("archive_filename", &string) == B_OK)
|
||||||
zippoview->m_archive_name_view->SetText(archive_filename.String());
|
fView->fArchiveNameView->SetText(string.String());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'outp':
|
case 'outp':
|
||||||
{
|
{
|
||||||
BString zip_output;
|
BString string;
|
||||||
if (a_message->FindString("zip_output", & zip_output) == B_OK)
|
if (message->FindString("zip_output", &string) == B_OK)
|
||||||
zippoview->m_zip_output_view->SetText(zip_output.String());
|
fView->fZipOutputView->SetText(string.String());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'alrt':
|
case 'alrt':
|
||||||
{
|
{
|
||||||
int32 which_button = -1;
|
int32 which_button = -1;
|
||||||
if (a_message->FindInt32("which", & which_button) == B_OK)
|
if (message->FindInt32("which", &which_button) == B_OK) {
|
||||||
if (which_button == 0)
|
if (which_button == 0) {
|
||||||
StopZipping();
|
_StopZipping();
|
||||||
else
|
} else {
|
||||||
{
|
if (fThread != NULL)
|
||||||
if (m_zipper_thread != NULL)
|
fThread->ResumeExternalZip();
|
||||||
m_zipper_thread->ResumeExternalZip();
|
|
||||||
|
fView->fActivityView->Start();
|
||||||
zippoview->m_activity_view->Start();
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default: BWindow::MessageReceived(a_message); break;
|
default:
|
||||||
|
BWindow::MessageReceived(message);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ZippoWindow::QuitRequested (void)
|
ZippoWindow::QuitRequested()
|
||||||
{
|
{
|
||||||
PRINT(("ZippoWindow::QuitRequested()\n"));
|
if (fThread == NULL) {
|
||||||
|
_WriteSettings();
|
||||||
if (m_zipper_thread == NULL)
|
|
||||||
{
|
|
||||||
WriteSettings();
|
|
||||||
be_app_messenger.SendMessage(ZIPPO_WINDOW_QUIT);
|
be_app_messenger.SendMessage(ZIPPO_WINDOW_QUIT);
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
else
|
if (fThread != NULL)
|
||||||
{
|
fThread->SuspendExternalZip();
|
||||||
if (m_zipper_thread != NULL)
|
|
||||||
m_zipper_thread->SuspendExternalZip();
|
|
||||||
|
|
||||||
zippoview->m_activity_view->Pause();
|
fView->fActivityView->Pause();
|
||||||
|
|
||||||
BAlert * quit_requester = new BAlert ("Stop or Continue", "Are you sure you want to "
|
BAlert* alert = new BAlert("Stop or Continue",
|
||||||
"stop creating this archive?", "Stop", "Continue",
|
"Are you sure you want to stop creating this archive?", "Stop",
|
||||||
NULL, B_WIDTH_AS_USUAL, B_INFO_ALERT);
|
"Continue", NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
||||||
quit_requester->Go(m_alert_window_invoker);
|
alert->Go(fWindowInvoker);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
ZippoWindow::ReadSettings (void)
|
ZippoWindow::_ReadSettings()
|
||||||
{
|
{
|
||||||
status_t status = B_OK;
|
status_t status = B_OK;
|
||||||
|
|
||||||
status = m_zippo_settings.InitCheck();
|
status = fSettings.InitCheck();
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
error_message("m_zippo_settings.InitCheck()", status);
|
ErrorMessage("fSettings.InitCheck()", status);
|
||||||
|
|
||||||
status = m_zippo_settings.ReadSettings();
|
status = fSettings.ReadSettings();
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
error_message("m_zippo_settings.ReadSettings()", status);
|
ErrorMessage("fSettings.ReadSettings()", status);
|
||||||
|
|
||||||
BRect window_rect;
|
BRect windowRect;
|
||||||
|
|
||||||
status = m_zippo_settings.FindRect("window_rect", & window_rect);
|
status = fSettings.FindRect("windowRect", &windowRect);
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
{
|
{
|
||||||
error_message("m_settings_message->FindRect(window_rect)", status);
|
ErrorMessage("fSettings.FindRect(windowRect)", status);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResizeTo (window_rect.Width(), window_rect.Height());
|
ResizeTo(windowRect.Width(), windowRect.Height());
|
||||||
MoveTo (window_rect.LeftTop());
|
MoveTo(windowRect.LeftTop());
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
ZippoWindow::WriteSettings (void)
|
ZippoWindow::_WriteSettings()
|
||||||
{
|
{
|
||||||
status_t status = B_OK;
|
status_t status = B_OK;
|
||||||
|
|
||||||
status = m_zippo_settings.InitCheck();
|
status = fSettings.InitCheck();
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
error_message("m_zippo_settings.InitCheck()", status);
|
ErrorMessage("fSettings.InitCheck()", status);
|
||||||
|
|
||||||
status = m_zippo_settings.MakeEmpty();
|
status = fSettings.MakeEmpty();
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
error_message("m_zippo_settings.MakeEmpty()", status);
|
ErrorMessage("fSettings.MakeEmpty()", status);
|
||||||
|
|
||||||
status = m_zippo_settings.AddRect("window_rect", Frame());
|
status = fSettings.AddRect("windowRect", Frame());
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
{
|
{
|
||||||
error_message("m_settings_message->AddRect(window_rect)", status);
|
ErrorMessage("fSettings.AddRect(windowRect)", status);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = m_zippo_settings.WriteSettings();
|
status = fSettings.WriteSettings();
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
{
|
{
|
||||||
error_message("m_zippo_settings.WriteSettings()", status);
|
ErrorMessage("fSettings.WriteSettings()", status);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
ZippoWindow::StartZipping (BMessage * a_message)
|
|
||||||
{
|
|
||||||
PRINT(("ZippoWindow::StartZipping()\n"));
|
|
||||||
|
|
||||||
zippoview->m_stop_button->SetEnabled(true);
|
|
||||||
zippoview->m_activity_view->Start();
|
|
||||||
|
|
||||||
m_zipper_thread = new ZipperThread (a_message, this);
|
|
||||||
m_zipper_thread->Start();
|
|
||||||
|
|
||||||
m_zipping_was_stopped = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ZippoWindow::StopZipping (void)
|
ZippoWindow::_StartZipping(BMessage* message)
|
||||||
{
|
{
|
||||||
PRINT(("ZippoWindow::StopZipping()\n"));
|
fView->fStopButton->SetEnabled(true);
|
||||||
|
fView->fActivityView->Start();
|
||||||
|
|
||||||
m_zipping_was_stopped = true;
|
fThread = new ZipperThread(message, this);
|
||||||
|
fThread->Start();
|
||||||
zippoview->m_stop_button->SetEnabled(false);
|
|
||||||
|
|
||||||
zippoview->m_activity_view->Stop();
|
fZippingWasStopped = false;
|
||||||
|
|
||||||
m_zipper_thread->InterruptExternalZip();
|
|
||||||
m_zipper_thread->Quit();
|
|
||||||
|
|
||||||
status_t status = B_OK;
|
|
||||||
m_zipper_thread->WaitForThread (& status);
|
|
||||||
m_zipper_thread = NULL;
|
|
||||||
|
|
||||||
zippoview->m_archive_name_view->SetText(" ");
|
|
||||||
zippoview->m_zip_output_view->SetText("Stopped");
|
|
||||||
|
|
||||||
CloseWindowOrKeepOpen();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ZippoWindow::_StopZipping()
|
||||||
|
{
|
||||||
|
fZippingWasStopped = true;
|
||||||
|
|
||||||
|
fView->fStopButton->SetEnabled(false);
|
||||||
|
fView->fActivityView->Stop();
|
||||||
|
|
||||||
|
fThread->InterruptExternalZip();
|
||||||
|
fThread->Quit();
|
||||||
|
|
||||||
|
status_t status = B_OK;
|
||||||
|
fThread->WaitForThread(&status);
|
||||||
|
fThread = NULL;
|
||||||
|
|
||||||
|
fView->fArchiveNameView->SetText(" ");
|
||||||
|
fView->fZipOutputView->SetText("Stopped");
|
||||||
|
|
||||||
|
_CloseWindowOrKeepOpen();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ZippoWindow::IsZipping (void)
|
ZippoWindow::IsZipping()
|
||||||
{
|
{
|
||||||
if (m_zipper_thread == NULL)
|
if (fThread == NULL)
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ZippoWindow::CloseWindowOrKeepOpen (void)
|
ZippoWindow::_CloseWindowOrKeepOpen()
|
||||||
{
|
{
|
||||||
if (m_got_refs_at_window_startup)
|
if (fWindowGotRefs)
|
||||||
PostMessage(B_QUIT_REQUESTED);
|
PostMessage(B_QUIT_REQUESTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ZippoWindow::Zoom (BPoint origin, float width, float height)
|
ZippoWindow::Zoom(BPoint origin, float width, float height)
|
||||||
{
|
{
|
||||||
/*
|
if (IsZipping()) {
|
||||||
float archive_name_view_preferred_width;
|
float archiveNameWidth =
|
||||||
float zip_output_view_preferred_width;
|
fView->StringWidth(fView->fArchiveNameView->Text());
|
||||||
float throw_away_height;
|
float zipOutputWidth =
|
||||||
zippoview->GetPreferredSize(& archive_name_view_preferred_width, & throw_away_height);
|
fView->StringWidth(fView->fZipOutputView->Text());
|
||||||
zippoview->GetPreferredSize(& zip_output_view_preferred_width, & throw_away_height);
|
|
||||||
*/
|
|
||||||
|
|
||||||
// BStringView::GetPreferredSize appears to be broken,
|
|
||||||
// so we have to use BView::StringWidth() instead
|
|
||||||
|
|
||||||
if (IsZipping())
|
|
||||||
{
|
|
||||||
float archive_name_view_preferred_width = zippoview->StringWidth(zippoview->m_archive_name_view->Text());
|
|
||||||
float zip_output_view_preferred_width = zippoview->StringWidth(zippoview->m_zip_output_view->Text());
|
|
||||||
|
|
||||||
float the_wide_string;
|
if (zipOutputWidth > archiveNameWidth)
|
||||||
|
ResizeTo(zipOutputWidth, Bounds().Height());
|
||||||
if (zip_output_view_preferred_width > archive_name_view_preferred_width)
|
|
||||||
the_wide_string = zip_output_view_preferred_width;
|
|
||||||
else
|
else
|
||||||
the_wide_string = archive_name_view_preferred_width;
|
ResizeTo(archiveNameWidth, Bounds().Height());
|
||||||
|
|
||||||
ResizeTo(the_wide_string, Bounds().Height());
|
} else {
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ResizeTo(230,110);
|
ResizeTo(230,110);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,46 +1,48 @@
|
|||||||
#ifndef __ZIPPO_WINDOW_H__
|
#ifndef _ZIPOMATIC_WINDOW_H
|
||||||
#define __ZIPPO_WINDOW_H__
|
#define _ZIPOMATIC_WINDOW_H
|
||||||
|
|
||||||
|
|
||||||
#include <Window.h>
|
|
||||||
#include <MenuBar.h>
|
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
#include <Menu.h>
|
#include <Menu.h>
|
||||||
|
#include <MenuBar.h>
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
|
#include <Window.h>
|
||||||
|
|
||||||
#include "ZipOMaticSettings.h"
|
#include "ZipOMaticSettings.h"
|
||||||
class ZippoView;
|
#include "ZipOMaticView.h"
|
||||||
class ZipperThread;
|
#include "ZipperThread.h"
|
||||||
|
|
||||||
|
|
||||||
class ZippoWindow : public BWindow
|
class ZippoWindow : public BWindow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ZippoWindow (BMessage * a_message = NULL);
|
ZippoWindow(BMessage* message = NULL);
|
||||||
~ZippoWindow (void);
|
~ZippoWindow();
|
||||||
virtual void MessageReceived (BMessage * a_message);
|
|
||||||
virtual bool QuitRequested (void);
|
virtual void MessageReceived(BMessage* message);
|
||||||
virtual void Zoom (BPoint origin, float width, float height);
|
virtual bool QuitRequested();
|
||||||
|
virtual void Zoom(BPoint origin, float width, float height);
|
||||||
|
|
||||||
bool IsZipping (void);
|
bool IsZipping();
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
status_t ReadSettings (void);
|
private:
|
||||||
status_t WriteSettings (void);
|
status_t _ReadSettings();
|
||||||
|
status_t _WriteSettings();
|
||||||
|
|
||||||
void StartZipping (BMessage * a_message);
|
void _StartZipping(BMessage* message);
|
||||||
void StopZipping (void);
|
void _StopZipping();
|
||||||
|
|
||||||
void CloseWindowOrKeepOpen (void);
|
void _CloseWindowOrKeepOpen();
|
||||||
|
|
||||||
ZippoView * zippoview;
|
ZippoView* fView;
|
||||||
ZippoSettings m_zippo_settings;
|
ZippoSettings fSettings;
|
||||||
ZipperThread * m_zipper_thread;
|
ZipperThread* fThread;
|
||||||
|
|
||||||
bool m_got_refs_at_window_startup;
|
bool fWindowGotRefs;
|
||||||
bool m_zipping_was_stopped;
|
bool fZippingWasStopped;
|
||||||
|
|
||||||
BMessage * m_alert_invoker_message;
|
BInvoker* fWindowInvoker;
|
||||||
BInvoker * m_alert_window_invoker;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __ZIPPO_WINDOW_H__
|
#endif // _ZIPOMATIC_WINDOW_H
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
#include "ZipOMaticWindow.h"
|
#include "ZipOMaticWindow.h"
|
||||||
|
|
||||||
|
|
||||||
ZipperThread::ZipperThread (BMessage* refsMessage, BWindow* window)
|
ZipperThread::ZipperThread(BMessage* refsMessage, BWindow* window)
|
||||||
:
|
:
|
||||||
GenericThread("ZipperThread", B_NORMAL_PRIORITY, refsMessage),
|
GenericThread("ZipperThread", B_NORMAL_PRIORITY, refsMessage),
|
||||||
fWindowMessenger(window),
|
fWindowMessenger(window),
|
||||||
@@ -61,7 +61,7 @@ ZipperThread::ThreadStartup()
|
|||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
for (int index = 0; index < refCount; index++) {
|
for (int index = 0; index < refCount; index++) {
|
||||||
fThreadDataStore->FindRef("refs", index, &ref);
|
fThreadDataStore->FindRef("refs", index, &ref);
|
||||||
|
|
||||||
if (index > 0) {
|
if (index > 0) {
|
||||||
@@ -109,7 +109,7 @@ ZipperThread::ThreadStartup()
|
|||||||
argv[2] = strdup(archiveName.String());
|
argv[2] = strdup(archiveName.String());
|
||||||
|
|
||||||
// files to zip
|
// files to zip
|
||||||
for (int index = 0; index < refCount; index++) {
|
for (int index = 0; index < refCount; index++) {
|
||||||
fThreadDataStore->FindRef("refs", index, &ref);
|
fThreadDataStore->FindRef("refs", index, &ref);
|
||||||
|
|
||||||
if (sameFolder) {
|
if (sameFolder) {
|
||||||
@@ -190,7 +190,7 @@ ZipperThread::ThreadShutdown()
|
|||||||
void
|
void
|
||||||
ZipperThread::ThreadStartupFailed(status_t status)
|
ZipperThread::ThreadStartupFailed(status_t status)
|
||||||
{
|
{
|
||||||
error_message("ZipperThread::ThreadStartupFailed() \n", status);
|
ErrorMessage("ZipperThread::ThreadStartupFailed() \n", status);
|
||||||
Quit();
|
Quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,7 +198,7 @@ ZipperThread::ThreadStartupFailed(status_t status)
|
|||||||
void
|
void
|
||||||
ZipperThread::ExecuteUnitFailed(status_t status)
|
ZipperThread::ExecuteUnitFailed(status_t status)
|
||||||
{
|
{
|
||||||
error_message("ZipperThread::ExecuteUnitFailed() \n", status);
|
ErrorMessage("ZipperThread::ExecuteUnitFailed() \n", status);
|
||||||
|
|
||||||
if (status == EOF) {
|
if (status == EOF) {
|
||||||
// thread has finished, been quit or killed, we don't know
|
// thread has finished, been quit or killed, we don't know
|
||||||
@@ -215,7 +215,7 @@ ZipperThread::ExecuteUnitFailed(status_t status)
|
|||||||
void
|
void
|
||||||
ZipperThread::ThreadShutdownFailed(status_t status)
|
ZipperThread::ThreadShutdownFailed(status_t status)
|
||||||
{
|
{
|
||||||
error_message("ZipperThread::ThreadShutdownFailed() \n", status);
|
ErrorMessage("ZipperThread::ThreadShutdownFailed() \n", status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user