diff --git a/src/kits/tracker/Bitmaps.cpp b/src/kits/tracker/Bitmaps.cpp index 53ac3cc011..600b3736bf 100644 --- a/src/kits/tracker/Bitmaps.cpp +++ b/src/kits/tracker/Bitmaps.cpp @@ -160,6 +160,23 @@ BImageResources::GetIconResource(int32 id, icon_size size, BBitmap *dest) const return ret; } +status_t +BImageResources::GetIconResource(int32 id, const uint8** iconData, + size_t* iconSize) const +{ + // try to load vector icon data from resources + size_t length = 0; + const void* data = LoadResource(B_RAW_TYPE, id, &length); + + if (!data) + return B_ERROR; + + *iconData = (const uint8*)data; + *iconSize = length; + + return B_OK; +} + image_id BImageResources::find_image(void *memAddr) const { diff --git a/src/kits/tracker/Bitmaps.h b/src/kits/tracker/Bitmaps.h index 0084d9eeb4..05203dc287 100644 --- a/src/kits/tracker/Bitmaps.h +++ b/src/kits/tracker/Bitmaps.h @@ -125,6 +125,11 @@ public: // resources. this does sanity checking on the found data, // and if all is okay blasts it into the 'dest' bitmap. + status_t GetIconResource(int32 id, const uint8** iconData, + size_t* iconSize) const; + // this is a wrapper around LoadResource(), for retrieving + // the vector icon data + status_t GetBitmapResource(type_code type, int32 id, BBitmap **out) const; // this is a wrapper around LoadResource(), for retrieving // arbitrary bitmaps. the resource with the given type and diff --git a/src/kits/tracker/TrackerInitialState.cpp b/src/kits/tracker/TrackerInitialState.cpp index df8d306fee..8d3615d117 100644 --- a/src/kits/tracker/TrackerInitialState.cpp +++ b/src/kits/tracker/TrackerInitialState.cpp @@ -158,14 +158,26 @@ TTracker::InstallMimeIfNeeded(const char *type, int32 bitsID, // whole mime type is installed and all attributes are set; nulls can // be passed for attributes that don't matter; returns true if anything // had to be changed - BBitmap largeIcon(BRect(0, 0, 31, 31), B_CMAP8); - BBitmap miniIcon(BRect(0, 0, 15, 15), B_CMAP8); + +#ifndef __HAIKU__ +# define B_BITMAP_NO_SERVER_LINK 0 +#endif + +#if __HAIKU__ + BBitmap vectorIcon(BRect(0, 0, 31, 31), B_BITMAP_NO_SERVER_LINK, B_RGB32); +#endif + BBitmap largeIcon(BRect(0, 0, 31, 31), B_BITMAP_NO_SERVER_LINK, B_CMAP8); + BBitmap miniIcon(BRect(0, 0, 15, 15), B_BITMAP_NO_SERVER_LINK, B_CMAP8); char tmp[B_MIME_TYPE_LENGTH]; BMimeType mime(type); bool installed = mime.IsInstalled(); if (!installed +#if __HAIKU__ + || (bitsID >= 0 && ((forceMask & kForceLargeIcon) + || mime.GetIcon(&vectorIcon, B_LARGE_ICON) != B_OK)) +#endif || (bitsID >= 0 && ((forceMask & kForceLargeIcon) || mime.GetIcon(&largeIcon, B_LARGE_ICON) != B_OK)) || (bitsID >= 0 && ((forceMask & kForceMiniIcon) @@ -181,6 +193,14 @@ TTracker::InstallMimeIfNeeded(const char *type, int32 bitsID, mime.Install(); if (bitsID >= 0) { +#if __HAIKU__ + const uint8* iconData; + size_t iconSize; + if (GetTrackerResources()-> + GetIconResource(bitsID, &iconData, &iconSize) == B_OK) + mime.SetIcon(iconData, iconSize); +#endif + if (GetTrackerResources()-> GetIconResource(bitsID, B_LARGE_ICON, &largeIcon) == B_OK) mime.SetIcon(&largeIcon, B_LARGE_ICON); @@ -433,7 +453,8 @@ InstallTemporaryBackgroundImagesIfNeeded(BNode *node, const char *imagePath, void TTracker::InstallTemporaryBackgroundImages() { - + // TODO: make the large Haiku Logo the default background + BPath path; FSFindTrackerSettingsDir(&path, false); BString defaultFolderPath(path.Path());