Followed Ingo's suggestion: use private get_app_ref(). This reduce code duplication.
Thanks. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42659 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
283db26d5c
commit
dd537d13a8
@ -9,6 +9,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <AppMisc.h>
|
||||
#include <Bitmap.h>
|
||||
#include <ColumnTypes.h>
|
||||
#include <FindDirectory.h>
|
||||
@ -203,51 +204,32 @@ TeamRow::TeamRow(team_id team)
|
||||
status_t
|
||||
TeamRow::_SetTo(team_info& info)
|
||||
{
|
||||
BPath systemPath;
|
||||
team_info teamInfo = fTeamInfo = info;
|
||||
|
||||
find_directory(B_BEOS_SYSTEM_DIRECTORY, &systemPath);
|
||||
|
||||
// strip any trailing space(s)...
|
||||
for (int len = strlen(teamInfo.args) - 1;
|
||||
len >= 0 && teamInfo.args[len] == ' '; len--) {
|
||||
teamInfo.args[len] = 0;
|
||||
}
|
||||
|
||||
|
||||
app_info appInfo;
|
||||
status_t status = be_roster->GetRunningAppInfo(teamInfo.team, &appInfo);
|
||||
|
||||
if (status == B_OK || teamInfo.team == B_SYSTEM_TEAM) {
|
||||
if (status != B_OK) {
|
||||
// Not an application known to be_roster
|
||||
|
||||
if (teamInfo.team == B_SYSTEM_TEAM) {
|
||||
// Get icon and name from kernel
|
||||
// Get icon and name from kernel image
|
||||
system_info systemInfo;
|
||||
get_system_info(&systemInfo);
|
||||
|
||||
BPath kernelPath(systemPath);
|
||||
BPath kernelPath;
|
||||
find_directory(B_BEOS_SYSTEM_DIRECTORY, &kernelPath);
|
||||
kernelPath.Append(systemInfo.kernel_name);
|
||||
|
||||
get_ref_for_path(kernelPath.Path(), &appInfo.ref);
|
||||
}
|
||||
} else {
|
||||
// Not an application known to be_roster
|
||||
|
||||
// The teamInfo.args string is not safe and could be truncated.
|
||||
// This could leads to show an intermediate folder icon!
|
||||
//
|
||||
// Let's retrieve instead the entry_ref from the first team's image of
|
||||
// type B_APP_IMAGE
|
||||
int32 cookie = 0;
|
||||
image_info imageInfo;
|
||||
while (get_next_image_info(teamInfo.team, &cookie, &imageInfo) == B_OK) {
|
||||
if (imageInfo.type == B_APP_IMAGE) {
|
||||
BPath imagePath(imageInfo.name);
|
||||
appInfo.ref.device = imageInfo.device;
|
||||
appInfo.ref.directory = imageInfo.node;
|
||||
appInfo.ref.set_name(imagePath.Leaf());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} else
|
||||
BPrivate::get_app_ref(teamInfo.team, &appInfo.ref);
|
||||
}
|
||||
|
||||
BBitmap* icon = new BBitmap(BRect(0, 0, B_MINI_ICON - 1, B_MINI_ICON - 1), B_RGBA32);
|
||||
|
Loading…
Reference in New Issue
Block a user