desklink: Make use of BControlLook::ComposeIconSize().

Fixes #16370.
This commit is contained in:
Augustin Cavalier
2022-08-26 18:53:13 -04:00
parent 6970f0fdab
commit 8f3508d9c5
2 changed files with 15 additions and 18 deletions
+8 -13
View File
@@ -13,6 +13,7 @@
#include <Alert.h>
#include <Bitmap.h>
#include <Catalog.h>
#include <ControlLook.h>
#include <Dragger.h>
#include <MenuItem.h>
#include <Message.h>
@@ -42,17 +43,13 @@ DeskButton::DeskButton(BRect frame, entry_ref* ref, const char* name,
fActionList(actions),
fTitleList(titles)
{
#ifdef __HAIKU__
fSegments = new BBitmap(BRect(0, 0, 15, 15), B_RGBA32);
#else
fSegments = new BBitmap(BRect(0, 0, 15, 15), B_CMAP8);
#endif
BNodeInfo::GetTrackerIcon(&fRef, fSegments, B_MINI_ICON);
fSegments = new BBitmap(frame, B_RGBA32);
BNodeInfo::GetTrackerIcon(&fRef, fSegments, (icon_size)(frame.IntegerWidth() + 1));
}
DeskButton::DeskButton(BMessage *message)
: BView(message)
: BView(message)
{
message->FindRef("ref", &fRef);
@@ -65,12 +62,10 @@ DeskButton::DeskButton(BMessage *message)
index++;
}
#ifdef __HAIKU__
fSegments = new BBitmap(BRect(0, 0, 15, 15), B_RGBA32);
#else
fSegments = new BBitmap(BRect(0, 0, 15, 15), B_CMAP8);
#endif
BNodeInfo::GetTrackerIcon(&fRef, fSegments, B_MINI_ICON);
fSegments = new BBitmap(BRect(BPoint(0, 0), be_control_look->ComposeIconSize(B_MINI_ICON)),
B_RGBA32);
BNodeInfo::GetTrackerIcon(&fRef, fSegments,
(icon_size)(fSegments->Bounds().IntegerWidth() + 1));
}
+7 -5
View File
@@ -18,6 +18,7 @@
#include <Alert.h>
#include <Application.h>
#include <ControlLook.h>
#include <Deskbar.h>
#include <MimeType.h>
#include <Roster.h>
@@ -34,7 +35,7 @@ const char *kAppSignature = "application/x-vnd.Haiku-desklink";
int
main(int, char **argv)
{
{
BApplication app(kAppSignature);
bool atLeastOnePath = false;
BList titleList;
@@ -45,7 +46,7 @@ main(int, char **argv)
for (int32 i = 1; argv[i]!=NULL; i++) {
if (strcmp(argv[i], "--help") == 0)
break;
if (strcmp(argv[i], "--list") == 0) {
int32 count = deskbar.CountItems();
int32 found = 0;
@@ -124,7 +125,7 @@ main(int, char **argv)
BEntry entry(argv[i], true);
entry_ref ref;
if (entry.Exists()) {
entry.GetRef(&ref);
} else if (BMimeType::IsValid(argv[i])) {
@@ -136,10 +137,11 @@ main(int, char **argv)
printf("desklink: cannot find '%s'\n", argv[i]);
return 1;
}
err = deskbar.AddItem(&ref);
if (err != B_OK) {
err = deskbar.AddItem(new DeskButton(BRect(0, 0, 15, 15),
err = deskbar.AddItem(new DeskButton(BRect(BPoint(0, 0),
be_control_look->ComposeIconSize(B_MINI_ICON)),
&ref, ref.name, titleList, actionList));
if (err != B_OK) {
printf("desklink: Deskbar refuses link to '%s': %s\n", argv[i], strerror(err));