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 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(); } } }
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(); } }