btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / apps / switcher / ApplicationsView.cpp
blob1be9ca8c2fb86ed6f287f59d0e26f5e824332cec
1 /*
2 * Copyright 2011, Axel Dörfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT License.
4 */
7 #include "ApplicationsView.h"
9 #include "LaunchButton.h"
10 #include "Switcher.h"
13 static const uint32 kMsgActivateApp = 'AcAp';
16 ApplicationsView::ApplicationsView(uint32 location)
18 BGroupView((location & (kTopEdge | kBottomEdge)) != 0
19 ? B_HORIZONTAL : B_VERTICAL)
24 ApplicationsView::~ApplicationsView()
29 void
30 ApplicationsView::AttachedToWindow()
32 // TODO: make this dynamic!
34 BList teamList;
35 be_roster->GetAppList(&teamList);
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);
46 void
47 ApplicationsView::MessageReceived(BMessage* message)
49 switch (message->what) {
50 case kMsgActivateApp:
51 be_roster->ActivateApp(message->FindInt32("team"));
52 break;
54 default:
55 BGroupView::MessageReceived(message);
56 break;
61 void
62 ApplicationsView::_AddTeam(app_info& info)
64 if ((info.flags & B_BACKGROUND_APP) != 0)
65 return;
67 BMessage* message = new BMessage(kMsgActivateApp);
68 message->AddInt32("team", info.team);
70 LaunchButton* button = new LaunchButton(info.signature, NULL, message,
71 this);
72 button->SetTo(&info.ref);
73 AddChild(button);