Moved icon_for_type() to IconView.cpp.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19283 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2006-11-14 18:26:10 +00:00
parent 7f721ea14d
commit 00cf1f4671
5 changed files with 64 additions and 58 deletions

View File

@ -9,6 +9,7 @@
#include "ExtensionWindow.h"
#include "FileTypes.h"
#include "FileTypesWindow.h"
#include "IconView.h"
#include "MimeTypeListView.h"
#include "NewFileTypeWindow.h"
#include "PreferredAppMenu.h"

View File

@ -26,6 +26,58 @@
#include <string.h>
status_t
icon_for_type(BMimeType& type, BBitmap& bitmap, icon_size size,
icon_source* _source)
{
icon_source source = kNoIcon;
if (type.GetIcon(&bitmap, size) == B_OK)
source = kOwnIcon;
if (source == kNoIcon) {
// check for icon from preferred app
char preferred[B_MIME_TYPE_LENGTH];
if (type.GetPreferredApp(preferred) == B_OK) {
BMimeType preferredApp(preferred);
if (preferredApp.GetIconForType(type.Type(), &bitmap, size) == B_OK)
source = kApplicationIcon;
}
}
if (source == kNoIcon) {
// check super type for an icon
BMimeType superType;
if (type.GetSupertype(&superType) == B_OK) {
if (superType.GetIcon(&bitmap, size) == B_OK)
source = kSupertypeIcon;
else {
// check the super type's preferred app
char preferred[B_MIME_TYPE_LENGTH];
if (superType.GetPreferredApp(preferred) == B_OK) {
BMimeType preferredApp(preferred);
if (preferredApp.GetIconForType(superType.Type(),
&bitmap, size) == B_OK)
source = kSupertypeIcon;
}
}
}
}
if (_source)
*_source = source;
return source != kNoIcon ? B_OK : B_ERROR;
}
// #pragma mark -
Icon::Icon()
:
fLarge(NULL),

View File

@ -111,4 +111,14 @@ static const uint32 kMsgRemoveIcon = 'icrm';
static const uint32 kMsgAddIcon = 'icad';
static const uint32 kMsgEditIcon = 'iced';
enum icon_source {
kNoIcon = 0,
kOwnIcon,
kApplicationIcon,
kSupertypeIcon
};
extern status_t icon_for_type(BMimeType& type, BBitmap& bitmap,
icon_size size, icon_source* _source = NULL);
#endif // ICON_VIEW_H

View File

@ -4,6 +4,7 @@
*/
#include "IconView.h"
#include "MimeTypeListView.h"
#include <Bitmap.h>
@ -16,55 +17,6 @@
const uint32 kMsgAddType = 'adtp';
status_t
icon_for_type(BMimeType& type, BBitmap& bitmap, icon_size size,
icon_source* _source)
{
icon_source source = kNoIcon;
if (type.GetIcon(&bitmap, size) == B_OK)
source = kOwnIcon;
if (source == kNoIcon) {
// check for icon from preferred app
char preferred[B_MIME_TYPE_LENGTH];
if (type.GetPreferredApp(preferred) == B_OK) {
BMimeType preferredApp(preferred);
if (preferredApp.GetIconForType(type.Type(), &bitmap, size) == B_OK)
source = kApplicationIcon;
}
}
if (source == kNoIcon) {
// check super type for an icon
BMimeType superType;
if (type.GetSupertype(&superType) == B_OK) {
if (superType.GetIcon(&bitmap, size) == B_OK)
source = kSupertypeIcon;
else {
// check the super type's preferred app
char preferred[B_MIME_TYPE_LENGTH];
if (superType.GetPreferredApp(preferred) == B_OK) {
BMimeType preferredApp(preferred);
if (preferredApp.GetIconForType(superType.Type(),
&bitmap, size) == B_OK)
source = kSupertypeIcon;
}
}
}
}
if (_source)
*_source = source;
return source != kNoIcon ? B_OK : B_ERROR;
}
bool
mimetype_is_application_signature(BMimeType& type)
{

View File

@ -87,15 +87,6 @@ class MimeTypeListView : public BOutlineListView {
bool fApplicationMode;
};
enum icon_source {
kNoIcon = 0,
kOwnIcon,
kApplicationIcon,
kSupertypeIcon
};
extern status_t icon_for_type(BMimeType& type, BBitmap& bitmap, icon_size size,
icon_source* _source = NULL);
extern bool mimetype_is_application_signature(BMimeType& type);
#endif // MIME_TYPE_LIST_VIEW_H