/*********************************************************** * RemoveDeskbarIcon ***********************************************************/ void HDaemonApp::RemoveDeskbarIcon() { BDeskbar deskbar; if( deskbar.HasItem( "scooby_daemon" )) deskbar.RemoveItem( "scooby_daemon" ); }
void MailDaemonApp::RemoveDeskbarIcon() { BDeskbar deskbar; if (deskbar.HasItem("mail_daemon")) deskbar.RemoveItem("mail_daemon"); }
bool LoadInDeskbar() { PulseApp *pulseapp = (PulseApp *)be_app; BDeskbar *deskbar = new BDeskbar(); // Don't allow two copies in the Deskbar at once if (deskbar->HasItem("DeskbarPulseView")) { delete deskbar; return false; } // Must be 16 pixels high, the width is retrieved from the Prefs class int width = pulseapp->prefs->deskbar_icon_width; int min_width = GetMinimumViewWidth(); if (width < min_width) { pulseapp->prefs->deskbar_icon_width = min_width; width = min_width; } BRect rect(0, 0, width - 1, 15); DeskbarPulseView *replicant = new DeskbarPulseView(rect); status_t err = deskbar->AddItem(replicant); delete replicant; delete deskbar; if (err != B_OK) { BAlert *alert = new BAlert(NULL, strerror(err), "OK"); alert->Go(NULL); return false; } return true; }
void ProjectWindow::ShowErrorWindow(ErrorList *list) { if (fErrorWindow && list) { BMessage msg; list->Flatten(msg); msg.what = M_BUILD_WARNINGS; fErrorWindow->PostMessage(&msg); } else { BRect screen(BScreen().Frame()); BRect r(screen); r.left = r.right / 4.0; r.right *= .75; r.top = r.bottom - 200; BDeskbar deskbar; if (deskbar.Location() == B_DESKBAR_BOTTOM) r.OffsetBy(0,-deskbar.Frame().Height()); fErrorWindow = new ErrorWindow(r,this,list); fErrorWindow->Show(); } fStatusBar->SetText(""); }
void AsciiWindow::Zoom(BPoint, float, float) { if (!fIsZoomed) { fLastFrame = Frame(); BDeskbar deskbar; BRect deskbarFrame = deskbar.Frame(); BRect screenFrame = (BScreen(this)).Frame(); switch (deskbar.Location()) { case B_DESKBAR_TOP: MoveTo(std::max(fLastFrame.left, screenFrame.left + 4.0f), deskbarFrame.bottom + 28.0f); ResizeTo(std::max(fLastFrame.Width(), kWindowWidth), screenFrame.bottom - deskbarFrame.Height() - 33.0f); break; case B_DESKBAR_BOTTOM: MoveTo(std::max(fLastFrame.left, screenFrame.left + 4.0f), 26.0f); ResizeTo(std::max(fLastFrame.Width(), kWindowWidth), deskbarFrame.top - 33.0f); break; case B_DESKBAR_LEFT_TOP: case B_DESKBAR_LEFT_BOTTOM: MoveTo(std::max(fLastFrame.left, deskbarFrame.right + 7.0f), 26.0f); ResizeTo(std::max(fLastFrame.Width(), kWindowWidth), screenFrame.bottom - 30.0f); break; case B_DESKBAR_RIGHT_TOP: case B_DESKBAR_RIGHT_BOTTOM: ResizeTo(std::max(fLastFrame.Width(), kWindowWidth), screenFrame.bottom - 30.0f); if (fLastFrame.right + 7.0f > deskbarFrame.left) { MoveTo(fLastFrame.left - 7.0f - (fLastFrame.right - deskbarFrame.left), 26.0f); } else { MoveTo(std::max(fLastFrame.left, screenFrame.left + 4.0f), 26.0f); } break; default: MoveTo(std::max(fLastFrame.left, screenFrame.left + 4.0f), 26.0f); ResizeTo(std::max(fLastFrame.Width(), kWindowWidth), screenFrame.bottom - 30.0f); break; } } else { MoveTo(fLastFrame.LeftTop()); ResizeTo(fLastFrame.Width(), fLastFrame.Height()); } fIsZoomed = !fIsZoomed; }
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 NotificationWindow::SetPosition() { Layout(true); BRect bounds = DecoratorFrame(); float width = Bounds().Width() + 1; float height = Bounds().Height() + 1; float leftOffset = Frame().left - bounds.left; float topOffset = Frame().top - bounds.top + 1; float rightOffset = bounds.right - Frame().right; float bottomOffset = bounds.bottom - Frame().bottom; // Size of the borders around the window float x = Frame().left, y = Frame().top; // If we can't guess, don't move... BDeskbar deskbar; BRect frame = deskbar.Frame(); switch (deskbar.Location()) { case B_DESKBAR_TOP: // Put it just under, top right corner y = frame.bottom + topOffset; x = frame.right - width + rightOffset; break; case B_DESKBAR_BOTTOM: // Put it just above, lower left corner y = frame.top - height - bottomOffset; x = frame.right - width + rightOffset; break; case B_DESKBAR_RIGHT_TOP: x = frame.left - width - rightOffset; y = frame.top - topOffset; break; case B_DESKBAR_LEFT_TOP: x = frame.right + leftOffset; y = frame.top - topOffset; break; case B_DESKBAR_RIGHT_BOTTOM: y = frame.bottom - height + bottomOffset; x = frame.left - width - rightOffset; break; case B_DESKBAR_LEFT_BOTTOM: y = frame.bottom - height + bottomOffset; x = frame.right + leftOffset; break; default: break; } MoveTo(x, y); }
/*********************************************************** * InstallDeskbarIcon ***********************************************************/ void HDaemonApp::InstallDeskbarIcon() { BDeskbar deskbar; if(deskbar.HasItem( "scooby_daemon" ) == false) { BRoster roster; entry_ref ref; roster.FindApp( APP_SIG , &ref); int32 id; deskbar.AddItem(&ref, &id); } }
void NetworkStatus::_InstallReplicantInDeskbar() { 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(); }
int32 LoadIcon(team_id tid) { BDeskbar deskbar; int32 id=-1; deskbar.AddItem(new DeskbarView(tid),&id); if(id>0) { BMessage msg('_ID_'); msg.AddInt32("ReplicantID",id); SendMessageToReplicant(id,&msg); } return id; }
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 AudioSettingsView::_ShowDeskbarVolumeControl() { BDeskbar deskbar; BEntry entry("/bin/desklink", true); int32 id; entry_ref ref; status_t status = entry.GetRef(&ref); if (status == B_OK) status = deskbar.AddItem(&ref, &id); if (status != B_OK) { fprintf(stderr, B_TRANSLATE( "Couldn't add volume control in Deskbar: %s\n"), strerror(status)); } }
void move_to_deskbar(BDeskbar& deskbar) { entry_ref ref; find_self(ref); deskbar.AddItem(&ref); }
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 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 BeGadu::AddDeskbarIcon() { DEBUG_TRACE( "BeGadu::AddDeskbarIcon()\n" ); BDeskbar deskbar; if( !deskbar.HasItem( "BGDeskbar" ) ) { BRoster roster; entry_ref ref; status_t status = roster.FindApp( APP_MIME, &ref ); if( status != B_OK ) { fprintf( stderr, _T("Can't find BeGadu running: %s\n"), strerror( status ) ); return; } status = deskbar.AddItem( &ref ); if( status != B_OK ) { fprintf( stderr, _T("Can't put BeGadu into Deskbar: %s\n"), strerror( status ) ); return; } } }
status_t VBoxGuestDeskbarView::AddToDeskbar(bool force) { BDeskbar deskbar; status_t err; if (force) RemoveFromDeskbar(); else if (deskbar.HasItem(VIEWNAME)) return B_OK; app_info info; err = be_app->GetAppInfo(&info); if (err < B_OK) return err; BPath p(&info.ref); return deskbar.AddItem(&info.ref); }
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; } }
WatchApp::WatchApp() : BApplication(APP_SIGNATURE) { B_TRANSLATE_MARK_SYSTEM_NAME_VOID("WebWatch"); // Here we tell the Deskbar that we want to add a new replicant, and // where it can find this replicant (in our app). Because we only run // less than a second, there is no need for our title to appear inside // the Deskbar. Therefore, the application flags inside our resource // file should be set to B_BACKGROUND_APP. BDeskbar deskbar; if (!deskbar.HasItem(DESKBAR_ITEM_NAME)) { entry_ref ref; be_roster->FindApp(APP_SIGNATURE, &ref); deskbar.AddItem(&ref); } PostMessage(B_QUIT_REQUESTED); }
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"); } }
bool LoadInDeskbar() { PulseApp *pulseapp = (PulseApp *)be_app; BDeskbar *deskbar = new BDeskbar(); // Don't allow two copies in the Deskbar at once if (deskbar->HasItem("DeskbarPulseView")) { delete deskbar; return false; } // Must be 16 pixels high, the width is retrieved from the Prefs class int width = pulseapp->prefs->deskbar_icon_width; int min_width = GetMinimumViewWidth(); if (width < min_width) { pulseapp->prefs->deskbar_icon_width = min_width; width = min_width; } float height = deskbar->MaxItemHeight(); BRect rect(0, 0, width - 1, height - 1); DeskbarPulseView *replicant = new DeskbarPulseView(rect); status_t err = deskbar->AddItem(replicant); delete replicant; delete deskbar; if (err != B_OK) { BString message; snprintf(message.LockBuffer(512), 512, B_TRANSLATE("Installing in Deskbar failed\n%s"), strerror(err)); message.UnlockBuffer(); BAlert *alert = new BAlert(B_TRANSLATE("Error"), message.String(), B_TRANSLATE("OK")); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(NULL); return false; } return true; }
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 MailDaemonApp::InstallDeskbarIcon() { BDeskbar deskbar; if (!deskbar.HasItem("mail_daemon")) { BRoster roster; entry_ref ref; status_t status = roster.FindApp(B_MAIL_DAEMON_SIGNATURE, &ref); if (status < B_OK) { fprintf(stderr, "Can't find application to tell deskbar: %s\n", strerror(status)); return; } status = deskbar.AddItem(&ref); if (status < B_OK) { fprintf(stderr, "Can't add deskbar replicant: %s\n", strerror(status)); return; } } }
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 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; } }
void WorkspacesView::MouseDown(BPoint where) { // With enabled auto-raise feature, we'll get mouse messages we don't // want to handle here. if (!Bounds().Contains(where)) return; int32 buttons = 0; if (Window() != NULL && Window()->CurrentMessage() != NULL) Window()->CurrentMessage()->FindInt32("buttons", &buttons); if ((buttons & B_SECONDARY_MOUSE_BUTTON) == 0) return; // open context menu BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING, false, false); menu->SetFont(be_plain_font); // TODO: alternatively change the count here directly? BMenuItem* changeItem = new BMenuItem(B_TRANSLATE("Change workspace count" B_UTF8_ELLIPSIS), new BMessage(kMsgChangeCount)); menu->AddItem(changeItem); WorkspacesWindow* window = dynamic_cast<WorkspacesWindow*>(Window()); if (window != NULL) { // inside Workspaces app BMenuItem* item; menu->AddSeparatorItem(); menu->AddItem(item = new BMenuItem(B_TRANSLATE("Show window tab"), new BMessage(kMsgToggleTitle))); if (window->Look() == B_TITLED_WINDOW_LOOK) item->SetMarked(true); menu->AddItem(item = new BMenuItem(B_TRANSLATE("Show window border"), new BMessage(kMsgToggleBorder))); if (window->Look() == B_TITLED_WINDOW_LOOK || window->Look() == B_MODAL_WINDOW_LOOK) item->SetMarked(true); menu->AddSeparatorItem(); menu->AddItem(item = new BMenuItem(B_TRANSLATE("Always on top"), new BMessage(kMsgToggleAlwaysOnTop))); if (window->Feel() == B_FLOATING_ALL_WINDOW_FEEL) item->SetMarked(true); menu->AddItem(item = new BMenuItem(B_TRANSLATE("Auto-raise"), new BMessage(kMsgToggleAutoRaise))); if (window->IsAutoRaising()) item->SetMarked(true); if (be_roster->IsRunning(kDeskbarSignature)) { menu->AddItem(item = new BMenuItem(B_TRANSLATE("Live in the Deskbar"), new BMessage(kMsgToggleLiveInDeskbar))); BDeskbar deskbar; item->SetMarked(deskbar.HasItem(kDeskbarItemName)); } menu->AddSeparatorItem(); menu->AddItem(new BMenuItem(B_TRANSLATE("About Workspaces" B_UTF8_ELLIPSIS), new BMessage(B_ABOUT_REQUESTED))); menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"), new BMessage(B_QUIT_REQUESTED))); menu->SetTargetForItems(window); } else { // we're replicated in some way... BMenuItem* item; menu->AddSeparatorItem(); // check which way BDragger *dragger = dynamic_cast<BDragger*>(ChildAt(0)); if (dragger) { // replicant menu->AddItem(item = new BMenuItem(B_TRANSLATE("Remove replicant"), new BMessage(B_TRASH_TARGET))); item->SetTarget(dragger); } else { // Deskbar item menu->AddItem(item = new BMenuItem(B_TRANSLATE("Remove replicant"), new BMessage(kMsgToggleLiveInDeskbar))); item->SetTarget(this); } } changeItem->SetTarget(this); ConvertToScreen(&where); menu->Go(where, true, true, true); }