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:
+191
-160
@@ -8,10 +8,10 @@
|
|||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
|
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
@@ -27,17 +27,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "LauncherApp.h"
|
#include "BrowserApp.h"
|
||||||
|
|
||||||
|
#include "BrowserWindow.h"
|
||||||
#include "DownloadWindow.h"
|
#include "DownloadWindow.h"
|
||||||
#include "FrameView.h"
|
|
||||||
#include "GraphicsContext.h"
|
|
||||||
#include "LauncherWindow.h"
|
|
||||||
#include "WebPage.h"
|
#include "WebPage.h"
|
||||||
#include "WebView.h"
|
#include "WebView.h"
|
||||||
#include "WebViewConstants.h"
|
#include "WebViewConstants.h"
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
|
#include <Directory.h>
|
||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
@@ -45,170 +44,187 @@
|
|||||||
#include <Screen.h>
|
#include <Screen.h>
|
||||||
#include <stdio.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 {
|
enum {
|
||||||
LOAD_AT_STARTING = 'lost'
|
LOAD_AT_STARTING = 'lost'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
LauncherApp::LauncherApp()
|
BrowserApp::BrowserApp()
|
||||||
: BApplication(kApplicationSignature)
|
: BApplication(kApplicationSignature)
|
||||||
, m_windowCount(0)
|
, fWindowCount(0)
|
||||||
, m_lastWindowFrame(100, 100, 700, 750)
|
, fLastWindowFrame(100, 100, 700, 750)
|
||||||
, m_launchRefsMessage(0)
|
, fLaunchRefsMessage(0)
|
||||||
, m_initialized(false)
|
, fInitialized(false)
|
||||||
, m_downloadWindow(0)
|
, fDownloadWindow(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
LauncherApp::~LauncherApp()
|
|
||||||
|
BrowserApp::~BrowserApp()
|
||||||
{
|
{
|
||||||
delete m_launchRefsMessage;
|
delete fLaunchRefsMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherApp::AboutRequested()
|
|
||||||
|
void
|
||||||
|
BrowserApp::AboutRequested()
|
||||||
{
|
{
|
||||||
BAlert* alert = new BAlert("About HaikuLauncher",
|
BAlert* alert = new BAlert("About WebPositive",
|
||||||
"For testing WebKit...\n\nby Ryan Leavengood", "Sweet!");
|
"WebPositive\n\nby Ryan Leavengood, Andrea Anzani, "
|
||||||
alert->Go();
|
"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++) {
|
for (int i = 1; i < argc; i++) {
|
||||||
const char* url = argv[i];
|
const char* url = argv[i];
|
||||||
BEntry entry(argv[i], true);
|
BEntry entry(argv[i], true);
|
||||||
BPath path;
|
BPath path;
|
||||||
if (entry.Exists() && entry.GetPath(&path) == B_OK)
|
if (entry.Exists() && entry.GetPath(&path) == B_OK)
|
||||||
url = path.Path();
|
url = path.Path();
|
||||||
BMessage message(LOAD_AT_STARTING);
|
BMessage message(LOAD_AT_STARTING);
|
||||||
message.AddString("url", url);
|
message.AddString("url", url);
|
||||||
message.AddBool("new window", m_initialized || i > 1);
|
message.AddBool("new window", fInitialized || i > 1);
|
||||||
PostMessage(&message);
|
PostMessage(&message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherApp::ReadyToRun()
|
|
||||||
|
void
|
||||||
|
BrowserApp::ReadyToRun()
|
||||||
{
|
{
|
||||||
// Since we will essentially run the GUI...
|
// Since we will essentially run the GUI...
|
||||||
set_thread_priority(Thread(), B_DISPLAY_PRIORITY);
|
set_thread_priority(Thread(), B_DISPLAY_PRIORITY);
|
||||||
|
|
||||||
BWebPage::InitializeOnce();
|
BWebPage::InitializeOnce();
|
||||||
BWebPage::SetCacheModel(B_WEBKIT_CACHE_MODEL_WEB_BROWSER);
|
BWebPage::SetCacheModel(B_WEBKIT_CACHE_MODEL_WEB_BROWSER);
|
||||||
|
|
||||||
BFile settingsFile;
|
BFile settingsFile;
|
||||||
BRect windowFrameFromSettings = m_lastWindowFrame;
|
BRect windowFrameFromSettings = fLastWindowFrame;
|
||||||
BRect downloadWindowFrame(100, 100, 300, 250);
|
BRect downloadWindowFrame(100, 100, 300, 250);
|
||||||
bool showDownloads = false;
|
bool showDownloads = false;
|
||||||
if (openSettingsFile(settingsFile, B_READ_ONLY)) {
|
if (_OpenSettingsFile(settingsFile, B_READ_ONLY)) {
|
||||||
BMessage settingsArchive;
|
BMessage settingsArchive;
|
||||||
settingsArchive.Unflatten(&settingsFile);
|
settingsArchive.Unflatten(&settingsFile);
|
||||||
settingsArchive.FindRect("window frame", &windowFrameFromSettings);
|
settingsArchive.FindRect("window frame", &windowFrameFromSettings);
|
||||||
settingsArchive.FindRect("downloads window frame", &downloadWindowFrame);
|
settingsArchive.FindRect("downloads window frame", &downloadWindowFrame);
|
||||||
settingsArchive.FindBool("show downloads", &showDownloads);
|
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) {
|
if (fLaunchRefsMessage) {
|
||||||
RefsReceived(m_launchRefsMessage);
|
RefsReceived(fLaunchRefsMessage);
|
||||||
delete m_launchRefsMessage;
|
delete fLaunchRefsMessage;
|
||||||
m_launchRefsMessage = 0;
|
fLaunchRefsMessage = 0;
|
||||||
} else {
|
} else {
|
||||||
LauncherWindow* window = new LauncherWindow(m_lastWindowFrame,
|
BrowserWindow* window = new BrowserWindow(fLastWindowFrame,
|
||||||
BMessenger(m_downloadWindow));
|
BMessenger(fDownloadWindow));
|
||||||
window->Show();
|
window->Show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherApp::MessageReceived(BMessage* message)
|
|
||||||
|
void
|
||||||
|
BrowserApp::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
case LOAD_AT_STARTING: {
|
case LOAD_AT_STARTING: {
|
||||||
BString url;
|
|
||||||
if (message->FindString("url", &url) != B_OK)
|
|
||||||
break;
|
|
||||||
bool openNewWindow = false;
|
|
||||||
message->FindBool("new window", &openNewWindow);
|
|
||||||
LauncherWindow* webWindow = NULL;
|
|
||||||
for (int i = 0; BWindow* window = WindowAt(i); i++) {
|
|
||||||
webWindow = dynamic_cast<LauncherWindow*>(window);
|
|
||||||
if (!webWindow)
|
|
||||||
continue;
|
|
||||||
if (!openNewWindow) {
|
|
||||||
// stop at the first window
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (webWindow) {
|
|
||||||
// There should always be at least one window open. If not, maybe we are about
|
|
||||||
// to quit anyway...
|
|
||||||
if (openNewWindow) {
|
|
||||||
// open a new window with an offset to the last window
|
|
||||||
newWindow(url);
|
|
||||||
} else {
|
|
||||||
// load the URL in the first window
|
|
||||||
webWindow->CurrentWebView()->LoadURL(url.String());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case B_SILENT_RELAUNCH:
|
|
||||||
newWindow("");
|
|
||||||
break;
|
|
||||||
case NEW_WINDOW: {
|
|
||||||
BString url;
|
BString url;
|
||||||
if (message->FindString("url", &url) != B_OK)
|
if (message->FindString("url", &url) != B_OK)
|
||||||
break;
|
break;
|
||||||
newWindow(url);
|
bool openNewWindow = false;
|
||||||
break;
|
message->FindBool("new window", &openNewWindow);
|
||||||
}
|
BrowserWindow* webWindow = NULL;
|
||||||
case NEW_TAB: {
|
for (int i = 0; BWindow* window = WindowAt(i); i++) {
|
||||||
LauncherWindow* window;
|
webWindow = dynamic_cast<BrowserWindow*>(window);
|
||||||
|
if (!webWindow)
|
||||||
|
continue;
|
||||||
|
if (!openNewWindow) {
|
||||||
|
// stop at the first window
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (webWindow) {
|
||||||
|
// There should always be at least one window open. If not, maybe we are about
|
||||||
|
// to quit anyway...
|
||||||
|
if (openNewWindow) {
|
||||||
|
// open a new window with an offset to the last window
|
||||||
|
_CreateNewWindow(url);
|
||||||
|
} else {
|
||||||
|
// load the URL in the first window
|
||||||
|
webWindow->CurrentWebView()->LoadURL(url.String());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_SILENT_RELAUNCH:
|
||||||
|
_CreateNewWindow("");
|
||||||
|
break;
|
||||||
|
case NEW_WINDOW: {
|
||||||
|
BString url;
|
||||||
|
if (message->FindString("url", &url) != B_OK)
|
||||||
|
break;
|
||||||
|
_CreateNewWindow(url);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case NEW_TAB: {
|
||||||
|
BrowserWindow* window;
|
||||||
if (message->FindPointer("window", reinterpret_cast<void**>(&window)) != B_OK)
|
if (message->FindPointer("window", reinterpret_cast<void**>(&window)) != B_OK)
|
||||||
break;
|
break;
|
||||||
BString url;
|
BString url;
|
||||||
message->FindString("url", &url);
|
message->FindString("url", &url);
|
||||||
bool select = false;
|
bool select = false;
|
||||||
message->FindBool("select", &select);
|
message->FindBool("select", &select);
|
||||||
newTab(window, url, select);
|
_CreateNewTab(window, url, select);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WINDOW_OPENED:
|
case WINDOW_OPENED:
|
||||||
m_windowCount++;
|
fWindowCount++;
|
||||||
break;
|
break;
|
||||||
case WINDOW_CLOSED:
|
case WINDOW_CLOSED:
|
||||||
m_windowCount--;
|
fWindowCount--;
|
||||||
message->FindRect("window frame", &m_lastWindowFrame);
|
message->FindRect("window frame", &fLastWindowFrame);
|
||||||
if (m_windowCount <= 0)
|
if (fWindowCount <= 0)
|
||||||
PostMessage(B_QUIT_REQUESTED);
|
PostMessage(B_QUIT_REQUESTED);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SHOW_DOWNLOAD_WINDOW: {
|
case SHOW_DOWNLOAD_WINDOW: {
|
||||||
BAutolock _(m_downloadWindow);
|
BAutolock _(fDownloadWindow);
|
||||||
uint32 workspaces;
|
uint32 workspaces;
|
||||||
if (message->FindUInt32("workspaces", &workspaces) == B_OK)
|
if (message->FindUInt32("workspaces", &workspaces) == B_OK)
|
||||||
m_downloadWindow->SetWorkspaces(workspaces);
|
fDownloadWindow->SetWorkspaces(workspaces);
|
||||||
if (m_downloadWindow->IsHidden())
|
if (fDownloadWindow->IsHidden())
|
||||||
m_downloadWindow->Show();
|
fDownloadWindow->Show();
|
||||||
else
|
else
|
||||||
m_downloadWindow->Activate();
|
fDownloadWindow->Activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BApplication::MessageReceived(message);
|
BApplication::MessageReceived(message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherApp::RefsReceived(BMessage* message)
|
|
||||||
|
void
|
||||||
|
BrowserApp::RefsReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
if (!m_initialized) {
|
if (!fInitialized) {
|
||||||
delete m_launchRefsMessage;
|
delete fLaunchRefsMessage;
|
||||||
m_launchRefsMessage = new BMessage(*message);
|
fLaunchRefsMessage = new BMessage(*message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,82 +238,97 @@ void LauncherApp::RefsReceived(BMessage* message)
|
|||||||
continue;
|
continue;
|
||||||
BString url;
|
BString url;
|
||||||
url << path.Path();
|
url << path.Path();
|
||||||
newWindow(url);
|
_CreateNewWindow(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LauncherApp::QuitRequested()
|
|
||||||
|
bool
|
||||||
|
BrowserApp::QuitRequested()
|
||||||
{
|
{
|
||||||
for (int i = 0; BWindow* window = WindowAt(i); i++) {
|
for (int i = 0; BWindow* window = WindowAt(i); i++) {
|
||||||
LauncherWindow* webWindow = dynamic_cast<LauncherWindow*>(window);
|
BrowserWindow* webWindow = dynamic_cast<BrowserWindow*>(window);
|
||||||
if (!webWindow)
|
if (!webWindow)
|
||||||
continue;
|
continue;
|
||||||
if (!webWindow->Lock())
|
if (!webWindow->Lock())
|
||||||
continue;
|
continue;
|
||||||
if (webWindow->QuitRequested()) {
|
if (webWindow->QuitRequested()) {
|
||||||
m_lastWindowFrame = webWindow->Frame();
|
fLastWindowFrame = webWindow->Frame();
|
||||||
webWindow->Quit();
|
webWindow->Quit();
|
||||||
i--;
|
i--;
|
||||||
} else {
|
} else {
|
||||||
webWindow->Unlock();
|
webWindow->Unlock();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BFile settingsFile;
|
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;
|
BMessage settingsArchive;
|
||||||
settingsArchive.AddRect("window frame", m_lastWindowFrame);
|
settingsArchive.AddRect("window frame", fLastWindowFrame);
|
||||||
if (m_downloadWindow->Lock()) {
|
if (fDownloadWindow->Lock()) {
|
||||||
settingsArchive.AddRect("downloads window frame", m_downloadWindow->Frame());
|
settingsArchive.AddRect("downloads window frame", fDownloadWindow->Frame());
|
||||||
settingsArchive.AddBool("show downloads", !m_downloadWindow->IsHidden());
|
settingsArchive.AddBool("show downloads", !fDownloadWindow->IsHidden());
|
||||||
m_downloadWindow->Unlock();
|
fDownloadWindow->Unlock();
|
||||||
}
|
}
|
||||||
settingsArchive.Flatten(&settingsFile);
|
settingsArchive.Flatten(&settingsFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LauncherApp::openSettingsFile(BFile& file, uint32 mode)
|
|
||||||
|
bool
|
||||||
|
BrowserApp::_OpenSettingsFile(BFile& file, uint32 mode)
|
||||||
{
|
{
|
||||||
BPath path;
|
BPath path;
|
||||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK
|
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 false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return file.SetTo(path.Path(), mode) == B_OK;
|
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,
|
void
|
||||||
BMessenger(m_downloadWindow));
|
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();
|
window->Show();
|
||||||
if (url.Length())
|
if (url.Length())
|
||||||
window->CurrentWebView()->LoadURL(url.String());
|
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())
|
if (!window->Lock())
|
||||||
return;
|
return;
|
||||||
window->newTab(url, select);
|
window->CreateNewTab(url, select);
|
||||||
window->Unlock();
|
window->Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
int main(int, char**)
|
|
||||||
{
|
|
||||||
new LauncherApp();
|
|
||||||
be_app->Run();
|
|
||||||
delete be_app;
|
|
||||||
|
|
||||||
return 0;
|
int
|
||||||
|
main(int, char**)
|
||||||
|
{
|
||||||
|
new BrowserApp();
|
||||||
|
be_app->Run();
|
||||||
|
delete be_app;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,10 +8,10 @@
|
|||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
|
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
@@ -25,43 +25,49 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* 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 <Application.h>
|
||||||
#include <Rect.h>
|
#include <Rect.h>
|
||||||
|
|
||||||
class BFile;
|
class BFile;
|
||||||
class DownloadWindow;
|
class DownloadWindow;
|
||||||
class LauncherWindow;
|
class BrowserWindow;
|
||||||
|
|
||||||
class LauncherApp : public BApplication {
|
|
||||||
|
class BrowserApp : public BApplication {
|
||||||
public:
|
public:
|
||||||
LauncherApp();
|
BrowserApp();
|
||||||
virtual ~LauncherApp();
|
virtual ~BrowserApp();
|
||||||
|
|
||||||
virtual void AboutRequested();
|
virtual void AboutRequested();
|
||||||
virtual void ArgvReceived(int32, char**);
|
virtual void ArgvReceived(int32 agrc, char** argv);
|
||||||
virtual void MessageReceived(BMessage*);
|
virtual void MessageReceived(BMessage* message);
|
||||||
virtual void RefsReceived(BMessage*);
|
virtual void RefsReceived(BMessage* message);
|
||||||
virtual void ReadyToRun();
|
virtual void ReadyToRun();
|
||||||
virtual bool QuitRequested();
|
virtual bool QuitRequested();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool openSettingsFile(BFile& file, uint32 mode);
|
bool _OpenSettingsFile(BFile& file, uint32 mode);
|
||||||
void newWindow(const BString& url);
|
void _CreateNewWindow(const BString& url);
|
||||||
void newTab(LauncherWindow* window, const BString& url, bool select);
|
void _CreateNewTab(BrowserWindow* window,
|
||||||
|
const BString& url, bool select);
|
||||||
|
|
||||||
int m_windowCount;
|
private:
|
||||||
BRect m_lastWindowFrame;
|
int fWindowCount;
|
||||||
BMessage* m_launchRefsMessage;
|
BRect fLastWindowFrame;
|
||||||
bool m_initialized;
|
BMessage* fLaunchRefsMessage;
|
||||||
|
bool fInitialized;
|
||||||
|
|
||||||
DownloadWindow* m_downloadWindow;
|
DownloadWindow* fDownloadWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
extern const char* kApplicationSignature;
|
extern const char* kApplicationSignature;
|
||||||
|
extern const char* kApplicationName;
|
||||||
|
|
||||||
#endif // LauncherApp_h
|
|
||||||
|
#endif // BROWSER_APP_H
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -26,9 +26,9 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* 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 "WebWindow.h"
|
||||||
#include <Messenger.h>
|
#include <Messenger.h>
|
||||||
@@ -46,75 +46,91 @@ class TabManager;
|
|||||||
class BWebView;
|
class BWebView;
|
||||||
|
|
||||||
enum ToolbarPolicy {
|
enum ToolbarPolicy {
|
||||||
HaveToolbar,
|
HaveToolbar,
|
||||||
DoNotHaveToolbar
|
DoNotHaveToolbar
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
NEW_WINDOW = 'nwnd',
|
NEW_WINDOW = 'nwnd',
|
||||||
NEW_TAB = 'ntab',
|
NEW_TAB = 'ntab',
|
||||||
WINDOW_OPENED = 'wndo',
|
WINDOW_OPENED = 'wndo',
|
||||||
WINDOW_CLOSED = 'wndc',
|
WINDOW_CLOSED = 'wndc',
|
||||||
SHOW_DOWNLOAD_WINDOW = 'sdwd'
|
SHOW_DOWNLOAD_WINDOW = 'sdwd'
|
||||||
};
|
};
|
||||||
|
|
||||||
class LauncherWindow : public BWebWindow {
|
|
||||||
|
class BrowserWindow : public BWebWindow {
|
||||||
public:
|
public:
|
||||||
LauncherWindow(BRect frame, const BMessenger& downloadListener,
|
BrowserWindow(BRect frame,
|
||||||
ToolbarPolicy = HaveToolbar);
|
const BMessenger& downloadListener,
|
||||||
virtual ~LauncherWindow();
|
ToolbarPolicy = HaveToolbar);
|
||||||
|
virtual ~BrowserWindow();
|
||||||
|
|
||||||
virtual void DispatchMessage(BMessage* message, BHandler* target);
|
virtual void DispatchMessage(BMessage* message,
|
||||||
virtual void MessageReceived(BMessage* message);
|
BHandler* target);
|
||||||
virtual bool QuitRequested();
|
virtual void MessageReceived(BMessage* message);
|
||||||
virtual void MenusBeginning();
|
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:
|
private:
|
||||||
// WebPage notification API implementations
|
// WebPage notification API implementations
|
||||||
virtual void NavigationRequested(const BString& url, BWebView* view);
|
virtual void NavigationRequested(const BString& url,
|
||||||
virtual void NewWindowRequested(const BString& url, bool primaryAction);
|
BWebView* view);
|
||||||
virtual void NewPageCreated(BWebView* view);
|
virtual void NewWindowRequested(const BString& url,
|
||||||
virtual void LoadNegotiating(const BString& url, BWebView* view);
|
bool primaryAction);
|
||||||
virtual void LoadCommitted(const BString& url, BWebView* view);
|
virtual void NewPageCreated(BWebView* view);
|
||||||
virtual void LoadProgress(float progress, BWebView* view);
|
virtual void LoadNegotiating(const BString& url,
|
||||||
virtual void LoadFailed(const BString& url, BWebView* view);
|
BWebView* view);
|
||||||
virtual void LoadFinished(const BString& url, BWebView* view);
|
virtual void LoadCommitted(const BString& url,
|
||||||
virtual void TitleChanged(const BString& title, BWebView* view);
|
BWebView* view);
|
||||||
virtual void ResizeRequested(float width, float height, BWebView* view);
|
virtual void LoadProgress(float progress, BWebView* view);
|
||||||
virtual void SetToolBarsVisible(bool flag, BWebView* view);
|
virtual void LoadFailed(const BString& url, BWebView* view);
|
||||||
virtual void SetStatusBarVisible(bool flag, BWebView* view);
|
virtual void LoadFinished(const BString& url,
|
||||||
virtual void SetMenuBarVisible(bool flag, BWebView* view);
|
BWebView* view);
|
||||||
virtual void SetResizable(bool flag, BWebView* view);
|
virtual void TitleChanged(const BString& title,
|
||||||
virtual void StatusChanged(const BString& status, BWebView* view);
|
BWebView* view);
|
||||||
virtual void NavigationCapabilitiesChanged(bool canGoBackward,
|
virtual void ResizeRequested(float width, float height,
|
||||||
bool canGoForward, bool canStop, BWebView* view);
|
BWebView* view);
|
||||||
virtual void UpdateGlobalHistory(const BString& url);
|
virtual void SetToolBarsVisible(bool flag, BWebView* view);
|
||||||
virtual bool AuthenticationChallenge(BString message, BString& inOutUser,
|
virtual void SetStatusBarVisible(bool flag, BWebView* view);
|
||||||
BString& inOutPassword, bool& inOutRememberCredentials,
|
virtual void SetMenuBarVisible(bool flag, BWebView* view);
|
||||||
uint32 failureCount, BWebView* view);
|
virtual void SetResizable(bool flag, BWebView* view);
|
||||||
|
virtual void StatusChanged(const BString& status,
|
||||||
void updateTitle(const BString &title);
|
BWebView* view);
|
||||||
void updateTabGroupVisibility();
|
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,
|
||||||
|
uint32 failureCount, BWebView* view);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BMessenger m_downloadListener;
|
void _UpdateTitle(const BString &title);
|
||||||
BMenuBar* m_menuBar;
|
void _UpdateTabGroupVisibility();
|
||||||
BMenu* m_goMenu;
|
|
||||||
IconButton* m_BackButton;
|
private:
|
||||||
IconButton* m_ForwardButton;
|
BMessenger fDownloadListener;
|
||||||
IconButton* m_StopButton;
|
BMenuBar* fMenuBar;
|
||||||
BButton* m_goButton;
|
BMenu* fGoMenu;
|
||||||
BTextControl* m_url;
|
IconButton* fBackButton;
|
||||||
BStringView* m_statusText;
|
IconButton* fForwardButton;
|
||||||
BStatusBar* m_loadingProgressBar;
|
IconButton* fStopButton;
|
||||||
BLayoutItem* m_findGroup;
|
BButton* fGoButton;
|
||||||
BLayoutItem* m_tabGroup;
|
BTextControl* fURLTextControl;
|
||||||
BTextControl* m_findTextControl;
|
BStringView* fStatusText;
|
||||||
BCheckBox* m_findCaseSensitiveCheckBox;
|
BStatusBar* fLoadingProgressBar;
|
||||||
TabManager* m_tabManager;
|
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 "config.h"
|
||||||
#include "BrowsingHistory.h"
|
#include "BrowsingHistory.h"
|
||||||
|
|
||||||
|
#include "BrowserApp.h"
|
||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
@@ -262,7 +263,8 @@ bool BrowsingHistory::openSettingsFile(BFile& file, uint32 mode)
|
|||||||
{
|
{
|
||||||
BPath path;
|
BPath path;
|
||||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK
|
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 false;
|
||||||
}
|
}
|
||||||
return file.SetTo(path.Path(), mode) == B_OK;
|
return file.SetTo(path.Path(), mode) == B_OK;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "DownloadWindow.h"
|
#include "DownloadWindow.h"
|
||||||
|
|
||||||
|
#include "BrowserApp.h"
|
||||||
#include "WebDownload.h"
|
#include "WebDownload.h"
|
||||||
#include "WebPage.h"
|
#include "WebPage.h"
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
@@ -550,7 +551,8 @@ bool DownloadWindow::openSettingsFile(BFile& file, uint32 mode)
|
|||||||
{
|
{
|
||||||
BPath path;
|
BPath path;
|
||||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK
|
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 false;
|
||||||
}
|
}
|
||||||
return file.SetTo(path.Path(), mode) == B_OK;
|
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 {
|
resource app_version {
|
||||||
major = 0,
|
major = 0,
|
||||||
@@ -6,8 +6,8 @@ resource app_version {
|
|||||||
minor = 1,
|
minor = 1,
|
||||||
variety = B_APPV_ALPHA,
|
variety = B_APPV_ALPHA,
|
||||||
internal = 0,
|
internal = 0,
|
||||||
short_info = "HaikuLauncher",
|
short_info = "WebPositive",
|
||||||
long_info = "HaikuLauncher ©2007-2010 The WebKit Haiku Project"
|
long_info = "WebPositive ©2007-2010 The WebKit Haiku Project"
|
||||||
};
|
};
|
||||||
|
|
||||||
resource app_flags B_SINGLE_LAUNCH;
|
resource app_flags B_SINGLE_LAUNCH;
|
||||||
|
|||||||
Reference in New Issue
Block a user