From da01624374ea884fffb15d10a295ded84c6619af Mon Sep 17 00:00:00 2001 From: Sven Weidauer Date: Wed, 26 Jan 2011 13:35:07 +0000 Subject: Enabling back/forward buttons only if appropriate. svn path=/trunk/netsurf/; revision=11494 --- cocoa/BrowserWindowController.m | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'cocoa/BrowserWindowController.m') diff --git a/cocoa/BrowserWindowController.m b/cocoa/BrowserWindowController.m index 019807513..21e787b03 100644 --- a/cocoa/BrowserWindowController.m +++ b/cocoa/BrowserWindowController.m @@ -30,6 +30,7 @@ @synthesize tabBar; @synthesize tabView; @synthesize urlField; +@synthesize navigationControl; @synthesize activeBrowser; @synthesize activeBrowserController; @@ -46,6 +47,7 @@ [self setTabBar: nil]; [self setTabView: nil]; [self setUrlField: nil]; + [self setNavigationControl: nil]; [super dealloc]; } @@ -64,6 +66,13 @@ [urlField setRefreshAction: @selector(reloadPage:)]; [urlField bind: @"favicon" toObject: activeBrowserController withKeyPath: @"selection.favicon" options: nil]; + + [self bind: @"canGoBack" + toObject: activeBrowserController withKeyPath: @"selection.canGoBack" + options: nil]; + [self bind: @"canGoForward" + toObject: activeBrowserController withKeyPath: @"selection.canGoForward" + options: nil]; } - (void) addTab: (BrowserViewController *)browser; @@ -110,6 +119,26 @@ extern NSString * const kHomepageURL; [self setNextResponder: activeBrowser]; } +- (void) setCanGoBack: (BOOL)can; +{ + [navigationControl setEnabled: can forSegment: 0]; +} + +- (BOOL) canGoBack; +{ + return [navigationControl isEnabledForSegment: 0]; +} + +- (void) setCanGoForward: (BOOL)can; +{ + [navigationControl setEnabled: can forSegment: 1]; +} + +- (BOOL) canGoForward; +{ + return [navigationControl isEnabledForSegment: 1]; +} + #pragma mark - #pragma mark Tab bar delegate -- cgit v1.2.3