Reworked GUI settings storage.

- Simplified things so each window simply records all its settings into
  a BMessage, which is what ultimately goes into the actual UI settings.

- Added settings storage/retrieval to the various sub views of the
  team window. This means that the column widths/positioning on all
  views hosting a column list view are now also preserved and restored.
This commit is contained in:
Rene Gollent
2011-11-19 18:17:40 -05:00
parent 79dbafbc66
commit 11102e3848
19 changed files with 378 additions and 73 deletions
@@ -267,7 +267,7 @@ bool
InspectorWindow::QuitRequested() InspectorWindow::QuitRequested()
{ {
BMessage settings(MSG_INSPECTOR_WINDOW_CLOSED); BMessage settings(MSG_INSPECTOR_WINDOW_CLOSED);
SaveSettings(&settings); SaveSettings(settings);
BMessenger(fTarget).SendMessage(&settings); BMessenger(fTarget).SendMessage(&settings);
return true; return true;
@@ -288,35 +288,40 @@ InspectorWindow::MemoryBlockRetrieved(TeamMemoryBlock* block)
status_t status_t
InspectorWindow::LoadSettings(const GUITeamUISettings* settings) InspectorWindow::LoadSettings(const GUITeamUISettings& settings)
{ {
AutoLocker<BLooper> lock(this); AutoLocker<BLooper> lock(this);
if (!lock.IsLocked()) if (!lock.IsLocked())
return B_ERROR; return B_ERROR;
BVariant value; BMessage inspectorSettings;
if (settings->Value("inspectorWindowFrame", value) == B_OK) { if (settings.Settings("inspectorWindow", inspectorSettings) == B_OK)
BRect frameRect = value.ToRect(); return B_OK;
BRect frameRect;
if (inspectorSettings.FindRect("frame", &frameRect) == B_OK) {
ResizeTo(frameRect.Width(), frameRect.Height()); ResizeTo(frameRect.Width(), frameRect.Height());
MoveTo(frameRect.left, frameRect.top); MoveTo(frameRect.left, frameRect.top);
} }
_LoadMenuFieldMode(fHexMode, "Hex", settings); _LoadMenuFieldMode(fHexMode, "Hex", inspectorSettings);
_LoadMenuFieldMode(fEndianMode, "Endian", settings); _LoadMenuFieldMode(fEndianMode, "Endian", inspectorSettings);
_LoadMenuFieldMode(fTextMode, "Text", settings); _LoadMenuFieldMode(fTextMode, "Text", inspectorSettings);
return B_OK; return B_OK;
} }
status_t status_t
InspectorWindow::SaveSettings(BMessage* settings) InspectorWindow::SaveSettings(BMessage& settings)
{ {
AutoLocker<BLooper> lock(this); AutoLocker<BLooper> lock(this);
if (!lock.IsLocked()) if (!lock.IsLocked())
return B_ERROR; return B_ERROR;
status_t error = settings->AddRect("inspectorWindowFrame", Frame()); settings.MakeEmpty();
status_t error = settings.AddRect("frame", Frame());
if (error != B_OK) if (error != B_OK)
return error; return error;
@@ -338,17 +343,16 @@ InspectorWindow::SaveSettings(BMessage* settings)
void void
InspectorWindow::_LoadMenuFieldMode(BMenuField* field, const char* name, InspectorWindow::_LoadMenuFieldMode(BMenuField* field, const char* name,
const GUITeamUISettings* settings) const BMessage& settings)
{ {
BVariant value;
BString fieldName; BString fieldName;
fieldName.SetToFormat("inspectorWindow%sMode", name); int32 mode;
status_t error = settings->Value(fieldName.String(), value); fieldName.SetToFormat("%sMode", name);
if (error == B_OK) { if (settings.FindInt32(fieldName.String(), &mode) == B_OK) {
BMenu* menu = field->Menu(); BMenu* menu = field->Menu();
for (int32 i = 0; i < menu->CountItems(); i++) { for (int32 i = 0; i < menu->CountItems(); i++) {
BInvoker* item = menu->ItemAt(i); BInvoker* item = menu->ItemAt(i);
if (item->Message()->FindInt32("mode") == value.ToInt32()) { if (item->Message()->FindInt32("mode") == mode) {
item->Invoke(); item->Invoke();
break; break;
} }
@@ -359,14 +363,14 @@ InspectorWindow::_LoadMenuFieldMode(BMenuField* field, const char* name,
status_t status_t
InspectorWindow::_SaveMenuFieldMode(BMenuField* field, const char* name, InspectorWindow::_SaveMenuFieldMode(BMenuField* field, const char* name,
BMessage* settings) BMessage& settings)
{ {
BMenuItem* item = field->Menu()->FindMarked(); BMenuItem* item = field->Menu()->FindMarked();
if (item && item->Message()) { if (item && item->Message()) {
int32 mode = item->Message()->FindInt32("mode"); int32 mode = item->Message()->FindInt32("mode");
BString fieldName; BString fieldName;
fieldName.SetToFormat("inspectorWindow%sMode", name); fieldName.SetToFormat("%sMode", name);
return settings->AddInt32(fieldName.String(), mode); return settings.AddInt32(fieldName.String(), mode);
} }
return B_OK; return B_OK;
@@ -41,18 +41,18 @@ public:
virtual void MemoryBlockRetrieved(TeamMemoryBlock* block); virtual void MemoryBlockRetrieved(TeamMemoryBlock* block);
status_t LoadSettings( status_t LoadSettings(
const GUITeamUISettings* settings); const GUITeamUISettings& settings);
status_t SaveSettings( status_t SaveSettings(
BMessage* settings); BMessage& settings);
private: private:
void _Init(); void _Init();
void _LoadMenuFieldMode(BMenuField* field, void _LoadMenuFieldMode(BMenuField* field,
const char* name, const char* name,
const GUITeamUISettings* settings); const BMessage& settings);
status_t _SaveMenuFieldMode(BMenuField* field, status_t _SaveMenuFieldMode(BMenuField* field,
const char* name, const char* name,
BMessage* settings); BMessage& settings);
private: private:
UserInterfaceListener* fListener; UserInterfaceListener* fListener;
@@ -1,5 +1,6 @@
/* /*
* Copyright 2009, Ingo Weinhold, [email protected]. * Copyright 2009, Ingo Weinhold, [email protected].
* Copyright 2011, Rene Gollent, [email protected].
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@@ -14,6 +15,7 @@
#include <ObjectList.h> #include <ObjectList.h>
#include "FunctionID.h" #include "FunctionID.h"
#include "GUISettingsUtils.h"
#include "LocatableFile.h" #include "LocatableFile.h"
#include "table/TableColumns.h" #include "table/TableColumns.h"
#include "Team.h" #include "Team.h"
@@ -234,6 +236,32 @@ BreakpointListView::UserBreakpointChanged(UserBreakpoint* breakpoint)
} }
void
BreakpointListView::LoadSettings(const BMessage& settings)
{
BMessage tableSettings;
if (settings.FindMessage("breakpointsTable", &tableSettings) == B_OK) {
GUISettingsUtils::UnarchiveTableSettings(tableSettings,
fBreakpointsTable);
}
}
status_t
BreakpointListView::SaveSettings(BMessage& settings)
{
settings.MakeEmpty();
BMessage tableSettings;
status_t result = GUISettingsUtils::ArchiveTableSettings(tableSettings,
fBreakpointsTable);
if (result == B_OK)
result = settings.AddMessage("breakpointsTable", &tableSettings);
return result;
}
void void
BreakpointListView::TableSelectionChanged(Table* table) BreakpointListView::TableSelectionChanged(Table* table)
{ {
@@ -33,6 +33,9 @@ public:
void UserBreakpointChanged( void UserBreakpointChanged(
UserBreakpoint* breakpoint); UserBreakpoint* breakpoint);
void LoadSettings(const BMessage& settings);
status_t SaveSettings(BMessage& settings);
private: private:
class BreakpointsTableModel; class BreakpointsTableModel;
@@ -1,5 +1,6 @@
/* /*
* Copyright 2009, Ingo Weinhold, [email protected]. * Copyright 2009, Ingo Weinhold, [email protected].
* Copyright 2011, Rene Gollent, [email protected].
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@@ -126,6 +127,30 @@ BreakpointsView::AttachedToWindow()
} }
void
BreakpointsView::LoadSettings(const BMessage& settings)
{
BMessage breakpointListSettings;
if (settings.FindMessage("breakpointList", &breakpointListSettings)
== B_OK)
fListView->LoadSettings(breakpointListSettings);
}
status_t
BreakpointsView::SaveSettings(BMessage& settings)
{
BMessage breakpointListSettings;
if (fListView->SaveSettings(breakpointListSettings) != B_OK)
return B_NO_MEMORY;
if (settings.AddMessage("breakpointList", &breakpointListSettings) != B_OK)
return B_NO_MEMORY;
return B_OK;
}
void void
BreakpointsView::BreakpointSelectionChanged(UserBreakpoint* breakpoint) BreakpointsView::BreakpointSelectionChanged(UserBreakpoint* breakpoint)
{ {
@@ -35,6 +35,9 @@ public:
virtual void MessageReceived(BMessage* message); virtual void MessageReceived(BMessage* message);
virtual void AttachedToWindow(); virtual void AttachedToWindow();
void LoadSettings(const BMessage& settings);
status_t SaveSettings(BMessage& settings);
private: private:
// BreakpointListView::Listener // BreakpointListView::Listener
virtual void BreakpointSelectionChanged( virtual void BreakpointSelectionChanged(
@@ -1,5 +1,6 @@
/* /*
* Copyright 2009, Ingo Weinhold, [email protected]. * Copyright 2009, Ingo Weinhold, [email protected].
* Copyright 2011, Rene Gollent, [email protected].
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@@ -15,6 +16,7 @@
#include "table/TableColumns.h" #include "table/TableColumns.h"
#include "FunctionInstance.h" #include "FunctionInstance.h"
#include "GUISettingsUtils.h"
#include "Image.h" #include "Image.h"
#include "ImageDebugInfo.h" #include "ImageDebugInfo.h"
#include "LocatableFile.h" #include "LocatableFile.h"
@@ -391,6 +393,32 @@ ImageFunctionsView::SetFunction(FunctionInstance* function)
} }
void
ImageFunctionsView::LoadSettings(const BMessage& settings)
{
BMessage tableSettings;
if (settings.FindMessage("functionsTable", &tableSettings) == B_OK) {
GUISettingsUtils::UnarchiveTableSettings(tableSettings,
fFunctionsTable);
}
}
status_t
ImageFunctionsView::SaveSettings(BMessage& settings)
{
settings.MakeEmpty();
BMessage tableSettings;
status_t result = GUISettingsUtils::ArchiveTableSettings(tableSettings,
fFunctionsTable);
if (result == B_OK)
result = settings.AddMessage("functionsTable", &tableSettings);
return result;
}
void void
ImageFunctionsView::TreeTableSelectionChanged(TreeTable* table) ImageFunctionsView::TreeTableSelectionChanged(TreeTable* table)
{ {
@@ -31,6 +31,9 @@ public:
ImageDebugInfo* imageDebugInfo); ImageDebugInfo* imageDebugInfo);
void SetFunction(FunctionInstance* function); void SetFunction(FunctionInstance* function);
void LoadSettings(const BMessage& settings);
status_t SaveSettings(BMessage& settings);
private: private:
class FunctionsTableModel; class FunctionsTableModel;
@@ -1,5 +1,6 @@
/* /*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2011, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@@ -15,6 +16,7 @@
#include <AutoLocker.h> #include <AutoLocker.h>
#include <ObjectList.h> #include <ObjectList.h>
#include "GUISettingsUtils.h"
#include "table/TableColumns.h" #include "table/TableColumns.h"
#include "Tracing.h" #include "Tracing.h"
@@ -224,6 +226,32 @@ ImageListView::MessageReceived(BMessage* message)
} }
void
ImageListView::LoadSettings(const BMessage& settings)
{
BMessage tableSettings;
if (settings.FindMessage("imagesTable", &tableSettings) == B_OK) {
GUISettingsUtils::UnarchiveTableSettings(tableSettings,
fImagesTable);
}
}
status_t
ImageListView::SaveSettings(BMessage& settings)
{
settings.MakeEmpty();
BMessage tableSettings;
status_t result = GUISettingsUtils::ArchiveTableSettings(tableSettings,
fImagesTable);
if (result == B_OK)
result = settings.AddMessage("imagesTable", &tableSettings);
return result;
}
void void
ImageListView::ImageAdded(const Team::ImageEvent& event) ImageListView::ImageAdded(const Team::ImageEvent& event)
{ {
@@ -29,6 +29,9 @@ public:
virtual void MessageReceived(BMessage* message); virtual void MessageReceived(BMessage* message);
void LoadSettings(const BMessage& settings);
status_t SaveSettings(BMessage& settings);
private: private:
class ImagesTableModel; class ImagesTableModel;
@@ -1,5 +1,6 @@
/* /*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2011, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@@ -15,6 +16,7 @@
#include "Architecture.h" #include "Architecture.h"
#include "CpuState.h" #include "CpuState.h"
#include "GUISettingsUtils.h"
#include "Register.h" #include "Register.h"
@@ -226,6 +228,32 @@ RegistersView::SetCpuState(CpuState* cpuState)
} }
void
RegistersView::LoadSettings(const BMessage& settings)
{
BMessage tableSettings;
if (settings.FindMessage("registerTable", &tableSettings) == B_OK) {
GUISettingsUtils::UnarchiveTableSettings(tableSettings,
fRegisterTable);
}
}
status_t
RegistersView::SaveSettings(BMessage& settings)
{
settings.MakeEmpty();
BMessage tableSettings;
status_t result = GUISettingsUtils::ArchiveTableSettings(tableSettings,
fRegisterTable);
if (result == B_OK)
result = settings.AddMessage("registerTable", &tableSettings);
return result;
}
void void
RegistersView::TableRowInvoked(Table* table, int32 rowIndex) RegistersView::TableRowInvoked(Table* table, int32 rowIndex)
{ {
@@ -24,6 +24,9 @@ public:
void SetCpuState(CpuState* cpuState); void SetCpuState(CpuState* cpuState);
void LoadSettings(const BMessage& settings);
status_t SaveSettings(BMessage& settings);
private: private:
class RegisterValueColumn; class RegisterValueColumn;
class RegisterTableModel; class RegisterTableModel;
@@ -1,5 +1,6 @@
/* /*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2011, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@@ -15,6 +16,7 @@
#include "table/TableColumns.h" #include "table/TableColumns.h"
#include "FunctionInstance.h" #include "FunctionInstance.h"
#include "GUISettingsUtils.h"
#include "Image.h" #include "Image.h"
#include "StackTrace.h" #include "StackTrace.h"
#include "TargetAddressTableColumn.h" #include "TargetAddressTableColumn.h"
@@ -196,6 +198,32 @@ StackTraceView::SetStackFrame(StackFrame* stackFrame)
} }
void
StackTraceView::LoadSettings(const BMessage& settings)
{
BMessage tableSettings;
if (settings.FindMessage("framesTable", &tableSettings) == B_OK) {
GUISettingsUtils::UnarchiveTableSettings(tableSettings,
fFramesTable);
}
}
status_t
StackTraceView::SaveSettings(BMessage& settings)
{
settings.MakeEmpty();
BMessage tableSettings;
status_t result = GUISettingsUtils::ArchiveTableSettings(tableSettings,
fFramesTable);
if (result == B_OK)
result = settings.AddMessage("framesTable", &tableSettings);
return result;
}
void void
StackTraceView::TableSelectionChanged(Table* table) StackTraceView::TableSelectionChanged(Table* table)
{ {
@@ -30,6 +30,9 @@ public:
void SetStackTrace(StackTrace* stackTrace); void SetStackTrace(StackTrace* stackTrace);
void SetStackFrame(StackFrame* stackFrame); void SetStackFrame(StackFrame* stackFrame);
void LoadSettings(const BMessage& settings);
status_t SaveSettings(BMessage& settings);
private: private:
class FramesTableModel; class FramesTableModel;
@@ -224,7 +224,8 @@ TeamWindow::MessageReceived(BMessage* message)
fInspectorWindow = InspectorWindow::Create(fTeam, fListener, fInspectorWindow = InspectorWindow::Create(fTeam, fListener,
this); this);
if (fInspectorWindow != NULL) { if (fInspectorWindow != NULL) {
fInspectorWindow->LoadSettings(&fUISettings); BMessage settings;
fInspectorWindow->LoadSettings(fUISettings);
fInspectorWindow->Show(); fInspectorWindow->Show();
} }
} catch (...) { } catch (...) {
@@ -354,22 +355,50 @@ TeamWindow::LoadSettings(const GUITeamUISettings* settings)
if (!lock.IsLocked()) if (!lock.IsLocked())
return B_ERROR; return B_ERROR;
BVariant value; BMessage teamWindowSettings;
status_t error = settings->Value("teamWindowFrame", value); // no settings stored yet
if (error == B_OK) { if (settings->Settings("teamWindow", teamWindowSettings) != B_OK)
BRect rect = value.ToRect(); return B_OK;
ResizeTo(rect.Width(), rect.Height());
MoveTo(rect.left, rect.top); BRect frame;
if (teamWindowSettings.FindRect("frame", &frame) == B_OK) {
ResizeTo(frame.Width(), frame.Height());
MoveTo(frame.left, frame.top);
} }
GUISettingsUtils::UnarchiveSplitView(Name(), "Source", settings, BMessage archive;
fSourceSplitView); if (teamWindowSettings.FindMessage("sourceSplit", &archive) == B_OK)
GUISettingsUtils::UnarchiveSplitView(Name(), "Function", settings, GUISettingsUtils::UnarchiveSplitView(archive, fSourceSplitView);
fFunctionSplitView);
GUISettingsUtils::UnarchiveSplitView(Name(), "Image", settings, if (teamWindowSettings.FindMessage("functionSplit", &archive) == B_OK)
fImageSplitView); GUISettingsUtils::UnarchiveSplitView(archive, fFunctionSplitView);
GUISettingsUtils::UnarchiveSplitView(Name(), "Thread", settings,
fThreadSplitView); if (teamWindowSettings.FindMessage("imageSplit", &archive) == B_OK)
GUISettingsUtils::UnarchiveSplitView(archive, fImageSplitView);
if (teamWindowSettings.FindMessage("threadSplit", &archive) == B_OK)
GUISettingsUtils::UnarchiveSplitView(archive, fThreadSplitView);
if (teamWindowSettings.FindMessage("imageListView", &archive) == B_OK)
fImageListView->LoadSettings(archive);
if (teamWindowSettings.FindMessage("imageFunctionsView", &archive) == B_OK)
fImageFunctionsView->LoadSettings(archive);
if (teamWindowSettings.FindMessage("threadListView", &archive) == B_OK)
fThreadListView->LoadSettings(archive);
if (teamWindowSettings.FindMessage("variablesView", &archive) == B_OK)
fVariablesView->LoadSettings(archive);
if (teamWindowSettings.FindMessage("registersView", &archive) == B_OK)
fRegistersView->LoadSettings(archive);
if (teamWindowSettings.FindMessage("stackTraceView", &archive) == B_OK)
fStackTraceView->LoadSettings(archive);
if (teamWindowSettings.FindMessage("breakpointsView", &archive) == B_OK)
fBreakpointsView->LoadSettings(archive);
fUISettings = *settings; fUISettings = *settings;
@@ -384,40 +413,73 @@ TeamWindow::SaveSettings(GUITeamUISettings* settings)
if (!lock.IsLocked()) if (!lock.IsLocked())
return B_ERROR; return B_ERROR;
// save the settings from the cached copy first, BMessage inspectorSettings;
// then overwrite them with our most current set if (fUISettings.Settings("inspectorWindow", inspectorSettings) == B_OK) {
// this is necessary in order to preserve the settings if (!settings->AddSettings("inspectorWindow", inspectorSettings))
// of things like the inspector in case we haven't actually return B_NO_MEMORY;
// invoked them at all in this session
const BMessage& values = fUISettings.Values();
char *name;
type_code type;
BVariant value;
for (int32 i = 0; values.GetInfo(B_ANY_TYPE, i, &name, &type) == B_OK;
i++) {
if (value.SetFromMessage(values, name) == B_OK) {
if (!settings->SetValue(name, value))
return B_NO_MEMORY;
}
} }
if (!settings->SetValue("teamWindowFrame", Frame())) BMessage archive;
BMessage teamWindowSettings;
if (teamWindowSettings.AddRect("frame", Frame()) != B_OK)
return B_NO_MEMORY; return B_NO_MEMORY;
if (GUISettingsUtils::ArchiveSplitView(Name(), "Source", if (GUISettingsUtils::ArchiveSplitView(archive, fSourceSplitView) != B_OK)
settings, fSourceSplitView) != B_OK) return B_NO_MEMORY;
if (teamWindowSettings.AddMessage("sourceSplit", &archive) != B_OK)
return B_NO_MEMORY; return B_NO_MEMORY;
if (GUISettingsUtils::ArchiveSplitView(Name(), "Function", if (GUISettingsUtils::ArchiveSplitView(archive, fFunctionSplitView) != B_OK)
settings, fFunctionSplitView) != B_OK) return B_NO_MEMORY;
if (teamWindowSettings.AddMessage("functionSplit", &archive) != B_OK)
return B_NO_MEMORY; return B_NO_MEMORY;
if (GUISettingsUtils::ArchiveSplitView(Name(), "Image", if (GUISettingsUtils::ArchiveSplitView(archive, fImageSplitView) != B_OK)
settings, fImageSplitView) != B_OK) return B_NO_MEMORY;
if (teamWindowSettings.AddMessage("imageSplit", &archive))
return B_NO_MEMORY; return B_NO_MEMORY;
if (GUISettingsUtils::ArchiveSplitView(Name(), "Thread", if (GUISettingsUtils::ArchiveSplitView(archive, fThreadSplitView) != B_OK)
settings, fThreadSplitView) != B_OK) return B_NO_MEMORY;
if (teamWindowSettings.AddMessage("threadSplit", &archive))
return B_NO_MEMORY;
if (fImageListView->SaveSettings(archive) != B_OK)
return B_NO_MEMORY;
if (teamWindowSettings.AddMessage("imageListView", &archive))
return B_NO_MEMORY;
if (fImageFunctionsView->SaveSettings(archive) != B_OK)
return B_NO_MEMORY;
if (teamWindowSettings.AddMessage("imageFunctionsView", &archive))
return B_NO_MEMORY;
if (fThreadListView->SaveSettings(archive) != B_OK)
return B_NO_MEMORY;
if (teamWindowSettings.AddMessage("threadListView", &archive))
return B_NO_MEMORY;
if (fVariablesView->SaveSettings(archive) != B_OK)
return B_NO_MEMORY;
if (teamWindowSettings.AddMessage("variablesView", &archive))
return B_NO_MEMORY;
if (fRegistersView->SaveSettings(archive) != B_OK)
return B_NO_MEMORY;
if (teamWindowSettings.AddMessage("registersView", &archive))
return B_NO_MEMORY;
if (fStackTraceView->SaveSettings(archive) != B_OK)
return B_NO_MEMORY;
if (teamWindowSettings.AddMessage("stackTraceView", &archive))
return B_NO_MEMORY;
if (fBreakpointsView->SaveSettings(archive) != B_OK)
return B_NO_MEMORY;
if (teamWindowSettings.AddMessage("breakpointsView", &archive))
return B_NO_MEMORY;
if (!settings->AddSettings("teamWindow", teamWindowSettings))
return B_NO_MEMORY; return B_NO_MEMORY;
return B_OK; return B_OK;
@@ -1186,17 +1248,8 @@ TeamWindow::_HandleResolveMissingSourceFile(entry_ref& locatedPath)
status_t status_t
TeamWindow::_SaveInspectorSettings(const BMessage* settings) TeamWindow::_SaveInspectorSettings(const BMessage* settings)
{ {
char *name; if (fUISettings.AddSettings("inspectorWindow", *settings) != B_OK)
type_code type; return B_NO_MEMORY;
BVariant value;
for (int32 i = 0; settings->GetInfo(B_ANY_TYPE, i, &name, &type) == B_OK;
i++) {
if (value.SetFromMessage(*settings, name) == B_OK) {
if (!fUISettings.SetValue(name, value))
return B_NO_MEMORY;
}
}
return B_OK; return B_OK;
} }
@@ -1,5 +1,6 @@
/* /*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2011, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@@ -15,6 +16,7 @@
#include <ObjectList.h> #include <ObjectList.h>
#include <ToolTip.h> #include <ToolTip.h>
#include "GUISettingsUtils.h"
#include "table/TableColumns.h" #include "table/TableColumns.h"
@@ -306,6 +308,34 @@ ThreadListView::MessageReceived(BMessage* message)
} }
void
ThreadListView::LoadSettings(const BMessage& settings)
{
BMessage tableSettings;
if (settings.FindMessage("threadsTable", &tableSettings) == B_OK) {
GUISettingsUtils::UnarchiveTableSettings(tableSettings,
fThreadsTable);
}
}
status_t
ThreadListView::SaveSettings(BMessage& settings)
{
settings.MakeEmpty();
BMessage tableSettings;
status_t result = GUISettingsUtils::ArchiveTableSettings(tableSettings,
fThreadsTable);
if (result == B_OK)
result = settings.AddMessage("threadsTable", &tableSettings);
return result;
}
void void
ThreadListView::ThreadAdded(const Team::ThreadEvent& event) ThreadListView::ThreadAdded(const Team::ThreadEvent& event)
{ {
@@ -33,6 +33,9 @@ public:
virtual void MessageReceived(BMessage* message); virtual void MessageReceived(BMessage* message);
void LoadSettings(const BMessage& settings);
status_t SaveSettings(BMessage& settings);
private: private:
class ThreadsTableModel; class ThreadsTableModel;
@@ -22,6 +22,7 @@
#include "Architecture.h" #include "Architecture.h"
#include "FunctionID.h" #include "FunctionID.h"
#include "FunctionInstance.h" #include "FunctionInstance.h"
#include "GUISettingsUtils.h"
#include "MessageCodes.h" #include "MessageCodes.h"
#include "SettingsMenu.h" #include "SettingsMenu.h"
#include "StackFrame.h" #include "StackFrame.h"
@@ -1519,6 +1520,34 @@ VariablesView::DetachedFromWindow()
} }
void
VariablesView::LoadSettings(const BMessage& settings)
{
BMessage tableSettings;
if (settings.FindMessage("variableTable", &tableSettings) == B_OK) {
GUISettingsUtils::UnarchiveTableSettings(tableSettings,
fVariableTable);
}
}
status_t
VariablesView::SaveSettings(BMessage& settings)
{
settings.MakeEmpty();
BMessage tableSettings;
status_t result = GUISettingsUtils::ArchiveTableSettings(tableSettings,
fVariableTable);
if (result == B_OK)
result = settings.AddMessage("variableTable", &tableSettings);
return result;
}
void void
VariablesView::TreeTableNodeExpandedChanged(TreeTable* table, VariablesView::TreeTableNodeExpandedChanged(TreeTable* table,
const TreeTablePath& path, bool expanded) const TreeTablePath& path, bool expanded)
@@ -41,6 +41,9 @@ public:
virtual void DetachedFromWindow(); virtual void DetachedFromWindow();
void LoadSettings(const BMessage& settings);
status_t SaveSettings(BMessage& settings);
private: private:
// TreeTableListener // TreeTableListener
virtual void TreeTableNodeExpandedChanged(TreeTable* table, virtual void TreeTableNodeExpandedChanged(TreeTable* table,