* Cleanup, some style changes.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35076 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
#include "ExpanderThread.h"
|
#include "ExpanderThread.h"
|
||||||
#include "ExpanderPreferences.h"
|
#include "ExpanderPreferences.h"
|
||||||
|
|
||||||
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Box.h>
|
#include <Box.h>
|
||||||
@@ -24,6 +25,7 @@
|
|||||||
#include <StringView.h>
|
#include <StringView.h>
|
||||||
#include <TextView.h>
|
#include <TextView.h>
|
||||||
|
|
||||||
|
|
||||||
const uint32 MSG_SOURCE = 'mSOU';
|
const uint32 MSG_SOURCE = 'mSOU';
|
||||||
const uint32 MSG_DEST = 'mDES';
|
const uint32 MSG_DEST = 'mDES';
|
||||||
const uint32 MSG_EXPAND = 'mEXP';
|
const uint32 MSG_EXPAND = 'mEXP';
|
||||||
@@ -35,8 +37,12 @@ const uint32 MSG_DESTTEXT = 'mDTX';
|
|||||||
const uint32 MSG_SHOWCONTENTS = 'mSCT';
|
const uint32 MSG_SHOWCONTENTS = 'mSCT';
|
||||||
|
|
||||||
|
|
||||||
ExpanderWindow::ExpanderWindow(BRect frame, const entry_ref *ref, BMessage *settings)
|
ExpanderWindow::ExpanderWindow(BRect frame, const entry_ref* ref,
|
||||||
: BWindow(frame, "Expander", B_TITLED_WINDOW, B_NOT_ZOOMABLE),
|
BMessage* settings)
|
||||||
|
:
|
||||||
|
BWindow(frame, "Expander", B_TITLED_WINDOW, B_NOT_ZOOMABLE),
|
||||||
|
fSourcePanel(NULL),
|
||||||
|
fDestPanel(NULL),
|
||||||
fSourceChanged(true),
|
fSourceChanged(true),
|
||||||
fListingThread(NULL),
|
fListingThread(NULL),
|
||||||
fListingStarted(false),
|
fListingStarted(false),
|
||||||
@@ -45,22 +51,24 @@ ExpanderWindow::ExpanderWindow(BRect frame, const entry_ref *ref, BMessage *sett
|
|||||||
fSettings(*settings),
|
fSettings(*settings),
|
||||||
fPreferences(NULL)
|
fPreferences(NULL)
|
||||||
{
|
{
|
||||||
fSourcePanel = NULL;
|
|
||||||
fDestPanel = NULL;
|
|
||||||
|
|
||||||
// create menu bar
|
// create menu bar
|
||||||
fBar = new BMenuBar(BRect(0, 0, Bounds().right, 20), "menu_bar");
|
fBar = new BMenuBar(BRect(0, 0, Bounds().right, 20), "menu_bar");
|
||||||
BMenu* menu = new BMenu("File");
|
BMenu* menu = new BMenu("File");
|
||||||
BMenuItem* item;
|
BMenuItem* item;
|
||||||
menu->AddItem(item = new BMenuItem("About Expander" B_UTF8_ELLIPSIS, new BMessage(B_ABOUT_REQUESTED)));
|
menu->AddItem(item = new BMenuItem("About Expander" B_UTF8_ELLIPSIS,
|
||||||
|
new BMessage(B_ABOUT_REQUESTED)));
|
||||||
item->SetTarget(be_app_messenger);
|
item->SetTarget(be_app_messenger);
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
menu->AddItem(fSourceItem = new BMenuItem("Set source" B_UTF8_ELLIPSIS, new BMessage(MSG_SOURCE), 'O'));
|
menu->AddItem(fSourceItem = new BMenuItem("Set source" B_UTF8_ELLIPSIS,
|
||||||
menu->AddItem(fDestItem = new BMenuItem("Set destination" B_UTF8_ELLIPSIS, new BMessage(MSG_DEST), 'D'));
|
new BMessage(MSG_SOURCE), 'O'));
|
||||||
|
menu->AddItem(fDestItem = new BMenuItem("Set destination" B_UTF8_ELLIPSIS,
|
||||||
|
new BMessage(MSG_DEST), 'D'));
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
menu->AddItem(fExpandItem = new BMenuItem("Expand", new BMessage(MSG_EXPAND), 'E'));
|
menu->AddItem(fExpandItem = new BMenuItem("Expand", new BMessage(MSG_EXPAND),
|
||||||
|
'E'));
|
||||||
fExpandItem->SetEnabled(false);
|
fExpandItem->SetEnabled(false);
|
||||||
menu->AddItem(fShowItem = new BMenuItem("Show contents", new BMessage(MSG_SHOW), 'L'));
|
menu->AddItem(fShowItem = new BMenuItem("Show contents",
|
||||||
|
new BMessage(MSG_SHOW), 'L'));
|
||||||
fShowItem->SetEnabled(false);
|
fShowItem->SetEnabled(false);
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
menu->AddItem(fStopItem = new BMenuItem("Stop", new BMessage(MSG_STOP), 'K'));
|
menu->AddItem(fStopItem = new BMenuItem("Stop", new BMessage(MSG_STOP), 'K'));
|
||||||
@@ -179,6 +187,7 @@ ExpanderWindow::~ExpanderWindow()
|
|||||||
delete fSourcePanel;
|
delete fSourcePanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ExpanderWindow::ValidateDest()
|
ExpanderWindow::ValidateDest()
|
||||||
{
|
{
|
||||||
@@ -206,6 +215,7 @@ ExpanderWindow::ValidateDest()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ExpanderWindow::FrameResized(float width, float height)
|
ExpanderWindow::FrameResized(float width, float height)
|
||||||
{
|
{
|
||||||
@@ -238,6 +248,7 @@ ExpanderWindow::MessageReceived(BMessage *msg)
|
|||||||
fSourcePanel->Show();
|
fSourcePanel->Show();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case MSG_DEST:
|
case MSG_DEST:
|
||||||
{
|
{
|
||||||
BEntry entry(fDestText->Text(), true);
|
BEntry entry(fDestText->Text(), true);
|
||||||
@@ -246,13 +257,15 @@ ExpanderWindow::MessageReceived(BMessage *msg)
|
|||||||
entry.GetRef(&destRef);
|
entry.GetRef(&destRef);
|
||||||
if (!fDestPanel) {
|
if (!fDestPanel) {
|
||||||
BMessenger messenger(this);
|
BMessenger messenger(this);
|
||||||
fDestPanel = new DirectoryFilePanel(B_OPEN_PANEL, &messenger, &destRef,
|
fDestPanel = new DirectoryFilePanel(B_OPEN_PANEL, &messenger,
|
||||||
B_DIRECTORY_NODE, false, NULL, new DirectoryRefFilter(), true);
|
&destRef, B_DIRECTORY_NODE, false, NULL,
|
||||||
|
new DirectoryRefFilter(), true);
|
||||||
} else
|
} else
|
||||||
fDestPanel->SetPanelDirectory(&destRef);
|
fDestPanel->SetPanelDirectory(&destRef);
|
||||||
fDestPanel->Show();
|
fDestPanel->Show();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case MSG_DIRECTORY:
|
case MSG_DIRECTORY:
|
||||||
{
|
{
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
@@ -281,8 +294,9 @@ ExpanderWindow::MessageReceived(BMessage *msg)
|
|||||||
case MSG_STOP:
|
case MSG_STOP:
|
||||||
if (fExpandingStarted) {
|
if (fExpandingStarted) {
|
||||||
fExpandingThread->SuspendExternalExpander();
|
fExpandingThread->SuspendExternalExpander();
|
||||||
BAlert *alert = new BAlert("stopAlert", "Are you sure you want to stop expanding this\n"
|
BAlert* alert = new BAlert("stopAlert", "Are you sure you want "
|
||||||
"archive? The expanded items may not be complete.", "Stop", "Continue", NULL,
|
"to stop expanding this\narchive? The expanded items may "
|
||||||
|
"not be complete.", "Stop", "Continue", NULL,
|
||||||
B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
|
B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
|
||||||
if (alert->Go() == 0) {
|
if (alert->Go() == 0) {
|
||||||
fExpandingThread->ResumeExternalExpander();
|
fExpandingThread->ResumeExternalExpander();
|
||||||
@@ -337,8 +351,8 @@ ExpanderWindow::MessageReceived(BMessage *msg)
|
|||||||
BString string = "The file : ";
|
BString string = "The file : ";
|
||||||
string += fSourceText->Text();
|
string += fSourceText->Text();
|
||||||
string += " is not supported";
|
string += " is not supported";
|
||||||
BAlert *alert = new BAlert("srcAlert", string.String(),
|
BAlert* alert = new BAlert("srcAlert", string.String(), "Cancel",
|
||||||
"Cancel", NULL, NULL, B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_INFO_ALERT);
|
NULL, NULL, B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_INFO_ALERT);
|
||||||
alert->Go();
|
alert->Go();
|
||||||
|
|
||||||
fShowContents->SetEnabled(false);
|
fShowContents->SetEnabled(false);
|
||||||
@@ -347,16 +361,17 @@ ExpanderWindow::MessageReceived(BMessage *msg)
|
|||||||
fShowItem->SetEnabled(false);
|
fShowItem->SetEnabled(false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_DESTTEXT:
|
case MSG_DESTTEXT:
|
||||||
{
|
|
||||||
ValidateDest();
|
ValidateDest();
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_PREFERENCES:
|
case MSG_PREFERENCES:
|
||||||
if (!fPreferences)
|
if (!fPreferences)
|
||||||
fPreferences = new ExpanderPreferences(&fSettings);
|
fPreferences = new ExpanderPreferences(&fSettings);
|
||||||
fPreferences->Show();
|
fPreferences->Show();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'outp':
|
case 'outp':
|
||||||
if (!fExpandingStarted && fListingStarted) {
|
if (!fExpandingStarted && fListingStarted) {
|
||||||
BString string;
|
BString string;
|
||||||
@@ -372,9 +387,10 @@ ExpanderWindow::MessageReceived(BMessage *msg)
|
|||||||
}
|
}
|
||||||
fListingText->ScrollToSelection();
|
fListingText->ScrollToSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'exit': // thread has finished (finished, quit, killed, we don't know)
|
|
||||||
|
case 'exit':
|
||||||
|
// thread has finished (finished, quit, killed, we don't know)
|
||||||
// reset window state
|
// reset window state
|
||||||
if (fExpandingStarted) {
|
if (fExpandingStarted) {
|
||||||
fStatusView->SetText("File expanded");
|
fStatusView->SetText("File expanded");
|
||||||
@@ -390,12 +406,14 @@ ExpanderWindow::MessageReceived(BMessage *msg)
|
|||||||
} else
|
} else
|
||||||
fStatusView->SetText("");
|
fStatusView->SetText("");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'exrr': // thread has finished
|
case 'exrr': // thread has finished
|
||||||
// reset window state
|
// reset window state
|
||||||
|
|
||||||
fStatusView->SetText("Error when expanding archive");
|
fStatusView->SetText("Error when expanding archive");
|
||||||
CloseWindowOrKeepOpen();
|
CloseWindowOrKeepOpen();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BWindow::MessageReceived(msg);
|
BWindow::MessageReceived(msg);
|
||||||
break;
|
break;
|
||||||
@@ -412,9 +430,10 @@ ExpanderWindow::CanQuit()
|
|||||||
|
|
||||||
if (fExpandingStarted) {
|
if (fExpandingStarted) {
|
||||||
fExpandingThread->SuspendExternalExpander();
|
fExpandingThread->SuspendExternalExpander();
|
||||||
BAlert *alert = new BAlert("stopAlert", "Are you sure you want to stop expanding this\n"
|
BAlert* alert = new BAlert("stopAlert", "Are you sure you want to stop "
|
||||||
"archive? The expanded items may not be complete.", "Stop", "Continue", NULL,
|
"expanding this\narchive? The expanded items may not be complete.",
|
||||||
B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
|
"Stop", "Continue", NULL, B_WIDTH_AS_USUAL, B_EVEN_SPACING,
|
||||||
|
B_WARNING_ALERT);
|
||||||
if (alert->Go() == 0) {
|
if (alert->Go() == 0) {
|
||||||
fExpandingThread->ResumeExternalExpander();
|
fExpandingThread->ResumeExternalExpander();
|
||||||
StopExpanding();
|
StopExpanding();
|
||||||
@@ -508,9 +527,8 @@ ExpanderWindow::StartExpanding()
|
|||||||
|
|
||||||
BEntry destEntry(fDestText->Text(), true);
|
BEntry destEntry(fDestText->Text(), true);
|
||||||
if (!destEntry.Exists()) {
|
if (!destEntry.Exists()) {
|
||||||
BAlert *alert = new BAlert("destAlert", "The folder was either moved, renamed or not\n"
|
BAlert* alert = new BAlert("destAlert", "The folder was either moved, "
|
||||||
"supported.",
|
"renamed or not\nsupported.", "Cancel", NULL, NULL,
|
||||||
"Cancel", NULL, NULL,
|
|
||||||
B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
|
B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
|
||||||
alert->Go();
|
alert->Go();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -9,10 +9,12 @@
|
|||||||
#define EXPANDER_WINDOW_H
|
#define EXPANDER_WINDOW_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <Window.h>
|
||||||
|
|
||||||
|
|
||||||
#include "DirectoryFilePanel.h"
|
#include "DirectoryFilePanel.h"
|
||||||
#include "ExpanderRules.h"
|
#include "ExpanderRules.h"
|
||||||
|
|
||||||
#include <Window.h>
|
|
||||||
|
|
||||||
class BCheckBox;
|
class BCheckBox;
|
||||||
class BMenu;
|
class BMenu;
|
||||||
@@ -27,7 +29,8 @@ class ExpanderPreferences;
|
|||||||
|
|
||||||
class ExpanderWindow : public BWindow {
|
class ExpanderWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
ExpanderWindow(BRect frameRect, const entry_ref *ref, BMessage *settings);
|
ExpanderWindow(BRect frameRect,
|
||||||
|
const entry_ref* ref, BMessage* settings);
|
||||||
virtual ~ExpanderWindow();
|
virtual ~ExpanderWindow();
|
||||||
|
|
||||||
virtual void FrameResized(float width, float height);
|
virtual void FrameResized(float width, float height);
|
||||||
@@ -51,6 +54,7 @@ class ExpanderWindow : public BWindow {
|
|||||||
void StopListing();
|
void StopListing();
|
||||||
bool ValidateDest();
|
bool ValidateDest();
|
||||||
|
|
||||||
|
private:
|
||||||
BFilePanel* fSourcePanel;
|
BFilePanel* fSourcePanel;
|
||||||
DirectoryFilePanel* fDestPanel;
|
DirectoryFilePanel* fDestPanel;
|
||||||
BMenuBar* fBar;
|
BMenuBar* fBar;
|
||||||
@@ -59,11 +63,18 @@ class ExpanderWindow : public BWindow {
|
|||||||
entry_ref fDestRef;
|
entry_ref fDestRef;
|
||||||
bool fSourceChanged;
|
bool fSourceChanged;
|
||||||
|
|
||||||
BButton *fSourceButton, *fDestButton, *fExpandButton;
|
BButton* fSourceButton;
|
||||||
BMenuItem *fExpandItem, *fShowItem, *fStopItem,
|
BButton* fDestButton;
|
||||||
*fSourceItem, *fDestItem, *fPreferencesItem;
|
BButton* fExpandButton;
|
||||||
|
BMenuItem* fExpandItem;
|
||||||
|
BMenuItem* fShowItem;
|
||||||
|
BMenuItem* fStopItem;
|
||||||
|
BMenuItem* fSourceItem;
|
||||||
|
BMenuItem* fDestItem;
|
||||||
|
BMenuItem* fPreferencesItem;
|
||||||
BCheckBox* fShowContents;
|
BCheckBox* fShowContents;
|
||||||
BTextControl *fSourceText, *fDestText;
|
BTextControl* fSourceText;
|
||||||
|
BTextControl* fDestText;
|
||||||
BStringView* fStatusView;
|
BStringView* fStatusView;
|
||||||
BTextView* fListingText;
|
BTextView* fListingText;
|
||||||
BScrollView* fListingScroll;
|
BScrollView* fListingScroll;
|
||||||
|
|||||||
Reference in New Issue
Block a user