本文整理汇总了C++中BMimeType::GetSupportingApps方法的典型用法代码示例。如果您正苦于以下问题:C++ BMimeType::GetSupportingApps方法的具体用法?C++ BMimeType::GetSupportingApps怎么用?C++ BMimeType::GetSupportingApps使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BMimeType
的用法示例。
在下文中一共展示了BMimeType::GetSupportingApps方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// Fetches a \c BMessage containing a list of MIME signatures of
// applications that are able to handle files of any type.
status_t
BMimeType::GetWildcardApps(BMessage* wild_ones)
{
BMimeType mime;
status_t err = mime.SetTo("application/octet-stream");
if (err == B_OK)
err = mime.GetSupportingApps(wild_ones);
return err;
}
示例2: BMenu
BMenu*
PieView::_BuildOpenWithMenu(FileInfo* info)
{
vector<AppMenuItem*> appList;
// Get preferred app.
BMimeType* type = info->Type();
char appSignature[B_MIME_TYPE_LENGTH];
if (type->GetPreferredApp(appSignature) == B_OK)
_AddAppToList(appList, appSignature, 1);
// Get apps that handle this subtype and supertype.
BMessage msg;
if (type->GetSupportingApps(&msg) == B_OK) {
int32 subs, supers, i;
msg.FindInt32("be:sub", &subs);
msg.FindInt32("be:super", &supers);
const char* appSig;
for (i = 0; i < subs; i++) {
msg.FindString("applications", i, &appSig);
_AddAppToList(appList, appSig, 2);
}
int hold = i;
for (i = 0; i < supers; i++) {
msg.FindString("applications", i + hold, &appSig);
_AddAppToList(appList, appSig, 3);
}
}
// Get apps that handle any type.
if (BMimeType::GetWildcardApps(&msg) == B_OK) {
const char* appSig;
for (int32 i = 0; true; i++) {
if (msg.FindString("applications", i, &appSig) == B_OK)
_AddAppToList(appList, appSig, 4);
else
break;
}
}
delete type;
BMenu* openWith = new BMenu(B_TRANSLATE("Open With"));
if (appList.size() == 0) {
BMenuItem* item = new BMenuItem(B_TRANSLATE("no supporting apps"),
NULL);
item->SetEnabled(false);
openWith->AddItem(item);
} else {
vector<AppMenuItem*>::iterator i = appList.begin();
int category = (*i)->Category();
while (i != appList.end()) {
if (category != (*i)->Category()) {
openWith->AddSeparatorItem();
category = (*i)->Category();
}
openWith->AddItem(*i);
i++;
}
}
return openWith;
}