* 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;
|
||||
}
|
||||
|
||||
Activate();
|
||||
|
||||
// if requested, stop the given thread
|
||||
if (threadID >= 0) {
|
||||
if (stopInMain) {
|
||||
@ -548,6 +546,7 @@ TeamDebugger::MessageReceived(BMessage* message)
|
||||
|
||||
case MSG_LOAD_SETTINGS:
|
||||
_LoadSettings();
|
||||
Activate();
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -64,6 +64,7 @@ GUITeamUISettings::SetTo(const BMessage& archive)
|
||||
status_t
|
||||
GUITeamUISettings::WriteTo(BMessage& archive) const
|
||||
{
|
||||
archive.MakeEmpty();
|
||||
status_t error = archive.AddString("ID", fID);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
@ -81,7 +82,7 @@ GUITeamUISettings::WriteTo(BMessage& archive) const
|
||||
TeamUISettings*
|
||||
GUITeamUISettings::Clone() const
|
||||
{
|
||||
GUITeamUISettings* settings = new(std::nothrow) GUITeamUISettings();
|
||||
GUITeamUISettings* settings = new(std::nothrow) GUITeamUISettings(fID);
|
||||
|
||||
if (settings == 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
|
||||
GUITeamUISettings::SetValue(const Setting* setting, const BVariant& value)
|
||||
GUITeamUISettings::SetValue(const char* settingID, const BVariant& value)
|
||||
{
|
||||
const char* fieldName = setting->ID();
|
||||
fValues.RemoveName(fieldName);
|
||||
fValues.RemoveName(settingID);
|
||||
|
||||
return value.AddToMessage(fValues, fieldName) == B_OK;
|
||||
return value.AddToMessage(fValues, settingID) == B_OK;
|
||||
}
|
||||
|
||||
|
||||
BVariant
|
||||
GUITeamUISettings::Value(const Setting* setting) const
|
||||
status_t
|
||||
GUITeamUISettings::Value(const char* settingID, BVariant &value) const
|
||||
{
|
||||
BVariant value;
|
||||
|
||||
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;
|
||||
return value.SetFromMessage(fValues, settingID);
|
||||
}
|
||||
|
||||
|
||||
@ -163,13 +127,7 @@ GUITeamUISettings::_SetTo(const GUITeamUISettings& other)
|
||||
{
|
||||
_Unset();
|
||||
|
||||
for (int32 i = 0; i < other.fSettings.CountItems(); i++) {
|
||||
Setting* setting = other.fSettings.ItemAt(i);
|
||||
if (!fSettings.AddItem(setting))
|
||||
return B_NO_MEMORY;
|
||||
|
||||
setting->AcquireReference();
|
||||
}
|
||||
fID = other.fID;
|
||||
|
||||
fValues = other.fValues;
|
||||
|
||||
@ -182,9 +140,5 @@ GUITeamUISettings::_Unset()
|
||||
{
|
||||
fID.Truncate(0);
|
||||
|
||||
for (int32 i = 0; i < fSettings.CountItems(); i++)
|
||||
fSettings.ItemAt(i)->ReleaseReference();
|
||||
|
||||
fSettings.MakeEmpty();
|
||||
fValues.MakeEmpty();
|
||||
}
|
||||
|
@ -30,23 +30,19 @@ public:
|
||||
virtual status_t WriteTo(BMessage& archive) const;
|
||||
virtual TeamUISettings* Clone() const;
|
||||
|
||||
status_t AddSetting(Setting* setting);
|
||||
bool SetValue(const Setting* setting,
|
||||
bool SetValue(const char* settingID,
|
||||
const BVariant& value);
|
||||
BVariant Value(const Setting* setting) const;
|
||||
BVariant Value(const char* settingID) const;
|
||||
status_t Value(const char* settingID,
|
||||
BVariant& value) const;
|
||||
|
||||
GUITeamUISettings& operator=(const GUITeamUISettings& other);
|
||||
// throws std::bad_alloc
|
||||
|
||||
private:
|
||||
typedef BObjectList<Setting> SettingsList;
|
||||
private:
|
||||
|
||||
status_t _SetTo(const GUITeamUISettings& other);
|
||||
void _Unset();
|
||||
|
||||
SettingsList fSettings;
|
||||
BMessage fValues;
|
||||
BString fID;
|
||||
};
|
||||
|
@ -41,6 +41,10 @@ GraphicalUserInterface::Init(Team* team, UserInterfaceListener* listener)
|
||||
try {
|
||||
fTeamWindow = TeamWindow::Create(team, listener);
|
||||
fTeamWindowMessenger = new BMessenger(fTeamWindow);
|
||||
|
||||
// start the message loop
|
||||
fTeamWindow->Hide();
|
||||
fTeamWindow->Show();
|
||||
} catch (...) {
|
||||
// TODO: Notify the user!
|
||||
ERROR("Error: Failed to create team window!\n");
|
||||
@ -70,9 +74,9 @@ GraphicalUserInterface::Terminate()
|
||||
status_t
|
||||
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)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
// TODO: fill in settings
|
||||
fTeamWindow->SaveSettings((GUITeamUISettings*)settings);
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "CpuState.h"
|
||||
#include "DisassembledCode.h"
|
||||
#include "FileSourceCode.h"
|
||||
#include "GUITeamUISettings.h"
|
||||
#include "Image.h"
|
||||
#include "ImageDebugInfo.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
|
||||
TeamWindow::ThreadSelectionChanged(::Thread* thread)
|
||||
{
|
||||
|
@ -26,6 +26,7 @@ class BButton;
|
||||
class BMenuBar;
|
||||
class BStringView;
|
||||
class BTabView;
|
||||
class GUITeamUISettings;
|
||||
class Image;
|
||||
class InspectorWindow;
|
||||
class RegistersView;
|
||||
@ -55,6 +56,12 @@ public:
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
virtual bool QuitRequested();
|
||||
|
||||
status_t LoadSettings(
|
||||
const GUITeamUISettings* settings);
|
||||
status_t SaveSettings(
|
||||
GUITeamUISettings* settings);
|
||||
|
||||
|
||||
private:
|
||||
enum ActiveSourceObject {
|
||||
ACTIVE_SOURCE_NONE,
|
||||
|
Loading…
Reference in New Issue
Block a user