* Tracker makes sure certain mimetypes exist and copies icons from

its resources -> now also the vector icons (thanks Jérôme for
  the hint)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18806 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2006-09-11 15:12:50 +00:00
parent 2634e48f59
commit aac40c99c2
3 changed files with 46 additions and 3 deletions
+17
View File
@@ -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
{
+5
View File
@@ -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
+24 -3
View File
@@ -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());