Author: anevilyak Date: 2011-10-30 19:28:22 +0100 (Sun, 30 Oct 2011) New Revision: 43009 Changeset: https://dev.haiku-os.org/changeset/43009 Modified: haiku/trunk/src/apps/deskbar/StatusView.cpp haiku/trunk/src/apps/deskbar/StatusView.h Log: Factor out an _SaveSettings() call to write back settings. Use it to commit tray item changes immediately instead of at Deskbar exit. Modified: haiku/trunk/src/apps/deskbar/StatusView.cpp =================================================================== --- haiku/trunk/src/apps/deskbar/StatusView.cpp 2011-10-30 18:28:03 UTC (rev 43008) +++ haiku/trunk/src/apps/deskbar/StatusView.cpp 2011-10-30 18:28:22 UTC (rev 43009) @@ -439,14 +439,7 @@ void TReplicantTray::DeleteAddOnSupport() { - BPath path; - if (find_directory(B_USER_SETTINGS_DIRECTORY, &path, true) == B_OK) { - path.Append(kReplicantSettingsFile); - - BFile file(path.Path(), B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE); - if (file.InitCheck() == B_OK) - fAddOnSettings.Flatten(&file); - } + _SaveSettings(); for (int32 i = fItemList->CountItems(); i-- > 0 ;) { DeskbarItemInfo* item = (DeskbarItemInfo*)fItemList->RemoveItem(i); @@ -625,9 +618,8 @@ // add the rep; adds info to list if (addToSettings) { - entry_ref ref; - if (entry->GetRef(&ref) == B_OK) - fAddOnSettings.AddString(kReplicantPathField, path.Path()); + fAddOnSettings.AddString(kReplicantPathField, path.Path()); + _SaveSettings(); } return B_OK; @@ -697,6 +689,18 @@ // attribute was added via Deskbar API (AddItem(entry_ref*, int32*) if (item->isAddOn) { + BPath path(&item->entryRef); + BString storedPath; + for (int32 i = 0; + fAddOnSettings->FindString(kReplicantPathField, i, &storedPath) + == B_OK; i++) { + if (storedPath == path.Path()) { + fAddOnSettings->RemoveItem(kReplicantPathField, i); + break; + } + } + _SaveSettings(); + BNode node(&item->entryRef); watch_node(&item->nodeRef, B_STOP_WATCHING, this, Window()); } @@ -1198,6 +1202,24 @@ } +void +TReplicantTray::_SaveSettings() +{ + status_t result; + BPath path; + if ((result = find_directory(B_USER_SETTINGS_DIRECTORY, &path, true)) + == B_OK) { + path.Append(kReplicantSettingsFile); + + BFile file(path.Path(), B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE); + if ((result = file.InitCheck()) == B_OK) + result = fAddOnSettings.Flatten(&file); + } + + return result; +} + + // #pragma mark - Modified: haiku/trunk/src/apps/deskbar/StatusView.h =================================================================== --- haiku/trunk/src/apps/deskbar/StatusView.h 2011-10-30 18:28:03 UTC (rev 43008) +++ haiku/trunk/src/apps/deskbar/StatusView.h 2011-10-30 18:28:22 UTC (rev 43009) @@ -199,6 +199,8 @@ bool IsDragging() {return IsTracking();} private: + status_t _SaveSettings(); + TBarView* fBarView; BView* fChild; BPoint fPreviousPosition;