mime/Database: Add SetIcon[ForType]() BBitmap* version
When switching AppMetaMimeCreator from BMimeType to Database the SetIcon[ForType]() calls with a BBitmap* ended up calling the vector icon version with the icon_size as the data size argument, thus not only not writing the bitmap icon attributes, but also clobbering the vector icon attribute.
This commit is contained in:
@@ -69,9 +69,13 @@ class Database {
|
|||||||
status_t SetShortDescription(const char *type, const char *description);
|
status_t SetShortDescription(const char *type, const char *description);
|
||||||
status_t SetLongDescription(const char *type, const char *description);
|
status_t SetLongDescription(const char *type, const char *description);
|
||||||
status_t SetFileExtensions(const char *type, const BMessage *extensions);
|
status_t SetFileExtensions(const char *type, const BMessage *extensions);
|
||||||
|
status_t SetIcon(const char* type, const BBitmap* icon,
|
||||||
|
icon_size which);
|
||||||
status_t SetIcon(const char *type, const void *data, size_t dataSize,
|
status_t SetIcon(const char *type, const void *data, size_t dataSize,
|
||||||
icon_size which);
|
icon_size which);
|
||||||
status_t SetIcon(const char *type, const void *data, size_t dataSize);
|
status_t SetIcon(const char *type, const void *data, size_t dataSize);
|
||||||
|
status_t SetIconForType(const char* type, const char* fileType,
|
||||||
|
const BBitmap* icon, icon_size which);
|
||||||
status_t SetIconForType(const char *type, const char *fileType,
|
status_t SetIconForType(const char *type, const char *fileType,
|
||||||
const void *data, size_t dataSize, icon_size which);
|
const void *data, size_t dataSize, icon_size which);
|
||||||
status_t SetIconForType(const char *type, const char *fileType,
|
status_t SetIconForType(const char *type, const char *fileType,
|
||||||
|
|||||||
@@ -356,16 +356,19 @@ Database::SetFileExtensions(const char *type, const BMessage *extensions)
|
|||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Sets the icon for the given mime type
|
\brief Sets a bitmap icon for the given mime type
|
||||||
|
*/
|
||||||
|
status_t
|
||||||
|
Database::SetIcon(const char* type, const BBitmap* icon, icon_size which)
|
||||||
|
{
|
||||||
|
if (icon != NULL)
|
||||||
|
return SetIcon(type, icon->Bits(), icon->BitsLength(), which);
|
||||||
|
return SetIcon(type, NULL, 0, which);
|
||||||
|
}
|
||||||
|
|
||||||
This is the version I would have used if I could have gotten a BBitmap
|
|
||||||
to the registrar somehow. Since R5::BBitmap::Instantiate is causing a
|
|
||||||
violent crash, I've copied most of the icon color conversion code into
|
|
||||||
Mime::get_icon_data() so BMimeType::SetIcon() can get at it.
|
|
||||||
|
|
||||||
Once we have a sufficiently complete OBOS::BBitmap implementation, we
|
/*!
|
||||||
ought to be able to use this version of SetIcon() again. At that point,
|
\brief Sets a bitmap icon for the given mime type
|
||||||
I'll add some real documentation.
|
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
Database::SetIcon(const char *type, const void *data, size_t dataSize,
|
Database::SetIcon(const char *type, const void *data, size_t dataSize,
|
||||||
@@ -374,12 +377,29 @@ Database::SetIcon(const char *type, const void *data, size_t dataSize,
|
|||||||
return SetIconForType(type, NULL, data, dataSize, which);
|
return SetIconForType(type, NULL, data, dataSize, which);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Sets the vector icon for the given mime type
|
||||||
|
*/
|
||||||
status_t
|
status_t
|
||||||
Database::SetIcon(const char *type, const void *data, size_t dataSize)
|
Database::SetIcon(const char *type, const void *data, size_t dataSize)
|
||||||
{
|
{
|
||||||
return SetIconForType(type, NULL, data, dataSize);
|
return SetIconForType(type, NULL, data, dataSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
Database::SetIconForType(const char* type, const char* fileType,
|
||||||
|
const BBitmap* icon, icon_size which)
|
||||||
|
{
|
||||||
|
if (icon != NULL) {
|
||||||
|
return SetIconForType(type, fileType, icon->Bits(),
|
||||||
|
(size_t)icon->BitsLength(), which);
|
||||||
|
}
|
||||||
|
return SetIconForType(type, fileType, NULL, 0, which);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// SetIconForType
|
// SetIconForType
|
||||||
/*! \brief Sets the large or mini icon used by an application of this type for
|
/*! \brief Sets the large or mini icon used by an application of this type for
|
||||||
files of the given type.
|
files of the given type.
|
||||||
|
|||||||
Reference in New Issue
Block a user