Application icons and supported type icons are now also saved.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19292 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2006-11-15 14:26:10 +00:00
parent 6e78183a77
commit f483286d59
1 changed files with 17 additions and 18 deletions

View File

@ -52,7 +52,7 @@ class SupportedTypeItem : public BStringItem {
~SupportedTypeItem(); ~SupportedTypeItem();
const char* Type() const { return fType.String(); } const char* Type() const { return fType.String(); }
::Icon* Icon() { return fIcon; } ::Icon& Icon() { return fIcon; }
void SetIcon(::Icon* icon); void SetIcon(::Icon* icon);
void SetIcon(entry_ref& ref, const char* type); void SetIcon(entry_ref& ref, const char* type);
@ -60,7 +60,7 @@ class SupportedTypeItem : public BStringItem {
private: private:
BString fType; BString fType;
::Icon* fIcon; ::Icon fIcon;
}; };
class SupportedTypeListView : public DropTargetListView { class SupportedTypeListView : public DropTargetListView {
@ -78,8 +78,7 @@ class SupportedTypeListView : public DropTargetListView {
SupportedTypeItem::SupportedTypeItem(const char* type) SupportedTypeItem::SupportedTypeItem(const char* type)
: BStringItem(type), : BStringItem(type),
fType(type), fType(type)
fIcon(NULL)
{ {
BMimeType mimeType(type); BMimeType mimeType(type);
@ -97,21 +96,17 @@ SupportedTypeItem::~SupportedTypeItem()
void void
SupportedTypeItem::SetIcon(::Icon* icon) SupportedTypeItem::SetIcon(::Icon* icon)
{ {
delete fIcon;
if (icon != NULL) if (icon != NULL)
fIcon = new ::Icon(*icon); fIcon = *icon;
else else
fIcon = NULL; fIcon.Unset();
} }
void void
SupportedTypeItem::SetIcon(entry_ref& ref, const char* type) SupportedTypeItem::SetIcon(entry_ref& ref, const char* type)
{ {
if (fIcon == NULL) fIcon.SetTo(ref, type);
fIcon = new ::Icon;
fIcon->SetTo(ref, type);
} }
@ -706,8 +701,6 @@ ApplicationTypeWindow::_Save()
for (int32 i = 0; i < fTypeListView->CountItems(); i++) { for (int32 i = 0; i < fTypeListView->CountItems(); i++) {
SupportedTypeItem* item = dynamic_cast<SupportedTypeItem*>( SupportedTypeItem* item = dynamic_cast<SupportedTypeItem*>(
fTypeListView->ItemAt(i)); fTypeListView->ItemAt(i));
if (item == NULL)
continue;
supportedTypes.AddString("types", item->Type()); supportedTypes.AddString("types", item->Type());
} }
@ -730,13 +723,19 @@ ApplicationTypeWindow::_Save()
status = info.SetAppFlags(flags); status = info.SetAppFlags(flags);
if (status == B_OK) if (status == B_OK)
status = info.SetVersionInfo(&versionInfo, B_APP_VERSION_KIND); status = info.SetVersionInfo(&versionInfo, B_APP_VERSION_KIND);
if (status == B_OK)
fIcon.CopyTo(info, NULL, true);
// TODO: icon & supported types icons // supported types and their icons
// if (status == B_OK)
// status = info.SetIcon(&icon);
if (status == B_OK) if (status == B_OK)
status = info.SetSupportedTypes(&supportedTypes); status = info.SetSupportedTypes(&supportedTypes);
for (int32 i = 0; i < fTypeListView->CountItems(); i++) {
SupportedTypeItem* item = dynamic_cast<SupportedTypeItem*>(
fTypeListView->ItemAt(i));
item->Icon().CopyTo(info, item->Type(), true);
}
} }
@ -766,7 +765,7 @@ ApplicationTypeWindow::MessageReceived(BMessage* message)
if (message->FindInt32("index", &index) == B_OK) { if (message->FindInt32("index", &index) == B_OK) {
SupportedTypeItem* item = (SupportedTypeItem*)fTypeListView->ItemAt(index); SupportedTypeItem* item = (SupportedTypeItem*)fTypeListView->ItemAt(index);
fTypeIconView->SetTo(item != NULL ? item->Icon() : NULL); fTypeIconView->SetTo(item != NULL ? &item->Icon() : NULL);
fTypeIconView->SetEnabled(item != NULL); fTypeIconView->SetEnabled(item != NULL);
fRemoveTypeButton->SetEnabled(item != NULL); fRemoveTypeButton->SetEnabled(item != NULL);
} }