added a "Restart the Desktop" button, untested

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17086 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2006-04-11 16:51:16 +00:00
parent 6a9b090ae0
commit 94a2752647
3 changed files with 29 additions and 2 deletions
@@ -2,8 +2,7 @@ SubDir HAIKU_TOP src add-ons input_server devices keyboard ;
SetSubDirSupportedPlatformsBeOSCompatible ; SetSubDirSupportedPlatformsBeOSCompatible ;
UsePrivateHeaders input ; UsePrivateHeaders input kernel tracker ;
UsePrivateHeaders kernel ;
UseArchHeaders $(TARGET_ARCH) ; UseArchHeaders $(TARGET_ARCH) ;
Addon <input>keyboard : input_server/devices : Addon <input>keyboard : input_server/devices :
@@ -18,7 +18,10 @@
#include "TMListItem.h" #include "TMListItem.h"
#include "KeyboardInputDevice.h" #include "KeyboardInputDevice.h"
#include "tracker_private.h"
#include <Message.h> #include <Message.h>
#include <Roster.h>
#include <ScrollView.h> #include <ScrollView.h>
#include <Screen.h> #include <Screen.h>
#include <String.h> #include <String.h>
@@ -27,6 +30,7 @@
const uint32 TM_CANCEL = 'TMca'; const uint32 TM_CANCEL = 'TMca';
const uint32 TM_FORCE_REBOOT = 'TMfr'; const uint32 TM_FORCE_REBOOT = 'TMfr';
const uint32 TM_KILL_APPLICATION = 'TMka'; const uint32 TM_KILL_APPLICATION = 'TMka';
const uint32 TM_RESTART_DESKTOP = 'TMrd';
const uint32 TM_SELECTED_TEAM = 'TMst'; const uint32 TM_SELECTED_TEAM = 'TMst';
#ifndef __HAIKU__ #ifndef __HAIKU__
@@ -165,6 +169,14 @@ TMView::TMView(BRect bounds, const char* name, uint32 resizeFlags,
new BMessage(TM_FORCE_REBOOT), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); new BMessage(TM_FORCE_REBOOT), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
AddChild(forceReboot); AddChild(forceReboot);
BRect restartRect = rect;
restartRect.left = rect.right + 20;
restartRect.right = restartRect.left + font.StringWidth("Restart the Desktop") + 20;
BButton *fRestartButton = new BButton(restartRect, "restart", "Restart the Desktop",
new BMessage(TM_RESTART_DESKTOP), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
AddChild(fRestartButton);
fRestartButton->Hide();
rect.left += 4; rect.left += 4;
rect.bottom = rect.top - 8; rect.bottom = rect.top - 8;
rect.top = fKillButton->Frame().bottom + 8; rect.top = fKillButton->Frame().bottom + 8;
@@ -204,6 +216,14 @@ TMView::MessageReceived(BMessage *msg)
UpdateList(); UpdateList();
break; break;
} }
case TM_RESTART_DESKTOP: {
fRestartButton->SetEnabled(false);
if (!be_roster->IsRunning(kTrackerSignature))
be_roster->Launch(kTrackerSignature);
if (!be_roster->IsRunning(kDeskbarSignature))
be_roster->Launch(kDeskbarSignature);
break;
}
case TM_SELECTED_TEAM: { case TM_SELECTED_TEAM: {
fKillButton->SetEnabled(fListView->CurrentSelection() >= 0); fKillButton->SetEnabled(fListView->CurrentSelection() >= 0);
TMListItem *item = (TMListItem*)ListView()->ItemAt( TMListItem *item = (TMListItem*)ListView()->ItemAt(
@@ -279,6 +299,13 @@ TMView::UpdateList()
if (changed) if (changed)
fListView->Invalidate(); fListView->Invalidate();
bool desktopRunning = be_roster->IsRunning(kTrackerSignature)
&& be_roster->IsRunning(kDeskbarSignature);
if (desktopRunning ^ fRestartButton->IsHidden())
fRestartButton->Show();
if (!desktopRunning)
fRestartButton->SetEnabled(true);
} }
@@ -46,6 +46,7 @@ class TMView : public BBox {
private: private:
BListView *fListView; BListView *fListView;
BButton *fKillButton; BButton *fKillButton;
BButton *fRestartButton;
TMDescView *fDescView; TMDescView *fDescView;
}; };