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:
Ingo Weinhold
2014-01-25 11:53:47 +01:00
parent 6ef57ae2a9
commit ee2974dadb
2 changed files with 32 additions and 8 deletions
+4
View File
@@ -69,9 +69,13 @@ class Database {
status_t SetShortDescription(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 SetIcon(const char* type, const BBitmap* icon,
icon_size which);
status_t SetIcon(const char *type, const void *data, size_t dataSize,
icon_size which);
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,
const void *data, size_t dataSize, icon_size which);
status_t SetIconForType(const char *type, const char *fileType,
+28 -8
View File
@@ -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,
I'll add some real documentation.
/*!
\brief Sets a bitmap icon for the given mime type
*/
status_t
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);
}
/*!
\brief Sets the vector icon for the given mime type
*/
status_t
Database::SetIcon(const char *type, const void *data, size_t 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
/*! \brief Sets the large or mini icon used by an application of this type for
files of the given type.