* 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;
|
||||
}
|
||||
@ -501,199 +511,220 @@ void
|
||||
BrowserWindow::MessageReceived(BMessage* message)
|
||||
{
|
||||
switch (message->what) {
|
||||
case OPEN_LOCATION:
|
||||
if (fURLTextControl) {
|
||||
if (fURLTextControl->TextView()->IsFocus())
|
||||
fURLTextControl->TextView()->SelectAll();
|
||||
else
|
||||
fURLTextControl->MakeFocus(true);
|
||||
}
|
||||
break;
|
||||
case RELOAD:
|
||||
CurrentWebView()->Reload();
|
||||
break;
|
||||
case GOTO_URL: {
|
||||
BString url;
|
||||
if (message->FindString("url", &url) != B_OK)
|
||||
url = fURLTextControl->Text();
|
||||
fTabManager->SetTabIcon(CurrentWebView(), NULL);
|
||||
CurrentWebView()->LoadURL(url.String());
|
||||
break;
|
||||
}
|
||||
case GO_BACK:
|
||||
CurrentWebView()->GoBack();
|
||||
break;
|
||||
case GO_FORWARD:
|
||||
CurrentWebView()->GoForward();
|
||||
break;
|
||||
case STOP:
|
||||
CurrentWebView()->StopLoading();
|
||||
break;
|
||||
|
||||
case CLEAR_HISTORY: {
|
||||
BrowsingHistory* history = BrowsingHistory::DefaultInstance();
|
||||
if (history->CountItems() == 0)
|
||||
case OPEN_LOCATION:
|
||||
if (fURLTextControl) {
|
||||
if (fURLTextControl->TextView()->IsFocus())
|
||||
fURLTextControl->TextView()->SelectAll();
|
||||
else
|
||||
fURLTextControl->MakeFocus(true);
|
||||
}
|
||||
break;
|
||||
case RELOAD:
|
||||
CurrentWebView()->Reload();
|
||||
break;
|
||||
case GOTO_URL:
|
||||
{
|
||||
BString url;
|
||||
if (message->FindString("url", &url) != B_OK)
|
||||
url = fURLTextControl->Text();
|
||||
fTabManager->SetTabIcon(CurrentWebView(), NULL);
|
||||
CurrentWebView()->LoadURL(url.String());
|
||||
break;
|
||||
BAlert* alert = new BAlert("Confirmation", "Do you really want to "
|
||||
"clear the browsing history?", "Clear", "Cancel");
|
||||
if (alert->Go() == 0)
|
||||
history->Clear();
|
||||
break;
|
||||
}
|
||||
|
||||
case CREATE_BOOKMARK:
|
||||
_CreateBookmark();
|
||||
break;
|
||||
case SHOW_BOOKMARKS:
|
||||
_ShowBookmarks();
|
||||
break;
|
||||
|
||||
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
|
||||
// open the corresponding folder.
|
||||
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);
|
||||
} else {
|
||||
BFile file(&ref, B_READ_ONLY);
|
||||
printf(" file ok\n");
|
||||
BString url;
|
||||
if (_ReadURLAttr(file, url)) {
|
||||
message->AddString("url", url.String());
|
||||
addedSubCount++;
|
||||
}
|
||||
}
|
||||
if (addedSubCount == 0) {
|
||||
// Don't know what to do with this entry, just pass it
|
||||
// on to the system to handle. Note that this may result
|
||||
// in us opening other supported files via the application
|
||||
// mechanism.
|
||||
be_roster->Launch(&ref);
|
||||
}
|
||||
addedCount += addedSubCount;
|
||||
}
|
||||
message->RemoveName("refs");
|
||||
if (addedCount > 10) {
|
||||
BString string;
|
||||
string << "Do you want to open " << addedCount;
|
||||
string << " bookmarks all at once?";
|
||||
BAlert* alert = new BAlert("Open bookmarks confirmation",
|
||||
string.String(), "Cancel", "Open all");
|
||||
if (alert->Go() == 0)
|
||||
case GO_BACK:
|
||||
CurrentWebView()->GoBack();
|
||||
break;
|
||||
case GO_FORWARD:
|
||||
CurrentWebView()->GoForward();
|
||||
break;
|
||||
case STOP:
|
||||
CurrentWebView()->StopLoading();
|
||||
break;
|
||||
|
||||
case CLEAR_HISTORY: {
|
||||
BrowsingHistory* history = BrowsingHistory::DefaultInstance();
|
||||
if (history->CountItems() == 0)
|
||||
break;
|
||||
}
|
||||
be_app->PostMessage(message);
|
||||
break;
|
||||
}
|
||||
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.
|
||||
type_code type;
|
||||
int32 countFound;
|
||||
if (message->GetInfo("refs", &type, &countFound) != B_OK
|
||||
|| type != B_REF_TYPE) {
|
||||
BAlert* alert = new BAlert("Confirmation", "Do you really want to "
|
||||
"clear the browsing history?", "Clear", "Cancel");
|
||||
if (alert->Go() == 0)
|
||||
history->Clear();
|
||||
break;
|
||||
}
|
||||
if (countFound > 1) {
|
||||
message->what = B_REFS_RECEIVED;
|
||||
|
||||
case CREATE_BOOKMARK:
|
||||
_CreateBookmark();
|
||||
break;
|
||||
case SHOW_BOOKMARKS:
|
||||
_ShowBookmarks();
|
||||
break;
|
||||
|
||||
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
|
||||
// open the corresponding folder.
|
||||
entry_ref ref;
|
||||
uint32 addedCount = 0;
|
||||
for (int32 i = 0; message->FindRef("refs", i, &ref) == B_OK; i++) {
|
||||
BEntry entry(&ref);
|
||||
uint32 addedSubCount = 0;
|
||||
if (entry.IsDirectory()) {
|
||||
BDirectory directory(&entry);
|
||||
_AddBookmarkURLsRecursively(directory, message,
|
||||
addedSubCount);
|
||||
} else {
|
||||
BFile file(&ref, B_READ_ONLY);
|
||||
BString url;
|
||||
if (_ReadURLAttr(file, url)) {
|
||||
message->AddString("url", url.String());
|
||||
addedSubCount++;
|
||||
}
|
||||
}
|
||||
if (addedSubCount == 0) {
|
||||
// Don't know what to do with this entry, just pass it
|
||||
// on to the system to handle. Note that this may result
|
||||
// in us opening other supported files via the application
|
||||
// mechanism.
|
||||
be_roster->Launch(&ref);
|
||||
}
|
||||
addedCount += addedSubCount;
|
||||
}
|
||||
message->RemoveName("refs");
|
||||
if (addedCount > 10) {
|
||||
BString string;
|
||||
string << "Do you want to open " << addedCount;
|
||||
string << " bookmarks all at once?";
|
||||
BAlert* alert = new BAlert("Open bookmarks confirmation",
|
||||
string.String(), "Cancel", "Open all");
|
||||
if (alert->Go() == 0)
|
||||
break;
|
||||
}
|
||||
be_app->PostMessage(message);
|
||||
break;
|
||||
}
|
||||
entry_ref ref;
|
||||
if (message->FindRef("refs", &ref) != B_OK)
|
||||
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.
|
||||
type_code type;
|
||||
int32 countFound;
|
||||
if (message->GetInfo("refs", &type, &countFound) != B_OK
|
||||
|| type != B_REF_TYPE) {
|
||||
break;
|
||||
}
|
||||
if (countFound > 1) {
|
||||
message->what = B_REFS_RECEIVED;
|
||||
be_app->PostMessage(message);
|
||||
break;
|
||||
}
|
||||
entry_ref ref;
|
||||
if (message->FindRef("refs", &ref) != B_OK)
|
||||
break;
|
||||
BEntry entry(&ref, true);
|
||||
BPath path;
|
||||
if (!entry.Exists() || entry.GetPath(&path) != B_OK)
|
||||
break;
|
||||
CurrentWebView()->LoadURL(path.Path());
|
||||
break;
|
||||
BEntry entry(&ref, true);
|
||||
BPath path;
|
||||
if (!entry.Exists() || entry.GetPath(&path) != B_OK)
|
||||
break;
|
||||
CurrentWebView()->LoadURL(path.Path());
|
||||
break;
|
||||
}
|
||||
|
||||
case ZOOM_FACTOR_INCREASE:
|
||||
CurrentWebView()->IncreaseZoomFactor(fZoomTextOnly);
|
||||
break;
|
||||
case ZOOM_FACTOR_DECREASE:
|
||||
CurrentWebView()->DecreaseZoomFactor(fZoomTextOnly);
|
||||
break;
|
||||
case ZOOM_FACTOR_RESET:
|
||||
CurrentWebView()->ResetZoomFactor();
|
||||
break;
|
||||
case ZOOM_TEXT_ONLY:
|
||||
fZoomTextOnly = !fZoomTextOnly;
|
||||
fZoomTextOnlyMenuItem->SetMarked(fZoomTextOnly);
|
||||
// TODO: Would be nice to have an instant update if the page is already
|
||||
// zoomed.
|
||||
break;
|
||||
|
||||
case TEXT_FIND_NEXT:
|
||||
CurrentWebView()->FindString(fFindTextControl->Text(), true,
|
||||
fFindCaseSensitiveCheckBox->Value());
|
||||
break;
|
||||
case TEXT_FIND_PREVIOUS:
|
||||
CurrentWebView()->FindString(fFindTextControl->Text(), false,
|
||||
fFindCaseSensitiveCheckBox->Value());
|
||||
break;
|
||||
case TEXT_SHOW_FIND_GROUP:
|
||||
if (!fFindGroup->IsVisible())
|
||||
fFindGroup->SetVisible(true);
|
||||
fFindTextControl->MakeFocus(true);
|
||||
break;
|
||||
case TEXT_HIDE_FIND_GROUP:
|
||||
if (fFindGroup->IsVisible())
|
||||
fFindGroup->SetVisible(false);
|
||||
break;
|
||||
|
||||
case SHOW_DOWNLOAD_WINDOW:
|
||||
case SHOW_SETTINGS_WINDOW:
|
||||
message->AddUInt32("workspaces", Workspaces());
|
||||
be_app->PostMessage(message);
|
||||
break;
|
||||
|
||||
case CLOSE_TAB:
|
||||
if (fTabManager->CountTabs() > 1) {
|
||||
int32 index;
|
||||
if (message->FindInt32("tab index", &index) != B_OK)
|
||||
index = fTabManager->SelectedTabIndex();
|
||||
_ShutdownTab(index);
|
||||
_UpdateTabGroupVisibility();
|
||||
} else
|
||||
PostMessage(B_QUIT_REQUESTED);
|
||||
break;
|
||||
|
||||
case SELECT_TAB: {
|
||||
int32 index;
|
||||
if (message->FindInt32("tab index", &index) == B_OK
|
||||
&& fTabManager->SelectedTabIndex() != index
|
||||
&& fTabManager->CountTabs() > index) {
|
||||
fTabManager->SelectTab(index);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ZOOM_FACTOR_INCREASE:
|
||||
CurrentWebView()->IncreaseZoomFactor(fZoomTextOnly);
|
||||
break;
|
||||
case ZOOM_FACTOR_DECREASE:
|
||||
CurrentWebView()->DecreaseZoomFactor(fZoomTextOnly);
|
||||
break;
|
||||
case ZOOM_FACTOR_RESET:
|
||||
CurrentWebView()->ResetZoomFactor();
|
||||
break;
|
||||
case ZOOM_TEXT_ONLY:
|
||||
fZoomTextOnly = !fZoomTextOnly;
|
||||
fZoomTextOnlyMenuItem->SetMarked(fZoomTextOnly);
|
||||
// TODO: Would be nice to have an instant update if the page is
|
||||
// already zoomed.
|
||||
break;
|
||||
|
||||
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;
|
||||
_TabChanged(index);
|
||||
break;
|
||||
}
|
||||
case TEXT_FIND_NEXT:
|
||||
CurrentWebView()->FindString(fFindTextControl->Text(), true,
|
||||
fFindCaseSensitiveCheckBox->Value());
|
||||
break;
|
||||
case TEXT_FIND_PREVIOUS:
|
||||
CurrentWebView()->FindString(fFindTextControl->Text(), false,
|
||||
fFindCaseSensitiveCheckBox->Value());
|
||||
break;
|
||||
case TEXT_SHOW_FIND_GROUP:
|
||||
if (!fFindGroup->IsVisible())
|
||||
fFindGroup->SetVisible(true);
|
||||
fFindTextControl->MakeFocus(true);
|
||||
break;
|
||||
case TEXT_HIDE_FIND_GROUP:
|
||||
if (fFindGroup->IsVisible())
|
||||
fFindGroup->SetVisible(false);
|
||||
break;
|
||||
|
||||
default:
|
||||
BWebWindow::MessageReceived(message);
|
||||
break;
|
||||
case SHOW_DOWNLOAD_WINDOW:
|
||||
case SHOW_SETTINGS_WINDOW:
|
||||
message->AddUInt32("workspaces", Workspaces());
|
||||
be_app->PostMessage(message);
|
||||
break;
|
||||
|
||||
case CLOSE_TAB:
|
||||
if (fTabManager->CountTabs() > 1) {
|
||||
int32 index;
|
||||
if (message->FindInt32("tab index", &index) != B_OK)
|
||||
index = fTabManager->SelectedTabIndex();
|
||||
_ShutdownTab(index);
|
||||
_UpdateTabGroupVisibility();
|
||||
} else
|
||||
PostMessage(B_QUIT_REQUESTED);
|
||||
break;
|
||||
|
||||
case SELECT_TAB:
|
||||
{
|
||||
int32 index;
|
||||
if (message->FindInt32("tab index", &index) == B_OK
|
||||
&& fTabManager->SelectedTabIndex() != index
|
||||
&& fTabManager->CountTabs() > index) {
|
||||
fTabManager->SelectTab(index);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
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;
|
||||
_TabChanged(index);
|
||||
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;
|
||||
@ -144,33 +147,39 @@ void
|
||||
SettingsWindow::MessageReceived(BMessage* message)
|
||||
{
|
||||
switch (message->what) {
|
||||
case MSG_APPLY:
|
||||
_ApplySettings();
|
||||
break;
|
||||
case MSG_CANCEL:
|
||||
_RevertSettings();
|
||||
PostMessage(B_QUIT_REQUESTED);
|
||||
break;
|
||||
case MSG_REVERT:
|
||||
_RevertSettings();
|
||||
break;
|
||||
case MSG_APPLY:
|
||||
_ApplySettings();
|
||||
break;
|
||||
case MSG_CANCEL:
|
||||
_RevertSettings();
|
||||
PostMessage(B_QUIT_REQUESTED);
|
||||
break;
|
||||
case MSG_REVERT:
|
||||
_RevertSettings();
|
||||
break;
|
||||
|
||||
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: {
|
||||
int32 size = _SizesMenuValue(fFixedSizesMenu->Menu());
|
||||
fFixedFontView->SetSize(size);
|
||||
break;
|
||||
}
|
||||
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:
|
||||
{
|
||||
int32 size = _SizesMenuValue(fFixedSizesMenu->Menu());
|
||||
fFixedFontView->SetSize(size);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
BWindow::MessageReceived(message);
|
||||
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