summaryrefslogtreecommitdiff
path: root/cocoa
diff options
context:
space:
mode:
authorVincent Sanders <vince@netsurf-browser.org>2013-02-14 18:21:11 +0000
committerVincent Sanders <vince@netsurf-browser.org>2013-02-18 11:23:48 +0000
commitb112dec78d5e8289ded3f61db96e495690ae96b5 (patch)
tree9babaed21ed2eb841b8d398e28814544c73656d9 /cocoa
parent3bfb5b96a7c7cb2718a60987e69cd659ed49b9d8 (diff)
downloadnetsurf-b112dec78d5e8289ded3f61db96e495690ae96b5.tar.gz
netsurf-b112dec78d5e8289ded3f61db96e495690ae96b5.tar.bz2
change browser_window_create and refactor all callsites
Diffstat (limited to 'cocoa')
-rw-r--r--cocoa/BookmarksController.m19
-rw-r--r--cocoa/BrowserView.m35
-rw-r--r--cocoa/BrowserWindowController.m22
-rw-r--r--cocoa/NetSurfAppDelegate.m80
-rw-r--r--cocoa/NetsurfApp.m18
5 files changed, 155 insertions, 19 deletions
diff --git a/cocoa/BookmarksController.m b/cocoa/BookmarksController.m
index bb43b2fde..830c054a7 100644
--- a/cocoa/BookmarksController.m
+++ b/cocoa/BookmarksController.m
@@ -135,12 +135,10 @@ static const char *cocoa_hotlist_path( void )
nserror error;
error = nsurl_create(urltxt, &url);
- if (error != NSERROR_OK) {
- warn_user(messages_get_errorcode(error), 0);
- } else {
+ if (error == NSERROR_OK) {
BrowserViewController *tab = [(NetSurfApp *)NSApp frontTab];
if (tab != nil) {
- browser_window_navigate([tab browser],
+ error = browser_window_navigate([tab browser],
url,
NULL,
BROWSER_WINDOW_GO_FLAG_HISTORY |
@@ -149,13 +147,18 @@ static const char *cocoa_hotlist_path( void )
NULL,
NULL);
} else {
- browser_window_create( url, NULL, NULL, true, false );
+ error = browser_window_create(BROWSER_WINDOW_GO_FLAG_VERIFIABLE |
+ BROWSER_WINDOW_GO_FLAG_HISTORY,
+ url,
+ NULL,
+ NULL,
+ NULL);
}
-
nsurl_unref(url);
}
-
-
+ if (error != NSERROR_OK) {
+ warn_user(messages_get_errorcode(error), 0);
+ }
}
- (IBAction) addBookmark: (id) sender;
diff --git a/cocoa/BrowserView.m b/cocoa/BrowserView.m
index 63efac468..aed2230b9 100644
--- a/cocoa/BrowserView.m
+++ b/cocoa/BrowserView.m
@@ -575,12 +575,43 @@ static browser_mouse_state cocoa_mouse_flags_for_event( NSEvent *evt )
- (IBAction) cmOpenURLInTab: (id) sender;
{
- browser_window_create( [[sender representedObject] UTF8String], browser, NULL, true, true );
+ nsurl *url;
+ nserror error;
+
+ error = nsurl_create([[sender representedObject] UTF8String], &url);
+ if (error == NSERROR_OK) {
+ error = browser_window_create(BROWSER_WINDOW_GO_FLAG_VERIFIABLE |
+ BROWSER_WINDOW_GO_FLAG_HISTORY |
+ BROWSER_WINDOW_GO_FLAG_TAB,
+ url,
+ NULL,
+ browser,
+ NULL);
+ nsurl_unref(url);
+ }
+ if (error != NSERROR_OK) {
+ warn_user(messages_get_errorcode(error), 0);
+ }
}
- (IBAction) cmOpenURLInWindow: (id) sender;
{
- browser_window_create( [[sender representedObject] UTF8String], browser, NULL, true, false );
+ nsurl *url;
+ nserror error;
+
+ error = nsurl_create([[sender representedObject] UTF8String], &url);
+ if (error == NSERROR_OK) {
+ error = browser_window_create(BROWSER_WINDOW_GO_FLAG_VERIFIABLE |
+ BROWSER_WINDOW_GO_FLAG_HISTORY,
+ url,
+ NULL,
+ browser,
+ NULL);
+ nsurl_unref(url);
+ }
+ if (error != NSERROR_OK) {
+ warn_user(messages_get_errorcode(error), 0);
+ }
}
- (IBAction) cmDownloadURL: (id) sender;
diff --git a/cocoa/BrowserWindowController.m b/cocoa/BrowserWindowController.m
index b709ec613..771ae0841 100644
--- a/cocoa/BrowserWindowController.m
+++ b/cocoa/BrowserWindowController.m
@@ -150,7 +150,27 @@
- (IBAction) newTab: (id) sender;
{
- browser_window_create( nsoption_charp(homepage_url), [activeBrowser browser], NULL, false, true );
+ nsurl *url;
+ nserror error;
+
+ if (nsoption_charp(homepage_url) != NULL) {
+ error = nsurl_create(nsoption_charp(homepage_url), &url);
+ } else {
+ error = nsurl_create(NETSURF_HOMEPAGE, &url);
+ }
+ if (error == NSERROR_OK) {
+ error = browser_window_create(BROWSER_WINDOW_GO_FLAG_VERIFIABLE |
+ BROWSER_WINDOW_GO_FLAG_HISTORY |
+ BROWSER_WINDOW_GO_FLAG_TAB,
+ url,
+ NULL,
+ [activeBrowser browser],
+ NULL);
+ nsurl_unref(url);
+ }
+ if (error != NSERROR_OK) {
+ warn_user(messages_get_errorcode(error), 0);
+ }
}
- (IBAction) closeCurrentTab: (id) sender;
diff --git a/cocoa/NetSurfAppDelegate.m b/cocoa/NetSurfAppDelegate.m
index 651df1259..ba8678d42 100644
--- a/cocoa/NetSurfAppDelegate.m
+++ b/cocoa/NetSurfAppDelegate.m
@@ -39,24 +39,74 @@
- (void) newDocument: (id) sender;
{
- browser_window_create( nsoption_charp(homepage_url), NULL, NULL, true, false );
+ nsurl *url;
+ nserror error;
+
+ if (nsoption_charp(homepage_url) != NULL) {
+ error = nsurl_create(nsoption_charp(homepage_url), &url);
+ } else {
+ error = nsurl_create(NETSURF_HOMEPAGE, &url);
+ }
+
+ if (error == NSERROR_OK) {
+ error = browser_window_create(BROWSER_WINDOW_GO_FLAG_VERIFIABLE |
+ BROWSER_WINDOW_GO_FLAG_HISTORY,
+ url,
+ NULL,
+ NULL,
+ NULL);
+ nsurl_unref(url);
+ }
+ if (error != NSERROR_OK) {
+ warn_user(messages_get_errorcode(error), 0);
+ }
}
- (void) openDocument: (id) sender;
{
+ nsurl *url;
+ nserror error;
+
NSOpenPanel *openPanel = [NSOpenPanel openPanel];
[openPanel setAllowsMultipleSelection: YES];
if ([openPanel runModalForTypes: nil] == NSOKButton) {
for (NSURL *url in [openPanel URLs]) {
- browser_window_create( [[url absoluteString] UTF8String], NULL, NULL, true, false );
+ error = nsurl_create([[url absoluteString] UTF8String], &url);
+ if (error == NSERROR_OK) {
+ error = browser_window_create(BROWSER_WINDOW_GO_FLAG_VERIFIABLE |
+ BROWSER_WINDOW_GO_FLAG_HISTORY,
+ url,
+ NULL,
+ NULL,
+ NULL);
+ nsurl_unref(url);
+ }
+ if (error != NSERROR_OK) {
+ warn_user(messages_get_errorcode(error), 0);
+ }
}
}
}
- (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
{
- NSString *urlAsString = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
- browser_window_create( [urlAsString UTF8String], NULL, NULL, true, false );
+ nsurl *url;
+ nserror error;
+ NSString *urlAsString = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
+
+ error = nsurl_create([urlAsString UTF8String], &url);
+ if (error == NSERROR_OK) {
+ error = browser_window_create(BROWSER_WINDOW_GO_FLAG_VERIFIABLE |
+ BROWSER_WINDOW_GO_FLAG_HISTORY,
+ url,
+ NULL,
+ NULL,
+ NULL);
+ nsurl_unref(url);
+ }
+ if (error != NSERROR_OK) {
+ warn_user(messages_get_errorcode(error), 0);
+ }
}
- (IBAction) showSearchWindow: (id) sender;
@@ -124,9 +174,25 @@
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
{
- NSURL *url = [NSURL fileURLWithPath: filename];
- browser_window_create( [[url absoluteString] UTF8String], NULL, NULL, true, false );
- return YES;
+ nsurl *url;
+ nserror error;
+ NSURL *urltxt = [NSURL fileURLWithPath: filename];
+
+ error = nsurl_create([[urltxt absoluteString] UTF8String], &url);
+ if (error == NSERROR_OK) {
+ error = browser_window_create(BROWSER_WINDOW_GO_FLAG_VERIFIABLE |
+ BROWSER_WINDOW_GO_FLAG_HISTORY,
+ url,
+ NULL,
+ NULL,
+ NULL);
+ nsurl_unref(url);
+ }
+ if (error != NSERROR_OK) {
+ warn_user(messages_get_errorcode(error), 0);
+ }
+
+ return YES;
}
diff --git a/cocoa/NetsurfApp.m b/cocoa/NetsurfApp.m
index 4c2dfc185..b9cf4b999 100644
--- a/cocoa/NetsurfApp.m
+++ b/cocoa/NetsurfApp.m
@@ -175,6 +175,9 @@ void gui_options_init_defaults(void)
int main( int argc, char **argv )
{
+ nsurl *url;
+ nserror error;
+
cocoa_autorelease();
const char * const messages = [[[NSBundle mainBundle] pathForResource: @"Messages" ofType: @""] UTF8String];
@@ -193,7 +196,20 @@ int main( int argc, char **argv )
/* skip -psn_* and other possible options */
if (argv[i][0] == '-')
continue;
- browser_window_create( argv[i], NULL, NULL, true, false );
+
+ error = nsurl_create(argv[i], &url);
+ if (error == NSERROR_OK) {
+ error = browser_window_create(BROWSER_WINDOW_GO_FLAG_VERIFIABLE |
+ BROWSER_WINDOW_GO_FLAG_HISTORY,
+ url,
+ NULL,
+ NULL,
+ NULL);
+ nsurl_unref(url);
+ }
+ if (error != NSERROR_OK) {
+ warn_user(messages_get_errorcode(error), 0);
+ }
}
[app run];