WebPositive Add option to start new session on startup
* Add settings file entry "start up policy", with two options: resume prior session, and start new session * Add dropdown to settings window to select option (defaulting to "resume prior session", which is the behaviour prior to this patch) * Add code to check setting on launch and open a new session, or reload the prior session as specified. * The "Start new session" option behaves in the same manner as opening a new window, following the user's already specified new window option * Related comment 2 of bug #14890 Change-Id: I46c33977bf3e9b943841f70050f890f51ac73bff Reviewed-on: https://review.haiku-os.org/c/1035 Reviewed-by: Stephan Aßmus <superstippi@gmx.de>
This commit is contained in:
parent
2f1a930a4a
commit
41ddfe2a44
@ -248,26 +248,34 @@ BrowserApp::ReadyToRun()
|
||||
fLaunchRefsMessage = NULL;
|
||||
}
|
||||
|
||||
// If no refs led to a new open page, restore previous session.
|
||||
// If no refs led to a new open page, open new session if set
|
||||
if (fSession->InitCheck() == B_OK && pagesCreated == 0) {
|
||||
BMessage archivedWindow;
|
||||
for (int i = 0; fSession->FindMessage("window", i, &archivedWindow) == B_OK;
|
||||
i++) {
|
||||
BRect frame = archivedWindow.FindRect("window frame");
|
||||
BString url;
|
||||
archivedWindow.FindString("tab", 0, &url);
|
||||
BrowserWindow* window = new(std::nothrow) BrowserWindow(frame,
|
||||
fSettings, url, fContext);
|
||||
const char* kSettingsKeyStartUpPolicy = "start up policy";
|
||||
uint32 fStartUpPolicy = fSettings->GetValue(kSettingsKeyStartUpPolicy,
|
||||
(uint32)ResumePriorSession);
|
||||
if (fStartUpPolicy == StartNewSession) {
|
||||
PostMessage(NEW_WINDOW);
|
||||
} else {
|
||||
// otherwise, restore previous session
|
||||
BMessage archivedWindow;
|
||||
for (int i = 0; fSession->FindMessage("window", i, &archivedWindow)
|
||||
== B_OK; i++) {
|
||||
BRect frame = archivedWindow.FindRect("window frame");
|
||||
BString url;
|
||||
archivedWindow.FindString("tab", 0, &url);
|
||||
BrowserWindow* window = new(std::nothrow) BrowserWindow(frame,
|
||||
fSettings, url, fContext);
|
||||
|
||||
if (window != NULL) {
|
||||
window->Show();
|
||||
pagesCreated++;
|
||||
|
||||
for (int j = 1; archivedWindow.FindString("tab", j, &url) == B_OK;
|
||||
j++) {
|
||||
printf("Create %d:%d\n", i, j);
|
||||
_CreateNewTab(window, url, false);
|
||||
if (window != NULL) {
|
||||
window->Show();
|
||||
pagesCreated++;
|
||||
|
||||
for (int j = 1; archivedWindow.FindString("tab", j, &url)
|
||||
== B_OK; j++) {
|
||||
printf("Create %d:%d\n", i, j);
|
||||
_CreateNewTab(window, url, false);
|
||||
pagesCreated++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -76,6 +76,11 @@ enum NewPagePolicy {
|
||||
CloneCurrentPage = 3
|
||||
};
|
||||
|
||||
enum StartUpPolicy {
|
||||
ResumePriorSession = 0,
|
||||
StartNewSession = 1
|
||||
};
|
||||
|
||||
enum {
|
||||
NEW_WINDOW = 'nwnd',
|
||||
NEW_TAB = 'ntab',
|
||||
|
@ -23,10 +23,10 @@ const char* kSettingsKeyShowHomeButton = "show home button";
|
||||
|
||||
const char* kSettingsKeyNewWindowPolicy = "new window policy";
|
||||
const char* kSettingsKeyNewTabPolicy = "new tab policy";
|
||||
const char* kSettingsKeyStartUpPolicy = "start up policy";
|
||||
const char* kSettingsKeyStartPageURL = "start page url";
|
||||
const char* kSettingsKeySearchPageURL = "search page url";
|
||||
|
||||
|
||||
const char* kDefaultDownloadPath = "/boot/home/Desktop/";
|
||||
const char* kDefaultStartPageURL
|
||||
= "file:///boot/home/config/settings/WebPositive/LoaderPages/Welcome";
|
||||
|
@ -21,6 +21,7 @@ extern const char* kSettingsKeyAutoHideInterfaceInFullscreenMode;
|
||||
extern const char* kSettingsKeyAutoHidePointer;
|
||||
extern const char* kSettingsKeyShowHomeButton;
|
||||
|
||||
extern const char* kSettingsKeyStartUpPolicy;
|
||||
extern const char* kSettingsKeyNewWindowPolicy;
|
||||
extern const char* kSettingsKeyNewTabPolicy;
|
||||
extern const char* kSettingsKeyStartPageURL;
|
||||
|
@ -51,6 +51,7 @@ enum {
|
||||
MSG_DOWNLOAD_FOLDER_CHANGED = 'dnfc',
|
||||
MSG_NEW_WINDOWS_BEHAVIOR_CHANGED = 'nwbc',
|
||||
MSG_NEW_TABS_BEHAVIOR_CHANGED = 'ntbc',
|
||||
MSG_START_UP_BEHAVIOR_CHANGED = 'subc',
|
||||
MSG_HISTORY_MENU_DAYS_CHANGED = 'digm',
|
||||
MSG_TAB_DISPLAY_BEHAVIOR_CHANGED = 'tdbc',
|
||||
MSG_AUTO_HIDE_INTERFACE_BEHAVIOR_CHANGED = 'ahic',
|
||||
@ -194,6 +195,7 @@ SettingsWindow::MessageReceived(BMessage* message)
|
||||
case MSG_START_PAGE_CHANGED:
|
||||
case MSG_SEARCH_PAGE_CHANGED:
|
||||
case MSG_DOWNLOAD_FOLDER_CHANGED:
|
||||
case MSG_START_UP_BEHAVIOR_CHANGED:
|
||||
case MSG_NEW_WINDOWS_BEHAVIOR_CHANGED:
|
||||
case MSG_NEW_TABS_BEHAVIOR_CHANGED:
|
||||
case MSG_HISTORY_MENU_DAYS_CHANGED:
|
||||
@ -276,6 +278,13 @@ SettingsWindow::_CreateGeneralPage(float spacing)
|
||||
fDownloadFolderControl->SetText(
|
||||
fSettings->GetValue(kSettingsKeyDownloadPath, kDefaultDownloadPath));
|
||||
|
||||
fStartUpBehaviorResumePriorSession = new BMenuItem(
|
||||
B_TRANSLATE("Resume prior session"),
|
||||
new BMessage(MSG_START_UP_BEHAVIOR_CHANGED));
|
||||
fStartUpBehaviorStartNewSession = new BMenuItem(
|
||||
B_TRANSLATE("Start new session"),
|
||||
new BMessage(MSG_START_UP_BEHAVIOR_CHANGED));
|
||||
|
||||
fNewWindowBehaviorOpenHomeItem = new BMenuItem(
|
||||
B_TRANSLATE("Open start page"),
|
||||
new BMessage(MSG_NEW_WINDOWS_BEHAVIOR_CHANGED));
|
||||
@ -303,6 +312,14 @@ SettingsWindow::_CreateGeneralPage(float spacing)
|
||||
|
||||
fNewWindowBehaviorOpenHomeItem->SetMarked(true);
|
||||
fNewTabBehaviorOpenBlankItem->SetMarked(true);
|
||||
fStartUpBehaviorResumePriorSession->SetMarked(true);
|
||||
|
||||
BPopUpMenu* startUpBehaviorMenu = new BPopUpMenu("Start up");
|
||||
startUpBehaviorMenu->AddItem(fStartUpBehaviorResumePriorSession);
|
||||
startUpBehaviorMenu->AddItem(fStartUpBehaviorStartNewSession);
|
||||
fStartUpBehaviorMenu = new BMenuField("start up behavior",
|
||||
B_TRANSLATE("Start up:"), startUpBehaviorMenu);
|
||||
|
||||
|
||||
BPopUpMenu* newWindowBehaviorMenu = new BPopUpMenu("New windows");
|
||||
newWindowBehaviorMenu->AddItem(fNewWindowBehaviorOpenHomeItem);
|
||||
@ -354,15 +371,18 @@ SettingsWindow::_CreateGeneralPage(float spacing)
|
||||
.Add(fSearchPageControl->CreateLabelLayoutItem(), 0, 1)
|
||||
.Add(fSearchPageControl->CreateTextViewLayoutItem(), 1, 1)
|
||||
|
||||
.Add(fNewWindowBehaviorMenu->CreateLabelLayoutItem(), 0, 2)
|
||||
.Add(fNewWindowBehaviorMenu->CreateMenuBarLayoutItem(), 1, 2)
|
||||
.Add(fStartUpBehaviorMenu->CreateLabelLayoutItem(), 0, 2)
|
||||
.Add(fStartUpBehaviorMenu->CreateMenuBarLayoutItem(), 1, 2)
|
||||
|
||||
.Add(fDownloadFolderControl->CreateLabelLayoutItem(), 0, 3)
|
||||
.Add(fDownloadFolderControl->CreateTextViewLayoutItem(), 1, 3)
|
||||
.Add(fNewWindowBehaviorMenu->CreateLabelLayoutItem(), 0, 3)
|
||||
.Add(fNewWindowBehaviorMenu->CreateMenuBarLayoutItem(), 1, 3)
|
||||
|
||||
.Add(fDownloadFolderControl->CreateLabelLayoutItem(), 0, 4)
|
||||
.Add(fDownloadFolderControl->CreateTextViewLayoutItem(), 1, 4)
|
||||
.Add(fChooseButton, 2, 3)
|
||||
|
||||
.Add(fNewTabBehaviorMenu->CreateLabelLayoutItem(), 0, 4)
|
||||
.Add(fNewTabBehaviorMenu->CreateMenuBarLayoutItem(), 1, 4)
|
||||
.Add(fNewTabBehaviorMenu->CreateLabelLayoutItem(), 0, 5)
|
||||
.Add(fNewTabBehaviorMenu->CreateMenuBarLayoutItem(), 1, 5)
|
||||
)
|
||||
.Add(BSpaceLayoutItem::CreateVerticalStrut(spacing))
|
||||
.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
|
||||
@ -552,6 +572,11 @@ SettingsWindow::_CanApplySettings() const
|
||||
canApply = canApply || (fDaysInHistory->Value()
|
||||
!= BrowsingHistory::DefaultInstance()->MaxHistoryItemAge());
|
||||
|
||||
// Start up policy
|
||||
canApply = canApply || (_StartUpPolicy()
|
||||
!= fSettings->GetValue(kSettingsKeyStartUpPolicy,
|
||||
(uint32)ResumePriorSession));
|
||||
|
||||
// New window policy
|
||||
canApply = canApply || (_NewWindowPolicy()
|
||||
!= fSettings->GetValue(kSettingsKeyNewWindowPolicy,
|
||||
@ -623,6 +648,7 @@ SettingsWindow::_ApplySettings()
|
||||
fShowHomeButton->Value() == B_CONTROL_ON);
|
||||
|
||||
// New page policies
|
||||
fSettings->SetValue(kSettingsKeyStartUpPolicy, _StartUpPolicy());
|
||||
fSettings->SetValue(kSettingsKeyNewWindowPolicy, _NewWindowPolicy());
|
||||
fSettings->SetValue(kSettingsKeyNewTabPolicy, _NewTabPolicy());
|
||||
|
||||
@ -705,6 +731,19 @@ SettingsWindow::_RevertSettings()
|
||||
fDaysInHistory->SetValue(
|
||||
BrowsingHistory::DefaultInstance()->MaxHistoryItemAge());
|
||||
|
||||
// Start Up policy
|
||||
uint32 startUpPolicy = fSettings->GetValue(kSettingsKeyStartUpPolicy,
|
||||
(uint32)ResumePriorSession);
|
||||
switch (startUpPolicy) {
|
||||
default:
|
||||
case ResumePriorSession:
|
||||
fStartUpBehaviorResumePriorSession->SetMarked(true);
|
||||
break;
|
||||
case StartNewSession:
|
||||
fStartUpBehaviorStartNewSession->SetMarked(true);
|
||||
break;
|
||||
}
|
||||
|
||||
// New window policy
|
||||
uint32 newWindowPolicy = fSettings->GetValue(kSettingsKeyNewWindowPolicy,
|
||||
(uint32)OpenStartPage);
|
||||
@ -827,6 +866,16 @@ SettingsWindow::_ValidateControlsEnabledStatus()
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
uint32
|
||||
SettingsWindow::_StartUpPolicy() const
|
||||
{
|
||||
uint32 startUpPolicy = ResumePriorSession;
|
||||
BMenuItem* markedItem = fStartUpBehaviorMenu->Menu()->FindMarked();
|
||||
if (markedItem == fStartUpBehaviorStartNewSession)
|
||||
startUpPolicy = StartNewSession;
|
||||
return startUpPolicy;
|
||||
}
|
||||
|
||||
uint32
|
||||
SettingsWindow::_NewWindowPolicy() const
|
||||
{
|
||||
|
@ -49,6 +49,7 @@ private:
|
||||
const BMessage* message);
|
||||
void _ValidateControlsEnabledStatus();
|
||||
|
||||
uint32 _StartUpPolicy() const;
|
||||
uint32 _NewWindowPolicy() const;
|
||||
uint32 _NewTabPolicy() const;
|
||||
|
||||
@ -74,6 +75,10 @@ private:
|
||||
BMenuItem* fNewTabBehaviorOpenSearchItem;
|
||||
BMenuItem* fNewTabBehaviorOpenBlankItem;
|
||||
|
||||
BMenuField* fStartUpBehaviorMenu;
|
||||
BMenuItem* fStartUpBehaviorResumePriorSession;
|
||||
BMenuItem* fStartUpBehaviorStartNewSession;
|
||||
|
||||
BSpinner* fDaysInHistory;
|
||||
BCheckBox* fShowTabsIfOnlyOnePage;
|
||||
BCheckBox* fAutoHideInterfaceInFullscreenMode;
|
||||
|
Loading…
Reference in New Issue
Block a user