desklink: --list fixes

* Don't assume that ids to be contiguous (and to start at 0).
 * Use the executable's name as the replicant view name (to ease its identification and removal)

Fixes ticket #5354.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35402 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Philippe Saint-Pierre 2010-02-04 01:37:21 +00:00
parent ab2540c49c
commit 686c893326

View File

@ -48,15 +48,18 @@ main(int, char **argv)
if (strcmp(argv[i], "--list") == 0) {
int32 count = deskbar.CountItems();
int32 found = 0;
int32 j = 0;
printf("Deskbar items:\n");
for (int32 i = 0; i < count; i++) {
while (found < count) {
const char *name = NULL;
if (deskbar.GetItemInfo(i, &name) == B_OK) {
printf("Item %ld: '%s'\n", i, name);
if (deskbar.GetItemInfo(j, &name) == B_OK) {
printf("Item %ld: '%s'\n", j, name);
free((void *)name);
found++;
}
j++;
}
return 0;
}
@ -137,7 +140,7 @@ main(int, char **argv)
err = deskbar.AddItem(&ref);
if (err != B_OK) {
err = deskbar.AddItem(new DeskButton(BRect(0, 0, 15, 15),
&ref, "DeskButton", titleList, actionList));
&ref, ref.name, titleList, actionList));
if (err != B_OK) {
printf("desklink: Deskbar refuses link to '%s': %s\n", argv[i], strerror(err));
return 1;