Imported current OpenTracker Deskbar: it can now start apps (and show the
"About Haiku" window) without having Tracker running. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15803 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
20c2f67293
commit
f4a73641e0
@ -59,9 +59,11 @@ All rights reserved.
|
||||
#include "BarView.h"
|
||||
#include "BarWindow.h"
|
||||
#include "DeskBarUtils.h"
|
||||
#include "TeamMenu.h"
|
||||
#include "Switcher.h"
|
||||
#include "FSUtils.h"
|
||||
#include "PublicCommands.h"
|
||||
#include "ResourceSet.h"
|
||||
#include "Switcher.h"
|
||||
#include "TeamMenu.h"
|
||||
#include "WindowMenuItem.h"
|
||||
|
||||
|
||||
@ -480,6 +482,14 @@ TBarApp::MessageReceived(BMessage *message)
|
||||
}
|
||||
#endif // __HAIKU__
|
||||
|
||||
// in case Tracker is not running
|
||||
|
||||
case kShowSplash:
|
||||
#ifdef B_BEOS_VERSION_5
|
||||
run_be_about();
|
||||
#endif
|
||||
break;
|
||||
|
||||
default:
|
||||
BApplication::MessageReceived(message);
|
||||
break;
|
||||
@ -487,10 +497,30 @@ TBarApp::MessageReceived(BMessage *message)
|
||||
}
|
||||
|
||||
|
||||
// called when ExpandoMenuBar, TeamMenu or Switcher are built/rebuilt
|
||||
/** In case Tracker is not running, the TBeMenu will use us as a target.
|
||||
* We'll make sure the user won't be completely confused and take over
|
||||
* Tracker's duties until it's back.
|
||||
*/
|
||||
|
||||
void
|
||||
TBarApp::RefsReceived(BMessage *refs)
|
||||
{
|
||||
entry_ref ref;
|
||||
for (int32 i = 0; refs->FindRef("refs", i, &ref) == B_OK; i++) {
|
||||
BMessage refsReceived(B_REFS_RECEIVED);
|
||||
refsReceived.AddRef("refs", &ref);
|
||||
|
||||
BEntry entry(&ref);
|
||||
if (!entry.IsDirectory())
|
||||
TrackerLaunch(&refsReceived, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarApp::Subscribe(const BMessenger &subscriber, BList *list)
|
||||
{
|
||||
// called when ExpandoMenuBar, TeamMenu or Switcher are built/rebuilt
|
||||
list->MakeEmpty();
|
||||
|
||||
BAutolock autolock(sSubscriberLock);
|
||||
|
@ -139,7 +139,8 @@ class TBarApp : public BApplication {
|
||||
virtual ~TBarApp();
|
||||
|
||||
virtual bool QuitRequested();
|
||||
virtual void MessageReceived(BMessage *);
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
virtual void RefsReceived(BMessage *refs);
|
||||
|
||||
desk_settings *Settings()
|
||||
{ return &fSettings; }
|
||||
@ -173,4 +174,4 @@ class TBarApp : public BApplication {
|
||||
static BList sSubscribers;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // BAR_APP_H
|
||||
|
@ -87,7 +87,7 @@ TBarView::TBarView(BRect frame, bool vertical, bool left, bool top,
|
||||
fMaxRecentApps(kDefaultRecentAppCount),
|
||||
fLastDragItem(NULL),
|
||||
fClickToOpen(_menu_info_ptr_->click_to_open)
|
||||
//init click to open to current local setting
|
||||
// init click to open to current local setting
|
||||
{
|
||||
}
|
||||
|
||||
@ -150,7 +150,7 @@ TBarView::Draw(BRect)
|
||||
void
|
||||
TBarView::MessageReceived(BMessage *message)
|
||||
{
|
||||
switch(message->what) {
|
||||
switch (message->what) {
|
||||
case B_REFS_RECEIVED:
|
||||
// received when an item is selected during DnD
|
||||
// message is targeted here from Be menu
|
||||
@ -158,15 +158,15 @@ TBarView::MessageReceived(BMessage *message)
|
||||
break;
|
||||
|
||||
case B_ARCHIVED_OBJECT:
|
||||
{
|
||||
// this message has been retargeted to here
|
||||
// instead of directly to the replicant tray
|
||||
// so that I can follow the common pathway
|
||||
// for adding icons to the tray
|
||||
{
|
||||
int32 id;
|
||||
AddItem(new BMessage(*message), B_DESKBAR_TRAY, &id);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
BView::MessageReceived(message);
|
||||
@ -207,7 +207,8 @@ TBarView::PlaceBeMenu()
|
||||
fBarMenuBar->RemoveTeamMenu();
|
||||
width = 8 + 16 + 8;
|
||||
loc = Bounds().LeftTop();
|
||||
} else if (fState == kExpandoState) { // shows apps below tray
|
||||
} else if (fState == kExpandoState) {
|
||||
// shows apps below tray
|
||||
fBarMenuBar->RemoveTeamMenu();
|
||||
if (fVertical)
|
||||
width += 1;
|
||||
@ -215,7 +216,7 @@ TBarView::PlaceBeMenu()
|
||||
width = floorf(width) / 2;
|
||||
loc = Bounds().LeftTop();
|
||||
} else
|
||||
// mini mode, bemenu next to team menu
|
||||
// mini mode, BeMenu next to team menu
|
||||
fBarMenuBar->AddTeamMenu();
|
||||
|
||||
fBarMenuBar->SmartResize(width, menuFrame.Height());
|
||||
@ -280,9 +281,8 @@ TBarView::PlaceApplicationBar(BRect screenFrame)
|
||||
// top left/right
|
||||
if (fTrayLocation != 0)
|
||||
expandoFrame.top = fDragRegion->Frame().bottom + 2;
|
||||
else {
|
||||
else
|
||||
expandoFrame.top = fBarMenuBar->Frame().bottom + 2;
|
||||
}
|
||||
|
||||
expandoFrame.bottom = expandoFrame.top + 1;
|
||||
if (fState == kFullState)
|
||||
@ -293,15 +293,14 @@ TBarView::PlaceApplicationBar(BRect screenFrame)
|
||||
// top or bottom
|
||||
expandoFrame.top = -1;
|
||||
expandoFrame.bottom = kHModeHeight;
|
||||
if (fTrayLocation != 0) {
|
||||
if (fTrayLocation != 0)
|
||||
expandoFrame.right = fDragRegion->Frame().left;
|
||||
} else
|
||||
else
|
||||
expandoFrame.right = screenFrame.Width();
|
||||
|
||||
}
|
||||
|
||||
fExpando = new TExpandoMenuBar(this, expandoFrame, "ExpandoMenuBar", fVertical,
|
||||
(fState != kFullState));
|
||||
fExpando = new TExpandoMenuBar(this, expandoFrame, "ExpandoMenuBar",
|
||||
fVertical, fState != kFullState);
|
||||
AddChild(fExpando);
|
||||
}
|
||||
|
||||
@ -557,15 +556,16 @@ TBarView::CacheDragData(BMessage *incoming)
|
||||
|
||||
static void
|
||||
init_tracking_hook(BMenuItem *item,
|
||||
bool (*hookfunction)(BMenu *, void *), void *state)
|
||||
bool (*hookFunction)(BMenu *, void *), void *state)
|
||||
{
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
BMenu *windowmenu = item->Submenu();
|
||||
if (windowmenu)
|
||||
BMenu *windowMenu = item->Submenu();
|
||||
if (windowMenu) {
|
||||
// have a menu, set the tracking hook
|
||||
windowmenu->SetTrackingHook(hookfunction, state);
|
||||
windowMenu->SetTrackingHook(hookFunction, state);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -615,12 +615,10 @@ TBarView::MenuTrackingHook(BMenu *menu, void *castToThis)
|
||||
if (!data)
|
||||
return false;
|
||||
|
||||
|
||||
TBarView *barview = dynamic_cast<TBarView *>(data->fTarget.Target(NULL));
|
||||
if (!barview || !menu->LockLooper())
|
||||
return false;
|
||||
|
||||
|
||||
uint32 buttons;
|
||||
BPoint location;
|
||||
menu->GetMouse(&location, &buttons);
|
||||
@ -663,13 +661,11 @@ TBarView::MenuTrackingHook(BMenu *menu, void *castToThis)
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// used by WindowMenu and TeamMenu to
|
||||
// set the tracking hook for dragging
|
||||
TrackingHookData *
|
||||
TBarView::GetTrackingHookData()
|
||||
{
|
||||
//
|
||||
// all tracking hook data is
|
||||
// preset in AttachedToWindow
|
||||
// data should never change
|
||||
@ -683,7 +679,6 @@ TBarView::DragStop(bool full)
|
||||
if (!Dragging())
|
||||
return;
|
||||
|
||||
//
|
||||
// revert the local click to open to
|
||||
// the launch state, cached in constructor
|
||||
_menu_info_ptr_->click_to_open = fClickToOpen;
|
||||
@ -710,17 +705,20 @@ TBarView::AppCanHandleTypes(const char *signature)
|
||||
{
|
||||
// used for filtering apps/teams in the ExpandoMenuBar and TeamMenu
|
||||
|
||||
if (modifiers() & B_CONTROL_KEY)
|
||||
return true; // control key forces acceptance, just like drag&drop on icons
|
||||
if (modifiers() & B_CONTROL_KEY) {
|
||||
// control key forces acceptance, just like drag&drop on icons
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!signature || strlen(signature) == 0
|
||||
|| !fCachedTypesList || fCachedTypesList->CountItems() == 0)
|
||||
return false;
|
||||
|
||||
if (strcmp(signature, kTrackerSignature) == 0)
|
||||
if (strcmp(signature, kTrackerSignature) == 0) {
|
||||
// tracker should support all types
|
||||
// and should pass them on to the appropriate application
|
||||
return true;
|
||||
}
|
||||
|
||||
entry_ref hintref;
|
||||
BMimeType appmime(signature);
|
||||
@ -737,9 +735,10 @@ TBarView::AppCanHandleTypes(const char *signature)
|
||||
// only one item needs to match in the list of refs
|
||||
|
||||
int32 count = fCachedTypesList->CountItems();
|
||||
for (int32 i = 0 ; i < count ; i++)
|
||||
for (int32 i = 0 ; i < count ; i++) {
|
||||
if (fileinfo.IsSupportedType(fCachedTypesList->ItemAt(i)->String()))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -830,9 +829,10 @@ TBarView::HandleBeMenu(BMessage *messagewithdestination)
|
||||
} else
|
||||
SendDragMessage(NULL, &ref);
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
// adds drag refs to top level in be menu
|
||||
AddRefsToBeMenu(DragMessage(), NULL);
|
||||
}
|
||||
|
||||
// clean up drag message and types list
|
||||
DragStop(true);
|
||||
@ -841,6 +841,7 @@ TBarView::HandleBeMenu(BMessage *messagewithdestination)
|
||||
|
||||
// #pragma mark - Add-ons
|
||||
|
||||
|
||||
// shelf is ignored for now,
|
||||
// it exists in anticipation of having other 'shelves' for
|
||||
// storing items
|
||||
@ -930,4 +931,3 @@ TBarView::IconFrame(const char *name) const
|
||||
return OffsetIconFrame(fReplicantTray->IconFrame(name));
|
||||
}
|
||||
|
||||
|
||||
|
@ -83,13 +83,14 @@ namespace BPrivate {
|
||||
}
|
||||
using namespace BPrivate;
|
||||
|
||||
//********************************************************************************
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
TBeMenu::TBeMenu(TBarView *barview)
|
||||
: BNavMenu("BeMenu", B_REFS_RECEIVED, BMessenger(kTrackerSignature)),
|
||||
TBeMenu::TBeMenu(TBarView *barView)
|
||||
: BNavMenu("BeMenu", B_REFS_RECEIVED, DefaultTarget()),
|
||||
fAddState(kStart),
|
||||
fBarView(barview)
|
||||
fBarView(barView)
|
||||
{
|
||||
}
|
||||
|
||||
@ -106,7 +107,7 @@ TBeMenu::AttachedToWindow()
|
||||
fBarView->DragStart();
|
||||
} else {
|
||||
SetTypesList(NULL);
|
||||
SetTarget(BMessenger(kTrackerSignature));
|
||||
SetTarget(DefaultTarget());
|
||||
SetTrackingHookDeep(this, NULL, NULL);
|
||||
}
|
||||
|
||||
@ -403,16 +404,13 @@ TBeMenu::ResetTargets()
|
||||
{
|
||||
BNavMenu::ResetTargets();
|
||||
|
||||
//
|
||||
// if we are dragging, set the target to whatever was set
|
||||
// else set it to the default (Tracker)
|
||||
//
|
||||
if (!fBarView->Dragging())
|
||||
SetTarget(BMessenger(kTrackerSignature));
|
||||
//
|
||||
SetTarget(DefaultTarget());
|
||||
|
||||
// now set the target for the menuitems to the currently
|
||||
// set target, which may or may not be tracker
|
||||
//
|
||||
SetTargetForItems(Target());
|
||||
|
||||
for (int32 i = 0; ; i++) {
|
||||
@ -424,10 +422,8 @@ TBeMenu::ResetTargets()
|
||||
switch (item->Message()->what) {
|
||||
case kShowSplash:
|
||||
#ifdef B_BEOS_VERSION_5
|
||||
#if 0
|
||||
run_be_about();
|
||||
// about box in libbe in BeOS R5
|
||||
#endif
|
||||
item->SetTarget(be_app);
|
||||
#endif
|
||||
break;
|
||||
case kFindButton:
|
||||
@ -464,33 +460,45 @@ TBeMenu::ResetTargets()
|
||||
BPoint
|
||||
TBeMenu::ScreenLocation()
|
||||
{
|
||||
BPoint pt;
|
||||
BRect r;
|
||||
bool vertical = fBarView->Vertical();
|
||||
int32 expando = (fBarView->State() == kExpandoState);
|
||||
BPoint point;
|
||||
|
||||
BRect rect = Supermenu()->Bounds();
|
||||
Supermenu()->ConvertToScreen(&rect);
|
||||
|
||||
r = Supermenu()->Bounds();
|
||||
Supermenu()->ConvertToScreen(&r);
|
||||
if (expando && vertical && fBarView->Left()) {
|
||||
PRINT(("Left\n"));
|
||||
pt = r.RightTop() + BPoint(0,3);
|
||||
point = rect.RightTop() + BPoint(0,3);
|
||||
} else if (expando && vertical && !fBarView->Left()) {
|
||||
PRINT(("Right\n"));
|
||||
pt = r.LeftTop() - BPoint(Bounds().Width(), 0) + BPoint(0,3);
|
||||
} else {
|
||||
pt = BMenu::ScreenLocation();
|
||||
}
|
||||
return pt;
|
||||
point = rect.LeftTop() - BPoint(Bounds().Width(), 0) + BPoint(0,3);
|
||||
} else
|
||||
point = BMenu::ScreenLocation();
|
||||
|
||||
return point;
|
||||
}
|
||||
|
||||
|
||||
/*static*/
|
||||
BMessenger
|
||||
TBeMenu::DefaultTarget()
|
||||
{
|
||||
// if Tracker is not available we target the BarApp
|
||||
BMessenger target(kTrackerSignature);
|
||||
if (target.IsValid())
|
||||
return target;
|
||||
|
||||
return BMessenger(be_app);
|
||||
}
|
||||
|
||||
|
||||
//********************************************************************************
|
||||
// #pragma mark -
|
||||
//
|
||||
|
||||
|
||||
TRecentsMenu::TRecentsMenu(const char *name, TBarView *bar, int32 which, const char *signature, entry_ref *appRef)
|
||||
: BNavMenu(name, B_REFS_RECEIVED, BMessenger(kTrackerSignature)),
|
||||
TRecentsMenu::TRecentsMenu(const char *name, TBarView *bar, int32 which,
|
||||
const char *signature, entry_ref *appRef)
|
||||
: BNavMenu(name, B_REFS_RECEIVED, TBeMenu::DefaultTarget()),
|
||||
fWhich(which),
|
||||
fAppRef(NULL),
|
||||
fSignature(NULL),
|
||||
@ -551,7 +559,7 @@ TRecentsMenu::StartBuildingItemList()
|
||||
RemoveItem(index);
|
||||
delete item;
|
||||
}
|
||||
//
|
||||
|
||||
// !! note: don't call inherited from here
|
||||
// the navref is not set for this menu
|
||||
// but it still needs to be a draggable navmenu
|
||||
@ -662,9 +670,7 @@ TRecentsMenu::AddRecents(int32 count)
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// return false if we are done with this list
|
||||
//
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -672,12 +678,10 @@ TRecentsMenu::AddRecents(int32 count)
|
||||
void
|
||||
TRecentsMenu::DoneBuildingItemList()
|
||||
{
|
||||
//
|
||||
// !! note: don't call inherited here
|
||||
// the object list is not built
|
||||
// and this list does not need to be sorted
|
||||
// BNavMenu::DoneBuildingItemList();
|
||||
//
|
||||
|
||||
if (CountItems() > 0)
|
||||
SetTargetForItems(Target());
|
||||
@ -696,16 +700,14 @@ void
|
||||
TRecentsMenu::ResetTargets()
|
||||
{
|
||||
BNavMenu::ResetTargets();
|
||||
//
|
||||
|
||||
// if we are dragging, set the target to whatever was set
|
||||
// else set it to the default (Tracker)
|
||||
//
|
||||
if (!fBarView->Dragging())
|
||||
SetTarget(BMessenger(kTrackerSignature));
|
||||
//
|
||||
SetTarget(TBeMenu::DefaultTarget());
|
||||
|
||||
// now set the target for the menuitems to the currently
|
||||
// set target, which may or may not be tracker
|
||||
//
|
||||
SetTargetForItems(Target());
|
||||
}
|
||||
|
||||
@ -730,17 +732,13 @@ MountMenu::AddDynamicItem(add_state s)
|
||||
while ((item = RemoveItem(0L)) != NULL)
|
||||
delete item;
|
||||
|
||||
//
|
||||
// Send message to tracker to get items.
|
||||
//
|
||||
BMessage request('gmtv');
|
||||
BMessage reply;
|
||||
BMessenger(kTrackerSignature).SendMessage(&request,
|
||||
&reply);
|
||||
|
||||
//
|
||||
// populate menu
|
||||
//
|
||||
type_code code;
|
||||
int32 countFound;
|
||||
reply.GetInfo("DisplayName", &code, &countFound);
|
||||
|
@ -95,6 +95,8 @@ class TBeMenu : public BNavMenu {
|
||||
|
||||
void ResetTargets();
|
||||
|
||||
static BMessenger DefaultTarget();
|
||||
|
||||
private:
|
||||
enum State {
|
||||
kStart,
|
||||
|
@ -41,6 +41,7 @@ All rights reserved.
|
||||
#include "StatusViewShelf.h"
|
||||
#include "StatusView.h"
|
||||
|
||||
|
||||
TReplicantShelf::TReplicantShelf(TReplicantTray* parent)
|
||||
: BShelf(parent, false, "DeskbarShelf")
|
||||
{
|
||||
@ -48,19 +49,21 @@ TReplicantShelf::TReplicantShelf(TReplicantTray* parent)
|
||||
SetAllowsZombies(false);
|
||||
}
|
||||
|
||||
|
||||
TReplicantShelf::~TReplicantShelf()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TReplicantShelf::MessageReceived(BMessage* message)
|
||||
{
|
||||
switch(message->what) {
|
||||
switch (message->what) {
|
||||
case B_DELETE_PROPERTY:
|
||||
{
|
||||
BMessage repspec;
|
||||
int32 index = 0;
|
||||
//
|
||||
|
||||
// this should only occur via scripting
|
||||
// since we can't use ReplicantDeleted
|
||||
// catch the message and find the id or name specifier
|
||||
@ -70,7 +73,7 @@ TReplicantShelf::MessageReceived(BMessage* message)
|
||||
// after a remove when done through scripting
|
||||
//
|
||||
// note: if specified by index its the index not the id!
|
||||
//
|
||||
|
||||
while (message->FindMessage("specifiers", index++, &repspec) == B_OK) {
|
||||
const char* str;
|
||||
if (repspec.FindString("property", &str) == B_OK) {
|
||||
@ -89,8 +92,8 @@ TReplicantShelf::MessageReceived(BMessage* message)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
BShelf::MessageReceived(message);
|
||||
@ -98,8 +101,10 @@ TReplicantShelf::MessageReceived(BMessage* message)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TReplicantShelf::CanAcceptReplicantView(BRect frame, BView* view, BMessage* message) const
|
||||
TReplicantShelf::CanAcceptReplicantView(BRect frame, BView* view,
|
||||
BMessage* message) const
|
||||
{
|
||||
if (view->ResizingMode() != B_FOLLOW_NONE)
|
||||
view->SetResizingMode(B_FOLLOW_NONE);
|
||||
@ -108,24 +113,23 @@ TReplicantShelf::CanAcceptReplicantView(BRect frame, BView* view, BMessage* mess
|
||||
return fParent->AcceptAddon(frame, message);
|
||||
}
|
||||
|
||||
|
||||
BPoint
|
||||
TReplicantShelf::AdjustReplicantBy(BRect frame, BMessage *message) const
|
||||
{
|
||||
// added in AcceptAddon, from TReplicantTray
|
||||
BPoint pt;
|
||||
message->FindPoint("_pjp_loc", &pt);
|
||||
BPoint point;
|
||||
message->FindPoint("_pjp_loc", &point);
|
||||
message->RemoveName("_pjp_loc");
|
||||
|
||||
pt = pt - frame.LeftTop();
|
||||
|
||||
return pt;
|
||||
return point - frame.LeftTop();
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
// the virtual BShelf::ReplicantDeleted is called before the
|
||||
// replicant is actually removed from BShelf's internal list
|
||||
// thus, this returns the wrong number of replicants.
|
||||
//
|
||||
|
||||
void
|
||||
TReplicantShelf::ReplicantDeleted(int32, const BMessage*, const BView*)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user