mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-02-23 01:44:42 +03:00
Setting/Loading more options. Also loading urldb and cookies.
svn path=/trunk/netsurf/; revision=11503
This commit is contained in:
parent
47c7051242
commit
f5ef7c71e7
@ -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;
|
||||
|
@ -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 */,
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
26
cocoa/gui.h
Normal file
26
cocoa/gui.h
Normal file
@ -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;
|
25
cocoa/gui.m
25
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();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user