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 "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,35 +44,46 @@
|
|||||||
#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, "
|
||||||
|
"Maxime Simone, Michael Lotz, Rene Gollent and Stephan Aßmus",
|
||||||
|
"Sweet!");
|
||||||
alert->Go();
|
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];
|
||||||
@@ -83,12 +93,14 @@ void LauncherApp::ArgvReceived(int32 argc, char** argv)
|
|||||||
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);
|
||||||
@@ -97,34 +109,36 @@ void LauncherApp::ReadyToRun()
|
|||||||
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: {
|
||||||
@@ -133,9 +147,9 @@ void LauncherApp::MessageReceived(BMessage* message)
|
|||||||
break;
|
break;
|
||||||
bool openNewWindow = false;
|
bool openNewWindow = false;
|
||||||
message->FindBool("new window", &openNewWindow);
|
message->FindBool("new window", &openNewWindow);
|
||||||
LauncherWindow* webWindow = NULL;
|
BrowserWindow* webWindow = NULL;
|
||||||
for (int i = 0; BWindow* window = WindowAt(i); i++) {
|
for (int i = 0; BWindow* window = WindowAt(i); i++) {
|
||||||
webWindow = dynamic_cast<LauncherWindow*>(window);
|
webWindow = dynamic_cast<BrowserWindow*>(window);
|
||||||
if (!webWindow)
|
if (!webWindow)
|
||||||
continue;
|
continue;
|
||||||
if (!openNewWindow) {
|
if (!openNewWindow) {
|
||||||
@@ -148,7 +162,7 @@ void LauncherApp::MessageReceived(BMessage* message)
|
|||||||
// to quit anyway...
|
// to quit anyway...
|
||||||
if (openNewWindow) {
|
if (openNewWindow) {
|
||||||
// open a new window with an offset to the last window
|
// open a new window with an offset to the last window
|
||||||
newWindow(url);
|
_CreateNewWindow(url);
|
||||||
} else {
|
} else {
|
||||||
// load the URL in the first window
|
// load the URL in the first window
|
||||||
webWindow->CurrentWebView()->LoadURL(url.String());
|
webWindow->CurrentWebView()->LoadURL(url.String());
|
||||||
@@ -157,45 +171,45 @@ void LauncherApp::MessageReceived(BMessage* message)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_SILENT_RELAUNCH:
|
case B_SILENT_RELAUNCH:
|
||||||
newWindow("");
|
_CreateNewWindow("");
|
||||||
break;
|
break;
|
||||||
case NEW_WINDOW: {
|
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);
|
_CreateNewWindow(url);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case NEW_TAB: {
|
case NEW_TAB: {
|
||||||
LauncherWindow* window;
|
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:
|
||||||
@@ -204,11 +218,13 @@ void LauncherApp::MessageReceived(BMessage* message)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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,20 +238,22 @@ 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 {
|
||||||
@@ -245,13 +263,13 @@ bool LauncherApp::QuitRequested()
|
|||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
@@ -259,42 +277,55 @@ bool LauncherApp::QuitRequested()
|
|||||||
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**)
|
|
||||||
|
int
|
||||||
|
main(int, char**)
|
||||||
{
|
{
|
||||||
new LauncherApp();
|
new BrowserApp();
|
||||||
be_app->Run();
|
be_app->Run();
|
||||||
delete be_app;
|
delete be_app;
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -31,12 +31,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "LauncherWindow.h"
|
#include "BrowserWindow.h"
|
||||||
|
|
||||||
#include "AuthenticationPanel.h"
|
#include "AuthenticationPanel.h"
|
||||||
|
#include "BrowserApp.h"
|
||||||
#include "BrowsingHistory.h"
|
#include "BrowsingHistory.h"
|
||||||
#include "IconButton.h"
|
#include "IconButton.h"
|
||||||
#include "LauncherApp.h"
|
|
||||||
#include "WebPage.h"
|
#include "WebPage.h"
|
||||||
#include "WebTabView.h"
|
#include "WebTabView.h"
|
||||||
#include "WebView.h"
|
#include "WebView.h"
|
||||||
@@ -61,6 +61,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
OPEN_LOCATION = 'open',
|
OPEN_LOCATION = 'open',
|
||||||
GO_BACK = 'goba',
|
GO_BACK = 'goba',
|
||||||
@@ -80,31 +81,32 @@ enum {
|
|||||||
TEXT_FIND_PREVIOUS = 'fndp',
|
TEXT_FIND_PREVIOUS = 'fndp',
|
||||||
};
|
};
|
||||||
|
|
||||||
using namespace WebCore;
|
|
||||||
|
|
||||||
static BLayoutItem* layoutItemFor(BView* view)
|
static BLayoutItem*
|
||||||
|
layoutItemFor(BView* view)
|
||||||
{
|
{
|
||||||
BLayout* layout = view->Parent()->GetLayout();
|
BLayout* layout = view->Parent()->GetLayout();
|
||||||
int32 index = layout->IndexOfView(view);
|
int32 index = layout->IndexOfView(view);
|
||||||
return layout->ItemAt(index);
|
return layout->ItemAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
LauncherWindow::LauncherWindow(BRect frame, const BMessenger& downloadListener,
|
|
||||||
|
BrowserWindow::BrowserWindow(BRect frame, const BMessenger& downloadListener,
|
||||||
ToolbarPolicy toolbarPolicy)
|
ToolbarPolicy toolbarPolicy)
|
||||||
: BWebWindow(frame, "HaikuLauncher",
|
: BWebWindow(frame, kApplicationName,
|
||||||
B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
|
B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
|
||||||
B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS)
|
B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS)
|
||||||
, m_downloadListener(downloadListener)
|
, fDownloadListener(downloadListener)
|
||||||
{
|
{
|
||||||
BMessage* newTabMessage = new BMessage(NEW_TAB);
|
BMessage* newTabMessage = new BMessage(NEW_TAB);
|
||||||
newTabMessage->AddString("url", "");
|
newTabMessage->AddString("url", "");
|
||||||
newTabMessage->AddPointer("window", this);
|
newTabMessage->AddPointer("window", this);
|
||||||
newTabMessage->AddBool("select", true);
|
newTabMessage->AddBool("select", true);
|
||||||
m_tabManager = new TabManager(BMessenger(this), newTabMessage);
|
fTabManager = new TabManager(BMessenger(this), newTabMessage);
|
||||||
|
|
||||||
if (toolbarPolicy == HaveToolbar) {
|
if (toolbarPolicy == HaveToolbar) {
|
||||||
// Menu
|
// Menu
|
||||||
m_menuBar = new BMenuBar("Main menu");
|
fMenuBar = new BMenuBar("Main menu");
|
||||||
BMenu* menu = new BMenu("Window");
|
BMenu* menu = new BMenu("Window");
|
||||||
BMessage* newWindowMessage = new BMessage(NEW_WINDOW);
|
BMessage* newWindowMessage = new BMessage(NEW_WINDOW);
|
||||||
newWindowMessage->AddString("url", "");
|
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');
|
BMenuItem* quitItem = new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q');
|
||||||
menu->AddItem(quitItem);
|
menu->AddItem(quitItem);
|
||||||
quitItem->SetTarget(be_app);
|
quitItem->SetTarget(be_app);
|
||||||
m_menuBar->AddItem(menu);
|
fMenuBar->AddItem(menu);
|
||||||
|
|
||||||
menu = new BMenu("Text");
|
menu = new BMenu("Text");
|
||||||
menu->AddItem(new BMenuItem("Find", new BMessage(TEXT_SHOW_FIND_GROUP), 'F'));
|
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("Increase size", new BMessage(TEXT_SIZE_INCREASE), '+'));
|
||||||
menu->AddItem(new BMenuItem("Decrease size", new BMessage(TEXT_SIZE_DECREASE), '-'));
|
menu->AddItem(new BMenuItem("Decrease size", new BMessage(TEXT_SIZE_DECREASE), '-'));
|
||||||
menu->AddItem(new BMenuItem("Reset size", new BMessage(TEXT_SIZE_RESET), '0'));
|
menu->AddItem(new BMenuItem("Reset size", new BMessage(TEXT_SIZE_RESET), '0'));
|
||||||
m_menuBar->AddItem(menu);
|
fMenuBar->AddItem(menu);
|
||||||
|
|
||||||
m_goMenu = new BMenu("Go");
|
fGoMenu = new BMenu("Go");
|
||||||
m_menuBar->AddItem(m_goMenu);
|
fMenuBar->AddItem(fGoMenu);
|
||||||
|
|
||||||
// Back, Forward & Stop
|
// Back, Forward & Stop
|
||||||
m_BackButton = new IconButton("Back", 0, NULL, new BMessage(GO_BACK));
|
fBackButton = new IconButton("Back", 0, NULL, new BMessage(GO_BACK));
|
||||||
m_BackButton->SetIcon(201);
|
fBackButton->SetIcon(201);
|
||||||
m_BackButton->TrimIcon();
|
fBackButton->TrimIcon();
|
||||||
|
|
||||||
m_ForwardButton = new IconButton("Forward", 0, NULL, new BMessage(GO_FORWARD));
|
fForwardButton = new IconButton("Forward", 0, NULL, new BMessage(GO_FORWARD));
|
||||||
m_ForwardButton->SetIcon(202);
|
fForwardButton->SetIcon(202);
|
||||||
m_ForwardButton->TrimIcon();
|
fForwardButton->TrimIcon();
|
||||||
|
|
||||||
m_StopButton = new IconButton("Stop", 0, NULL, new BMessage(STOP));
|
fStopButton = new IconButton("Stop", 0, NULL, new BMessage(STOP));
|
||||||
m_StopButton->SetIcon(204);
|
fStopButton->SetIcon(204);
|
||||||
m_StopButton->TrimIcon();
|
fStopButton->TrimIcon();
|
||||||
|
|
||||||
// URL
|
// URL
|
||||||
m_url = new BTextControl("url", "", "", NULL);
|
fURLTextControl = new BTextControl("url", "", "", NULL);
|
||||||
m_url->SetDivider(50.0);
|
fURLTextControl->SetDivider(50.0);
|
||||||
|
|
||||||
// Go
|
// Go
|
||||||
m_goButton = new BButton("", "Go", new BMessage(GOTO_URL));
|
fGoButton = new BButton("", "Go", new BMessage(GOTO_URL));
|
||||||
|
|
||||||
// Status Bar
|
// Status Bar
|
||||||
m_statusText = new BStringView("status", "");
|
fStatusText = new BStringView("status", "");
|
||||||
m_statusText->SetAlignment(B_ALIGN_LEFT);
|
fStatusText->SetAlignment(B_ALIGN_LEFT);
|
||||||
m_statusText->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
|
fStatusText->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
|
||||||
m_statusText->SetExplicitMinSize(BSize(150, 12));
|
fStatusText->SetExplicitMinSize(BSize(150, 12));
|
||||||
// Prevent the window from growing to fit a long status message...
|
// Prevent the window from growing to fit a long status message...
|
||||||
BFont font(be_plain_font);
|
BFont font(be_plain_font);
|
||||||
font.SetSize(ceilf(font.Size() * 0.8));
|
font.SetSize(ceilf(font.Size() * 0.8));
|
||||||
m_statusText->SetFont(&font, B_FONT_SIZE);
|
fStatusText->SetFont(&font, B_FONT_SIZE);
|
||||||
|
|
||||||
// Loading progress bar
|
// Loading progress bar
|
||||||
m_loadingProgressBar = new BStatusBar("progress");
|
fLoadingProgressBar = new BStatusBar("progress");
|
||||||
m_loadingProgressBar->SetMaxValue(100);
|
fLoadingProgressBar->SetMaxValue(100);
|
||||||
m_loadingProgressBar->Hide();
|
fLoadingProgressBar->Hide();
|
||||||
m_loadingProgressBar->SetBarHeight(12);
|
fLoadingProgressBar->SetBarHeight(12);
|
||||||
|
|
||||||
const float kInsetSpacing = 5;
|
const float kInsetSpacing = 5;
|
||||||
const float kElementSpacing = 7;
|
const float kElementSpacing = 7;
|
||||||
|
|
||||||
m_findTextControl = new BTextControl("find", "Find:", "",
|
fFindTextControl = new BTextControl("find", "Find:", "",
|
||||||
new BMessage(TEXT_FIND_NEXT));
|
new BMessage(TEXT_FIND_NEXT));
|
||||||
m_findCaseSensitiveCheckBox = new BCheckBox("Match case");
|
fFindCaseSensitiveCheckBox = new BCheckBox("Match case");
|
||||||
BView* findGroup = BGroupLayoutBuilder(B_VERTICAL)
|
BView* findGroup = BGroupLayoutBuilder(B_VERTICAL)
|
||||||
.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
|
.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
|
||||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL, kElementSpacing)
|
.Add(BGroupLayoutBuilder(B_HORIZONTAL, kElementSpacing)
|
||||||
.Add(m_findTextControl)
|
.Add(fFindTextControl)
|
||||||
.Add(new BButton("Previous", new BMessage(TEXT_FIND_PREVIOUS)))
|
.Add(new BButton("Previous", new BMessage(TEXT_FIND_PREVIOUS)))
|
||||||
.Add(new BButton("Next", new BMessage(TEXT_FIND_NEXT)))
|
.Add(new BButton("Next", new BMessage(TEXT_FIND_NEXT)))
|
||||||
.Add(m_findCaseSensitiveCheckBox)
|
.Add(fFindCaseSensitiveCheckBox)
|
||||||
.Add(BSpaceLayoutItem::CreateGlue())
|
.Add(BSpaceLayoutItem::CreateGlue())
|
||||||
.Add(new BButton("Close", new BMessage(TEXT_HIDE_FIND_GROUP)))
|
.Add(new BButton("Close", new BMessage(TEXT_HIDE_FIND_GROUP)))
|
||||||
.SetInsets(kInsetSpacing, kInsetSpacing,
|
.SetInsets(kInsetSpacing, kInsetSpacing,
|
||||||
@@ -194,41 +196,41 @@ LauncherWindow::LauncherWindow(BRect frame, const BMessenger& downloadListener,
|
|||||||
;
|
;
|
||||||
// Layout
|
// Layout
|
||||||
AddChild(BGroupLayoutBuilder(B_VERTICAL)
|
AddChild(BGroupLayoutBuilder(B_VERTICAL)
|
||||||
.Add(m_menuBar)
|
.Add(fMenuBar)
|
||||||
.Add(m_tabManager->TabGroup())
|
.Add(fTabManager->TabGroup())
|
||||||
.Add(BGridLayoutBuilder(kElementSpacing, kElementSpacing)
|
.Add(BGridLayoutBuilder(kElementSpacing, kElementSpacing)
|
||||||
.Add(m_BackButton, 0, 0)
|
.Add(fBackButton, 0, 0)
|
||||||
.Add(m_ForwardButton, 1, 0)
|
.Add(fForwardButton, 1, 0)
|
||||||
.Add(m_StopButton, 2, 0)
|
.Add(fStopButton, 2, 0)
|
||||||
.Add(m_url, 3, 0)
|
.Add(fURLTextControl, 3, 0)
|
||||||
.Add(m_goButton, 4, 0)
|
.Add(fGoButton, 4, 0)
|
||||||
.SetInsets(kInsetSpacing, kInsetSpacing, kInsetSpacing, kInsetSpacing)
|
.SetInsets(kInsetSpacing, kInsetSpacing, kInsetSpacing, kInsetSpacing)
|
||||||
)
|
)
|
||||||
.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
|
.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
|
||||||
.Add(m_tabManager->ContainerView())
|
.Add(fTabManager->ContainerView())
|
||||||
.Add(findGroup)
|
.Add(findGroup)
|
||||||
.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
|
.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
|
||||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL, kElementSpacing)
|
.Add(BGroupLayoutBuilder(B_HORIZONTAL, kElementSpacing)
|
||||||
.Add(m_statusText)
|
.Add(fStatusText)
|
||||||
.Add(m_loadingProgressBar, 0.2)
|
.Add(fLoadingProgressBar, 0.2)
|
||||||
.AddStrut(12 - kElementSpacing)
|
.AddStrut(12 - kElementSpacing)
|
||||||
.SetInsets(kInsetSpacing, 0, kInsetSpacing, 0)
|
.SetInsets(kInsetSpacing, 0, kInsetSpacing, 0)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
m_url->MakeFocus(true);
|
fURLTextControl->MakeFocus(true);
|
||||||
|
|
||||||
m_findGroup = layoutItemFor(findGroup);
|
fFindGroup = layoutItemFor(findGroup);
|
||||||
m_tabGroup = layoutItemFor(m_tabManager->TabGroup());
|
fTabGroup = layoutItemFor(fTabManager->TabGroup());
|
||||||
} else {
|
} else {
|
||||||
m_BackButton = 0;
|
fBackButton = 0;
|
||||||
m_ForwardButton = 0;
|
fForwardButton = 0;
|
||||||
m_StopButton = 0;
|
fStopButton = 0;
|
||||||
m_goButton = 0;
|
fGoButton = 0;
|
||||||
m_url = 0;
|
fURLTextControl = 0;
|
||||||
m_menuBar = 0;
|
fMenuBar = 0;
|
||||||
m_statusText = 0;
|
fStatusText = 0;
|
||||||
m_loadingProgressBar = 0;
|
fLoadingProgressBar = 0;
|
||||||
|
|
||||||
BWebView* webView = new BWebView("web_view");
|
BWebView* webView = new BWebView("web_view");
|
||||||
SetCurrentWebView(webView);
|
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, new BMessage(TEXT_FIND_NEXT));
|
||||||
AddShortcut('G', B_COMMAND_KEY | B_SHIFT_KEY, new BMessage(TEXT_FIND_PREVIOUS));
|
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);
|
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
|
// 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
|
// 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
|
// 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
|
if (message->FindString("bytes", &bytes) == B_OK
|
||||||
&& bytes[0] == B_RETURN) {
|
&& bytes[0] == B_RETURN) {
|
||||||
// Do it in such a way that the user sees the Go-button go down.
|
// 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();
|
UpdateIfNeeded();
|
||||||
m_goButton->Invoke();
|
fGoButton->Invoke();
|
||||||
snooze(1000);
|
snooze(1000);
|
||||||
m_goButton->SetValue(B_CONTROL_OFF);
|
fGoButton->SetValue(B_CONTROL_OFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BWebWindow::DispatchMessage(message, target);
|
BWebWindow::DispatchMessage(message, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherWindow::MessageReceived(BMessage* message)
|
|
||||||
|
void
|
||||||
|
BrowserWindow::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
case OPEN_LOCATION:
|
case OPEN_LOCATION:
|
||||||
if (m_url) {
|
if (fURLTextControl) {
|
||||||
if (m_url->TextView()->IsFocus())
|
if (fURLTextControl->TextView()->IsFocus())
|
||||||
m_url->TextView()->SelectAll();
|
fURLTextControl->TextView()->SelectAll();
|
||||||
else
|
else
|
||||||
m_url->MakeFocus(true);
|
fURLTextControl->MakeFocus(true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RELOAD:
|
case RELOAD:
|
||||||
@@ -293,7 +301,7 @@ void LauncherWindow::MessageReceived(BMessage* message)
|
|||||||
case GOTO_URL: {
|
case GOTO_URL: {
|
||||||
BString url;
|
BString url;
|
||||||
if (message->FindString("url", &url) != B_OK)
|
if (message->FindString("url", &url) != B_OK)
|
||||||
url = m_url->Text();
|
url = fURLTextControl->Text();
|
||||||
CurrentWebView()->LoadURL(url.String());
|
CurrentWebView()->LoadURL(url.String());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -311,8 +319,8 @@ void LauncherWindow::MessageReceived(BMessage* message)
|
|||||||
BrowsingHistory* history = BrowsingHistory::defaultInstance();
|
BrowsingHistory* history = BrowsingHistory::defaultInstance();
|
||||||
if (history->countItems() == 0)
|
if (history->countItems() == 0)
|
||||||
break;
|
break;
|
||||||
BAlert* alert = new BAlert("Confirmation", "Do you really want to clear "
|
BAlert* alert = new BAlert("Confirmation", "Do you really want to "
|
||||||
"the browsing history?", "Clear", "Cancel");
|
"clear the browsing history?", "Clear", "Cancel");
|
||||||
if (alert->Go() == 0)
|
if (alert->Go() == 0)
|
||||||
history->clear();
|
history->clear();
|
||||||
break;
|
break;
|
||||||
@@ -355,21 +363,21 @@ void LauncherWindow::MessageReceived(BMessage* message)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case TEXT_FIND_NEXT:
|
case TEXT_FIND_NEXT:
|
||||||
CurrentWebView()->FindString(m_findTextControl->Text(), true,
|
CurrentWebView()->FindString(fFindTextControl->Text(), true,
|
||||||
m_findCaseSensitiveCheckBox->Value());
|
fFindCaseSensitiveCheckBox->Value());
|
||||||
break;
|
break;
|
||||||
case TEXT_FIND_PREVIOUS:
|
case TEXT_FIND_PREVIOUS:
|
||||||
CurrentWebView()->FindString(m_findTextControl->Text(), false,
|
CurrentWebView()->FindString(fFindTextControl->Text(), false,
|
||||||
m_findCaseSensitiveCheckBox->Value());
|
fFindCaseSensitiveCheckBox->Value());
|
||||||
break;
|
break;
|
||||||
case TEXT_SHOW_FIND_GROUP:
|
case TEXT_SHOW_FIND_GROUP:
|
||||||
if (!m_findGroup->IsVisible())
|
if (!fFindGroup->IsVisible())
|
||||||
m_findGroup->SetVisible(true);
|
fFindGroup->SetVisible(true);
|
||||||
m_findTextControl->MakeFocus(true);
|
fFindTextControl->MakeFocus(true);
|
||||||
break;
|
break;
|
||||||
case TEXT_HIDE_FIND_GROUP:
|
case TEXT_HIDE_FIND_GROUP:
|
||||||
if (m_findGroup->IsVisible())
|
if (fFindGroup->IsVisible())
|
||||||
m_findGroup->SetVisible(false);
|
fFindGroup->SetVisible(false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SHOW_DOWNLOAD_WINDOW:
|
case SHOW_DOWNLOAD_WINDOW:
|
||||||
@@ -378,12 +386,12 @@ void LauncherWindow::MessageReceived(BMessage* message)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CLOSE_TAB:
|
case CLOSE_TAB:
|
||||||
if (m_tabManager->CountTabs() > 1) {
|
if (fTabManager->CountTabs() > 1) {
|
||||||
int32 index;
|
int32 index;
|
||||||
if (message->FindInt32("tab index", &index) != B_OK)
|
if (message->FindInt32("tab index", &index) != B_OK)
|
||||||
index = m_tabManager->SelectedTabIndex();
|
index = fTabManager->SelectedTabIndex();
|
||||||
delete m_tabManager->RemoveTab(index);
|
delete fTabManager->RemoveTab(index);
|
||||||
updateTabGroupVisibility();
|
_UpdateTabGroupVisibility();
|
||||||
} else
|
} else
|
||||||
PostMessage(B_QUIT_REQUESTED);
|
PostMessage(B_QUIT_REQUESTED);
|
||||||
break;
|
break;
|
||||||
@@ -393,16 +401,16 @@ void LauncherWindow::MessageReceived(BMessage* message)
|
|||||||
int32 index;
|
int32 index;
|
||||||
if (message->FindInt32("tab index", &index) != B_OK)
|
if (message->FindInt32("tab index", &index) != B_OK)
|
||||||
index = -1;
|
index = -1;
|
||||||
BWebView* webView = dynamic_cast<BWebView*>(m_tabManager->ViewForTab(index));
|
BWebView* webView = dynamic_cast<BWebView*>(fTabManager->ViewForTab(index));
|
||||||
if (webView == CurrentWebView())
|
if (webView == CurrentWebView())
|
||||||
break;
|
break;
|
||||||
SetCurrentWebView(webView);
|
SetCurrentWebView(webView);
|
||||||
if (webView)
|
if (webView)
|
||||||
updateTitle(webView->MainFrameTitle());
|
_UpdateTitle(webView->MainFrameTitle());
|
||||||
else
|
else
|
||||||
updateTitle("");
|
_UpdateTitle("");
|
||||||
if (webView) {
|
if (webView) {
|
||||||
m_url->SetText(webView->MainFrameURL());
|
fURLTextControl->SetText(webView->MainFrameURL());
|
||||||
// Trigger update of the interface to the new page, by requesting
|
// Trigger update of the interface to the new page, by requesting
|
||||||
// to resend all notifications.
|
// to resend all notifications.
|
||||||
webView->WebPage()->ResendNotifications();
|
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.
|
// TODO: Check for modified form data and ask user for confirmation, etc.
|
||||||
|
|
||||||
// Iterate over all tabs to delete all BWebViews.
|
// Iterate over all tabs to delete all BWebViews.
|
||||||
// Do this here, so WebKit tear down happens earlier.
|
// Do this here, so WebKit tear down happens earlier.
|
||||||
while (m_tabManager->CountTabs() > 0)
|
while (fTabManager->CountTabs() > 0)
|
||||||
delete m_tabManager->RemoveTab(0L);
|
delete fTabManager->RemoveTab(0L);
|
||||||
SetCurrentWebView(0);
|
SetCurrentWebView(0);
|
||||||
|
|
||||||
BMessage message(WINDOW_CLOSED);
|
BMessage message(WINDOW_CLOSED);
|
||||||
@@ -432,10 +442,12 @@ bool LauncherWindow::QuitRequested()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherWindow::MenusBeginning()
|
|
||||||
|
void
|
||||||
|
BrowserWindow::MenusBeginning()
|
||||||
{
|
{
|
||||||
BMenuItem* menuItem;
|
BMenuItem* menuItem;
|
||||||
while ((menuItem = m_goMenu->RemoveItem(0L)))
|
while ((menuItem = fGoMenu->RemoveItem(0L)))
|
||||||
delete menuItem;
|
delete menuItem;
|
||||||
|
|
||||||
BrowsingHistory* history = BrowsingHistory::defaultInstance();
|
BrowsingHistory* history = BrowsingHistory::defaultInstance();
|
||||||
@@ -451,50 +463,58 @@ void LauncherWindow::MenusBeginning()
|
|||||||
BString truncatedUrl(historyItem.url());
|
BString truncatedUrl(historyItem.url());
|
||||||
be_plain_font->TruncateString(&truncatedUrl, B_TRUNCATE_END, 480);
|
be_plain_font->TruncateString(&truncatedUrl, B_TRUNCATE_END, 480);
|
||||||
menuItem = new BMenuItem(truncatedUrl, message);
|
menuItem = new BMenuItem(truncatedUrl, message);
|
||||||
m_goMenu->AddItem(menuItem);
|
fGoMenu->AddItem(menuItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (m_goMenu->CountItems() > 3) {
|
if (fGoMenu->CountItems() > 3) {
|
||||||
m_goMenu->AddSeparatorItem();
|
fGoMenu->AddSeparatorItem();
|
||||||
m_goMenu->AddItem(new BMenuItem("Clear history", new BMessage(CLEAR_HISTORY)));
|
fGoMenu->AddItem(new BMenuItem("Clear history",
|
||||||
|
new BMessage(CLEAR_HISTORY)));
|
||||||
}
|
}
|
||||||
|
|
||||||
history->Unlock();
|
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).
|
// Executed in app thread (new BWebPage needs to be created in app thread).
|
||||||
if (!webView)
|
if (!webView)
|
||||||
webView = new BWebView("web view");
|
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())
|
if (url.Length())
|
||||||
webView->LoadURL(url.String());
|
webView->LoadURL(url.String());
|
||||||
|
|
||||||
if (select) {
|
if (select) {
|
||||||
m_tabManager->SelectTab(m_tabManager->CountTabs() - 1);
|
fTabManager->SelectTab(fTabManager->CountTabs() - 1);
|
||||||
SetCurrentWebView(webView);
|
SetCurrentWebView(webView);
|
||||||
NavigationCapabilitiesChanged(false, false, false, webView);
|
NavigationCapabilitiesChanged(false, false, false, webView);
|
||||||
if (m_url) {
|
if (fURLTextControl) {
|
||||||
m_url->SetText(url.String());
|
fURLTextControl->SetText(url.String());
|
||||||
m_url->MakeFocus(true);
|
fURLTextControl->MakeFocus(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTabGroupVisibility();
|
_UpdateTabGroupVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark - Notification API
|
// #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
|
// Always open new windows in the application thread, since
|
||||||
// creating a BWebView will try to grab the application lock.
|
// 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);
|
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: ");
|
BString status("Requesting: ");
|
||||||
status << url;
|
status << url;
|
||||||
StatusChanged(status, view);
|
StatusChanged(status, view);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherWindow::LoadCommitted(const BString& url, BWebView* view)
|
|
||||||
|
void
|
||||||
|
BrowserWindow::LoadCommitted(const BString& url, BWebView* view)
|
||||||
{
|
{
|
||||||
if (view != CurrentWebView())
|
if (view != CurrentWebView())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// This hook is invoked when the load is commited.
|
// This hook is invoked when the load is commited.
|
||||||
if (m_url)
|
if (fURLTextControl)
|
||||||
m_url->SetText(url.String());
|
fURLTextControl->SetText(url.String());
|
||||||
|
|
||||||
BString status("Loading: ");
|
BString status("Loading: ");
|
||||||
status << url;
|
status << url;
|
||||||
StatusChanged(status, view);
|
StatusChanged(status, view);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherWindow::LoadProgress(float progress, BWebView* view)
|
|
||||||
|
void
|
||||||
|
BrowserWindow::LoadProgress(float progress, BWebView* view)
|
||||||
{
|
{
|
||||||
if (view != CurrentWebView())
|
if (view != CurrentWebView())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_loadingProgressBar) {
|
if (fLoadingProgressBar) {
|
||||||
if (progress < 100 && m_loadingProgressBar->IsHidden())
|
if (progress < 100 && fLoadingProgressBar->IsHidden())
|
||||||
m_loadingProgressBar->Show();
|
fLoadingProgressBar->Show();
|
||||||
m_loadingProgressBar->SetTo(progress);
|
fLoadingProgressBar->SetTo(progress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherWindow::LoadFailed(const BString& url, BWebView* view)
|
|
||||||
|
void
|
||||||
|
BrowserWindow::LoadFailed(const BString& url, BWebView* view)
|
||||||
{
|
{
|
||||||
if (view != CurrentWebView())
|
if (view != CurrentWebView())
|
||||||
return;
|
return;
|
||||||
@@ -554,11 +584,13 @@ void LauncherWindow::LoadFailed(const BString& url, BWebView* view)
|
|||||||
BString status(url);
|
BString status(url);
|
||||||
status << " failed.";
|
status << " failed.";
|
||||||
StatusChanged(status, view);
|
StatusChanged(status, view);
|
||||||
if (m_loadingProgressBar && !m_loadingProgressBar->IsHidden())
|
if (fLoadingProgressBar && !fLoadingProgressBar->IsHidden())
|
||||||
m_loadingProgressBar->Hide();
|
fLoadingProgressBar->Hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherWindow::LoadFinished(const BString& url, BWebView* view)
|
|
||||||
|
void
|
||||||
|
BrowserWindow::LoadFinished(const BString& url, BWebView* view)
|
||||||
{
|
{
|
||||||
if (view != CurrentWebView())
|
if (view != CurrentWebView())
|
||||||
return;
|
return;
|
||||||
@@ -566,14 +598,16 @@ void LauncherWindow::LoadFinished(const BString& url, BWebView* view)
|
|||||||
BString status(url);
|
BString status(url);
|
||||||
status << " finished.";
|
status << " finished.";
|
||||||
StatusChanged(status, view);
|
StatusChanged(status, view);
|
||||||
if (m_loadingProgressBar && !m_loadingProgressBar->IsHidden())
|
if (fLoadingProgressBar && !fLoadingProgressBar->IsHidden())
|
||||||
m_loadingProgressBar->Hide();
|
fLoadingProgressBar->Hide();
|
||||||
|
|
||||||
NavigationCapabilitiesChanged(m_BackButton->IsEnabled(),
|
NavigationCapabilitiesChanged(fBackButton->IsEnabled(),
|
||||||
m_ForwardButton->IsEnabled(), false, view);
|
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())
|
if (view != CurrentWebView())
|
||||||
return;
|
return;
|
||||||
@@ -583,25 +617,33 @@ void LauncherWindow::ResizeRequested(float width, float height, BWebView* view)
|
|||||||
ResizeTo(width, height);
|
ResizeTo(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherWindow::SetToolBarsVisible(bool flag, BWebView* view)
|
|
||||||
|
void
|
||||||
|
BrowserWindow::SetToolBarsVisible(bool flag, BWebView* view)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
// TODO: Ignore request when there is more than one BWebView embedded!
|
// 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
|
||||||
// TODO: Ignore request when there is more than one BWebView embedded!
|
// 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
|
||||||
// TODO: Ignore request when there is more than one BWebView embedded!
|
// 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!
|
// 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);
|
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++) {
|
for (int32 i = 0; i < fTabManager->CountTabs(); i++) {
|
||||||
if (m_tabManager->ViewForTab(i) == view) {
|
if (fTabManager->ViewForTab(i) == view) {
|
||||||
m_tabManager->SetTabLabel(i, title);
|
fTabManager->SetTabLabel(i, title);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (view != CurrentWebView())
|
if (view != CurrentWebView())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
updateTitle(title);
|
_UpdateTitle(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherWindow::StatusChanged(const BString& statusText, BWebView* view)
|
|
||||||
|
void
|
||||||
|
BrowserWindow::StatusChanged(const BString& statusText, BWebView* view)
|
||||||
{
|
{
|
||||||
if (view != CurrentWebView())
|
if (view != CurrentWebView())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_statusText)
|
if (fStatusText)
|
||||||
m_statusText->SetText(statusText.String());
|
fStatusText->SetText(statusText.String());
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherWindow::NavigationCapabilitiesChanged(bool canGoBackward,
|
|
||||||
|
void
|
||||||
|
BrowserWindow::NavigationCapabilitiesChanged(bool canGoBackward,
|
||||||
bool canGoForward, bool canStop, BWebView* view)
|
bool canGoForward, bool canStop, BWebView* view)
|
||||||
{
|
{
|
||||||
if (view != CurrentWebView())
|
if (view != CurrentWebView())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_BackButton)
|
if (fBackButton)
|
||||||
m_BackButton->SetEnabled(canGoBackward);
|
fBackButton->SetEnabled(canGoBackward);
|
||||||
if (m_ForwardButton)
|
if (fForwardButton)
|
||||||
m_ForwardButton->SetEnabled(canGoForward);
|
fForwardButton->SetEnabled(canGoForward);
|
||||||
if (m_StopButton)
|
if (fStopButton)
|
||||||
m_StopButton->SetEnabled(canStop);
|
fStopButton->SetEnabled(canStop);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherWindow::UpdateGlobalHistory(const BString& url)
|
|
||||||
|
void
|
||||||
|
BrowserWindow::UpdateGlobalHistory(const BString& url)
|
||||||
{
|
{
|
||||||
BrowsingHistory::defaultInstance()->addItem(BrowsingHistoryItem(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,
|
BString& inOutPassword, bool& inOutRememberCredentials, uint32 failureCount,
|
||||||
BWebView* view)
|
BWebView* view)
|
||||||
{
|
{
|
||||||
// Switch to the page for which this authentication is required.
|
// Switch to the page for which this authentication is required.
|
||||||
if (view != CurrentWebView()) {
|
if (view != CurrentWebView()) {
|
||||||
m_tabManager->SelectTab(view);
|
fTabManager->SelectTab(view);
|
||||||
UpdateIfNeeded();
|
UpdateIfNeeded();
|
||||||
}
|
}
|
||||||
AuthenticationPanel* panel = new AuthenticationPanel(Frame());
|
AuthenticationPanel* panel = new AuthenticationPanel(Frame());
|
||||||
@@ -669,20 +721,27 @@ bool LauncherWindow::AuthenticationChallenge(BString message, BString& inOutUser
|
|||||||
&inOutRememberCredentials);
|
&inOutRememberCredentials);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherWindow::updateTitle(const BString& title)
|
|
||||||
|
// #pragma mark - private
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BrowserWindow::_UpdateTitle(const BString& title)
|
||||||
{
|
{
|
||||||
BString windowTitle = title;
|
BString windowTitle = title;
|
||||||
if (windowTitle.Length() > 0)
|
if (windowTitle.Length() > 0)
|
||||||
windowTitle << " - ";
|
windowTitle << " - ";
|
||||||
windowTitle << "HaikuLauncher";
|
windowTitle << kApplicationName;
|
||||||
SetTitle(windowTitle.String());
|
SetTitle(windowTitle.String());
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherWindow::updateTabGroupVisibility()
|
|
||||||
|
void
|
||||||
|
BrowserWindow::_UpdateTabGroupVisibility()
|
||||||
{
|
{
|
||||||
if (Lock()) {
|
if (Lock()) {
|
||||||
//m_tabGroup->SetVisible(m_tabManager->CountTabs() > 1);
|
//fTabGroup->SetVisible(fTabManager->CountTabs() > 1);
|
||||||
m_tabManager->SetCloseButtonsAvailable(m_tabManager->CountTabs() > 1);
|
fTabManager->SetCloseButtonsAvailable(fTabManager->CountTabs() > 1);
|
||||||
Unlock();
|
Unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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>
|
||||||
@@ -58,63 +58,79 @@ enum {
|
|||||||
SHOW_DOWNLOAD_WINDOW = 'sdwd'
|
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 void MessageReceived(BMessage* message);
|
||||||
virtual bool QuitRequested();
|
virtual bool QuitRequested();
|
||||||
virtual void MenusBeginning();
|
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 NewWindowRequested(const BString& url,
|
||||||
|
bool primaryAction);
|
||||||
virtual void NewPageCreated(BWebView* view);
|
virtual void NewPageCreated(BWebView* view);
|
||||||
virtual void LoadNegotiating(const BString& url, BWebView* view);
|
virtual void LoadNegotiating(const BString& url,
|
||||||
virtual void LoadCommitted(const BString& url, BWebView* view);
|
BWebView* view);
|
||||||
|
virtual void LoadCommitted(const BString& url,
|
||||||
|
BWebView* view);
|
||||||
virtual void LoadProgress(float progress, BWebView* view);
|
virtual void LoadProgress(float progress, BWebView* view);
|
||||||
virtual void LoadFailed(const BString& url, BWebView* view);
|
virtual void LoadFailed(const BString& url, BWebView* view);
|
||||||
virtual void LoadFinished(const BString& url, BWebView* view);
|
virtual void LoadFinished(const BString& url,
|
||||||
virtual void TitleChanged(const BString& title, BWebView* view);
|
BWebView* view);
|
||||||
virtual void ResizeRequested(float width, float height, 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 SetToolBarsVisible(bool flag, BWebView* view);
|
||||||
virtual void SetStatusBarVisible(bool flag, BWebView* view);
|
virtual void SetStatusBarVisible(bool flag, BWebView* view);
|
||||||
virtual void SetMenuBarVisible(bool flag, BWebView* view);
|
virtual void SetMenuBarVisible(bool flag, BWebView* view);
|
||||||
virtual void SetResizable(bool flag, BWebView* view);
|
virtual void SetResizable(bool flag, BWebView* view);
|
||||||
virtual void StatusChanged(const BString& status, BWebView* view);
|
virtual void StatusChanged(const BString& status,
|
||||||
virtual void NavigationCapabilitiesChanged(bool canGoBackward,
|
BWebView* view);
|
||||||
bool canGoForward, bool canStop, BWebView* view);
|
virtual void NavigationCapabilitiesChanged(
|
||||||
|
bool canGoBackward, bool canGoForward,
|
||||||
|
bool canStop, BWebView* view);
|
||||||
virtual void UpdateGlobalHistory(const BString& url);
|
virtual void UpdateGlobalHistory(const BString& url);
|
||||||
virtual bool AuthenticationChallenge(BString message, BString& inOutUser,
|
virtual bool AuthenticationChallenge(BString message,
|
||||||
BString& inOutPassword, bool& inOutRememberCredentials,
|
BString& inOutUser, BString& inOutPassword,
|
||||||
|
bool& inOutRememberCredentials,
|
||||||
uint32 failureCount, BWebView* view);
|
uint32 failureCount, BWebView* view);
|
||||||
|
|
||||||
void updateTitle(const BString &title);
|
private:
|
||||||
void updateTabGroupVisibility();
|
void _UpdateTitle(const BString &title);
|
||||||
|
void _UpdateTabGroupVisibility();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BMessenger m_downloadListener;
|
BMessenger fDownloadListener;
|
||||||
BMenuBar* m_menuBar;
|
BMenuBar* fMenuBar;
|
||||||
BMenu* m_goMenu;
|
BMenu* fGoMenu;
|
||||||
IconButton* m_BackButton;
|
IconButton* fBackButton;
|
||||||
IconButton* m_ForwardButton;
|
IconButton* fForwardButton;
|
||||||
IconButton* m_StopButton;
|
IconButton* fStopButton;
|
||||||
BButton* m_goButton;
|
BButton* fGoButton;
|
||||||
BTextControl* m_url;
|
BTextControl* fURLTextControl;
|
||||||
BStringView* m_statusText;
|
BStringView* fStatusText;
|
||||||
BStatusBar* m_loadingProgressBar;
|
BStatusBar* fLoadingProgressBar;
|
||||||
BLayoutItem* m_findGroup;
|
BLayoutItem* fFindGroup;
|
||||||
BLayoutItem* m_tabGroup;
|
BLayoutItem* fTabGroup;
|
||||||
BTextControl* m_findTextControl;
|
BTextControl* fFindTextControl;
|
||||||
BCheckBox* m_findCaseSensitiveCheckBox;
|
BCheckBox* fFindCaseSensitiveCheckBox;
|
||||||
TabManager* m_tabManager;
|
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