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()
|
App::App()
|
||||||
:
|
:
|
||||||
BApplication(kAppSignature),
|
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
|
#undef B_TRANSLATION_CONTEXT
|
||||||
#define B_TRANSLATION_CONTEXT "DiskUsage"
|
#define B_TRANSLATION_CONTEXT "DiskUsage"
|
||||||
|
|
||||||
entry_ref helpFileRef;
|
|
||||||
bool helpFileWasFound = false;
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main()
|
main()
|
||||||
|
|||||||
@@ -52,13 +52,10 @@ const float kPieOuterMargin = 10.0;
|
|||||||
const float kMinSegmentSpan = 2.0;
|
const float kMinSegmentSpan = 2.0;
|
||||||
const float kDragThreshold = 5.0;
|
const float kDragThreshold = 5.0;
|
||||||
|
|
||||||
extern entry_ref helpFileRef;
|
|
||||||
extern bool helpFileWasFound;
|
|
||||||
|
|
||||||
#define kMenuSelectVol 'gMSV'
|
#define kMenuSelectVol 'gMSV'
|
||||||
#define kBtnRescan 'gBRF'
|
#define kBtnRescan 'gBRF'
|
||||||
#define kBtnCancel 'gCAN'
|
#define kBtnCancel 'gCAN'
|
||||||
#define kBtnHelp 'gHLP'
|
|
||||||
#define kScanRefresh 'gSRF'
|
#define kScanRefresh 'gSRF'
|
||||||
#define kScanProgress 'gSPR'
|
#define kScanProgress 'gSPR'
|
||||||
#define kScanDone 'gSDN'
|
#define kScanDone 'gSDN'
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ resource app_version {
|
|||||||
long_info = "1.0.2 ©1999 Mike Steed, ©2008-2011 Haiku"
|
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 {
|
resource file_types message {
|
||||||
"types" = "application/x-vnd.Be-volume",
|
"types" = "application/x-vnd.Be-volume",
|
||||||
|
|||||||
@@ -58,11 +58,6 @@ MainWindow::MessageReceived(BMessage* message)
|
|||||||
fControlsView->MessageReceived(message);
|
fControlsView->MessageReceived(message);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kBtnHelp:
|
|
||||||
if (helpFileWasFound)
|
|
||||||
be_roster->Launch(&helpFileRef);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BWindow::MessageReceived(message);
|
BWindow::MessageReceived(message);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -35,8 +35,7 @@ Scanner::Scanner(BVolume *v, BHandler *handler)
|
|||||||
fDesiredPath(),
|
fDesiredPath(),
|
||||||
fTask(),
|
fTask(),
|
||||||
fBusy(false),
|
fBusy(false),
|
||||||
fQuitRequested(false),
|
fQuitRequested(false)
|
||||||
fPreviousSnapshot(NULL)
|
|
||||||
{
|
{
|
||||||
Run();
|
Run();
|
||||||
}
|
}
|
||||||
@@ -144,11 +143,11 @@ Scanner::_DirectoryContains(FileInfo* currentDir, entry_ref* ref)
|
|||||||
void
|
void
|
||||||
Scanner::_RunScan(FileInfo* startInfo)
|
Scanner::_RunScan(FileInfo* startInfo)
|
||||||
{
|
{
|
||||||
fPreviousSnapshot = fSnapshot;
|
|
||||||
fQuitRequested = false;
|
fQuitRequested = false;
|
||||||
BString stringScan(B_TRANSLATE("Scanning %refName%"));
|
BString stringScan(B_TRANSLATE("Scanning %refName%"));
|
||||||
|
|
||||||
if (startInfo == NULL || startInfo == fSnapshot->rootDir) {
|
if (startInfo == NULL || startInfo == fSnapshot->rootDir) {
|
||||||
|
VolumeSnapshot* previousSnapshot = fSnapshot;
|
||||||
fSnapshot = new VolumeSnapshot(fVolume);
|
fSnapshot = new VolumeSnapshot(fVolume);
|
||||||
stringScan.ReplaceFirst("%refName%", fSnapshot->name.c_str());
|
stringScan.ReplaceFirst("%refName%", fSnapshot->name.c_str());
|
||||||
fTask = stringScan.String();
|
fTask = stringScan.String();
|
||||||
@@ -162,7 +161,7 @@ Scanner::_RunScan(FileInfo* startInfo)
|
|||||||
fSnapshot->rootDir = _GetFileInfo(&root, NULL);
|
fSnapshot->rootDir = _GetFileInfo(&root, NULL);
|
||||||
if (fSnapshot->rootDir == NULL) {
|
if (fSnapshot->rootDir == NULL) {
|
||||||
delete fSnapshot;
|
delete fSnapshot;
|
||||||
fSnapshot = fPreviousSnapshot;
|
fSnapshot = previousSnapshot;
|
||||||
fBusy = false;
|
fBusy = false;
|
||||||
fListener.SendMessage(&fDoneMessage);
|
fListener.SendMessage(&fDoneMessage);
|
||||||
return;
|
return;
|
||||||
@@ -177,7 +176,7 @@ Scanner::_RunScan(FileInfo* startInfo)
|
|||||||
|
|
||||||
fSnapshot->currentDir = NULL;
|
fSnapshot->currentDir = NULL;
|
||||||
|
|
||||||
delete fPreviousSnapshot;
|
delete previousSnapshot;
|
||||||
} else {
|
} else {
|
||||||
off_t previousVolumeCapacity = fSnapshot->capacity;
|
off_t previousVolumeCapacity = fSnapshot->capacity;
|
||||||
off_t previousVolumeFreeBytes = fSnapshot->freeBytes;
|
off_t previousVolumeFreeBytes = fSnapshot->freeBytes;
|
||||||
|
|||||||
@@ -72,8 +72,6 @@ private:
|
|||||||
string fTask;
|
string fTask;
|
||||||
bool fBusy;
|
bool fBusy;
|
||||||
bool fQuitRequested;
|
bool fQuitRequested;
|
||||||
|
|
||||||
VolumeSnapshot* fPreviousSnapshot;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SCANNER_H
|
#endif // SCANNER_H
|
||||||
|
|||||||
Reference in New Issue
Block a user