DiskUsage: minor clean up
* remove unused code. * make fPreviousSnapshot local. * change app_flags to B_SINGLE_LAUNCH when it is invoked by add-on reuses an already scanned volume
This commit is contained in:
@@ -25,18 +25,9 @@
|
||||
App::App()
|
||||
:
|
||||
BApplication(kAppSignature),
|
||||
fMainWindow(NULL), fSavedRefsReceived(NULL)
|
||||
fMainWindow(NULL),
|
||||
fSavedRefsReceived(NULL)
|
||||
{
|
||||
// Get a reference to the help file.
|
||||
BPath path;
|
||||
if (find_directory(B_BEOS_DOCUMENTATION_DIRECTORY, &path) == B_OK
|
||||
&& path.Append(kHelpFileName) == B_OK) {
|
||||
printf("help file =? %s\n", path.Path());
|
||||
BEntry entry(path.Path());
|
||||
helpFileWasFound = entry.Exists();
|
||||
entry.GetRef(&helpFileRef);
|
||||
} else
|
||||
helpFileWasFound = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
#undef B_TRANSLATION_CONTEXT
|
||||
#define B_TRANSLATION_CONTEXT "DiskUsage"
|
||||
|
||||
entry_ref helpFileRef;
|
||||
bool helpFileWasFound = false;
|
||||
|
||||
int
|
||||
main()
|
||||
|
||||
@@ -52,13 +52,10 @@ const float kPieOuterMargin = 10.0;
|
||||
const float kMinSegmentSpan = 2.0;
|
||||
const float kDragThreshold = 5.0;
|
||||
|
||||
extern entry_ref helpFileRef;
|
||||
extern bool helpFileWasFound;
|
||||
|
||||
#define kMenuSelectVol 'gMSV'
|
||||
#define kBtnRescan 'gBRF'
|
||||
#define kBtnCancel 'gCAN'
|
||||
#define kBtnHelp 'gHLP'
|
||||
#define kScanRefresh 'gSRF'
|
||||
#define kScanProgress 'gSPR'
|
||||
#define kScanDone 'gSDN'
|
||||
|
||||
@@ -14,7 +14,7 @@ resource app_version {
|
||||
long_info = "1.0.2 ©1999 Mike Steed, ©2008-2011 Haiku"
|
||||
};
|
||||
|
||||
resource app_flags B_MULTIPLE_LAUNCH;
|
||||
resource app_flags B_SINGLE_LAUNCH;
|
||||
|
||||
resource file_types message {
|
||||
"types" = "application/x-vnd.Be-volume",
|
||||
|
||||
@@ -58,11 +58,6 @@ MainWindow::MessageReceived(BMessage* message)
|
||||
fControlsView->MessageReceived(message);
|
||||
break;
|
||||
|
||||
case kBtnHelp:
|
||||
if (helpFileWasFound)
|
||||
be_roster->Launch(&helpFileRef);
|
||||
break;
|
||||
|
||||
default:
|
||||
BWindow::MessageReceived(message);
|
||||
break;
|
||||
|
||||
@@ -35,8 +35,7 @@ Scanner::Scanner(BVolume *v, BHandler *handler)
|
||||
fDesiredPath(),
|
||||
fTask(),
|
||||
fBusy(false),
|
||||
fQuitRequested(false),
|
||||
fPreviousSnapshot(NULL)
|
||||
fQuitRequested(false)
|
||||
{
|
||||
Run();
|
||||
}
|
||||
@@ -144,11 +143,11 @@ Scanner::_DirectoryContains(FileInfo* currentDir, entry_ref* ref)
|
||||
void
|
||||
Scanner::_RunScan(FileInfo* startInfo)
|
||||
{
|
||||
fPreviousSnapshot = fSnapshot;
|
||||
fQuitRequested = false;
|
||||
BString stringScan(B_TRANSLATE("Scanning %refName%"));
|
||||
|
||||
if (startInfo == NULL || startInfo == fSnapshot->rootDir) {
|
||||
VolumeSnapshot* previousSnapshot = fSnapshot;
|
||||
fSnapshot = new VolumeSnapshot(fVolume);
|
||||
stringScan.ReplaceFirst("%refName%", fSnapshot->name.c_str());
|
||||
fTask = stringScan.String();
|
||||
@@ -162,7 +161,7 @@ Scanner::_RunScan(FileInfo* startInfo)
|
||||
fSnapshot->rootDir = _GetFileInfo(&root, NULL);
|
||||
if (fSnapshot->rootDir == NULL) {
|
||||
delete fSnapshot;
|
||||
fSnapshot = fPreviousSnapshot;
|
||||
fSnapshot = previousSnapshot;
|
||||
fBusy = false;
|
||||
fListener.SendMessage(&fDoneMessage);
|
||||
return;
|
||||
@@ -177,7 +176,7 @@ Scanner::_RunScan(FileInfo* startInfo)
|
||||
|
||||
fSnapshot->currentDir = NULL;
|
||||
|
||||
delete fPreviousSnapshot;
|
||||
delete previousSnapshot;
|
||||
} else {
|
||||
off_t previousVolumeCapacity = fSnapshot->capacity;
|
||||
off_t previousVolumeFreeBytes = fSnapshot->freeBytes;
|
||||
|
||||
@@ -72,8 +72,6 @@ private:
|
||||
string fTask;
|
||||
bool fBusy;
|
||||
bool fQuitRequested;
|
||||
|
||||
VolumeSnapshot* fPreviousSnapshot;
|
||||
};
|
||||
|
||||
#endif // SCANNER_H
|
||||
|
||||
Reference in New Issue
Block a user