* Tracker wrote icons with the wrong type at several places.

* Also replaced all B_COLOR_8_BIT with the B_CMAP8 constant.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16909 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2006-03-28 11:32:21 +00:00
parent 9913366fe7
commit cd94fddab2
8 changed files with 271 additions and 186 deletions
+7 -8
View File
@@ -2126,7 +2126,7 @@ FSGetDeskDir(BDirectory *deskDir, dev_t dev)
status_t result = volume.InitCheck(); status_t result = volume.InitCheck();
if (result != B_OK) if (result != B_OK)
return result; return result;
BPath path; BPath path;
result = find_directory(B_DESKTOP_DIRECTORY, &path, true, &volume); result = find_directory(B_DESKTOP_DIRECTORY, &path, true, &volume);
if (result != B_OK) if (result != B_OK)
@@ -2147,14 +2147,14 @@ FSGetDeskDir(BDirectory *deskDir, dev_t dev)
LoadResource('ICON', kResDeskIcon, &size); LoadResource('ICON', kResDeskIcon, &size);
if (data) if (data)
deskDir->WriteAttr(kAttrLargeIcon, B_COLOR_8_BIT_TYPE, 0, data, size); deskDir->WriteAttr(kAttrLargeIcon, 'ICON', 0, data, size);
data = GetTrackerResources()-> data = GetTrackerResources()->
LoadResource('MICN', kResDeskIcon, &size); LoadResource('MICN', kResDeskIcon, &size);
if (data) if (data)
deskDir->WriteAttr(kAttrMiniIcon, B_COLOR_8_BIT_TYPE, 0, data, size); deskDir->WriteAttr(kAttrMiniIcon, 'MICN', 0, data, size);
return B_OK; return B_OK;
} }
@@ -2631,10 +2631,9 @@ FSCreateTrashDirs()
roster.Rewind(); roster.Rewind();
while (roster.GetNextVolume(&volume) == B_OK) { while (roster.GetNextVolume(&volume) == B_OK) {
if (volume.IsReadOnly() || !volume.IsPersistent()) if (volume.IsReadOnly() || !volume.IsPersistent())
continue; continue;
BPath path; BPath path;
find_directory(B_DESKTOP_DIRECTORY, &path, true, &volume); find_directory(B_DESKTOP_DIRECTORY, &path, true, &volume);
find_directory(B_TRASH_DIRECTORY, &path, true, &volume); find_directory(B_TRASH_DIRECTORY, &path, true, &volume);
@@ -2645,13 +2644,13 @@ FSCreateTrashDirs()
const void* data = GetTrackerResources()-> const void* data = GetTrackerResources()->
LoadResource('ICON', kResTrashIcon, &size); LoadResource('ICON', kResTrashIcon, &size);
if (data) { if (data) {
trashDir.WriteAttr(kAttrLargeIcon, B_COLOR_8_BIT_TYPE, 0, trashDir.WriteAttr(kAttrLargeIcon, 'ICON', 0,
data, size); data, size);
} }
data = GetTrackerResources()-> data = GetTrackerResources()->
LoadResource('MICN', kResTrashIcon, &size); LoadResource('MICN', kResTrashIcon, &size);
if (data) { if (data) {
trashDir.WriteAttr(kAttrMiniIcon, B_COLOR_8_BIT_TYPE, 0, trashDir.WriteAttr(kAttrMiniIcon, 'MICN', 0,
data, size); data, size);
} }
} }
+5 -5
View File
@@ -1049,8 +1049,8 @@ TDraggableIconButton::AttachedToWindow()
else else
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
fIcon = new BBitmap(BRect(0, 0, 31, 31), B_COLOR_8_BIT); fIcon = new BBitmap(BRect(0, 0, 31, 31), B_CMAP8);
fIcon->SetBits(kLargeNewGroupIcon, fIcon->BitsLength(), 0, B_COLOR_8_BIT); fIcon->SetBits(kLargeNewGroupIcon, fIcon->BitsLength(), 0, B_CMAP8);
// calculate correct frame for icon and label // calculate correct frame for icon and label
// sets icon rect and label rect for drawing // sets icon rect and label rect for drawing
ResizeToPreferred(); ResizeToPreferred();
@@ -1250,14 +1250,14 @@ TContentsMenu::AttachedToWindow()
fDownBtn->SetTarget(this, Window()); fDownBtn->SetTarget(this, Window());
// cache the new group icon // cache the new group icon
fSmallGroupIcon = new BBitmap(BRect(0, 0, 15, 15), B_COLOR_8_BIT); fSmallGroupIcon = new BBitmap(BRect(0, 0, 15, 15), B_CMAP8);
fSmallGroupIcon->SetBits(kSmallNewGroupIcon, fSmallGroupIcon->BitsLength(), fSmallGroupIcon->SetBits(kSmallNewGroupIcon, fSmallGroupIcon->BitsLength(),
0, B_COLOR_8_BIT); 0, B_CMAP8);
// cache the symlink icon // cache the symlink icon
BMimeType symlink("application/x-vnd.Be-symlink"); BMimeType symlink("application/x-vnd.Be-symlink");
if (symlink.InitCheck() == B_OK) { if (symlink.InitCheck() == B_OK) {
fSymlinkIcon = new BBitmap(BRect(0, 0, 15, 15), B_COLOR_8_BIT); fSymlinkIcon = new BBitmap(BRect(0, 0, 15, 15), B_CMAP8);
if (symlink.GetIcon(fSymlinkIcon, B_MINI_ICON) != B_OK) if (symlink.GetIcon(fSymlinkIcon, B_MINI_ICON) != B_OK)
fSymlinkIcon = NULL; fSymlinkIcon = NULL;
} else } else
+34 -33
View File
@@ -34,29 +34,29 @@ All rights reserved.
// menu items with small icons. // menu items with small icons.
#include "IconCache.h"
#include "IconMenuItem.h"
#include <Debug.h> #include <Debug.h>
#include <Menu.h> #include <Menu.h>
#include <NodeInfo.h> #include <NodeInfo.h>
#include "IconCache.h"
#include "IconMenuItem.h"
ModelMenuItem::ModelMenuItem(const Model *model, const char *title, ModelMenuItem::ModelMenuItem(const Model *model, const char *title,
BMessage *message, char shortcut, uint32 modifiers, BMessage *message, char shortcut, uint32 modifiers,
bool drawText, bool extraPad) bool drawText, bool extraPad)
: BMenuItem(title, message, shortcut, modifiers), : BMenuItem(title, message, shortcut, modifiers),
fModel(*model), fModel(*model),
fHeightDelta(0), fHeightDelta(0),
fDrawText(drawText), fDrawText(drawText),
fExtraPad(extraPad) fExtraPad(extraPad)
{ {
ThrowOnInitCheckError(&fModel); ThrowOnInitCheckError(&fModel);
// The 'fExtraPad' field is used to when this menu item is added to // The 'fExtraPad' field is used to when this menu item is added to
// a menubar instead of a menu. Menus and MenuBars space out items // a menubar instead of a menu. Menus and MenuBars space out items
// differently (more space around items in a menu). This class wants // differently (more space around items in a menu). This class wants
// to be able to space item the same, no matter where they are. The // to be able to space item the same, no matter where they are. The
// fExtraPad field allows for that. // fExtraPad field allows for that.
if (model->IsRoot()) if (model->IsRoot())
SetLabel(model->Name()); SetLabel(model->Name());
@@ -189,10 +189,11 @@ ModelMenuItem::Invoke(BMessage *message)
clone.AddInt64("when", system_time()); clone.AddInt64("when", system_time());
clone.AddPointer("source", this); clone.AddPointer("source", this);
if ((modifiers() & B_OPTION_KEY) == 0) if ((modifiers() & B_OPTION_KEY) == 0) {
// if option not held, remove refs to close to prevent closing // if option not held, remove refs to close to prevent closing
// parent window // parent window
clone.RemoveData("nodeRefsToClose"); clone.RemoveData("nodeRefsToClose");
}
return BInvoker::Invoke(&clone); return BInvoker::Invoke(&clone);
} }
@@ -226,8 +227,8 @@ SpecialModelMenuItem::DrawContent()
IconMenuItem::IconMenuItem(const char *label, BMessage *message, BBitmap *icon) IconMenuItem::IconMenuItem(const char *label, BMessage *message, BBitmap *icon)
: PositionPassingMenuItem(label, message), : PositionPassingMenuItem(label, message),
fDeviceIcon(icon) fDeviceIcon(icon)
{ {
// IconMenuItem is used in synchronously invoked menus, make sure // IconMenuItem is used in synchronously invoked menus, make sure
// we invoke with a timeout // we invoke with a timeout
@@ -236,18 +237,18 @@ IconMenuItem::IconMenuItem(const char *label, BMessage *message, BBitmap *icon)
IconMenuItem::IconMenuItem(const char *label, BMessage *message, IconMenuItem::IconMenuItem(const char *label, BMessage *message,
const BNodeInfo *nodeInfo, icon_size which) const BNodeInfo *nodeInfo, icon_size which)
: PositionPassingMenuItem(label, message), : PositionPassingMenuItem(label, message),
fDeviceIcon(NULL) fDeviceIcon(NULL)
{ {
if (nodeInfo) { if (nodeInfo) {
fDeviceIcon = new BBitmap(BRect(0, 0, which - 1, which - 1), B_COLOR_8_BIT); fDeviceIcon = new BBitmap(BRect(0, 0, which - 1, which - 1), B_CMAP8);
if (nodeInfo->GetTrackerIcon(fDeviceIcon, B_MINI_ICON)) { if (nodeInfo->GetTrackerIcon(fDeviceIcon, B_MINI_ICON)) {
delete fDeviceIcon; delete fDeviceIcon;
fDeviceIcon = NULL; fDeviceIcon = NULL;
} }
} }
// IconMenuItem is used in synchronously invoked menus, make sure // IconMenuItem is used in synchronously invoked menus, make sure
// we invoke with a timeout // we invoke with a timeout
SetTimeout(kSynchMenuInvokeTimeout); SetTimeout(kSynchMenuInvokeTimeout);
@@ -255,18 +256,18 @@ IconMenuItem::IconMenuItem(const char *label, BMessage *message,
IconMenuItem::IconMenuItem(const char *label, BMessage *message, IconMenuItem::IconMenuItem(const char *label, BMessage *message,
const char *iconType, icon_size which) const char *iconType, icon_size which)
: PositionPassingMenuItem(label, message), : PositionPassingMenuItem(label, message),
fDeviceIcon(NULL) fDeviceIcon(NULL)
{ {
BMimeType mime(iconType); BMimeType mime(iconType);
fDeviceIcon = new BBitmap(BRect(0, 0, which - 1, which - 1), B_COLOR_8_BIT); fDeviceIcon = new BBitmap(BRect(0, 0, which - 1, which - 1), B_CMAP8);
if (mime.GetIcon(fDeviceIcon, which) != B_OK) { if (mime.GetIcon(fDeviceIcon, which) != B_OK) {
delete fDeviceIcon; delete fDeviceIcon;
fDeviceIcon = NULL; fDeviceIcon = NULL;
} }
// IconMenuItem is used in synchronously invoked menus, make sure // IconMenuItem is used in synchronously invoked menus, make sure
// we invoke with a timeout // we invoke with a timeout
SetTimeout(kSynchMenuInvokeTimeout); SetTimeout(kSynchMenuInvokeTimeout);
@@ -274,18 +275,18 @@ IconMenuItem::IconMenuItem(const char *label, BMessage *message,
IconMenuItem::IconMenuItem(BMenu *submenu, BMessage *message, IconMenuItem::IconMenuItem(BMenu *submenu, BMessage *message,
const char *iconType, icon_size which) const char *iconType, icon_size which)
: PositionPassingMenuItem(submenu, message), : PositionPassingMenuItem(submenu, message),
fDeviceIcon(NULL) fDeviceIcon(NULL)
{ {
BMimeType mime(iconType); BMimeType mime(iconType);
fDeviceIcon = new BBitmap(BRect(0, 0, which - 1, which - 1), B_COLOR_8_BIT); fDeviceIcon = new BBitmap(BRect(0, 0, which - 1, which - 1), B_CMAP8);
if (mime.GetIcon(fDeviceIcon, which) != B_OK) { if (mime.GetIcon(fDeviceIcon, which) != B_OK) {
delete fDeviceIcon; delete fDeviceIcon;
fDeviceIcon = NULL; fDeviceIcon = NULL;
} }
// IconMenuItem is used in synchronously invoked menus, make sure // IconMenuItem is used in synchronously invoked menus, make sure
// we invoke with a timeout // we invoke with a timeout
SetTimeout(kSynchMenuInvokeTimeout); SetTimeout(kSynchMenuInvokeTimeout);
+1 -1
View File
@@ -1327,7 +1327,7 @@ Model::TrackIconSource(icon_size size)
else else
rect.Set(0, 0, B_LARGE_ICON - 1, B_LARGE_ICON - 1); rect.Set(0, 0, B_LARGE_ICON - 1, B_LARGE_ICON - 1);
BBitmap bitmap(rect, B_COLOR_8_BIT); BBitmap bitmap(rect, B_CMAP8);
BModelOpener opener(this); BModelOpener opener(this);
+2 -2
View File
@@ -78,7 +78,7 @@ AddOnePartitionAsMenuItem(Partition *partition, void *castToParams)
AddOneAsMenuItemParams *params = (AddOneAsMenuItemParams *)castToParams; AddOneAsMenuItemParams *params = (AddOneAsMenuItemParams *)castToParams;
BBitmap *icon = new BBitmap(BRect(0, 0, B_MINI_ICON - 1, B_MINI_ICON - 1), BBitmap *icon = new BBitmap(BRect(0, 0, B_MINI_ICON - 1, B_MINI_ICON - 1),
B_COLOR_8_BIT); B_CMAP8);
get_device_icon(partition->GetDevice()->Name(), icon->Bits(), B_MINI_ICON); get_device_icon(partition->GetDevice()->Name(), icon->Bits(), B_MINI_ICON);
@@ -160,7 +160,7 @@ MountMenu::AddDynamicItem(add_state)
while (volumeRoster.GetNextVolume(&volume) == B_OK) { while (volumeRoster.GetNextVolume(&volume) == B_OK) {
if (volume.IsShared()) { if (volume.IsShared()) {
needSeparator = true; needSeparator = true;
BBitmap *icon = new BBitmap(BRect(0, 0, 15, 15), B_COLOR_8_BIT); BBitmap *icon = new BBitmap(BRect(0, 0, 15, 15), B_CMAP8);
fs_info info; fs_info info;
if (fs_stat_dev(volume.Device(), &info) != B_OK) { if (fs_stat_dev(volume.Device(), &info) != B_OK) {
PRINT(("Cannot get mount menu item icon; bad device ID\n")); PRINT(("Cannot get mount menu item icon; bad device ID\n"));
+2 -2
View File
@@ -158,8 +158,8 @@ TTracker::InstallMimeIfNeeded(const char *type, int32 bitsID,
// whole mime type is installed and all attributes are set; nulls can // whole mime type is installed and all attributes are set; nulls can
// be passed for attributes that don't matter; returns true if anything // be passed for attributes that don't matter; returns true if anything
// had to be changed // had to be changed
BBitmap largeIcon(BRect(0, 0, 31, 31), B_COLOR_8_BIT); BBitmap largeIcon(BRect(0, 0, 31, 31), B_CMAP8);
BBitmap miniIcon(BRect(0, 0, 15, 15), B_COLOR_8_BIT); BBitmap miniIcon(BRect(0, 0, 15, 15), B_CMAP8);
char tmp[B_MIME_TYPE_LENGTH]; char tmp[B_MIME_TYPE_LENGTH];
BMimeType mime(type); BMimeType mime(type);
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -75,7 +75,7 @@ const int64 kTBSize = kGBSize * kKBSize;
const int32 kMiniIconSeparator = 3; const int32 kMiniIconSeparator = 3;
const color_space kDefaultIconDepth = B_COLOR_8_BIT; const color_space kDefaultIconDepth = B_CMAP8;
// misc typedefs, constants and structs // misc typedefs, constants and structs