summaryrefslogtreecommitdiff
path: root/cocoa
diff options
context:
space:
mode:
authorOle Loots <ole@monochrom.net>2014-09-12 23:22:26 +0200
committerOle Loots <ole@monochrom.net>2014-09-12 23:22:26 +0200
commita9ac9c00fc2c73705db242a459160f14d279cdcd (patch)
tree5f9aa630340bad67934e6fdbfda7f239f0fade57 /cocoa
parent181bc41a9aa200cfac5bf4b84175003639fce488 (diff)
parent9e6b0fb8b07cd3147b0a2727d3644860cf7c8c7e (diff)
downloadnetsurf-a9ac9c00fc2c73705db242a459160f14d279cdcd.tar.gz
netsurf-a9ac9c00fc2c73705db242a459160f14d279cdcd.tar.bz2
Merge branch 'master' of git://git.netsurf-browser.org/netsurf
Conflicts: atari/gui.h
Diffstat (limited to 'cocoa')
-rw-r--r--cocoa/BookmarksController.m8
-rw-r--r--cocoa/BrowserView.m47
-rw-r--r--cocoa/BrowserViewController.m44
-rw-r--r--cocoa/BrowserWindowController.m7
-rw-r--r--cocoa/DownloadWindowController.h2
-rw-r--r--cocoa/DownloadWindowController.m19
-rw-r--r--cocoa/FormSelectMenu.m4
-rw-r--r--cocoa/HistoryView.m17
-rw-r--r--cocoa/Makefile.defaults65
-rw-r--r--cocoa/Makefile.target77
-rw-r--r--cocoa/NetSurfAppDelegate.m14
-rw-r--r--cocoa/NetsurfApp.m25
-rw-r--r--cocoa/PreferencesWindowController.m1
-rw-r--r--cocoa/SearchWindowController.h2
-rw-r--r--cocoa/SearchWindowController.m10
-rw-r--r--cocoa/apple_image.m11
-rw-r--r--cocoa/fetch.h (renamed from cocoa/url.m)17
-rw-r--r--cocoa/fetch.m34
-rw-r--r--cocoa/gui.h4
-rw-r--r--cocoa/gui.m169
-rw-r--r--cocoa/schedule.h (renamed from cocoa/utf8.m)24
-rw-r--r--cocoa/schedule.m22
-rw-r--r--cocoa/selection.h19
-rw-r--r--cocoa/selection.m21
-rw-r--r--cocoa/utils.m13
25 files changed, 320 insertions, 356 deletions
diff --git a/cocoa/BookmarksController.m b/cocoa/BookmarksController.m
index 2f8d9d839..64c2ef37a 100644
--- a/cocoa/BookmarksController.m
+++ b/cocoa/BookmarksController.m
@@ -27,6 +27,8 @@
#import "desktop/hotlist.h"
#import "desktop/tree.h"
#import "utils/messages.h"
+#import "utils/utils.h"
+#import "content/hlcache.h"
@interface BookmarksController ()
- (void) noteAppWillTerminate: (NSNotification *) note;
@@ -140,14 +142,12 @@ static const char *cocoa_hotlist_path( void )
error = browser_window_navigate([tab browser],
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
} else {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
diff --git a/cocoa/BrowserView.m b/cocoa/BrowserView.m
index ca5808c90..2a3382c8c 100644
--- a/cocoa/BrowserView.m
+++ b/cocoa/BrowserView.m
@@ -24,11 +24,11 @@
#import "cocoa/BrowserWindowController.h"
#import "desktop/browser_private.h"
-#import "desktop/local_history.h"
#import "desktop/plotters.h"
#import "desktop/textinput.h"
#import "utils/nsoption.h"
#import "utils/messages.h"
+#import "content/hlcache.h"
@interface BrowserView ()
@@ -38,7 +38,6 @@
- (void) scrollVertical: (CGFloat) amount;
- (CGFloat) pageScroll;
-+ (void)reformatTimerFired: (NSTimer *) timer;
- (void) reformat;
- (void) popUpContextMenuForEvent: (NSEvent *) event;
@@ -60,8 +59,6 @@
static const CGFloat CaretWidth = 1.0;
static const NSTimeInterval CaretBlinkTime = 0.8;
-static NSMutableArray *cocoa_reformat_pending = nil;
-
- initWithFrame: (NSRect) frame;
{
@@ -438,13 +435,7 @@ static browser_mouse_state cocoa_mouse_flags_for_event( NSEvent *evt )
- (void) adjustFrame;
{
- browser->reformat_pending = true;
- browser_reformat_pending = true;
-
- if (cocoa_reformat_pending == nil) {
- cocoa_reformat_pending = [[NSMutableArray alloc] init];
- }
- [cocoa_reformat_pending addObject: self];
+ browser_window_schedule_reformat(browser);
[super adjustFrame];
}
@@ -492,24 +483,6 @@ static browser_mouse_state cocoa_mouse_flags_for_event( NSEvent *evt )
browser_window_reformat( browser, false, cocoa_pt_to_px( NSWidth( size ) ), cocoa_pt_to_px( NSHeight( size ) ) );
}
-+ (void)reformatTimerFired: (NSTimer *) timer;
-{
- if (browser_reformat_pending) {
- [cocoa_reformat_pending makeObjectsPerformSelector: @selector( reformat )];
- [cocoa_reformat_pending removeAllObjects];
- browser_reformat_pending = false;
- }
-}
-
-+ (void) initialize;
-{
- NSTimer *timer = [[NSTimer alloc] initWithFireDate: nil interval: 0.02
- target: self selector: @selector(reformatTimerFired:)
- userInfo: nil repeats: YES];
- [[NSRunLoop currentRunLoop] addTimer: timer forMode: NSRunLoopCommonModes];
- [timer release];
-}
-
- (void) popUpContextMenuForEvent: (NSEvent *) event;
{
if (content_get_type( browser->current_content ) != CONTENT_HTML) return;
@@ -580,9 +553,9 @@ static browser_mouse_state cocoa_mouse_flags_for_event( NSEvent *evt )
error = nsurl_create([[sender representedObject] UTF8String], &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_TAB,
+ error = browser_window_create(BW_CREATE_HISTORY |
+ BW_CREATE_TAB |
+ BW_CREATE_CLONE,
url,
NULL,
browser,
@@ -601,8 +574,8 @@ static browser_mouse_state cocoa_mouse_flags_for_event( NSEvent *evt )
error = nsurl_create([[sender representedObject] UTF8String], &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY |
+ BW_CREATE_CLONE,
url,
NULL,
browser,
@@ -622,8 +595,7 @@ static browser_mouse_state cocoa_mouse_flags_for_event( NSEvent *evt )
browser_window_navigate(browser,
url,
NULL,
- BROWSER_WINDOW_DOWNLOAD |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_DOWNLOAD,
NULL,
NULL,
NULL);
@@ -687,8 +659,7 @@ static browser_mouse_state cocoa_mouse_flags_for_event( NSEvent *evt )
browser_window_navigate(browser,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_DOWNLOAD,
NULL,
NULL,
NULL);
diff --git a/cocoa/BrowserViewController.m b/cocoa/BrowserViewController.m
index 77ee57bd1..f1b25d9d0 100644
--- a/cocoa/BrowserViewController.m
+++ b/cocoa/BrowserViewController.m
@@ -19,16 +19,19 @@
#import "cocoa/BrowserViewController.h"
#import "cocoa/BrowserView.h"
#import "cocoa/BrowserWindowController.h"
+#import "cocoa/fetch.h"
+#import "desktop/browser_history.h"
#import "desktop/browser_private.h"
-#import "desktop/local_history.h"
#import "desktop/textinput.h"
#import "utils/nsoption.h"
#import "utils/corestrings.h"
#import "utils/filename.h"
+#import "utils/file.h"
#import "utils/messages.h"
#import "utils/url.h"
+#import "content/hlcache.h"
@implementation BrowserViewController
@@ -77,8 +80,7 @@
browser_window_navigate(browser,
urlns,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -115,16 +117,16 @@
- (IBAction) goBack: (id) sender;
{
- if (browser && history_back_available( browser->history )) {
- history_back(browser, browser->history);
+ if (browser && browser_window_history_back_available( browser )) {
+ browser_window_history_back(browser, false);
[self updateBackForward];
}
}
- (IBAction) goForward: (id) sender;
{
- if (browser && history_forward_available( browser->history )) {
- history_forward(browser, browser->history);
+ if (browser && browser_window_history_forward_available( browser )) {
+ browser_window_history_forward(browser, false);
[self updateBackForward];
}
}
@@ -139,8 +141,7 @@
error = browser_window_navigate(browser,
urlns,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -166,7 +167,7 @@
struct hlcache_handle *content;
size_t size;
const char *source;
- const char *path = NULL;
+ char *path = NULL;
if (browser == NULL)
return;
@@ -178,14 +179,7 @@
return;
/* try to load local files directly. */
- lwc_string *scheme = nsurl_get_component(hlcache_handle_get_url(content), NSURL_SCHEME);
- if (scheme == NULL)
- return;
-
- bool match;
- if (lwc_string_isequal(scheme, corestring_lwc_file, &match) == lwc_error_ok && match == true)
- path = url_to_path(nsurl_access(hlcache_handle_get_url(content)));
- lwc_string_unref(scheme);
+ netsurf_nsurl_to_path(hlcache_handle_get_url(content), &path);
if (path == NULL) {
/* We cannot release the requested filename until after it
@@ -272,8 +266,8 @@ static inline bool compare_float( float a, float b )
- (void) updateBackForward;
{
[browserView updateHistory];
- [self setCanGoBack: browser != NULL && history_back_available( browser->history )];
- [self setCanGoForward: browser != NULL && history_forward_available( browser->history )];
+ [self setCanGoBack: browser != NULL && browser_window_history_back_available( browser )];
+ [self setCanGoForward: browser != NULL && browser_window_history_forward_available( browser )];
}
- (void) contentUpdated;
@@ -287,7 +281,7 @@ struct history_add_menu_item_data {
id target;
};
-static bool history_add_menu_item_cb( const struct history *history, int x0, int y0, int x1, int y1,
+static bool history_add_menu_item_cb( const struct browser_window *bw, int x0, int y0, int x1, int y1,
const struct history_entry *page, void *user_data )
{
struct history_add_menu_item_data *data = user_data;
@@ -305,7 +299,7 @@ static bool history_add_menu_item_cb( const struct history *history, int x0, int
++data->index;
[item setTarget: data->target];
- [item setTitle: [NSString stringWithUTF8String: history_entry_get_title( page )]];
+ [item setTitle: [NSString stringWithUTF8String: browser_window_history_entry_get_title( page )]];
[item setRepresentedObject: [NSValue valueWithPointer: page]];
return true;
@@ -314,7 +308,7 @@ static bool history_add_menu_item_cb( const struct history *history, int x0, int
- (IBAction) historyItemSelected: (id) sender;
{
struct history_entry *entry = [[sender representedObject] pointerValue];
- history_go( browser, browser->history, entry, false );
+ browser_window_history_go( browser, entry, false );
[self updateBackForward];
}
@@ -325,7 +319,7 @@ static bool history_add_menu_item_cb( const struct history *history, int x0, int
.menu = menu,
.target = self
};
- history_enumerate_back( browser->history, history_add_menu_item_cb, &data );
+ browser_window_history_enumerate_back( browser, history_add_menu_item_cb, &data );
while (data.index < [menu numberOfItems]) [menu removeItemAtIndex: data.index];
}
@@ -336,7 +330,7 @@ static bool history_add_menu_item_cb( const struct history *history, int x0, int
.menu = menu,
.target = self
};
- history_enumerate_forward( browser->history, history_add_menu_item_cb, &data );
+ browser_window_history_enumerate_forward( browser, history_add_menu_item_cb, &data );
while (data.index < [menu numberOfItems]) [menu removeItemAtIndex: data.index];
}
diff --git a/cocoa/BrowserWindowController.m b/cocoa/BrowserWindowController.m
index 2edb9a1db..cfc45cd7c 100644
--- a/cocoa/BrowserWindowController.m
+++ b/cocoa/BrowserWindowController.m
@@ -28,6 +28,8 @@
#import "desktop/browser.h"
#import "utils/nsoption.h"
#import "utils/messages.h"
+#import "utils/utils.h"
+#import "utils/nsurl.h"
@interface BrowserWindowController ()
@@ -160,9 +162,8 @@
error = nsurl_create(NETSURF_HOMEPAGE, &url);
}
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_TAB,
+ error = browser_window_create(BW_CREATE_HISTORY |
+ BW_CREATE_TAB,
url,
NULL,
[activeBrowser browser],
diff --git a/cocoa/DownloadWindowController.h b/cocoa/DownloadWindowController.h
index b93c24c65..798ebd1b6 100644
--- a/cocoa/DownloadWindowController.h
+++ b/cocoa/DownloadWindowController.h
@@ -18,6 +18,7 @@
#import <Cocoa/Cocoa.h>
+struct gui_download_table *cocoa_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..e7b78a4ec 100644
--- a/cocoa/DownloadWindowController.m
+++ b/cocoa/DownloadWindowController.m
@@ -53,7 +53,7 @@ static void cocoa_register_download( DownloadWindowController *download );
context = ctx;
totalSize = download_context_get_total_length( context );
- [self setURL: [NSURL URLWithString: [NSString stringWithUTF8String: download_context_get_url( context )]]];
+ [self setURL: [NSURL URLWithString: [NSString stringWithUTF8String: nsurl_access(download_context_get_url( context ))]]];
[self setMIMEType: [NSString stringWithUTF8String: download_context_get_mime_type( context )]];
[self setStartDate: [NSDate date]];
@@ -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 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_download_table = &download_table;
diff --git a/cocoa/FormSelectMenu.m b/cocoa/FormSelectMenu.m
index 3aaeae524..d1548b244 100644
--- a/cocoa/FormSelectMenu.m
+++ b/cocoa/FormSelectMenu.m
@@ -19,7 +19,7 @@
#import "cocoa/FormSelectMenu.h"
#import "cocoa/coordinates.h"
-#import "desktop/browser_private.h"
+#import "desktop/browser.h"
#import "render/form.h"
@interface FormSelectMenu ()
@@ -87,7 +87,7 @@
- (void) itemSelected: (id) sender;
{
- form_select_process_selection( browser->current_content, control, [sender tag] );
+ form_select_process_selection( control, [sender tag] );
}
- (void) menuDidClose: (NSMenu *) sender;
diff --git a/cocoa/HistoryView.m b/cocoa/HistoryView.m
index 45f7facbf..7b192336e 100644
--- a/cocoa/HistoryView.m
+++ b/cocoa/HistoryView.m
@@ -23,8 +23,7 @@
#import "cocoa/LocalHistoryController.h"
#import "cocoa/BrowserView.h"
-#import "desktop/browser_private.h"
-#import "desktop/local_history.h"
+#import "desktop/browser_history.h"
#import "desktop/plotters.h"
@implementation HistoryView
@@ -41,7 +40,7 @@
- (NSSize) size;
{
int width, height;
- history_size( browser->history, &width, &height );
+ browser_window_history_size( browser, &width, &height );
return cocoa_size( width, height );
}
@@ -65,14 +64,14 @@
cocoa_set_clip( rect );
- history_redraw( browser->history, &ctx );
+ browser_window_history_redraw( browser, &ctx );
}
- (void) mouseUp: (NSEvent *)theEvent;
{
const NSPoint location = [self convertPoint: [theEvent locationInWindow] fromView: nil];
const bool newWindow = [theEvent modifierFlags] & NSCommandKeyMask;
- if (history_click( browser, browser->history,
+ if (browser_window_history_click( browser,
cocoa_pt_to_px( location.x ), cocoa_pt_to_px( location.y ),
newWindow )) {
[browserView setHistoryVisible: NO];
@@ -94,7 +93,7 @@
[[NSCursor arrowCursor] set];
}
-static bool cursor_rects_cb( const struct history *history, int x0, int y0, int x1, int y1,
+static bool cursor_rects_cb( const struct browser_window *bw, int x0, int y0, int x1, int y1,
const struct history_entry *page, void *user_data )
{
HistoryView *view = user_data;
@@ -102,8 +101,8 @@ static bool cursor_rects_cb( const struct history *history, int x0, int y0, int
NSRect rect = NSIntersectionRect( [view visibleRect], cocoa_rect( x0, y0, x1, y1 ) );
if (!NSIsEmptyRect( rect )) {
- NSString *toolTip = [NSString stringWithFormat: @"%s\n%s", history_entry_get_title(page),
- history_entry_get_url( page )];
+ NSString *toolTip = [NSString stringWithFormat: @"%s\n%s", browser_window_history_entry_get_title(page),
+ browser_window_history_entry_get_url( page )];
[view addToolTipRect: rect owner: toolTip userData: nil];
NSTrackingArea *area = [[NSTrackingArea alloc] initWithRect: rect
@@ -138,7 +137,7 @@ static bool cursor_rects_cb( const struct history *history, int x0, int y0, int
[self removeTrackingArea: area];
}
- history_enumerate( browser->history, cursor_rects_cb, self );
+ browser_window_history_enumerate( browser, cursor_rects_cb, self );
[super updateTrackingAreas];
}
diff --git a/cocoa/Makefile.defaults b/cocoa/Makefile.defaults
index b2f64ec56..501d17585 100644
--- a/cocoa/Makefile.defaults
+++ b/cocoa/Makefile.defaults
@@ -2,36 +2,35 @@
# Cocoa-specific options
# ----------------------------------------------------------------------------
- # Force using glibc internal iconv implementation instead of external libiconv
- # Valid options: YES, NO
- NETSURF_USE_LIBICONV_PLUG := NO
-
- # Enable NetSurf's use of librosprite for displaying RISC OS Sprites
- # Valid options: YES, NO, AUTO
- NETSURF_USE_ROSPRITE := NO
-
- # Enable NetSurf's use of libwebp for displaying WebPs
- # Valid options: YES, NO
- NETSURF_USE_WEBP := NO
-
- # Enable NetSurf's use of librsvg in conjunction with Cairo to display SVGs
- # Valid options: YES, NO, AUTO
- NETSURF_USE_RSVG := AUTO
-
- # Enable NetSurf's use of libsvgtiny for displaying SVGs
- # Valid options: YES, NO, AUTO
- NETSURF_USE_NSSVG := AUTO
-
- NETSURF_USE_MNG := NO
- NETSURF_USE_BMP := NO
- NETSURF_USE_GIF := NO
- NETSURF_USE_PNG := NO
- NETSURF_USE_JPEG := NO
- NETSURF_USE_IMAGEIO := YES
-
- DEVELOPER_PATH := /Developer
- MACOSX_VERSION := 10.5
- SDK_VERSION := $(MACOSX_VERSION)
-
- # Optimisation levels
- CFLAGS += -O2
+# Force using glibc internal iconv implementation instead of external libiconv
+# Valid options: YES, NO
+NETSURF_USE_LIBICONV_PLUG := NO
+
+# Enable NetSurf's use of librosprite for displaying RISC OS Sprites
+# Valid options: YES, NO, AUTO
+NETSURF_USE_ROSPRITE := NO
+
+# Enable NetSurf's use of libwebp for displaying WebPs
+# Valid options: YES, NO
+NETSURF_USE_WEBP := NO
+
+# Enable NetSurf's use of librsvg in conjunction with Cairo to display SVGs
+# Valid options: YES, NO, AUTO
+NETSURF_USE_RSVG := AUTO
+
+# Enable NetSurf's use of libsvgtiny for displaying SVGs
+# Valid options: YES, NO, AUTO
+NETSURF_USE_NSSVG := AUTO
+
+NETSURF_USE_BMP := NO
+NETSURF_USE_GIF := NO
+NETSURF_USE_PNG := NO
+NETSURF_USE_JPEG := NO
+NETSURF_USE_IMAGEIO := YES
+
+DEVELOPER_PATH := /Developer
+MACOSX_VERSION := 10.5
+SDK_VERSION := $(MACOSX_VERSION)
+
+# Optimisation levels
+CFLAGS += -O2
diff --git a/cocoa/Makefile.target b/cocoa/Makefile.target
index 8bd13c29b..d5b983a98 100644
--- a/cocoa/Makefile.target
+++ b/cocoa/Makefile.target
@@ -2,67 +2,65 @@
# Mac OS X target setup
# ----------------------------------------------------------------------------
- POSTEXES += NetSurf.app
+POSTEXES += NetSurf.app
- LDFLAGS += -L/usr/lib
- LDFLAGS += $(shell $(PKG_CONFIG) --libs libhubbub libcss libdom)
- LDFLAGS += -L/usr/X11/lib
- LDFLAGS += -lm -lcurl -liconv
- LDFLAGS += -lssl -lcrypto
+LDFLAGS += -L/usr/lib
+LDFLAGS += $(shell $(PKG_CONFIG) --libs libhubbub libcss libdom)
+LDFLAGS += -L/usr/X11/lib
+LDFLAGS += -lm -lcurl
+LDFLAGS += -lssl -lcrypto
- CFLAGS += -O $(WARNFLAGS) -Dnscocoa \
- -D_BSD_SOURCE -D_POSIX_C_SOURCE \
- -std=c99 -g -Os
+CFLAGS += -Dnscocoa -D_BSD_SOURCE -D_POSIX_C_SOURCE -std=c99 -g -Os
- CFLAGS += $(shell $(PKG_CONFIG) --cflags libhubbub libcss libdom)
+CFLAGS += $(shell $(PKG_CONFIG) --cflags libhubbub libcss libdom)
- # shut up zconf.h and zlib.h
- #CFLAGS += -D_LARGEFILE64_SOURCE=1
+# shut up zconf.h and zlib.h
+#CFLAGS += -D_LARGEFILE64_SOURCE=1
ifneq ($(WITH_MACPORTS),)
LDFLAGS += -L/opt/local/lib
CFLAGS += -I/opt/local/include
endif
- # for timerisset()
- CFLAGS += -D_DARWIN_C_SOURCE
+# for timerisset()
+CFLAGS += -D_DARWIN_C_SOURCE
- MACOSX_VERSION ?= 10.5
- SDK_VERSION ?= $(MACOSX_VERSION)
- SDK_PATH ?= $(DEVELOPER_PATH)/SDKs/MacOSX$(SDK_VERSION).sdk
- SDK_FLAGS := -isysroot $(SDK_PATH) -mmacosx-version-min=$(MACOSX_VERSION)
- CFLAGS := $(SDK_FLAGS) $(CFLAGS)
- LDFLAGS := $(SDK_FLAGS) -Wl,-syslibroot,$(SDK_PATH) $(LDFLAGS)
- CXXFLAGS := $(SDK_FLAGS) $(CXXFLAGS)
+MACOSX_VERSION ?= 10.5
+SDK_VERSION ?= $(MACOSX_VERSION)
+SDK_PATH ?= $(DEVELOPER_PATH)/SDKs/MacOSX$(SDK_VERSION).sdk
+SDK_FLAGS := -isysroot $(SDK_PATH) -mmacosx-version-min=$(MACOSX_VERSION)
+CFLAGS := $(SDK_FLAGS) $(CFLAGS)
+LDFLAGS := $(SDK_FLAGS) -Wl,-syslibroot,$(SDK_PATH) $(LDFLAGS)
+CXXFLAGS := $(SDK_FLAGS) $(CXXFLAGS)
- CFLAGS += -I/usr/X11/include
- CFLAGS += -include cocoa/Prefix.pch
+CFLAGS += -I/usr/X11/include
+CFLAGS += -include cocoa/Prefix.pch
# VERSION_FULL := $(shell sed -n '/\"/{s/.*"\(.*\)\".*/\1/;p;}' desktop/version.c)
# TODO: this needs fixing properly everywhere
- VERSION_FULL := "3.0 (Dev)"
- VERSION_MAJ := $(shell sed -n '/_major/{s/.* = \([0-9]*\).*/\1/;p;}' desktop/version.c)
- VERSION_MIN := $(shell sed -n '/_minor/{s/.* = \([0-9]*\).*/\1/;p;}' desktop/version.c)
+VERSION_FULL := "3.0 (Dev)"
+VERSION_MAJ := $(shell sed -n '/_major/{s/.* = \([0-9]*\).*/\1/;p;}' desktop/version.c)
+VERSION_MIN := $(shell sed -n '/_minor/{s/.* = \([0-9]*\).*/\1/;p;}' desktop/version.c)
- LDFLAGS += -Wl,-framework,Cocoa -Wl,-framework,Carbon $(NETLDFLAGS)
+LDFLAGS += -Wl,-framework,Cocoa -Wl,-framework,Carbon $(NETLDFLAGS)
- NETSURF_FEATURE_BMP_CFLAGS := -DWITH_BMP
- NETSURF_FEATURE_GIF_CFLAGS := -DWITH_GIF
- NETSURF_FEATURE_PNG_CFLAGS := -DWITH_PNG
- NETSURF_FEATURE_NSSVG_CFLAGS := -DWITH_NS_SVG
+NETSURF_FEATURE_BMP_CFLAGS := -DWITH_BMP
+NETSURF_FEATURE_GIF_CFLAGS := -DWITH_GIF
+NETSURF_FEATURE_PNG_CFLAGS := -DWITH_PNG
+NETSURF_FEATURE_NSSVG_CFLAGS := -DWITH_NS_SVG
- $(eval $(call pkg_config_find_and_add_enabled,BMP,libnsbmp,BMP))
- $(eval $(call pkg_config_find_and_add_enabled,GIF,libnsgif,GIF))
- $(eval $(call pkg_config_find_and_add_enabled,PNG,libpng,PNG))
- $(eval $(call pkg_config_find_and_add_enabled,NSSVG,libsvgtiny,SVG))
- $(eval $(call feature_enabled,IMAGEIO,-DWITH_APPLE_IMAGE,,Apple ImageIO ))
+$(eval $(call pkg_config_find_and_add_enabled,BMP,libnsbmp,BMP))
+$(eval $(call pkg_config_find_and_add_enabled,GIF,libnsgif,GIF))
+$(eval $(call pkg_config_find_and_add_enabled,PNG,libpng,PNG))
+$(eval $(call pkg_config_find_and_add_enabled,NSSVG,libsvgtiny,SVG))
+$(eval $(call feature_enabled,IMAGEIO,-DWITH_APPLE_IMAGE,,Apple ImageIO ))
- ifneq ($(UNIVERSAL),)
+ifneq ($(UNIVERSAL),)
UNIVERSAL_FLAGS := $(foreach arch,$(UNIVERSAL),-arch $(arch) )
CFLAGS += $(UNIVERSAL_FLAGS)
LDFLAGS += $(UNIVERSAL_FLAGS)
CXXFLAGS += $(UNIVERSAL_FLAGS)
- endif
+endif
# ----------------------------------------------------------------------------
# Source file setup
@@ -95,8 +93,6 @@ S_COCOA := \
schedule.m \
selection.m \
thumbnail.m \
- url.m \
- utf8.m \
utils.m \
ArrowBox.m \
ArrowWindow.m \
@@ -242,4 +238,3 @@ clean-package-cocoa:
$(Q)$(RM) NetSurf.dmg
$(VQ)echo " CLEAN: NetSurf.app"
$(Q)$(RM) -r NetSurf.app
-
diff --git a/cocoa/NetSurfAppDelegate.m b/cocoa/NetSurfAppDelegate.m
index 4a66212e8..34605a95c 100644
--- a/cocoa/NetSurfAppDelegate.m
+++ b/cocoa/NetSurfAppDelegate.m
@@ -24,6 +24,8 @@
#import "desktop/browser.h"
#import "utils/nsoption.h"
#import "utils/messages.h"
+#import "utils/utils.h"
+#import "utils/nsurl.h"
@interface NetSurfAppDelegate ()
@@ -50,8 +52,7 @@
}
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -74,8 +75,7 @@
for (NSURL *url in [openPanel URLs]) {
error = nsurl_create([[url absoluteString] UTF8String], &u);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
u,
NULL,
NULL,
@@ -97,8 +97,7 @@
error = nsurl_create([urlAsString UTF8String], &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -181,8 +180,7 @@
error = nsurl_create([[urltxt absoluteString] UTF8String], &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
diff --git a/cocoa/NetsurfApp.m b/cocoa/NetsurfApp.m
index 33e3bfa43..f9cc98885 100644
--- a/cocoa/NetsurfApp.m
+++ b/cocoa/NetsurfApp.m
@@ -20,13 +20,15 @@
#import "cocoa/NetsurfApp.h"
#import "cocoa/gui.h"
#import "cocoa/plotter.h"
+#import "cocoa/DownloadWindowController.h"
+#import "cocoa/SearchWindowController.h"
+#import "cocoa/selection.h"
+#import "cocoa/fetch.h"
#import "desktop/gui.h"
#import "content/urldb.h"
-#import "content/fetch.h"
#import "css/utils.h"
#import "desktop/gui.h"
-#import "desktop/local_history.h"
#import "desktop/mouse.h"
#import "desktop/netsurf.h"
#import "utils/nsoption.h"
@@ -35,7 +37,6 @@
#import "desktop/textinput.h"
#import "desktop/tree.h"
#import "render/html.h"
-#import "utils/url.h"
#import "utils/filename.h"
#import "utils/log.h"
#import "utils/messages.h"
@@ -183,8 +184,21 @@ int main( int argc, char **argv )
{
nsurl *url;
nserror error;
+ struct netsurf_table cocoa_table = {
+ .browser = cocoa_browser_table,
+ .window = cocoa_window_table,
+ .clipboard = cocoa_clipboard_table,
+ .download = cocoa_download_table,
+ .fetch = cocoa_fetch_table,
+ .search = cocoa_search_table,
+ };
cocoa_autorelease();
+
+ error = netsurf_register(&cocoa_table);
+ if (error != NSERROR_OK) {
+ die("NetSurf operation table failed registration");
+ }
const char * const messages = [[[NSBundle mainBundle] pathForResource: @"Messages" ofType: @""] UTF8String];
const char * const options = cocoa_get_options_file();
@@ -203,7 +217,7 @@ int main( int argc, char **argv )
nsoption_commandline(&argc, argv, NULL);
/* common initialisation */
- error = netsurf_init(messages);
+ error = netsurf_init(messages, NULL);
if (error != NSERROR_OK) {
die("NetSurf failed to initialise");
}
@@ -222,8 +236,7 @@ int main( int argc, char **argv )
error = nsurl_create(argv[i], &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
diff --git a/cocoa/PreferencesWindowController.m b/cocoa/PreferencesWindowController.m
index a3abe2908..54e7b91d0 100644
--- a/cocoa/PreferencesWindowController.m
+++ b/cocoa/PreferencesWindowController.m
@@ -25,6 +25,7 @@
#import "desktop/browser_private.h"
#import "content/content.h"
#import "utils/nsoption.h"
+#import "content/hlcache.h"
@implementation PreferencesWindowController
diff --git a/cocoa/SearchWindowController.h b/cocoa/SearchWindowController.h
index a1aac2e3f..896983b30 100644
--- a/cocoa/SearchWindowController.h
+++ b/cocoa/SearchWindowController.h
@@ -49,4 +49,6 @@ typedef enum {
- (void) search: (SearchDirection)direction;
+struct gui_search_table *cocoa_search_table;
+
@end
diff --git a/cocoa/SearchWindowController.m b/cocoa/SearchWindowController.m
index 06147fa1a..e4dfb737f 100644
--- a/cocoa/SearchWindowController.m
+++ b/cocoa/SearchWindowController.m
@@ -20,20 +20,20 @@
#import "cocoa/SearchWindowController.h"
#import "cocoa/BrowserViewController.h"
+#import "desktop/gui.h"
#import "desktop/browser.h"
#import "desktop/search.h"
static void cocoa_search_set_back( bool active, void *p );
static void cocoa_search_set_forward( bool active, void *p );
-static struct gui_search_callbacks cocoa_search_callbacks = {
+static struct gui_search_table search_table = {
.forward_state = cocoa_search_set_forward,
.back_state = cocoa_search_set_back,
- .status = NULL,
- .hourglass = NULL,
- .add_recent = NULL
};
+struct gui_search_table *cocoa_search_table = &search_table;
+
@implementation SearchWindowController
@synthesize caseSensitive;
@@ -76,7 +76,7 @@ static struct gui_search_callbacks cocoa_search_callbacks = {
if (selectAll) flags |= SEARCH_FLAG_SHOWALL;
struct browser_window *bw = [browser browser];
- browser_window_search( bw, &cocoa_search_callbacks, self, flags, [searchString UTF8String] );
+ browser_window_search( bw, self, flags, [searchString UTF8String] );
}
- (IBAction) searchStringDidChange: (id) sender;
diff --git a/cocoa/apple_image.m b/cocoa/apple_image.m
index ab17f8ab4..c6f9df324 100644
--- a/cocoa/apple_image.m
+++ b/cocoa/apple_image.m
@@ -25,7 +25,8 @@
#include "image/bitmap.h"
#include "desktop/plotters.h"
#include "utils/utils.h"
-#include "utils/schedule.h"
+
+#include "cocoa/schedule.h"
typedef struct apple_image_content {
struct content base;
@@ -147,7 +148,7 @@ static void animate_image_cb( void *ptr )
data.redraw.object = &ai->base;
content_broadcast( &ai->base, CONTENT_MSG_REDRAW, data );
- schedule( ai->frameTimes[ai->currentFrame], animate_image_cb, ai );
+ cocoa_schedule(ai->frameTimes[ai->currentFrame], animate_image_cb, ai );
}
/**
@@ -190,10 +191,10 @@ bool apple_image_convert(struct content *c)
ai->frameTimes = calloc( ai->frames , sizeof(int));
for (NSUInteger i = 0; i < frames; i++) {
[image setProperty: NSImageCurrentFrame withValue: [NSNumber numberWithUnsignedInteger: i]];
- ai->frameTimes[i] = 100 * [[image valueForProperty: NSImageCurrentFrameDuration] floatValue];
+ ai->frameTimes[i] = 1000 * [[image valueForProperty: NSImageCurrentFrameDuration] floatValue];
}
[image setProperty: NSImageCurrentFrame withValue: [NSNumber numberWithUnsignedInteger: 0]];
- schedule( ai->frameTimes[0], animate_image_cb, ai );
+ cocoa_schedule( ai->frameTimes[0], animate_image_cb, ai );
}
return true;
@@ -206,7 +207,7 @@ void apple_image_destroy(struct content *c)
[(id)ai_c->bitmap release];
ai_c->bitmap = NULL;
- schedule_remove( animate_image_cb, c );
+ cocoa_schedule(-1, animate_image_cb, c );
}
diff --git a/cocoa/url.m b/cocoa/fetch.h
index 931f459a3..1b0991ef5 100644
--- a/cocoa/url.m
+++ b/cocoa/fetch.h
@@ -16,19 +16,4 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#import <Cocoa/Cocoa.h>
-
-#import "utils/url.h"
-
-
-char *url_to_path(const char *url)
-{
- NSURL *nsurl = [NSURL URLWithString: [NSString stringWithUTF8String: url]];
- return strdup([[nsurl path] UTF8String]);
-}
-
-char *path_to_url(const char *path)
-{
- return strdup( [[[NSURL fileURLWithPath: [NSString stringWithUTF8String: path]]
- absoluteString] UTF8String] );
-}
+extern struct gui_fetch_table *cocoa_fetch_table;
diff --git a/cocoa/fetch.m b/cocoa/fetch.m
index ff1496246..df424c3e8 100644
--- a/cocoa/fetch.m
+++ b/cocoa/fetch.m
@@ -19,7 +19,10 @@
#import <Cocoa/Cocoa.h>
#import "utils/log.h"
-#import "content/fetch.h"
+#import "utils/nsurl.h"
+#import "desktop/gui.h"
+
+#import "cocoa/fetch.h"
static char cocoafiletype[200];
@@ -40,9 +43,9 @@ static const struct mimemap_s {
};
-const char *fetch_filetype(const char *unix_path)
+static const char *fetch_filetype(const char *unix_path)
{
- NSString *uti;
+ NSString *uti;
NSString *mimeType = nil;
NSError *utiError = nil;
@@ -56,7 +59,7 @@ const char *fetch_filetype(const char *unix_path)
LOG(("uti call failed"));
- strncpy(cocoafiletype, "text/html", sizeof(cocoafiletype));
+ strncpy(cocoafiletype, "text/html", sizeof(cocoafiletype));
return cocoafiletype;
}
@@ -81,19 +84,30 @@ const char *fetch_filetype(const char *unix_path)
eidx++;
}
- strncpy(cocoafiletype,
- cocoamimemap[eidx].mimetype,
+ strncpy(cocoafiletype,
+ cocoamimemap[eidx].mimetype,
sizeof(cocoafiletype));
}
}
LOG(( "\tMIME type for '%s' is '%s'", unix_path, cocoafiletype ));
-
+
return cocoafiletype;
}
-
-char *fetch_mimetype(const char *ro_path)
+static nsurl *gui_get_resource_url(const char *path)
{
- return strdup( fetch_filetype( ro_path ) );
+ nsurl *url = NULL;
+ NSString *nspath = [[NSBundle mainBundle] pathForResource: [NSString stringWithUTF8String: path] ofType: @""];
+ if (nspath == nil) return NULL;
+ nsurl_create([[[NSURL fileURLWithPath: nspath] absoluteString] UTF8String], &url);
+ return url;
}
+
+static struct gui_fetch_table fetch_table = {
+ .filetype = fetch_filetype,
+
+ .get_resource_url = gui_get_resource_url,
+};
+
+struct gui_fetch_table *cocoa_fetch_table = &fetch_table;
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 b2ff01dc0..8f08fc7fa 100644
--- a/cocoa/gui.m
+++ b/cocoa/gui.m
@@ -24,16 +24,20 @@
#import "cocoa/BrowserViewController.h"
#import "cocoa/BrowserWindowController.h"
#import "cocoa/FormSelectMenu.h"
+#import "cocoa/fetch.h"
+#import "cocoa/schedule.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"
#import "content/fetchers/resource.h"
+#import "content/hlcache.h"
+#import "content/content.h"
NSString * const kCookiesFileOption = @"CookiesFile";
NSString * const kURLsFileOption = @"URLsFile";
@@ -45,20 +49,11 @@ NSString * const kAlwaysCloseMultipleTabs = @"AlwaysCloseMultipleTabs";
#define UNIMPL() NSLog( @"Function '%s' unimplemented", __func__ )
-nsurl *gui_get_resource_url(const char *path)
-{
- nsurl *url = NULL;
- NSString *nspath = [[NSBundle mainBundle] pathForResource: [NSString stringWithUTF8String: path] ofType: @""];
- if (nspath == nil) return NULL;
- nsurl_create([[[NSURL fileURLWithPath: nspath] absoluteString] UTF8String], &url);
- return url;
-}
-
-void gui_poll(bool active)
+static void gui_poll(bool active)
{
cocoa_autorelease();
- NSEvent *event = [NSApp nextEventMatchingMask: NSAnyEventMask untilDate: active ? nil : [NSDate distantFuture]
+ NSEvent *event = [NSApp nextEventMatchingMask: NSAnyEventMask untilDate: [NSDate distantFuture]
inMode: NSDefaultRunLoopMode dequeue: YES];
if (nil != event) {
@@ -67,28 +62,24 @@ 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 gui_window *existing,
+ gui_window_create_flags flags)
{
BrowserWindowController *window = nil;
- if (clone != NULL) {
- bw->scale = clone->scale;
- window = [(BrowserViewController *)(clone->window) windowController];
+ if (existing != NULL) {
+ bw->scale = (float) nsoption_int(scale) / 100;
+ window = [(BrowserViewController *)(existing) windowController];
} else {
bw->scale = (float) nsoption_int(scale) / 100;
}
BrowserViewController *result = [[BrowserViewController alloc] initWithBrowser: bw];
- if (!new_tab || nil == window) {
+ if (!(flags & GW_CREATE_TAB) || nil == window) {
window = [[[BrowserWindowController alloc] init] autorelease];
[[window window] makeKeyAndOrderFront: nil];
}
@@ -97,7 +88,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;
@@ -105,17 +96,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,
@@ -123,7 +114,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 );
@@ -133,19 +124,25 @@ 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)
+/**
+ * callback from core to reformat a window.
+ */
+static void cocoa_window_reformat(struct gui_window *gw)
{
- gui_window_set_scroll( g, x0, y0 );
+ if (gw != NULL) {
+ [[(BrowserViewController *)gw browserView] reformat ];
+ }
}
-void gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
- bool scaled)
+
+static void gui_window_get_dimensions(struct gui_window *g,
+ int *width, int *height,
+ bool scaled)
{
NSCParameterAssert( width != NULL && height != NULL );
@@ -159,7 +156,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;
@@ -170,12 +167,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:
@@ -208,28 +205,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;
@@ -246,56 +239,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];
@@ -303,14 +265,15 @@ void gui_create_form_select_menu(struct browser_window *bw,
[menu release];
}
-void gui_launch_url(const char *url)
+static nserror gui_launch_url(nsurl *url)
{
- [[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString: [NSString stringWithUTF8String: url]]];
+ [[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString: [NSString stringWithUTF8String: nsurl_access(url)]]];
+ return NSERROR_OK;
}
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)
{
@@ -318,9 +281,39 @@ void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs,
}
-void gui_401login_open(nsurl *url, const char *realm,
- nserror (*cb)(bool proceed, void *pw), void *cbpw)
-{
- cb( false, cbpw );
-}
+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,
+ .reformat = cocoa_window_reformat,
+
+ .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_browser_table browser_table = {
+ .poll = gui_poll,
+ .schedule = cocoa_schedule,
+
+ .launch_url = gui_launch_url,
+ .create_form_select_menu = gui_create_form_select_menu,
+ .cert_verify = gui_cert_verify,
+};
+struct gui_browser_table *cocoa_browser_table = &browser_table;
diff --git a/cocoa/utf8.m b/cocoa/schedule.h
index 2ec829888..43b2c1462 100644
--- a/cocoa/utf8.m
+++ b/cocoa/schedule.h
@@ -16,26 +16,4 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#import <Cocoa/Cocoa.h>
-
-#import "utils/utf8.h"
-
-utf8_convert_ret utf8_to_local_encoding(const char *string, size_t len,
- char **result)
-{
- NSCParameterAssert( NULL != result );
-
- char *newString = malloc( len + 1 );
- if (NULL == newString) return UTF8_CONVERT_NOMEM;
- memcpy( newString, string, len );
- newString[len] = 0;
- *result = newString;
- return UTF8_CONVERT_OK;
-}
-
-utf8_convert_ret utf8_from_local_encoding(const char *string, size_t len,
- char **result)
-{
- /* same function, local encoding = UTF-8 */
- return utf8_to_local_encoding( string, len, result );
-}
+nserror cocoa_schedule(int t, void (*callback)(void *p), void *p);
diff --git a/cocoa/schedule.m b/cocoa/schedule.m
index 1ad75b390..f0896bd9d 100644
--- a/cocoa/schedule.m
+++ b/cocoa/schedule.m
@@ -17,7 +17,10 @@
*/
#import <Cocoa/Cocoa.h>
-#import "utils/schedule.h"
+
+#import "utils/errors.h"
+
+#import "cocoa/schedule.h"
@interface ScheduledCallback : NSObject {
void (*callback)( void *userData );
@@ -73,18 +76,15 @@ static NSMutableSet *timerSet = nil;
@end
-/* In platform specific schedule.c. */
-void schedule(int t, void (*callback)(void *p), void *p)
-{
- ScheduledCallback *cb = [[ScheduledCallback alloc] initWithCallback: callback userData: p];
- [cb schedule: (NSTimeInterval)t / 100];
- [cb release];
-}
-
-void schedule_remove(void (*callback)(void *p), void *p)
+/* exported interface documented in cocoa/schedule.h */
+nserror cocoa_schedule(int t, void (*callback)(void *p), void *p)
{
ScheduledCallback *cb = [[ScheduledCallback alloc] initWithCallback: callback userData: p];
[timerSet removeObject: cb];
+ if (t >= 0) {
+ [cb schedule: (NSTimeInterval)t / 1000];
+ }
[cb release];
-}
+ return NSERROR_OK;
+}
diff --git a/cocoa/selection.h b/cocoa/selection.h
new file mode 100644
index 000000000..67331ea83
--- /dev/null
+++ b/cocoa/selection.h
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2011 Sven Weidauer <sven.weidauer@gmail.com>
+ *
+ * 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/>.
+ */
+
+struct gui_clipboard_table *cocoa_clipboard_table;
diff --git a/cocoa/selection.m b/cocoa/selection.m
index 237c61ce2..c8d6c7d5e 100644
--- a/cocoa/selection.m
+++ b/cocoa/selection.m
@@ -19,28 +19,21 @@
#import <Cocoa/Cocoa.h>
#import "cocoa/BrowserViewController.h"
+#import "cocoa/selection.h"
+#import "desktop/gui.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.
*
* \param buffer UTF-8 text, allocated by front end, ownership yeilded to core
* \param length Byte length of UTF-8 text in buffer
*/
-void gui_get_clipboard(char **buffer, size_t *length)
+static void gui_get_clipboard(char **buffer, size_t *length)
{
NSPasteboard *pb = [NSPasteboard generalPasteboard];
NSString *string = [pb stringForType: NSStringPboardType];
@@ -70,7 +63,7 @@ void gui_get_clipboard(char **buffer, size_t *length)
* \param styles Array of styles given to text runs, owned by core, or NULL
* \param n_styles Number of text run styles in array
*/
-void gui_set_clipboard(const char *buffer, size_t length,
+static void gui_set_clipboard(const char *buffer, size_t length,
nsclipboard_styles styles[], int n_styles)
{
/* Empty clipboard string */
@@ -104,3 +97,9 @@ void gui_set_clipboard(const char *buffer, size_t length,
}
}
+static struct gui_clipboard_table clipboard_table = {
+ .get = gui_get_clipboard,
+ .set = gui_set_clipboard,
+};
+
+struct gui_clipboard_table *cocoa_clipboard_table = &clipboard_table;
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;
-}