From c1284ddf07ec00770f74419b55c284d7b44dd30e Mon Sep 17 00:00:00 2001
From: Jessica Hamilton <jessica.l.hamilton@gmail.com>
Date: Sat, 4 May 2013 09:11:04 +1200
Subject: [PATCH] Tracker: Find Panel - fix handling of duplicate mimetype
descriptions.
Currently, Haiku has two mimetypes for MIDI files, which causes the
logic for clearing the currently marked item to sometimes fail. Instead,
when two mimetypes have the same description, the subtype is added to
the label in parentheses as is done in the FileTypes preflet.
---
src/kits/tracker/FindPanel.cpp | 30 ++++++++++++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/src/kits/tracker/FindPanel.cpp b/src/kits/tracker/FindPanel.cpp
index f42c7dd..709308f 100644
a
|
b
|
FindPanel::SetCurrentMimeType(const char* label)
|
1723 | 1723 | } |
1724 | 1724 | |
1725 | 1725 | return found ? B_OK : B_ENTRY_NOT_FOUND; |
| 1726 | } |
| 1727 | |
| 1728 | |
| 1729 | static |
| 1730 | void AddSubtype(BString& text, const BMimeType& type) |
| 1731 | { |
| 1732 | text.Append(" ("); |
| 1733 | text.Append(strchr(type.Type(), '/') + 1); |
| 1734 | // omit the slash |
| 1735 | text.Append(")"); |
1726 | 1736 | } |
1727 | 1737 | |
1728 | 1738 | |
… |
… |
FindPanel::AddOneMimeTypeToMenu(const ShortMimeInfo* info, void* castToMenu)
|
1742 | 1752 | BMessage* msg = new BMessage(kMIMETypeItem); |
1743 | 1753 | msg->AddString("mimetype", info->InternalName()); |
1744 | 1754 | |
1745 | | superItem->Submenu()->AddItem(new IconMenuItem( |
1746 | | info->ShortDescription(), msg, info->InternalName(), |
| 1755 | // check to ensure previous item's name differs |
| 1756 | BMenu* menu = superItem->Submenu(); |
| 1757 | BMenuItem* previous = menu->ItemAt(menu->CountItems() - 1); |
| 1758 | BString text = info->ShortDescription(); |
| 1759 | if (previous != NULL && strcasecmp(previous->Label(), |
| 1760 | info->ShortDescription()) == 0) { |
| 1761 | AddSubtype(text, type); |
| 1762 | |
| 1763 | // update the previous item as well |
| 1764 | BMimeType type(previous->Message()->GetString("mimetype", |
| 1765 | NULL)); |
| 1766 | BString label = ShortMimeInfo(type).ShortDescription(); |
| 1767 | AddSubtype(label, type); |
| 1768 | previous->SetLabel(label); |
| 1769 | } |
| 1770 | |
| 1771 | menu->AddItem(new IconMenuItem( |
| 1772 | text, msg, info->InternalName(), |
1747 | 1773 | B_MINI_ICON)); |
1748 | 1774 | } |
1749 | 1775 | |