- Add shortcut for About window.

- Created 'bootman' directory in config/settings.
- Added file open/save dialog.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24705 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Pfeiffer 2008-03-31 16:28:36 +00:00
parent a635399b07
commit 022152bc81
6 changed files with 124 additions and 10 deletions

View File

@ -42,7 +42,7 @@ BootManager::ReadyToRun()
void
BootManager::AboutRequested()
{
BAlert *alert = new BAlert("about", "Haiku Boot Manager\n"
BAlert *alert = new BAlert("about", "Haiku Boot Manager\n\n"
"\twritten by Michael Pfeiffer\n"
"\tCopyright 2008, Haiku Inc.\n", "Ok");
BTextView *view = alert->TextView();

View File

@ -47,7 +47,13 @@ BootManagerController::BootManagerController()
BPath path;
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path, true) == B_OK) {
path.Append("bootman/MBR");
fSettings.AddString("file", path.Path());
fSettings.AddString("file", path.Path());
// create directory
BPath parent;
if (path.GetParent(&parent) == B_OK) {
BDirectory directory;
directory.CreateDirectory(parent.Path(), NULL);
}
} else {
fSettings.AddString("file", "");
}
@ -266,7 +272,8 @@ BootManagerController::_CreateSaveMBRPage(BRect frame)
"you later wish to remove the boot menu, simply run the "
"bootman program and choose to 'Uninstall' option.";
FileSelectionPage* page = new FileSelectionPage(&fSettings, frame, "saveMBR", description.String());
FileSelectionPage* page = new FileSelectionPage(&fSettings, frame, "saveMBR", description.String(),
B_SAVE_PANEL);
return page;
}
@ -353,7 +360,8 @@ BootManagerController::_CreateUninstallPage(BRect frame)
"restore from. This is the file that was created when the "
"boot manager was first installed.";
FileSelectionPage* page = new FileSelectionPage(&fSettings, frame, "restoreMBR", description.String());
FileSelectionPage* page = new FileSelectionPage(&fSettings, frame, "restoreMBR", description.String(),
B_OPEN_PANEL);
return page;
}

View File

@ -29,7 +29,9 @@ BootManagerWindow::BootManagerWindow()
fWizardView = new WizardView(Bounds(), "wizard", B_FOLLOW_ALL);
AddChild(fWizardView);
fController.Initialize(fWizardView);
fController.Initialize(fWizardView);
AddShortcut('A', B_COMMAND_KEY, new BMessage(B_ABOUT_REQUESTED));
}
@ -50,6 +52,10 @@ BootManagerWindow::MessageReceived(BMessage* msg)
fController.Previous(fWizardView);
break;
case B_ABOUT_REQUESTED:
be_app_messenger.SendMessage(B_ABOUT_REQUESTED);
break;
default:
BWindow::MessageReceived(msg);
}

View File

@ -8,6 +8,7 @@
#include <Button.h>
#include <Path.h>
#include <RadioButton.h>
#include <TextControl.h>
#include <TextView.h>
@ -16,10 +17,15 @@
#include <String.h>
const uint32 kMsgOpenFilePanel = 'open';
FileSelectionPage::FileSelectionPage(BMessage* settings, BRect frame, const char* name,
const char* description)
const char* description, file_panel_mode mode)
: WizardPageView(settings, frame, name, B_FOLLOW_ALL,
B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE)
, fMode(mode)
, fFilePanel(NULL)
{
_BuildUI(description);
}
@ -38,6 +44,33 @@ FileSelectionPage::FrameResized(float width, float height)
}
void
FileSelectionPage::AttachedToWindow()
{
fSelect->SetTarget(this);
}
void
FileSelectionPage::MessageReceived(BMessage* message)
{
switch (message->what) {
case kMsgOpenFilePanel:
_OpenFilePanel();
break;
case B_REFS_RECEIVED:
case B_SAVE_REQUESTED:
_SetFileFromFilePanelMessage(message);
break;
case B_CANCEL:
_FilePanelCanceled();
break;
default:
WizardPageView::MessageReceived(message);
}
}
void
FileSelectionPage::PageCompleted()
{
@ -66,8 +99,7 @@ FileSelectionPage::_BuildUI(const char* description)
fFile->SetDivider(be_plain_font->StringWidth(fFile->Label()) + 5);
AddChild(fFile);
// TODO open file dialog
fSelect = new BButton(rect, "select", "Select", new BMessage(),
fSelect = new BButton(rect, "select", "Select", new BMessage(kMsgOpenFilePanel),
B_FOLLOW_RIGHT);
fSelect->ResizeToPreferred();
float left = rect.right - fSelect->Frame().Width();
@ -95,3 +127,60 @@ FileSelectionPage::_Layout()
fSelect->MoveTo(left, top);
}
void
FileSelectionPage::_OpenFilePanel()
{
if (fFilePanel != NULL)
return;
const entry_ref* directory = NULL;
entry_ref base;
BPath file(fFile->Text());
BPath parent;
if (file.GetParent(&parent) == B_OK &&
get_ref_for_path(parent.Path(), &base) == B_OK)
directory = &base;
BMessenger messenger(this);
fFilePanel = new BFilePanel(fMode, &messenger, directory,
B_FILE_NODE,
false,
NULL,
NULL,
true);
if (fMode == B_SAVE_PANEL && file.Leaf() != NULL)
fFilePanel->SetSaveText(file.Leaf());
fFilePanel->Show();
}
void
FileSelectionPage::_SetFileFromFilePanelMessage(BMessage* message)
{
if (message->what == B_SAVE_REQUESTED) {
entry_ref directory;
BString name;
message->FindRef("directory", &directory);
message->FindString("name", &name);
BPath path(&directory);
if (path.Append(name.String()) == B_OK)
fFile->SetText(path.Path());
} else {
entry_ref entryRef;
message->FindRef("refs", &entryRef);
BEntry entry(&entryRef);
BPath path;
if (entry.GetPath(&path) == B_OK)
fFile->SetText(path.Path());
}
}
void
FileSelectionPage::_FilePanelCanceled()
{
delete fFilePanel;
fFilePanel = NULL;
}

View File

@ -8,6 +8,8 @@
#include "WizardPageView.h"
#include <FilePanel.h>
class BButton;
class BTextControl;
@ -16,10 +18,13 @@ class BTextView;
class FileSelectionPage : public WizardPageView
{
public:
FileSelectionPage(BMessage* settings, BRect frame, const char* name, const char* description);
FileSelectionPage(BMessage* settings, BRect frame, const char* name, const char* description,
file_panel_mode mode);
virtual ~FileSelectionPage();
virtual void FrameResized(float width, float height);
virtual void AttachedToWindow();
virtual void MessageReceived(BMessage* message);
virtual void PageCompleted();
@ -27,7 +32,13 @@ private:
void _BuildUI(const char* description);
void _Layout();
void _OpenFilePanel();
void _SetFileFromFilePanelMessage(BMessage* message);
void _FilePanelCanceled();
file_panel_mode fMode;
BFilePanel* fFilePanel;
BTextView* fDescription;
BTextControl* fFile;
BButton* fSelect;

View File

@ -23,7 +23,7 @@ TestBootDrive::~TestBootDrive()
bool
TestBootDrive::IsBootMenuInstalled()
{
return true;
return false;
}