- 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:
parent
a635399b07
commit
022152bc81
@ -42,7 +42,7 @@ BootManager::ReadyToRun()
|
|||||||
void
|
void
|
||||||
BootManager::AboutRequested()
|
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"
|
"\twritten by Michael Pfeiffer\n"
|
||||||
"\tCopyright 2008, Haiku Inc.\n", "Ok");
|
"\tCopyright 2008, Haiku Inc.\n", "Ok");
|
||||||
BTextView *view = alert->TextView();
|
BTextView *view = alert->TextView();
|
||||||
|
@ -48,6 +48,12 @@ BootManagerController::BootManagerController()
|
|||||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path, true) == B_OK) {
|
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path, true) == B_OK) {
|
||||||
path.Append("bootman/MBR");
|
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 {
|
} else {
|
||||||
fSettings.AddString("file", "");
|
fSettings.AddString("file", "");
|
||||||
}
|
}
|
||||||
@ -266,7 +272,8 @@ BootManagerController::_CreateSaveMBRPage(BRect frame)
|
|||||||
"you later wish to remove the boot menu, simply run the "
|
"you later wish to remove the boot menu, simply run the "
|
||||||
"bootman program and choose to 'Uninstall' option.";
|
"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;
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -353,7 +360,8 @@ BootManagerController::_CreateUninstallPage(BRect frame)
|
|||||||
"restore from. This is the file that was created when the "
|
"restore from. This is the file that was created when the "
|
||||||
"boot manager was first installed.";
|
"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;
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +30,8 @@ BootManagerWindow::BootManagerWindow()
|
|||||||
AddChild(fWizardView);
|
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);
|
fController.Previous(fWizardView);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case B_ABOUT_REQUESTED:
|
||||||
|
be_app_messenger.SendMessage(B_ABOUT_REQUESTED);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BWindow::MessageReceived(msg);
|
BWindow::MessageReceived(msg);
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
|
#include <Path.h>
|
||||||
#include <RadioButton.h>
|
#include <RadioButton.h>
|
||||||
#include <TextControl.h>
|
#include <TextControl.h>
|
||||||
#include <TextView.h>
|
#include <TextView.h>
|
||||||
@ -16,10 +17,15 @@
|
|||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
|
|
||||||
|
const uint32 kMsgOpenFilePanel = 'open';
|
||||||
|
|
||||||
|
|
||||||
FileSelectionPage::FileSelectionPage(BMessage* settings, BRect frame, const char* name,
|
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,
|
: WizardPageView(settings, frame, name, B_FOLLOW_ALL,
|
||||||
B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE)
|
B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE)
|
||||||
|
, fMode(mode)
|
||||||
|
, fFilePanel(NULL)
|
||||||
{
|
{
|
||||||
_BuildUI(description);
|
_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
|
void
|
||||||
FileSelectionPage::PageCompleted()
|
FileSelectionPage::PageCompleted()
|
||||||
{
|
{
|
||||||
@ -66,8 +99,7 @@ FileSelectionPage::_BuildUI(const char* description)
|
|||||||
fFile->SetDivider(be_plain_font->StringWidth(fFile->Label()) + 5);
|
fFile->SetDivider(be_plain_font->StringWidth(fFile->Label()) + 5);
|
||||||
AddChild(fFile);
|
AddChild(fFile);
|
||||||
|
|
||||||
// TODO open file dialog
|
fSelect = new BButton(rect, "select", "Select", new BMessage(kMsgOpenFilePanel),
|
||||||
fSelect = new BButton(rect, "select", "Select", new BMessage(),
|
|
||||||
B_FOLLOW_RIGHT);
|
B_FOLLOW_RIGHT);
|
||||||
fSelect->ResizeToPreferred();
|
fSelect->ResizeToPreferred();
|
||||||
float left = rect.right - fSelect->Frame().Width();
|
float left = rect.right - fSelect->Frame().Width();
|
||||||
@ -95,3 +127,60 @@ FileSelectionPage::_Layout()
|
|||||||
fSelect->MoveTo(left, top);
|
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;
|
||||||
|
}
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
#include "WizardPageView.h"
|
#include "WizardPageView.h"
|
||||||
|
|
||||||
|
#include <FilePanel.h>
|
||||||
|
|
||||||
|
|
||||||
class BButton;
|
class BButton;
|
||||||
class BTextControl;
|
class BTextControl;
|
||||||
@ -16,10 +18,13 @@ class BTextView;
|
|||||||
class FileSelectionPage : public WizardPageView
|
class FileSelectionPage : public WizardPageView
|
||||||
{
|
{
|
||||||
public:
|
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 ~FileSelectionPage();
|
||||||
|
|
||||||
virtual void FrameResized(float width, float height);
|
virtual void FrameResized(float width, float height);
|
||||||
|
virtual void AttachedToWindow();
|
||||||
|
virtual void MessageReceived(BMessage* message);
|
||||||
|
|
||||||
virtual void PageCompleted();
|
virtual void PageCompleted();
|
||||||
|
|
||||||
@ -27,6 +32,12 @@ private:
|
|||||||
|
|
||||||
void _BuildUI(const char* description);
|
void _BuildUI(const char* description);
|
||||||
void _Layout();
|
void _Layout();
|
||||||
|
void _OpenFilePanel();
|
||||||
|
void _SetFileFromFilePanelMessage(BMessage* message);
|
||||||
|
void _FilePanelCanceled();
|
||||||
|
|
||||||
|
file_panel_mode fMode;
|
||||||
|
BFilePanel* fFilePanel;
|
||||||
|
|
||||||
BTextView* fDescription;
|
BTextView* fDescription;
|
||||||
BTextControl* fFile;
|
BTextControl* fFile;
|
||||||
|
@ -23,7 +23,7 @@ TestBootDrive::~TestBootDrive()
|
|||||||
bool
|
bool
|
||||||
TestBootDrive::IsBootMenuInstalled()
|
TestBootDrive::IsBootMenuInstalled()
|
||||||
{
|
{
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user