void AppGroupView::MessageReceived(BMessage* msg) { switch (msg->what) { case kRemoveView: { NotificationView* view = NULL; if (msg->FindPointer("view", (void**)&view) != B_OK) return; infoview_t::iterator vIt = find(fInfo.begin(), fInfo.end(), view); if (vIt == fInfo.end()) break; fInfo.erase(vIt); view->RemoveSelf(); delete view; fParent->PostMessage(msg); if (!this->HasChildren()) { Hide(); BMessage removeSelfMessage(kRemoveGroupView); removeSelfMessage.AddPointer("view", this); fParent->PostMessage(&removeSelfMessage); } break; } default: BView::MessageReceived(msg); } }
void NotificationWindow::_LoadDisplaySettings(bool startMonitor) { BPath path; BMessage settings; if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK) return; path.Append(kSettingsDirectory); if (create_directory(path.Path(), 0755) == B_OK) { path.Append(kDisplaySettings); BFile file(path.Path(), B_READ_ONLY); settings.Unflatten(&file); } int32 setting; if (settings.FindFloat(kWidthName, &fWidth) != B_OK) fWidth = kDefaultWidth; if (settings.FindInt32(kIconSizeName, &setting) != B_OK) fIconSize = kDefaultIconSize; else fIconSize = (icon_size)setting; // Notify the view about the change views_t::iterator it; for (it = fViews.begin(); it != fViews.end(); ++it) { NotificationView* view = (*it); view->Invalidate(); } if (startMonitor) { node_ref nref; BEntry entry(path.Path()); entry.GetNodeRef(&nref); if (watch_node(&nref, B_WATCH_ALL, BMessenger(this)) != B_OK) { BAlert* alert = new BAlert(B_TRANSLATE("Warning"), B_TRANSLATE("Couldn't start display settings monitor.\n" "Live filter changes disabled."), B_TRANSLATE("OK")); alert->Go(); } } }
void NotificationWindow::_LoadGeneralSettings(BMessage& settings) { bool shouldRun; if (settings.FindBool(kAutoStartName, &shouldRun) == B_OK) { if (shouldRun == false) { // We should not start. Quit the app! be_app_messenger.SendMessage(B_QUIT_REQUESTED); } } if (settings.FindInt32(kTimeoutName, &fTimeout) != B_OK) fTimeout = kDefaultTimeout; // Notify the view about the change views_t::iterator it; for (it = fViews.begin(); it != fViews.end(); ++it) { NotificationView* view = (*it); view->Invalidate(); } }
void AppGroupView::AddInfo(NotificationView* view) { BString id = view->MessageID(); bool found = false; if (id.Length() > 0) { int32 children = fInfo.size(); for (int32 i = 0; i < children; i++) { if (id == fInfo[i]->MessageID()) { NotificationView* oldView = fInfo[i]; fParent->NotificationViewSwapped(oldView, view); oldView->RemoveSelf(); delete oldView; fInfo[i] = view; found = true; break; } } } // Invalidate all children to show or hide the close buttons in the // notification view int32 children = fInfo.size(); for (int32 i = 0; i < children; i++) { fInfo[i]->Invalidate(); } if (!found) { fInfo.push_back(view); } GetLayout()->AddView(view); if (IsHidden()) Show(); if (view->IsHidden(view) && !fCollapsed) view->Show(); }
void NotificationWindow::_LoadDisplaySettings(BMessage& settings) { int32 setting; if (settings.FindFloat(kWidthName, &fWidth) != B_OK) fWidth = kDefaultWidth; GetLayout()->SetExplicitMaxSize(BSize(fWidth, B_SIZE_UNSET)); GetLayout()->SetExplicitMinSize(BSize(fWidth, B_SIZE_UNSET)); if (settings.FindInt32(kIconSizeName, &setting) != B_OK) fIconSize = kDefaultIconSize; else fIconSize = (icon_size)setting; // Notify the view about the change views_t::iterator it; for (it = fViews.begin(); it != fViews.end(); ++it) { NotificationView* view = (*it); view->Invalidate(); } }
void NotificationWindow::_LoadGeneralSettings(bool startMonitor) { BPath path; BMessage settings; if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK) return; path.Append(kSettingsDirectory); if (create_directory(path.Path(), 0755) == B_OK) { path.Append(kGeneralSettings); BFile file(path.Path(), B_READ_ONLY); settings.Unflatten(&file); } if (settings.FindInt32(kTimeoutName, &fTimeout) != B_OK) fTimeout = kDefaultTimeout; // Notify the view about the change views_t::iterator it; for (it = fViews.begin(); it != fViews.end(); ++it) { NotificationView* view = (*it); view->SetText(view->Application(), view->Title(), view->Text()); view->Invalidate(); } if (startMonitor) { node_ref nref; BEntry entry(path.Path()); entry.GetNodeRef(&nref); if (watch_node(&nref, B_WATCH_ALL, BMessenger(this)) != B_OK) { BAlert* alert = new BAlert(B_TRANSLATE("Warning"), B_TRANSLATE("Couldn't start general settings monitor.\n" "Live filter changes disabled."), B_TRANSLATE("OK")); alert->Go(); } } }