Applied yet another localization patch from Jorma Karvonen. Fixes #7169.
Beside of localization task some refactoring was performed: - strings, stored previously in resources were moved from resource definition file to cpp files at the place of using; - cleanup of resource definitions and Common.cpp/Common.h. Additionall tasks, made by S.Zharski: - the rests of resource handling tasks were purged out from Common.cpp/Common.h; - Common.h renamed to DiskUsage.h; - the rests of code from Common.cpp merged into DiskUsage.cpp; - the preprocessor tricks and magics targeted mainly for resources support were removed; - some code style fixes and "internationalization style" fixes were made. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40493 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -12,27 +12,36 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <Entry.h>
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
#include <Node.h>
|
#include <Node.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
|
|
||||||
#include "Common.h"
|
#include "DiskUsage.h"
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
|
|
||||||
|
|
||||||
App::App()
|
App::App()
|
||||||
:
|
:
|
||||||
BApplication(kAppSignature),
|
BApplication(kAppSignature),
|
||||||
fResources(read_resources(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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
App::~App()
|
App::~App()
|
||||||
{
|
{
|
||||||
delete fResources;
|
|
||||||
delete fSavedRefsReceived;
|
delete fSavedRefsReceived;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ public:
|
|||||||
virtual bool QuitRequested();
|
virtual bool QuitRequested();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BResources* fResources;
|
|
||||||
MainWindow* fMainWindow;
|
MainWindow* fMainWindow;
|
||||||
BMessage* fSavedRefsReceived;
|
BMessage* fSavedRefsReceived;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,151 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2008 Stephan Aßmus <[email protected]>. All rights reserved.
|
|
||||||
* Distributed under the terms of the MIT/X11 license.
|
|
||||||
*
|
|
||||||
* Copyright (c) 1999 Mike Steed. You are free to use and distribute this software
|
|
||||||
* as long as it is accompanied by it's documentation and this copyright notice.
|
|
||||||
* The software comes with no warranty, etc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#define ASSIGN_RESOURCES
|
|
||||||
#include "Common.h"
|
|
||||||
#undef ASSIGN_RESOURCES
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include <Application.h>
|
|
||||||
#include <FindDirectory.h>
|
|
||||||
#include <Roster.h>
|
|
||||||
#include <Path.h>
|
|
||||||
|
|
||||||
|
|
||||||
const char* kAppSignature = "application/x-vnd.Haiku-DiskUsage";
|
|
||||||
const char* kHelpFileName = "userguide/en/applications/diskusage.html";
|
|
||||||
const char* kPieRectAttrName = "mainrect";
|
|
||||||
|
|
||||||
const char* kHelpBtnLabel = "?";
|
|
||||||
const char* kEmptyStr = "";
|
|
||||||
const char* kNameVolPtr = "vol";
|
|
||||||
const char* kNameFilePtr = "file";
|
|
||||||
|
|
||||||
const float kSmallHMargin = 5.0;
|
|
||||||
const float kSmallVMargin = 2.0;
|
|
||||||
const float kButtonMargin = 20.0;
|
|
||||||
const float kMinButtonWidth = 60.0;
|
|
||||||
|
|
||||||
const float kProgBarWidth = 150.0;
|
|
||||||
const float kProgBarHeight = 16.0;
|
|
||||||
const float kReportInterval = 2.5;
|
|
||||||
|
|
||||||
const float kDefaultPieSize = 400.0;
|
|
||||||
const float kPieCenterSize = 80.0;
|
|
||||||
const float kPieRingSize = 20.0;
|
|
||||||
const float kPieInnerMargin = 10.0;
|
|
||||||
const float kPieOuterMargin = 10.0;
|
|
||||||
const float kMinSegmentSpan = 2.0;
|
|
||||||
const int kLightenFactor = 0x12;
|
|
||||||
const float kDragThreshold = 5.0;
|
|
||||||
|
|
||||||
|
|
||||||
BResources*
|
|
||||||
read_resources(const char* appSignature)
|
|
||||||
{
|
|
||||||
status_t ret = be_app->GetAppInfo(&kAppInfo);
|
|
||||||
if (ret != B_OK) {
|
|
||||||
fprintf(stderr, "Failed to init application info: %s\n",
|
|
||||||
strerror(ret));
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
BFile file(&kAppInfo.ref, O_RDONLY);
|
|
||||||
ret = file.InitCheck();
|
|
||||||
if (ret != B_OK) {
|
|
||||||
fprintf(stderr, "Failed to init application file to read resources: "
|
|
||||||
"%s\n", strerror(ret));
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
BResources* r = new BResources(&file);
|
|
||||||
|
|
||||||
#define LoadString(n) (char*)r->LoadResource(B_STRING_TYPE, n, &ignore)
|
|
||||||
#define LoadColor(n) *(rgb_color*)r->LoadResource(B_RGB_COLOR_TYPE, n, &ignore)
|
|
||||||
#define LoadUint8(n) *(uint8*)r->LoadResource(B_UINT8_TYPE, n, &ignore)
|
|
||||||
|
|
||||||
size_t ignore;
|
|
||||||
kVolMenuLabel = LoadString("STR_VM_LABEL");
|
|
||||||
kOneFile = LoadString("STR_1_FILE");
|
|
||||||
kManyFiles = LoadString("STR_N_FILES");
|
|
||||||
kStrScan = LoadString("STR_SCAN");
|
|
||||||
kStrRescan = LoadString("STR_RESCAN");
|
|
||||||
kStrScanningX = LoadString("STR_SCN_X");
|
|
||||||
kStrUnavail = LoadString("STR_UNAVAIL");
|
|
||||||
kVolMenuDefault = LoadString("STR_VM_DFLT");
|
|
||||||
kVolPrompt = LoadString("STR_VPROMPT");
|
|
||||||
kMenuGetInfo = LoadString("STR_M_INFO");
|
|
||||||
kMenuOpen = LoadString("STR_M_OPEN");
|
|
||||||
kMenuOpenWith = LoadString("STR_M_OPENW");
|
|
||||||
kMenuNoApps = LoadString("STR_M_NAPPS");
|
|
||||||
kInfoSize = LoadString("STR_SIZE");
|
|
||||||
kInfoInFiles = LoadString("STR_INFILES");
|
|
||||||
kInfoCreated = LoadString("STR_MADE");
|
|
||||||
kInfoModified = LoadString("STR_MOD");
|
|
||||||
kInfoTimeFmt = LoadString("STR_TIMEFMT");
|
|
||||||
kInfoKind = LoadString("STR_KIND");
|
|
||||||
kInfoPath = LoadString("STR_PATH");
|
|
||||||
kOutdatedStr = LoadString("STR_OUTDATED");
|
|
||||||
|
|
||||||
kWindowColor = ui_color(B_PANEL_BACKGROUND_COLOR);
|
|
||||||
kOutlineColor = LoadColor("RGB_PIE_OL");
|
|
||||||
kPieBGColor = LoadColor("RGB_PIE_BG");
|
|
||||||
kEmptySpcColor = LoadColor("RGB_PIE_MT");
|
|
||||||
|
|
||||||
kBasePieColorCount = LoadUint8("N_PIE_COLORS");
|
|
||||||
kBasePieColor = new rgb_color[kBasePieColorCount];
|
|
||||||
for (int i = 0; i < kBasePieColorCount; i++) {
|
|
||||||
char colorName[16] = "RGB_PIE_n";
|
|
||||||
colorName[8] = '1' + i;
|
|
||||||
kBasePieColor[i] = LoadColor(colorName);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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());
|
|
||||||
kFoundHelpFile = entry.Exists();
|
|
||||||
entry.GetRef(&kHelpFileRef);
|
|
||||||
} else
|
|
||||||
kFoundHelpFile = false;
|
|
||||||
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
size_to_string(off_t byteCount, char* name)
|
|
||||||
{
|
|
||||||
struct {
|
|
||||||
off_t limit;
|
|
||||||
float divisor;
|
|
||||||
const char* format;
|
|
||||||
} scale[] = {
|
|
||||||
{ 0x100000, 1024.0, "%.2f KiB" },
|
|
||||||
{ 0x40000000, 1048576.0, "%.2f MiB" },
|
|
||||||
{ 0x10000000000ull, 1073741824.0, "%.2f GiB" },
|
|
||||||
{ 0x4000000000000ull, 1.09951162778e+12, "%.2f TiB" }
|
|
||||||
};
|
|
||||||
|
|
||||||
if (byteCount < 1024) {
|
|
||||||
sprintf(name, "%lld bytes", byteCount);
|
|
||||||
} else {
|
|
||||||
int i = 0;
|
|
||||||
while (byteCount >= scale[i].limit)
|
|
||||||
i++;
|
|
||||||
|
|
||||||
sprintf(name, scale[i].format, byteCount / scale[i].divisor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,107 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2008 Stephan Aßmus <[email protected]>. All rights reserved.
|
|
||||||
* Distributed under the terms of the MIT/X11 license.
|
|
||||||
*
|
|
||||||
* Copyright (c) 1999 Mike Steed. You are free to use and distribute this software
|
|
||||||
* as long as it is accompanied by it's documentation and this copyright notice.
|
|
||||||
* The software comes with no warranty, etc.
|
|
||||||
*/
|
|
||||||
#ifndef COMMON_H
|
|
||||||
#define COMMON_H
|
|
||||||
|
|
||||||
|
|
||||||
#include <Entry.h>
|
|
||||||
#include <GraphicsDefs.h>
|
|
||||||
#include <Resources.h>
|
|
||||||
#include <Roster.h>
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef ASSIGN_RESOURCES
|
|
||||||
# define EXTERN
|
|
||||||
# define EQ(x)
|
|
||||||
#else
|
|
||||||
# define EXTERN extern
|
|
||||||
# define EQ(x)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define EXTERN_CONST extern const
|
|
||||||
|
|
||||||
|
|
||||||
// Resources
|
|
||||||
EXTERN char* kStrScan;
|
|
||||||
EXTERN char* kStrRescan;
|
|
||||||
EXTERN char* kOutdatedStr;
|
|
||||||
EXTERN char* kStrScanningX;
|
|
||||||
EXTERN char* kStrUnavail;
|
|
||||||
EXTERN char* kVolMenuLabel;
|
|
||||||
EXTERN char* kVolMenuDefault;
|
|
||||||
EXTERN char* kVolPrompt;
|
|
||||||
EXTERN char* kOneFile;
|
|
||||||
EXTERN char* kManyFiles;
|
|
||||||
EXTERN char* kMenuGetInfo;
|
|
||||||
EXTERN char* kMenuOpen;
|
|
||||||
EXTERN char* kMenuOpenWith;
|
|
||||||
EXTERN char* kMenuNoApps;
|
|
||||||
EXTERN char* kInfoSize;
|
|
||||||
EXTERN char* kInfoInFiles;
|
|
||||||
EXTERN char* kInfoCreated;
|
|
||||||
EXTERN char* kInfoModified;
|
|
||||||
EXTERN char* kInfoTimeFmt;
|
|
||||||
EXTERN char* kInfoKind;
|
|
||||||
EXTERN char* kInfoPath;
|
|
||||||
|
|
||||||
EXTERN rgb_color kWindowColor;
|
|
||||||
EXTERN rgb_color kOutlineColor;
|
|
||||||
EXTERN rgb_color kPieBGColor;
|
|
||||||
EXTERN rgb_color kEmptySpcColor;
|
|
||||||
EXTERN int kBasePieColorCount;
|
|
||||||
EXTERN rgb_color *kBasePieColor;
|
|
||||||
|
|
||||||
// Non-resources :)
|
|
||||||
EXTERN_CONST char* kAppSignature;
|
|
||||||
EXTERN_CONST char* kHelpFileName;
|
|
||||||
EXTERN_CONST char* kPieRectAttrName;
|
|
||||||
|
|
||||||
EXTERN_CONST char* kHelpBtnLabel;
|
|
||||||
EXTERN_CONST char* kEmptyStr;
|
|
||||||
EXTERN_CONST char* kNameVolPtr;
|
|
||||||
EXTERN_CONST char* kNameFilePtr;
|
|
||||||
|
|
||||||
EXTERN_CONST float kSmallHMargin;
|
|
||||||
EXTERN_CONST float kSmallVMargin;
|
|
||||||
EXTERN_CONST float kButtonMargin;
|
|
||||||
EXTERN_CONST float kMinButtonWidth;
|
|
||||||
|
|
||||||
EXTERN_CONST float kProgBarWidth;
|
|
||||||
EXTERN_CONST float kProgBarHeight;
|
|
||||||
EXTERN_CONST float kReportInterval;
|
|
||||||
|
|
||||||
EXTERN_CONST float kDefaultPieSize;
|
|
||||||
EXTERN_CONST float kPieCenterSize;
|
|
||||||
EXTERN_CONST float kPieRingSize;
|
|
||||||
EXTERN_CONST float kPieInnerMargin;
|
|
||||||
EXTERN_CONST float kPieOuterMargin;
|
|
||||||
EXTERN_CONST float kMinSegmentSpan;
|
|
||||||
EXTERN_CONST int kLightenFactor;
|
|
||||||
EXTERN_CONST float kDragThreshold;
|
|
||||||
|
|
||||||
EXTERN app_info kAppInfo;
|
|
||||||
EXTERN entry_ref kHelpFileRef;
|
|
||||||
EXTERN bool kFoundHelpFile;
|
|
||||||
|
|
||||||
#define kMenuSelectVol 'gMSV'
|
|
||||||
#define kBtnRescan 'gBRF'
|
|
||||||
#define kBtnHelp 'gHLP'
|
|
||||||
#define kScanRefresh 'gSRF'
|
|
||||||
#define kScanProgress 'gSPR'
|
|
||||||
#define kScanDone 'gSDN'
|
|
||||||
#define kOutdatedMsg 'gOUT'
|
|
||||||
|
|
||||||
#define deg2rad(x) (2.0 * M_PI * (x) / 360.0)
|
|
||||||
#define rad2deg(x) (360.0 * (x) / (2.0 * M_PI))
|
|
||||||
|
|
||||||
BResources* read_resources(const char* appSignature);
|
|
||||||
void size_to_string(off_t byteCount, char* name);
|
|
||||||
|
|
||||||
|
|
||||||
#endif // COMMON_H
|
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include <LayoutBuilder.h>
|
#include <LayoutBuilder.h>
|
||||||
|
|
||||||
#include "Common.h"
|
#include "DiskUsage.h"
|
||||||
#include "VolumeView.h"
|
#include "VolumeView.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,46 @@
|
|||||||
|
|
||||||
#include "App.h"
|
#include "App.h"
|
||||||
|
|
||||||
#include <TrackerAddOnAppLaunch.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <Catalog.h>
|
||||||
|
|
||||||
|
#include "DiskUsage.h"
|
||||||
|
|
||||||
|
#undef B_TRANSLATE_CONTEXT
|
||||||
|
#define B_TRANSLATE_CONTEXT "DiskUsage"
|
||||||
|
|
||||||
|
entry_ref helpFileRef;
|
||||||
|
bool helpFileWasFound = false;
|
||||||
|
|
||||||
|
void
|
||||||
|
size_to_string(off_t byteCount, char* name)
|
||||||
|
{
|
||||||
|
struct {
|
||||||
|
off_t limit;
|
||||||
|
float divisor;
|
||||||
|
const char* format;
|
||||||
|
} scale[] = {
|
||||||
|
{ 0x100000, 1024.0,
|
||||||
|
B_TRANSLATE("%.2f KiB") },
|
||||||
|
{ 0x40000000, 1048576.0,
|
||||||
|
B_TRANSLATE("%.2f MiB") },
|
||||||
|
{ 0x10000000000ull, 1073741824.0,
|
||||||
|
B_TRANSLATE("%.2f GiB") },
|
||||||
|
{ 0x4000000000000ull, 1.09951162778e+12,
|
||||||
|
B_TRANSLATE("%.2f TiB") }
|
||||||
|
};
|
||||||
|
|
||||||
|
if (byteCount < 1024) {
|
||||||
|
sprintf(name, B_TRANSLATE("%lld bytes"), byteCount);
|
||||||
|
} else {
|
||||||
|
int i = 0;
|
||||||
|
while (byteCount >= scale[i].limit)
|
||||||
|
i++;
|
||||||
|
|
||||||
|
sprintf(name, scale[i].format, byteCount / scale[i].divisor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main()
|
main()
|
||||||
@@ -16,3 +54,4 @@ main()
|
|||||||
app.Run();
|
app.Run();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2008 Stephan Aßmus <[email protected]>. All rights reserved.
|
||||||
|
* Distributed under the terms of the MIT/X11 license.
|
||||||
|
*
|
||||||
|
* Copyright (c) 1999 Mike Steed. You are free to use and distribute this software
|
||||||
|
* as long as it is accompanied by it's documentation and this copyright notice.
|
||||||
|
* The software comes with no warranty, etc.
|
||||||
|
*/
|
||||||
|
#ifndef DISKUSAGE_H
|
||||||
|
#define DISKUSAGE_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <Entry.h>
|
||||||
|
#include <InterfaceDefs.h>
|
||||||
|
|
||||||
|
|
||||||
|
const rgb_color RGB_WIN = { 0xDE, 0xDB, 0xDE, 0xFF };
|
||||||
|
const rgb_color RGB_PIE_OL = { 0x80, 0x80, 0x80, 0xFF };
|
||||||
|
const rgb_color RGB_PIE_BG = { 0xFF, 0xFF, 0xFF, 0xFF };
|
||||||
|
const rgb_color RGB_PIE_MT = { 0xA0, 0xA0, 0xA0, 0xFF };
|
||||||
|
const rgb_color RGB_PIE_1 = { 0x00, 0x60, 0x60, 0xFF };
|
||||||
|
const rgb_color RGB_PIE_2 = { 0x00, 0x00, 0x68, 0xFF };
|
||||||
|
const rgb_color RGB_PIE_3 = { 0x60, 0x00, 0x60, 0xFF };
|
||||||
|
const rgb_color RGB_PIE_4 = { 0x68, 0x00, 0x00, 0xFF };
|
||||||
|
|
||||||
|
const int kBasePieColorCount = 4;
|
||||||
|
const rgb_color kBasePieColor[kBasePieColorCount]
|
||||||
|
= { RGB_PIE_1, RGB_PIE_2, RGB_PIE_3, RGB_PIE_4 };
|
||||||
|
|
||||||
|
const rgb_color kWindowColor = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||||
|
const rgb_color kOutlineColor = RGB_PIE_OL;
|
||||||
|
const rgb_color kPieBGColor = RGB_PIE_BG;
|
||||||
|
const rgb_color kEmptySpcColor = RGB_PIE_MT;
|
||||||
|
|
||||||
|
const char* const kAppSignature = "application/x-vnd.Haiku-DiskUsage";
|
||||||
|
const char* const kHelpFileName = "userguide/en/applications/diskusage.html";
|
||||||
|
|
||||||
|
const char* const kEmptyStr = "";
|
||||||
|
const char* const kNameFilePtr = "file";
|
||||||
|
|
||||||
|
const float kSmallHMargin = 5.0;
|
||||||
|
const float kSmallVMargin = 2.0;
|
||||||
|
const float kButtonMargin = 20.0;
|
||||||
|
const float kMinButtonWidth = 60.0;
|
||||||
|
|
||||||
|
const float kProgBarWidth = 150.0;
|
||||||
|
const float kProgBarHeight = 16.0;
|
||||||
|
const float kReportInterval = 2.5;
|
||||||
|
|
||||||
|
const float kDefaultPieSize = 400.0;
|
||||||
|
const float kPieCenterSize = 80.0;
|
||||||
|
const float kPieRingSize = 20.0;
|
||||||
|
const float kPieInnerMargin = 10.0;
|
||||||
|
const float kPieOuterMargin = 10.0;
|
||||||
|
const float kMinSegmentSpan = 2.0;
|
||||||
|
const int kLightenFactor = 0x12;
|
||||||
|
const float kDragThreshold = 5.0;
|
||||||
|
|
||||||
|
extern entry_ref helpFileRef;
|
||||||
|
extern bool helpFileWasFound;
|
||||||
|
|
||||||
|
#define kMenuSelectVol 'gMSV'
|
||||||
|
#define kBtnRescan 'gBRF'
|
||||||
|
#define kBtnHelp 'gHLP'
|
||||||
|
#define kScanRefresh 'gSRF'
|
||||||
|
#define kScanProgress 'gSPR'
|
||||||
|
#define kScanDone 'gSDN'
|
||||||
|
#define kOutdatedMsg 'gOUT'
|
||||||
|
|
||||||
|
#define deg2rad(x) (2.0 * M_PI * (x) / 360.0)
|
||||||
|
#define rad2deg(x) (360.0 * (x) / (2.0 * M_PI))
|
||||||
|
|
||||||
|
void size_to_string(off_t byteCount, char* name);
|
||||||
|
|
||||||
|
|
||||||
|
#endif // DISKUSAGE_H
|
||||||
|
|
||||||
@@ -3,13 +3,13 @@ resource app_signature "application/x-vnd.Haiku-DiskUsage";
|
|||||||
resource app_version {
|
resource app_version {
|
||||||
major = 1,
|
major = 1,
|
||||||
middle = 0,
|
middle = 0,
|
||||||
minor = 0,
|
minor = 2,
|
||||||
|
|
||||||
variety = B_APPV_FINAL,
|
variety = B_APPV_FINAL,
|
||||||
internal = 0,
|
internal = 0,
|
||||||
|
|
||||||
short_info = "1.0.1",
|
short_info = "1.0.2",
|
||||||
long_info = "1.0.1 ©1999 Mike Steed, ©2008-2009 Haiku"
|
long_info = "1.0.2 ©1999 Mike Steed, ©2008-2011 Haiku"
|
||||||
};
|
};
|
||||||
|
|
||||||
resource app_flags B_MULTIPLE_LAUNCH;
|
resource app_flags B_MULTIPLE_LAUNCH;
|
||||||
@@ -47,36 +47,3 @@ resource vector_icon {
|
|||||||
$"18001501178600040A01010B1815FF01178400040A08010C000A09010D000A0A"
|
$"18001501178600040A01010B1815FF01178400040A08010C000A09010D000A0A"
|
||||||
$"010E00"
|
$"010E00"
|
||||||
};
|
};
|
||||||
|
|
||||||
resource(101, "RGB_WIN") rgb_color { 0xDE, 0xDB, 0xDE, 0xFF };
|
|
||||||
resource(102, "RGB_PIE_OL") rgb_color { 0x80, 0x80, 0x80, 0xFF };
|
|
||||||
resource(103, "RGB_PIE_BG") rgb_color { 0xFF, 0xFF, 0xFF, 0xFF };
|
|
||||||
resource(104, "RGB_PIE_MT") rgb_color { 0xA0, 0xA0, 0xA0, 0xFF };
|
|
||||||
resource(105, "RGB_PIE_1") rgb_color { 0x00, 0x60, 0x60, 0xFF };
|
|
||||||
resource(106, "RGB_PIE_2") rgb_color { 0x00, 0x00, 0x68, 0xFF };
|
|
||||||
resource(107, "RGB_PIE_3") rgb_color { 0x60, 0x00, 0x60, 0xFF };
|
|
||||||
resource(108, "RGB_PIE_4") rgb_color { 0x68, 0x00, 0x00, 0xFF };
|
|
||||||
|
|
||||||
resource(101, "N_PIE_COLORS") (uint8)4;
|
|
||||||
|
|
||||||
resource(103, "STR_N_FILES") "%d files";
|
|
||||||
resource(102, "STR_1_FILE") "%d file";
|
|
||||||
resource(101, "STR_VM_LABEL") "Volume:";
|
|
||||||
resource(120, "STR_SCAN") "Scan";
|
|
||||||
resource(104, "STR_RESCAN") "Rescan";
|
|
||||||
resource(105, "STR_SCN_X") "Scanning ";
|
|
||||||
resource(106, "STR_UNAVAIL") "file unavailable";
|
|
||||||
resource(107, "STR_VM_DFLT") "(Select)";
|
|
||||||
resource(108, "STR_VPROMPT") "Select a volume to scan";
|
|
||||||
resource(109, "STR_M_INFO") "Get Info";
|
|
||||||
resource(110, "STR_M_OPEN") "Open";
|
|
||||||
resource(111, "STR_M_OPENW") "Open With";
|
|
||||||
resource(112, "STR_M_NAPPS") "no supporting apps";
|
|
||||||
resource(113, "STR_SIZE") "Size";
|
|
||||||
resource(114, "STR_INFILES") " in %d files";
|
|
||||||
resource(115, "STR_MADE") "Created";
|
|
||||||
resource(116, "STR_MOD") "Modified";
|
|
||||||
resource(117, "STR_TIMEFMT") "%a, %d %b %Y, %r";
|
|
||||||
resource(118, "STR_KIND") "Kind";
|
|
||||||
resource(119, "STR_PATH") "Path";
|
|
||||||
resource(121, "STR_OUTDATED") "Outdated view";
|
|
||||||
|
|||||||
@@ -16,17 +16,20 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <Catalog.h>
|
||||||
#include <StringView.h>
|
#include <StringView.h>
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
#include <NodeInfo.h>
|
#include <NodeInfo.h>
|
||||||
|
|
||||||
#include "Common.h"
|
#include "DiskUsage.h"
|
||||||
#include "Snapshot.h"
|
#include "Snapshot.h"
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using std::pair;
|
using std::pair;
|
||||||
|
|
||||||
|
#undef B_TRANSLATE_CONTEXT
|
||||||
|
#define B_TRANSLATE_CONTEXT "Info Window"
|
||||||
|
|
||||||
LeftView::LeftView(BRect frame, BBitmap* icon)
|
LeftView::LeftView(BRect frame, BBitmap* icon)
|
||||||
:
|
:
|
||||||
@@ -65,44 +68,44 @@ InfoWin::InfoWin(BPoint p, FileInfo *f, BWindow* parent)
|
|||||||
typedef pair<string, string> Item;
|
typedef pair<string, string> Item;
|
||||||
typedef vector<Item> InfoList;
|
typedef vector<Item> InfoList;
|
||||||
|
|
||||||
char name[B_PATH_NAME_LENGTH];
|
BString stringTitle("%refName% info");
|
||||||
strcpy(name, f->ref.name);
|
stringTitle.ReplaceFirst("%refName%", f->ref.name);
|
||||||
strcat(name, " info");
|
SetTitle(stringTitle.String());
|
||||||
SetTitle(name);
|
|
||||||
|
|
||||||
InfoList info;
|
InfoList info;
|
||||||
Item item;
|
Item item;
|
||||||
|
|
||||||
// Size
|
// Size
|
||||||
|
char name[B_PATH_NAME_LENGTH] = { 0 };
|
||||||
size_to_string(f->size, name);
|
size_to_string(f->size, name);
|
||||||
if (f->count > 0) {
|
if (f->count > 0) {
|
||||||
// This is a directory.
|
// This is a directory.
|
||||||
char str[64];
|
char str[64];
|
||||||
sprintf(str, kInfoInFiles, f->count);
|
sprintf(str, B_TRANSLATE(" in %d files"), f->count);
|
||||||
strcat(name, str);
|
strcat(name, str);
|
||||||
}
|
}
|
||||||
info.push_back(Item(kInfoSize, name));
|
info.push_back(Item(B_TRANSLATE_MARK("Size"), name));
|
||||||
|
|
||||||
// Created & modified dates
|
// Created & modified dates
|
||||||
BEntry entry(&f->ref);
|
BEntry entry(&f->ref);
|
||||||
time_t t;
|
time_t t;
|
||||||
entry.GetCreationTime(&t);
|
entry.GetCreationTime(&t);
|
||||||
strftime(name, 64, kInfoTimeFmt, localtime(&t));
|
strftime(name, 64, B_TRANSLATE("%a, %d %b %Y, %r"), localtime(&t));
|
||||||
info.push_back(Item(kInfoCreated, name));
|
info.push_back(Item(B_TRANSLATE("Created"), name));
|
||||||
entry.GetModificationTime(&t);
|
entry.GetModificationTime(&t);
|
||||||
strftime(name, 64, kInfoTimeFmt, localtime(&t));
|
strftime(name, 64, B_TRANSLATE("%a, %d %b %Y, %r"), localtime(&t));
|
||||||
info.push_back(Item(kInfoModified, name));
|
info.push_back(Item(B_TRANSLATE("Modified"), name));
|
||||||
|
|
||||||
// Kind
|
// Kind
|
||||||
BMimeType* type = f->Type();
|
BMimeType* type = f->Type();
|
||||||
type->GetShortDescription(name);
|
type->GetShortDescription(name);
|
||||||
info.push_back(Item(kInfoKind, name));
|
info.push_back(Item(B_TRANSLATE("Kind"), name));
|
||||||
delete type;
|
delete type;
|
||||||
|
|
||||||
// Path
|
// Path
|
||||||
string path;
|
string path;
|
||||||
f->GetPath(path);
|
f->GetPath(path);
|
||||||
info.push_back(Item(kInfoPath, path));
|
info.push_back(Item(B_TRANSLATE("Path"), path));
|
||||||
|
|
||||||
// Icon
|
// Icon
|
||||||
BBitmap *icon = new BBitmap(BRect(0.0, 0.0, 31.0, 31.0), B_RGBA32);
|
BBitmap *icon = new BBitmap(BRect(0.0, 0.0, 31.0, 31.0), B_RGBA32);
|
||||||
@@ -122,18 +125,21 @@ InfoWin::InfoWin(BPoint p, FileInfo *f, BWindow* parent)
|
|||||||
float rightWidth = 0.0;
|
float rightWidth = 0.0;
|
||||||
InfoList::iterator i = info.begin();
|
InfoList::iterator i = info.begin();
|
||||||
while (i != info.end()) {
|
while (i != info.end()) {
|
||||||
float w = smallFont.StringWidth((*i).first.c_str()) + 2.0 * kSmallHMargin;
|
float w = smallFont.StringWidth((*i).first.c_str()) +
|
||||||
|
2.0 * kSmallHMargin;
|
||||||
leftWidth = max_c(leftWidth, w);
|
leftWidth = max_c(leftWidth, w);
|
||||||
w = smallFont.StringWidth((*i).second.c_str()) + 2.0 * kSmallHMargin;
|
w = smallFont.StringWidth((*i).second.c_str()) + 2.0 * kSmallHMargin;
|
||||||
rightWidth = max_c(rightWidth, w);
|
rightWidth = max_c(rightWidth, w);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
float winHeight = 32.0 + 4.0 * kSmallVMargin + 5.0 * (fontHeight + kSmallVMargin);
|
float winHeight = 32.0 + 4.0 * kSmallVMargin + 5.0 * (fontHeight
|
||||||
|
+ kSmallVMargin);
|
||||||
float winWidth = leftWidth + rightWidth;
|
float winWidth = leftWidth + rightWidth;
|
||||||
ResizeTo(winWidth, winHeight);
|
ResizeTo(winWidth, winHeight);
|
||||||
|
|
||||||
LeftView *leftView = new LeftView(BRect(0.0, 0.0, leftWidth, winHeight), icon);
|
LeftView *leftView = new LeftView(BRect(0.0, 0.0, leftWidth, winHeight),
|
||||||
|
icon);
|
||||||
BView *rightView = new BView(
|
BView *rightView = new BView(
|
||||||
BRect(leftWidth + 1.0, 0.0, winWidth, winHeight), NULL,
|
BRect(leftWidth + 1.0, 0.0, winWidth, winHeight), NULL,
|
||||||
B_FOLLOW_NONE, B_WILL_DRAW);
|
B_FOLLOW_NONE, B_WILL_DRAW);
|
||||||
@@ -142,8 +148,8 @@ InfoWin::InfoWin(BPoint p, FileInfo *f, BWindow* parent)
|
|||||||
AddChild(rightView);
|
AddChild(rightView);
|
||||||
|
|
||||||
BStringView *sv = new BStringView(
|
BStringView *sv = new BStringView(
|
||||||
BRect(kSmallHMargin, kSmallVMargin, rightView->Bounds().Width(), kSmallVMargin + 30.0),
|
BRect(kSmallHMargin, kSmallVMargin, rightView->Bounds().Width(),
|
||||||
NULL, f->ref.name, B_FOLLOW_ALL);
|
kSmallVMargin + 30.0), NULL, f->ref.name, B_FOLLOW_ALL);
|
||||||
|
|
||||||
BFont largeFont(be_plain_font);
|
BFont largeFont(be_plain_font);
|
||||||
largeFont.SetSize(ceilf(largeFont.Size() * 1.1));
|
largeFont.SetSize(ceilf(largeFont.Size() * 1.1));
|
||||||
@@ -154,16 +160,16 @@ InfoWin::InfoWin(BPoint p, FileInfo *f, BWindow* parent)
|
|||||||
i = info.begin();
|
i = info.begin();
|
||||||
while (i != info.end()) {
|
while (i != info.end()) {
|
||||||
sv = new BStringView(
|
sv = new BStringView(
|
||||||
BRect(kSmallHMargin, y, leftView->Bounds().Width(), y + fontHeight),
|
BRect(kSmallHMargin, y, leftView->Bounds().Width(),
|
||||||
NULL, (*i).first.c_str());
|
y + fontHeight), NULL, (*i).first.c_str());
|
||||||
sv->SetFont(&smallFont);
|
sv->SetFont(&smallFont);
|
||||||
sv->SetAlignment(B_ALIGN_RIGHT);
|
sv->SetAlignment(B_ALIGN_RIGHT);
|
||||||
sv->SetHighColor(kBasePieColor[1]); // arbitrary
|
sv->SetHighColor(kBasePieColor[1]); // arbitrary
|
||||||
leftView->AddChild(sv);
|
leftView->AddChild(sv);
|
||||||
|
|
||||||
sv = new BStringView(
|
sv = new BStringView(
|
||||||
BRect(kSmallHMargin, y, rightView->Bounds().Width(), y + fontHeight),
|
BRect(kSmallHMargin, y, rightView->Bounds().Width(),
|
||||||
NULL, (*i).second.c_str());
|
y + fontHeight), NULL, (*i).second.c_str());
|
||||||
sv->SetFont(&smallFont);
|
sv->SetFont(&smallFont);
|
||||||
rightView->AddChild(sv);
|
rightView->AddChild(sv);
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ SubDirHdrs $(HAIKU_TOP) src kits tracker ;
|
|||||||
|
|
||||||
Application DiskUsage :
|
Application DiskUsage :
|
||||||
App.cpp
|
App.cpp
|
||||||
Common.cpp
|
|
||||||
ControlsView.cpp
|
ControlsView.cpp
|
||||||
DiskUsage.cpp
|
DiskUsage.cpp
|
||||||
InfoWindow.cpp
|
InfoWindow.cpp
|
||||||
@@ -15,7 +14,18 @@ Application DiskUsage :
|
|||||||
Snapshot.cpp
|
Snapshot.cpp
|
||||||
StatusView.cpp
|
StatusView.cpp
|
||||||
VolumeView.cpp
|
VolumeView.cpp
|
||||||
: be $(TARGET_LIBSTDC++)
|
: be $(HAIKU_LOCALE_LIBS) $(TARGET_LIBSTDC++)
|
||||||
: DiskUsage.rdef
|
: DiskUsage.rdef
|
||||||
;
|
;
|
||||||
|
|
||||||
|
DoCatalogs DiskUsage :
|
||||||
|
x-vnd.Haiku-DiskUsage
|
||||||
|
:
|
||||||
|
MainWindow.cpp
|
||||||
|
InfoWindow.cpp
|
||||||
|
PieView.cpp
|
||||||
|
Scanner.cpp
|
||||||
|
StatusView.cpp
|
||||||
|
VolumeView.cpp
|
||||||
|
;
|
||||||
|
|
||||||
|
|||||||
@@ -10,19 +10,22 @@
|
|||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
|
#include <Catalog.h>
|
||||||
#include <Node.h>
|
#include <Node.h>
|
||||||
#include <Roster.h>
|
#include <Roster.h>
|
||||||
#include <Screen.h>
|
#include <Screen.h>
|
||||||
|
|
||||||
#include <LayoutBuilder.h>
|
#include <LayoutBuilder.h>
|
||||||
|
|
||||||
#include "Common.h"
|
#include "DiskUsage.h"
|
||||||
#include "ControlsView.h"
|
#include "ControlsView.h"
|
||||||
|
|
||||||
|
#undef B_TRANSLATE_CONTEXT
|
||||||
|
#define B_TRANSLATE_CONTEXT "MainWindow"
|
||||||
|
|
||||||
MainWindow::MainWindow(BRect pieRect)
|
MainWindow::MainWindow(BRect pieRect)
|
||||||
:
|
:
|
||||||
BWindow(pieRect, "DiskUsage", B_TITLED_WINDOW,
|
BWindow(pieRect, B_TRANSLATE("DiskUsage"), B_TITLED_WINDOW,
|
||||||
B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE
|
B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE
|
||||||
| B_AUTO_UPDATE_SIZE_LIMITS)
|
| B_AUTO_UPDATE_SIZE_LIMITS)
|
||||||
{
|
{
|
||||||
@@ -57,7 +60,8 @@ MainWindow::MessageReceived(BMessage* message)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case kBtnHelp:
|
case kBtnHelp:
|
||||||
be_roster->Launch(&kHelpFileRef);
|
if (helpFileWasFound)
|
||||||
|
be_roster->Launch(&helpFileRef);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include <AppFileInfo.h>
|
#include <AppFileInfo.h>
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
|
#include <Catalog.h>
|
||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
@@ -29,11 +30,13 @@
|
|||||||
#include <tracker_private.h>
|
#include <tracker_private.h>
|
||||||
|
|
||||||
#include "Commands.h"
|
#include "Commands.h"
|
||||||
#include "Common.h"
|
#include "DiskUsage.h"
|
||||||
#include "InfoWindow.h"
|
#include "InfoWindow.h"
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "Scanner.h"
|
#include "Scanner.h"
|
||||||
|
|
||||||
|
#undef B_TRANSLATE_CONTEXT
|
||||||
|
#define B_TRANSLATE_CONTEXT "Pie View"
|
||||||
|
|
||||||
static const int32 kIdxGetInfo = 0;
|
static const int32 kIdxGetInfo = 0;
|
||||||
static const int32 kIdxOpen = 1;
|
static const int32 kIdxOpen = 1;
|
||||||
@@ -96,7 +99,8 @@ void
|
|||||||
AppMenuItem::GetContentSize(float* _width, float* _height)
|
AppMenuItem::GetContentSize(float* _width, float* _height)
|
||||||
{
|
{
|
||||||
if (_width)
|
if (_width)
|
||||||
*_width = fIcon->Bounds().Width() + be_plain_font->StringWidth(Label());
|
*_width = fIcon->Bounds().Width() +
|
||||||
|
be_plain_font->StringWidth(Label());
|
||||||
|
|
||||||
if (_height) {
|
if (_height) {
|
||||||
struct font_height fh;
|
struct font_height fh;
|
||||||
@@ -134,11 +138,13 @@ PieView::PieView(BVolume* volume)
|
|||||||
fOutdated(false)
|
fOutdated(false)
|
||||||
{
|
{
|
||||||
fMouseOverMenu = new BPopUpMenu(kEmptyStr, false, false);
|
fMouseOverMenu = new BPopUpMenu(kEmptyStr, false, false);
|
||||||
fMouseOverMenu->AddItem(new BMenuItem(kMenuGetInfo, NULL), kIdxGetInfo);
|
fMouseOverMenu->AddItem(new BMenuItem(B_TRANSLATE("Get Info"), NULL),
|
||||||
fMouseOverMenu->AddItem(new BMenuItem(kMenuOpen, NULL), kIdxOpen);
|
kIdxGetInfo);
|
||||||
|
fMouseOverMenu->AddItem(new BMenuItem(B_TRANSLATE("Open"), NULL),
|
||||||
|
kIdxOpen);
|
||||||
|
|
||||||
fFileUnavailableMenu = new BPopUpMenu(kEmptyStr, false, false);
|
fFileUnavailableMenu = new BPopUpMenu(kEmptyStr, false, false);
|
||||||
BMenuItem* item = new BMenuItem(kStrUnavail, NULL);
|
BMenuItem* item = new BMenuItem(B_TRANSLATE("file unavailable"), NULL);
|
||||||
item->SetEnabled(false);
|
item->SetEnabled(false);
|
||||||
fFileUnavailableMenu->AddItem(item);
|
fFileUnavailableMenu->AddItem(item);
|
||||||
|
|
||||||
@@ -424,14 +430,14 @@ PieView::_DrawPieChart(BRect updateRect)
|
|||||||
parent = parent->parent;
|
parent = parent->parent;
|
||||||
colorIdx++;
|
colorIdx++;
|
||||||
}
|
}
|
||||||
_DrawDirectory(pieRect, currentDir, 0.0, 0.0, colorIdx % kBasePieColorCount,
|
_DrawDirectory(pieRect, currentDir, 0.0, 0.0,
|
||||||
0);
|
colorIdx % kBasePieColorCount, 0);
|
||||||
|
|
||||||
if (fOutdated) {
|
if (fOutdated) {
|
||||||
|
|
||||||
BRect b = Bounds();
|
BRect b = Bounds();
|
||||||
|
|
||||||
float strWidth = StringWidth(kOutdatedStr);
|
float strWidth = StringWidth(B_TRANSLATE("Outdated view"));
|
||||||
float bx = (b.Width() - strWidth - kSmallHMargin);
|
float bx = (b.Width() - strWidth - kSmallHMargin);
|
||||||
|
|
||||||
struct font_height fh;
|
struct font_height fh;
|
||||||
@@ -439,7 +445,7 @@ PieView::_DrawPieChart(BRect updateRect)
|
|||||||
|
|
||||||
float by = (b.Height() - ceil(fh.descent) - kSmallVMargin);
|
float by = (b.Height() - ceil(fh.descent) - kSmallVMargin);
|
||||||
SetHighColor(0x00, 0x00, 0x00);
|
SetHighColor(0x00, 0x00, 0x00);
|
||||||
DrawString(kOutdatedStr, BPoint(bx, by));
|
DrawString(B_TRANSLATE("Outdated view"), BPoint(bx, by));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -711,10 +717,11 @@ PieView::_BuildOpenWithMenu(FileInfo* info)
|
|||||||
|
|
||||||
delete type;
|
delete type;
|
||||||
|
|
||||||
BMenu* openWith = new BMenu(kMenuOpenWith);
|
BMenu* openWith = new BMenu(B_TRANSLATE("Open With"));
|
||||||
|
|
||||||
if (appList.size() == 0) {
|
if (appList.size() == 0) {
|
||||||
BMenuItem* item = new BMenuItem(kMenuNoApps, NULL);
|
BMenuItem* item = new BMenuItem(B_TRANSLATE("no supporting apps"),
|
||||||
|
NULL);
|
||||||
item->SetEnabled(false);
|
item->SetEnabled(false);
|
||||||
openWith->AddItem(item);
|
openWith->AddItem(item);
|
||||||
} else {
|
} else {
|
||||||
@@ -749,7 +756,7 @@ PieView::_ShowContextMenu(FileInfo* info, BPoint p)
|
|||||||
// Add a "Rescan" option for folders.
|
// Add a "Rescan" option for folders.
|
||||||
BMenuItem* rescan = NULL;
|
BMenuItem* rescan = NULL;
|
||||||
if (info->children.size() > 0) {
|
if (info->children.size() > 0) {
|
||||||
rescan = new BMenuItem(kStrRescan, NULL);
|
rescan = new BMenuItem(B_TRANSLATE("Rescan"), NULL);
|
||||||
fMouseOverMenu->AddItem(rescan, kIdxRescan);
|
fMouseOverMenu->AddItem(rescan, kIdxRescan);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,10 +13,14 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <Catalog.h>
|
||||||
#include <Directory.h>
|
#include <Directory.h>
|
||||||
#include <PathMonitor.h>
|
#include <PathMonitor.h>
|
||||||
|
|
||||||
#include "Common.h"
|
#include "DiskUsage.h"
|
||||||
|
|
||||||
|
#undef B_TRANSLATE_CONTEXT
|
||||||
|
#define B_TRANSLATE_CONTEXT "Scanner"
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
@@ -63,7 +67,8 @@ Scanner::MessageReceived(BMessage* message)
|
|||||||
case kScanRefresh:
|
case kScanRefresh:
|
||||||
{
|
{
|
||||||
FileInfo* startInfo;
|
FileInfo* startInfo;
|
||||||
if (message->FindPointer(kNameFilePtr, (void **)&startInfo) == B_OK)
|
if (message->FindPointer(kNameFilePtr, (void **)&startInfo)
|
||||||
|
== B_OK)
|
||||||
_RunScan(startInfo);
|
_RunScan(startInfo);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -200,10 +205,13 @@ Scanner::_DirectoryContains(FileInfo* currentDir, entry_ref* ref)
|
|||||||
void
|
void
|
||||||
Scanner::_RunScan(FileInfo* startInfo)
|
Scanner::_RunScan(FileInfo* startInfo)
|
||||||
{
|
{
|
||||||
|
BString stringScan(B_TRANSLATE("Scanning %refName%"));
|
||||||
|
|
||||||
if (startInfo == NULL || startInfo == fSnapshot->rootDir) {
|
if (startInfo == NULL || startInfo == fSnapshot->rootDir) {
|
||||||
delete fSnapshot;
|
delete fSnapshot;
|
||||||
fSnapshot = new VolumeSnapshot(fVolume);
|
fSnapshot = new VolumeSnapshot(fVolume);
|
||||||
fTask = kStrScanningX + fSnapshot->name;
|
stringScan.ReplaceFirst("%refName%", fSnapshot->name.c_str());
|
||||||
|
fTask = stringScan.String();
|
||||||
fVolumeBytesInUse = fSnapshot->capacity - fSnapshot->freeBytes;
|
fVolumeBytesInUse = fSnapshot->capacity - fSnapshot->freeBytes;
|
||||||
fVolumeBytesScanned = 0;
|
fVolumeBytesScanned = 0;
|
||||||
fProgress = 0.0;
|
fProgress = 0.0;
|
||||||
@@ -215,8 +223,9 @@ Scanner::_RunScan(FileInfo* startInfo)
|
|||||||
|
|
||||||
FileInfo* freeSpace = new FileInfo;
|
FileInfo* freeSpace = new FileInfo;
|
||||||
freeSpace->pseudo = true;
|
freeSpace->pseudo = true;
|
||||||
string s = "Free on " + fSnapshot->name;
|
BString string(B_TRANSLATE("Free on %refName%"));
|
||||||
freeSpace->ref.set_name(s.c_str());
|
string.ReplaceFirst("%refName%", fSnapshot->name.c_str());
|
||||||
|
freeSpace->ref.set_name(string.String());
|
||||||
freeSpace->size = fSnapshot->freeBytes;
|
freeSpace->size = fSnapshot->freeBytes;
|
||||||
fSnapshot->freeSpace = freeSpace;
|
fSnapshot->freeSpace = freeSpace;
|
||||||
|
|
||||||
@@ -225,9 +234,10 @@ Scanner::_RunScan(FileInfo* startInfo)
|
|||||||
} else {
|
} else {
|
||||||
fSnapshot->capacity = fVolume->Capacity();
|
fSnapshot->capacity = fVolume->Capacity();
|
||||||
fSnapshot->freeBytes = fVolume->FreeBytes();
|
fSnapshot->freeBytes = fVolume->FreeBytes();
|
||||||
fTask = kStrScanningX + string(startInfo->ref.name);
|
stringScan.ReplaceFirst("%refName%", startInfo->ref.name);
|
||||||
|
fTask = stringScan.String();
|
||||||
fVolumeBytesInUse = fSnapshot->capacity - fSnapshot->freeBytes;
|
fVolumeBytesInUse = fSnapshot->capacity - fSnapshot->freeBytes;
|
||||||
fVolumeBytesScanned = fVolumeBytesInUse - startInfo->size; // best guess
|
fVolumeBytesScanned = fVolumeBytesInUse - startInfo->size; //best guess
|
||||||
fProgress = 100.0 * fVolumeBytesScanned / fVolumeBytesInUse;
|
fProgress = 100.0 * fVolumeBytesScanned / fVolumeBytesInUse;
|
||||||
fLastReport = -100.0;
|
fLastReport = -100.0;
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <Catalog.h>
|
||||||
#include <Box.h>
|
#include <Box.h>
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
#include <Node.h>
|
#include <Node.h>
|
||||||
@@ -22,9 +23,11 @@
|
|||||||
|
|
||||||
#include <LayoutBuilder.h>
|
#include <LayoutBuilder.h>
|
||||||
|
|
||||||
#include "Common.h"
|
#include "DiskUsage.h"
|
||||||
#include "Scanner.h"
|
#include "Scanner.h"
|
||||||
|
|
||||||
|
#undef B_TRANSLATE_CONTEXT
|
||||||
|
#define B_TRANSLATE_CONTEXT "Status View"
|
||||||
|
|
||||||
StatusView::StatusView()
|
StatusView::StatusView()
|
||||||
:
|
:
|
||||||
@@ -35,13 +38,13 @@ StatusView::StatusView()
|
|||||||
SetLowColor(kPieBGColor);
|
SetLowColor(kPieBGColor);
|
||||||
|
|
||||||
fSizeView = new BStringView(NULL, kEmptyStr);
|
fSizeView = new BStringView(NULL, kEmptyStr);
|
||||||
fSizeView->SetExplicitMinSize(BSize(StringWidth("9999.99 GB"),
|
fSizeView->SetExplicitMinSize(BSize(StringWidth(B_TRANSLATE("9999.99 GB")),
|
||||||
B_SIZE_UNSET));
|
B_SIZE_UNSET));
|
||||||
fSizeView->SetExplicitMaxSize(BSize(StringWidth("9999.99 GB"),
|
fSizeView->SetExplicitMaxSize(BSize(StringWidth(B_TRANSLATE("9999.99 GB")),
|
||||||
B_SIZE_UNSET));
|
B_SIZE_UNSET));
|
||||||
|
|
||||||
char testLabel[256];
|
char testLabel[256];
|
||||||
sprintf(testLabel, kManyFiles, 999999);
|
sprintf(testLabel, B_TRANSLATE("%d files"), 999999);
|
||||||
|
|
||||||
fCountView = new BStringView(NULL, kEmptyStr);
|
fCountView = new BStringView(NULL, kEmptyStr);
|
||||||
fCountView->SetExplicitMinSize(BSize(StringWidth(testLabel), B_SIZE_UNSET));
|
fCountView->SetExplicitMinSize(BSize(StringWidth(testLabel), B_SIZE_UNSET));
|
||||||
@@ -50,7 +53,7 @@ StatusView::StatusView()
|
|||||||
fPathView = new BStringView(NULL, kEmptyStr);
|
fPathView = new BStringView(NULL, kEmptyStr);
|
||||||
fPathView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
|
fPathView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
|
||||||
|
|
||||||
fRefreshBtn = new BButton(NULL, kStrScan, new BMessage(kBtnRescan));
|
fRefreshBtn = new BButton(NULL, B_TRANSLATE("Scan"), new BMessage(kBtnRescan));
|
||||||
|
|
||||||
fRefreshBtn->SetExplicitMaxSize(BSize(B_SIZE_UNSET, B_SIZE_UNLIMITED));
|
fRefreshBtn->SetExplicitMaxSize(BSize(B_SIZE_UNSET, B_SIZE_UNLIMITED));
|
||||||
|
|
||||||
@@ -119,7 +122,7 @@ StatusView::ShowInfo(const FileInfo* info)
|
|||||||
if (!info->pseudo) {
|
if (!info->pseudo) {
|
||||||
BNode node(&info->ref);
|
BNode node(&info->ref);
|
||||||
if (node.InitCheck() != B_OK) {
|
if (node.InitCheck() != B_OK) {
|
||||||
fPathView->SetText(kStrUnavail);
|
fPathView->SetText(B_TRANSLATE("file unavailable"));
|
||||||
fSizeView->SetText(kEmptyStr);
|
fSizeView->SetText(kEmptyStr);
|
||||||
fCountView->SetText(kEmptyStr);
|
fCountView->SetText(kEmptyStr);
|
||||||
return;
|
return;
|
||||||
@@ -139,7 +142,8 @@ StatusView::ShowInfo(const FileInfo* info)
|
|||||||
|
|
||||||
if (info->count > 0) {
|
if (info->count > 0) {
|
||||||
char label[256];
|
char label[256];
|
||||||
sprintf(label, (info->count == 1) ? kOneFile : kManyFiles, info->count);
|
sprintf(label, (info->count == 1) ? B_TRANSLATE("%d file") :
|
||||||
|
B_TRANSLATE("%d files"), info->count);
|
||||||
fCountView->SetText(label);
|
fCountView->SetText(label);
|
||||||
} else {
|
} else {
|
||||||
fCountView->SetText(kEmptyStr);
|
fCountView->SetText(kEmptyStr);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <Catalog.h>
|
||||||
#include <Box.h>
|
#include <Box.h>
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
#include <StringView.h>
|
#include <StringView.h>
|
||||||
@@ -16,13 +17,16 @@
|
|||||||
|
|
||||||
#include <LayoutBuilder.h>
|
#include <LayoutBuilder.h>
|
||||||
|
|
||||||
#include "Common.h"
|
#include "DiskUsage.h"
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "PieView.h"
|
#include "PieView.h"
|
||||||
#include "StatusView.h"
|
#include "StatusView.h"
|
||||||
|
|
||||||
#include "VolumeView.h"
|
#include "VolumeView.h"
|
||||||
|
|
||||||
|
#undef B_TRANSLATE_CONTEXT
|
||||||
|
#define B_TRANSLATE_CONTEXT "Volume View"
|
||||||
|
|
||||||
const float kMinWinSize = 275.0;
|
const float kMinWinSize = 275.0;
|
||||||
|
|
||||||
VolumeView::VolumeView(const char* name, BVolume* volume)
|
VolumeView::VolumeView(const char* name, BVolume* volume)
|
||||||
@@ -58,7 +62,7 @@ void
|
|||||||
VolumeView::SetPath(BPath path)
|
VolumeView::SetPath(BPath path)
|
||||||
{
|
{
|
||||||
fPieView->SetPath(path);
|
fPieView->SetPath(path);
|
||||||
fStatusView->SetBtnLabel(kStrRescan);
|
fStatusView->SetBtnLabel(B_TRANSLATE("Rescan"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -69,7 +73,7 @@ VolumeView::MessageReceived(BMessage* msg)
|
|||||||
switch(msg->what) {
|
switch(msg->what) {
|
||||||
case kBtnRescan:
|
case kBtnRescan:
|
||||||
fPieView->MessageReceived(msg);
|
fPieView->MessageReceived(msg);
|
||||||
fStatusView->SetBtnLabel(kStrRescan);
|
fStatusView->SetBtnLabel(B_TRANSLATE("Rescan"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user