-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDSystemInfoWindow.cpp
More file actions
111 lines (99 loc) · 3.7 KB
/
DSystemInfoWindow.cpp
File metadata and controls
111 lines (99 loc) · 3.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#include <Alert.h>
#include <String.h>
#include "DSystemInfo.h"
#include "DSystemInfoWindow.h"
DSystemInfoWindow::DSystemInfoWindow(BRect frame) : BWindow(frame,"D System Info",B_TITLED_WINDOW,B_NOT_RESIZABLE)
{
fSysInfoView = new DSystemInfoView(BRect(0, 20, Bounds().right, Bounds().bottom), (char*)"DSystemInfoView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_PULSE_NEEDED);
fSysInfoView->AttachedToWindow();
AddChild(fSysInfoView);
fSysInfoView->UpdateSystemInfo();
fMenuBar = new BMenuBar(BRect(0,0,Bounds().right,20),"MenuBar");
fSystem = new BMenu("System");
fSystem->AddItem(new BMenuItem("Volume more info...",new BMessage(kVolumeMoreInfo)));
// fSystem->AddSeparatorItem();
// fSystem->AddItem(new BMenuItem("Preferences...",NULL));
fSystem->AddSeparatorItem();
fSystem->AddItem(new BMenuItem("Quit",new BMessage(B_QUIT_REQUESTED)));
fMenuBar->AddItem(fSystem);
fAbout = new BMenu("About");
fAbout->AddItem(new BMenuItem("About D System Info...",new BMessage(B_ABOUT_REQUESTED)));
fMenuBar->AddItem(fAbout);
AddChild(fMenuBar);
BMessenger msgr(this);
volumeRoster = new BVolumeRoster();
volumeRoster->StartWatching(msgr); // to control when a volume is mounted/unmounted
}
DSystemInfoWindow::~DSystemInfoWindow(void)
{
volumeRoster->StopWatching(); // stop the volume roster
delete volumeRoster;
fSysInfoView->RemoveSelf();
delete fSysInfoView;
}
void
DSystemInfoWindow::MessageReceived(BMessage* message)
{
int32 DeviceID = 0;
char volName[B_FILE_NAME_LENGTH];
int64 Capacity, FreeBytes;
BString label,trailing;
switch(message->what) {
case kVolumeMessage: {
message->FindInt32("DevID",&DeviceID);
fSysInfoView->SetDevice((dev_t)DeviceID);
fSysInfoView->GetVolName(volName);
Capacity = fSysInfoView->VolumeCapacity();
FreeBytes = fSysInfoView->VolumeFreeBytes();
label << volName;
if(Capacity <= 250000000) {
trailing << (Capacity - FreeBytes) / 1024 << " KB used - " << FreeBytes / 1024 << " KB free - " << Capacity / 1024 << " KB total";
} else {
trailing << (Capacity - FreeBytes) / 1024 / 1024 << " MB used - " << FreeBytes / 1024 / 1024 << " MB free - " << Capacity / 1024 / 1024 << " MB total";
}
fSysInfoView->UpdateFileSystemStatusBar((char*)label.String(),(char*)trailing.String(),Capacity,FreeBytes);
break;
}
case kVolumeMoreInfo: {
BMessenger* mes = new BMessenger(fSysInfoView);
mes->SendMessage(new BMessage(kVolumeMoreInfo));
delete mes;
break;
}
case B_ABOUT_REQUESTED: {
(new BAlert("Diego", "D System Info release 0.2.6-20181204\n\nDiego Lago <diego.lago.gonzalez@gmail.com>\n\n"
"Thanks to Héctor López for his help and discover BeOS to me. Thanks to all the people who help "
"me when I need it. Thanks to Be Inc. for make BeOS and thanks to Haiku team.","hehe!"))->Go();
break;
}
case B_NODE_MONITOR: { // a volume has been mounted/unmounted
Lock();
fSysInfoView->RebuildFileSystemMenu();
Unlock();
int32 opcode;
message->FindInt32("opcode",&opcode);
switch(opcode) {
case B_DEVICE_MOUNTED: // device mounted
break;
case B_DEVICE_UNMOUNTED: // if the device unmounted is showing, select boot
BMessenger mes(fSysInfoView);
mes.SendMessage(kSelectBoot);
break;
}
break;
}
default: BWindow::MessageReceived(message); break;
}
}
bool
DSystemInfoWindow::QuitRequested(void)
{
be_app->PostMessage(B_QUIT_REQUESTED);
return true;
}
void
DSystemInfoWindow::Zoom(BPoint P,float x,float y)
// About box when you press... ZOOM
{
PostMessage(B_ABOUT_REQUESTED);
}