More readable use of the BDeskbar API when removing desklink replicants. Clean ups.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21553 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -42,7 +42,7 @@
|
|||||||
#define SET_VOLUME_WHICH 'svwh'
|
#define SET_VOLUME_WHICH 'svwh'
|
||||||
|
|
||||||
#define VOLUME_CTL_NAME "MediaReplicant"
|
#define VOLUME_CTL_NAME "MediaReplicant"
|
||||||
/* R5 name needed, Media prefs manel removes by name */
|
// R5 name needed, Media prefs manel removes by name
|
||||||
|
|
||||||
#define SETTINGS_FILE "x-vnd.Haiku-desklink"
|
#define SETTINGS_FILE "x-vnd.Haiku-desklink"
|
||||||
|
|
||||||
@@ -82,9 +82,9 @@ private:
|
|||||||
BBitmap* fSegments;
|
BBitmap* fSegments;
|
||||||
VolumeSlider* fVolumeSlider;
|
VolumeSlider* fVolumeSlider;
|
||||||
bool fDontBeep;
|
bool fDontBeep;
|
||||||
/* don't beep on volume change */
|
// don't beep on volume change
|
||||||
int32 fVolumeWhich;
|
int32 fVolumeWhich;
|
||||||
/* which volume parameter to act on (Mixer/Phys.Output) */
|
// which volume parameter to act on (Mixer/Phys.Output)
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -312,7 +312,7 @@ MediaReplicant::MouseDown(BPoint point)
|
|||||||
void
|
void
|
||||||
MediaReplicant::MouseUp(BPoint point)
|
MediaReplicant::MouseUp(BPoint point)
|
||||||
{
|
{
|
||||||
/* don't Quit() ! thanks for FFM users */
|
// don't Quit() ! thanks for FFM users
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -363,40 +363,44 @@ main(int, char **argv)
|
|||||||
bool atLeastOnePath = false;
|
bool atLeastOnePath = false;
|
||||||
BList titleList;
|
BList titleList;
|
||||||
BList actionList;
|
BList actionList;
|
||||||
|
BDeskbar deskbar;
|
||||||
|
status_t err = B_OK;
|
||||||
|
|
||||||
for (int32 i = 1; argv[i]!=NULL; i++) {
|
for (int32 i = 1; argv[i]!=NULL; i++) {
|
||||||
if (strcmp(argv[i], "--help") == 0)
|
if (strcmp(argv[i], "--help") == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (strcmp(argv[i], "--list") == 0) {
|
if (strcmp(argv[i], "--list") == 0) {
|
||||||
BDeskbar db;
|
|
||||||
int32 i, found = 0, count;
|
int32 i, found = 0, count;
|
||||||
count = db.CountItems();
|
count = deskbar.CountItems();
|
||||||
printf("Deskbar items:\n");
|
printf("Deskbar items:\n");
|
||||||
/* the API is doomed, so don't try to enum for too long */
|
// the API is doomed, so don't try to enum for too long
|
||||||
for (i = 0; (found < count) && (i >= 0) && (i < 5000); i++) {
|
for (i = 0; (found < count) && (i >= 0) && (i < 5000); i++) {
|
||||||
const char scratch[2] = ""; /* BDeskbar is buggy */
|
const char scratch[2] = ""; // BDeskbar is buggy
|
||||||
const char *name=scratch;
|
const char *name=scratch;
|
||||||
if (db.GetItemInfo(i, &name) >= B_OK) {
|
if (deskbar.GetItemInfo(i, &name) >= B_OK) {
|
||||||
found++;
|
found++;
|
||||||
printf("Item %ld: '%s'\n", i, name);
|
printf("Item %ld: '%s'\n", i, name);
|
||||||
free((void *)name); /* INTENDED */
|
free((void *)name); // INTENDED
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(argv[i], "--remove") == 0) {
|
if (strcmp(argv[i], "--remove") == 0) {
|
||||||
BDeskbar db;
|
|
||||||
int32 found = 0;
|
int32 found = 0;
|
||||||
uint32 count = db.CountItems();
|
int32 found_id;
|
||||||
/* BDeskbar is definitely doomed ! */
|
while (deskbar.GetItemInfo("DeskButton", &found_id) == B_OK) {
|
||||||
while ((db.RemoveItem("DeskButton") == B_OK) && (db.CountItems() < count)) {
|
err = deskbar.RemoveItem(found_id);
|
||||||
count = db.CountItems();
|
if (err != B_OK) {
|
||||||
|
printf("desklink: Error removing replicant id %ld: %s\n",
|
||||||
|
found_id, strerror(err));
|
||||||
|
break;
|
||||||
|
}
|
||||||
found++;
|
found++;
|
||||||
}
|
}
|
||||||
printf("removed %ld items.\n", found);
|
printf("Removed %ld items.\n", found);
|
||||||
return 0;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strncmp(argv[i], "cmd=", 4) == 0) {
|
if (strncmp(argv[i], "cmd=", 4) == 0) {
|
||||||
@@ -425,7 +429,7 @@ main(int, char **argv)
|
|||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
entry.GetRef(&ref);
|
entry.GetRef(&ref);
|
||||||
|
|
||||||
status_t err = BDeskbar().AddItem(new DeskButton(BRect(0, 0, 15, 15),
|
err = deskbar.AddItem(new DeskButton(BRect(0, 0, 15, 15),
|
||||||
&ref, "DeskButton", titleList, actionList));
|
&ref, "DeskButton", titleList, actionList));
|
||||||
if (err != B_OK) {
|
if (err != B_OK) {
|
||||||
printf("desklink: Deskbar refuses link to '%s': %s\n", argv[i], strerror(err));
|
printf("desklink: Deskbar refuses link to '%s': %s\n", argv[i], strerror(err));
|
||||||
@@ -436,7 +440,6 @@ main(int, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!atLeastOnePath) {
|
if (!atLeastOnePath) {
|
||||||
// print a simple usage string
|
|
||||||
printf( "usage: desklink { [ --list|--remove|[cmd=title:action ... ] path ] } ...\n"
|
printf( "usage: desklink { [ --list|--remove|[cmd=title:action ... ] path ] } ...\n"
|
||||||
"--list: list all Deskbar addons.\n"
|
"--list: list all Deskbar addons.\n"
|
||||||
"--remove: delete all desklink addons.\n");
|
"--remove: delete all desklink addons.\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user