Manually update to the r238 state, so that we can rebase next commits on top of it
Original commit message of r238:
Split up WebPositive from HaikuLauncher. HaikuLauncher is back to it's simple
self. WebPositive uses a new WebPositive folder in config/settings. Otherwise,
everything should be as before. LauncherWindow and LauncherApp have been renamed
and cleaned up for the Haiku coding style.
This commit is contained in:
@@ -27,17 +27,16 @@
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "LauncherApp.h"
|
||||
#include "BrowserApp.h"
|
||||
|
||||
#include "BrowserWindow.h"
|
||||
#include "DownloadWindow.h"
|
||||
#include "FrameView.h"
|
||||
#include "GraphicsContext.h"
|
||||
#include "LauncherWindow.h"
|
||||
#include "WebPage.h"
|
||||
#include "WebView.h"
|
||||
#include "WebViewConstants.h"
|
||||
#include <Alert.h>
|
||||
#include <Autolock.h>
|
||||
#include <Directory.h>
|
||||
#include <Entry.h>
|
||||
#include <File.h>
|
||||
#include <FindDirectory.h>
|
||||
@@ -45,35 +44,46 @@
|
||||
#include <Screen.h>
|
||||
#include <stdio.h>
|
||||
|
||||
extern const char* kApplicationSignature = "application/x-vnd.RJL-HaikuLauncher";
|
||||
|
||||
const char* kApplicationSignature = "application/x-vnd.Haiku-WebPositive";
|
||||
const char* kApplicationName = "WebPositive";
|
||||
|
||||
|
||||
enum {
|
||||
LOAD_AT_STARTING = 'lost'
|
||||
};
|
||||
|
||||
|
||||
LauncherApp::LauncherApp()
|
||||
BrowserApp::BrowserApp()
|
||||
: BApplication(kApplicationSignature)
|
||||
, m_windowCount(0)
|
||||
, m_lastWindowFrame(100, 100, 700, 750)
|
||||
, m_launchRefsMessage(0)
|
||||
, m_initialized(false)
|
||||
, m_downloadWindow(0)
|
||||
, fWindowCount(0)
|
||||
, fLastWindowFrame(100, 100, 700, 750)
|
||||
, fLaunchRefsMessage(0)
|
||||
, fInitialized(false)
|
||||
, fDownloadWindow(0)
|
||||
{
|
||||
}
|
||||
|
||||
LauncherApp::~LauncherApp()
|
||||
|
||||
BrowserApp::~BrowserApp()
|
||||
{
|
||||
delete m_launchRefsMessage;
|
||||
delete fLaunchRefsMessage;
|
||||
}
|
||||
|
||||
void LauncherApp::AboutRequested()
|
||||
|
||||
void
|
||||
BrowserApp::AboutRequested()
|
||||
{
|
||||
BAlert* alert = new BAlert("About HaikuLauncher",
|
||||
"For testing WebKit...\n\nby Ryan Leavengood", "Sweet!");
|
||||
BAlert* alert = new BAlert("About WebPositive",
|
||||
"WebPositive\n\nby Ryan Leavengood, Andrea Anzani, "
|
||||
"Maxime Simone, Michael Lotz, Rene Gollent and Stephan Aßmus",
|
||||
"Sweet!");
|
||||
alert->Go();
|
||||
}
|
||||
|
||||
void LauncherApp::ArgvReceived(int32 argc, char** argv)
|
||||
|
||||
void
|
||||
BrowserApp::ArgvReceived(int32 argc, char** argv)
|
||||
{
|
||||
for (int i = 1; i < argc; i++) {
|
||||
const char* url = argv[i];
|
||||
@@ -83,12 +93,14 @@ void LauncherApp::ArgvReceived(int32 argc, char** argv)
|
||||
url = path.Path();
|
||||
BMessage message(LOAD_AT_STARTING);
|
||||
message.AddString("url", url);
|
||||
message.AddBool("new window", m_initialized || i > 1);
|
||||
message.AddBool("new window", fInitialized || i > 1);
|
||||
PostMessage(&message);
|
||||
}
|
||||
}
|
||||
|
||||
void LauncherApp::ReadyToRun()
|
||||
|
||||
void
|
||||
BrowserApp::ReadyToRun()
|
||||
{
|
||||
// Since we will essentially run the GUI...
|
||||
set_thread_priority(Thread(), B_DISPLAY_PRIORITY);
|
||||
@@ -97,34 +109,36 @@ void LauncherApp::ReadyToRun()
|
||||
BWebPage::SetCacheModel(B_WEBKIT_CACHE_MODEL_WEB_BROWSER);
|
||||
|
||||
BFile settingsFile;
|
||||
BRect windowFrameFromSettings = m_lastWindowFrame;
|
||||
BRect windowFrameFromSettings = fLastWindowFrame;
|
||||
BRect downloadWindowFrame(100, 100, 300, 250);
|
||||
bool showDownloads = false;
|
||||
if (openSettingsFile(settingsFile, B_READ_ONLY)) {
|
||||
if (_OpenSettingsFile(settingsFile, B_READ_ONLY)) {
|
||||
BMessage settingsArchive;
|
||||
settingsArchive.Unflatten(&settingsFile);
|
||||
settingsArchive.FindRect("window frame", &windowFrameFromSettings);
|
||||
settingsArchive.FindRect("downloads window frame", &downloadWindowFrame);
|
||||
settingsArchive.FindBool("show downloads", &showDownloads);
|
||||
}
|
||||
m_lastWindowFrame = windowFrameFromSettings;
|
||||
fLastWindowFrame = windowFrameFromSettings;
|
||||
|
||||
m_downloadWindow = new DownloadWindow(downloadWindowFrame, showDownloads);
|
||||
fDownloadWindow = new DownloadWindow(downloadWindowFrame, showDownloads);
|
||||
|
||||
m_initialized = true;
|
||||
fInitialized = true;
|
||||
|
||||
if (m_launchRefsMessage) {
|
||||
RefsReceived(m_launchRefsMessage);
|
||||
delete m_launchRefsMessage;
|
||||
m_launchRefsMessage = 0;
|
||||
if (fLaunchRefsMessage) {
|
||||
RefsReceived(fLaunchRefsMessage);
|
||||
delete fLaunchRefsMessage;
|
||||
fLaunchRefsMessage = 0;
|
||||
} else {
|
||||
LauncherWindow* window = new LauncherWindow(m_lastWindowFrame,
|
||||
BMessenger(m_downloadWindow));
|
||||
BrowserWindow* window = new BrowserWindow(fLastWindowFrame,
|
||||
BMessenger(fDownloadWindow));
|
||||
window->Show();
|
||||
}
|
||||
}
|
||||
|
||||
void LauncherApp::MessageReceived(BMessage* message)
|
||||
|
||||
void
|
||||
BrowserApp::MessageReceived(BMessage* message)
|
||||
{
|
||||
switch (message->what) {
|
||||
case LOAD_AT_STARTING: {
|
||||
@@ -133,9 +147,9 @@ void LauncherApp::MessageReceived(BMessage* message)
|
||||
break;
|
||||
bool openNewWindow = false;
|
||||
message->FindBool("new window", &openNewWindow);
|
||||
LauncherWindow* webWindow = NULL;
|
||||
BrowserWindow* webWindow = NULL;
|
||||
for (int i = 0; BWindow* window = WindowAt(i); i++) {
|
||||
webWindow = dynamic_cast<LauncherWindow*>(window);
|
||||
webWindow = dynamic_cast<BrowserWindow*>(window);
|
||||
if (!webWindow)
|
||||
continue;
|
||||
if (!openNewWindow) {
|
||||
@@ -148,7 +162,7 @@ void LauncherApp::MessageReceived(BMessage* message)
|
||||
// to quit anyway...
|
||||
if (openNewWindow) {
|
||||
// open a new window with an offset to the last window
|
||||
newWindow(url);
|
||||
_CreateNewWindow(url);
|
||||
} else {
|
||||
// load the URL in the first window
|
||||
webWindow->CurrentWebView()->LoadURL(url.String());
|
||||
@@ -157,45 +171,45 @@ void LauncherApp::MessageReceived(BMessage* message)
|
||||
break;
|
||||
}
|
||||
case B_SILENT_RELAUNCH:
|
||||
newWindow("");
|
||||
_CreateNewWindow("");
|
||||
break;
|
||||
case NEW_WINDOW: {
|
||||
BString url;
|
||||
if (message->FindString("url", &url) != B_OK)
|
||||
break;
|
||||
newWindow(url);
|
||||
_CreateNewWindow(url);
|
||||
break;
|
||||
}
|
||||
case NEW_TAB: {
|
||||
LauncherWindow* window;
|
||||
BrowserWindow* window;
|
||||
if (message->FindPointer("window", reinterpret_cast<void**>(&window)) != B_OK)
|
||||
break;
|
||||
BString url;
|
||||
message->FindString("url", &url);
|
||||
bool select = false;
|
||||
message->FindBool("select", &select);
|
||||
newTab(window, url, select);
|
||||
_CreateNewTab(window, url, select);
|
||||
break;
|
||||
}
|
||||
case WINDOW_OPENED:
|
||||
m_windowCount++;
|
||||
fWindowCount++;
|
||||
break;
|
||||
case WINDOW_CLOSED:
|
||||
m_windowCount--;
|
||||
message->FindRect("window frame", &m_lastWindowFrame);
|
||||
if (m_windowCount <= 0)
|
||||
fWindowCount--;
|
||||
message->FindRect("window frame", &fLastWindowFrame);
|
||||
if (fWindowCount <= 0)
|
||||
PostMessage(B_QUIT_REQUESTED);
|
||||
break;
|
||||
|
||||
case SHOW_DOWNLOAD_WINDOW: {
|
||||
BAutolock _(m_downloadWindow);
|
||||
BAutolock _(fDownloadWindow);
|
||||
uint32 workspaces;
|
||||
if (message->FindUInt32("workspaces", &workspaces) == B_OK)
|
||||
m_downloadWindow->SetWorkspaces(workspaces);
|
||||
if (m_downloadWindow->IsHidden())
|
||||
m_downloadWindow->Show();
|
||||
fDownloadWindow->SetWorkspaces(workspaces);
|
||||
if (fDownloadWindow->IsHidden())
|
||||
fDownloadWindow->Show();
|
||||
else
|
||||
m_downloadWindow->Activate();
|
||||
fDownloadWindow->Activate();
|
||||
}
|
||||
|
||||
default:
|
||||
@@ -204,11 +218,13 @@ void LauncherApp::MessageReceived(BMessage* message)
|
||||
}
|
||||
}
|
||||
|
||||
void LauncherApp::RefsReceived(BMessage* message)
|
||||
|
||||
void
|
||||
BrowserApp::RefsReceived(BMessage* message)
|
||||
{
|
||||
if (!m_initialized) {
|
||||
delete m_launchRefsMessage;
|
||||
m_launchRefsMessage = new BMessage(*message);
|
||||
if (!fInitialized) {
|
||||
delete fLaunchRefsMessage;
|
||||
fLaunchRefsMessage = new BMessage(*message);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -222,20 +238,22 @@ void LauncherApp::RefsReceived(BMessage* message)
|
||||
continue;
|
||||
BString url;
|
||||
url << path.Path();
|
||||
newWindow(url);
|
||||
_CreateNewWindow(url);
|
||||
}
|
||||
}
|
||||
|
||||
bool LauncherApp::QuitRequested()
|
||||
|
||||
bool
|
||||
BrowserApp::QuitRequested()
|
||||
{
|
||||
for (int i = 0; BWindow* window = WindowAt(i); i++) {
|
||||
LauncherWindow* webWindow = dynamic_cast<LauncherWindow*>(window);
|
||||
BrowserWindow* webWindow = dynamic_cast<BrowserWindow*>(window);
|
||||
if (!webWindow)
|
||||
continue;
|
||||
if (!webWindow->Lock())
|
||||
continue;
|
||||
if (webWindow->QuitRequested()) {
|
||||
m_lastWindowFrame = webWindow->Frame();
|
||||
fLastWindowFrame = webWindow->Frame();
|
||||
webWindow->Quit();
|
||||
i--;
|
||||
} else {
|
||||
@@ -245,13 +263,13 @@ bool LauncherApp::QuitRequested()
|
||||
}
|
||||
|
||||
BFile settingsFile;
|
||||
if (openSettingsFile(settingsFile, B_CREATE_FILE | B_ERASE_FILE | B_WRITE_ONLY)) {
|
||||
if (_OpenSettingsFile(settingsFile, B_CREATE_FILE | B_ERASE_FILE | B_WRITE_ONLY)) {
|
||||
BMessage settingsArchive;
|
||||
settingsArchive.AddRect("window frame", m_lastWindowFrame);
|
||||
if (m_downloadWindow->Lock()) {
|
||||
settingsArchive.AddRect("downloads window frame", m_downloadWindow->Frame());
|
||||
settingsArchive.AddBool("show downloads", !m_downloadWindow->IsHidden());
|
||||
m_downloadWindow->Unlock();
|
||||
settingsArchive.AddRect("window frame", fLastWindowFrame);
|
||||
if (fDownloadWindow->Lock()) {
|
||||
settingsArchive.AddRect("downloads window frame", fDownloadWindow->Frame());
|
||||
settingsArchive.AddBool("show downloads", !fDownloadWindow->IsHidden());
|
||||
fDownloadWindow->Unlock();
|
||||
}
|
||||
settingsArchive.Flatten(&settingsFile);
|
||||
}
|
||||
@@ -259,42 +277,55 @@ bool LauncherApp::QuitRequested()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LauncherApp::openSettingsFile(BFile& file, uint32 mode)
|
||||
|
||||
bool
|
||||
BrowserApp::_OpenSettingsFile(BFile& file, uint32 mode)
|
||||
{
|
||||
BPath path;
|
||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK
|
||||
|| path.Append("HaikuLauncher") != B_OK) {
|
||||
|| path.Append(kApplicationName) != B_OK
|
||||
|| create_directory(path.Path(), 0777) != B_OK
|
||||
|| path.Append("Application") != B_OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return file.SetTo(path.Path(), mode) == B_OK;
|
||||
}
|
||||
|
||||
void LauncherApp::newWindow(const BString& url)
|
||||
{
|
||||
m_lastWindowFrame.OffsetBy(20, 20);
|
||||
if (!BScreen().Frame().Contains(m_lastWindowFrame))
|
||||
m_lastWindowFrame.OffsetTo(50, 50);
|
||||
|
||||
LauncherWindow* window = new LauncherWindow(m_lastWindowFrame,
|
||||
BMessenger(m_downloadWindow));
|
||||
void
|
||||
BrowserApp::_CreateNewWindow(const BString& url)
|
||||
{
|
||||
fLastWindowFrame.OffsetBy(20, 20);
|
||||
if (!BScreen().Frame().Contains(fLastWindowFrame))
|
||||
fLastWindowFrame.OffsetTo(50, 50);
|
||||
|
||||
BrowserWindow* window = new BrowserWindow(fLastWindowFrame,
|
||||
BMessenger(fDownloadWindow));
|
||||
window->Show();
|
||||
if (url.Length())
|
||||
window->CurrentWebView()->LoadURL(url.String());
|
||||
}
|
||||
|
||||
void LauncherApp::newTab(LauncherWindow* window, const BString& url, bool select)
|
||||
|
||||
void
|
||||
BrowserApp::_CreateNewTab(BrowserWindow* window, const BString& url,
|
||||
bool select)
|
||||
{
|
||||
if (!window->Lock())
|
||||
return;
|
||||
window->newTab(url, select);
|
||||
window->CreateNewTab(url, select);
|
||||
window->Unlock();
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
int main(int, char**)
|
||||
|
||||
int
|
||||
main(int, char**)
|
||||
{
|
||||
new LauncherApp();
|
||||
new BrowserApp();
|
||||
be_app->Run();
|
||||
delete be_app;
|
||||
|
||||
|
||||
@@ -25,43 +25,49 @@
|
||||
* (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 BROWSER_APP_H
|
||||
#define BROWSER_APP_H
|
||||
|
||||
#ifndef LauncherApp_h
|
||||
#define LauncherApp_h
|
||||
|
||||
#include <Application.h>
|
||||
#include <Rect.h>
|
||||
|
||||
class BFile;
|
||||
class DownloadWindow;
|
||||
class LauncherWindow;
|
||||
class BrowserWindow;
|
||||
|
||||
class LauncherApp : public BApplication {
|
||||
|
||||
class BrowserApp : public BApplication {
|
||||
public:
|
||||
LauncherApp();
|
||||
virtual ~LauncherApp();
|
||||
BrowserApp();
|
||||
virtual ~BrowserApp();
|
||||
|
||||
virtual void AboutRequested();
|
||||
virtual void ArgvReceived(int32, char**);
|
||||
virtual void MessageReceived(BMessage*);
|
||||
virtual void RefsReceived(BMessage*);
|
||||
virtual void ArgvReceived(int32 agrc, char** argv);
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
virtual void RefsReceived(BMessage* message);
|
||||
virtual void ReadyToRun();
|
||||
virtual bool QuitRequested();
|
||||
|
||||
private:
|
||||
bool openSettingsFile(BFile& file, uint32 mode);
|
||||
void newWindow(const BString& url);
|
||||
void newTab(LauncherWindow* window, const BString& url, bool select);
|
||||
bool _OpenSettingsFile(BFile& file, uint32 mode);
|
||||
void _CreateNewWindow(const BString& url);
|
||||
void _CreateNewTab(BrowserWindow* window,
|
||||
const BString& url, bool select);
|
||||
|
||||
int m_windowCount;
|
||||
BRect m_lastWindowFrame;
|
||||
BMessage* m_launchRefsMessage;
|
||||
bool m_initialized;
|
||||
private:
|
||||
int fWindowCount;
|
||||
BRect fLastWindowFrame;
|
||||
BMessage* fLaunchRefsMessage;
|
||||
bool fInitialized;
|
||||
|
||||
DownloadWindow* m_downloadWindow;
|
||||
DownloadWindow* fDownloadWindow;
|
||||
};
|
||||
|
||||
|
||||
extern const char* kApplicationSignature;
|
||||
extern const char* kApplicationName;
|
||||
|
||||
#endif // LauncherApp_h
|
||||
|
||||
#endif // BROWSER_APP_H
|
||||
|
||||
|
||||
@@ -31,12 +31,12 @@
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "LauncherWindow.h"
|
||||
#include "BrowserWindow.h"
|
||||
|
||||
#include "AuthenticationPanel.h"
|
||||
#include "BrowserApp.h"
|
||||
#include "BrowsingHistory.h"
|
||||
#include "IconButton.h"
|
||||
#include "LauncherApp.h"
|
||||
#include "WebPage.h"
|
||||
#include "WebTabView.h"
|
||||
#include "WebView.h"
|
||||
@@ -61,6 +61,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
enum {
|
||||
OPEN_LOCATION = 'open',
|
||||
GO_BACK = 'goba',
|
||||
@@ -80,31 +81,32 @@ enum {
|
||||
TEXT_FIND_PREVIOUS = 'fndp',
|
||||
};
|
||||
|
||||
using namespace WebCore;
|
||||
|
||||
static BLayoutItem* layoutItemFor(BView* view)
|
||||
static BLayoutItem*
|
||||
layoutItemFor(BView* view)
|
||||
{
|
||||
BLayout* layout = view->Parent()->GetLayout();
|
||||
int32 index = layout->IndexOfView(view);
|
||||
return layout->ItemAt(index);
|
||||
}
|
||||
|
||||
LauncherWindow::LauncherWindow(BRect frame, const BMessenger& downloadListener,
|
||||
|
||||
BrowserWindow::BrowserWindow(BRect frame, const BMessenger& downloadListener,
|
||||
ToolbarPolicy toolbarPolicy)
|
||||
: BWebWindow(frame, "HaikuLauncher",
|
||||
: BWebWindow(frame, kApplicationName,
|
||||
B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
|
||||
B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS)
|
||||
, m_downloadListener(downloadListener)
|
||||
, fDownloadListener(downloadListener)
|
||||
{
|
||||
BMessage* newTabMessage = new BMessage(NEW_TAB);
|
||||
newTabMessage->AddString("url", "");
|
||||
newTabMessage->AddPointer("window", this);
|
||||
newTabMessage->AddBool("select", true);
|
||||
m_tabManager = new TabManager(BMessenger(this), newTabMessage);
|
||||
fTabManager = new TabManager(BMessenger(this), newTabMessage);
|
||||
|
||||
if (toolbarPolicy == HaveToolbar) {
|
||||
// Menu
|
||||
m_menuBar = new BMenuBar("Main menu");
|
||||
fMenuBar = new BMenuBar("Main menu");
|
||||
BMenu* menu = new BMenu("Window");
|
||||
BMessage* newWindowMessage = new BMessage(NEW_WINDOW);
|
||||
newWindowMessage->AddString("url", "");
|
||||
@@ -124,7 +126,7 @@ LauncherWindow::LauncherWindow(BRect frame, const BMessenger& downloadListener,
|
||||
BMenuItem* quitItem = new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q');
|
||||
menu->AddItem(quitItem);
|
||||
quitItem->SetTarget(be_app);
|
||||
m_menuBar->AddItem(menu);
|
||||
fMenuBar->AddItem(menu);
|
||||
|
||||
menu = new BMenu("Text");
|
||||
menu->AddItem(new BMenuItem("Find", new BMessage(TEXT_SHOW_FIND_GROUP), 'F'));
|
||||
@@ -132,60 +134,60 @@ LauncherWindow::LauncherWindow(BRect frame, const BMessenger& downloadListener,
|
||||
menu->AddItem(new BMenuItem("Increase size", new BMessage(TEXT_SIZE_INCREASE), '+'));
|
||||
menu->AddItem(new BMenuItem("Decrease size", new BMessage(TEXT_SIZE_DECREASE), '-'));
|
||||
menu->AddItem(new BMenuItem("Reset size", new BMessage(TEXT_SIZE_RESET), '0'));
|
||||
m_menuBar->AddItem(menu);
|
||||
fMenuBar->AddItem(menu);
|
||||
|
||||
m_goMenu = new BMenu("Go");
|
||||
m_menuBar->AddItem(m_goMenu);
|
||||
fGoMenu = new BMenu("Go");
|
||||
fMenuBar->AddItem(fGoMenu);
|
||||
|
||||
// Back, Forward & Stop
|
||||
m_BackButton = new IconButton("Back", 0, NULL, new BMessage(GO_BACK));
|
||||
m_BackButton->SetIcon(201);
|
||||
m_BackButton->TrimIcon();
|
||||
fBackButton = new IconButton("Back", 0, NULL, new BMessage(GO_BACK));
|
||||
fBackButton->SetIcon(201);
|
||||
fBackButton->TrimIcon();
|
||||
|
||||
m_ForwardButton = new IconButton("Forward", 0, NULL, new BMessage(GO_FORWARD));
|
||||
m_ForwardButton->SetIcon(202);
|
||||
m_ForwardButton->TrimIcon();
|
||||
fForwardButton = new IconButton("Forward", 0, NULL, new BMessage(GO_FORWARD));
|
||||
fForwardButton->SetIcon(202);
|
||||
fForwardButton->TrimIcon();
|
||||
|
||||
m_StopButton = new IconButton("Stop", 0, NULL, new BMessage(STOP));
|
||||
m_StopButton->SetIcon(204);
|
||||
m_StopButton->TrimIcon();
|
||||
fStopButton = new IconButton("Stop", 0, NULL, new BMessage(STOP));
|
||||
fStopButton->SetIcon(204);
|
||||
fStopButton->TrimIcon();
|
||||
|
||||
// URL
|
||||
m_url = new BTextControl("url", "", "", NULL);
|
||||
m_url->SetDivider(50.0);
|
||||
fURLTextControl = new BTextControl("url", "", "", NULL);
|
||||
fURLTextControl->SetDivider(50.0);
|
||||
|
||||
// Go
|
||||
m_goButton = new BButton("", "Go", new BMessage(GOTO_URL));
|
||||
fGoButton = new BButton("", "Go", new BMessage(GOTO_URL));
|
||||
|
||||
// Status Bar
|
||||
m_statusText = new BStringView("status", "");
|
||||
m_statusText->SetAlignment(B_ALIGN_LEFT);
|
||||
m_statusText->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
|
||||
m_statusText->SetExplicitMinSize(BSize(150, 12));
|
||||
fStatusText = new BStringView("status", "");
|
||||
fStatusText->SetAlignment(B_ALIGN_LEFT);
|
||||
fStatusText->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
|
||||
fStatusText->SetExplicitMinSize(BSize(150, 12));
|
||||
// Prevent the window from growing to fit a long status message...
|
||||
BFont font(be_plain_font);
|
||||
font.SetSize(ceilf(font.Size() * 0.8));
|
||||
m_statusText->SetFont(&font, B_FONT_SIZE);
|
||||
fStatusText->SetFont(&font, B_FONT_SIZE);
|
||||
|
||||
// Loading progress bar
|
||||
m_loadingProgressBar = new BStatusBar("progress");
|
||||
m_loadingProgressBar->SetMaxValue(100);
|
||||
m_loadingProgressBar->Hide();
|
||||
m_loadingProgressBar->SetBarHeight(12);
|
||||
fLoadingProgressBar = new BStatusBar("progress");
|
||||
fLoadingProgressBar->SetMaxValue(100);
|
||||
fLoadingProgressBar->Hide();
|
||||
fLoadingProgressBar->SetBarHeight(12);
|
||||
|
||||
const float kInsetSpacing = 5;
|
||||
const float kElementSpacing = 7;
|
||||
|
||||
m_findTextControl = new BTextControl("find", "Find:", "",
|
||||
fFindTextControl = new BTextControl("find", "Find:", "",
|
||||
new BMessage(TEXT_FIND_NEXT));
|
||||
m_findCaseSensitiveCheckBox = new BCheckBox("Match case");
|
||||
fFindCaseSensitiveCheckBox = new BCheckBox("Match case");
|
||||
BView* findGroup = BGroupLayoutBuilder(B_VERTICAL)
|
||||
.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
|
||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL, kElementSpacing)
|
||||
.Add(m_findTextControl)
|
||||
.Add(fFindTextControl)
|
||||
.Add(new BButton("Previous", new BMessage(TEXT_FIND_PREVIOUS)))
|
||||
.Add(new BButton("Next", new BMessage(TEXT_FIND_NEXT)))
|
||||
.Add(m_findCaseSensitiveCheckBox)
|
||||
.Add(fFindCaseSensitiveCheckBox)
|
||||
.Add(BSpaceLayoutItem::CreateGlue())
|
||||
.Add(new BButton("Close", new BMessage(TEXT_HIDE_FIND_GROUP)))
|
||||
.SetInsets(kInsetSpacing, kInsetSpacing,
|
||||
@@ -194,41 +196,41 @@ LauncherWindow::LauncherWindow(BRect frame, const BMessenger& downloadListener,
|
||||
;
|
||||
// Layout
|
||||
AddChild(BGroupLayoutBuilder(B_VERTICAL)
|
||||
.Add(m_menuBar)
|
||||
.Add(m_tabManager->TabGroup())
|
||||
.Add(fMenuBar)
|
||||
.Add(fTabManager->TabGroup())
|
||||
.Add(BGridLayoutBuilder(kElementSpacing, kElementSpacing)
|
||||
.Add(m_BackButton, 0, 0)
|
||||
.Add(m_ForwardButton, 1, 0)
|
||||
.Add(m_StopButton, 2, 0)
|
||||
.Add(m_url, 3, 0)
|
||||
.Add(m_goButton, 4, 0)
|
||||
.Add(fBackButton, 0, 0)
|
||||
.Add(fForwardButton, 1, 0)
|
||||
.Add(fStopButton, 2, 0)
|
||||
.Add(fURLTextControl, 3, 0)
|
||||
.Add(fGoButton, 4, 0)
|
||||
.SetInsets(kInsetSpacing, kInsetSpacing, kInsetSpacing, kInsetSpacing)
|
||||
)
|
||||
.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
|
||||
.Add(m_tabManager->ContainerView())
|
||||
.Add(fTabManager->ContainerView())
|
||||
.Add(findGroup)
|
||||
.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
|
||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL, kElementSpacing)
|
||||
.Add(m_statusText)
|
||||
.Add(m_loadingProgressBar, 0.2)
|
||||
.Add(fStatusText)
|
||||
.Add(fLoadingProgressBar, 0.2)
|
||||
.AddStrut(12 - kElementSpacing)
|
||||
.SetInsets(kInsetSpacing, 0, kInsetSpacing, 0)
|
||||
)
|
||||
);
|
||||
|
||||
m_url->MakeFocus(true);
|
||||
fURLTextControl->MakeFocus(true);
|
||||
|
||||
m_findGroup = layoutItemFor(findGroup);
|
||||
m_tabGroup = layoutItemFor(m_tabManager->TabGroup());
|
||||
fFindGroup = layoutItemFor(findGroup);
|
||||
fTabGroup = layoutItemFor(fTabManager->TabGroup());
|
||||
} else {
|
||||
m_BackButton = 0;
|
||||
m_ForwardButton = 0;
|
||||
m_StopButton = 0;
|
||||
m_goButton = 0;
|
||||
m_url = 0;
|
||||
m_menuBar = 0;
|
||||
m_statusText = 0;
|
||||
m_loadingProgressBar = 0;
|
||||
fBackButton = 0;
|
||||
fForwardButton = 0;
|
||||
fStopButton = 0;
|
||||
fGoButton = 0;
|
||||
fURLTextControl = 0;
|
||||
fMenuBar = 0;
|
||||
fStatusText = 0;
|
||||
fLoadingProgressBar = 0;
|
||||
|
||||
BWebView* webView = new BWebView("web_view");
|
||||
SetCurrentWebView(webView);
|
||||
@@ -238,9 +240,9 @@ LauncherWindow::LauncherWindow(BRect frame, const BMessenger& downloadListener,
|
||||
);
|
||||
}
|
||||
|
||||
newTab("", true);
|
||||
CreateNewTab("", true);
|
||||
|
||||
m_findGroup->SetVisible(false);
|
||||
fFindGroup->SetVisible(false);
|
||||
|
||||
AddShortcut('G', B_COMMAND_KEY, new BMessage(TEXT_FIND_NEXT));
|
||||
AddShortcut('G', B_COMMAND_KEY | B_SHIFT_KEY, new BMessage(TEXT_FIND_PREVIOUS));
|
||||
@@ -251,13 +253,17 @@ LauncherWindow::LauncherWindow(BRect frame, const BMessenger& downloadListener,
|
||||
be_app->PostMessage(WINDOW_OPENED);
|
||||
}
|
||||
|
||||
LauncherWindow::~LauncherWindow()
|
||||
|
||||
BrowserWindow::~BrowserWindow()
|
||||
{
|
||||
}
|
||||
|
||||
void LauncherWindow::DispatchMessage(BMessage* message, BHandler* target)
|
||||
|
||||
void
|
||||
BrowserWindow::DispatchMessage(BMessage* message, BHandler* target)
|
||||
{
|
||||
if (m_url && message->what == B_KEY_DOWN && target == m_url->TextView()) {
|
||||
if (fURLTextControl && message->what == B_KEY_DOWN
|
||||
&& target == fURLTextControl->TextView()) {
|
||||
// Handle B_RETURN in the URL text control. This is the easiest
|
||||
// way to react *only* when the user presses the return key in the
|
||||
// address bar, as opposed to trying to load whatever is in there when
|
||||
@@ -266,25 +272,27 @@ void LauncherWindow::DispatchMessage(BMessage* message, BHandler* target)
|
||||
if (message->FindString("bytes", &bytes) == B_OK
|
||||
&& bytes[0] == B_RETURN) {
|
||||
// Do it in such a way that the user sees the Go-button go down.
|
||||
m_goButton->SetValue(B_CONTROL_ON);
|
||||
fGoButton->SetValue(B_CONTROL_ON);
|
||||
UpdateIfNeeded();
|
||||
m_goButton->Invoke();
|
||||
fGoButton->Invoke();
|
||||
snooze(1000);
|
||||
m_goButton->SetValue(B_CONTROL_OFF);
|
||||
fGoButton->SetValue(B_CONTROL_OFF);
|
||||
}
|
||||
}
|
||||
BWebWindow::DispatchMessage(message, target);
|
||||
}
|
||||
|
||||
void LauncherWindow::MessageReceived(BMessage* message)
|
||||
|
||||
void
|
||||
BrowserWindow::MessageReceived(BMessage* message)
|
||||
{
|
||||
switch (message->what) {
|
||||
case OPEN_LOCATION:
|
||||
if (m_url) {
|
||||
if (m_url->TextView()->IsFocus())
|
||||
m_url->TextView()->SelectAll();
|
||||
if (fURLTextControl) {
|
||||
if (fURLTextControl->TextView()->IsFocus())
|
||||
fURLTextControl->TextView()->SelectAll();
|
||||
else
|
||||
m_url->MakeFocus(true);
|
||||
fURLTextControl->MakeFocus(true);
|
||||
}
|
||||
break;
|
||||
case RELOAD:
|
||||
@@ -293,7 +301,7 @@ void LauncherWindow::MessageReceived(BMessage* message)
|
||||
case GOTO_URL: {
|
||||
BString url;
|
||||
if (message->FindString("url", &url) != B_OK)
|
||||
url = m_url->Text();
|
||||
url = fURLTextControl->Text();
|
||||
CurrentWebView()->LoadURL(url.String());
|
||||
break;
|
||||
}
|
||||
@@ -311,8 +319,8 @@ void LauncherWindow::MessageReceived(BMessage* message)
|
||||
BrowsingHistory* history = BrowsingHistory::defaultInstance();
|
||||
if (history->countItems() == 0)
|
||||
break;
|
||||
BAlert* alert = new BAlert("Confirmation", "Do you really want to clear "
|
||||
"the browsing history?", "Clear", "Cancel");
|
||||
BAlert* alert = new BAlert("Confirmation", "Do you really want to "
|
||||
"clear the browsing history?", "Clear", "Cancel");
|
||||
if (alert->Go() == 0)
|
||||
history->clear();
|
||||
break;
|
||||
@@ -355,21 +363,21 @@ void LauncherWindow::MessageReceived(BMessage* message)
|
||||
break;
|
||||
|
||||
case TEXT_FIND_NEXT:
|
||||
CurrentWebView()->FindString(m_findTextControl->Text(), true,
|
||||
m_findCaseSensitiveCheckBox->Value());
|
||||
CurrentWebView()->FindString(fFindTextControl->Text(), true,
|
||||
fFindCaseSensitiveCheckBox->Value());
|
||||
break;
|
||||
case TEXT_FIND_PREVIOUS:
|
||||
CurrentWebView()->FindString(m_findTextControl->Text(), false,
|
||||
m_findCaseSensitiveCheckBox->Value());
|
||||
CurrentWebView()->FindString(fFindTextControl->Text(), false,
|
||||
fFindCaseSensitiveCheckBox->Value());
|
||||
break;
|
||||
case TEXT_SHOW_FIND_GROUP:
|
||||
if (!m_findGroup->IsVisible())
|
||||
m_findGroup->SetVisible(true);
|
||||
m_findTextControl->MakeFocus(true);
|
||||
if (!fFindGroup->IsVisible())
|
||||
fFindGroup->SetVisible(true);
|
||||
fFindTextControl->MakeFocus(true);
|
||||
break;
|
||||
case TEXT_HIDE_FIND_GROUP:
|
||||
if (m_findGroup->IsVisible())
|
||||
m_findGroup->SetVisible(false);
|
||||
if (fFindGroup->IsVisible())
|
||||
fFindGroup->SetVisible(false);
|
||||
break;
|
||||
|
||||
case SHOW_DOWNLOAD_WINDOW:
|
||||
@@ -378,12 +386,12 @@ void LauncherWindow::MessageReceived(BMessage* message)
|
||||
break;
|
||||
|
||||
case CLOSE_TAB:
|
||||
if (m_tabManager->CountTabs() > 1) {
|
||||
if (fTabManager->CountTabs() > 1) {
|
||||
int32 index;
|
||||
if (message->FindInt32("tab index", &index) != B_OK)
|
||||
index = m_tabManager->SelectedTabIndex();
|
||||
delete m_tabManager->RemoveTab(index);
|
||||
updateTabGroupVisibility();
|
||||
index = fTabManager->SelectedTabIndex();
|
||||
delete fTabManager->RemoveTab(index);
|
||||
_UpdateTabGroupVisibility();
|
||||
} else
|
||||
PostMessage(B_QUIT_REQUESTED);
|
||||
break;
|
||||
@@ -393,16 +401,16 @@ void LauncherWindow::MessageReceived(BMessage* message)
|
||||
int32 index;
|
||||
if (message->FindInt32("tab index", &index) != B_OK)
|
||||
index = -1;
|
||||
BWebView* webView = dynamic_cast<BWebView*>(m_tabManager->ViewForTab(index));
|
||||
BWebView* webView = dynamic_cast<BWebView*>(fTabManager->ViewForTab(index));
|
||||
if (webView == CurrentWebView())
|
||||
break;
|
||||
SetCurrentWebView(webView);
|
||||
if (webView)
|
||||
updateTitle(webView->MainFrameTitle());
|
||||
_UpdateTitle(webView->MainFrameTitle());
|
||||
else
|
||||
updateTitle("");
|
||||
_UpdateTitle("");
|
||||
if (webView) {
|
||||
m_url->SetText(webView->MainFrameURL());
|
||||
fURLTextControl->SetText(webView->MainFrameURL());
|
||||
// Trigger update of the interface to the new page, by requesting
|
||||
// to resend all notifications.
|
||||
webView->WebPage()->ResendNotifications();
|
||||
@@ -416,14 +424,16 @@ void LauncherWindow::MessageReceived(BMessage* message)
|
||||
}
|
||||
}
|
||||
|
||||
bool LauncherWindow::QuitRequested()
|
||||
|
||||
bool
|
||||
BrowserWindow::QuitRequested()
|
||||
{
|
||||
// TODO: Check for modified form data and ask user for confirmation, etc.
|
||||
|
||||
// Iterate over all tabs to delete all BWebViews.
|
||||
// Do this here, so WebKit tear down happens earlier.
|
||||
while (m_tabManager->CountTabs() > 0)
|
||||
delete m_tabManager->RemoveTab(0L);
|
||||
while (fTabManager->CountTabs() > 0)
|
||||
delete fTabManager->RemoveTab(0L);
|
||||
SetCurrentWebView(0);
|
||||
|
||||
BMessage message(WINDOW_CLOSED);
|
||||
@@ -432,10 +442,12 @@ bool LauncherWindow::QuitRequested()
|
||||
return true;
|
||||
}
|
||||
|
||||
void LauncherWindow::MenusBeginning()
|
||||
|
||||
void
|
||||
BrowserWindow::MenusBeginning()
|
||||
{
|
||||
BMenuItem* menuItem;
|
||||
while ((menuItem = m_goMenu->RemoveItem(0L)))
|
||||
while ((menuItem = fGoMenu->RemoveItem(0L)))
|
||||
delete menuItem;
|
||||
|
||||
BrowsingHistory* history = BrowsingHistory::defaultInstance();
|
||||
@@ -451,50 +463,58 @@ void LauncherWindow::MenusBeginning()
|
||||
BString truncatedUrl(historyItem.url());
|
||||
be_plain_font->TruncateString(&truncatedUrl, B_TRUNCATE_END, 480);
|
||||
menuItem = new BMenuItem(truncatedUrl, message);
|
||||
m_goMenu->AddItem(menuItem);
|
||||
fGoMenu->AddItem(menuItem);
|
||||
}
|
||||
|
||||
|
||||
if (m_goMenu->CountItems() > 3) {
|
||||
m_goMenu->AddSeparatorItem();
|
||||
m_goMenu->AddItem(new BMenuItem("Clear history", new BMessage(CLEAR_HISTORY)));
|
||||
if (fGoMenu->CountItems() > 3) {
|
||||
fGoMenu->AddSeparatorItem();
|
||||
fGoMenu->AddItem(new BMenuItem("Clear history",
|
||||
new BMessage(CLEAR_HISTORY)));
|
||||
}
|
||||
|
||||
history->Unlock();
|
||||
}
|
||||
|
||||
void LauncherWindow::newTab(const BString& url, bool select, BWebView* webView)
|
||||
|
||||
void
|
||||
BrowserWindow::CreateNewTab(const BString& url, bool select, BWebView* webView)
|
||||
{
|
||||
// Executed in app thread (new BWebPage needs to be created in app thread).
|
||||
if (!webView)
|
||||
webView = new BWebView("web view");
|
||||
webView->WebPage()->SetDownloadListener(m_downloadListener);
|
||||
webView->WebPage()->SetDownloadListener(fDownloadListener);
|
||||
|
||||
m_tabManager->AddTab(webView, "New tab");
|
||||
fTabManager->AddTab(webView, "New tab");
|
||||
|
||||
if (url.Length())
|
||||
webView->LoadURL(url.String());
|
||||
|
||||
if (select) {
|
||||
m_tabManager->SelectTab(m_tabManager->CountTabs() - 1);
|
||||
fTabManager->SelectTab(fTabManager->CountTabs() - 1);
|
||||
SetCurrentWebView(webView);
|
||||
NavigationCapabilitiesChanged(false, false, false, webView);
|
||||
if (m_url) {
|
||||
m_url->SetText(url.String());
|
||||
m_url->MakeFocus(true);
|
||||
if (fURLTextControl) {
|
||||
fURLTextControl->SetText(url.String());
|
||||
fURLTextControl->MakeFocus(true);
|
||||
}
|
||||
}
|
||||
|
||||
updateTabGroupVisibility();
|
||||
_UpdateTabGroupVisibility();
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - Notification API
|
||||
|
||||
void LauncherWindow::NavigationRequested(const BString& url, BWebView* view)
|
||||
|
||||
void
|
||||
BrowserWindow::NavigationRequested(const BString& url, BWebView* view)
|
||||
{
|
||||
}
|
||||
|
||||
void LauncherWindow::NewWindowRequested(const BString& url, bool primaryAction)
|
||||
|
||||
void
|
||||
BrowserWindow::NewWindowRequested(const BString& url, bool primaryAction)
|
||||
{
|
||||
// Always open new windows in the application thread, since
|
||||
// creating a BWebView will try to grab the application lock.
|
||||
@@ -508,45 +528,55 @@ void LauncherWindow::NewWindowRequested(const BString& url, bool primaryAction)
|
||||
be_app->PostMessage(&message);
|
||||
}
|
||||
|
||||
void LauncherWindow::NewPageCreated(BWebView* view)
|
||||
|
||||
void
|
||||
BrowserWindow::NewPageCreated(BWebView* view)
|
||||
{
|
||||
newTab(BString(), true, view);
|
||||
CreateNewTab(BString(), true, view);
|
||||
}
|
||||
|
||||
void LauncherWindow::LoadNegotiating(const BString& url, BWebView* view)
|
||||
|
||||
void
|
||||
BrowserWindow::LoadNegotiating(const BString& url, BWebView* view)
|
||||
{
|
||||
BString status("Requesting: ");
|
||||
status << url;
|
||||
StatusChanged(status, view);
|
||||
}
|
||||
|
||||
void LauncherWindow::LoadCommitted(const BString& url, BWebView* view)
|
||||
|
||||
void
|
||||
BrowserWindow::LoadCommitted(const BString& url, BWebView* view)
|
||||
{
|
||||
if (view != CurrentWebView())
|
||||
return;
|
||||
|
||||
// This hook is invoked when the load is commited.
|
||||
if (m_url)
|
||||
m_url->SetText(url.String());
|
||||
if (fURLTextControl)
|
||||
fURLTextControl->SetText(url.String());
|
||||
|
||||
BString status("Loading: ");
|
||||
status << url;
|
||||
StatusChanged(status, view);
|
||||
}
|
||||
|
||||
void LauncherWindow::LoadProgress(float progress, BWebView* view)
|
||||
|
||||
void
|
||||
BrowserWindow::LoadProgress(float progress, BWebView* view)
|
||||
{
|
||||
if (view != CurrentWebView())
|
||||
return;
|
||||
|
||||
if (m_loadingProgressBar) {
|
||||
if (progress < 100 && m_loadingProgressBar->IsHidden())
|
||||
m_loadingProgressBar->Show();
|
||||
m_loadingProgressBar->SetTo(progress);
|
||||
if (fLoadingProgressBar) {
|
||||
if (progress < 100 && fLoadingProgressBar->IsHidden())
|
||||
fLoadingProgressBar->Show();
|
||||
fLoadingProgressBar->SetTo(progress);
|
||||
}
|
||||
}
|
||||
|
||||
void LauncherWindow::LoadFailed(const BString& url, BWebView* view)
|
||||
|
||||
void
|
||||
BrowserWindow::LoadFailed(const BString& url, BWebView* view)
|
||||
{
|
||||
if (view != CurrentWebView())
|
||||
return;
|
||||
@@ -554,11 +584,13 @@ void LauncherWindow::LoadFailed(const BString& url, BWebView* view)
|
||||
BString status(url);
|
||||
status << " failed.";
|
||||
StatusChanged(status, view);
|
||||
if (m_loadingProgressBar && !m_loadingProgressBar->IsHidden())
|
||||
m_loadingProgressBar->Hide();
|
||||
if (fLoadingProgressBar && !fLoadingProgressBar->IsHidden())
|
||||
fLoadingProgressBar->Hide();
|
||||
}
|
||||
|
||||
void LauncherWindow::LoadFinished(const BString& url, BWebView* view)
|
||||
|
||||
void
|
||||
BrowserWindow::LoadFinished(const BString& url, BWebView* view)
|
||||
{
|
||||
if (view != CurrentWebView())
|
||||
return;
|
||||
@@ -566,14 +598,16 @@ void LauncherWindow::LoadFinished(const BString& url, BWebView* view)
|
||||
BString status(url);
|
||||
status << " finished.";
|
||||
StatusChanged(status, view);
|
||||
if (m_loadingProgressBar && !m_loadingProgressBar->IsHidden())
|
||||
m_loadingProgressBar->Hide();
|
||||
if (fLoadingProgressBar && !fLoadingProgressBar->IsHidden())
|
||||
fLoadingProgressBar->Hide();
|
||||
|
||||
NavigationCapabilitiesChanged(m_BackButton->IsEnabled(),
|
||||
m_ForwardButton->IsEnabled(), false, view);
|
||||
NavigationCapabilitiesChanged(fBackButton->IsEnabled(),
|
||||
fForwardButton->IsEnabled(), false, view);
|
||||
}
|
||||
|
||||
void LauncherWindow::ResizeRequested(float width, float height, BWebView* view)
|
||||
|
||||
void
|
||||
BrowserWindow::ResizeRequested(float width, float height, BWebView* view)
|
||||
{
|
||||
if (view != CurrentWebView())
|
||||
return;
|
||||
@@ -583,25 +617,33 @@ void LauncherWindow::ResizeRequested(float width, float height, BWebView* view)
|
||||
ResizeTo(width, height);
|
||||
}
|
||||
|
||||
void LauncherWindow::SetToolBarsVisible(bool flag, BWebView* view)
|
||||
|
||||
void
|
||||
BrowserWindow::SetToolBarsVisible(bool flag, BWebView* view)
|
||||
{
|
||||
// TODO
|
||||
// TODO: Ignore request when there is more than one BWebView embedded!
|
||||
}
|
||||
|
||||
void LauncherWindow::SetStatusBarVisible(bool flag, BWebView* view)
|
||||
|
||||
void
|
||||
BrowserWindow::SetStatusBarVisible(bool flag, BWebView* view)
|
||||
{
|
||||
// TODO
|
||||
// TODO: Ignore request when there is more than one BWebView embedded!
|
||||
}
|
||||
|
||||
void LauncherWindow::SetMenuBarVisible(bool flag, BWebView* view)
|
||||
|
||||
void
|
||||
BrowserWindow::SetMenuBarVisible(bool flag, BWebView* view)
|
||||
{
|
||||
// TODO
|
||||
// TODO: Ignore request when there is more than one BWebView embedded!
|
||||
}
|
||||
|
||||
void LauncherWindow::SetResizable(bool flag, BWebView* view)
|
||||
|
||||
void
|
||||
BrowserWindow::SetResizable(bool flag, BWebView* view)
|
||||
{
|
||||
// TODO: Ignore request when there is more than one BWebView embedded!
|
||||
|
||||
@@ -611,55 +653,65 @@ void LauncherWindow::SetResizable(bool flag, BWebView* view)
|
||||
SetFlags(Flags() | B_NOT_RESIZABLE);
|
||||
}
|
||||
|
||||
void LauncherWindow::TitleChanged(const BString& title, BWebView* view)
|
||||
|
||||
void
|
||||
BrowserWindow::TitleChanged(const BString& title, BWebView* view)
|
||||
{
|
||||
for (int32 i = 0; i < m_tabManager->CountTabs(); i++) {
|
||||
if (m_tabManager->ViewForTab(i) == view) {
|
||||
m_tabManager->SetTabLabel(i, title);
|
||||
for (int32 i = 0; i < fTabManager->CountTabs(); i++) {
|
||||
if (fTabManager->ViewForTab(i) == view) {
|
||||
fTabManager->SetTabLabel(i, title);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (view != CurrentWebView())
|
||||
return;
|
||||
|
||||
updateTitle(title);
|
||||
_UpdateTitle(title);
|
||||
}
|
||||
|
||||
void LauncherWindow::StatusChanged(const BString& statusText, BWebView* view)
|
||||
|
||||
void
|
||||
BrowserWindow::StatusChanged(const BString& statusText, BWebView* view)
|
||||
{
|
||||
if (view != CurrentWebView())
|
||||
return;
|
||||
|
||||
if (m_statusText)
|
||||
m_statusText->SetText(statusText.String());
|
||||
if (fStatusText)
|
||||
fStatusText->SetText(statusText.String());
|
||||
}
|
||||
|
||||
void LauncherWindow::NavigationCapabilitiesChanged(bool canGoBackward,
|
||||
|
||||
void
|
||||
BrowserWindow::NavigationCapabilitiesChanged(bool canGoBackward,
|
||||
bool canGoForward, bool canStop, BWebView* view)
|
||||
{
|
||||
if (view != CurrentWebView())
|
||||
return;
|
||||
|
||||
if (m_BackButton)
|
||||
m_BackButton->SetEnabled(canGoBackward);
|
||||
if (m_ForwardButton)
|
||||
m_ForwardButton->SetEnabled(canGoForward);
|
||||
if (m_StopButton)
|
||||
m_StopButton->SetEnabled(canStop);
|
||||
if (fBackButton)
|
||||
fBackButton->SetEnabled(canGoBackward);
|
||||
if (fForwardButton)
|
||||
fForwardButton->SetEnabled(canGoForward);
|
||||
if (fStopButton)
|
||||
fStopButton->SetEnabled(canStop);
|
||||
}
|
||||
|
||||
void LauncherWindow::UpdateGlobalHistory(const BString& url)
|
||||
|
||||
void
|
||||
BrowserWindow::UpdateGlobalHistory(const BString& url)
|
||||
{
|
||||
BrowsingHistory::defaultInstance()->addItem(BrowsingHistoryItem(url));
|
||||
}
|
||||
|
||||
bool LauncherWindow::AuthenticationChallenge(BString message, BString& inOutUser,
|
||||
|
||||
bool
|
||||
BrowserWindow::AuthenticationChallenge(BString message, BString& inOutUser,
|
||||
BString& inOutPassword, bool& inOutRememberCredentials, uint32 failureCount,
|
||||
BWebView* view)
|
||||
{
|
||||
// Switch to the page for which this authentication is required.
|
||||
if (view != CurrentWebView()) {
|
||||
m_tabManager->SelectTab(view);
|
||||
fTabManager->SelectTab(view);
|
||||
UpdateIfNeeded();
|
||||
}
|
||||
AuthenticationPanel* panel = new AuthenticationPanel(Frame());
|
||||
@@ -669,20 +721,27 @@ bool LauncherWindow::AuthenticationChallenge(BString message, BString& inOutUser
|
||||
&inOutRememberCredentials);
|
||||
}
|
||||
|
||||
void LauncherWindow::updateTitle(const BString& title)
|
||||
|
||||
// #pragma mark - private
|
||||
|
||||
|
||||
void
|
||||
BrowserWindow::_UpdateTitle(const BString& title)
|
||||
{
|
||||
BString windowTitle = title;
|
||||
if (windowTitle.Length() > 0)
|
||||
windowTitle << " - ";
|
||||
windowTitle << "HaikuLauncher";
|
||||
windowTitle << kApplicationName;
|
||||
SetTitle(windowTitle.String());
|
||||
}
|
||||
|
||||
void LauncherWindow::updateTabGroupVisibility()
|
||||
|
||||
void
|
||||
BrowserWindow::_UpdateTabGroupVisibility()
|
||||
{
|
||||
if (Lock()) {
|
||||
//m_tabGroup->SetVisible(m_tabManager->CountTabs() > 1);
|
||||
m_tabManager->SetCloseButtonsAvailable(m_tabManager->CountTabs() > 1);
|
||||
//fTabGroup->SetVisible(fTabManager->CountTabs() > 1);
|
||||
fTabManager->SetCloseButtonsAvailable(fTabManager->CountTabs() > 1);
|
||||
Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,9 +26,9 @@
|
||||
* (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 BROWSER_WINDOW_H
|
||||
#define BROWSER_WINDOW_H
|
||||
|
||||
#ifndef LauncherWindow_h
|
||||
#define LauncherWindow_h
|
||||
|
||||
#include "WebWindow.h"
|
||||
#include <Messenger.h>
|
||||
@@ -58,63 +58,79 @@ enum {
|
||||
SHOW_DOWNLOAD_WINDOW = 'sdwd'
|
||||
};
|
||||
|
||||
class LauncherWindow : public BWebWindow {
|
||||
public:
|
||||
LauncherWindow(BRect frame, const BMessenger& downloadListener,
|
||||
ToolbarPolicy = HaveToolbar);
|
||||
virtual ~LauncherWindow();
|
||||
|
||||
virtual void DispatchMessage(BMessage* message, BHandler* target);
|
||||
class BrowserWindow : public BWebWindow {
|
||||
public:
|
||||
BrowserWindow(BRect frame,
|
||||
const BMessenger& downloadListener,
|
||||
ToolbarPolicy = HaveToolbar);
|
||||
virtual ~BrowserWindow();
|
||||
|
||||
virtual void DispatchMessage(BMessage* message,
|
||||
BHandler* target);
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
virtual bool QuitRequested();
|
||||
virtual void MenusBeginning();
|
||||
|
||||
void newTab(const BString& url, bool select, BWebView* webView = 0);
|
||||
void CreateNewTab(const BString& url, bool select,
|
||||
BWebView* webView = 0);
|
||||
|
||||
private:
|
||||
// WebPage notification API implementations
|
||||
virtual void NavigationRequested(const BString& url, BWebView* view);
|
||||
virtual void NewWindowRequested(const BString& url, bool primaryAction);
|
||||
virtual void NavigationRequested(const BString& url,
|
||||
BWebView* view);
|
||||
virtual void NewWindowRequested(const BString& url,
|
||||
bool primaryAction);
|
||||
virtual void NewPageCreated(BWebView* view);
|
||||
virtual void LoadNegotiating(const BString& url, BWebView* view);
|
||||
virtual void LoadCommitted(const BString& url, BWebView* view);
|
||||
virtual void LoadNegotiating(const BString& url,
|
||||
BWebView* view);
|
||||
virtual void LoadCommitted(const BString& url,
|
||||
BWebView* view);
|
||||
virtual void LoadProgress(float progress, BWebView* view);
|
||||
virtual void LoadFailed(const BString& url, BWebView* view);
|
||||
virtual void LoadFinished(const BString& url, BWebView* view);
|
||||
virtual void TitleChanged(const BString& title, BWebView* view);
|
||||
virtual void ResizeRequested(float width, float height, BWebView* view);
|
||||
virtual void LoadFinished(const BString& url,
|
||||
BWebView* view);
|
||||
virtual void TitleChanged(const BString& title,
|
||||
BWebView* view);
|
||||
virtual void ResizeRequested(float width, float height,
|
||||
BWebView* view);
|
||||
virtual void SetToolBarsVisible(bool flag, BWebView* view);
|
||||
virtual void SetStatusBarVisible(bool flag, BWebView* view);
|
||||
virtual void SetMenuBarVisible(bool flag, BWebView* view);
|
||||
virtual void SetResizable(bool flag, BWebView* view);
|
||||
virtual void StatusChanged(const BString& status, BWebView* view);
|
||||
virtual void NavigationCapabilitiesChanged(bool canGoBackward,
|
||||
bool canGoForward, bool canStop, BWebView* view);
|
||||
virtual void StatusChanged(const BString& status,
|
||||
BWebView* view);
|
||||
virtual void NavigationCapabilitiesChanged(
|
||||
bool canGoBackward, bool canGoForward,
|
||||
bool canStop, BWebView* view);
|
||||
virtual void UpdateGlobalHistory(const BString& url);
|
||||
virtual bool AuthenticationChallenge(BString message, BString& inOutUser,
|
||||
BString& inOutPassword, bool& inOutRememberCredentials,
|
||||
virtual bool AuthenticationChallenge(BString message,
|
||||
BString& inOutUser, BString& inOutPassword,
|
||||
bool& inOutRememberCredentials,
|
||||
uint32 failureCount, BWebView* view);
|
||||
|
||||
void updateTitle(const BString &title);
|
||||
void updateTabGroupVisibility();
|
||||
private:
|
||||
void _UpdateTitle(const BString &title);
|
||||
void _UpdateTabGroupVisibility();
|
||||
|
||||
private:
|
||||
BMessenger m_downloadListener;
|
||||
BMenuBar* m_menuBar;
|
||||
BMenu* m_goMenu;
|
||||
IconButton* m_BackButton;
|
||||
IconButton* m_ForwardButton;
|
||||
IconButton* m_StopButton;
|
||||
BButton* m_goButton;
|
||||
BTextControl* m_url;
|
||||
BStringView* m_statusText;
|
||||
BStatusBar* m_loadingProgressBar;
|
||||
BLayoutItem* m_findGroup;
|
||||
BLayoutItem* m_tabGroup;
|
||||
BTextControl* m_findTextControl;
|
||||
BCheckBox* m_findCaseSensitiveCheckBox;
|
||||
TabManager* m_tabManager;
|
||||
BMessenger fDownloadListener;
|
||||
BMenuBar* fMenuBar;
|
||||
BMenu* fGoMenu;
|
||||
IconButton* fBackButton;
|
||||
IconButton* fForwardButton;
|
||||
IconButton* fStopButton;
|
||||
BButton* fGoButton;
|
||||
BTextControl* fURLTextControl;
|
||||
BStringView* fStatusText;
|
||||
BStatusBar* fLoadingProgressBar;
|
||||
BLayoutItem* fFindGroup;
|
||||
BLayoutItem* fTabGroup;
|
||||
BTextControl* fFindTextControl;
|
||||
BCheckBox* fFindCaseSensitiveCheckBox;
|
||||
TabManager* fTabManager;
|
||||
};
|
||||
|
||||
#endif // LauncherWindow_h
|
||||
|
||||
#endif // BROWSER_WINDOW_H
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "config.h"
|
||||
#include "BrowsingHistory.h"
|
||||
|
||||
#include "BrowserApp.h"
|
||||
#include <Autolock.h>
|
||||
#include <Entry.h>
|
||||
#include <File.h>
|
||||
@@ -262,7 +263,8 @@ bool BrowsingHistory::openSettingsFile(BFile& file, uint32 mode)
|
||||
{
|
||||
BPath path;
|
||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK
|
||||
|| path.Append("HaikuLauncher_BrowsingHistory") != B_OK) {
|
||||
|| path.Append(kApplicationName) != B_OK
|
||||
|| path.Append("BrowsingHistory") != B_OK) {
|
||||
return false;
|
||||
}
|
||||
return file.SetTo(path.Path(), mode) == B_OK;
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "config.h"
|
||||
#include "DownloadWindow.h"
|
||||
|
||||
#include "BrowserApp.h"
|
||||
#include "WebDownload.h"
|
||||
#include "WebPage.h"
|
||||
#include <Alert.h>
|
||||
@@ -550,7 +551,8 @@ bool DownloadWindow::openSettingsFile(BFile& file, uint32 mode)
|
||||
{
|
||||
BPath path;
|
||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK
|
||||
|| path.Append("HaikuLauncher_Downloads") != B_OK) {
|
||||
|| path.Append(kApplicationName) != B_OK
|
||||
|| path.Append("Downloads") != B_OK) {
|
||||
return false;
|
||||
}
|
||||
return file.SetTo(path.Path(), mode) == B_OK;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
resource app_signature "application/x-vnd.RJL-HaikuLauncher";
|
||||
resource app_signature "application/x-vnd.Haiku-WebPositive";
|
||||
|
||||
resource app_version {
|
||||
major = 0,
|
||||
@@ -6,8 +6,8 @@ resource app_version {
|
||||
minor = 1,
|
||||
variety = B_APPV_ALPHA,
|
||||
internal = 0,
|
||||
short_info = "HaikuLauncher",
|
||||
long_info = "HaikuLauncher ©2007-2010 The WebKit Haiku Project"
|
||||
short_info = "WebPositive",
|
||||
long_info = "WebPositive ©2007-2010 The WebKit Haiku Project"
|
||||
};
|
||||
|
||||
resource app_flags B_SINGLE_LAUNCH;
|
||||
|
||||
Reference in New Issue
Block a user