Add a Quit button to the Team Monitor.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41215 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jonas Sundström 2011-04-11 15:22:40 +00:00
parent 1c09002cbe
commit 4787e491e6
4 changed files with 40 additions and 0 deletions

View File

@ -13,6 +13,7 @@
#include <FindDirectory.h>
#include <NodeInfo.h>
#include <Path.h>
#include <Roster.h>
#include <View.h>
@ -34,6 +35,10 @@ TeamListItem::TeamListItem(team_info &tinfo)
nodeInfo.GetTrackerIcon(&fIcon, B_MINI_ICON);
nodeInfo.GetTrackerIcon(&fLargeIcon, B_LARGE_ICON);
}
app_info appInfo;
if (be_roster->GetRunningAppInfo(fInfo.team, &appInfo) == B_OK)
fAppSignature = appInfo.signature;
}
@ -145,3 +150,13 @@ TeamListItem::IsSystemServer()
return false;
}
bool
TeamListItem::IsApplication()
{
if (fAppSignature.Length() > 0)
return true;
else
return false;
}

View File

@ -12,6 +12,7 @@
#include <Bitmap.h>
#include <ListItem.h>
#include <Path.h>
#include <String.h>
class TeamListItem : public BListItem {
@ -26,7 +27,9 @@ public:
const team_info* GetInfo();
const BBitmap* LargeIcon() { return &fLargeIcon; };
const BPath* Path() { return &fPath; };
const BString* AppSignature() { return &fAppSignature; };
bool IsSystemServer();
bool IsApplication();
bool Found() const { return fFound; }
void SetFound(bool found) { fFound = found; }
@ -37,6 +40,7 @@ private:
team_info fInfo;
BBitmap fIcon, fLargeIcon;
BPath fPath;
BString fAppSignature;
bool fFound;
};

View File

@ -59,6 +59,7 @@ static const uint32 kMsgLaunchTerminal = 'TMlt';
const uint32 TM_CANCEL = 'TMca';
const uint32 TM_FORCE_REBOOT = 'TMfr';
const uint32 TM_KILL_APPLICATION = 'TMka';
const uint32 TM_QUIT_APPLICATION = 'TMqa';
const uint32 TM_RESTART_DESKTOP = 'TMrd';
const uint32 TM_SELECTED_TEAM = 'TMst';
@ -96,6 +97,11 @@ TeamMonitorWindow::TeamMonitorWindow()
new BMessage(TM_KILL_APPLICATION));
groupView->AddChild(fKillButton);
fKillButton->SetEnabled(false);
fQuitButton = new BButton("quit", "Quit Application",
new BMessage(TM_QUIT_APPLICATION));
groupView->AddChild(fQuitButton);
fQuitButton->SetEnabled(false);
groupView->GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue());
@ -195,6 +201,18 @@ TeamMonitorWindow::MessageReceived(BMessage *msg)
}
break;
}
case TM_QUIT_APPLICATION:
{
TeamListItem* item = dynamic_cast<TeamListItem*>(fListView->ItemAt(
fListView->CurrentSelection()));
if (item != NULL) {
BMessenger messenger(item->AppSignature()->String(),
item->GetInfo()->team);
messenger.SendMessage(B_QUIT_REQUESTED);
UpdateList();
}
break;
}
case TM_RESTART_DESKTOP:
{
if (!be_roster->IsRunning(kTrackerSignature))
@ -211,6 +229,7 @@ TeamMonitorWindow::MessageReceived(BMessage *msg)
TeamListItem* item = (TeamListItem*)fListView->ItemAt(
fListView->CurrentSelection());
fDescriptionView->SetItem(item);
fQuitButton->SetEnabled(item && item->IsApplication());
break;
}
case TM_CANCEL:
@ -273,6 +292,7 @@ TeamMonitorWindow::UpdateList()
if (item == fDescriptionView->Item()) {
fDescriptionView->SetItem(NULL);
fKillButton->SetEnabled(false);
fQuitButton->SetEnabled(false);
}
delete fListView->RemoveItem(i);

View File

@ -39,6 +39,7 @@ private:
BListView* fListView;
BButton* fCancelButton;
BButton* fKillButton;
BButton* fQuitButton;
BButton* fRestartButton;
TeamDescriptionView* fDescriptionView;
};