summaryrefslogtreecommitdiff
path: root/cocoa
diff options
context:
space:
mode:
Diffstat (limited to 'cocoa')
-rw-r--r--cocoa/BrowserWindowController.m6
-rw-r--r--cocoa/NetSurf.xcodeproj/project.pbxproj2
-rw-r--r--cocoa/NetSurfAppDelegate.m12
-rw-r--r--cocoa/NetsurfApp.m43
-rw-r--r--cocoa/gui.h26
-rw-r--r--cocoa/gui.m25
6 files changed, 96 insertions, 18 deletions
diff --git a/cocoa/BrowserWindowController.m b/cocoa/BrowserWindowController.m
index 32cb57e9a..4ed220015 100644
--- a/cocoa/BrowserWindowController.m
+++ b/cocoa/BrowserWindowController.m
@@ -24,6 +24,7 @@
#import "URLFieldCell.h"
#import "desktop/browser.h"
+#import "desktop/options.h"
@implementation BrowserWindowController
@@ -105,12 +106,9 @@
}
}
-extern NSString * const kHomepageURL;
- (IBAction) newTab: (id) sender;
{
- NSString *homepageURL = [[NSUserDefaults standardUserDefaults] objectForKey: kHomepageURL];
- struct browser_window *clone = [[[tabView selectedTabViewItem] identifier] browser];
- browser_window_create( [homepageURL UTF8String], clone, NULL, false, true );
+ browser_window_create( option_homepage_url, [activeBrowser browser], NULL, false, true );
}
- (IBAction) closeCurrentTab: (id) sender;
diff --git a/cocoa/NetSurf.xcodeproj/project.pbxproj b/cocoa/NetSurf.xcodeproj/project.pbxproj
index 26b0c43b3..22188e5a9 100644
--- a/cocoa/NetSurf.xcodeproj/project.pbxproj
+++ b/cocoa/NetSurf.xcodeproj/project.pbxproj
@@ -322,6 +322,7 @@
262711BE12DDDD1500B2FA62 /* release.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = release.xcconfig; sourceTree = "<group>"; };
262711C212DDDDC300B2FA62 /* NetSurf.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = NetSurf.xcconfig; sourceTree = "<group>"; };
262711D412DDDEEE00B2FA62 /* common.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = common.xcconfig; sourceTree = "<group>"; };
+ 264C344112F0987E00D11246 /* gui.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gui.h; sourceTree = "<group>"; };
265F30A712D6637E0048B600 /* NetSurf-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "NetSurf-Info.plist"; sourceTree = "<group>"; };
265F30AB12D6637E0048B600 /* Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = "<group>"; };
265F311912D663F50048B600 /* gui.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = gui.m; sourceTree = "<group>"; };
@@ -846,6 +847,7 @@
26CDD26912E7446E004FC66B /* Platform Interface */ = {
isa = PBXGroup;
children = (
+ 264C344112F0987E00D11246 /* gui.h */,
265F311912D663F50048B600 /* gui.m */,
261223CB12D7805300E10F91 /* plotter.h */,
265F314712D666660048B600 /* plotter.m */,
diff --git a/cocoa/NetSurfAppDelegate.m b/cocoa/NetSurfAppDelegate.m
index 3900ec985..1d9df1ff2 100644
--- a/cocoa/NetSurfAppDelegate.m
+++ b/cocoa/NetSurfAppDelegate.m
@@ -19,6 +19,7 @@
#import "NetSurfAppDelegate.h"
#import "desktop/browser.h"
+#import "desktop/options.h"
@interface NetSurfAppDelegate ()
@@ -29,21 +30,12 @@
@implementation NetSurfAppDelegate
-NSString * const kHomepageURL = @"HomepageURL";
@synthesize historyWindow;
-+ (void) initialize;
-{
- [[NSUserDefaults standardUserDefaults] registerDefaults: [NSDictionary dictionaryWithObjectsAndKeys:
- @"http://netsurf-browser.org/welcome/", kHomepageURL,
- nil]];
-}
-
- (void) newDocument: (id) sender;
{
- NSString *homepageURL = [[NSUserDefaults standardUserDefaults] objectForKey: kHomepageURL];
- browser_window_create( [homepageURL UTF8String], NULL, NULL, true, false );
+ browser_window_create( option_homepage_url, NULL, NULL, true, false );
}
- (void) openDocument: (id) sender;
diff --git a/cocoa/NetsurfApp.m b/cocoa/NetsurfApp.m
index e82856704..245302962 100644
--- a/cocoa/NetsurfApp.m
+++ b/cocoa/NetsurfApp.m
@@ -18,6 +18,8 @@
#import "NetsurfApp.h"
+#import "cocoa/gui.h"
+
#import "desktop/gui.h"
#include "content/urldb.h"
#include "content/fetch.h"
@@ -36,14 +38,55 @@
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/utils.h"
+#import "css/utils.h"
+#ifndef NETSURF_HOMEPAGE
+#define NETSURF_HOMEPAGE "http://www.netsurf-browser.org/welcome/"
+#endif
@implementation NetSurfApp
+- (void) loadOptions;
+{
+ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+ [defaults registerDefaults: [NSDictionary dictionaryWithObjectsAndKeys:
+ cocoa_get_user_path( @"Cookies" ), kCookiesFileOption,
+ cocoa_get_user_path( @"URLs" ), kURLsFileOption,
+ cocoa_get_user_path( @"Hotlist" ), kHotlistFileOption,
+ [NSString stringWithUTF8String: NETSURF_HOMEPAGE], kHomepageURLOption,
+ nil]];
+
+
+ if (NULL == option_cookie_file) {
+ option_cookie_file = strdup( [[defaults objectForKey: kCookiesFileOption] UTF8String] );
+ }
+
+ if (NULL == option_cookie_jar) {
+ option_cookie_jar = strdup( option_cookie_file );
+ }
+
+ if (NULL == option_homepage_url) {
+ option_homepage_url = strdup( [[defaults objectForKey: kHomepageURLOption] UTF8String] );
+ }
+
+ nscss_screen_dpi = FLTTOFIX( 72.0 * [[NSScreen mainScreen] userSpaceScaleFactor] );
+
+ urldb_load( [[defaults objectForKey: kURLsFileOption] UTF8String] );
+ urldb_load_cookies( option_cookie_file );
+}
+
+- (void) saveOptions;
+{
+ urldb_save_cookies( option_cookie_file );
+ urldb_save( [[[NSUserDefaults standardUserDefaults] objectForKey: kURLsFileOption] UTF8String] );
+}
+
- (void) run;
{
[self finishLaunching];
+ [self loadOptions];
netsurf_main_loop();
+ [self saveOptions];
}
-(void) terminate: (id)sender;
diff --git a/cocoa/gui.h b/cocoa/gui.h
new file mode 100644
index 000000000..ba72456fa
--- /dev/null
+++ b/cocoa/gui.h
@@ -0,0 +1,26 @@
+/*
+ * 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/>.
+ */
+
+#import <Cocoa/Cocoa.h>
+
+NSString *cocoa_get_user_path( NSString *fileName );
+
+extern NSString * const kCookiesFileOption;
+extern NSString * const kURLsFileOption;
+extern NSString * const kHotlistFileOption;
+extern NSString * const kHomepageURLOption;
diff --git a/cocoa/gui.m b/cocoa/gui.m
index 57b7cc479..f6c0870e3 100644
--- a/cocoa/gui.m
+++ b/cocoa/gui.m
@@ -18,6 +18,8 @@
#import <Cocoa/Cocoa.h>
+#import "cocoa/gui.h"
+
#import "BrowserView.h"
#import "BrowserViewController.h"
#import "BrowserWindowController.h"
@@ -31,13 +33,17 @@
#import "desktop/selection.h"
#import "desktop/401login.h"
#import "utils/utils.h"
-
#import "image/ico.h"
char *default_stylesheet_url;
char *adblock_stylesheet_url;
char *quirks_stylesheet_url;
+NSString * const kCookiesFileOption = @"CookiesFile";
+NSString * const kURLsFileOption = @"URLsFile";
+NSString * const kHotlistFileOption = @"Hotlist";
+NSString * const kHomepageURLOption = @"HomepageURL";
+
#define UNIMPL() NSLog( @"Function '%s' unimplemented", __func__ )
void gui_multitask(void)
@@ -375,10 +381,21 @@ static NSString *cocoa_get_preferences_path( void )
return netsurfPath;
}
+NSString *cocoa_get_user_path( NSString *fileName )
+{
+ return [cocoa_get_preferences_path() stringByAppendingPathComponent: fileName];
+}
+
+NSString * const kClassicOptionsFile = @"ClassicOptionsFile";
+
static const char *cocoa_get_options_file( void )
{
- NSString *prefPath = [cocoa_get_preferences_path() stringByAppendingPathComponent: @"options"];
- return [prefPath UTF8String];
+ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+ [defaults registerDefaults: [NSDictionary dictionaryWithObjectsAndKeys:
+ cocoa_get_user_path( @"Options" ), kClassicOptionsFile,
+ nil]];
+
+ return [[defaults objectForKey: kClassicOptionsFile] UTF8String];
}
int main( int argc, char **argv )
@@ -404,7 +421,7 @@ int main( int argc, char **argv )
[mainNib instantiateNibWithOwner:NSApp topLevelObjects:nil];
[mainNib release];
- [NSApp performSelectorOnMainThread:@selector(run) withObject:nil waitUntilDone:YES];
+ [NSApp run];
netsurf_exit();