diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp index 303afcfe6e..542e29f5e9 100644 --- a/src/apps/deskbar/BarApp.cpp +++ b/src/apps/deskbar/BarApp.cpp @@ -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); diff --git a/src/apps/deskbar/BarApp.h b/src/apps/deskbar/BarApp.h index 3e262b9771..421fa35f48 100644 --- a/src/apps/deskbar/BarApp.h +++ b/src/apps/deskbar/BarApp.h @@ -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 diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp index 503dda0c95..31d93a42bc 100644 --- a/src/apps/deskbar/BarView.cpp +++ b/src/apps/deskbar/BarView.cpp @@ -69,25 +69,25 @@ const int32 kMenuTrackMargin = 20; TBarView::TBarView(BRect frame, bool vertical, bool left, bool top, - bool showInterval, uint32 state, float, bool showTime) - : BView(frame, "BarView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW), - fBarMenuBar(NULL), - fExpando(NULL), - fTrayLocation(1), - fShowInterval(showInterval), - fShowClock(showTime), - fVertical(vertical), - fTop(top), - fLeft(left), - fState(static_cast(state)), - fRefsRcvdOnly(true), - fDragMessage(NULL), - fCachedTypesList(NULL), - fMaxRecentDocs(kDefaultRecentDocCount), - fMaxRecentApps(kDefaultRecentAppCount), - fLastDragItem(NULL), - fClickToOpen(_menu_info_ptr_->click_to_open) - //init click to open to current local setting + bool showInterval, uint32 state, float, bool showTime) + : BView(frame, "BarView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW), + fBarMenuBar(NULL), + fExpando(NULL), + fTrayLocation(1), + fShowInterval(showInterval), + fShowClock(showTime), + fVertical(vertical), + fTop(top), + fLeft(left), + fState(static_cast(state)), + fRefsRcvdOnly(true), + fDragMessage(NULL), + fCachedTypesList(NULL), + fMaxRecentDocs(kDefaultRecentDocCount), + fMaxRecentApps(kDefaultRecentAppCount), + fLastDragItem(NULL), + fClickToOpen(_menu_info_ptr_->click_to_open) + // init click to open to current local setting { } @@ -96,9 +96,9 @@ TBarView::~TBarView() { delete fDragMessage; delete fCachedTypesList; - - // !! this should be done in DetachedFromWindow - // to be symetric + + // !! this should be done in DetachedFromWindow + // to be symetric delete fTrackingHookData.fDragMessage; } @@ -150,24 +150,24 @@ 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 + // received when an item is selected during DnD + // message is targeted here from Be menu HandleBeMenu(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); - } + { + // 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()); @@ -226,22 +227,22 @@ TBarView::PlaceBeMenu() void TBarView::PlaceTray(bool, bool, BRect screenFrame) { - BPoint statusLoc; + BPoint statusLoc; if (fState == kFullState) { fDragRegion->ResizeTo(fBarMenuBar->Frame().Width(), kMenuBarHeight); statusLoc.y = fBarMenuBar->Frame().bottom + 1; statusLoc.x = 0; fDragRegion->MoveTo(statusLoc); - + if (!fReplicantTray->IsHidden()) fReplicantTray->Hide(); return; } - + if (fReplicantTray->IsHidden()) fReplicantTray->Show(); - + if (fTrayLocation != 0) { fReplicantTray->SetMultiRow(fVertical); fReplicantTray->RealignReplicants(); @@ -274,15 +275,14 @@ TBarView::PlaceApplicationBar(BRect screenFrame) } if (fState == kMiniState) return; - + BRect expandoFrame(0, 0, 0, 0); if (fVertical) { // 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); } @@ -331,7 +330,7 @@ TBarView::GetPreferredWindowSize(BRect screenFrame, float *width, float *height) else windowHeight = fBarMenuBar->Frame().bottom; } - + *width = windowWidth; *height = windowHeight; } @@ -406,7 +405,7 @@ TBarView::ChangeState(int32 state, bool vertical, bool left, bool top) fVertical = vertical; fLeft = left; fTop = top; - + BRect screenFrame = (BScreen(Window())).Frame(); PlaceBeMenu(); @@ -548,41 +547,42 @@ TBarView::CacheDragData(BMessage *incoming) if (Dragging() && SpringLoadedFolderCompareMessages(incoming, fDragMessage)) return; - - // disposes then fills cached drag message and - // mimetypes list + + // disposes then fills cached drag message and + // mimetypes list SpringLoadedFolderCacheDragData(incoming, &fDragMessage, &fCachedTypesList); } 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) - // have a menu, set the tracking hook - windowmenu->SetTrackingHook(hookfunction, state); + + BMenu *windowMenu = item->Submenu(); + if (windowMenu) { + // have a menu, set the tracking hook + windowMenu->SetTrackingHook(hookFunction, state); + } } status_t TBarView::DragStart() { - // always set the click to open state - // to false during a drag - // so that a release on a menu/menubar will not - // leave the menu open (ExpandoMenuBar, BarMenuBar) - // will get reset to actual initial system - // state on DragStop + // always set the click to open state + // to false during a drag + // so that a release on a menu/menubar will not + // leave the menu open (ExpandoMenuBar, BarMenuBar) + // will get reset to actual initial system + // state on DragStop _menu_info_ptr_->click_to_open = false; if (!Dragging()) return B_OK; - + BPoint loc; uint32 buttons; GetMouse(&loc, &buttons); @@ -602,7 +602,7 @@ TBarView::DragStart() fLastDragItem = item; } } - + return B_OK; } @@ -610,17 +610,15 @@ TBarView::DragStart() bool TBarView::MenuTrackingHook(BMenu *menu, void *castToThis) { - // return true if the menu should go away + // return true if the menu should go away TrackingHookData *data = static_cast(castToThis); - if (!data) + if (!data) return false; - TBarView *barview = dynamic_cast(data->fTarget.Target(NULL)); if (!barview || !menu->LockLooper()) return false; - uint32 buttons; BPoint location; menu->GetMouse(&location, &buttons); @@ -630,16 +628,16 @@ TBarView::MenuTrackingHook(BMenu *menu, void *castToThis) frame.InsetBy(-kMenuTrackMargin, -kMenuTrackMargin); if (frame.Contains(location)) { - // if current loc is still in the menu - // keep tracking + // if current loc is still in the menu + // keep tracking returnvalue = false; } else { - // see if the mouse is in the team/be menu item + // see if the mouse is in the team/be menu item menu->ConvertToScreen(&location); if (barview->LockLooper()) { TExpandoMenuBar *expando = barview->ExpandoMenuBar(); TBeMenu *bemenu = (dynamic_cast(barview->Window()))->BeMenu(); - + if (bemenu && bemenu->LockLooper()) { bemenu->ConvertFromScreen(&location); if (bemenu->Frame().Contains(location)) @@ -647,7 +645,7 @@ TBarView::MenuTrackingHook(BMenu *menu, void *castToThis) bemenu->UnlockLooper(); } - + if (returnvalue && expando) { expando->ConvertFromScreen(&location); TTeamMenuItem *item = expando->ItemAtPoint(location); @@ -657,22 +655,20 @@ TBarView::MenuTrackingHook(BMenu *menu, void *castToThis) barview->UnlockLooper(); } } - + menu->UnlockLooper(); return returnvalue; } -// -// used by WindowMenu and TeamMenu to -// set the tracking hook for dragging +// 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 + // all tracking hook data is + // preset in AttachedToWindow + // data should never change return &fTrackingHookData; } @@ -682,10 +678,9 @@ TBarView::DragStop(bool full) { if (!Dragging()) return; - - // - // revert the local click to open to - // the launch state, cached in constructor + + // revert the local click to open to + // the launch state, cached in constructor _menu_info_ptr_->click_to_open = fClickToOpen; if (fExpando) { @@ -694,11 +689,11 @@ TBarView::DragStop(bool full) fLastDragItem = NULL; } } - + if (full) { delete fDragMessage; fDragMessage = NULL; - + delete fCachedTypesList; fCachedTypesList = NULL; } @@ -709,37 +704,41 @@ bool 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) - // tracker should support all types - // and should pass them on to the appropriate application + 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); if (appmime.GetAppHint(&hintref) != B_OK) return false; - - // an app was found, now see if it supports any of - // the refs in the message + + // an app was found, now see if it supports any of + // the refs in the message BFile file(&hintref, O_RDONLY); BAppFileInfo fileinfo(&file); - // scan the cached mimetype list and see if this app - // supports anything in the list - // only one item needs to match in the list of refs + // scan the cached mimetype list and see if this app + // supports anything in the list + // 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; } @@ -765,15 +764,15 @@ TBarView::SendDragMessage(const char *signature, entry_ref *ref) status_t err = B_ERROR; if (fDragMessage) { if (fRefsRcvdOnly) { - // current message sent to apps is only B_REFS_RECEIVED + // current message sent to apps is only B_REFS_RECEIVED fDragMessage->what = B_REFS_RECEIVED; } BRoster roster; if (signature && strlen(signature) > 0 && roster.IsRunning(signature)) { BMessenger mess(signature); - // drag message is still owned by DB, copy is sent - // can toss it after send + // drag message is still owned by DB, copy is sent + // can toss it after send err = mess.SendMessage(fDragMessage); } else if (ref) { FSLaunchItem((const entry_ref*)ref, (const BMessage*)fDragMessage, @@ -789,14 +788,14 @@ TBarView::SendDragMessage(const char *signature, entry_ref *ref) bool TBarView::InvokeItem(const char *signature) { - // sent from TeamMenuItem + // sent from TeamMenuItem if (Dragging() && AppCanHandleTypes(signature)) { SendDragMessage(signature); - // invoking okay to toss memory + // invoking okay to toss memory DragStop(true); return true; } - + return false; } @@ -806,10 +805,10 @@ TBarView::HandleBeMenu(BMessage *messagewithdestination) { if (!Dragging()) return; - - // in mini-mode + + // in mini-mode if (Vertical() && !Expando()) { - // if drop is in the team menu, bail + // if drop is in the team menu, bail if (fBarMenuBar->CountItems() >= 2) { uint32 buttons; BPoint location; @@ -818,32 +817,34 @@ TBarView::HandleBeMenu(BMessage *messagewithdestination) return; } } - + if (messagewithdestination) { entry_ref ref; if (messagewithdestination->FindRef("refs", &ref) == B_OK) { BEntry entry(&ref, true); if (entry.IsDirectory()) { - // if the ref received (should only be 1) is a directory - // then add the drag refs to the directory + // if the ref received (should only be 1) is a directory + // then add the drag refs to the directory AddRefsToBeMenu(DragMessage(), &ref); } else SendDragMessage(NULL, &ref); } - } else - // adds drag refs to top level in be menu + } else { + // adds drag refs to top level in be menu AddRefsToBeMenu(DragMessage(), NULL); + } - // clean up drag message and types list + // clean up drag message and types list DragStop(true); } // #pragma mark - Add-ons -// shelf is ignored for now, -// it exists in anticipation of having other 'shelves' for -// storing items + +// shelf is ignored for now, +// it exists in anticipation of having other 'shelves' for +// storing items status_t TBarView::ItemInfo(int32 id, const char **name, DeskbarShelf *shelf) @@ -909,10 +910,10 @@ TBarView::OffsetIconFrame(BRect rect) const BRect frame(Frame()); frame.left += fDragRegion->Frame().left + fReplicantTray->Frame().left + rect.left; frame.top += fDragRegion->Frame().top + fReplicantTray->Frame().top + rect.top; - + frame.right = frame.left + rect.Width(); frame.bottom = frame.top + rect.Height(); - + return frame; } @@ -930,4 +931,3 @@ TBarView::IconFrame(const char *name) const return OffsetIconFrame(fReplicantTray->IconFrame(name)); } - diff --git a/src/apps/deskbar/BeMenu.cpp b/src/apps/deskbar/BeMenu.cpp index 2ec13a1db0..f430468ad2 100644 --- a/src/apps/deskbar/BeMenu.cpp +++ b/src/apps/deskbar/BeMenu.cpp @@ -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) { } @@ -101,13 +102,13 @@ TBeMenu::AttachedToWindow() if (fBarView->Dragging()) { SetTypesList(fBarView->CachedTypesList()); SetTarget(BMessenger(fBarView)); - SetTrackingHookDeep(this, fBarView->MenuTrackingHook, + SetTrackingHookDeep(this, fBarView->MenuTrackingHook, fBarView->GetTrackingHookData()); fBarView->DragStart(); } else { SetTypesList(NULL); - SetTarget(BMessenger(kTrackerSignature)); - SetTrackingHookDeep(this, NULL, NULL); + SetTarget(DefaultTarget()); + SetTrackingHookDeep(this, NULL, NULL); } fBarView->UnlockLooper(); @@ -336,7 +337,7 @@ TBeMenu::AddStandardBeMenuItems() AddItem(subMenu); if ((modifiers() & (B_LEFT_SHIFT_KEY|B_LEFT_CONTROL_KEY|B_LEFT_COMMAND_KEY)) - == (B_LEFT_SHIFT_KEY|B_LEFT_CONTROL_KEY|B_LEFT_COMMAND_KEY)) { + == (B_LEFT_SHIFT_KEY|B_LEFT_CONTROL_KEY|B_LEFT_COMMAND_KEY)) { subMenu = new BMenu("Window Decor"); subMenu->SetEnabled(!dragging); @@ -402,17 +403,14 @@ void TBeMenu::ResetTargets() { BNavMenu::ResetTargets(); - - // - // if we are dragging, set the target to whatever was set - // else set it to the default (Tracker) - // + + // if we are dragging, set the target to whatever was set + // else set it to the default (Tracker) if (!fBarView->Dragging()) - SetTarget(BMessenger(kTrackerSignature)); - // - // now set the target for the menuitems to the currently - // set target, which may or may not be tracker - // + 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,17 +422,15 @@ 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: // about, find item->SetTarget(BMessenger(kTrackerSignature)); break; - + case msg_ToggleDraggers: case msg_config_db: case msg_AlwaysTop: @@ -464,33 +460,45 @@ TBeMenu::ResetTargets() BPoint TBeMenu::ScreenLocation() { - BPoint pt; - BRect r; - bool vertical = fBarView->Vertical(); - int32 expando = (fBarView->State() == kExpandoState); + 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,13 +559,13 @@ 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 + // simply return true so that AddNextItem is called // - // !! note: don't call inherited from here - // the navref is not set for this menu - // but it still needs to be a draggable navmenu - // simply return true so that AddNextItem is called - // - // return BNavMenu::StartBuildingItemList(); + // return BNavMenu::StartBuildingItemList(); return true; } @@ -657,14 +665,12 @@ TRecentsMenu::AddRecents(int32 count) } } - // return true so that we know to reenter this list + // return true so that we know to reenter this list return true; } } - // - // return false if we are done with this list - // + // 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(); - // + // !! 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 we are dragging, set the target to whatever was set + // else set it to the default (Tracker) if (!fBarView->Dragging()) - SetTarget(BMessenger(kTrackerSignature)); - // - // now set the target for the menuitems to the currently - // set target, which may or may not be tracker - // + 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); diff --git a/src/apps/deskbar/BeMenu.h b/src/apps/deskbar/BeMenu.h index c4d6d88fd7..f6a9abda69 100644 --- a/src/apps/deskbar/BeMenu.h +++ b/src/apps/deskbar/BeMenu.h @@ -57,16 +57,16 @@ class TRecentsMenu : public BNavMenu { void DetachedFromWindow(); void ResetTargets(); - int32 RecentsCount(); + int32 RecentsCount(); - private: + private: virtual bool StartBuildingItemList(); virtual bool AddNextItem(); bool AddRecents(int32 count); - virtual void DoneBuildingItemList(); + virtual void DoneBuildingItemList(); virtual void ClearMenuBuildingState(); - private: + private: int32 fWhich; entry_ref *fAppRef; char *fSignature; @@ -95,6 +95,8 @@ class TBeMenu : public BNavMenu { void ResetTargets(); + static BMessenger DefaultTarget(); + private: enum State { kStart, diff --git a/src/apps/deskbar/StatusViewShelf.cpp b/src/apps/deskbar/StatusViewShelf.cpp index 2c05bdeb2d..e597d16953 100644 --- a/src/apps/deskbar/StatusViewShelf.cpp +++ b/src/apps/deskbar/StatusViewShelf.cpp @@ -41,6 +41,7 @@ All rights reserved. #include "StatusViewShelf.h" #include "StatusView.h" + TReplicantShelf::TReplicantShelf(TReplicantTray* parent) : BShelf(parent, false, "DeskbarShelf") { @@ -48,29 +49,31 @@ 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 + // then delete the rep vi the api, // - // this should only occur via scripting - // since we can't use ReplicantDeleted - // catch the message and find the id or name specifier - // then delete the rep vi the api, - // - // this will fix the problem of realigning the reps - // after a remove when done through scripting - // - // note: if specified by index its the index not the id! + // this will fix the problem of realigning the reps + // 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,17 +92,19 @@ TReplicantShelf::MessageReceived(BMessage* message) } } } + break; } - break; - + default: BShelf::MessageReceived(message); break; } } + 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); + // added in AcceptAddon, from TReplicantTray + 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. -// + +// 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*) {