summaryrefslogtreecommitdiff
path: root/frontends/cocoa/NetSurfAppDelegate.m
diff options
context:
space:
mode:
Diffstat (limited to 'frontends/cocoa/NetSurfAppDelegate.m')
-rw-r--r--frontends/cocoa/NetSurfAppDelegate.m228
1 files changed, 113 insertions, 115 deletions
diff --git a/frontends/cocoa/NetSurfAppDelegate.m b/frontends/cocoa/NetSurfAppDelegate.m
index e9e5b4376..55cd714f0 100644
--- a/frontends/cocoa/NetSurfAppDelegate.m
+++ b/frontends/cocoa/NetSurfAppDelegate.m
@@ -28,173 +28,171 @@
#import "cocoa/PreferencesWindowController.h"
#import "cocoa/HistoryWindowController.h"
-
@interface NetSurfAppDelegate ()
- (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent;
@end
-
@implementation NetSurfAppDelegate
@synthesize history;
@synthesize search;
@synthesize preferences;
-- (void) newDocument: (id) sender
+- (void)newDocument:(id)sender
{
- 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(BW_CREATE_HISTORY,
- url,
- NULL,
- NULL,
- NULL);
- nsurl_unref(url);
- }
- if (error != NSERROR_OK) {
- cocoa_warning(messages_get_errorcode(error), 0);
- }
+ 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(BW_CREATE_HISTORY,
+ url,
+ NULL,
+ NULL,
+ NULL);
+ nsurl_unref(url);
+ }
+ if (error != NSERROR_OK) {
+ cocoa_warning(messages_get_errorcode(error), 0);
+ }
}
-- (void) openDocument: (id) sender
+- (void)openDocument:(id)sender
{
- nsurl *u;
- nserror error;
-
- NSOpenPanel *openPanel = [NSOpenPanel openPanel];
- [openPanel setAllowsMultipleSelection: YES];
- if ([openPanel runModalForTypes: nil] == NSModalResponseOK) {
- for (NSURL *url in [openPanel URLs]) {
- error = nsurl_create([[url absoluteString] UTF8String], &u);
- if (error == NSERROR_OK) {
- error = browser_window_create(BW_CREATE_HISTORY,
- u,
- NULL,
- NULL,
- NULL);
- nsurl_unref(u);
- }
- if (error != NSERROR_OK) {
- cocoa_warning(messages_get_errorcode(error), 0);
- }
- }
- }
+ nsurl *u;
+ nserror error;
+
+ NSOpenPanel *openPanel = [NSOpenPanel openPanel];
+ [openPanel setAllowsMultipleSelection:YES];
+ if ([openPanel runModalForTypes:nil] == NSModalResponseOK) {
+ for (NSURL *url in [openPanel URLs]) {
+ error = nsurl_create([[url absoluteString] UTF8String], &u);
+ if (error == NSERROR_OK) {
+ error = browser_window_create(BW_CREATE_HISTORY,
+ u,
+ NULL,
+ NULL,
+ NULL);
+ nsurl_unref(u);
+ }
+ if (error != NSERROR_OK) {
+ cocoa_warning(messages_get_errorcode(error), 0);
+ }
+ }
+ }
}
- (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
{
- nsurl *url;
- nserror error;
- NSString *urlAsString = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
-
- error = nsurl_create([urlAsString UTF8String], &url);
- if (error == NSERROR_OK) {
- error = browser_window_create(BW_CREATE_HISTORY,
- url,
- NULL,
- NULL,
- NULL);
- nsurl_unref(url);
- }
- if (error != NSERROR_OK) {
- cocoa_warning(messages_get_errorcode(error), 0);
- }
+ nsurl *url;
+ nserror error;
+ NSString *urlAsString = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
+
+ error = nsurl_create([urlAsString UTF8String], &url);
+ if (error == NSERROR_OK) {
+ error = browser_window_create(BW_CREATE_HISTORY,
+ url,
+ NULL,
+ NULL,
+ NULL);
+ nsurl_unref(url);
+ }
+ if (error != NSERROR_OK) {
+ cocoa_warning(messages_get_errorcode(error), 0);
+ }
}
-- (IBAction) showSearchWindow: (id) sender
+- (IBAction)showSearchWindow:(id)sender
{
- if (search == nil) {
- [self setSearch: [[SearchWindowController alloc] init]];
- }
- [[search window] makeKeyAndOrderFront: self];
+ if (search == nil) {
+ [self setSearch:[[SearchWindowController alloc] init]];
+ }
+ [[search window] makeKeyAndOrderFront:self];
}
-- (IBAction) searchForward: (id) sender
+- (IBAction)searchForward:(id)sender
{
- [search search: SearchForward];
+ [search search:SearchForward];
}
-- (IBAction) searchBackward: (id) sender
+- (IBAction)searchBackward:(id)sender
{
- [search search: SearchBackward];
+ [search search:SearchBackward];
}
-- (BOOL) validateMenuItem: (id) item
+- (BOOL)validateMenuItem:(id)item
{
- SEL action = [item action];
-
- if (action == @selector( searchForward: )) {
- return [search canGoForward];
- } else if (action == @selector( searchBackward: )) {
- return [search canGoBack];
- }
-
- return YES;
+ SEL action = [item action];
+
+ if (action == @selector(searchForward:)) {
+ return [search canGoForward];
+ } else if (action == @selector(searchBackward:)) {
+ return [search canGoBack];
+ }
+
+ return YES;
}
-- (IBAction) showPreferences: (id) sender
+- (IBAction)showPreferences:(id)sender
{
- if (preferences == nil) {
- [self setPreferences: [[PreferencesWindowController alloc] init]];
- }
- [preferences showWindow: sender];
+ if (preferences == nil) {
+ [self setPreferences:[[PreferencesWindowController alloc] init]];
+ }
+ [preferences showWindow:sender];
}
-- (IBAction) showGlobalHistory: (id) sender
+- (IBAction)showGlobalHistory:(id)sender
{
- if (history == nil) {
- [self setHistory: [[HistoryWindowController alloc] init] ];
- }
- [history showWindow: sender];
+ if (history == nil) {
+ [self setHistory:[[HistoryWindowController alloc] init]];
+ }
+ [history showWindow:sender];
}
// Application delegate methods
-- (BOOL) applicationOpenUntitledFile: (NSApplication *)sender
+- (BOOL)applicationOpenUntitledFile:(NSApplication *)sender
{
- [self newDocument: self];
- return YES;
+ [self newDocument:self];
+ return YES;
}
--(void)applicationWillFinishLaunching:(NSNotification *)aNotification
+- (void)applicationWillFinishLaunching:(NSNotification *)aNotification
{
NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager];
- [appleEventManager setEventHandler:self
+ [appleEventManager setEventHandler:self
andSelector:@selector(handleGetURLEvent:withReplyEvent:)
- forEventClass:kInternetEventClass andEventID:kAEGetURL];
+ forEventClass:kInternetEventClass
+ andEventID:kAEGetURL];
}
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
{
- nsurl *url;
- nserror error;
- NSURL *urltxt = [NSURL fileURLWithPath: filename];
-
- error = nsurl_create([[urltxt absoluteString] UTF8String], &url);
- if (error == NSERROR_OK) {
- error = browser_window_create(BW_CREATE_HISTORY,
- url,
- NULL,
- NULL,
- NULL);
- nsurl_unref(url);
- }
- if (error != NSERROR_OK) {
- cocoa_warning(messages_get_errorcode(error), 0);
- }
-
- 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(BW_CREATE_HISTORY,
+ url,
+ NULL,
+ NULL,
+ NULL);
+ nsurl_unref(url);
+ }
+ if (error != NSERROR_OK) {
+ cocoa_warning(messages_get_errorcode(error), 0);
+ }
+
+ return YES;
}
-
@end