[haiku-commits] r35076 - haiku/trunk/src/apps/expander

  • From: host.haiku@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 14 Jan 2010 22:21:45 +0100 (CET)

Author: julun
Date: 2010-01-14 22:21:45 +0100 (Thu, 14 Jan 2010)
New Revision: 35076
Changeset: http://dev.haiku-os.org/changeset/35076/haiku

Modified:
   haiku/trunk/src/apps/expander/ExpanderWindow.cpp
   haiku/trunk/src/apps/expander/ExpanderWindow.h
Log:
* Cleanup, some style changes.



Modified: haiku/trunk/src/apps/expander/ExpanderWindow.cpp
===================================================================
--- haiku/trunk/src/apps/expander/ExpanderWindow.cpp    2010-01-14 20:44:29 UTC 
(rev 35075)
+++ haiku/trunk/src/apps/expander/ExpanderWindow.cpp    2010-01-14 21:21:45 UTC 
(rev 35076)
@@ -9,6 +9,7 @@
 #include "ExpanderThread.h"
 #include "ExpanderPreferences.h"
 
+
 #include <Alert.h>
 #include <Application.h>
 #include <Box.h>
@@ -24,19 +25,24 @@
 #include <StringView.h>
 #include <TextView.h>
 
-const uint32 MSG_SOURCE                = 'mSOU';
-const uint32 MSG_DEST          = 'mDES';
-const uint32 MSG_EXPAND                = 'mEXP';
-const uint32 MSG_SHOW          = 'mSHO';
-const uint32 MSG_STOP          = 'mSTO';
-const uint32 MSG_PREFERENCES = 'mPRE';
-const uint32 MSG_SOURCETEXT = 'mSTX';
-const uint32 MSG_DESTTEXT = 'mDTX';
-const uint32 MSG_SHOWCONTENTS = 'mSCT';
 
+const uint32 MSG_SOURCE                        = 'mSOU';
+const uint32 MSG_DEST                  = 'mDES';
+const uint32 MSG_EXPAND                        = 'mEXP';
+const uint32 MSG_SHOW                  = 'mSHO';
+const uint32 MSG_STOP                  = 'mSTO';
+const uint32 MSG_PREFERENCES   = 'mPRE';
+const uint32 MSG_SOURCETEXT            = 'mSTX';
+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 @@
        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)));
+       BMenu* menu = new BMenu("File");
+       BMenuItem* item;
+       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'));
@@ -77,7 +85,7 @@
 
        BRect rect = Bounds();
        rect.top += fBar->Bounds().Height() + 1;
-       BView *topView = new BView(rect, "background", B_FOLLOW_ALL, 
B_WILL_DRAW);
+       BView* topView = new BView(rect, "background", B_FOLLOW_ALL, 
B_WILL_DRAW);
        topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
        AddChild(topView);
 
@@ -179,13 +187,14 @@
        delete fSourcePanel;
 }
 
