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:
@@ -9,6 +9,7 @@
|
|||||||
#include "ExtensionWindow.h"
|
#include "ExtensionWindow.h"
|
||||||
#include "FileTypes.h"
|
#include "FileTypes.h"
|
||||||
#include "FileTypesWindow.h"
|
#include "FileTypesWindow.h"
|
||||||
|
#include "IconView.h"
|
||||||
#include "MimeTypeListView.h"
|
#include "MimeTypeListView.h"
|
||||||
#include "NewFileTypeWindow.h"
|
#include "NewFileTypeWindow.h"
|
||||||
#include "PreferredAppMenu.h"
|
#include "PreferredAppMenu.h"
|
||||||
|
|||||||
@@ -26,6 +26,58 @@
|
|||||||
#include <string.h>
|
#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()
|
Icon::Icon()
|
||||||
:
|
:
|
||||||
fLarge(NULL),
|
fLarge(NULL),
|
||||||
|
|||||||
@@ -111,4 +111,14 @@ static const uint32 kMsgRemoveIcon = 'icrm';
|
|||||||
static const uint32 kMsgAddIcon = 'icad';
|
static const uint32 kMsgAddIcon = 'icad';
|
||||||
static const uint32 kMsgEditIcon = 'iced';
|
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
|
#endif // ICON_VIEW_H
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "IconView.h"
|
||||||
#include "MimeTypeListView.h"
|
#include "MimeTypeListView.h"
|
||||||
|
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
@@ -16,55 +17,6 @@
|
|||||||
const uint32 kMsgAddType = 'adtp';
|
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
|
bool
|
||||||
mimetype_is_application_signature(BMimeType& type)
|
mimetype_is_application_signature(BMimeType& type)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -87,15 +87,6 @@ class MimeTypeListView : public BOutlineListView {
|
|||||||
bool fApplicationMode;
|
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);
|
extern bool mimetype_is_application_signature(BMimeType& type);
|
||||||
|
|
||||||
#endif // MIME_TYPE_LIST_VIEW_H
|
#endif // MIME_TYPE_LIST_VIEW_H
|
||||||
|
|||||||
Reference in New Issue
Block a user