From aac40c99c2fb40540b32018be90eb8859a313cb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Mon, 11 Sep 2006 15:12:50 +0000 Subject: [PATCH] =?UTF-8?q?*=20Tracker=20makes=20sure=20certain=20mimetype?= =?UTF-8?q?s=20exist=20and=20copies=20icons=20from=20=20=20its=20resources?= =?UTF-8?q?=20->=20now=20also=20the=20vector=20icons=20(thanks=20J=C3=A9r?= =?UTF-8?q?=C3=B4me=20for=20=20=20the=20hint)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18806 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/tracker/Bitmaps.cpp | 17 +++++++++++++++ src/kits/tracker/Bitmaps.h | 5 +++++ src/kits/tracker/TrackerInitialState.cpp | 27 +++++++++++++++++++++--- 3 files changed, 46 insertions(+), 3 deletions(-) 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());