void MailDaemonApp::RemoveDeskbarIcon() { BDeskbar deskbar; if (deskbar.HasItem("mail_daemon")) deskbar.RemoveItem("mail_daemon"); }
/*********************************************************** * RemoveDeskbarIcon ***********************************************************/ void HDaemonApp::RemoveDeskbarIcon() { BDeskbar deskbar; if( deskbar.HasItem( "scooby_daemon" )) deskbar.RemoveItem( "scooby_daemon" ); }
void PowerStatusReplicant::_Quit() { if (fInDeskbar) { BDeskbar deskbar; deskbar.RemoveItem(kDeskbarItemName); } else be_app->PostMessage(B_QUIT_REQUESTED); }
void NetworkStatusView::_Quit() { if (fInDeskbar) { BDeskbar deskbar; deskbar.RemoveItem(kDeskbarItemName); } else be_app->PostMessage(B_QUIT_REQUESTED); }
void WatchView::OnQuitRequested() { // According to the Be Book, we are not allowed to do this // since we're a view that's sitting on the Deskbar's shelf. // But it works just fine for me, and I see no other way to // make a Deskbar replicant quit itself. BDeskbar deskbar; deskbar.RemoveItem(DESKBAR_ITEM_NAME); }
void AudioSettingsView::_HideDeskbarVolumeControl() { BDeskbar deskbar; status_t status = deskbar.RemoveItem("MediaReplicant"); if (status != B_OK) { fprintf(stderr, B_TRANSLATE( "Couldn't remove volume control in Deskbar: %s\n"), strerror(status)); } }
void DeskbarPulseView::Remove() { // Remove ourselves from the deskbar by name BDeskbar *deskbar = new BDeskbar(); status_t err = deskbar->RemoveItem("DeskbarPulseView"); if (err != B_OK) { BString str; snprintf(str.LockBuffer(512), 512, B_TRANSLATE("Removing from Deskbar failed.\n%s"), strerror(err)); str.UnlockBuffer(); BAlert *alert = new BAlert(B_TRANSLATE("Info"), str.String(), B_TRANSLATE("OK")); alert->SetShortcut(0, B_ESCAPE); alert->Go(NULL); } delete deskbar; }
void DeskbarView::AttachedToWindow() { BView::AttachedToWindow(); if (Parent()) SetViewColor(Parent()->ViewColor()); else SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetLowColor(ViewColor()); if (be_roster->IsRunning("application/x-vnd.Be-POST")) { _RefreshMailQuery(); } else { BDeskbar deskbar; deskbar.RemoveItem("mail_daemon"); } }
void DeskbarView::AttachedToWindow() { BView::AttachedToWindow(); if (Parent()) SetViewColor(Parent()->ViewColor()); else SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetLowColor(ViewColor()); if (be_roster->IsRunning(B_MAIL_DAEMON_SIGNATURE)) { _RefreshMailQuery(); } else { BDeskbar deskbar; deskbar.RemoveItem("mail_daemon"); } }
void WorkspacesView::MessageReceived(BMessage* message) { switch (message->what) { case B_ABOUT_REQUESTED: _AboutRequested(); break; case B_MOUSE_WHEEL_CHANGED: { WorkspacesWindow* window = dynamic_cast<WorkspacesWindow*>(Window()); if (window == NULL || !window->SwitchOnWheel()) break; float deltaY = message->FindFloat("be:wheel_delta_y"); if (deltaY > 0.1) activate_workspace(current_workspace() + 1); else if (deltaY < -0.1) activate_workspace(current_workspace() - 1); break; } case kMsgChangeCount: be_roster->Launch(kScreenPrefletSignature); break; case kMsgToggleLiveInDeskbar: { // only actually used from the replicant itself // since HasItem() locks up we just remove directly. BDeskbar deskbar; // we shouldn't do this here actually, but it works for now... deskbar.RemoveItem (kDeskbarItemName); break; } default: BView::MessageReceived(message); break; } }
int main(int argc, char *argv[]) { BDeskbar deskbar; app_info info; new BApplication(APP_SIG); // Remove the old instance if (deskbar.HasItem(VIEW_NAME) == true) deskbar.RemoveItem(VIEW_NAME); if (argc == 1) { if (be_app->GetAppInfo(&info) == B_OK) { status_t result = deskbar.AddItem(&info.ref, NULL); printf("Adding deskbar icon (%s): %s\n", info.ref.name, strerror(result)); } else { printf("Unable to obtain app info\n"); }; }; return B_OK; };
void NetworkWindow::_ShowReplicant(bool show) { if (show) { const char* argv[] = {"--deskbar", NULL}; status_t status = be_roster->Launch(kNetworkStatusSignature, 1, argv); if (status != B_OK) { BString errorMessage; errorMessage.SetToFormat( B_TRANSLATE("Installing NetworkStatus in Deskbar failed: %s"), strerror(status)); BAlert* alert = new BAlert(B_TRANSLATE("launch error"), errorMessage, B_TRANSLATE("Ok")); alert->Go(NULL); } } else { BDeskbar deskbar; deskbar.RemoveItem("NetworkStatus"); } }
void AdvancedOptionsView::MessageReceived(BMessage *message) { switch (message->what) { case kLocalUseDirectWindow: fController->SetUseDirectWindow(fUseDirectWindow->Value() == B_CONTROL_ON); break; case kLocalHideDeskbar: { bool hide = fHideDeskbarIcon->Value() == B_CONTROL_ON; BDeskbar deskbar; if (deskbar.IsRunning()) { if (hide) { // Save the current minimize setting, since we are going to override // it when "hide deskbar" is set fCurrentMinimizeValue = Settings::Current().MinimizeOnRecording(); fMinimizeOnStart->SetValue(B_CONTROL_ON); fMinimizeOnStart->SetEnabled(false); while (deskbar.HasItem(BSC_DESKBAR_VIEW)) deskbar.RemoveItem(BSC_DESKBAR_VIEW); } else if (!deskbar.HasItem(BSC_DESKBAR_VIEW)) { fMinimizeOnStart->SetValue(fCurrentMinimizeValue ? B_CONTROL_ON : B_CONTROL_OFF); fMinimizeOnStart->SetEnabled(true); deskbar.AddItem(new DeskbarControlView(BRect(0, 0, 15, 15), BSC_DESKBAR_VIEW)); } } } // Fall through case kLocalMinimizeOnRecording: Settings::Current().SetMinimizeOnRecording(fMinimizeOnStart->Value() == B_CONTROL_ON); break; default: BView::MessageReceived(message); break; } }
void DeskbarView::MessageReceived(BMessage *message) { // message->PrintToStream(); switch (message->what) { case 'LIVE': { ticks++; Invalidate(); team_info teamInfo; status_t error = get_team_info(team, &teamInfo); if (error != B_OK && id>0) { BDeskbar deskbar; deskbar.RemoveItem(id); } else { BMessage *mes=new BMessage(*message); mes->AddRect("rect",ConvertToScreen(Bounds())); ReplyMessenger.SendMessage(mes); } break; } case B_SET_PROPERTY: { switch( message->FindInt32("what2") ) { case 'TTIP': { const char *tip=NULL; status_t res = message->FindString("tooltip",&tip); if(!tip || res!=B_OK) tip = applicationName.String(); if(strlen(tip)==0) tip = applicationName.String(); if(strlen(tip)!=0) SetToolTip(tip); break; } case 'BITS': { BBitmap *oldicon=icon; icon=NULL; delete oldicon; BMessage bits; message->FindMessage("icon", &bits); icon = new BBitmap(&bits); bits.MakeEmpty(); Invalidate(); break; } case '_ID_': { message->FindInt32("ReplicantID",&id); break; } case 'MSGR': { ssize_t numBytes; const char *name=NULL; message->FindMessenger("messenger", &ReplyMessenger); message->FindData("qtrayobject",B_ANY_TYPE,&traysysobject,&numBytes); if(message->FindString("application_name",&name)==B_OK) applicationName.SetTo(name); break; } } } break; default: BView::MessageReceived(message); break; } }
void ProcessController::MessageReceived(BMessage *message) { team_id team; thread_id thread; BAlert *alert; char question[1000]; switch (message->what) { case 'Puls': Update (); DoDraw (false); break; case 'QtTm': if (message->FindInt32("team", &team) == B_OK) { resume_thread(spawn_thread(thread_quit_application, B_TRANSLATE("Quit application"), B_NORMAL_PRIORITY, (void*) team)); } break; case 'KlTm': if (message->FindInt32("team", &team) == B_OK) { info_pack infos; if (get_team_info(team, &infos.team_info) == B_OK) { get_team_name_and_icon(infos); snprintf(question, sizeof(question), B_TRANSLATE("Do you really want to kill the team \"%s\"?"), infos.team_name); alert = new BAlert(B_TRANSLATE("Please confirm"), question, B_TRANSLATE("Cancel"), B_TRANSLATE("Yes, kill this team!"), NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); alert->SetShortcut(0, B_ESCAPE); if (alert->Go()) kill_team(team); } else { alert = new BAlert(B_TRANSLATE("Info"), B_TRANSLATE("This team is already gone"B_UTF8_ELLIPSIS), B_TRANSLATE("Ok!"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); alert->SetShortcut(0, B_ESCAPE); alert->Go(); } } break; case 'KlTh': if (message->FindInt32("thread", &thread) == B_OK) { thread_info thinfo; if (get_thread_info(thread, &thinfo) == B_OK) { #if DEBUG_THREADS snprintf(question, sizeof(question), B_TRANSLATE("What do you want to do " "with the thread \"%s\"?"), thinfo.name); alert = new BAlert(B_TRANSLATE("Please confirm"), question, B_TRANSLATE("Cancel"), B_TRANSLATE("Debug this thread!"), B_TRANSLATE("Kill this thread!"), B_WIDTH_AS_USUAL, B_STOP_ALERT); #define KILL 2 #else snprintf(question, sizeof(question), B_TRANSLATE("Are you sure you want " "to kill the thread \"%s\"?"), thinfo.name); alert = new BAlert(B_TRANSLATE("Please confirm"), question, B_TRANSLATE("Cancel"), B_TRANSLATE("Kill this thread!"), NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); #define KILL 1 #endif alert->SetShortcut(0, B_ESCAPE); int r = alert->Go(); if (r == KILL) kill_thread(thread); #if DEBUG_THREADS else if (r == 1) { Tdebug_thead_param* param = new Tdebug_thead_param; param->thread = thread; if (thinfo.state == B_THREAD_WAITING) param->sem = thinfo.sem; else param->sem = -1; param->totalTime = thinfo.user_time+thinfo.kernel_time; resume_thread(spawn_thread(thread_debug_thread, B_TRANSLATE("Debug thread"), B_NORMAL_PRIORITY, param)); } #endif } else { alert = new BAlert(B_TRANSLATE("Info"), B_TRANSLATE("This thread is already gone"B_UTF8_ELLIPSIS), B_TRANSLATE("Ok!"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); alert->SetShortcut(0, B_ESCAPE); alert->Go(); } } break; case 'PrTh': if (message->FindInt32("thread", &thread) == B_OK) { long new_priority; if (message->FindInt32("priority", &new_priority) == B_OK) set_thread_priority(thread, new_priority); } break; case 'Trac': launch(kTrackerSig, "/boot/system/Tracker"); break; case 'Dbar': launch(kDeskbarSig, "/boot/system/Deskbar"); break; case 'Term': launch(kTerminalSig, "/boot/system/apps/Terminal"); break; case 'AlDb': { if (!be_roster->IsRunning(kDeskbarSig)) launch(kDeskbarSig, "/boot/system/Deskbar"); BDeskbar deskbar; if (gInDeskbar || deskbar.HasItem (kDeskbarItemName)) deskbar.RemoveItem (kDeskbarItemName); else move_to_deskbar(deskbar); break; } case 'CPU ': { int32 cpu; if (message->FindInt32 ("cpu", &cpu) == B_OK) { bool last = true; for (int p = 0; p < gCPUcount; p++) { if (p != cpu && _kern_cpu_enabled(p)) { last = false; break; } } if (last) { alert = new BAlert(B_TRANSLATE("Info"), B_TRANSLATE("This is the last active processor...\n" "You can't turn it off!"), B_TRANSLATE("That's no Fun!"), NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); alert->SetShortcut(0, B_ESCAPE); alert->Go(); } else _kern_set_cpu_enabled(cpu, !_kern_cpu_enabled(cpu)); } break; } case B_ABOUT_REQUESTED: AboutRequested(); break; default: BView::MessageReceived(message); } }
void WorkspacesWindow::MessageReceived(BMessage *message) { switch (message->what) { case B_SIMPLE_DATA: { // Drop from Tracker entry_ref ref; for (int i = 0; (message->FindRef("refs", i, &ref) == B_OK); i++) be_roster->Launch(&ref); break; } case B_ABOUT_REQUESTED: PostMessage(message, ChildAt(0)); break; case kMsgToggleBorder: { bool enable = false; if (Look() == B_NO_BORDER_WINDOW_LOOK) enable = true; if (enable) if (fSettings->HasTitle()) SetLook(B_TITLED_WINDOW_LOOK); else SetLook(B_MODAL_WINDOW_LOOK); else SetLook(B_NO_BORDER_WINDOW_LOOK); fSettings->SetHasBorder(enable); break; } case kMsgToggleTitle: { bool enable = false; if (Look() == B_MODAL_WINDOW_LOOK || Look() == B_NO_BORDER_WINDOW_LOOK) enable = true; if (enable) SetLook(B_TITLED_WINDOW_LOOK); else SetLook(B_MODAL_WINDOW_LOOK); // No matter what the setting for title, // we must force the border on fSettings->SetHasBorder(true); fSettings->SetHasTitle(enable); break; } case kMsgToggleAutoRaise: SetAutoRaise(!IsAutoRaising()); SetFeel(B_NORMAL_WINDOW_FEEL); break; case kMsgToggleAlwaysOnTop: { bool enable = false; if (Feel() != B_FLOATING_ALL_WINDOW_FEEL) enable = true; if (enable) SetFeel(B_FLOATING_ALL_WINDOW_FEEL); else SetFeel(B_NORMAL_WINDOW_FEEL); fSettings->SetAlwaysOnTop(enable); break; } case kMsgToggleLiveInDeskbar: { BDeskbar deskbar; if (deskbar.HasItem (kDeskbarItemName)) deskbar.RemoveItem (kDeskbarItemName); else { entry_ref ref; be_roster->FindApp(kSignature, &ref); deskbar.AddItem(&ref); } break; } default: BWindow::MessageReceived(message); break; } }
status_t VBoxGuestDeskbarView::RemoveFromDeskbar() { BDeskbar deskbar; return deskbar.RemoveItem(VIEWNAME); }
void NetPulseView::MessageReceived(BMessage* message) { if (message->what == kMsgUpdate) { Update(); Draw(Bounds()); } else if (message->what == kMsgQuit) { SettingsFile settings("Settings", "NetPulse"); settings.AddInt32("Interface", fCookie); settings.AddInt32("InputColor", *((int32 *) &fInputColor)); settings.AddInt32("OutputColor", *((int32 *) &fOutputColor)); settings.AddFloat("DecayRate", fDecayRate); settings.AddInt64("UpdateInterval", fUpdateInterval); settings.Save(); BDeskbar deskbar; deskbar.RemoveItem(Name()); } else if (message->what == kMsgConnect) { if (fCookie != 0) { BNetworkInterface interface(fCookie); interface.SetFlags(interface.Flags() & IFF_UP); } } else if (message->what == kMsgDisconnect) { if (fCookie != 0) { BNetworkInterface interface(fCookie); interface.SetFlags(interface.Flags() & ~IFF_UP); } } else if (message->what >= kMsgChangeInterface + 1 && message->what <= kMsgChangeInterface + 1000) { fCookie = message->what - kMsgChangeInterface; fInputRate = fOutputRate = 0; fMaxInputRate = fMaxOutputRate = 0; BNetworkInterface interface(fCookie); ifreq_stats stats; if (interface.GetStats(stats) == B_OK) { fInputBytes = stats.receive.bytes; fOutputBytes = stats.send.bytes; } Update(); if (fMessenger != NULL) { BMessage message(kMsgChangeInterface); message.AddInt32("interface_index", fCookie); if (fMessenger->SendMessage(&message) != B_OK) fMessenger = NULL; } SettingsFile settings("Settings", "NetPulse"); settings.AddInt32("Interface", fCookie); settings.AddInt32("InputColor", *((int32 *) &fInputColor)); settings.AddInt32("OutputColor", *((int32 *) &fOutputColor)); settings.AddFloat("DecayRate", fDecayRate); settings.AddInt64("UpdateInterval", fUpdateInterval); settings.Save(); } else if (message->what == kMsgStatistics) { if (fMessenger == NULL || !fMessenger->IsValid()) { BRect frame(BScreen().Frame()); BWindow* window = new BWindow( BRect(frame.right - kViewWidth - 20, frame.top + 60, frame.right - 20 - 1, frame.top + 60 + kViewHeight - 1), "Statistics", B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS); BView* view = new NetPulseStatsView("Statistics", fCookie); view->Pulse(); BLayoutBuilder::Group<>(window, B_VERTICAL) .Add(view) .End(); window->SetPulseRate(1000000LL); window->Show(); fMessenger = new BMessenger(view); } } else BView::MessageReceived(message); }
void ProcessController::MessageReceived(BMessage *message) { team_id team; thread_id thread; BAlert *alert; char question[1000]; switch (message->what) { case 'Puls': Update (); DoDraw (false); break; case 'QtTm': if (message->FindInt32("team", &team) == B_OK) { resume_thread(spawn_thread(thread_quit_application, B_TRANSLATE("Quit application"), B_NORMAL_PRIORITY, (void*)(addr_t)team)); } break; case 'KlTm': if (message->FindInt32("team", &team) == B_OK) { info_pack infos; if (get_team_info(team, &infos.team_info) == B_OK) { get_team_name_and_icon(infos); snprintf(question, sizeof(question), B_TRANSLATE("What do you want to do with the team \"%s\"?"), infos.team_name); alert = new BAlert(B_TRANSLATE("Please confirm"), question, B_TRANSLATE("Cancel"), B_TRANSLATE("Debug this team!"), B_TRANSLATE("Kill this team!"), B_WIDTH_AS_USUAL, B_STOP_ALERT); alert->SetShortcut(0, B_ESCAPE); int result = alert->Go(); switch (result) { case 1: _HandleDebugRequest(team, -1); break; case 2: kill_team(team); break; default: break; } } else { alert = new BAlert(B_TRANSLATE("Info"), B_TRANSLATE("This team is already gone" B_UTF8_ELLIPSIS), B_TRANSLATE("Ok!"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); } } break; case 'KlTh': if (message->FindInt32("thread", &thread) == B_OK) { thread_info thinfo; if (get_thread_info(thread, &thinfo) == B_OK) { #if DEBUG_THREADS snprintf(question, sizeof(question), B_TRANSLATE("What do you want to do " "with the thread \"%s\"?"), thinfo.name); alert = new BAlert(B_TRANSLATE("Please confirm"), question, B_TRANSLATE("Cancel"), B_TRANSLATE("Debug this thread!"), B_TRANSLATE("Kill this thread!"), B_WIDTH_AS_USUAL, B_STOP_ALERT); alert->SetShortcut(0, B_ESCAPE); #define KILL 2 #else snprintf(question, sizeof(question), B_TRANSLATE("Are you sure you want " "to kill the thread \"%s\"?"), thinfo.name); alert = new BAlert(B_TRANSLATE("Please confirm"), question, B_TRANSLATE("Cancel"), B_TRANSLATE("Kill this thread!"), NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); alert->SetShortcut(0, B_ESCAPE); #define KILL 1 #endif alert->SetShortcut(0, B_ESCAPE); int r = alert->Go(); if (r == KILL) kill_thread(thread); #if DEBUG_THREADS else if (r == 1) _HandleDebugRequest(thinfo.team, thinfo.thread); #endif } else { alert = new BAlert(B_TRANSLATE("Info"), B_TRANSLATE("This thread is already gone" B_UTF8_ELLIPSIS), B_TRANSLATE("Ok!"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); } } break; case 'PrTh': if (message->FindInt32("thread", &thread) == B_OK) { int32 new_priority; if (message->FindInt32("priority", &new_priority) == B_OK) set_thread_priority(thread, new_priority); } break; case 'Trac': { BPath trackerPath; if (find_directory(B_SYSTEM_DIRECTORY, &trackerPath) == B_OK && trackerPath.Append("Tracker") == B_OK) { launch(kTrackerSig, trackerPath.Path()); } break; } case 'Dbar': { BPath deskbarPath; if (find_directory(B_SYSTEM_DIRECTORY, &deskbarPath) == B_OK && deskbarPath.Append("Deskbar") == B_OK) { launch(kDeskbarSig, deskbarPath.Path()); } break; } case 'Term': { BPath terminalPath; if (find_directory(B_SYSTEM_APPS_DIRECTORY, &terminalPath) == B_OK && terminalPath.Append("Terminal") == B_OK) { launch(kTerminalSig, terminalPath.Path()); } break; } case 'AlDb': { if (!be_roster->IsRunning(kDeskbarSig)) { BPath deskbarPath; if (find_directory(B_SYSTEM_DIRECTORY, &deskbarPath) == B_OK && deskbarPath.Append("Deskbar") == B_OK) { launch(kDeskbarSig, deskbarPath.Path()); } } BDeskbar deskbar; if (gInDeskbar || deskbar.HasItem (kDeskbarItemName)) deskbar.RemoveItem (kDeskbarItemName); else move_to_deskbar(deskbar); break; } case 'CPU ': { uint32 cpu; if (message->FindInt32("cpu", (int32*)&cpu) == B_OK) { bool last = true; for (unsigned int p = 0; p < gCPUcount; p++) { if (p != cpu && _kern_cpu_enabled(p)) { last = false; break; } } if (last) { alert = new BAlert(B_TRANSLATE("Info"), B_TRANSLATE("This is the last active processor...\n" "You can't turn it off!"), B_TRANSLATE("That's no Fun!"), NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); } else _kern_set_cpu_enabled(cpu, !_kern_cpu_enabled(cpu)); } break; } case 'Schd': { int32 mode; if (message->FindInt32 ("mode", &mode) == B_OK) set_scheduler_mode(mode); break; } case B_ABOUT_REQUESTED: AboutRequested(); break; default: BView::MessageReceived(message); } }
void BeGadu::DelDeskbarIcon() { DEBUG_TRACE( "BeGadu::DelDeskbarIcon()\n" ); BDeskbar deskbar; if( deskbar.HasItem( "BGDeskbar" ) ) deskbar.RemoveItem( "BGDeskbar" ); }
void RemoveIcon(int32 id) { BDeskbar deskbar; deskbar.RemoveItem(id); }
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; } } else { printf("desklink: cannot find '%s'\n", argv[i]); return 1; } err = deskbar.AddItem(&ref); if (err != B_OK) { err = deskbar.AddItem(new DeskButton(BRect(0, 0, 15, 15), &ref, ref.name, titleList, actionList)); if (err != B_OK) { printf("desklink: Deskbar refuses link to '%s': %s\n", argv[i], strerror(err)); return 1; } } titleList.MakeEmpty(); actionList.MakeEmpty(); } if (!atLeastOnePath) { printf( "usage: desklink { [ --list|--remove|[cmd=title:action ... ] [ path|signature ] } ...\n" "--add-volume: install volume control into Deskbar.\n" "--volume-control: show window with global volume control.\n" "--list: list all Deskbar addons.\n" "--remove: remove all desklink addons.\n" "--remove=name: remove all 'name' addons.\n"); return 1; } return 0; }