* Moved some settings keys into new files SettingsKeys.h/cpp to make it less
likely to introduce erros with spelling settings keys wrong somewhere. * Introduced new setting for the behavior if tabs should show at all if only one page is showing in a window. Defaults to on, i.e. the previous behavior. git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@393 94f232f2-1747-11df-bad5-a5bfde151594
This commit is contained in:
parent
bb68c7f66d
commit
d5f0e82b84
@ -167,7 +167,7 @@ BrowserApp::ReadyToRun()
|
||||
delete fLaunchRefsMessage;
|
||||
fLaunchRefsMessage = 0;
|
||||
} else {
|
||||
BrowserWindow* window = new BrowserWindow(fLastWindowFrame);
|
||||
BrowserWindow* window = new BrowserWindow(fLastWindowFrame, fSettings);
|
||||
window->Show();
|
||||
}
|
||||
PostMessage(PRELOAD_BROWSING_HISTORY);
|
||||
@ -327,7 +327,7 @@ BrowserApp::_CreateNewWindow(const BString& url)
|
||||
if (!BScreen().Frame().Contains(fLastWindowFrame))
|
||||
fLastWindowFrame.OffsetTo(50, 50);
|
||||
|
||||
BrowserWindow* window = new BrowserWindow(fLastWindowFrame);
|
||||
BrowserWindow* window = new BrowserWindow(fLastWindowFrame, fSettings);
|
||||
window->Show();
|
||||
if (url.Length())
|
||||
window->CurrentWebView()->LoadURL(url.String());
|
||||
|
@ -38,6 +38,8 @@
|
||||
#include "BrowsingHistory.h"
|
||||
#include "IconButton.h"
|
||||
#include "NavMenu.h"
|
||||
#include "SettingsKeys.h"
|
||||
#include "SettingsMessage.h"
|
||||
#include "TextControlCompleter.h"
|
||||
#include "WebPage.h"
|
||||
#include "WebTabView.h"
|
||||
@ -257,14 +259,21 @@ private:
|
||||
// #pragma mark - BrowserWindow
|
||||
|
||||
|
||||
BrowserWindow::BrowserWindow(BRect frame, ToolbarPolicy toolbarPolicy,
|
||||
BWebView* webView)
|
||||
BrowserWindow::BrowserWindow(BRect frame, SettingsMessage* appSettings,
|
||||
ToolbarPolicy toolbarPolicy, BWebView* webView)
|
||||
:
|
||||
BWebWindow(frame, kApplicationName,
|
||||
B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
|
||||
B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS),
|
||||
fZoomTextOnly(true)
|
||||
fAppSettings(appSettings),
|
||||
fZoomTextOnly(true),
|
||||
fShowTabsIfSinglePageOpen(true)
|
||||
{
|
||||
fAppSettings->AddListener(BMessenger(this));
|
||||
// fZoomTextOnly = fAppSettings->GetValue("zoom text only", fZoomTextOnly);
|
||||
fShowTabsIfSinglePageOpen = fAppSettings->GetValue(
|
||||
kSettingsKeyShowTabsIfSinglePageOpen, fShowTabsIfSinglePageOpen);
|
||||
|
||||
BMessage* newTabMessage = new BMessage(NEW_TAB);
|
||||
newTabMessage->AddString("url", "");
|
||||
newTabMessage->AddPointer("window", this);
|
||||
@ -461,6 +470,7 @@ BrowserWindow::BrowserWindow(BRect frame, ToolbarPolicy toolbarPolicy,
|
||||
|
||||
BrowserWindow::~BrowserWindow()
|
||||
{
|
||||
fAppSettings->RemoveListener(BMessenger(this));
|
||||
delete fURLAutoCompleter;
|
||||
delete fTabManager;
|
||||
}
|
||||
@ -512,7 +522,8 @@ BrowserWindow::MessageReceived(BMessage* message)
|
||||
case RELOAD:
|
||||
CurrentWebView()->Reload();
|
||||
break;
|
||||
case GOTO_URL: {
|
||||
case GOTO_URL:
|
||||
{
|
||||
BString url;
|
||||
if (message->FindString("url", &url) != B_OK)
|
||||
url = fURLTextControl->Text();
|
||||
@ -548,7 +559,8 @@ BrowserWindow::MessageReceived(BMessage* message)
|
||||
_ShowBookmarks();
|
||||
break;
|
||||
|
||||
case B_REFS_RECEIVED: {
|
||||
case B_REFS_RECEIVED:
|
||||
{
|
||||
// Currently the only source of these messages is the bookmarks menu.
|
||||
// Filter refs into URLs, this also gets rid of refs for folders.
|
||||
// For clicks on sub-folders in the bookmarks menu, we have Tracker
|
||||
@ -556,16 +568,14 @@ BrowserWindow::MessageReceived(BMessage* message)
|
||||
entry_ref ref;
|
||||
uint32 addedCount = 0;
|
||||
for (int32 i = 0; message->FindRef("refs", i, &ref) == B_OK; i++) {
|
||||
printf("B_REFS_RECEIVED: %s\n", ref.name);
|
||||
BEntry entry(&ref);
|
||||
uint32 addedSubCount = 0;
|
||||
if (entry.IsDirectory()) {
|
||||
BDirectory directory(&entry);
|
||||
printf(" directory ok\n");
|
||||
_AddBookmarkURLsRecursively(directory, message, addedSubCount);
|
||||
_AddBookmarkURLsRecursively(directory, message,
|
||||
addedSubCount);
|
||||
} else {
|
||||
BFile file(&ref, B_READ_ONLY);
|
||||
printf(" file ok\n");
|
||||
BString url;
|
||||
if (_ReadURLAttr(file, url)) {
|
||||
message->AddString("url", url.String());
|
||||
@ -594,10 +604,12 @@ printf(" file ok\n");
|
||||
be_app->PostMessage(message);
|
||||
break;
|
||||
}
|
||||
case B_SIMPLE_DATA: {
|
||||
case B_SIMPLE_DATA:
|
||||
{
|
||||
// User possibly dropped files on this window.
|
||||
// If there is more than one entry_ref, let the app handle it (open one
|
||||
// new page per ref). If there is one ref, open it in this window.
|
||||
// If there is more than one entry_ref, let the app handle it
|
||||
// (open one new page per ref). If there is one ref, open it in
|
||||
// this window.
|
||||
type_code type;
|
||||
int32 countFound;
|
||||
if (message->GetInfo("refs", &type, &countFound) != B_OK
|
||||
@ -632,8 +644,8 @@ printf(" file ok\n");
|
||||
case ZOOM_TEXT_ONLY:
|
||||
fZoomTextOnly = !fZoomTextOnly;
|
||||
fZoomTextOnlyMenuItem->SetMarked(fZoomTextOnly);
|
||||
// TODO: Would be nice to have an instant update if the page is already
|
||||
// zoomed.
|
||||
// TODO: Would be nice to have an instant update if the page is
|
||||
// already zoomed.
|
||||
break;
|
||||
|
||||
case TEXT_FIND_NEXT:
|
||||
@ -671,7 +683,8 @@ printf(" file ok\n");
|
||||
PostMessage(B_QUIT_REQUESTED);
|
||||
break;
|
||||
|
||||
case SELECT_TAB: {
|
||||
case SELECT_TAB:
|
||||
{
|
||||
int32 index;
|
||||
if (message->FindInt32("tab index", &index) == B_OK
|
||||
&& fTabManager->SelectedTabIndex() != index
|
||||
@ -682,8 +695,10 @@ printf(" file ok\n");
|
||||
break;
|
||||
}
|
||||
|
||||
case TAB_CHANGED: {
|
||||
// This message may be received also when the last tab closed, i.e. with index == -1.
|
||||
case TAB_CHANGED:
|
||||
{
|
||||
// This message may be received also when the last tab closed,
|
||||
// i.e. with index == -1.
|
||||
int32 index;
|
||||
if (message->FindInt32("tab index", &index) != B_OK)
|
||||
index = -1;
|
||||
@ -691,6 +706,22 @@ printf(" file ok\n");
|
||||
break;
|
||||
}
|
||||
|
||||
case SETTINGS_VALUE_CHANGED:
|
||||
{
|
||||
BString name;
|
||||
if (message->FindString("name", &name) != B_OK)
|
||||
break;
|
||||
bool flag;
|
||||
if (name == kSettingsKeyShowTabsIfSinglePageOpen
|
||||
&& message->FindBool("value", &flag) == B_OK) {
|
||||
if (fShowTabsIfSinglePageOpen != flag) {
|
||||
fShowTabsIfSinglePageOpen = flag;
|
||||
_UpdateTabGroupVisibility();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
BWebWindow::MessageReceived(message);
|
||||
break;
|
||||
@ -898,7 +929,7 @@ BrowserWindow::NewPageCreated(BWebView* view, BRect windowFrame,
|
||||
bool modalDialog, bool resizable)
|
||||
{
|
||||
if (windowFrame.IsValid()) {
|
||||
BrowserWindow* window = new BrowserWindow(windowFrame,
|
||||
BrowserWindow* window = new BrowserWindow(windowFrame, fAppSettings,
|
||||
DoNotHaveToolbar, view);
|
||||
window->Show();
|
||||
} else
|
||||
@ -1166,7 +1197,8 @@ void
|
||||
BrowserWindow::_UpdateTabGroupVisibility()
|
||||
{
|
||||
if (Lock()) {
|
||||
// fTabGroup->SetVisible(fTabManager->CountTabs() > 1);
|
||||
fTabGroup->SetVisible(fShowTabsIfSinglePageOpen
|
||||
|| fTabManager->CountTabs() > 1);
|
||||
fTabManager->SetCloseButtonsAvailable(fTabManager->CountTabs() > 1);
|
||||
Unlock();
|
||||
}
|
||||
|
@ -45,10 +45,11 @@ class BPath;
|
||||
class BStatusBar;
|
||||
class BStringView;
|
||||
class BTextControl;
|
||||
class BWebView;
|
||||
class IconButton;
|
||||
class SettingsMessage;
|
||||
class TabManager;
|
||||
class TextControlCompleter;
|
||||
class BWebView;
|
||||
|
||||
enum ToolbarPolicy {
|
||||
HaveToolbar,
|
||||
@ -70,6 +71,7 @@ enum {
|
||||
class BrowserWindow : public BWebWindow {
|
||||
public:
|
||||
BrowserWindow(BRect frame,
|
||||
SettingsMessage* appSettings,
|
||||
ToolbarPolicy = HaveToolbar,
|
||||
BWebView* webView = NULL);
|
||||
virtual ~BrowserWindow();
|
||||
@ -144,7 +146,6 @@ private:
|
||||
private:
|
||||
BMenu* fGoMenu;
|
||||
BMenuItem* fZoomTextOnlyMenuItem;
|
||||
bool fZoomTextOnly;
|
||||
IconButton* fBackButton;
|
||||
IconButton* fForwardButton;
|
||||
IconButton* fStopButton;
|
||||
@ -163,6 +164,10 @@ private:
|
||||
BTextControl* fFindTextControl;
|
||||
BCheckBox* fFindCaseSensitiveCheckBox;
|
||||
TabManager* fTabManager;
|
||||
|
||||
SettingsMessage* fAppSettings;
|
||||
bool fZoomTextOnly;
|
||||
bool fShowTabsIfSinglePageOpen;
|
||||
};
|
||||
|
||||
|
||||
|
32
src/apps/webpositive/SettingsKeys.cpp
Normal file
32
src/apps/webpositive/SettingsKeys.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Stephan Aßmus <superstippi@gmx.de>
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "SettingsKeys.h"
|
||||
|
||||
const char* kSettingsKeyDownloadPath = "download path";
|
||||
const char* kSettingsKeyShowTabsIfSinglePageOpen
|
||||
= "show tabs if single page open";
|
37
src/apps/webpositive/SettingsKeys.h
Normal file
37
src/apps/webpositive/SettingsKeys.h
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Stephan Aßmus <superstippi@gmx.de>
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef SETTINGS_KEYS_H
|
||||
#define SETTINGS_KEYS_H
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
|
||||
extern const char* kSettingsKeyDownloadPath;
|
||||
extern const char* kSettingsKeyShowTabsIfSinglePageOpen;
|
||||
|
||||
|
||||
#endif // SETTINGS_KEYS_H
|
@ -27,6 +27,7 @@
|
||||
#include "SettingsWindow.h"
|
||||
|
||||
#include <Button.h>
|
||||
#include <CheckBox.h>
|
||||
#include <ControlLook.h>
|
||||
#include <GridLayoutBuilder.h>
|
||||
#include <GroupLayout.h>
|
||||
@ -48,6 +49,7 @@
|
||||
#include "BrowserApp.h"
|
||||
#include "BrowsingHistory.h"
|
||||
#include "FontSelectionView.h"
|
||||
#include "SettingsKeys.h"
|
||||
#include "SettingsMessage.h"
|
||||
#include "WebSettings.h"
|
||||
|
||||
@ -64,6 +66,7 @@ enum {
|
||||
MSG_DOWNLOAD_FOLDER_CHANGED = 'dnfc',
|
||||
MSG_NEW_PAGE_BEHAVIOR_CHANGED = 'npbc',
|
||||
MSG_GO_MENU_DAYS_CHANGED = 'digm',
|
||||
MSG_TAB_DISPLAY_BEHAVIOR_CHANGED = 'tdbc',
|
||||
};
|
||||
|
||||
static const int32 kDefaultFontSize = 14;
|
||||
@ -155,19 +158,25 @@ SettingsWindow::MessageReceived(BMessage* message)
|
||||
_RevertSettings();
|
||||
break;
|
||||
|
||||
case MSG_STANDARD_FONT_SIZE_SELECTED: {
|
||||
case MSG_STANDARD_FONT_SIZE_SELECTED:
|
||||
{
|
||||
int32 size = _SizesMenuValue(fStandardSizesMenu->Menu());
|
||||
fStandardFontView->SetSize(size);
|
||||
fSerifFontView->SetSize(size);
|
||||
fSansSerifFontView->SetSize(size);
|
||||
break;
|
||||
}
|
||||
case MSG_FIXED_FONT_SIZE_SELECTED: {
|
||||
case MSG_FIXED_FONT_SIZE_SELECTED:
|
||||
{
|
||||
int32 size = _SizesMenuValue(fFixedSizesMenu->Menu());
|
||||
fFixedFontView->SetSize(size);
|
||||
break;
|
||||
}
|
||||
|
||||
case MSG_TAB_DISPLAY_BEHAVIOR_CHANGED:
|
||||
// TODO: Some settings could change live, some others not?
|
||||
break;
|
||||
|
||||
default:
|
||||
BWindow::MessageReceived(message);
|
||||
break;
|
||||
@ -236,6 +245,11 @@ fNewPageBehaviorMenu->SetEnabled(false);
|
||||
for (uchar i = '9' + 1; i <= 128; i++)
|
||||
fDaysInGoMenuControl->TextView()->DisallowChar(i);
|
||||
|
||||
fShowTabsIfOnlyOnePage = new BCheckBox("show tabs if only one page",
|
||||
TR("Show tabs if only page is open."),
|
||||
new BMessage(MSG_TAB_DISPLAY_BEHAVIOR_CHANGED));
|
||||
fShowTabsIfOnlyOnePage->SetValue(B_CONTROL_ON);
|
||||
|
||||
BView* view = BGridLayoutBuilder(spacing / 2, spacing / 2)
|
||||
.Add(fDownloadFolderControl->CreateLabelLayoutItem(), 0, 1)
|
||||
.Add(fDownloadFolderControl->CreateTextViewLayoutItem(), 1, 1)
|
||||
@ -246,7 +260,9 @@ fNewPageBehaviorMenu->SetEnabled(false);
|
||||
.Add(fDaysInGoMenuControl->CreateLabelLayoutItem(), 0, 3)
|
||||
.Add(fDaysInGoMenuControl->CreateTextViewLayoutItem(), 1, 3)
|
||||
|
||||
.Add(BSpaceLayoutItem::CreateHorizontalStrut(spacing), 0, 4, 2)
|
||||
.Add(fShowTabsIfOnlyOnePage, 0, 4, 2)
|
||||
|
||||
.Add(BSpaceLayoutItem::CreateHorizontalStrut(spacing), 0, 5, 2)
|
||||
|
||||
.SetInsets(spacing, spacing, spacing, spacing)
|
||||
;
|
||||
@ -323,7 +339,9 @@ SettingsWindow::_ApplySettings()
|
||||
fDaysInGoMenuControl->SetText(text.String());
|
||||
BrowsingHistory::DefaultInstance()->SetMaxHistoryItemAge(maxHistoryAge);
|
||||
|
||||
fSettings->SetValue("download path", fDownloadFolderControl->Text());
|
||||
fSettings->SetValue(kSettingsKeyDownloadPath, fDownloadFolderControl->Text());
|
||||
fSettings->SetValue(kSettingsKeyShowTabsIfSinglePageOpen,
|
||||
fShowTabsIfOnlyOnePage->Value() == B_CONTROL_ON);
|
||||
|
||||
// Store fond settings
|
||||
fSettings->SetValue("standard font", fStandardFontView->Font());
|
||||
@ -354,6 +372,11 @@ SettingsWindow::_ApplySettings()
|
||||
void
|
||||
SettingsWindow::_RevertSettings()
|
||||
{
|
||||
fDownloadFolderControl->SetText(
|
||||
fSettings->GetValue(kSettingsKeyDownloadPath, ""));
|
||||
fShowTabsIfOnlyOnePage->SetValue(
|
||||
fSettings->GetValue(kSettingsKeyShowTabsIfSinglePageOpen, true));
|
||||
|
||||
int32 defaultFontSize = fSettings->GetValue("standard font size",
|
||||
kDefaultFontSize);
|
||||
int32 defaultFixedFontSize = fSettings->GetValue("fixed font size",
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <Window.h>
|
||||
|
||||
class BButton;
|
||||
class BCheckBox;
|
||||
class BMenu;
|
||||
class BMenuField;
|
||||
class BMenuItem;
|
||||
@ -73,6 +74,7 @@ private:
|
||||
BMenuItem* fNewPageBehaviorOpenSearchItem;
|
||||
BMenuItem* fNewPageBehaviorOpenBlankItem;
|
||||
BTextControl* fDaysInGoMenuControl;
|
||||
BCheckBox* fShowTabsIfOnlyOnePage;
|
||||
|
||||
FontSelectionView* fStandardFontView;
|
||||
FontSelectionView* fSerifFontView;
|
||||
|
Loading…
Reference in New Issue
Block a user