From 81e295d8c94c3c2d7c6bcc3d71ae114b4d984ce6 Mon Sep 17 00:00:00 2001 From: Sven Weidauer Date: Tue, 1 Feb 2011 10:37:13 +0000 Subject: Using real path from options for the bookmarks file instead of hardcoded test string. svn path=/trunk/netsurf/; revision=11580 --- cocoa/BookmarksController.m | 19 +++++++++++++++++-- cocoa/NetsurfApp.h | 2 ++ cocoa/NetsurfApp.m | 4 +--- 3 files changed, 20 insertions(+), 5 deletions(-) (limited to 'cocoa') diff --git a/cocoa/BookmarksController.m b/cocoa/BookmarksController.m index 6e0c963d2..e78d76529 100644 --- a/cocoa/BookmarksController.m +++ b/cocoa/BookmarksController.m @@ -20,6 +20,7 @@ #import "cocoa/Tree.h" #import "cocoa/NetsurfApp.h" #import "cocoa/BrowserViewController.h" +#import "cocoa/gui.h" #import "desktop/hotlist.h" #import "desktop/tree.h" @@ -29,12 +30,18 @@ @synthesize defaultMenu; +static const char *cocoa_hotlist_path( void ) +{ + NSString *path = [[NSUserDefaults standardUserDefaults] stringForKey: kHotlistFileOption]; + return [path UTF8String]; +} + - init; { if ((self = [super init]) == nil) return nil; tree = [[Tree alloc] initWithFlags: hotlist_get_tree_flags()]; - hotlist_initialise( [tree tree], "/Users/sven/hotlist", "" ); + hotlist_initialise( [tree tree], cocoa_hotlist_path(), "" ); nodeForMenu = NSCreateMapTable( NSNonOwnedPointerMapKeyCallBacks, NSNonOwnedPointerMapValueCallBacks, 0 ); return self; @@ -43,7 +50,7 @@ - (void) dealloc; { NSFreeMapTable( nodeForMenu ); - hotlist_cleanup( "/Users/sven/hotlist" ); + hotlist_cleanup( cocoa_hotlist_path() ); [tree release]; [super dealloc]; } @@ -126,4 +133,12 @@ return YES; } + ++ (void) initialize; +{ + [[NSUserDefaults standardUserDefaults] registerDefaults: [NSDictionary dictionaryWithObjectsAndKeys: + cocoa_get_user_path( @"Bookmarks.html" ), kHotlistFileOption, + nil]]; +} + @end diff --git a/cocoa/NetsurfApp.h b/cocoa/NetsurfApp.h index a5f8fff3d..330f33826 100644 --- a/cocoa/NetsurfApp.h +++ b/cocoa/NetsurfApp.h @@ -27,3 +27,5 @@ @property (readwrite, assign, nonatomic) BrowserViewController *frontTab; @end + +NSString *cocoa_get_user_path( NSString *fileName ); diff --git a/cocoa/NetsurfApp.m b/cocoa/NetsurfApp.m index 0644c420f..6d881bb9d 100644 --- a/cocoa/NetsurfApp.m +++ b/cocoa/NetsurfApp.m @@ -44,7 +44,6 @@ #define NETSURF_HOMEPAGE "http://www.netsurf-browser.org/welcome/" #endif -static NSString *cocoa_get_user_path( NSString *fileName ) ; @implementation NetSurfApp @@ -56,7 +55,6 @@ static NSString *cocoa_get_user_path( NSString *fileName ) ; [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]]; @@ -134,7 +132,7 @@ static NSString *cocoa_get_preferences_path( void ) return netsurfPath; } -static NSString *cocoa_get_user_path( NSString *fileName ) +NSString *cocoa_get_user_path( NSString *fileName ) { return [cocoa_get_preferences_path() stringByAppendingPathComponent: fileName]; } -- cgit v1.2.3