Factor out an _SaveSettings() call to write back settings. Use it to commit tray item changes immediately instead of at Deskbar exit.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43009 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -439,14 +439,7 @@ TReplicantTray::InitAddOnSupport()
|
|||||||
void
|
void
|
||||||
TReplicantTray::DeleteAddOnSupport()
|
TReplicantTray::DeleteAddOnSupport()
|
||||||
{
|
{
|
||||||
BPath path;
|
_SaveSettings();
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int32 i = fItemList->CountItems(); i-- > 0 ;) {
|
for (int32 i = fItemList->CountItems(); i-- > 0 ;) {
|
||||||
DeskbarItemInfo* item = (DeskbarItemInfo*)fItemList->RemoveItem(i);
|
DeskbarItemInfo* item = (DeskbarItemInfo*)fItemList->RemoveItem(i);
|
||||||
@@ -625,9 +618,8 @@ TReplicantTray::LoadAddOn(BEntry* entry, int32* id, bool addToSettings)
|
|||||||
// add the rep; adds info to list
|
// add the rep; adds info to list
|
||||||
|
|
||||||
if (addToSettings) {
|
if (addToSettings) {
|
||||||
entry_ref ref;
|
fAddOnSettings.AddString(kReplicantPathField, path.Path());
|
||||||
if (entry->GetRef(&ref) == B_OK)
|
_SaveSettings();
|
||||||
fAddOnSettings.AddString(kReplicantPathField, path.Path());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -697,6 +689,18 @@ TReplicantTray::RemoveItem(int32 id)
|
|||||||
|
|
||||||
// attribute was added via Deskbar API (AddItem(entry_ref*, int32*)
|
// attribute was added via Deskbar API (AddItem(entry_ref*, int32*)
|
||||||
if (item->isAddOn) {
|
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);
|
BNode node(&item->entryRef);
|
||||||
watch_node(&item->nodeRef, B_STOP_WATCHING, this, Window());
|
watch_node(&item->nodeRef, B_STOP_WATCHING, this, Window());
|
||||||
}
|
}
|
||||||
@@ -1198,6 +1202,24 @@ TReplicantTray::SetMultiRow(bool state)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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 -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -199,6 +199,8 @@ public:
|
|||||||
bool IsDragging() {return IsTracking();}
|
bool IsDragging() {return IsTracking();}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
status_t _SaveSettings();
|
||||||
|
|
||||||
TBarView* fBarView;
|
TBarView* fBarView;
|
||||||
BView* fChild;
|
BView* fChild;
|
||||||
BPoint fPreviousPosition;
|
BPoint fPreviousPosition;
|
||||||
|
|||||||
Reference in New Issue
Block a user