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 MuscleAdmin::ReadyToRun() { bool isInstalled = false; bool isDeskbarRunning = true; { // if the Deskbar is not alive at this point, it might be after having // acknowledged the requester below BDeskbar deskbar; isDeskbarRunning = deskbar.IsRunning(); isInstalled = deskbar.HasItem(kDeskbarItemName); } if (isDeskbarRunning && !isInstalled) { BAlert* alert = new BAlert("", "You can run MuscleAdmin in a window or install it in the Deskbar." , "Run in window", "Install in Deskbar", NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); if (alert->Go()) { image_info info; entry_ref ref; if (our_image(info) == B_OK && get_ref_for_path(info.name, &ref) == B_OK) { BDeskbar deskbar; deskbar.AddItem(&ref); } Quit(); return; } } BWindow* window = new MuscleAdminWindow(); window->Show(); }
void NetworkStatus::ReadyToRun() { if (fQuitImmediately) { // we printed the help message into the Terminal and // should just quit Quit(); return; } bool isDeskbarRunning = true; bool isInstalled = false; { // if the Deskbar is not alive at this point, it might be after having // acknowledged the requester below BDeskbar deskbar; #ifdef HAIKU_TARGET_PLATFORM_HAIKU isDeskbarRunning = deskbar.IsRunning(); #endif isInstalled = deskbar.HasItem(kDeskbarItemName); } if (fAutoInstallInDeskbar) { if (isInstalled) { Quit(); return; } #ifdef HAIKU_TARGET_PLATFORM_HAIKU // wait up to 10 seconds for Deskbar to become available // in case it is not running (yet?) int32 tries = 10; while (!isDeskbarRunning && --tries) { BDeskbar deskbar; if (deskbar.IsRunning()) { isDeskbarRunning = true; break; } snooze(1000000); } #endif if (!isDeskbarRunning) { const char* str = B_TRANSLATE("Deskbar is not running, giving up."); puts(str); Quit(); return; } _InstallReplicantInDeskbar(); return; } if (isDeskbarRunning && !isInstalled) { BAlert* alert = new BAlert("", B_TRANSLATE("You can run NetworkStatus " "in a window or install it in the Deskbar."), B_TRANSLATE("Run in window"), B_TRANSLATE("Install in Deskbar"), NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); if (alert->Go() == 1) { _InstallReplicantInDeskbar(); return; } } BWindow* window = new NetworkStatusWindow(); window->Show(); }