diff --git a/headers/private/storage/mime/Database.h b/headers/private/storage/mime/Database.h index 2f621d3ea6..13a0eeb3b9 100644 --- a/headers/private/storage/mime/Database.h +++ b/headers/private/storage/mime/Database.h @@ -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, diff --git a/src/kits/storage/mime/Database.cpp b/src/kits/storage/mime/Database.cpp index 8ae3d701e4..c176f3d33f 100644 --- a/src/kits/storage/mime/Database.cpp +++ b/src/kits/storage/mime/Database.cpp @@ -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.