当前位置: 首页>>代码示例>>C++>>正文


C++ BDeskbar::CountItems方法代码示例

本文整理汇总了C++中BDeskbar::CountItems方法的典型用法代码示例。如果您正苦于以下问题:C++ BDeskbar::CountItems方法的具体用法?C++ BDeskbar::CountItems怎么用?C++ BDeskbar::CountItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BDeskbar的用法示例。


在下文中一共展示了BDeskbar::CountItems方法的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;
			}
//.........这里部分代码省略.........
开发者ID:DonCN,项目名称:haiku,代码行数:101,代码来源:desklink.cpp


注:本文中的BDeskbar::CountItems方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。