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