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