* It's #ifdef HAIKU_TARGET_PLATFORM_HAIKU - not just #if :-)

* Fixed using B_EDIT_ICON_DATA for file types in ref mode, too, as well as having
  the icon data ready for ref mode and MIME type mode.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19317 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2006-11-17 12:58:09 +00:00
parent 280ff9398a
commit 13417161c8
+34 -25
View File
@@ -664,15 +664,16 @@ IconView::MessageReceived(BMessage* message)
} }
break; break;
} }
#if HAIKU_TARGET_PLATFORM_HAIKU
case B_ICON_DATA_EDITED: { #ifdef HAIKU_TARGET_PLATFORM_HAIKU
case B_ICON_DATA_EDITED:
{
const uint8* data; const uint8* data;
ssize_t size; ssize_t size;
if (message->FindData("icon data", B_VECTOR_ICON_TYPE, if (message->FindData("icon data", B_VECTOR_ICON_TYPE,
(const void**)&data, &size) < B_OK) { (const void**)&data, &size) < B_OK)
// required
break; break;
}
_SetIcon(NULL, NULL, data, size); _SetIcon(NULL, NULL, data, size);
break; break;
} }
@@ -1122,36 +1123,44 @@ IconView::GetMimeType(BMimeType& type) const
void void
IconView::_AddOrEditIcon() IconView::_AddOrEditIcon()
{ {
// this works only in Haiku! (the icon editor is built-in in R5's FileType)
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
BMessage message; BMessage message;
if (fHasRef) { if (fHasRef && fType.Type() == NULL) {
// in ref mode, Icon-O-Matic can change the icon directly, and // in ref mode, Icon-O-Matic can change the icon directly, and
// we'll pick it up via node monitoring // we'll pick it up via node monitoring
message.what = B_REFS_RECEIVED; message.what = B_REFS_RECEIVED;
message.AddRef("refs", &fRef); message.AddRef("refs", &fRef);
if (fType.Type() != NULL)
message.AddString("file type", fType.Type());
// } else if (fHasType) {
// // TODO!
} else { } else {
// in static mode, Icon-O-Matic needs to return the buffer it // in static or MIME type mode, Icon-O-Matic needs to return the
// changed once its done // buffer it changed once its done
message.AddMessenger("reply to", BMessenger(this));
#if HAIKU_TARGET_PLATFORM_HAIKU
message.what = B_EDIT_ICON_DATA; message.what = B_EDIT_ICON_DATA;
uint8* data; message.AddMessenger("reply to", BMessenger(this));
size_t size;
if (fIconData->GetData(&data, &size) == B_OK) ::Icon* icon = fIconData;
message.AddData("icon data", B_VECTOR_ICON_TYPE, data, size); if (icon == NULL) {
// TODO: somehow figure out how names of objects in the icon icon = new ::Icon();
// can be preserved. Maybe in a second (optional) attribute if (fHasRef)
// where ever a vector icon attribute is present? icon->SetTo(fRef, fType.Type());
#else else
message.what = 0; icon->SetTo(fType);
// TODO: ? }
#endif
if (icon->HasData()) {
uint8* data;
size_t size;
if (icon->GetData(&data, &size) == B_OK)
message.AddData("icon data", B_VECTOR_ICON_TYPE, data, size);
// TODO: somehow figure out how names of objects in the icon
// can be preserved. Maybe in a second (optional) attribute
// where ever a vector icon attribute is present?
free(data);
}
} }
be_roster->Launch("application/x-vnd.Haiku-icon_o_matic", &message); be_roster->Launch("application/x-vnd.Haiku-icon_o_matic", &message);
#endif
} }