1/* 2 * Copyright 2011, Axel D��rfler, axeld@pinc-software.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7#include "ApplicationsView.h" 8 9#include "LaunchButton.h" 10#include "Switcher.h" 11 12 13static const uint32 kMsgActivateApp = 'AcAp'; 14 15 16ApplicationsView::ApplicationsView(uint32 location) 17 : 18 BGroupView((location & (kTopEdge | kBottomEdge)) != 0 19 ? B_HORIZONTAL : B_VERTICAL) 20{ 21} 22 23 24ApplicationsView::~ApplicationsView() 25{ 26} 27 28 29void 30ApplicationsView::AttachedToWindow() 31{ 32 // TODO: make this dynamic! 33 34 BList teamList; 35 be_roster->GetAppList(&teamList); 36 37 for (int32 i = 0; i < teamList.CountItems(); i++) { 38 app_info appInfo; 39 team_id team = (team_id)teamList.ItemAt(i); 40 if (be_roster->GetRunningAppInfo(team, &appInfo) == B_OK) 41 _AddTeam(appInfo); 42 } 43} 44 45 46void 47ApplicationsView::MessageReceived(BMessage* message) 48{ 49 switch (message->what) { 50 case kMsgActivateApp: 51 be_roster->ActivateApp(message->FindInt32("team")); 52 break; 53 54 default: 55 BGroupView::MessageReceived(message); 56 break; 57 } 58} 59 60 61void 62ApplicationsView::_AddTeam(app_info& info) 63{ 64 if ((info.flags & B_BACKGROUND_APP) != 0) 65 return; 66 67 BMessage* message = new BMessage(kMsgActivateApp); 68 message->AddInt32("team", info.team); 69 70 LaunchButton* button = new LaunchButton(info.signature, NULL, message, 71 this); 72 button->SetTo(&info.ref); 73 AddChild(button); 74} 75