mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-02-13 21:14:25 +03:00
Add Replicant support. No it's not about cyborgs, just embedding NetSurf into another app, like Tracker (the desktop), or documentation browsers like BeHappy...
svn path=/trunk/netsurf/; revision=5583
This commit is contained in:
parent
6330f8e475
commit
b3a5250f99
@ -47,6 +47,7 @@ extern "C" {
|
||||
#include "utils/base64.h"
|
||||
}
|
||||
#include "beos/beos_fetch_rsrc.h"
|
||||
#include "beos/beos_gui.h"
|
||||
|
||||
#include <image.h>
|
||||
#include <Resources.h>
|
||||
@ -317,21 +318,9 @@ static void fetch_rsrc_poll(const char *scheme)
|
||||
*/
|
||||
static int find_app_resources()
|
||||
{
|
||||
image_info info;
|
||||
const char *path = NULL;
|
||||
int32 cookie = 0;
|
||||
while (get_next_image_info(0, &cookie, &info) == B_OK) {
|
||||
//fprintf(stderr, "%p <> %p, %p\n", (char *)&find_app_resources, (char *)info.text, (char *)info.text + info.text_size);
|
||||
if (((char *)&find_app_resources >= (char *)info.text)
|
||||
&& ((char *)&find_app_resources < (char *)info.text + info.text_size)) {
|
||||
//fprintf(stderr, "match\n");
|
||||
path = info.name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (path == NULL)
|
||||
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);
|
||||
|
||||
BFile file(path, B_READ_ONLY);
|
||||
|
@ -81,6 +81,7 @@ extern "C" {
|
||||
//#include "beos/beos_download.h"
|
||||
#include "beos/beos_schedule.h"
|
||||
#include "beos/beos_fetch_rsrc.h"
|
||||
#include "beos/beos_scaffolding.h"
|
||||
|
||||
|
||||
#ifdef WITH_HUBBUB
|
||||
@ -96,6 +97,7 @@ static void *myrealloc(void *ptr, size_t len, void *pw);
|
||||
#define USE_RESOURCES 1
|
||||
|
||||
bool gui_in_multitask = false;
|
||||
bool replicated = false; /**< if we are running as a replicant */
|
||||
|
||||
char *default_stylesheet_url;
|
||||
char *adblock_stylesheet_url;
|
||||
@ -285,6 +287,26 @@ char *realpath(const char *f, char *buf)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* finds the NetSurf binary image ID and path
|
||||
*
|
||||
*/
|
||||
image_id nsbeos_find_app_path(char *path)
|
||||
{
|
||||
image_info info;
|
||||
int32 cookie = 0;
|
||||
while (get_next_image_info(0, &cookie, &info) == B_OK) {
|
||||
//fprintf(stderr, "%p <> %p, %p\n", (char *)&find_app_resources, (char *)info.text, (char *)info.text + info.text_size);
|
||||
if (((char *)&nsbeos_find_app_path >= (char *)info.text)
|
||||
&& ((char *)&nsbeos_find_app_path < (char *)info.text + info.text_size)) {
|
||||
//fprintf(stderr, "match\n");
|
||||
if (path)
|
||||
strlcpy(path, info.name, B_PATH_NAME_LENGTH);
|
||||
return info.id;
|
||||
}
|
||||
}
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Locate a shared resource file by searching known places in order.
|
||||
*
|
||||
@ -397,13 +419,14 @@ void gui_init(int argc, char** argv)
|
||||
|
||||
if (pipe(sEventPipe) < 0)
|
||||
return;
|
||||
|
||||
new NSBrowserApplication;
|
||||
sBAppThreadID = spawn_thread(bapp_thread, "BApplication(NetSurf)", B_NORMAL_PRIORITY, (void *)find_thread(NULL));
|
||||
if (sBAppThreadID < B_OK)
|
||||
return; /* #### handle errors */
|
||||
if (resume_thread(sBAppThreadID) < B_OK)
|
||||
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 */
|
||||
if (resume_thread(sBAppThreadID) < B_OK)
|
||||
return;
|
||||
}
|
||||
|
||||
fetch_rsrc_register();
|
||||
|
||||
@ -559,7 +582,8 @@ void gui_init(int argc, char** argv)
|
||||
nsbeos_history_init();
|
||||
//nsbeos_download_initialise();
|
||||
|
||||
be_app->Unlock();
|
||||
if (!replicated)
|
||||
be_app->Unlock();
|
||||
|
||||
#if 0 /* GTK */
|
||||
wndAbout = beos_WINDOW(glade_xml_get_widget(gladeWindows, "wndAbout"));
|
||||
|
@ -25,6 +25,8 @@
|
||||
#define CALLED() fprintf(stderr, "%s()\n", __FUNCTION__);
|
||||
|
||||
extern bool gui_in_multitask;
|
||||
extern bool replicated;
|
||||
|
||||
#if 0 /* GTK */
|
||||
//extern GladeXML *gladeWindows;
|
||||
//extern char *glade_file_location;
|
||||
@ -59,4 +61,4 @@ void nsbeos_pipe_message(BMessage *message, BView *_this, struct gui_window *gui
|
||||
void nsbeos_pipe_message_top(BMessage *message, BWindow *_this, struct beos_scaffolding *scaffold);
|
||||
|
||||
void nsbeos_gui_view_source(struct content *content, struct selection *selection);
|
||||
|
||||
image_id nsbeos_find_app_path(char *path);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -29,6 +29,28 @@ extern "C" {
|
||||
|
||||
typedef struct beos_scaffolding nsbeos_scaffolding;
|
||||
|
||||
class NSBaseView : public BView {
|
||||
public:
|
||||
NSBaseView(BRect frame);
|
||||
NSBaseView(BMessage *archive);
|
||||
virtual ~NSBaseView();
|
||||
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
//virtual void Draw(BRect updateRect);
|
||||
|
||||
//virtual void FrameMoved(BPoint new_location);
|
||||
//virtual void FrameResized(float new_width, float new_height);
|
||||
|
||||
virtual void AllAttached(void);
|
||||
|
||||
virtual status_t Archive(BMessage *archive, bool deep=true) const;
|
||||
static BArchivable *Instantiate(BMessage *archive);
|
||||
|
||||
void SetScaffolding(struct beos_scaffolding *scaf);
|
||||
private:
|
||||
struct beos_scaffolding *fScaffolding;
|
||||
};
|
||||
|
||||
class NSBrowserWindow : public BWindow {
|
||||
public:
|
||||
NSBrowserWindow(BRect frame, struct beos_scaffolding *scaf);
|
||||
@ -44,6 +66,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
// XXX: clean up
|
||||
typedef enum {
|
||||
|
||||
/* no/unknown actions */
|
||||
|
Loading…
x
Reference in New Issue
Block a user