implement misc callback, move tables into individual files

This commit is contained in:
anthony 2020-11-17 20:14:34 +00:00
parent 9bdf829926
commit 204031b467
19 changed files with 569 additions and 323 deletions

View File

@ -16,6 +16,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
#import "NetsurfCallback.h"
@interface AppDelegate: NSResponder<NSApplicationDelegate> {
@private
}

View File

@ -1,330 +1,20 @@
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
#import "AppDelegate.h"
#import "BrowserWindowController.h"
#import "netsurf/netsurf.h"
#import "netsurf/misc.h"
#import "netsurf/window.h"
#import "netsurf/clipboard.h"
#import "netsurf/download.h"
#import "netsurf/fetch.h"
#import "netsurf/search.h"
#import "netsurf/bitmap.h"
#import "netsurf/layout.h"
#import "netsurf/browser_window.h"
#import "utils/nsoption.h"
#import "utils/nsurl.h"
/*******************/
/****** Misc *******/
/*******************/
// Schedule a callback to be run after t ms, or removed if ngtv, func and param.
static nserror gnustep_misc_schedule(int t, void (*callback)(void *p), void *p) {
NSLog(@"gnustep_misc_schedule");
return NSERROR_OK;
}
static struct gui_misc_table gnustep_misc_table = {
.schedule = gnustep_misc_schedule
};
/********************/
/****** Window ******/
/********************/
// Create and open a browser window
static struct gui_window *gnustep_window_create(struct browser_window *bw,
struct gui_window *existing,
gui_window_create_flags flags) {
NSLog(@"gnustep_window_create");
BrowserWindowController *controller = [[BrowserWindowController alloc]
initWithWindowNibName: @"Browser"];
[controller loadWindow];
return (struct gui_window*)controller;
}
// Destroy the specified window
static void gnustep_window_destroy(struct gui_window *gw) {
NSLog(@"gnustep_window_destroy");
}
// Trigger a redraw of the specified area, or the entire window if null
static nserror gnustep_window_invalidate(struct gui_window *gw, const struct rect *rect) {
NSLog(@"gnustep_window_invalidate");
return NSERROR_OK;
}
// Put the current scroll offset into sx and sy
static bool gnustep_window_get_scroll(struct gui_window *gw, int *sx, int *sy) {
NSLog(@"gnustep_window_get_scroll");
return true;
}
// Set the current scroll offset
static nserror gnustep_window_set_scroll(struct gui_window *gw, const struct rect *rect) {
NSLog(@"gnustep_window_set_scroll");
return NSERROR_OK;
}
// Put the dimensions of the specified window into width, height
static nserror gnustep_window_get_dimensions(struct gui_window *gw, int *width, int *height) {
NSLog(@"gnustep_window_get_dimensions");
return NSERROR_OK;
}
// Some kind of event happened
static nserror gnustep_window_event(struct gui_window *gw, enum gui_window_event event) {
NSLog(@"gnustep_window_event");
return NSERROR_OK;
}
static struct gui_window_table gnustep_window_table = {
.create = gnustep_window_create,
.destroy = gnustep_window_destroy,
.invalidate = gnustep_window_invalidate,
.get_scroll = gnustep_window_get_scroll,
.set_scroll = gnustep_window_set_scroll,
.get_dimensions = gnustep_window_get_dimensions,
.event = gnustep_window_event
};
/***********************/
/****** Clipboard ******/
/***********************/
// Put content of clipboard into buffer up to a maximum length
static void gnustep_clipboard_get(char **buffer, size_t *length) {
NSLog(@"gnustep_clipboard_get");
}
// Save the provided clipboard for later retreival above
static void gnustep_clipboard_set(const char *buffer, size_t length, nsclipboard_styles styles[], int n_styles) {
NSLog(@"gnustep_clipboard_set");
}
static struct gui_clipboard_table gnustep_clipboard_table = {
.get = gnustep_clipboard_get,
.set = gnustep_clipboard_set
};
/**********************/
/****** Download ******/
/**********************/
// Create and display a downloads window?
static struct gui_download_window *gnustep_download_create(struct download_context *ctx, struct gui_window *parent) {
NSLog(@"gnustep_download_create");
return NULL;
}
// ??
static nserror gnustep_download_data(struct gui_download_window *dw, const char *data, unsigned int size) {
NSLog(@"gnustep_download_data");
return NSERROR_OK;
}
// Error occurred during download
static void gnustep_download_error(struct gui_download_window *dw, const char *error_msg) {
NSLog(@"gnustep_download_error");
}
// Download completed
static void gnustep_download_done(struct gui_download_window *dw) {
NSLog(@"gnustep_download_done");
}
static struct gui_download_table gnustep_download_table = {
.create = gnustep_download_create,
.data = gnustep_download_data,
.error = gnustep_download_error,
.done = gnustep_download_done
};
/*******************/
/****** Fetch ******/
/*******************/
// Return the MIME type of the specified file. Returned string can be inval on next req.
static const char *gnustep_fetch_filetype(const char *unix_path) {
static char filetype[100];
filetype[0] = '\0';
return filetype;
}
static struct gui_fetch_table gnustep_fetch_table = {
.filetype = gnustep_fetch_filetype
};
/********************/
/****** Search ******/
/********************/
// Change displayed search status found/notfound?
static void gnustep_search_status(bool found, void *p) {
NSLog(@"gnustep_search_status");
}
// Show hourglass if active else stop hourglass
static void gnustep_search_hourglass(bool active, void *p) {
NSLog(@"gnustep_search_hourglass");
}
// Add search string to recent searches list
static void gnustep_search_add_recent(const char *string, void *p) {
NSLog(@"gnustep_search_add_recent");
}
// Set the next match button to active/inactive
static void gnustep_search_forward_state(bool active, void *p) {
NSLog(@"gnustep_search_forward_state");
}
// set the previous match button to active/inactive
static void gnustep_search_back_state(bool active, void *p) {
NSLog(@"gnustep_search_back_state");
}
static struct gui_search_table gnustep_search_table = {
.status = gnustep_search_status,
.hourglass = gnustep_search_hourglass,
.add_recent = gnustep_search_add_recent,
.forward_state = gnustep_search_forward_state,
.back_state = gnustep_search_back_state
};
/********************/
/****** Bitmap ******/
/********************/
// Create a new bitmap of width height
static void *gnustep_bitmap_create(int width, int height, unsigned int state) {
NSLog(@"gnustep_bitmap_create");
return NULL;
}
// Destroy the specified bitmap
static void gnustep_bitmap_destroy(void *bitmap) {
NSLog(@"gnustep_bitmap_destroy");
}
// Set whether it's opaque or not
static void gnustep_bitmap_set_opaque(void *bitmap, bool opaque) {
NSLog(@"gnustep_bitmap_set_opaque");
}
// Get whether it's opaque or not
static bool gnustep_bitmap_get_opaque(void *bitmap) {
NSLog(@"gnustep_bitmap_get_opaque");
return 0;
}
// Test? whether it's opaque or not
static bool gnustep_bitmap_test_opaque(void *bitmap) {
NSLog(@"gnustep_bitmap_test_opaque");
return 0;
}
// Get the image buffer for the bitmap
static unsigned char *gnustep_bitmap_get_buffer(void *bitmap) {
NSLog(@"gnustep_bitmap_get_buffer");
return NULL;
}
// Get the number of bytes per row of the bitmap
static size_t gnustep_bitmap_get_rowstride(void *bitmap) {
NSLog(@"gnustep_bitmap_get_rowstride");
return 0;
}
// Get its width in pixels
static int gnustep_bitmap_get_width(void *bitmap) {
NSLog(@"gnustep_bitmap_get_width");
return 0;
}
// Get height in pixels
static int gnustep_bitmap_get_height(void *bitmap) {
NSLog(@"gnustep_bitmap_get_height");
return 0;
}
// Get how many byytes pet pixel
static size_t gnustep_bitmap_get_bpp(void *bitmap) {
NSLog(@"gnustep_bitmap_get_bpp");
return 0;
}
// Save the bitmap to the specified path
static bool gnustep_bitmap_save(void *bitmap, const char *path, unsigned flags) {
NSLog(@"gnustep_bitmap_save");
return 0;
}
// Mark bitmap as modified
static void gnustep_bitmap_modified(void *bitmap) {
NSLog(@"gnustep_bitmap_modified");
}
// Render content into the specified bitmap
static nserror gnustep_bitmap_render(struct bitmap *bitmap, struct hlcache_handle *content) {
NSLog(@"gnustep_bitmap_render");
return NSERROR_OK;
}
static struct gui_bitmap_table gnustep_bitmap_table = {
.create = gnustep_bitmap_create,
.destroy = gnustep_bitmap_destroy,
.set_opaque = gnustep_bitmap_set_opaque,
.get_opaque = gnustep_bitmap_get_opaque,
.test_opaque = gnustep_bitmap_test_opaque,
.get_buffer = gnustep_bitmap_get_buffer,
.get_rowstride = gnustep_bitmap_get_rowstride,
.get_width = gnustep_bitmap_get_width,
.get_height = gnustep_bitmap_get_height,
.get_bpp = gnustep_bitmap_get_bpp,
.save = gnustep_bitmap_save,
.modified = gnustep_bitmap_modified,
.render = gnustep_bitmap_render
};
/****** Layout ******/
// Put the measured width of the string into width
static nserror gnustep_layout_width(const struct plot_font_style *fstyle, const char *string, size_t length, int *width) {
*width = 0;
NSLog(@"gnustep_layout_width");
}
// Put the character offset and actual x coordinate of the character for which the x
// coordinate is nearest to
static nserror gnustep_layout_position(const struct plot_font_style *fstyle, const char *string, size_t length, int x, size_t *char_offset, int *actual_x) {
*char_offset = 0;
*actual_x = 0;
NSLog(@"gnustep_layout_position");
}
// Put the char offset and x coordinate of where to split a string so it fits in width x
static nserror gnustep_layout_split(const struct plot_font_style *fstyle, const char *string, size_t length, int x, size_t *char_offset, int *actual_x) {
*char_offset = 0;
*actual_x = 0;
NSLog(@"gnustep_layout_split");
}
static struct gui_layout_table gnustep_layout_table = {
.width = gnustep_layout_width,
.position = gnustep_layout_position,
.split = gnustep_layout_split
};
#import "AppDelegate.h"
#import "BrowserWindowController.h"
#import "tables/tables.h"
#import "tables/misc.h"
#import "netsurf/browser_window.h"
/**
* Set option defaults for (taken from the cocoa frontend)
*
* @param defaults The option table to update.
* @return error status.
* @return error status
*/
static nserror set_defaults(struct nsoption_s *defaults)
{
@ -341,6 +31,7 @@ static nserror set_defaults(struct nsoption_s *defaults)
@implementation AppDelegate
-(void)applicationDidFinishLaunching: (NSNotification*)aNotification {
NSLog(@"NSApp did finish launching..");
[NSBundle loadNibNamed: @"Menu" owner: NSApp];
@ -350,9 +41,11 @@ static nserror set_defaults(struct nsoption_s *defaults)
NSLog(@"Will create a new window");
struct nsurl *url;
nserror error;
if (nsoption_charp(homepage_url) != NULL) {
error = nsurl_create(nsoption_charp(homepage_url), &url);
} else {
NSLog(@"opening default page %s", NETSURF_HOMEPAGE);
error = nsurl_create(NETSURF_HOMEPAGE, &url);
}

View File

@ -2,14 +2,16 @@
#include <AppKit/AppKit.h>
@interface BrowserWindowController : NSWindowController<NSTextFieldDelegate>
{
id backButton;
id forwardButton;
id scrollView;
id urlBar;
struct browser_window;
@interface BrowserWindowController : NSWindowController<NSTextFieldDelegate> {
id backButton;
id forwardButton;
id scrollView;
id urlBar;
struct browser_window *browser;
}
-(id)initWithBrowser: (struct browser_window*)aBrowser;
-(id)back: (id)sender;
-(id)forward: (id)sender;
@end

View File

@ -2,10 +2,21 @@
#include <AppKit/AppKit.h>
#include "BrowserWindowController.h"
#include "PlotView.h"
@implementation BrowserWindowController
-(void)windowDidLoad {
-(id)initWithBrowser: (struct browser_window*)aBrowser {
if ((self = [super initWithWindowNibName: @"Browser"])) {
browser = aBrowser;
}
return self;
}
-(void)awakeFromNib {
PlotView *plotView = [[PlotView alloc] initWithFrame: NSMakeRect(0, 0, 1000, 1000)];
[plotView setBrowser: browser];
[[scrollView contentView] addSubview: plotView];
NSLog(@"Browser window loaded");
}

View File

@ -8,6 +8,7 @@ EXETARGET := nscocoa
SDK_FLAGS := $(gnustep-config --objc-flags)
CFLAGS := $(SDK_FLAGS) $(CFLAGS)
CFLAGS += -I/usr/local/include/gnustep
CFLAGS += -Ifrontends/gnustep
LDFLAGS := $(LDFLAGS)
CXXFLAGS := $(SDK_FLAGS) $(CXXFLAGS)
@ -40,6 +41,15 @@ S_FRONTEND := \
AppDelegate.m \
BrowserWindowController.m \
PlotView.m \
NetsurfCallback.m \
tables/misc.m \
tables/bitmap.m \
tables/clipboard.m \
tables/download.m \
tables/fetch.m \
tables/layout.m \
tables/search.m \
tables/window.m \
# This is the final source build list

View File

@ -0,0 +1,23 @@
/*
This program 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, either version 3 of the License, or
(at your option) any later version.
This program 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/>.
*/
#import <Foundation/Foundation.h>
@interface NetsurfCallback: NSObject {
void (*callback)(void *p);
void *parameter;
}
+(id)newOrScheduledWithFunctionPointer: (void (*)(void *p))aCallback parameter: (void*)p;
-(void)scheduleAfterMillis: (int)ms;
-(void)cancel;
@end

View File

@ -0,0 +1,54 @@
/*
This program 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, either version 3 of the License, or
(at your option) any later version.
This program 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/>.
*/
#import <Foundation/Foundation.h>
#import "NetsurfCallback.h"
static NSMapTable *callbackMap;
@implementation NetsurfCallback
+(void)initialize {
callbackMap = NSCreateMapTable(NSNonOwnedPointerMapKeyCallBacks,
NSObjectMapValueCallBacks, 0);
}
+(id)newOrScheduledWithFunctionPointer: (void (*)(void *p))aCallback parameter: (void*)p {
NetsurfCallback *ret;
if ((ret = NSMapGet(callbackMap, aCallback)) != NULL) {
return ret;
}
ret = [NetsurfCallback new];
ret->callback = aCallback;
ret->parameter = p;
return ret;
}
-(void)perform {
NSMapRemove(callbackMap, callback);
callback(parameter);
}
-(void)scheduleAfterMillis: (int)ms {
NSMapInsert(callbackMap, callback, self);
[NSObject cancelPreviousPerformRequestsWithTarget: self];
[self performSelector: @selector(perform) withObject: nil afterDelay: ms / 1000.0];
}
-(void)cancel {
[NSObject cancelPreviousPerformRequestsWithTarget: self];
NSMapRemove(callbackMap, callback);
}
@end

View File

@ -1,11 +1,84 @@
/**
* Large chunks from the cocoa port
*/
#import <AppKit/AppKit.h>
#import "PlotView.h"
#import "utils/errors.h"
#import "netsurf/plotters.h"
#import "netsurf/browser_window.h"
#define colour_red_component( c ) (((c) >> 0) & 0xFF)
#define colour_green_component( c ) (((c) >> 8) & 0xFF)
#define colour_blue_component( c ) (((c) >> 16) & 0xFF)
#define colour_alpha_component( c ) (((c) >> 24) & 0xFF)
#define colour_from_rgba( r, g, b, a) ((((colour)(r)) << 0) | \
(((colour)(g)) << 8) | \
(((colour)(b)) << 16) | \
(((colour)(a)) << 24))
#define colour_from_rgb( r, g, b ) colour_from_rgba( (r), (g), (b), 0xFF )
static NSRect cocoa_plot_clip_rect;
static NSColor *cocoa_convert_colour( colour clr )
{
return [NSColor colorWithDeviceRed: (float)colour_red_component( clr ) / 0xFF
green: (float)colour_green_component( clr ) / 0xFF
blue: (float)colour_blue_component( clr ) / 0xFF
alpha: 1.0];
}
static void cocoa_plot_path_set_stroke_pattern(NSBezierPath *path, const plot_style_t *pstyle)
{
static const CGFloat dashed_pattern[2] = { 5.0, 2.0 };
static const CGFloat dotted_pattern[2] = { 2.0, 2.0 };
switch (pstyle->stroke_type) {
case PLOT_OP_TYPE_DASH:
[path setLineDash: dashed_pattern count: 2 phase: 0];
break;
case PLOT_OP_TYPE_DOT:
[path setLineDash: dotted_pattern count: 2 phase: 0];
break;
default:
// ignore
break;
}
[path setLineWidth: pstyle->stroke_width > 0 ? pstyle->stroke_width : 1];
}
void cocoa_plot_render_path(NSBezierPath *path, const plot_style_t *pstyle)
{
[NSGraphicsContext saveGraphicsState];
[NSBezierPath clipRect: cocoa_plot_clip_rect];
if (pstyle->fill_type != PLOT_OP_TYPE_NONE) {
[cocoa_convert_colour( pstyle->fill_colour ) setFill];
[path fill];
}
if (pstyle->stroke_type != PLOT_OP_TYPE_NONE) {
if (pstyle->stroke_width == 0 || pstyle->stroke_width % 2 != 0)
;
//cocoa_center_pixel( true, true );
cocoa_plot_path_set_stroke_pattern(path,pstyle);
[cocoa_convert_colour( pstyle->stroke_colour ) set];
[path stroke];
}
[NSGraphicsContext restoreGraphicsState];
}
static nserror plot_clip(const struct redraw_context *ctx, const struct rect *clip) {
NSLog(@"plot_clip");
[NSBezierPath clipRect: NSMakeRect(clip->x0, clip->y0, clip->x1, clip->y1)];
return NSERROR_OK;
}
@ -26,6 +99,10 @@ static nserror plot_line(const struct redraw_context *ctx, const plot_style_t *p
static nserror plot_rectangle(const struct redraw_context *ctx, const plot_style_t *pstyle, const struct rect *rectangle) {
NSLog(@"plot_rectangle");
NSRect nsrect = NSMakeRect(rectangle->x0, rectangle->y0, rectangle->x1,
rectangle->y1);
//cocoa_plot_render_path(path, pstyle);
return NSERROR_OK;
}
@ -69,6 +146,7 @@ static const struct plotter_table gnustep_plotters = {
}
-(void)drawRect: (NSRect)rect {
NSLog(@"Drawing plotview");
struct redraw_context ctx = {
.interactive = true,
.background_images = true,

View File

@ -0,0 +1,100 @@
#import <Cocoa/Cocoa.h>
#import "netsurf/netsurf.h"
#import "netsurf/bitmap.h"
/********************/
/****** Bitmap ******/
/********************/
// Create a new bitmap of width height
static void *gnustep_bitmap_create(int width, int height, unsigned int state) {
NSLog(@"gnustep_bitmap_create");
return NULL;
}
// Destroy the specified bitmap
static void gnustep_bitmap_destroy(void *bitmap) {
NSLog(@"gnustep_bitmap_destroy");
}
// Set whether it's opaque or not
static void gnustep_bitmap_set_opaque(void *bitmap, bool opaque) {
NSLog(@"gnustep_bitmap_set_opaque");
}
// Get whether it's opaque or not
static bool gnustep_bitmap_get_opaque(void *bitmap) {
NSLog(@"gnustep_bitmap_get_opaque");
return 0;
}
// Test? whether it's opaque or not
static bool gnustep_bitmap_test_opaque(void *bitmap) {
NSLog(@"gnustep_bitmap_test_opaque");
return 0;
}
// Get the image buffer for the bitmap
static unsigned char *gnustep_bitmap_get_buffer(void *bitmap) {
NSLog(@"gnustep_bitmap_get_buffer");
return NULL;
}
// Get the number of bytes per row of the bitmap
static size_t gnustep_bitmap_get_rowstride(void *bitmap) {
NSLog(@"gnustep_bitmap_get_rowstride");
return 0;
}
// Get its width in pixels
static int gnustep_bitmap_get_width(void *bitmap) {
NSLog(@"gnustep_bitmap_get_width");
return 0;
}
// Get height in pixels
static int gnustep_bitmap_get_height(void *bitmap) {
NSLog(@"gnustep_bitmap_get_height");
return 0;
}
// Get how many byytes pet pixel
static size_t gnustep_bitmap_get_bpp(void *bitmap) {
NSLog(@"gnustep_bitmap_get_bpp");
return 0;
}
// Save the bitmap to the specified path
static bool gnustep_bitmap_save(void *bitmap, const char *path, unsigned flags) {
NSLog(@"gnustep_bitmap_save");
return 0;
}
// Mark bitmap as modified
static void gnustep_bitmap_modified(void *bitmap) {
NSLog(@"gnustep_bitmap_modified");
}
// Render content into the specified bitmap
static nserror gnustep_bitmap_render(struct bitmap *bitmap, struct hlcache_handle *content) {
NSLog(@"gnustep_bitmap_render");
return NSERROR_OK;
}
struct gui_bitmap_table gnustep_bitmap_table = {
.create = gnustep_bitmap_create,
.destroy = gnustep_bitmap_destroy,
.set_opaque = gnustep_bitmap_set_opaque,
.get_opaque = gnustep_bitmap_get_opaque,
.test_opaque = gnustep_bitmap_test_opaque,
.get_buffer = gnustep_bitmap_get_buffer,
.get_rowstride = gnustep_bitmap_get_rowstride,
.get_width = gnustep_bitmap_get_width,
.get_height = gnustep_bitmap_get_height,
.get_bpp = gnustep_bitmap_get_bpp,
.save = gnustep_bitmap_save,
.modified = gnustep_bitmap_modified,
.render = gnustep_bitmap_render
};

View File

@ -0,0 +1,23 @@
#import <Cocoa/Cocoa.h>
#import "netsurf/netsurf.h"
#import "netsurf/clipboard.h"
/***********************/
/****** Clipboard ******/
/***********************/
// Put content of clipboard into buffer up to a maximum length
static void gnustep_clipboard_get(char **buffer, size_t *length) {
NSLog(@"gnustep_clipboard_get");
}
// Save the provided clipboard for later retreival above
static void gnustep_clipboard_set(const char *buffer, size_t length, nsclipboard_styles styles[], int n_styles) {
NSLog(@"gnustep_clipboard_set");
}
struct gui_clipboard_table gnustep_clipboard_table = {
.get = gnustep_clipboard_get,
.set = gnustep_clipboard_set
};

View File

@ -0,0 +1,38 @@
#import <Cocoa/Cocoa.h>
#import "netsurf/netsurf.h"
#import "netsurf/download.h"
/**********************/
/****** Download ******/
/**********************/
// Create and display a downloads window?
static struct gui_download_window *gnustep_download_create(struct download_context *ctx, struct gui_window *parent) {
NSLog(@"gnustep_download_create");
return NULL;
}
// ??
static nserror gnustep_download_data(struct gui_download_window *dw, const char *data, unsigned int size) {
NSLog(@"gnustep_download_data");
return NSERROR_OK;
}
// Error occurred during download
static void gnustep_download_error(struct gui_download_window *dw, const char *error_msg) {
NSLog(@"gnustep_download_error");
}
// Download completed
static void gnustep_download_done(struct gui_download_window *dw) {
NSLog(@"gnustep_download_done");
}
struct gui_download_table gnustep_download_table = {
.create = gnustep_download_create,
.data = gnustep_download_data,
.error = gnustep_download_error,
.done = gnustep_download_done
};

View File

@ -0,0 +1,19 @@
#import <Cocoa/Cocoa.h>
#import "netsurf/netsurf.h"
#import "netsurf/fetch.h"
/*******************/
/****** Fetch ******/
/*******************/
// Return the MIME type of the specified file. Returned string can be inval on next req.
static const char *gnustep_fetch_filetype(const char *unix_path) {
static char filetype[100];
filetype[0] = '\0';
return filetype;
}
struct gui_fetch_table gnustep_fetch_table = {
.filetype = gnustep_fetch_filetype
};

View File

@ -0,0 +1,36 @@
#import <Cocoa/Cocoa.h>
#import "netsurf/netsurf.h"
#import "netsurf/layout.h"
/********************/
/****** Layout ******/
/********************/
// Put the measured width of the string into width
static nserror gnustep_layout_width(const struct plot_font_style *fstyle, const char *string, size_t length, int *width) {
*width = 0;
NSLog(@"gnustep_layout_width");
}
// Put the character offset and actual x coordinate of the character for which the x
// coordinate is nearest to
static nserror gnustep_layout_position(const struct plot_font_style *fstyle, const char *string, size_t length, int x, size_t *char_offset, int *actual_x) {
*char_offset = 0;
*actual_x = 0;
NSLog(@"gnustep_layout_position");
}
// Put the char offset and x coordinate of where to split a string so it fits in width x
static nserror gnustep_layout_split(const struct plot_font_style *fstyle, const char *string, size_t length, int x, size_t *char_offset, int *actual_x) {
*char_offset = 0;
*actual_x = 0;
NSLog(@"gnustep_layout_split");
}
struct gui_layout_table gnustep_layout_table = {
.width = gnustep_layout_width,
.position = gnustep_layout_position,
.split = gnustep_layout_split
};

View File

@ -0,0 +1,3 @@
#import "netsurf/misc.h"
extern struct gui_misc_table gnustep_misc_table;

View File

@ -0,0 +1,28 @@
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
#import "netsurf/netsurf.h"
#import "netsurf/misc.h"
#import "NetsurfCallback.h"
/*******************/
/****** Misc *******/
/*******************/
// Schedule a callback to be run after t ms, or removed if ngtv, func and param.
static nserror gnustep_misc_schedule(int t, void (*callback)(void *p), void *p) {
NSLog(@"gnustep_misc_schedule in %dms", t);
NetsurfCallback *nsCallback = [NetsurfCallback newOrScheduledWithFunctionPointer:
callback parameter: p];
if (t < 1) {
[nsCallback cancel];
return NSERROR_OK;
} else {
[nsCallback scheduleAfterMillis: t];
return NSERROR_OK;
}
}
struct gui_misc_table gnustep_misc_table = {
.schedule = gnustep_misc_schedule
};

View File

@ -0,0 +1,42 @@
#import <Cocoa/Cocoa.h>
#import "netsurf/netsurf.h"
#import "netsurf/search.h"
/********************/
/****** Search ******/
/********************/
// Change displayed search status found/notfound?
static void gnustep_search_status(bool found, void *p) {
NSLog(@"gnustep_search_status");
}
// Show hourglass if active else stop hourglass
static void gnustep_search_hourglass(bool active, void *p) {
NSLog(@"gnustep_search_hourglass");
}
// Add search string to recent searches list
static void gnustep_search_add_recent(const char *string, void *p) {
NSLog(@"gnustep_search_add_recent");
}
// Set the next match button to active/inactive
static void gnustep_search_forward_state(bool active, void *p) {
NSLog(@"gnustep_search_forward_state");
}
// set the previous match button to active/inactive
static void gnustep_search_back_state(bool active, void *p) {
NSLog(@"gnustep_search_back_state");
}
struct gui_search_table gnustep_search_table = {
.status = gnustep_search_status,
.hourglass = gnustep_search_hourglass,
.add_recent = gnustep_search_add_recent,
.forward_state = gnustep_search_forward_state,
.back_state = gnustep_search_back_state
};

View File

@ -0,0 +1,16 @@
#import "netsurf/window.h"
#import "netsurf/clipboard.h"
#import "netsurf/download.h"
#import "netsurf/fetch.h"
#import "netsurf/search.h"
#import "netsurf/layout.h"
#import "netsurf/bitmap.h"
extern struct gui_window_table gnustep_window_table;
extern struct gui_clipboard_table gnustep_clipboard_table;
extern struct gui_download_table gnustep_download_table;
extern struct gui_fetch_table gnustep_fetch_table;
extern struct gui_search_table gnustep_search_table;
extern struct gui_bitmap_table gnustep_bitmap_table;
extern struct gui_layout_table gnustep_layout_table;

View File

@ -0,0 +1,66 @@
#import <Cocoa/Cocoa.h>
#import "BrowserWindowController.h"
#import "netsurf/netsurf.h"
#import "netsurf/window.h"
/********************/
/****** Window ******/
/********************/
// Create and open a browser window
static struct gui_window *gnustep_window_create(struct browser_window *bw,
struct gui_window *existing,
gui_window_create_flags flags) {
NSLog(@"gnustep_window_create");
BrowserWindowController *controller = [[BrowserWindowController alloc]
initWithBrowser: bw];
[controller loadWindow];
return (struct gui_window*)controller;
}
// Destroy the specified window
static void gnustep_window_destroy(struct gui_window *gw) {
NSLog(@"gnustep_window_destroy");
}
// Trigger a redraw of the specified area, or the entire window if null
static nserror gnustep_window_invalidate(struct gui_window *gw, const struct rect *rect) {
NSLog(@"gnustep_window_invalidate");
return NSERROR_OK;
}
// Put the current scroll offset into sx and sy
static bool gnustep_window_get_scroll(struct gui_window *gw, int *sx, int *sy) {
NSLog(@"gnustep_window_get_scroll");
return true;
}
// Set the current scroll offset
static nserror gnustep_window_set_scroll(struct gui_window *gw, const struct rect *rect) {
NSLog(@"gnustep_window_set_scroll");
return NSERROR_OK;
}
// Put the dimensions of the specified window into width, height
static nserror gnustep_window_get_dimensions(struct gui_window *gw, int *width, int *height) {
NSLog(@"gnustep_window_get_dimensions");
return NSERROR_OK;
}
// Some kind of event happened
static nserror gnustep_window_event(struct gui_window *gw, enum gui_window_event event) {
NSLog(@"gnustep_window_event");
return NSERROR_OK;
}
struct gui_window_table gnustep_window_table = {
.create = gnustep_window_create,
.destroy = gnustep_window_destroy,
.invalidate = gnustep_window_invalidate,
.get_scroll = gnustep_window_get_scroll,
.set_scroll = gnustep_window_set_scroll,
.get_dimensions = gnustep_window_get_dimensions,
.event = gnustep_window_event
};

2
gnustepbuild.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/ksh
gmake TARGET=gnustep NETSURF_USE_DUKTAPE=NO NETSURF_USE_NSSVG=AUTO NETSURF_USE_ROSPRITE=AUTO