From 73309d564f6e50159c2051eded8e466946e494eb Mon Sep 17 00:00:00 2001 From: Julien Lepiller Date: Thu, 18 Sep 2014 15:44:22 +1200 Subject: [PATCH] bootman: add the drive's icon in the drive list * Also check status of GetIcon() * Delete fDrive, fIcon in destructor Fixes #7088 Signed-off-by: Jessica Hamilton --- src/apps/bootmanager/DrivesPage.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/apps/bootmanager/DrivesPage.cpp b/src/apps/bootmanager/DrivesPage.cpp index d96dc335e9..8c1c204898 100644 --- a/src/apps/bootmanager/DrivesPage.cpp +++ b/src/apps/bootmanager/DrivesPage.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include @@ -49,6 +50,7 @@ protected: private: BootDrive* fDrive; + BBitmap* fIcon; BString fName; BPath fPath; BString fSize; @@ -73,6 +75,11 @@ DriveItem::DriveItem(const BDiskDevice& device, const BootMenuList& menus) else fName = B_TRANSLATE_COMMENT("Hard Drive", "Default disk name"); + fIcon = new BBitmap(BRect(0, 0, B_LARGE_ICON - 1, B_LARGE_ICON - 1), + B_RGBA32); + if (device.GetIcon(fIcon, B_LARGE_ICON) != B_OK) + memset(fIcon->Bits(), 0, fIcon->BitsLength()); + fDrive = new BootDrive(fPath.Path()); fIsInstalled = fDrive->InstalledMenu(menus) != NULL; @@ -85,6 +92,8 @@ DriveItem::DriveItem(const BDiskDevice& device, const BootMenuList& menus) DriveItem::~DriveItem() { + delete fDrive; + delete fIcon; } @@ -113,7 +122,7 @@ void DriveItem::DrawItem(BView* owner, BRect frame, bool complete) { owner->PushState(); - + owner->SetDrawingMode(B_OP_ALPHA); if (IsSelected() || complete) { if (IsSelected()) { owner->SetHighColor(tint_color(owner->LowColor(), B_DARKEN_2_TINT)); @@ -131,8 +140,12 @@ DriveItem::DrawItem(BView* owner, BRect frame, bool complete) else owner->SetHighColor(black); + // icon + owner->MovePenTo(frame.left + 4, frame.top + 1); + owner->DrawBitmap(fIcon); + // device - owner->MovePenTo(frame.left + 4, frame.top + fSecondBaselineOffset); + owner->MovePenTo(frame.left + 8 + fIcon->Bounds().Width(), frame.top + fSecondBaselineOffset); owner->DrawString(fPath.Path()); // size @@ -145,7 +158,7 @@ DriveItem::DrawItem(BView* owner, BRect frame, bool complete) boldFont.SetFace(B_BOLD_FACE); owner->SetFont(&boldFont); - owner->MovePenTo(frame.left + 4, frame.top + fBaselineOffset); + owner->MovePenTo(frame.left + 8 + fIcon->Bounds().Width(), frame.top + fBaselineOffset); owner->DrawString(fName.String()); if (fCanBeInstalled != B_OK) {