Various cleanups to Teams window.
- Convert to using layout APIs. - Add buttons to attach to an existing team or create a new one (not implemented yet). - Various minor style cleanups.
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009-2010, Philippe Houdoin, [email protected]. All rights reserved.
|
* Copyright 2009-2010, Philippe Houdoin, [email protected]. All rights reserved.
|
||||||
|
* Copyright 2013, Rene Gollent, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -23,6 +24,11 @@
|
|||||||
#include "TeamsListView.h"
|
#include "TeamsListView.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum {
|
||||||
|
MSG_UPDATE_TEAMS_LIST = 'uptl'
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark - BitmapStringField
|
// #pragma mark - BitmapStringField
|
||||||
|
|
||||||
|
|
||||||
@@ -204,17 +210,17 @@ TeamRow::TeamRow(team_id team)
|
|||||||
bool
|
bool
|
||||||
TeamRow::NeedsUpdate(team_info& info)
|
TeamRow::NeedsUpdate(team_info& info)
|
||||||
{
|
{
|
||||||
// Check if we need to rebuilt the row's fields because the team critical
|
// Check if we need to rebuilt the row's fields because the team critical
|
||||||
// info (basically, app image running under that team ID) has changed
|
// info (basically, app image running under that team ID) has changed
|
||||||
|
|
||||||
if (info.argc != fTeamInfo.argc
|
if (info.argc != fTeamInfo.argc
|
||||||
|| strncmp(info.args, fTeamInfo.args, sizeof(fTeamInfo.args)) != 0) {
|
|| strncmp(info.args, fTeamInfo.args, sizeof(fTeamInfo.args)) != 0) {
|
||||||
_SetTo(info);
|
_SetTo(info);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
@@ -227,12 +233,12 @@ TeamRow::_SetTo(team_info& info)
|
|||||||
len >= 0 && teamInfo.args[len] == ' '; len--) {
|
len >= 0 && teamInfo.args[len] == ' '; len--) {
|
||||||
teamInfo.args[len] = 0;
|
teamInfo.args[len] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
app_info appInfo;
|
app_info appInfo;
|
||||||
status_t status = be_roster->GetRunningAppInfo(teamInfo.team, &appInfo);
|
status_t status = be_roster->GetRunningAppInfo(teamInfo.team, &appInfo);
|
||||||
if (status != B_OK) {
|
if (status != B_OK) {
|
||||||
// Not an application known to be_roster
|
// Not an application known to be_roster
|
||||||
|
|
||||||
if (teamInfo.team == B_SYSTEM_TEAM) {
|
if (teamInfo.team == B_SYSTEM_TEAM) {
|
||||||
// Get icon and name from kernel image
|
// Get icon and name from kernel image
|
||||||
system_info systemInfo;
|
system_info systemInfo;
|
||||||
@@ -243,7 +249,7 @@ TeamRow::_SetTo(team_info& info)
|
|||||||
kernelPath.Append(systemInfo.kernel_name);
|
kernelPath.Append(systemInfo.kernel_name);
|
||||||
|
|
||||||
get_ref_for_path(kernelPath.Path(), &appInfo.ref);
|
get_ref_for_path(kernelPath.Path(), &appInfo.ref);
|
||||||
|
|
||||||
} else
|
} else
|
||||||
BPrivate::get_app_ref(teamInfo.team, &appInfo.ref);
|
BPrivate::get_app_ref(teamInfo.team, &appInfo.ref);
|
||||||
}
|
}
|
||||||
@@ -279,10 +285,11 @@ TeamRow::_SetTo(team_info& info)
|
|||||||
// #pragma mark - TeamsListView
|
// #pragma mark - TeamsListView
|
||||||
|
|
||||||
|
|
||||||
TeamsListView::TeamsListView(BRect frame, const char* name)
|
TeamsListView::TeamsListView(const char* name, team_id currentTeam)
|
||||||
:
|
:
|
||||||
Inherited(frame, name, B_FOLLOW_ALL, 0, B_NO_BORDER, true),
|
Inherited(name, 0),
|
||||||
fUpdateRunner(NULL)
|
fUpdateRunner(NULL),
|
||||||
|
fCurrentTeam(currentTeam)
|
||||||
{
|
{
|
||||||
AddColumn(new TeamsColumn("Name", 400, 100, 600,
|
AddColumn(new TeamsColumn("Name", 400, 100, 600,
|
||||||
B_TRUNCATE_BEGINNING), kNameColumn);
|
B_TRUNCATE_BEGINNING), kNameColumn);
|
||||||
@@ -295,9 +302,6 @@ TeamsListView::TeamsListView(BRect frame, const char* name)
|
|||||||
*/
|
*/
|
||||||
SetSortingEnabled(false);
|
SetSortingEnabled(false);
|
||||||
|
|
||||||
team_info tmi;
|
|
||||||
get_team_info(B_CURRENT_TEAM, &tmi);
|
|
||||||
fThisTeam = tmi.team;
|
|
||||||
/*
|
/*
|
||||||
#ifdef __HAIKU__
|
#ifdef __HAIKU__
|
||||||
SetFlags(Flags() | B_SUBPIXEL_PRECISE);
|
SetFlags(Flags() | B_SUBPIXEL_PRECISE);
|
||||||
@@ -322,7 +326,7 @@ TeamsListView::AttachedToWindow()
|
|||||||
|
|
||||||
be_roster->StartWatching(this, B_REQUEST_LAUNCHED | B_REQUEST_QUIT);
|
be_roster->StartWatching(this, B_REQUEST_LAUNCHED | B_REQUEST_QUIT);
|
||||||
|
|
||||||
BMessage msg(kMsgUpdateTeamsList);
|
BMessage msg(MSG_UPDATE_TEAMS_LIST);
|
||||||
fUpdateRunner = new BMessageRunner(this, &msg, 100000L); // 10Hz
|
fUpdateRunner = new BMessageRunner(this, &msg, 100000L); // 10Hz
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,7 +349,7 @@ void
|
|||||||
TeamsListView::MessageReceived(BMessage* message)
|
TeamsListView::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
case kMsgUpdateTeamsList:
|
case MSG_UPDATE_TEAMS_LIST:
|
||||||
_UpdateList();
|
_UpdateList();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -415,7 +419,7 @@ TeamsListView::_InitList()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tmi.team == B_SYSTEM_TEAM ||
|
if (tmi.team == B_SYSTEM_TEAM ||
|
||||||
tmi.team == fThisTeam) {
|
tmi.team == fCurrentTeam) {
|
||||||
// We don't support debugging kernel and... ourself!
|
// We don't support debugging kernel and... ourself!
|
||||||
row->SetEnabled(false);
|
row->SetEnabled(false);
|
||||||
}
|
}
|
||||||
@@ -445,7 +449,7 @@ TeamsListView::_UpdateList()
|
|||||||
|
|
||||||
if (row != NULL && tmi.team == row->TeamID()
|
if (row != NULL && tmi.team == row->TeamID()
|
||||||
&& row->NeedsUpdate(tmi)) {
|
&& row->NeedsUpdate(tmi)) {
|
||||||
// The team image app could have change due after an exec*() call,
|
// The team image app could have change due after an exec*() call,
|
||||||
UpdateRow(row);
|
UpdateRow(row);
|
||||||
} else if (row == NULL || tmi.team != row->TeamID()) {
|
} else if (row == NULL || tmi.team != row->TeamID()) {
|
||||||
// Team not found in previously known teams list: insert a new row
|
// Team not found in previously known teams list: insert a new row
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009-2010 Haiku Inc. All rights reserved.
|
* Copyright 2009-2013 Haiku Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
|
* Rene Gollent
|
||||||
* Philippe Houdoin
|
* Philippe Houdoin
|
||||||
*/
|
*/
|
||||||
#ifndef TEAMS_LIST_ITEM_H
|
#ifndef TEAMS_LIST_ITEM_H
|
||||||
@@ -86,7 +87,8 @@ private:
|
|||||||
class TeamsListView : public BColumnListView {
|
class TeamsListView : public BColumnListView {
|
||||||
typedef BColumnListView Inherited;
|
typedef BColumnListView Inherited;
|
||||||
public:
|
public:
|
||||||
TeamsListView(BRect frame, const char* name);
|
TeamsListView(const char* name,
|
||||||
|
team_id currentTeam);
|
||||||
virtual ~TeamsListView();
|
virtual ~TeamsListView();
|
||||||
|
|
||||||
TeamRow* FindTeamRow(team_id teamId);
|
TeamRow* FindTeamRow(team_id teamId);
|
||||||
@@ -103,9 +105,8 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
BMessageRunner* fUpdateRunner;
|
BMessageRunner* fUpdateRunner;
|
||||||
team_id fThisTeam;
|
team_id fCurrentTeam;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const uint32 kMsgUpdateTeamsList = 'uptl';
|
|
||||||
|
|
||||||
#endif // TEAMS_LIST_VIEW_H
|
#endif // TEAMS_LIST_VIEW_H
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009-2010, Philippe Houdoin, [email protected]. All rights reserved.
|
* Copyright 2009-2010, Philippe Houdoin, [email protected]. All rights reserved.
|
||||||
|
* Copyright 2013, Rene Gollent, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -11,11 +12,13 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <ListView.h>
|
#include <Button.h>
|
||||||
#include <ScrollView.h>
|
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
|
#include <LayoutBuilder.h>
|
||||||
|
#include <ListView.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
|
#include <ScrollView.h>
|
||||||
|
|
||||||
#include "MessageCodes.h"
|
#include "MessageCodes.h"
|
||||||
#include "SettingsManager.h"
|
#include "SettingsManager.h"
|
||||||
@@ -23,13 +26,24 @@
|
|||||||
#include "TeamsListView.h"
|
#include "TeamsListView.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum {
|
||||||
|
MSG_CREATE_NEW_TEAM = 'crnt',
|
||||||
|
MSG_TEAM_SELECTION_CHANGED = 'tesc'
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
TeamsWindow::TeamsWindow(SettingsManager* settingsManager)
|
TeamsWindow::TeamsWindow(SettingsManager* settingsManager)
|
||||||
:
|
:
|
||||||
BWindow(BRect(100, 100, 500, 250), "Teams", B_DOCUMENT_WINDOW,
|
BWindow(BRect(100, 100, 500, 250), "Teams", B_DOCUMENT_WINDOW,
|
||||||
B_ASYNCHRONOUS_CONTROLS),
|
B_ASYNCHRONOUS_CONTROLS),
|
||||||
fTeamsListView(NULL),
|
fTeamsListView(NULL),
|
||||||
|
fAttachTeamButton(NULL),
|
||||||
|
fCreateTeamButton(NULL),
|
||||||
fSettingsManager(settingsManager)
|
fSettingsManager(settingsManager)
|
||||||
{
|
{
|
||||||
|
team_info info;
|
||||||
|
get_team_info(B_CURRENT_TEAM, &info);
|
||||||
|
fCurrentTeam = info.team;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -58,9 +72,16 @@ void
|
|||||||
TeamsWindow::MessageReceived(BMessage* message)
|
TeamsWindow::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
case kMsgDebugThisTeam:
|
case MSG_CREATE_NEW_TEAM:
|
||||||
{
|
{
|
||||||
TeamRow* row = dynamic_cast<TeamRow*>(fTeamsListView->CurrentSelection());
|
// TODO: implement
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case MSG_DEBUG_THIS_TEAM:
|
||||||
|
{
|
||||||
|
TeamRow* row = dynamic_cast<TeamRow*>(
|
||||||
|
fTeamsListView->CurrentSelection());
|
||||||
if (row != NULL) {
|
if (row != NULL) {
|
||||||
BMessage message(MSG_DEBUG_THIS_TEAM);
|
BMessage message(MSG_DEBUG_THIS_TEAM);
|
||||||
message.AddInt32("team", row->TeamID());
|
message.AddInt32("team", row->TeamID());
|
||||||
@@ -69,6 +90,18 @@ TeamsWindow::MessageReceived(BMessage* message)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case MSG_TEAM_SELECTION_CHANGED:
|
||||||
|
{
|
||||||
|
TeamRow* row = dynamic_cast<TeamRow*>(
|
||||||
|
fTeamsListView->CurrentSelection());
|
||||||
|
bool enabled = false;
|
||||||
|
if (row != NULL && row->TeamID() != fCurrentTeam)
|
||||||
|
enabled = true;
|
||||||
|
|
||||||
|
fAttachTeamButton->SetEnabled(enabled);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BWindow::MessageReceived(message);
|
BWindow::MessageReceived(message);
|
||||||
break;
|
break;
|
||||||
@@ -101,17 +134,25 @@ TeamsWindow::_Init()
|
|||||||
ResizeTo(frame.Width(), frame.Height());
|
ResizeTo(frame.Width(), frame.Height());
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: add button to start a team debugger
|
BLayoutBuilder::Group<>(this, B_VERTICAL)
|
||||||
// TODO: add UI to setup arguments and environ, launch a program
|
.Add(fTeamsListView = new TeamsListView("TeamsList", fCurrentTeam))
|
||||||
// and start his team debugger
|
.SetInsets(1.0f, 1.0f, 1.0f, 1.0f)
|
||||||
|
.AddGroup(B_HORIZONTAL, 4.0f)
|
||||||
|
.Add(fAttachTeamButton = new BButton("Attach"))
|
||||||
|
.Add(fCreateTeamButton = new BButton("Create new team"
|
||||||
|
B_UTF8_ELLIPSIS))
|
||||||
|
.End()
|
||||||
|
.End();
|
||||||
|
|
||||||
// Add a teams list view
|
fTeamsListView->SetInvocationMessage(new BMessage(MSG_DEBUG_THIS_TEAM));
|
||||||
frame = Bounds();
|
fTeamsListView->SetSelectionMessage(new BMessage(
|
||||||
frame.InsetBy(-1, -1);
|
MSG_TEAM_SELECTION_CHANGED));
|
||||||
fTeamsListView = new TeamsListView(frame, "TeamsList");
|
|
||||||
fTeamsListView->SetInvocationMessage(new BMessage(kMsgDebugThisTeam));
|
|
||||||
|
|
||||||
AddChild(fTeamsListView);
|
fAttachTeamButton->SetMessage(new BMessage(MSG_DEBUG_THIS_TEAM));
|
||||||
|
fAttachTeamButton->SetEnabled(false);
|
||||||
|
fCreateTeamButton->SetMessage(new BMessage(MSG_CREATE_NEW_TEAM));
|
||||||
|
// TODO: re-enable once action is implemented
|
||||||
|
fAttachTeamButton->SetEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009-2010, Philippe Houdoin, [email protected]. All rights reserved.
|
* Copyright 2009-2010, Philippe Houdoin, [email protected]. All rights reserved.
|
||||||
|
* Copyright 2013, Rene Gollent, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef TEAMS_WINDOW_H
|
#ifndef TEAMS_WINDOW_H
|
||||||
@@ -8,6 +9,7 @@
|
|||||||
|
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
|
class BButton;
|
||||||
class BListView;
|
class BListView;
|
||||||
class BFile;
|
class BFile;
|
||||||
class BMessage;
|
class BMessage;
|
||||||
@@ -32,11 +34,13 @@ private:
|
|||||||
status_t _SaveSettings();
|
status_t _SaveSettings();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
team_id fCurrentTeam;
|
||||||
TeamsListView* fTeamsListView;
|
TeamsListView* fTeamsListView;
|
||||||
|
BButton* fAttachTeamButton;
|
||||||
|
BButton* fCreateTeamButton;
|
||||||
SettingsManager* fSettingsManager;
|
SettingsManager* fSettingsManager;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const uint32 kMsgDebugThisTeam = 'dbtm';
|
|
||||||
|
|
||||||
#endif // TEAMS_WINDOW_H
|
#endif // TEAMS_WINDOW_H
|
||||||
|
|||||||
Reference in New Issue
Block a user