Made ActivityMonitor buildable under BeOS (at least BONE).
This is only temporary, to help test adding data sources, so the gross #ifdef __HAIKU__ are intentional to keep BeOS-only code (without layout support) trackable. It is not fully functional but sufficient for testing and will go away later. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25009 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -140,7 +140,11 @@ ActivityView::ActivityView(BRect frame, const char* name,
|
|||||||
|
|
||||||
|
|
||||||
ActivityView::ActivityView(const char* name, const BMessage* settings)
|
ActivityView::ActivityView(const char* name, const BMessage* settings)
|
||||||
|
#ifdef __HAIKU__
|
||||||
: BView(name, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_FRAME_EVENTS)
|
: BView(name, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_FRAME_EVENTS)
|
||||||
|
#else
|
||||||
|
: BView(BRect(0,0,300,200), name, B_FOLLOW_NONE, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_FRAME_EVENTS)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
_Init(settings);
|
_Init(settings);
|
||||||
|
|
||||||
@@ -359,6 +363,7 @@ ActivityView::DetachedFromWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __HAIKU__
|
||||||
BSize
|
BSize
|
||||||
ActivityView::MinSize()
|
ActivityView::MinSize()
|
||||||
{
|
{
|
||||||
@@ -368,6 +373,7 @@ ActivityView::MinSize()
|
|||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -64,7 +64,9 @@ protected:
|
|||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void DetachedFromWindow();
|
virtual void DetachedFromWindow();
|
||||||
|
|
||||||
|
#ifdef __HAIKU__
|
||||||
virtual BSize MinSize();
|
virtual BSize MinSize();
|
||||||
|
#endif
|
||||||
|
|
||||||
virtual void FrameResized(float width, float height);
|
virtual void FrameResized(float width, float height);
|
||||||
virtual void MouseDown(BPoint where);
|
virtual void MouseDown(BPoint where);
|
||||||
|
|||||||
@@ -11,7 +11,9 @@
|
|||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
|
#ifdef __HAIKU__
|
||||||
#include <GroupLayout.h>
|
#include <GroupLayout.h>
|
||||||
|
#endif
|
||||||
#include <Menu.h>
|
#include <Menu.h>
|
||||||
#include <MenuBar.h>
|
#include <MenuBar.h>
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
@@ -39,6 +41,7 @@ ActivityWindow::ActivityWindow()
|
|||||||
ResizeTo(frame.Width(), frame.Height());
|
ResizeTo(frame.Width(), frame.Height());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __HAIKU__
|
||||||
BGroupLayout* layout = new BGroupLayout(B_VERTICAL);
|
BGroupLayout* layout = new BGroupLayout(B_VERTICAL);
|
||||||
SetLayout(layout);
|
SetLayout(layout);
|
||||||
|
|
||||||
@@ -66,6 +69,41 @@ ActivityWindow::ActivityWindow()
|
|||||||
if (count == 0)
|
if (count == 0)
|
||||||
fLayout->AddView(new ActivityView("ActivityMonitor", NULL));
|
fLayout->AddView(new ActivityView("ActivityMonitor", NULL));
|
||||||
|
|
||||||
|
#else
|
||||||
|
BView *layout = new BView(Bounds(), "topmost", B_FOLLOW_NONE, 0);
|
||||||
|
AddChild(layout);
|
||||||
|
|
||||||
|
// create GUI
|
||||||
|
BRect mbRect(Bounds());
|
||||||
|
mbRect.bottom = 10;
|
||||||
|
BMenuBar* menuBar = new BMenuBar(mbRect, "menu");
|
||||||
|
layout->AddChild(menuBar);
|
||||||
|
|
||||||
|
BRect topRect(Bounds());
|
||||||
|
topRect.top = menuBar->Bounds().bottom + 1;
|
||||||
|
|
||||||
|
BView* top = new BView(topRect, "top", B_FOLLOW_ALL, 0);
|
||||||
|
top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
layout->AddChild(top);
|
||||||
|
|
||||||
|
BMessage viewState;
|
||||||
|
int32 count = 0;
|
||||||
|
ActivityView *aview;
|
||||||
|
BRect rect;
|
||||||
|
for (int32 i = 0; settings.FindMessage("activity view", i, &viewState)
|
||||||
|
== B_OK; i++) {
|
||||||
|
aview = new ActivityView("ActivityMonitor", &viewState);
|
||||||
|
if (!rect.IsValid())
|
||||||
|
rect = aview->Bounds();
|
||||||
|
else
|
||||||
|
rect.OffsetBySelf(0.0, aview->Bounds().Height());
|
||||||
|
top->AddChild(aview);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
if (count == 0)
|
||||||
|
top->AddChild(new ActivityView("ActivityMonitor", NULL));
|
||||||
|
|
||||||
|
#endif
|
||||||
// add menu
|
// add menu
|
||||||
|
|
||||||
// "File" menu
|
// "File" menu
|
||||||
@@ -134,7 +172,11 @@ ActivityWindow::_SaveSettings()
|
|||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
|
#ifdef __HAIKU__
|
||||||
BView* top = GetLayout()->View();
|
BView* top = GetLayout()->View();
|
||||||
|
#else
|
||||||
|
BView *top = ChildAt(0);
|
||||||
|
#endif
|
||||||
int32 count = top->CountChildren();
|
int32 count = top->CountChildren();
|
||||||
for (int32 i = 0; i < count; i++) {
|
for (int32 i = 0; i < count; i++) {
|
||||||
ActivityView* view = dynamic_cast<ActivityView*>(top->ChildAt(i));
|
ActivityView* view = dynamic_cast<ActivityView*>(top->ChildAt(i));
|
||||||
@@ -161,10 +203,12 @@ ActivityWindow::_SaveSettings()
|
|||||||
void
|
void
|
||||||
ActivityWindow::_UpdateRemoveItem()
|
ActivityWindow::_UpdateRemoveItem()
|
||||||
{
|
{
|
||||||
|
#ifdef __HAIKU__
|
||||||
BView* view = fLayout->View();
|
BView* view = fLayout->View();
|
||||||
int32 count = view->CountChildren();
|
int32 count = view->CountChildren();
|
||||||
|
|
||||||
fRemoveItem->SetEnabled(count >= 2);
|
fRemoveItem->SetEnabled(count >= 2);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -194,16 +238,19 @@ ActivityWindow::MessageReceived(BMessage* message)
|
|||||||
|
|
||||||
case kMsgAddView:
|
case kMsgAddView:
|
||||||
{
|
{
|
||||||
|
#ifdef __HAIKU__
|
||||||
BView* view = fLayout->View()->ChildAt(0);
|
BView* view = fLayout->View()->ChildAt(0);
|
||||||
fLayout->AddView(new ActivityView("ActivityMonitor", NULL));
|
fLayout->AddView(new ActivityView("ActivityMonitor", NULL));
|
||||||
if (view != NULL)
|
if (view != NULL)
|
||||||
ResizeBy(0, view->Bounds().Height() + fLayout->Spacing());
|
ResizeBy(0, view->Bounds().Height() + fLayout->Spacing());
|
||||||
|
#endif
|
||||||
_UpdateRemoveItem();
|
_UpdateRemoveItem();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case kMsgRemoveView:
|
case kMsgRemoveView:
|
||||||
{
|
{
|
||||||
|
#ifdef __HAIKU__
|
||||||
BView* view = fLayout->View();
|
BView* view = fLayout->View();
|
||||||
int32 count = view->CountChildren();
|
int32 count = view->CountChildren();
|
||||||
if (count == 1)
|
if (count == 1)
|
||||||
@@ -213,6 +260,7 @@ ActivityWindow::MessageReceived(BMessage* message)
|
|||||||
fLayout->RemoveView(last);
|
fLayout->RemoveView(last);
|
||||||
ResizeBy(0, -last->Bounds().Height() - fLayout->Spacing());
|
ResizeBy(0, -last->Bounds().Height() - fLayout->Spacing());
|
||||||
delete last;
|
delete last;
|
||||||
|
#endif
|
||||||
|
|
||||||
_UpdateRemoveItem();
|
_UpdateRemoveItem();
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -30,7 +30,9 @@ private:
|
|||||||
void _UpdateRemoveItem();
|
void _UpdateRemoveItem();
|
||||||
void _MessageDropped(BMessage *message);
|
void _MessageDropped(BMessage *message);
|
||||||
|
|
||||||
|
#ifdef __HAIKU__
|
||||||
BGroupLayout* fLayout;
|
BGroupLayout* fLayout;
|
||||||
|
#endif
|
||||||
BMenuItem* fRemoveItem;
|
BMenuItem* fRemoveItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
SubDir HAIKU_TOP src apps activitymonitor ;
|
SubDir HAIKU_TOP src apps activitymonitor ;
|
||||||
|
|
||||||
|
# XXX: Temporary only
|
||||||
|
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||||
|
|
||||||
UsePrivateHeaders shared ;
|
UsePrivateHeaders shared ;
|
||||||
|
|
||||||
Application ActivityMonitor :
|
Application ActivityMonitor :
|
||||||
@@ -9,6 +12,6 @@ Application ActivityMonitor :
|
|||||||
DataSource.cpp
|
DataSource.cpp
|
||||||
SystemInfo.cpp
|
SystemInfo.cpp
|
||||||
|
|
||||||
: be tracker $(TARGET_LIBSTDC++) libnetwork.so
|
: be tracker $(TARGET_LIBSTDC++) $(TARGET_NETWORK_LIBS)
|
||||||
: ActivityMonitor.rdef
|
: ActivityMonitor.rdef
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/sockio.h>
|
#include <sys/sockio.h>
|
||||||
|
|
||||||
@@ -30,7 +31,11 @@ SystemInfo::~SystemInfo()
|
|||||||
uint64
|
uint64
|
||||||
SystemInfo::CachedMemory() const
|
SystemInfo::CachedMemory() const
|
||||||
{
|
{
|
||||||
|
#ifdef __HAIKU__
|
||||||
return fSystemInfo.cached_pages * B_PAGE_SIZE;
|
return fSystemInfo.cached_pages * B_PAGE_SIZE;
|
||||||
|
#else
|
||||||
|
return 0LL;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -122,10 +127,12 @@ SystemInfo::_RetrieveNetwork()
|
|||||||
ifreq request;
|
ifreq request;
|
||||||
strlcpy(request.ifr_name, interface->ifr_name, IF_NAMESIZE);
|
strlcpy(request.ifr_name, interface->ifr_name, IF_NAMESIZE);
|
||||||
|
|
||||||
|
#ifdef __HAIKU__
|
||||||
if (ioctl(socket, SIOCGIFSTATS, &request, sizeof(struct ifreq)) == 0) {
|
if (ioctl(socket, SIOCGIFSTATS, &request, sizeof(struct ifreq)) == 0) {
|
||||||
fBytesReceived += request.ifr_stats.receive.bytes;
|
fBytesReceived += request.ifr_stats.receive.bytes;
|
||||||
fBytesSent += request.ifr_stats.send.bytes;
|
fBytesSent += request.ifr_stats.send.bytes;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
interface = (ifreq *)((addr_t)interface + IF_NAMESIZE
|
interface = (ifreq *)((addr_t)interface + IF_NAMESIZE
|
||||||
+ interface->ifr_addr.sa_len);
|
+ interface->ifr_addr.sa_len);
|
||||||
|
|||||||
Reference in New Issue
Block a user