summaryrefslogtreecommitdiff
path: root/cocoa
diff options
context:
space:
mode:
Diffstat (limited to 'cocoa')
-rw-r--r--cocoa/DownloadWindowController.h2
-rw-r--r--cocoa/DownloadWindowController.m17
-rw-r--r--cocoa/NetsurfApp.m8
-rw-r--r--cocoa/gui.h4
-rw-r--r--cocoa/gui.m160
-rw-r--r--cocoa/selection.h2
-rw-r--r--cocoa/selection.m10
-rw-r--r--cocoa/utils.m13
8 files changed, 110 insertions, 106 deletions
diff --git a/cocoa/DownloadWindowController.h b/cocoa/DownloadWindowController.h
index b93c24c65..0d049da15 100644
--- a/cocoa/DownloadWindowController.h
+++ b/cocoa/DownloadWindowController.h
@@ -18,6 +18,7 @@
#import <Cocoa/Cocoa.h>
+struct gui_download_table *cocoa_gui_download_table;
@interface DownloadWindowController : NSWindowController {
struct download_context *context;
@@ -50,3 +51,4 @@
- (void) abort;
@end
+
diff --git a/cocoa/DownloadWindowController.m b/cocoa/DownloadWindowController.m
index 82be52e51..634257008 100644
--- a/cocoa/DownloadWindowController.m
+++ b/cocoa/DownloadWindowController.m
@@ -327,7 +327,7 @@ static NSString *cocoa_time_string( unsigned seconds )
#pragma mark -
#pragma mark NetSurf interface functions
-struct gui_download_window *gui_download_window_create(download_context *ctx,
+static struct gui_download_window *gui_download_window_create(download_context *ctx,
struct gui_window *parent)
{
DownloadWindowController * const window = [[DownloadWindowController alloc] initWithContext: ctx];
@@ -338,21 +338,21 @@ struct gui_download_window *gui_download_window_create(download_context *ctx,
return (struct gui_download_window *)window;
}
-nserror gui_download_window_data(struct gui_download_window *dw,
+static nserror gui_download_window_data(struct gui_download_window *dw,
const char *data, unsigned int size)
{
DownloadWindowController * const window = (DownloadWindowController *)dw;
return [window receivedData: [NSData dataWithBytes: data length: size]] ? NSERROR_OK : NSERROR_SAVE_FAILED;
}
-void gui_download_window_error(struct gui_download_window *dw,
+static void gui_download_window_error(struct gui_download_window *dw,
const char *error_msg)
{
DownloadWindowController * const window = (DownloadWindowController *)dw;
[window showError: [NSString stringWithUTF8String: error_msg]];
}
-void gui_download_window_done(struct gui_download_window *dw)
+static void gui_download_window_done(struct gui_download_window *dw)
{
DownloadWindowController * const window = (DownloadWindowController *)dw;
[window downloadDone];
@@ -376,3 +376,12 @@ static void cocoa_unregister_download( DownloadWindowController *download )
[cocoa_all_downloads removeObject: download];
}
+
+static struct gui_download_table gui_download_table = {
+ .create = gui_download_window_create,
+ .data = gui_download_window_data,
+ .error = gui_download_window_error,
+ .done = gui_download_window_done,
+};
+
+struct gui_download_table *cocoa_gui_download_table = &gui_download_table;
diff --git a/cocoa/NetsurfApp.m b/cocoa/NetsurfApp.m
index 33e3bfa43..62f684ddc 100644
--- a/cocoa/NetsurfApp.m
+++ b/cocoa/NetsurfApp.m
@@ -183,6 +183,12 @@ int main( int argc, char **argv )
{
nsurl *url;
nserror error;
+ struct gui_table cocoa_gui_table = {
+ .browser = cocoa_browser_table,
+ .window = cocoa_window_table,
+ .clipboard = cocoa_clipboard_table,
+ .download = cocoa_download_table,
+ };
cocoa_autorelease();
@@ -203,7 +209,7 @@ int main( int argc, char **argv )
nsoption_commandline(&argc, argv, NULL);
/* common initialisation */
- error = netsurf_init(messages);
+ error = netsurf_init(messages, &cocoa_gui_table);
if (error != NSERROR_OK) {
die("NetSurf failed to initialise");
}
diff --git a/cocoa/gui.h b/cocoa/gui.h
index 413727fe6..757140030 100644
--- a/cocoa/gui.h
+++ b/cocoa/gui.h
@@ -18,6 +18,10 @@
#import <Cocoa/Cocoa.h>
+extern struct gui_window_table *cocoa_window_table;
+extern struct gui_clipboard_table *cocoa_clipboard_table;
+extern struct gui_browser_table *cocoa_browser_table;
+
extern NSString * const kCookiesFileOption;
extern NSString * const kURLsFileOption;
extern NSString * const kHotlistFileOption;
diff --git a/cocoa/gui.m b/cocoa/gui.m
index 72f64bf04..a49ea9ea2 100644
--- a/cocoa/gui.m
+++ b/cocoa/gui.m
@@ -24,13 +24,13 @@
#import "cocoa/BrowserViewController.h"
#import "cocoa/BrowserWindowController.h"
#import "cocoa/FormSelectMenu.h"
+#import "cocoa/selection.h"
#import "desktop/gui.h"
#import "desktop/netsurf.h"
#import "desktop/browser_private.h"
#import "utils/nsoption.h"
#import "desktop/textinput.h"
-#import "desktop/401login.h"
#import "utils/utils.h"
#import "utils/log.h"
#import "image/ico.h"
@@ -46,7 +46,7 @@ NSString * const kAlwaysCloseMultipleTabs = @"AlwaysCloseMultipleTabs";
#define UNIMPL() NSLog( @"Function '%s' unimplemented", __func__ )
-nsurl *gui_get_resource_url(const char *path)
+static nsurl *gui_get_resource_url(const char *path)
{
nsurl *url = NULL;
NSString *nspath = [[NSBundle mainBundle] pathForResource: [NSString stringWithUTF8String: path] ofType: @""];
@@ -55,7 +55,7 @@ nsurl *gui_get_resource_url(const char *path)
return url;
}
-void gui_poll(bool active)
+static void gui_poll(bool active)
{
cocoa_autorelease();
@@ -68,15 +68,11 @@ void gui_poll(bool active)
}
}
-void gui_quit(void)
-{
- // nothing to do
-}
-
struct browser_window;
-struct gui_window *gui_create_browser_window(struct browser_window *bw,
- struct browser_window *clone, bool new_tab)
+static struct gui_window *gui_window_create(struct browser_window *bw,
+ struct browser_window *clone,
+ bool new_tab)
{
BrowserWindowController *window = nil;
@@ -98,7 +94,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
return (struct gui_window *)result;
}
-void gui_window_destroy(struct gui_window *g)
+static void gui_window_destroy(struct gui_window *g)
{
BrowserViewController *vc = (BrowserViewController *)g;
@@ -106,17 +102,17 @@ void gui_window_destroy(struct gui_window *g)
[vc release];
}
-void gui_window_set_title(struct gui_window *g, const char *title)
+static void gui_window_set_title(struct gui_window *g, const char *title)
{
[(BrowserViewController *)g setTitle: [NSString stringWithUTF8String: title]];
}
-void gui_window_redraw_window(struct gui_window *g)
+static void gui_window_redraw_window(struct gui_window *g)
{
[[(BrowserViewController *)g browserView] setNeedsDisplay: YES];
}
-void gui_window_update_box(struct gui_window *g, const struct rect *rect)
+static void gui_window_update_box(struct gui_window *g, const struct rect *rect)
{
const NSRect nsrect = cocoa_scaled_rect_wh( [(BrowserViewController *)g browser]->scale,
rect->x0, rect->y0,
@@ -124,7 +120,7 @@ void gui_window_update_box(struct gui_window *g, const struct rect *rect)
[[(BrowserViewController *)g browserView] setNeedsDisplayInRect: nsrect];
}
-bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
+static bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
{
NSCParameterAssert( g != NULL && sx != NULL && sy != NULL );
@@ -134,18 +130,12 @@ bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
return true;
}
-void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
+static void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
{
[[(BrowserViewController *)g browserView] scrollPoint: cocoa_point( sx, sy )];
}
-void gui_window_scroll_visible(struct gui_window *g, int x0, int y0,
- int x1, int y1)
-{
- gui_window_set_scroll( g, x0, y0 );
-}
-
-void gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
+static void gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
bool scaled)
{
NSCParameterAssert( width != NULL && height != NULL );
@@ -160,7 +150,7 @@ void gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
*height = cocoa_pt_to_px( NSHeight( frame ) );
}
-void gui_window_update_extent(struct gui_window *g)
+static void gui_window_update_extent(struct gui_window *g)
{
BrowserViewController * const window = (BrowserViewController *)g;
@@ -171,12 +161,12 @@ void gui_window_update_extent(struct gui_window *g)
[[window browserView] setMinimumSize: cocoa_scaled_size( browser->scale, width, height )];
}
-void gui_window_set_status(struct gui_window *g, const char *text)
+static void gui_window_set_status(struct gui_window *g, const char *text)
{
[(BrowserViewController *)g setStatus: [NSString stringWithUTF8String: text]];
}
-void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
+static void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
{
switch (shape) {
case GUI_POINTER_DEFAULT:
@@ -209,28 +199,24 @@ void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
}
}
-void gui_window_hide_pointer(struct gui_window *g)
-{
-}
-
-void gui_window_set_url(struct gui_window *g, const char *url)
+static void gui_window_set_url(struct gui_window *g, const char *url)
{
[(BrowserViewController *)g setUrl: [NSString stringWithUTF8String: url]];
}
-void gui_window_start_throbber(struct gui_window *g)
+static void gui_window_start_throbber(struct gui_window *g)
{
[(BrowserViewController *)g setIsProcessing: YES];
[(BrowserViewController *)g updateBackForward];
}
-void gui_window_stop_throbber(struct gui_window *g)
+static void gui_window_stop_throbber(struct gui_window *g)
{
[(BrowserViewController *)g setIsProcessing: NO];
[(BrowserViewController *)g updateBackForward];
}
-void gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
+static void gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
{
NSBitmapImageRep *bmp = icon != NULL ? (NSBitmapImageRep *)content_get_bitmap( icon ) : NULL;
@@ -247,56 +233,25 @@ void gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
[image release];
}
-void gui_window_set_search_ico(hlcache_handle *ico)
-{
- UNIMPL();
-}
-
-void gui_window_place_caret(struct gui_window *g, int x, int y, int height,
+static void gui_window_place_caret(struct gui_window *g, int x, int y, int height,
const struct rect *clip)
{
[[(BrowserViewController *)g browserView] addCaretAt: cocoa_point( x, y )
height: cocoa_px_to_pt( height )];
}
-void gui_window_remove_caret(struct gui_window *g)
+static void gui_window_remove_caret(struct gui_window *g)
{
[[(BrowserViewController *)g browserView] removeCaret];
}
-void gui_window_new_content(struct gui_window *g)
+static void gui_window_new_content(struct gui_window *g)
{
[(BrowserViewController *)g contentUpdated];
}
-bool gui_window_scroll_start(struct gui_window *g)
-{
- return true;
-}
-bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
- const struct rect *rect)
-{
- return true;
-}
-
-void gui_window_save_link(struct gui_window *g, const char *url,
- const char *title)
-{
- UNIMPL();
-}
-
-void gui_drag_save_object(gui_save_type type, hlcache_handle *c,
- struct gui_window *g)
-{
-}
-
-void gui_drag_save_selection(struct gui_window *g, const char *selection)
-{
-}
-
-
-void gui_create_form_select_menu(struct browser_window *bw,
+static void gui_create_form_select_menu(struct browser_window *bw,
struct form_control *control)
{
FormSelectMenu *menu = [[FormSelectMenu alloc] initWithControl: control forWindow: bw];
@@ -304,31 +259,78 @@ void gui_create_form_select_menu(struct browser_window *bw,
[menu release];
}
-void gui_launch_url(const char *url)
+static void gui_launch_url(const char *url)
{
[[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString: [NSString stringWithUTF8String: url]]];
}
struct ssl_cert_info;
-void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs,
+static void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs,
unsigned long num, nserror (*cb)(bool proceed, void *pw),
void *cbpw)
{
cb( false, cbpw );
}
-
-void gui_401login_open(nsurl *url, const char *realm,
- nserror (*cb)(bool proceed, void *pw), void *cbpw)
+static char *filename_from_path(char *path)
{
- cb( false, cbpw );
+ return strdup( [[[NSString stringWithUTF8String: path] lastPathComponent] UTF8String] );
}
-void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl,
- struct form_control *gadget)
+static bool path_add_part(char *path, int length, const char *newpart)
{
- LOG(("File open dialog rquest for %p/%p", g, gadget));
- /* browser_window_set_gadget_filename(bw, gadget, "filename"); */
+ NSString *newPath = [[NSString stringWithUTF8String: path] stringByAppendingPathComponent: [NSString stringWithUTF8String: newpart]];
+
+ strncpy( path, [newPath UTF8String], length );
+
+ return true;
}
+
+static struct gui_window_table window_table = {
+ .create = gui_window_create,
+ .destroy = gui_window_destroy,
+ .redraw = gui_window_redraw_window,
+ .update = gui_window_update_box,
+ .get_scroll = gui_window_get_scroll,
+ .set_scroll = gui_window_set_scroll,
+ .get_dimensions = gui_window_get_dimensions,
+ .update_extent = gui_window_update_extent,
+
+ .set_title = gui_window_set_title,
+ .set_url = gui_window_set_url,
+ .set_icon = gui_window_set_icon,
+ .set_status = gui_window_set_status,
+ .set_pointer = gui_window_set_pointer,
+ .place_caret = gui_window_place_caret,
+ .remove_caret = gui_window_remove_caret,
+ .new_content = gui_window_new_content,
+ .start_throbber = gui_window_start_throbber,
+ .stop_throbber = gui_window_stop_throbber,
+};
+
+struct gui_window_table *cocoa_window_table = &window_table;
+
+
+static struct gui_clipboard_table clipboard_table = {
+ .get_clipboard = gui_get_clipboard,
+ .set_clipboard = gui_set_clipboard,
+};
+
+struct gui_clipboard_table *cocoa_clipboard_table = &clipboard_table;
+
+
+static struct gui_browser_table browser_table = {
+ .poll = gui_poll,
+ .get_resource_url = gui_get_resource_url,
+ .launch_url = gui_launch_url,
+ .create_form_select_menu = gui_create_form_select_menu,
+ .cert_verify = gui_cert_verify,
+ .filename_from_path = filename_from_path,
+ .path_add_part = path_add_part,
+};
+
+struct gui_browser_table *cocoa_browser_table = &browser_table;
+
+
diff --git a/cocoa/selection.h b/cocoa/selection.h
new file mode 100644
index 000000000..14b6e763f
--- /dev/null
+++ b/cocoa/selection.h
@@ -0,0 +1,2 @@
+void gui_get_clipboard(char **buffer, size_t *length);
+void gui_set_clipboard(const char *buffer, size_t length, nsclipboard_styles styles[], int n_styles);
diff --git a/cocoa/selection.m b/cocoa/selection.m
index 237c61ce2..e95a78441 100644
--- a/cocoa/selection.m
+++ b/cocoa/selection.m
@@ -19,21 +19,13 @@
#import <Cocoa/Cocoa.h>
#import "cocoa/BrowserViewController.h"
+#import "cocoa/selection.h"
#import "desktop/browser_private.h"
static NSMutableString *cocoa_clipboard_string;
-void gui_start_selection(struct gui_window *g)
-{
-}
-
-void gui_clear_selection(struct gui_window *g)
-{
-}
-
-
/**
* Core asks front end for clipboard contents.
*
diff --git a/cocoa/utils.m b/cocoa/utils.m
index cd9313d34..61226ad2a 100644
--- a/cocoa/utils.m
+++ b/cocoa/utils.m
@@ -41,16 +41,3 @@ void PDF_Password(char **owner_pass, char **user_pass, char *path)
UNIMPL();
}
-char *filename_from_path(char *path)
-{
- return strdup( [[[NSString stringWithUTF8String: path] lastPathComponent] UTF8String] );
-}
-
-bool path_add_part(char *path, int length, const char *newpart)
-{
- NSString *newPath = [[NSString stringWithUTF8String: path] stringByAppendingPathComponent: [NSString stringWithUTF8String: newpart]];
-
- strncpy( path, [newPath UTF8String], length );
-
- return true;
-}