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 move_to_deskbar(BDeskbar& deskbar) { entry_ref ref; find_self(ref); deskbar.AddItem(&ref); }
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(); }
/*********************************************************** * 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); } }
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 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)); } }
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 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; } } }
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; };
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); }
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; } }
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 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; } }
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; }