mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-23 14:59:47 +03:00
Merge remote-tracking branch 'origin/mmu_man/beos-fixes'
This commit is contained in:
commit
840284b24d
2
Makefile
2
Makefile
@ -453,7 +453,7 @@ ifeq ($(TARGET),beos)
|
||||
$(Q)$(BEOS_SETVER) $(EXETARGET) \
|
||||
-app $(VERSION_MAJ) $(VERSION_MIN) 0 d 0 \
|
||||
-short "NetSurf $(VERSION_FULL)" \
|
||||
-long "NetSurf $(VERSION_FULL) © 2003 - 2008 The NetSurf Developers"
|
||||
-long "NetSurf $(VERSION_FULL) © 2003 - 2012 The NetSurf Developers"
|
||||
$(VQ)echo " MIMESET: $(EXETARGET)"
|
||||
$(Q)$(BEOS_MIMESET) $(EXETARGET)
|
||||
endif
|
||||
|
@ -9,8 +9,10 @@
|
||||
# for Haiku
|
||||
LDFLAGS += -L/boot/common/lib
|
||||
# some people do *not* have libm...
|
||||
LDFLAGS += -lcurl -liconv
|
||||
LDFLAGS += -lssl -lcrypto -lcss -ldom -lparserutils -lhubbub -lwapcaplet
|
||||
LDFLAGS += -lssl -lcrypto -lcss
|
||||
$(eval $(call feature_enabled,NSSVG,-DWITH_NS_SVG,-lsvgtiny,SVG (libsvgtiny)))
|
||||
LDFLAGS += -ldom -lparserutils -lhubbub -lwapcaplet
|
||||
LDFLAGS += -lexpat -lcurl -liconv
|
||||
|
||||
CFLAGS += -I. -O $(WARNFLAGS) -Dnsbeos \
|
||||
-D_BSD_SOURCE -D_POSIX_C_SOURCE \
|
||||
@ -59,9 +61,13 @@
|
||||
# cross: Haiku ?
|
||||
NETLDFLAGS := -lnetwork
|
||||
endif
|
||||
LDFLAGS += -lbe -ltranslation $(NETLDFLAGS)
|
||||
LDFLAGS += -lbe -ltranslation -ltracker $(NETLDFLAGS)
|
||||
ifeq ($(GCCVER),2)
|
||||
LDFLAGS += -lstdc++.r4
|
||||
else
|
||||
LDFLAGS += -lstdc++ -lsupc++
|
||||
endif
|
||||
|
||||
$(eval $(call feature_enabled,NSSVG,-DWITH_NS_SVG,-lsvgtiny,SVG (libsvgtiny)))
|
||||
ifeq ($(HOST),beos)
|
||||
CFLAGS += -I$(PREFIX)/include
|
||||
LDFLAGS += -L$(PREFIX)/lib
|
||||
@ -82,11 +88,9 @@
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# S_BEOS are sources purely for the BeOS build
|
||||
S_BEOS := about.cpp bitmap.cpp fetch_rsrc.cpp \
|
||||
filetype.cpp font.cpp gui.cpp login.cpp \
|
||||
gui_options.cpp plotters.cpp \
|
||||
scaffolding.cpp search.cpp schedule.cpp \
|
||||
thumbnail.cpp treeview.cpp throbber.cpp \
|
||||
S_BEOS := about.cpp bitmap.cpp download.cpp fetch_rsrc.cpp filetype.cpp \
|
||||
font.cpp gui.cpp login.cpp gui_options.cpp plotters.cpp scaffolding.cpp \
|
||||
search.cpp schedule.cpp thumbnail.cpp treeview.cpp throbber.cpp \
|
||||
window.cpp system_colour.cpp
|
||||
S_BEOS := $(addprefix beos/,$(S_BEOS))
|
||||
|
||||
@ -98,7 +102,7 @@ RDEF_IMP_BEOS := $(addprefix $(OBJROOT)/,$(subst /,_,$(RDEF_IMP_BEOS)))
|
||||
|
||||
RDEP_BEOS := \
|
||||
adblock.css beosdefault.css default.css internal.css quirks.css \
|
||||
netsurf.png ca-bundle.txt messages
|
||||
netsurf.png ca-bundle.txt
|
||||
RDEP_BEOS := $(addprefix beos/res/,$(RDEP_BEOS)) \
|
||||
$(wildcard beos/res/Icons/*.png) \
|
||||
$(wildcard beos/res/throbber/throbber*.png)
|
||||
@ -126,7 +130,7 @@ install-beos:
|
||||
@cp -vRL beos/res/beosdefault.css $(DESTDIR)$(NETSURF_BEOS_RESOURCES)
|
||||
@cp -vRL gtk/res/license $(DESTDIR)$(NETSURF_BEOS_RESOURCES)
|
||||
# @cp -vRL beos/res/throbber/*.png $(DESTDIR)$(NETSURF_BEOS_RESOURCES)throbber
|
||||
gzip -9v < beos/res/messages > $(DESTDIR)$(NETSURF_BEOS_RESOURCES)messages
|
||||
$(call split_install_messages, beos, $(DESTDIR)$(NETSURF_BEOS_RESOURCES))
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Package target
|
||||
|
45
beos/WindowStack.h
Normal file
45
beos/WindowStack.h
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2010, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef WINDOW_STACK_H
|
||||
#define WINDOW_STACK_H
|
||||
|
||||
|
||||
#include <Window.h>
|
||||
|
||||
|
||||
class BWindowStack {
|
||||
public:
|
||||
BWindowStack(BWindow* window);
|
||||
~BWindowStack();
|
||||
|
||||
status_t AddWindow(const BWindow* window);
|
||||
status_t AddWindow(const BMessenger& window);
|
||||
status_t AddWindowAt(const BWindow* window,
|
||||
int32 position);
|
||||
status_t AddWindowAt(const BMessenger& window,
|
||||
int32 position);
|
||||
|
||||
status_t RemoveWindow(const BWindow* window);
|
||||
status_t RemoveWindow(const BMessenger& window);
|
||||
status_t RemoveWindowAt(int32 position,
|
||||
BMessenger* window = NULL);
|
||||
|
||||
int32 CountWindows();
|
||||
|
||||
status_t WindowAt(int32 position,
|
||||
BMessenger& messenger);
|
||||
bool HasWindow(const BWindow* window);
|
||||
bool HasWindow(const BMessenger& window);
|
||||
|
||||
private:
|
||||
status_t _AttachMessenger(const BMessenger& window);
|
||||
status_t _ReadMessenger(BMessenger& window);
|
||||
status_t _StartMessage(int32 what);
|
||||
|
||||
BPrivate::PortLink* fLink;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
@ -106,7 +106,6 @@ static inline void nsbeos_rgba_to_bgra(void *src, void *dst, int width, int heig
|
||||
|
||||
void *bitmap_create(int width, int height, unsigned int state)
|
||||
{
|
||||
CALLED();
|
||||
struct bitmap *bmp = (struct bitmap *)malloc(sizeof(struct bitmap));
|
||||
if (bmp == NULL)
|
||||
return NULL;
|
||||
@ -288,7 +287,6 @@ bool bitmap_save(void *vbitmap, const char *path, unsigned flags)
|
||||
* \param vbitmap a bitmap, as returned by bitmap_create()
|
||||
*/
|
||||
void bitmap_modified(void *vbitmap) {
|
||||
CALLED();
|
||||
struct bitmap *bitmap = (struct bitmap *)vbitmap;
|
||||
// convert the shadow (ABGR) to into the primary bitmap
|
||||
nsbeos_rgba_to_bgra(bitmap->shadow->Bits(), bitmap->primary->Bits(),
|
||||
|
249
beos/download.cpp
Normal file
249
beos/download.cpp
Normal file
@ -0,0 +1,249 @@
|
||||
/*
|
||||
* Copyright 2012 Adrien Destugues <pulkomandy@pulkomandy.tk>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
* NetSurf is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* NetSurf is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define __STDBOOL_H__ 1
|
||||
#include <stdbool.h>
|
||||
|
||||
extern "C" {
|
||||
#include "desktop/gui.h"
|
||||
}
|
||||
#include "beos/download.h"
|
||||
|
||||
#include <File.h>
|
||||
#include <FilePanel.h>
|
||||
#include <Locker.h>
|
||||
#include <Messenger.h>
|
||||
#include <StatusBar.h>
|
||||
#include <Window.h>
|
||||
|
||||
class NSDownloadWindow: public BWindow
|
||||
{
|
||||
public:
|
||||
NSDownloadWindow(download_context* ctx);
|
||||
~NSDownloadWindow();
|
||||
|
||||
void MessageReceived(BMessage* message);
|
||||
|
||||
void Progress(int size);
|
||||
void Failure(const char* error);
|
||||
void Success();
|
||||
private:
|
||||
download_context* ctx;
|
||||
BStatusBar* bar;
|
||||
unsigned long progress;
|
||||
bool success;
|
||||
};
|
||||
|
||||
|
||||
struct gui_download_window {
|
||||
download_context* ctx;
|
||||
NSDownloadWindow* window;
|
||||
|
||||
BLocker* storageLock;
|
||||
BDataIO* storage;
|
||||
};
|
||||
|
||||
|
||||
NSDownloadWindow::NSDownloadWindow(download_context* ctx)
|
||||
: BWindow(BRect(30, 30, 400, 200), "Downloads", B_TITLED_WINDOW,
|
||||
B_NOT_RESIZABLE)
|
||||
, ctx(ctx)
|
||||
, progress(0)
|
||||
, success(false)
|
||||
{
|
||||
unsigned long dlsize = download_context_get_total_length(ctx);
|
||||
char* buffer = human_friendly_bytesize(dlsize);
|
||||
|
||||
// Create the status bar
|
||||
BRect rect = Bounds();
|
||||
rect.InsetBy(3, 3);
|
||||
bar = new BStatusBar(rect, "progress",
|
||||
download_context_get_filename(ctx), buffer);
|
||||
bar->SetMaxValue(dlsize);
|
||||
|
||||
// Create the backgroundview (just so that the area around the progress bar
|
||||
// is B_PANEL_BACKGROUND_COLOR instead of white)
|
||||
BView* back = new BView(Bounds(), "back", B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
|
||||
back->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
|
||||
// Add the views to the window
|
||||
back->AddChild(bar);
|
||||
AddChild(back);
|
||||
|
||||
// Resize the window to leave a margin around the progress bar
|
||||
BRect size = bar->Bounds();
|
||||
ResizeTo(size.Width() + 6, size.Height() + 6);
|
||||
Show();
|
||||
}
|
||||
|
||||
|
||||
NSDownloadWindow::~NSDownloadWindow()
|
||||
{
|
||||
download_context_abort(ctx);
|
||||
download_context_destroy(ctx);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
NSDownloadWindow::MessageReceived(BMessage* message)
|
||||
{
|
||||
switch(message->what)
|
||||
{
|
||||
case B_SAVE_REQUESTED:
|
||||
{
|
||||
entry_ref directory;
|
||||
const char* name;
|
||||
struct gui_download_window* dw;
|
||||
BFilePanel* source;
|
||||
|
||||
message->FindRef("directory", &directory);
|
||||
message->FindString("name", &name);
|
||||
message->FindPointer("dw", (void**)&dw);
|
||||
|
||||
BDirectory dir(&directory);
|
||||
BFile* storage = new BFile(&dir, name,
|
||||
B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE);
|
||||
dw->storageLock->Lock();
|
||||
|
||||
BMallocIO* tempstore = dynamic_cast<BMallocIO*>(dw->storage);
|
||||
|
||||
storage->Write(tempstore->Buffer(), tempstore->BufferLength());
|
||||
delete dw->storage;
|
||||
|
||||
if (success)
|
||||
delete storage; // File is already finished downloading !
|
||||
else
|
||||
dw->storage = storage;
|
||||
dw->storageLock->Unlock();
|
||||
|
||||
message->FindPointer("source", (void**)&source);
|
||||
delete source;
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BWindow::MessageReceived(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
NSDownloadWindow::Progress(int size)
|
||||
{
|
||||
progress += size;
|
||||
|
||||
char* buffer = human_friendly_bytesize(progress);
|
||||
strcat(buffer, "/");
|
||||
|
||||
bar->LockLooper();
|
||||
bar->Update(size, NULL, buffer);
|
||||
bar->Invalidate();
|
||||
bar->UnlockLooper();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
NSDownloadWindow::Success()
|
||||
{
|
||||
bar->LockLooper();
|
||||
bar->SetBarColor(ui_color(B_SUCCESS_COLOR));
|
||||
bar->UnlockLooper();
|
||||
|
||||
success = true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
NSDownloadWindow::Failure(const char* error)
|
||||
{
|
||||
bar->LockLooper();
|
||||
bar->Update(0, NULL, error);
|
||||
bar->SetBarColor(ui_color(B_FAILURE_COLOR));
|
||||
bar->UnlockLooper();
|
||||
}
|
||||
|
||||
|
||||
struct gui_download_window *gui_download_window_create(download_context *ctx,
|
||||
struct gui_window *parent)
|
||||
{
|
||||
struct gui_download_window *download = (struct gui_download_window*)malloc(sizeof *download);
|
||||
if (download == NULL)
|
||||
return NULL;
|
||||
|
||||
download->storageLock = new BLocker("storage_lock");
|
||||
download->storage = new BMallocIO();
|
||||
download->ctx = ctx;
|
||||
|
||||
download->window = new NSDownloadWindow(ctx);
|
||||
|
||||
// Also ask the user where to save the file
|
||||
// TODO inject the suggested name somehow
|
||||
BMessage* msg = new BMessage(B_SAVE_REQUESTED);
|
||||
|
||||
BFilePanel* panel = new BFilePanel(B_SAVE_PANEL,
|
||||
new BMessenger(download->window), NULL, 0, false);
|
||||
|
||||
msg->AddPointer("source", panel);
|
||||
msg->AddPointer("dw", download);
|
||||
panel->SetMessage(msg);
|
||||
|
||||
panel->Show();
|
||||
|
||||
return download;
|
||||
}
|
||||
|
||||
|
||||
nserror gui_download_window_data(struct gui_download_window *dw,
|
||||
const char *data, unsigned int size)
|
||||
{
|
||||
dw->window->Progress(size);
|
||||
|
||||
dw->storageLock->Lock();
|
||||
dw->storage->Write(data, size);
|
||||
dw->storageLock->Unlock();
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
void gui_download_window_error(struct gui_download_window *dw,
|
||||
const char *error_msg)
|
||||
{
|
||||
dw->window->Failure(error_msg);
|
||||
|
||||
delete dw->storageLock;
|
||||
delete dw->storage;
|
||||
}
|
||||
|
||||
|
||||
void gui_download_window_done(struct gui_download_window *dw)
|
||||
{
|
||||
dw->window->Success();
|
||||
|
||||
dw->storageLock->Lock();
|
||||
|
||||
// Only delete if the storage is already a file. Else, we must wait for the
|
||||
// user to select something in the BFilePanel!
|
||||
BFile* file = dynamic_cast<BFile*>(dw->storage);
|
||||
delete file;
|
||||
if (file)
|
||||
delete dw->storageLock;
|
||||
else
|
||||
dw->storageLock->Unlock();
|
||||
}
|
||||
|
18
beos/download.h
Normal file
18
beos/download.h
Normal file
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright 2012 Adrien Destugues <pulkomandy@pulkomandy.tk>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
* NetSurf is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* NetSurf is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
@ -48,6 +48,7 @@ extern "C" {
|
||||
|
||||
#include <image.h>
|
||||
#include <Resources.h>
|
||||
#include <String.h>
|
||||
|
||||
struct fetch_rsrc_context {
|
||||
struct fetch *parent_fetch;
|
||||
@ -65,7 +66,7 @@ struct fetch_rsrc_context {
|
||||
|
||||
static struct fetch_rsrc_context *ring = NULL;
|
||||
|
||||
static BResources *gAppResources = NULL;
|
||||
BResources *gAppResources = NULL;
|
||||
|
||||
static bool fetch_rsrc_initialise(lwc_string *scheme)
|
||||
{
|
||||
@ -197,11 +198,11 @@ static bool fetch_rsrc_process(struct fetch_rsrc_context *c)
|
||||
uint8 c1, c2, c3, c4;
|
||||
if (sscanf(params, "%c%c%c%c", &c1, &c2, &c3, &c4) > 3) {
|
||||
type = c1 << 24 | c2 << 16 | c3 << 8 | c4;
|
||||
printf("type:%4.4s\n", &type);
|
||||
LOG(("fetch_rsrc: type:%4.4s\n", &type));
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, "fetch_rsrc: 0x%08lx, %ld, '%s'\n", type, id, c->name);
|
||||
LOG(("fetch_rsrc: 0x%08lx, %ld, '%s'\n", type, id, c->name));
|
||||
|
||||
bool found;
|
||||
if (id)
|
||||
@ -209,8 +210,13 @@ static bool fetch_rsrc_process(struct fetch_rsrc_context *c)
|
||||
else
|
||||
found = gAppResources->HasResource(type, c->name);
|
||||
if (!found) {
|
||||
BString error("Cannot locate resource: ");
|
||||
if (id)
|
||||
error << id;
|
||||
else
|
||||
error << c->name;
|
||||
msg.type = FETCH_ERROR;
|
||||
msg.data.error = "Cannot locate rsrc: URL";
|
||||
msg.data.error = error.String();
|
||||
fetch_rsrc_send_callback(&msg, c);
|
||||
return false;
|
||||
}
|
||||
@ -328,7 +334,7 @@ static int find_app_resources()
|
||||
char path[B_PATH_NAME_LENGTH];
|
||||
if (nsbeos_find_app_path(path) < B_OK)
|
||||
return B_ERROR;
|
||||
//fprintf(stderr, "loading resources from '%s'\n", path);
|
||||
//fprintf(stderr, "loading resources from '%s'\n", path);
|
||||
|
||||
BFile file(path, B_READ_ONLY);
|
||||
if (file.InitCheck() < 0)
|
||||
|
150
beos/gui.cpp
150
beos/gui.cpp
@ -172,7 +172,6 @@ NSBrowserApplication::MessageReceived(BMessage *message)
|
||||
void
|
||||
NSBrowserApplication::ArgvReceived(int32 argc, char **argv)
|
||||
{
|
||||
CALLED();
|
||||
NSBrowserWindow *win = nsbeos_find_last_window();
|
||||
if (!win) {
|
||||
return;
|
||||
@ -186,7 +185,6 @@ NSBrowserApplication::ArgvReceived(int32 argc, char **argv)
|
||||
void
|
||||
NSBrowserApplication::RefsReceived(BMessage *message)
|
||||
{
|
||||
CALLED();
|
||||
DetachCurrentMessage();
|
||||
NSBrowserWindow *win = nsbeos_find_last_window();
|
||||
if (!win) {
|
||||
@ -325,7 +323,6 @@ image_id nsbeos_find_app_path(char *path)
|
||||
|
||||
static char *find_resource(char *buf, const char *filename, const char *def)
|
||||
{
|
||||
CALLED();
|
||||
const char *cdir = NULL;
|
||||
status_t err;
|
||||
BPath path;
|
||||
@ -388,7 +385,6 @@ static char *find_resource(char *buf, const char *filename, const char *def)
|
||||
*/
|
||||
static void check_homedir(void)
|
||||
{
|
||||
CALLED();
|
||||
status_t err;
|
||||
|
||||
BPath path;
|
||||
@ -423,14 +419,13 @@ nsurl *gui_get_resource_url(const char *path)
|
||||
u << "beosdefault.css";
|
||||
else
|
||||
u << path;
|
||||
fprintf(stderr, "%s(%s) -> '%s'\n", __FUNCTION__, path, u.String());
|
||||
LOG(("(%s) -> '%s'\n", path, u.String()));
|
||||
nsurl_create(u.String(), &url);
|
||||
return url;
|
||||
}
|
||||
|
||||
static void gui_init2(int argc, char** argv)
|
||||
{
|
||||
CALLED();
|
||||
const char *addr = NETSURF_HOMEPAGE;
|
||||
|
||||
if (nsoption_charp(homepage_url) != NULL)
|
||||
@ -450,7 +445,6 @@ static void gui_init2(int argc, char** argv)
|
||||
/** Normal entry point from OS */
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
setbuf(stderr, NULL);
|
||||
|
||||
BPath options;
|
||||
@ -458,12 +452,16 @@ int main(int argc, char** argv)
|
||||
options.Append("x-vnd.NetSurf");
|
||||
}
|
||||
|
||||
find_resource(buf, "messages", "./beos/res/messages");
|
||||
LOG(("Using '%s' as Messages file", buf));
|
||||
//messages_load(buf);
|
||||
if (!replicated) {
|
||||
// create the Application object before trying to use messages
|
||||
// so we can open an alert in case of error.
|
||||
new NSBrowserApplication;
|
||||
}
|
||||
|
||||
char* messages = "/boot/apps/netsurf/res/en/Messages";
|
||||
|
||||
/* initialise netsurf */
|
||||
netsurf_init(&argc, &argv, options.Path(), buf);
|
||||
netsurf_init(&argc, &argv, options.Path(), messages);
|
||||
|
||||
gui_init(argc, argv);
|
||||
gui_init2(argc, argv);
|
||||
@ -475,6 +473,27 @@ int main(int argc, char** argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** called when replicated from NSBaseView::Instantiate() */
|
||||
int gui_init_replicant(int argc, char** argv)
|
||||
{
|
||||
setbuf(stderr, NULL);
|
||||
|
||||
BPath options;
|
||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &options, true) == B_OK) {
|
||||
options.Append("x-vnd.NetSurf");
|
||||
}
|
||||
|
||||
char* messages = "/boot/apps/netsurf/res/en/Messages";
|
||||
|
||||
/* initialise netsurf */
|
||||
netsurf_init(&argc, &argv, options.Path(), messages);
|
||||
|
||||
gui_init(argc, argv);
|
||||
gui_init2(argc, argv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Documented in desktop/options.h */
|
||||
void gui_options_init_defaults(void)
|
||||
{
|
||||
@ -485,12 +504,10 @@ void gui_options_init_defaults(void)
|
||||
void gui_init(int argc, char** argv)
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
CALLED();
|
||||
|
||||
if (pipe(sEventPipe) < 0)
|
||||
return;
|
||||
if (!replicated) {
|
||||
new NSBrowserApplication;
|
||||
sBAppThreadID = spawn_thread(bapp_thread, "BApplication(NetSurf)", B_NORMAL_PRIORITY, (void *)find_thread(NULL));
|
||||
if (sBAppThreadID < B_OK)
|
||||
return; /* #### handle errors */
|
||||
@ -553,37 +570,38 @@ void gui_init(int argc, char** argv)
|
||||
/* check what the font settings are, setting them to a default font
|
||||
* if they're not set - stops Pango whinging
|
||||
*/
|
||||
#define SETFONTDEFAULT(OPTION,y) if (nsoption_charp(OPTION) == NULL) nsoption_set_charp(OPTION, strdup((y)))
|
||||
|
||||
//XXX: use be_plain_font & friends, when we can check if font is serif or not.
|
||||
/*
|
||||
font_family family;
|
||||
font_style style;
|
||||
be_plain_font->GetFamilyAndStyle(&family, &style);
|
||||
nsoption_setnull_charp(font_sans, family);
|
||||
nsoption_setnull_charp(font_serif, family);
|
||||
nsoption_setnull_charp(font_mono, family);
|
||||
nsoption_setnull_charp(font_cursive, family);
|
||||
nsoption_setnull_charp(font_fantasy, family);
|
||||
SETFONTDEFAULT(font_sans, family);
|
||||
SETFONTDEFAULT(font_serif, family);
|
||||
SETFONTDEFAULT(font_mono, family);
|
||||
SETFONTDEFAULT(font_cursive, family);
|
||||
SETFONTDEFAULT(font_fantasy, family);
|
||||
*/
|
||||
#ifdef __HAIKU__
|
||||
nsoption_setnull_charp(font_sans, "DejaVu Sans");
|
||||
nsoption_setnull_charp(font_serif, "DejaVu Serif");
|
||||
nsoption_setnull_charp(font_mono, "DejaVu Mono");
|
||||
nsoption_setnull_charp(font_cursive, "DejaVu Sans");
|
||||
nsoption_setnull_charp(font_fantasy, "DejaVu Sans");
|
||||
SETFONTDEFAULT(font_sans, "DejaVu Sans");
|
||||
SETFONTDEFAULT(font_serif, "DejaVu Serif");
|
||||
SETFONTDEFAULT(font_mono, "DejaVu Mono");
|
||||
SETFONTDEFAULT(font_cursive, "DejaVu Sans");
|
||||
SETFONTDEFAULT(font_fantasy, "DejaVu Sans");
|
||||
#else
|
||||
nsoption_setnull_charp(font_sans, "Bitstream Vera Sans");
|
||||
nsoption_setnull_charp(font_serif, "Bitstream Vera Serif");
|
||||
nsoption_setnull_charp(font_mono, "Bitstream Vera Sans Mono");
|
||||
nsoption_setnull_charp(font_cursive, "Bitstream Vera Serif");
|
||||
nsoption_setnull_charp(font_fantasy, "Bitstream Vera Serif");
|
||||
SETFONTDEFAULT(font_sans, "Bitstream Vera Sans");
|
||||
SETFONTDEFAULT(font_serif, "Bitstream Vera Serif");
|
||||
SETFONTDEFAULT(font_mono, "Bitstream Vera Sans Mono");
|
||||
SETFONTDEFAULT(font_cursive, "Bitstream Vera Serif");
|
||||
SETFONTDEFAULT(font_fantasy, "Bitstream Vera Serif");
|
||||
#if 0
|
||||
nsoption_setnull_charp(font_sans, "Swis721 BT");
|
||||
nsoption_setnull_charp(font_serif, "Dutch801 Rm BT");
|
||||
//nsoption_setnull_charp(font_mono, "Monospac821 BT");
|
||||
nsoption_setnull_charp(font_mono, "Courier10 BT");
|
||||
nsoption_setnull_charp(font_cursive, "Swis721 BT");
|
||||
nsoption_setnull_charp(font_fantasy, "Swis721 BT");
|
||||
SETFONTDEFAULT(font_sans, "Swis721 BT");
|
||||
SETFONTDEFAULT(font_serif, "Dutch801 Rm BT");
|
||||
//SETFONTDEFAULT(font_mono, "Monospac821 BT");
|
||||
SETFONTDEFAULT(font_mono, "Courier10 BT");
|
||||
SETFONTDEFAULT(font_cursive, "Swis721 BT");
|
||||
SETFONTDEFAULT(font_fantasy, "Swis721 BT");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -680,17 +698,16 @@ void nsbeos_pipe_message_top(BMessage *message, BWindow *_this, struct beos_scaf
|
||||
|
||||
void gui_poll(bool active)
|
||||
{
|
||||
//CALLED();
|
||||
CURLMcode code;
|
||||
|
||||
fd_set read_fd_set, write_fd_set, exc_fd_set;
|
||||
int max_fd = 0;
|
||||
struct timeval timeout;
|
||||
unsigned int fd_count = 0;
|
||||
bool block = true;
|
||||
bigtime_t next_schedule = 0;
|
||||
|
||||
if (browser_reformat_pending)
|
||||
block = false;
|
||||
// handle early deadlines
|
||||
schedule_run();
|
||||
|
||||
FD_ZERO(&read_fd_set);
|
||||
FD_ZERO(&write_fd_set);
|
||||
@ -709,25 +726,42 @@ void gui_poll(bool active)
|
||||
FD_SET(sEventPipe[0], &read_fd_set);
|
||||
max_fd = MAX(max_fd, sEventPipe[0] + 1);
|
||||
|
||||
// If there are pending events elsewhere, we should not be blocking
|
||||
if (!browser_reformat_pending) {
|
||||
if (earliest_callback_timeout != B_INFINITE_TIMEOUT) {
|
||||
next_schedule = earliest_callback_timeout - system_time();
|
||||
block = false;
|
||||
}
|
||||
|
||||
bigtime_t next_schedule = earliest_callback_timeout - system_time();
|
||||
if (!block)
|
||||
next_schedule = 0LL; // now
|
||||
if (block && earliest_callback_timeout != B_INFINITE_TIMEOUT)
|
||||
// we're quite late already...
|
||||
if (next_schedule < 0)
|
||||
next_schedule = 0;
|
||||
|
||||
} else //we're not allowed to sleep, there is other activity going on.
|
||||
block = false;
|
||||
|
||||
/*
|
||||
LOG(("gui_poll: browser_reformat_pending:%d earliest_callback_timeout:%Ld"
|
||||
" next_schedule:%Ld block:%d ", browser_reformat_pending,
|
||||
earliest_callback_timeout, next_schedule, block));
|
||||
*/
|
||||
|
||||
timeout.tv_sec = (long)(next_schedule / 1000000LL);
|
||||
timeout.tv_usec = (long)(next_schedule % 1000000LL);
|
||||
LOG(("gui_poll: select(%d, ..., %Ldus", max_fd, next_schedule));
|
||||
|
||||
//LOG(("gui_poll: select(%d, ..., %Ldus", max_fd, next_schedule));
|
||||
fd_count = select(max_fd, &read_fd_set, &write_fd_set, &exc_fd_set,
|
||||
block ? NULL : &timeout);
|
||||
//LOG(("select: %d\n", fd_count));
|
||||
|
||||
if (fd_count > 0 && FD_ISSET(sEventPipe[0], &read_fd_set)) {
|
||||
BMessage *message;
|
||||
int len = read(sEventPipe[0], &message, sizeof(void *));
|
||||
LOG(("gui_poll: BMessage ? %d read", len));
|
||||
if (len == sizeof(void *))
|
||||
//LOG(("gui_poll: BMessage ? %d read", len));
|
||||
if (len == sizeof(void *)) {
|
||||
//LOG(("gui_poll: BMessage.what %-4.4s\n", &(message->what)));
|
||||
nsbeos_dispatch_event(message);
|
||||
}
|
||||
}
|
||||
|
||||
schedule_run();
|
||||
@ -739,7 +773,6 @@ void gui_poll(bool active)
|
||||
|
||||
void gui_quit(void)
|
||||
{
|
||||
CALLED();
|
||||
urldb_save_cookies(nsoption_charp(cookie_jar));
|
||||
urldb_save(nsoption_charp(url_file));
|
||||
//options_save_tree(hotlist,nsoption_charp(hotlist_file),messages_get("TreeHotlist"));
|
||||
@ -751,31 +784,6 @@ void gui_quit(void)
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct gui_download_window *gui_download_window_create(download_context *ctx,
|
||||
struct gui_window *gui)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
nserror gui_download_window_data(struct gui_download_window *dw,
|
||||
const char *data, unsigned int size)
|
||||
{
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
void gui_download_window_error(struct gui_download_window *dw,
|
||||
const char *error_msg)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void gui_download_window_done(struct gui_download_window *dw)
|
||||
{
|
||||
}
|
||||
|
||||
#if 0 /* GTK */
|
||||
static void nsbeos_select_menu_clicked(BCheckMenuItem *checkmenuitem,
|
||||
gpointer user_data)
|
||||
|
@ -30,6 +30,8 @@
|
||||
#define CALLED() fprintf(stderr, "%s()\n", __FUNCTION__);
|
||||
|
||||
extern bool replicated;
|
||||
int gui_init_replicant(int argc, char** argv);
|
||||
|
||||
|
||||
#if 0 /* GTK */
|
||||
//extern GladeXML *gladeWindows;
|
||||
|
@ -45,7 +45,7 @@ class LoginAlert : public BAlert {
|
||||
public:
|
||||
LoginAlert(nserror (*callback)(bool proceed, void *pw),
|
||||
void *callbaclpw,
|
||||
const char *url,
|
||||
nsurl *url,
|
||||
const char *host,
|
||||
const char *realm,
|
||||
const char *text);
|
||||
@ -53,7 +53,7 @@ public:
|
||||
void MessageReceived(BMessage *message);
|
||||
|
||||
private:
|
||||
BString fUrl; /**< URL being fetched */
|
||||
nsurl* fUrl; /**< URL being fetched */
|
||||
BString fHost; /**< Host for user display */
|
||||
BString fRealm; /**< Authentication realm */
|
||||
nserror (*fCallback)(bool proceed, void *pw);
|
||||
@ -63,8 +63,8 @@ private:
|
||||
BTextControl *fPassControl;
|
||||
};
|
||||
|
||||
static void create_login_window(const char *host,
|
||||
const char *realm, const char *fetchurl,
|
||||
static void create_login_window(nsurl *host,
|
||||
lwc_string *realm, const char *fetchurl,
|
||||
nserror (*cb)(bool proceed, void *pw), void *cbpw);
|
||||
|
||||
|
||||
@ -73,7 +73,7 @@ static void create_login_window(const char *host,
|
||||
|
||||
LoginAlert::LoginAlert(nserror (*callback)(bool proceed, void *pw),
|
||||
void *callbackpw,
|
||||
const char *url,
|
||||
nsurl *url,
|
||||
const char *host,
|
||||
const char *realm,
|
||||
const char *text)
|
||||
@ -140,7 +140,7 @@ LoginAlert::MessageReceived(BMessage *message)
|
||||
break;
|
||||
BMessage *m = new BMessage(*message);
|
||||
m->what = 'nsLO';
|
||||
m->AddString("URL", fUrl.String());
|
||||
m->AddPointer("URL", fUrl);
|
||||
m->AddString("Host", fHost.String());
|
||||
m->AddString("Realm", fRealm.String());
|
||||
m->AddPointer("callback", (void *)fCallback);
|
||||
@ -163,14 +163,13 @@ LoginAlert::MessageReceived(BMessage *message)
|
||||
}
|
||||
|
||||
|
||||
void gui_401login_open(const char *url, const char *realm,
|
||||
extern "C" void gui_401login_open(nsurl *url, const char *realm,
|
||||
nserror (*cb)(bool proceed, void *pw), void *cbpw)
|
||||
{
|
||||
char *host;
|
||||
lwc_string *host;
|
||||
url_func_result res;
|
||||
|
||||
res = url_host(url, &host);
|
||||
assert(res == URL_FUNC_OK);
|
||||
host = nsurl_get_component(url, NSURL_HOST);
|
||||
|
||||
create_login_window(url, host, realm, cb, cbpw);
|
||||
|
||||
@ -179,7 +178,7 @@ void gui_401login_open(const char *url, const char *realm,
|
||||
|
||||
//void create_login_window(struct browser_window *bw, const char *host,
|
||||
// const char *realm, const char *fetchurl)
|
||||
static void create_login_window(const char *url, const char *host,
|
||||
static void create_login_window(nsurl *url, lwc_string *host,
|
||||
const char *realm, nserror (*cb)(bool proceed, void *pw),
|
||||
void *cbpw)
|
||||
{
|
||||
@ -191,8 +190,8 @@ static void create_login_window(const char *url, const char *host,
|
||||
text << "Host: " << host << "\n";
|
||||
//text << "\n";
|
||||
|
||||
LoginAlert *a = new LoginAlert(cb, cbpw, url, host, r.String(),
|
||||
text.String());
|
||||
LoginAlert *a = new LoginAlert(cb, cbpw, url, lwc_string_data(host),
|
||||
r.String(), text.String());
|
||||
// asynchronously
|
||||
a->Go(NULL);
|
||||
|
||||
|
@ -32,6 +32,7 @@ resource(408, "throbber8.png") #'data' import "res/throbber/throbber8.png";
|
||||
/* */
|
||||
resource(500, "credits.html") #'data' import "res/en/credits.html,faf";
|
||||
resource(501, "licence.html") #'data' import "res/en/licence.html,faf";
|
||||
resource(502, "welcome.html") #'data' import "res/en/welcome.html,faf";
|
||||
|
||||
|
||||
resource(1, "BEOS:APP_FLAGS") (#'APPF') $"01000000";
|
||||
@ -397,3 +398,48 @@ resource(101, "BEOS:V:STD_ICON") #'zICO' array {
|
||||
$"7F793EDCE3F417BB10DA0B"
|
||||
};
|
||||
|
||||
/* toolbar icons from Zumi <http://zumi.xoom.it/myhaiku>
|
||||
* (generated by Icon-O-Matic from the HFIV source file,
|
||||
* can't be automated)
|
||||
*/
|
||||
|
||||
resource(102, "forward_button") #'VICN' array {
|
||||
$"6E6369660304006603005900020006020000003C6000C000000000004C000048"
|
||||
$"A0000080FF80FF00B300010A0748353448343E223E222C342C3422030A000100"
|
||||
$"30222201178322040A0101001001178322040A02010000"
|
||||
};
|
||||
|
||||
resource(103, "back_button") #'VICN' array {
|
||||
$"6E6369660304006603005900020006020000003C6000C000000000004C000048"
|
||||
$"A0000080FF80FF00B300010A0722353622362C482C483E363E3648030A000100"
|
||||
$"30222201178322040A0101001001178322040A02010000"
|
||||
};
|
||||
|
||||
resource(104, "stop_button") #'VICN' array {
|
||||
$"6E6369660304006603800000020006020000003C6000C000000000004C000048"
|
||||
$"A00000FFABABFFD900000208022A40402A02043525BEE325B7D825253525B7D8"
|
||||
$"25BEE33545B7D845BEE345453545BEE345B7D8030A0002000130222201178900"
|
||||
$"040A010200011001178900040A02020100100117850004"
|
||||
};
|
||||
|
||||
resource(105, "reload_button") #'VICN' array {
|
||||
$"6E6369660404006603004080020006020000003A0000C000000000004C000046"
|
||||
$"7FFF00ABD5FFFF006CD9020006020000003A0000C000000000004C0000467FFF"
|
||||
$"FFAAD4FF00006CD9010606C60F482232383D2D3D2D3826222A2B2329224327BC"
|
||||
$"B7B25A4327060A00010030222201178322040A0101001001178322040A020100"
|
||||
$"000A00010012C00000000000000000C000004AC0004AC00001178422040A0101"
|
||||
$"0012C00000000000000000C000004AA0004AA00001178422040A03010002C000"
|
||||
$"00000000000000C000004AA0004AA000"
|
||||
};
|
||||
|
||||
resource(106, "home_button") #'VICN' array {
|
||||
$"6E6369660804006603800000020006020000003A8000C000000000004C000047"
|
||||
$"000000FFABABFFD900000554020016020000003AC000C000000000004BE00048"
|
||||
$"A00000FFFFE50300590002000602000000370000C000000000004C00004A5000"
|
||||
$"0080FF80FF00B20003806040040A064836483035222230223635280A04484848"
|
||||
$"42224222480A0542404234352A283428400A042C342C4032403234080A030102"
|
||||
$"1001178400040A040102000A0101001001178402040A020100000A0501011001"
|
||||
$"178402040A060101000A070103000A0701030240AAAA0000000000003E000045"
|
||||
$"0000468000"
|
||||
};
|
||||
|
||||
|
@ -22,7 +22,9 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <BeBuild.h>
|
||||
#include <Box.h>
|
||||
#include <Button.h>
|
||||
#include <Dragger.h>
|
||||
#include <Menu.h>
|
||||
@ -31,6 +33,8 @@
|
||||
#include <Node.h>
|
||||
#include <Path.h>
|
||||
#include <PopUpMenu.h>
|
||||
#include <Resources.h>
|
||||
#include <Roster.h>
|
||||
#include <Screen.h>
|
||||
#include <ScrollView.h>
|
||||
#include <String.h>
|
||||
@ -38,6 +42,12 @@
|
||||
#include <TextControl.h>
|
||||
#include <View.h>
|
||||
#include <Window.h>
|
||||
|
||||
#if defined(__HAIKU__)
|
||||
#include <IconUtils.h>
|
||||
#include "WindowStack.h"
|
||||
#endif
|
||||
|
||||
#include <fs_attr.h>
|
||||
extern "C" {
|
||||
#include "content/content.h"
|
||||
@ -164,6 +174,10 @@ static int32 nsbeos_replicant_main_thread(void *_arg);
|
||||
// in beos_gui.cpp
|
||||
extern int main(int argc, char** argv);
|
||||
|
||||
// in fetch_rsrc.cpp
|
||||
extern BResources *gAppResources;
|
||||
|
||||
|
||||
#warning XXX
|
||||
#if 0 /* GTK */
|
||||
static gboolean nsbeos_window_url_activate_event(beosWidget *, gpointer);
|
||||
@ -320,6 +334,7 @@ void
|
||||
NSThrobber::SetBitmap(const BBitmap *bitmap)
|
||||
{
|
||||
fBitmap = bitmap;
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
|
||||
@ -458,7 +473,7 @@ NSBaseView::MessageReceived(BMessage *message)
|
||||
nsbeos_pipe_message_top(message, NULL, fScaffolding);
|
||||
break;
|
||||
default:
|
||||
message->PrintToStream();
|
||||
//message->PrintToStream();
|
||||
BView::MessageReceived(message);
|
||||
}
|
||||
}
|
||||
@ -490,12 +505,13 @@ NSBaseView::Instantiate(BMessage *archive)
|
||||
if (!validate_instantiation(archive, "NSBaseView"))
|
||||
return NULL;
|
||||
const char *url;
|
||||
if (archive->FindString("url", &url) < B_OK) {
|
||||
return NULL;
|
||||
if (archive->FindString("url", &url) < B_OK
|
||||
|| url == NULL || strlen(url) == 0) {
|
||||
url = "about:";
|
||||
}
|
||||
|
||||
struct replicant_thread_info *info = new replicant_thread_info;
|
||||
info->url = url;
|
||||
info->url = BString(url);
|
||||
if (nsbeos_find_app_path(info->app) < B_OK)
|
||||
return NULL;
|
||||
info->args[0] = info->app;
|
||||
@ -510,6 +526,10 @@ NSBaseView::Instantiate(BMessage *archive)
|
||||
//netsurf_init(2, info->args);
|
||||
//return NULL;
|
||||
|
||||
// do as much as possible in this thread to avoid deadlocks
|
||||
|
||||
gui_init_replicant(2, info->args);
|
||||
|
||||
replicant_done_sem = create_sem(0, "NS Replicant created");
|
||||
thread_id nsMainThread = spawn_thread(nsbeos_replicant_main_thread,
|
||||
"NetSurf Main Thread", B_NORMAL_PRIORITY, info);
|
||||
@ -520,7 +540,8 @@ NSBaseView::Instantiate(BMessage *archive)
|
||||
return NULL;
|
||||
}
|
||||
resume_thread(nsMainThread);
|
||||
while (acquire_sem(replicant_done_sem) == EINTR);
|
||||
//XXX: deadlocks BeHappy
|
||||
//while (acquire_sem(replicant_done_sem) == EINTR);
|
||||
|
||||
return view;
|
||||
}
|
||||
@ -539,6 +560,7 @@ void
|
||||
NSBaseView::AllAttached()
|
||||
{
|
||||
BView::AllAttached();
|
||||
|
||||
struct beos_scaffolding *g = fScaffolding;
|
||||
if (!g)
|
||||
return;
|
||||
@ -576,6 +598,8 @@ NSBrowserWindow::NSBrowserWindow(BRect frame, struct beos_scaffolding *scaf)
|
||||
|
||||
NSBrowserWindow::~NSBrowserWindow()
|
||||
{
|
||||
if(activeWindow == this)
|
||||
activeWindow = NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -621,17 +645,26 @@ NSBrowserWindow::QuitRequested(void)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
NSBrowserWindow::WindowActivated(bool active)
|
||||
{
|
||||
if(active)
|
||||
activeWindow = this;
|
||||
else if(activeWindow == this)
|
||||
activeWindow = NULL;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - implementation
|
||||
|
||||
int32 nsbeos_replicant_main_thread(void *_arg)
|
||||
{
|
||||
struct replicant_thread_info *info = (struct replicant_thread_info *)_arg;
|
||||
int32 ret;
|
||||
ret = main(2, info->args);
|
||||
//netsurf_main_loop();
|
||||
//netsurf_exit();
|
||||
int32 ret = 0;
|
||||
|
||||
netsurf_main_loop();
|
||||
netsurf_exit();
|
||||
delete info;
|
||||
//release
|
||||
delete_sem(replicant_done_sem);
|
||||
return ret;
|
||||
}
|
||||
@ -686,6 +719,10 @@ void nsbeos_scaffolding_update_colors(nsbeos_scaffolding *g)
|
||||
}
|
||||
|
||||
|
||||
/*static*/ BWindow*
|
||||
NSBrowserWindow::activeWindow = NULL;
|
||||
|
||||
|
||||
void nsbeos_scaffolding_dispatch_event(nsbeos_scaffolding *scaffold, BMessage *message)
|
||||
{
|
||||
int width, height;
|
||||
@ -907,6 +944,7 @@ void nsbeos_scaffolding_dispatch_event(nsbeos_scaffolding *scaffold, BMessage *m
|
||||
text = scaffold->url_bar->Text();
|
||||
scaffold->url_bar->UnlockLooper();
|
||||
|
||||
NSBrowserWindow::activeWindow = scaffold->window;
|
||||
browser_window_create(text.String(), bw, NULL, false, false);
|
||||
break;
|
||||
}
|
||||
@ -1570,7 +1608,20 @@ void nsbeos_attach_toplevel_view(nsbeos_scaffolding *g, BView *view)
|
||||
message->AddPointer("scaffolding", g);
|
||||
g->window->AddShortcut('H', 0, message, view);
|
||||
|
||||
|
||||
#if defined(__HAIKU__)
|
||||
// Make sure the window is layouted and answering to events, but do not
|
||||
// show it before it is actually resized
|
||||
g->window->Hide();
|
||||
g->window->Show();
|
||||
|
||||
if(NSBrowserWindow::activeWindow) {
|
||||
BWindowStack stack(NSBrowserWindow::activeWindow);
|
||||
stack.AddWindow(g->window);
|
||||
}
|
||||
#endif
|
||||
g->window->Show();
|
||||
|
||||
} else {
|
||||
if (g->top_view->Looper())
|
||||
g->top_view->UnlockLooper();
|
||||
@ -1659,6 +1710,97 @@ static BMenuItem *make_menu_item(const char *name, BMessage *message)
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
class BBitmapButton: public BButton
|
||||
{
|
||||
public:
|
||||
BBitmapButton(BRect rect, const char* name, const char* label,
|
||||
BMessage* message);
|
||||
~BBitmapButton();
|
||||
|
||||
void Draw(BRect updateRect);
|
||||
void SetBitmap(const char* attrName);
|
||||
private:
|
||||
BBitmap* fBitmap;
|
||||
BBitmap* fDisabledBitmap;
|
||||
};
|
||||
|
||||
|
||||
BBitmapButton::BBitmapButton(BRect rect, const char* name, const char* label,
|
||||
BMessage* message)
|
||||
: BButton(rect, name, label, message)
|
||||
{
|
||||
SetBitmap(name);
|
||||
}
|
||||
|
||||
|
||||
BBitmapButton::~BBitmapButton()
|
||||
{
|
||||
delete fBitmap;
|
||||
delete fDisabledBitmap;
|
||||
}
|
||||
|
||||
|
||||
void BBitmapButton::Draw(BRect updateRect)
|
||||
{
|
||||
if(fBitmap == NULL) {
|
||||
BButton::Draw(updateRect);
|
||||
return;
|
||||
}
|
||||
|
||||
SetDrawingMode(B_OP_COPY);
|
||||
FillRect(updateRect, B_SOLID_LOW);
|
||||
rgb_color color = LowColor();
|
||||
|
||||
SetDrawingMode(B_OP_ALPHA);
|
||||
if(IsEnabled()) {
|
||||
if(Value() != 0) {
|
||||
// button is clicked
|
||||
DrawBitmap(fBitmap, BPoint(1, 1));
|
||||
} else {
|
||||
// button is released
|
||||
DrawBitmap(fBitmap, BPoint(0, 0));
|
||||
}
|
||||
} else
|
||||
DrawBitmap(fDisabledBitmap, BPoint(0, 0));
|
||||
}
|
||||
|
||||
|
||||
void BBitmapButton::SetBitmap(const char* attrname)
|
||||
{
|
||||
#ifdef __HAIKU__
|
||||
size_t size = 0;
|
||||
const void* data = gAppResources->LoadResource('VICN', attrname, &size);
|
||||
|
||||
if (!data) {
|
||||
printf("CANT LOAD RESOURCE %s\n", attrname);
|
||||
return;
|
||||
}
|
||||
|
||||
fBitmap = new BBitmap(BRect(0, 0, 32, 32), B_RGB32);
|
||||
status_t status = BIconUtils::GetVectorIcon((const uint8*)data, size, fBitmap);
|
||||
|
||||
if(status != B_OK) {
|
||||
fprintf(stderr, "%s > oops %s\n", attrname, strerror(status));
|
||||
delete fBitmap;
|
||||
fBitmap = NULL;
|
||||
}
|
||||
|
||||
fDisabledBitmap = new BBitmap(fBitmap);
|
||||
rgb_color* pixel = (rgb_color*)fDisabledBitmap->Bits();
|
||||
for(int i = 0; i < fDisabledBitmap->BitsLength()/4; i++)
|
||||
{
|
||||
*pixel = tint_color(*pixel, B_DISABLED_MARK_TINT);
|
||||
pixel++;
|
||||
}
|
||||
#else
|
||||
// No vector icon support on BeOS. We could try to load a bitmap one
|
||||
fBitmap = NULL;
|
||||
fDisabledBitmap = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
nsbeos_scaffolding *nsbeos_new_scaffolding(struct gui_window *toplevel)
|
||||
{
|
||||
struct beos_scaffolding *g = (struct beos_scaffolding *)malloc(sizeof(*g));
|
||||
@ -1676,7 +1818,6 @@ nsbeos_scaffolding *nsbeos_new_scaffolding(struct gui_window *toplevel)
|
||||
|
||||
g->window = NULL;
|
||||
g->menu_bar = NULL;
|
||||
g->window = NULL;
|
||||
|
||||
if (replicated && !replicant_view) {
|
||||
warn_user("Error: No subwindow allowed when replicated.", NULL);
|
||||
@ -1685,7 +1826,6 @@ nsbeos_scaffolding *nsbeos_new_scaffolding(struct gui_window *toplevel)
|
||||
|
||||
|
||||
if (!replicant_view) {
|
||||
|
||||
BRect frame(0, 0, 600-1, 500-1);
|
||||
if (nsoption_int(window_width) > 0) {
|
||||
frame.Set(0, 0, nsoption_int(window_width) - 1, nsoption_int(window_height) - 1);
|
||||
@ -1696,7 +1836,7 @@ nsbeos_scaffolding *nsbeos_new_scaffolding(struct gui_window *toplevel)
|
||||
NSBrowserWindow *win = nsbeos_find_last_window();
|
||||
if (win) {
|
||||
pos = win->Frame().LeftTop();
|
||||
win->Unlock();
|
||||
win->UnlockLooper();
|
||||
}
|
||||
pos += BPoint(20, 20);
|
||||
BScreen screen;
|
||||
@ -2035,17 +2175,19 @@ nsbeos_scaffolding *nsbeos_new_scaffolding(struct gui_window *toplevel)
|
||||
// the toolbar is also the dragger for now
|
||||
// XXX: try to stuff it in the status bar at the bottom
|
||||
// (BDragger *must* be a parent, sibiling or direct child of NSBaseView!)
|
||||
// XXX: B_FULL_UPDATE_ON_RESIZE avoids leaving bits on resize,
|
||||
// but causes flicker
|
||||
rect = g->top_view->Bounds();
|
||||
rect.bottom = rect.top + TOOLBAR_HEIGHT - 1;
|
||||
rect.right = rect.right - DRAGGER_WIDTH;
|
||||
g->tool_bar = new BView(rect, "Toolbar",
|
||||
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, B_WILL_DRAW);
|
||||
g->tool_bar = new BBox(rect, "Toolbar",
|
||||
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, B_WILL_DRAW | B_FRAME_EVENTS
|
||||
| B_FULL_UPDATE_ON_RESIZE | B_NAVIGABLE_JUMP, B_PLAIN_BORDER);
|
||||
g->top_view->AddChild(g->tool_bar);
|
||||
g->tool_bar->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
g->tool_bar->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)) ;
|
||||
|
||||
// buttons
|
||||
#warning use BPictureButton
|
||||
rect = g->tool_bar->Bounds();
|
||||
rect.right = TOOLBAR_HEIGHT;
|
||||
rect.InsetBySelf(5, 5);
|
||||
@ -2054,35 +2196,35 @@ nsbeos_scaffolding *nsbeos_new_scaffolding(struct gui_window *toplevel)
|
||||
|
||||
message = new BMessage('back');
|
||||
message->AddPointer("scaffolding", g);
|
||||
g->back_button = new BButton(rect, "back_button", "<", message);
|
||||
g->back_button = new BBitmapButton(rect, "back_button", "<", message);
|
||||
g->tool_bar->AddChild(g->back_button);
|
||||
nButtons++;
|
||||
|
||||
rect.OffsetBySelf(TOOLBAR_HEIGHT, 0);
|
||||
message = new BMessage('forw');
|
||||
message->AddPointer("scaffolding", g);
|
||||
g->forward_button = new BButton(rect, "forward_button", ">", message);
|
||||
g->forward_button = new BBitmapButton(rect, "forward_button", ">", message);
|
||||
g->tool_bar->AddChild(g->forward_button);
|
||||
nButtons++;
|
||||
|
||||
rect.OffsetBySelf(TOOLBAR_HEIGHT, 0);
|
||||
message = new BMessage('stop');
|
||||
message->AddPointer("scaffolding", g);
|
||||
g->stop_button = new BButton(rect, "stop_button", "S", message);
|
||||
g->stop_button = new BBitmapButton(rect, "stop_button", "S", message);
|
||||
g->tool_bar->AddChild(g->stop_button);
|
||||
nButtons++;
|
||||
|
||||
rect.OffsetBySelf(TOOLBAR_HEIGHT, 0);
|
||||
message = new BMessage('relo');
|
||||
message->AddPointer("scaffolding", g);
|
||||
g->reload_button = new BButton(rect, "reload_button", "R", message);
|
||||
g->reload_button = new BBitmapButton(rect, "reload_button", "R", message);
|
||||
g->tool_bar->AddChild(g->reload_button);
|
||||
nButtons++;
|
||||
|
||||
rect.OffsetBySelf(TOOLBAR_HEIGHT, 0);
|
||||
message = new BMessage('home');
|
||||
message->AddPointer("scaffolding", g);
|
||||
g->home_button = new BButton(rect, "home_button", "H", message);
|
||||
g->home_button = new BBitmapButton(rect, "home_button", "H", message);
|
||||
g->tool_bar->AddChild(g->home_button);
|
||||
nButtons++;
|
||||
|
||||
@ -2407,3 +2549,4 @@ void nsbeos_scaffolding_popup_menu(nsbeos_scaffolding *g, BPoint where)
|
||||
{
|
||||
g->popup_menu->Go(where);
|
||||
}
|
||||
|
||||
|
@ -61,11 +61,15 @@ virtual ~NSBrowserWindow();
|
||||
virtual void DispatchMessage(BMessage *message, BHandler *handler);
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
virtual bool QuitRequested(void);
|
||||
void WindowActivated(bool active);
|
||||
|
||||
struct beos_scaffolding *Scaffolding() const { return fScaffolding; };
|
||||
|
||||
static BWindow* activeWindow;
|
||||
private:
|
||||
struct beos_scaffolding *fScaffolding;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -95,8 +95,9 @@ schedule(int t, void (*callback)(void *p), void *p)
|
||||
cb->context = p;
|
||||
cb->callback_killed = cb->callback_fired = false;
|
||||
cb->timeout = timeout;
|
||||
if (earliest_callback_timeout > timeout)
|
||||
if (earliest_callback_timeout > timeout) {
|
||||
earliest_callback_timeout = timeout;
|
||||
}
|
||||
callbacks->AddItem(cb);
|
||||
}
|
||||
|
||||
@ -104,11 +105,12 @@ bool
|
||||
schedule_run(void)
|
||||
{
|
||||
LOG(("schedule_run()"));
|
||||
|
||||
earliest_callback_timeout = B_INFINITE_TIMEOUT;
|
||||
if (callbacks == NULL)
|
||||
return false; /* Nothing to do */
|
||||
|
||||
bigtime_t now = system_time();
|
||||
earliest_callback_timeout = B_INFINITE_TIMEOUT;
|
||||
int32 i;
|
||||
|
||||
LOG(("Checking %ld callbacks to for deadline.", this_run->CountItems()));
|
||||
|
@ -131,7 +131,7 @@ static GdkCursor *nsbeos_create_menu_cursor(void);
|
||||
|
||||
NSBrowserFrameView::NSBrowserFrameView(BRect frame, struct gui_window *gui)
|
||||
: BView(frame, "NSBrowserFrameView", B_FOLLOW_ALL_SIDES,
|
||||
B_WILL_DRAW | B_NAVIGABLE | B_FRAME_EVENTS /*| B_SUBPIXEL_PRECISE*/),
|
||||
B_WILL_DRAW | B_NAVIGABLE | B_FRAME_EVENTS ),
|
||||
fGuiWindow(gui)
|
||||
{
|
||||
}
|
||||
@ -250,7 +250,7 @@ NSBrowserFrameView::MessageReceived(BMessage *message)
|
||||
nsbeos_pipe_message_top(message, NULL, fGuiWindow->scaffold);
|
||||
break;
|
||||
default:
|
||||
message->PrintToStream();
|
||||
//message->PrintToStream();
|
||||
BView::MessageReceived(message);
|
||||
}
|
||||
}
|
||||
@ -756,18 +756,25 @@ void nsbeos_dispatch_event(BMessage *message)
|
||||
break;
|
||||
case 'nsLO': // login
|
||||
{
|
||||
BString url;
|
||||
nsurl* url;
|
||||
BString realm;
|
||||
BString auth;
|
||||
if (message->FindString("URL", &url) < B_OK)
|
||||
void* cbpw;
|
||||
nserror (*cb)(bool proceed, void* pw);
|
||||
|
||||
if (message->FindPointer("URL", (void**)&url) < B_OK)
|
||||
break;
|
||||
if (message->FindString("Realm", &realm) < B_OK)
|
||||
break;
|
||||
if (message->FindString("Auth", &auth) < B_OK)
|
||||
break;
|
||||
if (message->FindPointer("callback", (void**)&cb) < B_OK)
|
||||
break;
|
||||
if (message->FindPointer("callback_pw", (void**)&cbpw) < B_OK)
|
||||
break;
|
||||
//printf("login to '%s' with '%s'\n", url.String(), auth.String());
|
||||
urldb_set_auth_details(url.String(), realm.String(), auth.String());
|
||||
browser_window_go(gui->bw, url.String(), 0, true);
|
||||
urldb_set_auth_details(url, realm.String(), auth.String());
|
||||
cb(true, cbpw);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -926,11 +933,44 @@ void nsbeos_window_keypress_event(BView *view, gui_window *g, BMessage *event)
|
||||
nskey = utf8_to_ucs4(bytes, numbytes);
|
||||
}
|
||||
|
||||
bool done = browser_window_key_press(g->bw, nskey);
|
||||
LOG(("nskey %d %d", nskey, done));
|
||||
//if (browser_window_key_press(g->bw, nskey))
|
||||
if(browser_window_key_press(g->bw, nskey))
|
||||
return;
|
||||
|
||||
// Remaining events are for scrolling the page around
|
||||
float hdelta = 0.0f, vdelta = 0.0f;
|
||||
g->view->LockLooper();
|
||||
BRect size = g->view->Bounds();
|
||||
switch (byte) {
|
||||
case B_HOME:
|
||||
g->view->ScrollTo(0.0f, 0.0f);
|
||||
break;
|
||||
case B_END:
|
||||
{
|
||||
// TODO
|
||||
break;
|
||||
}
|
||||
case B_PAGE_UP:
|
||||
vdelta = -size.Height();
|
||||
break;
|
||||
case B_PAGE_DOWN:
|
||||
vdelta = size.Height();
|
||||
break;
|
||||
case B_LEFT_ARROW:
|
||||
hdelta = -10;
|
||||
break;
|
||||
case B_RIGHT_ARROW:
|
||||
hdelta = 10;
|
||||
break;
|
||||
case B_UP_ARROW:
|
||||
vdelta = -10;
|
||||
break;
|
||||
case B_DOWN_ARROW:
|
||||
vdelta = 10;
|
||||
break;
|
||||
}
|
||||
|
||||
g->view->ScrollBy(hdelta, vdelta);
|
||||
g->view->UnlockLooper();
|
||||
}
|
||||
|
||||
#warning WRITEME
|
||||
@ -1038,7 +1078,7 @@ gboolean nsbeos_window_keypress_event(GtkWidget *widget, GdkEventKey *event,
|
||||
|
||||
void nsbeos_window_resize_event(BView *view, gui_window *g, BMessage *event)
|
||||
{
|
||||
CALLED();
|
||||
//CALLED();
|
||||
int32 width;
|
||||
int32 height;
|
||||
|
||||
@ -1088,7 +1128,7 @@ void nsbeos_window_resize_event(BView *view, gui_window *g, BMessage *event)
|
||||
|
||||
void nsbeos_window_moved_event(BView *view, gui_window *g, BMessage *event)
|
||||
{
|
||||
CALLED();
|
||||
//CALLED();
|
||||
|
||||
#warning XXX: Invalidate ?
|
||||
if (!view || !view->LockLooper())
|
||||
@ -1272,7 +1312,7 @@ void gui_window_update_box(struct gui_window *g, const struct rect *rect)
|
||||
|
||||
bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
|
||||
{
|
||||
CALLED();
|
||||
//CALLED();
|
||||
if (g->view == NULL)
|
||||
return false;
|
||||
if (!g->view->LockLooper())
|
||||
@ -1302,7 +1342,7 @@ bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
|
||||
|
||||
void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
|
||||
{
|
||||
CALLED();
|
||||
//CALLED();
|
||||
if (g->view == NULL)
|
||||
return;
|
||||
if (!g->view->LockLooper())
|
||||
@ -1344,7 +1384,7 @@ void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
|
||||
|
||||
void gui_window_update_extent(struct gui_window *g)
|
||||
{
|
||||
CALLED();
|
||||
//CALLED();
|
||||
if (!g->bw->current_content)
|
||||
return;
|
||||
|
||||
@ -1359,7 +1399,7 @@ void gui_window_update_extent(struct gui_window *g)
|
||||
float y_prop = g->view->Bounds().Height() / y_max;
|
||||
x_max -= g->view->Bounds().Width() + 1;
|
||||
y_max -= g->view->Bounds().Height() + 1;
|
||||
printf("x_max = %f y_max = %f x_prop = %f y_prop = %f\n", x_max, y_max, x_prop, y_prop);
|
||||
LOG(("x_max = %f y_max = %f x_prop = %f y_prop = %f\n", x_max, y_max, x_prop, y_prop));
|
||||
if (g->view->ScrollBar(B_HORIZONTAL)) {
|
||||
g->view->ScrollBar(B_HORIZONTAL)->SetRange(0, x_max);
|
||||
g->view->ScrollBar(B_HORIZONTAL)->SetProportion(x_prop);
|
||||
@ -1542,7 +1582,7 @@ void gui_window_hide_pointer(struct gui_window *g)
|
||||
|
||||
void gui_window_place_caret(struct gui_window *g, int x, int y, int height)
|
||||
{
|
||||
CALLED();
|
||||
//CALLED();
|
||||
if (g->view == NULL)
|
||||
return;
|
||||
if (!g->view->LockLooper())
|
||||
@ -1674,7 +1714,7 @@ bool gui_add_to_clipboard(const char *text, size_t length, bool space,
|
||||
BFont font;
|
||||
text_run *run = new text_run;
|
||||
|
||||
nsbeos_style_to_font(font, &fstyle);
|
||||
nsbeos_style_to_font(font, fstyle);
|
||||
run->offset = current_selection.Length();
|
||||
run->font = font;
|
||||
run->color = nsbeos_rgb_colour(fstyle->foreground);
|
||||
|
@ -415,8 +415,8 @@ void hotlist_add_entry(bool selected)
|
||||
{
|
||||
struct node *node;
|
||||
struct node *parent = NULL;
|
||||
creating_node = true;
|
||||
nsurl *url;
|
||||
creating_node = true;
|
||||
|
||||
if (selected == true) {
|
||||
parent = tree_get_selected_node(tree_get_root(hotlist_tree));
|
||||
|
@ -24,14 +24,14 @@
|
||||
|
||||
/* Try to detect which features the target OS supports */
|
||||
|
||||
#if (defined(_GNU_SOURCE) && !defined(__APPLE__))
|
||||
#if (defined(_GNU_SOURCE) && !defined(__APPLE__) || defined(__HAIKU__))
|
||||
#define HAVE_STRNDUP
|
||||
#else
|
||||
#undef HAVE_STRNDUP
|
||||
char *strndup(const char *s, size_t n);
|
||||
#endif
|
||||
|
||||
#if (defined(_GNU_SOURCE) || defined(__APPLE__))
|
||||
#if (defined(_GNU_SOURCE) || defined(__APPLE__) || defined(__HAIKU__))
|
||||
#define HAVE_STRCASESTR
|
||||
#else
|
||||
#undef HAVE_STRCASESTR
|
||||
|
Loading…
Reference in New Issue
Block a user