本文整理汇总了C++中BDeskbar::GetItemInfo方法的典型用法代码示例。如果您正苦于以下问题:C++ BDeskbar::GetItemInfo方法的具体用法?C++ BDeskbar::GetItemInfo怎么用?C++ BDeskbar::GetItemInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BDeskbar
的用法示例。
在下文中一共展示了BDeskbar::GetItemInfo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: app
int
main(int, char **argv)
{
BApplication app(kAppSignature);
bool atLeastOnePath = false;
BList titleList;
BList actionList;
BDeskbar deskbar;
status_t err = B_OK;
for (int32 i = 1; argv[i]!=NULL; i++) {
if (strcmp(argv[i], "--help") == 0)
break;
if (strcmp(argv[i], "--list") == 0) {
int32 count = deskbar.CountItems();
int32 found = 0;
int32 j = 0;
printf("Deskbar items:\n");
while (found < count) {
const char *name = NULL;
if (deskbar.GetItemInfo(j, &name) == B_OK) {
printf("Item %ld: '%s'\n", j, name);
free((void *)name);
found++;
}
j++;
}
return 0;
}
if (strcmp(argv[i], "--add-volume") == 0) {
entry_ref ref;
if (get_ref_for_path(argv[0], &ref) == B_OK) {
deskbar.AddItem(&ref);
}
return 0;
}
if (strcmp(argv[i], "--volume-control") == 0) {
BWindow* window = new VolumeWindow(BRect(200, 150, 400, 200));
window->Show();
wait_for_thread(window->Thread(), NULL);
return 0;
}
if (strncmp(argv[i], "--remove", 8) == 0) {
BString replicant = "DeskButton";
if (strncmp(argv[i] + 8, "=", 1) == 0) {
if (strlen(argv[i] + 9) > 0) {
replicant = argv[i] + 9;
} else {
printf("desklink: Missing replicant name.\n");
return 1;
}
}
int32 found = 0;
int32 found_id;
while (deskbar.GetItemInfo(replicant.String(), &found_id) == B_OK) {
err = deskbar.RemoveItem(found_id);
if (err != B_OK) {
printf("desklink: Error removing replicant id %ld: %s\n",
found_id, strerror(err));
break;
}
found++;
}
printf("Removed %ld items.\n", found);
return err;
}
if (strncmp(argv[i], "cmd=", 4) == 0) {
BString *title = new BString(argv[i] + 4);
int32 index = title->FindFirst(':');
if (index <= 0) {
printf("desklink: usage: cmd=title:action\n");
} else {
title->Truncate(index);
BString *action = new BString(argv[i] + 4);
action->Remove(0, index+1);
titleList.AddItem(title);
actionList.AddItem(action);
}
continue;
}
atLeastOnePath = true;
BEntry entry(argv[i], true);
entry_ref ref;
if (entry.Exists()) {
entry.GetRef(&ref);
} else if (BMimeType::IsValid(argv[i])) {
if (be_roster->FindApp(argv[i], &ref) != B_OK) {
printf("desklink: cannot find '%s'\n", argv[i]);
return 1;
}
//.........这里部分代码省略.........