+
 bool 
 ExpanderWindow::ValidateDest()
 {
        BEntry entry(fDestText->Text(), true);
        BVolume volume;
        if (!entry.Exists()) {
-               BAlert *alert = new BAlert("destAlert", "The destination"
+               BAlert* alert = new BAlert("destAlert", "The destination"
                        " folder does not exist.", "Cancel", NULL, NULL,
                        B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
                alert->Go();
@@ -206,6 +215,7 @@
        }
 }
 
+
 void
 ExpanderWindow::FrameResized(float width, float height)
 {
@@ -220,7 +230,7 @@
 
 
 void
-ExpanderWindow::MessageReceived(BMessage *msg)
+ExpanderWindow::MessageReceived(BMessage* msg)
 {
        switch (msg->what) {
                case MSG_SOURCE:
@@ -238,6 +248,7 @@
                        fSourcePanel->Show();
                        break;
                }
+
                case MSG_DEST:
                {       
                        BEntry entry(fDestText->Text(), true);
@@ -246,13 +257,15 @@
                                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 @@
                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();
@@ -314,7 +328,7 @@
                {
                        BEntry entry(fSourceText->Text(), true);
                        if (!entry.Exists()) {
-                               BAlert *alert = new BAlert("srcAlert", "The 
file doesn't exist",
+                               BAlert* alert = new BAlert("srcAlert", "The 
file doesn't exist",
                                        "Cancel", NULL, NULL,
                                        B_WIDTH_AS_USUAL, B_EVEN_SPACING, 
B_WARNING_ALERT);
                                alert->Go();
@@ -323,7 +337,7 @@
 
                        entry_ref ref;
                        entry.GetRef(&ref);
-                       ExpanderRule *rule = fRules.MatchingRule(&ref);
+                       ExpanderRule* rule = fRules.MatchingRule(&ref);
                        if (rule) {
                                fSourceChanged = true;
                                fSourceRef = ref;
@@ -337,8 +351,8 @@
                        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 @@
                        fShowItem->SetEnabled(false);
                }
                break;
+
                case MSG_DESTTEXT:
-               {
                        ValidateDest();
-               }
-               break;
+                       break;
+
                case MSG_PREFERENCES:
                        if (!fPreferences)
                                fPreferences = new 
ExpanderPreferences(&fSettings);
                        fPreferences->Show();
                        break;
+
                case 'outp':
                        if (!fExpandingStarted && fListingStarted) {
                                BString string;
@@ -372,9 +387,10 @@
                                }
                                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
                        if (fExpandingStarted) {
                                fStatusView->SetText("File expanded");
@@ -390,12 +406,14 @@
                        } 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 @@
 
        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();
@@ -444,7 +463,7 @@
 
 
 void
-ExpanderWindow::RefsReceived(BMessage *msg)
+ExpanderWindow::RefsReceived(BMessage* msg)
 {
        entry_ref ref;
        int32 i = 0;
@@ -502,15 +521,14 @@
 void
 ExpanderWindow::StartExpanding()
 {
-       ExpanderRule *rule = fRules.MatchingRule(&fSourceRef);
+       ExpanderRule* rule = fRules.MatchingRule(&fSourceRef);
        if (!rule)
                return;
 
        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;
@@ -607,7 +625,7 @@
        if (!fSourceChanged)
                return;
 
-       ExpanderRule *rule = fRules.MatchingRule(&fSourceRef);
+       ExpanderRule* rule = fRules.MatchingRule(&fSourceRef);
        if (!rule)
                return;
 
@@ -690,7 +708,7 @@
        if (!openFolder)
                return;
 
-       BMessage * message = new BMessage(B_REFS_RECEIVED);
+       BMessage* message = new BMessage(B_REFS_RECEIVED);
        message->AddRef("refs", &fDestRef);
        BPath path(&fDestRef);
        BMessenger tracker("application/x-vnd.Be-TRAK");

Modified: haiku/trunk/src/apps/expander/ExpanderWindow.h
===================================================================
--- haiku/trunk/src/apps/expander/ExpanderWindow.h      2010-01-14 20:44:29 UTC 
(rev 35075)
+++ haiku/trunk/src/apps/expander/ExpanderWindow.h      2010-01-14 21:21:45 UTC 
(rev 35076)
@@ -9,10 +9,12 @@
 #define EXPANDER_WINDOW_H
 
 
+#include <Window.h>
+
+
 #include "DirectoryFilePanel.h"
 #include "ExpanderRules.h"
 
-#include <Window.h>
 
 class BCheckBox;
 class BMenu;
@@ -26,59 +28,68 @@
 
 
 class ExpanderWindow : public BWindow {
-       public:
-               ExpanderWindow(BRect frameRect, const entry_ref *ref, BMessage 
*settings);
-               virtual ~ExpanderWindow();
+public:
+                                                               
ExpanderWindow(BRect frameRect,
+                                                                       const 
entry_ref* ref, BMessage* settings);
+       virtual                                         ~ExpanderWindow();
 
-               virtual void FrameResized(float width, float height);
-               virtual void MessageReceived(BMessage *msg);
-               virtual bool QuitRequested();
+       virtual void                            FrameResized(float width, float 
height);
+       virtual void                            MessageReceived(BMessage* msg);
+       virtual bool                            QuitRequested();
 
-               void SetRef(const entry_ref *ref);
-               void RefsReceived(BMessage *msg);
+                       void                            SetRef(const entry_ref* 
ref);
+                       void                            RefsReceived(BMessage* 
msg);
 
-       private:
-               bool CanQuit();
-               // returns true if the window can be closed safely, false if not
-               void CloseWindowOrKeepOpen();
-               void OpenDestFolder();
-               void AutoListing();
-               void AutoExpand();
-               void StartExpanding();
-               void StopExpanding();
-               void _UpdateWindowSize(bool showContents);
-               void StartListing();
-               void StopListing();
-               bool ValidateDest();
+private:
+                       bool                            CanQuit();
+                               // returns true if the window can be closed 
safely, false if not
+                       void                            CloseWindowOrKeepOpen();
+                       void                            OpenDestFolder();
+                       void                            AutoListing();
+                       void                            AutoExpand();
+                       void                            StartExpanding();
+                       void                            StopExpanding();
+                       void                            _UpdateWindowSize(bool 
showContents);
+                       void                            StartListing();
+                       void                            StopListing();
+                       bool                            ValidateDest();
 
-               BFilePanel *fSourcePanel;
-               DirectoryFilePanel *fDestPanel;
-               BMenuBar *fBar;
-               BMenu *fMenu;
-               entry_ref fSourceRef;
-               entry_ref fDestRef;
-               bool fSourceChanged;
+private:
+                       BFilePanel*                     fSourcePanel;
+                       DirectoryFilePanel*     fDestPanel;
+                       BMenuBar*                       fBar;
+                       BMenu*                          fMenu;
+                       entry_ref                       fSourceRef;
+                       entry_ref                       fDestRef;
+                       bool                            fSourceChanged;
 
-               BButton *fSourceButton, *fDestButton, *fExpandButton;
-               BMenuItem *fExpandItem, *fShowItem, *fStopItem,
-                       *fSourceItem, *fDestItem, *fPreferencesItem;
-               BCheckBox *fShowContents;
-               BTextControl *fSourceText, *fDestText;
-               BStringView* fStatusView;
-               BTextView *fListingText;
-               BScrollView *fListingScroll;
+                       BButton*                        fSourceButton;
+                       BButton*                        fDestButton;
+                       BButton*                        fExpandButton;
+                       BMenuItem*                      fExpandItem;
+                       BMenuItem*                      fShowItem;
+                       BMenuItem*                      fStopItem;
+                       BMenuItem*                      fSourceItem;
+                       BMenuItem*                      fDestItem;
+                       BMenuItem*                      fPreferencesItem;
+                       BCheckBox*                      fShowContents;
+                       BTextControl*           fSourceText;
+                       BTextControl*           fDestText;
+                       BStringView*            fStatusView;
+                       BTextView*                      fListingText;
+                       BScrollView*            fListingScroll;
 
-               ExpanderThread *fListingThread;
-               bool fListingStarted;
+                       ExpanderThread*         fListingThread;
+                       bool                            fListingStarted;
 
-               ExpanderThread *fExpandingThread;
-               bool fExpandingStarted;
+                       ExpanderThread*         fExpandingThread;
+                       bool                            fExpandingStarted;
 
-               BMessage fSettings;
-               ExpanderPreferences *fPreferences;
-               ExpanderRules fRules;
+                       BMessage                        fSettings;
+                       ExpanderPreferences*    fPreferences;
+                       ExpanderRules           fRules;
 
-               float   fLargestDelta;
+                       float                           fLargestDelta;
 };
 
 #endif /* EXPANDER_WINDOW_H */


Other related posts:

  • » [haiku-commits] r35076 - haiku/trunk/src/apps/expander - host . haiku