Author: korli Date: 2010-01-10 23:57:21 +0100 (Sun, 10 Jan 2010) New Revision: 34998 Changeset: http://dev.haiku-os.org/changeset/34998/haiku Ticket: http://dev.haiku-os.org/ticket/4307 Modified: haiku/trunk/src/preferences/sounds/HWindow.cpp haiku/trunk/src/preferences/sounds/HWindow.h Log: * cleanup * save and restore window frame. Fixed bug #4307. Modified: haiku/trunk/src/preferences/sounds/HWindow.cpp =================================================================== --- haiku/trunk/src/preferences/sounds/HWindow.cpp 2010-01-10 22:53:00 UTC (rev 34997) +++ haiku/trunk/src/preferences/sounds/HWindow.cpp 2010-01-10 22:57:21 UTC (rev 34998) @@ -35,6 +35,9 @@ #include <Sound.h> +static const char kSettingsFile[] = "Sounds_Settings"; + + HWindow::HWindow(BRect rect, const char *name) : _inherited(rect, name, B_TITLED_WINDOW, 0), fFilePanel(NULL), @@ -49,6 +52,20 @@ fFilePanel = new BFilePanel(); fFilePanel->SetTarget(this); + + BPath path; + BMessage msg; + + if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) { + path.Append(kSettingsFile); + BFile file(path.Path(), B_READ_ONLY); + + if (file.InitCheck() == B_OK && msg.Unflatten(&file) == B_OK + && msg.FindRect("frame", &fFrame) == B_OK) { + MoveTo(fFrame.LeftTop()); + ResizeTo(fFrame.Width(), fFrame.Height()); + } + } } @@ -56,6 +73,18 @@ { delete fFilePanel; delete fPlayer; + + BPath path; + BMessage msg; + if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) { + path.Append(kSettingsFile); + BFile file(path.Path(), B_WRITE_ONLY|B_CREATE_FILE); + + if (file.InitCheck() == B_OK) { + msg.AddRect("frame", fFrame); + msg.Flatten(&file); + } + } } @@ -407,6 +436,8 @@ bool HWindow::QuitRequested() { + fFrame = Frame(); + fEventList->RemoveAll(); be_app->PostMessage(B_QUIT_REQUESTED); return true; Modified: haiku/trunk/src/preferences/sounds/HWindow.h =================================================================== --- haiku/trunk/src/preferences/sounds/HWindow.h 2010-01-10 22:53:00 UTC (rev 34997) +++ haiku/trunk/src/preferences/sounds/HWindow.h 2010-01-10 22:57:21 UTC (rev 34998) @@ -1,28 +1,25 @@ -// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ -// -// Copyright (c) 2003, OpenBeOS -// -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// -// File: HWindow.h -// Author: Jérôme Duval, Oliver Ruiz Dorantes, Atsushi Takamatsu -// Description: Sounds Preferences -// Created : November 24, 2003 -// -// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - +/* + * Copyright 2003-2010 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Jérôme Duval + * Oliver Ruiz Dorantes + * Atsushi Takamatsu + */ #ifndef __HWINDOW_H__ #define __HWINDOW_H__ + #include <Window.h> #include <FilePanel.h> #include <FileGameSound.h> + class HEventList; class HTypeList; + enum{ M_PLAY_MESSAGE = 'MPLM', M_STOP_MESSAGE = 'MSTO', @@ -35,23 +32,25 @@ M_OPEN_WITH = 'MOPW' }; -class HWindow :public BWindow { + +class HWindow : public BWindow { public: - HWindow(BRect rect ,const char* name); + HWindow(BRect rect, const char* name); protected: - virtual ~HWindow(); - virtual void MessageReceived(BMessage *message); - virtual bool QuitRequested(); - virtual void DispatchMessage(BMessage *message - ,BHandler *handler); - void InitGUI(); - void SetupMenuField(); - void Pulse(); + virtual ~HWindow(); + virtual void MessageReceived(BMessage *message); + virtual bool QuitRequested(); + virtual void DispatchMessage(BMessage *message, + BHandler *handler); + void InitGUI(); + void SetupMenuField(); + void Pulse(); private: - //HTypeList* fTypeList; - HEventList* fEventList; - typedef BWindow _inherited; - BFilePanel* fFilePanel; - BFileGameSound *fPlayer; + typedef BWindow _inherited; + HEventList* fEventList; + BFilePanel* fFilePanel; + BFileGameSound* fPlayer; + BRect fFrame; }; -#endif + +#endif // __HWINDOW_H__