* Simplify GUITeamUISettings to just use variants mapped by string keys. The
Setting classes didn't wind up being quite as useful for that purpose as I'd originally hoped, so they remain with their primary purpose of programmatically generating menus and such. * When GraphicalUserInterface constructs the team window, immediately start the message loop. This allows us to reorder startup so we only activate the user interface after having restored settings. * TeamWindow now saves/restores its frame on a per-team basis. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43131 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
2d36b8d9a7
commit
04f0e3d37b
@ -379,8 +379,6 @@ TeamDebugger::Init(team_id teamID, thread_id threadID, bool stopInMain)
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
Activate();
|
|
||||||
|
|
||||||
// if requested, stop the given thread
|
// if requested, stop the given thread
|
||||||
if (threadID >= 0) {
|
if (threadID >= 0) {
|
||||||
if (stopInMain) {
|
if (stopInMain) {
|
||||||
@ -548,6 +546,7 @@ TeamDebugger::MessageReceived(BMessage* message)
|
|||||||
|
|
||||||
case MSG_LOAD_SETTINGS:
|
case MSG_LOAD_SETTINGS:
|
||||||
_LoadSettings();
|
_LoadSettings();
|
||||||
|
Activate();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -64,6 +64,7 @@ GUITeamUISettings::SetTo(const BMessage& archive)
|
|||||||
status_t
|
status_t
|
||||||
GUITeamUISettings::WriteTo(BMessage& archive) const
|
GUITeamUISettings::WriteTo(BMessage& archive) const
|
||||||
{
|
{
|
||||||
|
archive.MakeEmpty();
|
||||||
status_t error = archive.AddString("ID", fID);
|
status_t error = archive.AddString("ID", fID);
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return error;
|
return error;
|
||||||
@ -81,7 +82,7 @@ GUITeamUISettings::WriteTo(BMessage& archive) const
|
|||||||
TeamUISettings*
|
TeamUISettings*
|
||||||
GUITeamUISettings::Clone() const
|
GUITeamUISettings::Clone() const
|
||||||
{
|
{
|
||||||
GUITeamUISettings* settings = new(std::nothrow) GUITeamUISettings();
|
GUITeamUISettings* settings = new(std::nothrow) GUITeamUISettings(fID);
|
||||||
|
|
||||||
if (settings == NULL)
|
if (settings == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -95,56 +96,19 @@ GUITeamUISettings::Clone() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
GUITeamUISettings::AddSetting(Setting* setting)
|
|
||||||
{
|
|
||||||
if (!fSettings.AddItem(setting))
|
|
||||||
return B_NO_MEMORY;
|
|
||||||
|
|
||||||
setting->AcquireReference();
|
|
||||||
|
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
GUITeamUISettings::SetValue(const Setting* setting, const BVariant& value)
|
GUITeamUISettings::SetValue(const char* settingID, const BVariant& value)
|
||||||
{
|
{
|
||||||
const char* fieldName = setting->ID();
|
fValues.RemoveName(settingID);
|
||||||
fValues.RemoveName(fieldName);
|
|
||||||
|
|
||||||
return value.AddToMessage(fValues, fieldName) == B_OK;
|
return value.AddToMessage(fValues, settingID) == B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BVariant
|
status_t
|
||||||
GUITeamUISettings::Value(const Setting* setting) const
|
GUITeamUISettings::Value(const char* settingID, BVariant &value) const
|
||||||
{
|
{
|
||||||
BVariant value;
|
return value.SetFromMessage(fValues, settingID);
|
||||||
|
|
||||||
return value.SetFromMessage(fValues, setting->ID()) == B_OK ?
|
|
||||||
value : setting->DefaultValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BVariant
|
|
||||||
GUITeamUISettings::Value(const char* settingID) const
|
|
||||||
{
|
|
||||||
BVariant value;
|
|
||||||
|
|
||||||
status_t result = value.SetFromMessage(fValues, settingID);
|
|
||||||
|
|
||||||
if (result != B_OK) {
|
|
||||||
for (int32 i = 0; i < fSettings.CountItems(); i++) {
|
|
||||||
Setting* setting = fSettings.ItemAt(i);
|
|
||||||
if (strcmp(setting->ID(), settingID) == 0) {
|
|
||||||
value = setting->DefaultValue();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -163,13 +127,7 @@ GUITeamUISettings::_SetTo(const GUITeamUISettings& other)
|
|||||||
{
|
{
|
||||||
_Unset();
|
_Unset();
|
||||||
|
|
||||||
for (int32 i = 0; i < other.fSettings.CountItems(); i++) {
|
fID = other.fID;
|
||||||
Setting* setting = other.fSettings.ItemAt(i);
|
|
||||||
if (!fSettings.AddItem(setting))
|
|
||||||
return B_NO_MEMORY;
|
|
||||||
|
|
||||||
setting->AcquireReference();
|
|
||||||
}
|
|
||||||
|
|
||||||
fValues = other.fValues;
|
fValues = other.fValues;
|
||||||
|
|
||||||
@ -182,9 +140,5 @@ GUITeamUISettings::_Unset()
|
|||||||
{
|
{
|
||||||
fID.Truncate(0);
|
fID.Truncate(0);
|
||||||
|
|
||||||
for (int32 i = 0; i < fSettings.CountItems(); i++)
|
|
||||||
fSettings.ItemAt(i)->ReleaseReference();
|
|
||||||
|
|
||||||
fSettings.MakeEmpty();
|
|
||||||
fValues.MakeEmpty();
|
fValues.MakeEmpty();
|
||||||
}
|
}
|
||||||
|
@ -30,23 +30,19 @@ public:
|
|||||||
virtual status_t WriteTo(BMessage& archive) const;
|
virtual status_t WriteTo(BMessage& archive) const;
|
||||||
virtual TeamUISettings* Clone() const;
|
virtual TeamUISettings* Clone() const;
|
||||||
|
|
||||||
status_t AddSetting(Setting* setting);
|
bool SetValue(const char* settingID,
|
||||||
bool SetValue(const Setting* setting,
|
|
||||||
const BVariant& value);
|
const BVariant& value);
|
||||||
BVariant Value(const Setting* setting) const;
|
status_t Value(const char* settingID,
|
||||||
BVariant Value(const char* settingID) const;
|
BVariant& value) const;
|
||||||
|
|
||||||
GUITeamUISettings& operator=(const GUITeamUISettings& other);
|
GUITeamUISettings& operator=(const GUITeamUISettings& other);
|
||||||
// throws std::bad_alloc
|
// throws std::bad_alloc
|
||||||
|
|
||||||
private:
|
|
||||||
typedef BObjectList<Setting> SettingsList;
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
status_t _SetTo(const GUITeamUISettings& other);
|
status_t _SetTo(const GUITeamUISettings& other);
|
||||||
void _Unset();
|
void _Unset();
|
||||||
|
|
||||||
SettingsList fSettings;
|
|
||||||
BMessage fValues;
|
BMessage fValues;
|
||||||
BString fID;
|
BString fID;
|
||||||
};
|
};
|
||||||
|
@ -41,6 +41,10 @@ GraphicalUserInterface::Init(Team* team, UserInterfaceListener* listener)
|
|||||||
try {
|
try {
|
||||||
fTeamWindow = TeamWindow::Create(team, listener);
|
fTeamWindow = TeamWindow::Create(team, listener);
|
||||||
fTeamWindowMessenger = new BMessenger(fTeamWindow);
|
fTeamWindowMessenger = new BMessenger(fTeamWindow);
|
||||||
|
|
||||||
|
// start the message loop
|
||||||
|
fTeamWindow->Hide();
|
||||||
|
fTeamWindow->Show();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
// TODO: Notify the user!
|
// TODO: Notify the user!
|
||||||
ERROR("Error: Failed to create team window!\n");
|
ERROR("Error: Failed to create team window!\n");
|
||||||
@ -70,9 +74,9 @@ GraphicalUserInterface::Terminate()
|
|||||||
status_t
|
status_t
|
||||||
GraphicalUserInterface::LoadSettings(const TeamUISettings* settings)
|
GraphicalUserInterface::LoadSettings(const TeamUISettings* settings)
|
||||||
{
|
{
|
||||||
// TODO: restore settings
|
status_t result = fTeamWindow->LoadSettings((GUITeamUISettings*)settings);
|
||||||
|
|
||||||
return B_OK;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -83,7 +87,7 @@ GraphicalUserInterface::SaveSettings(TeamUISettings*& settings) const
|
|||||||
if (settings == NULL)
|
if (settings == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
// TODO: fill in settings
|
fTeamWindow->SaveSettings((GUITeamUISettings*)settings);
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include "CpuState.h"
|
#include "CpuState.h"
|
||||||
#include "DisassembledCode.h"
|
#include "DisassembledCode.h"
|
||||||
#include "FileSourceCode.h"
|
#include "FileSourceCode.h"
|
||||||
|
#include "GUITeamUISettings.h"
|
||||||
#include "Image.h"
|
#include "Image.h"
|
||||||
#include "ImageDebugInfo.h"
|
#include "ImageDebugInfo.h"
|
||||||
#include "InspectorWindow.h"
|
#include "InspectorWindow.h"
|
||||||
@ -334,6 +335,30 @@ TeamWindow::QuitRequested()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
TeamWindow::LoadSettings(const GUITeamUISettings* settings)
|
||||||
|
{
|
||||||
|
BVariant value;
|
||||||
|
status_t result = settings->Value("teamWindowFrame", value);
|
||||||
|
if (result == B_OK) {
|
||||||
|
BRect rect = value.ToRect();
|
||||||
|
ResizeTo(rect.Width(), rect.Height());
|
||||||
|
MoveTo(rect.left, rect.top);
|
||||||
|
}
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
TeamWindow::SaveSettings(GUITeamUISettings* settings)
|
||||||
|
{
|
||||||
|
status_t error = settings->SetValue("teamWindowFrame", Frame());
|
||||||
|
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TeamWindow::ThreadSelectionChanged(::Thread* thread)
|
TeamWindow::ThreadSelectionChanged(::Thread* thread)
|
||||||
{
|
{
|
||||||
|
@ -26,6 +26,7 @@ class BButton;
|
|||||||
class BMenuBar;
|
class BMenuBar;
|
||||||
class BStringView;
|
class BStringView;
|
||||||
class BTabView;
|
class BTabView;
|
||||||
|
class GUITeamUISettings;
|
||||||
class Image;
|
class Image;
|
||||||
class InspectorWindow;
|
class InspectorWindow;
|
||||||
class RegistersView;
|
class RegistersView;
|
||||||
@ -55,6 +56,12 @@ public:
|
|||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
virtual bool QuitRequested();
|
virtual bool QuitRequested();
|
||||||
|
|
||||||
|
status_t LoadSettings(
|
||||||
|
const GUITeamUISettings* settings);
|
||||||
|
status_t SaveSettings(
|
||||||
|
GUITeamUISettings* settings);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum ActiveSourceObject {
|
enum ActiveSourceObject {
|
||||||
ACTIVE_SOURCE_NONE,
|
ACTIVE_SOURCE_NONE,
|
||||||
|
Loading…
Reference in New Issue
Block a user