From df5a5582fda50440d82d6993871f29d3350f813a Mon Sep 17 00:00:00 2001 From: Sven Weidauer Date: Tue, 18 Jan 2011 08:26:56 +0000 Subject: Menu items for reload and stop loading. Also validating zoom and stop loading menu actions. svn path=/trunk/netsurf/; revision=11367 --- cocoa/BrowserView.m | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'cocoa/BrowserView.m') diff --git a/cocoa/BrowserView.m b/cocoa/BrowserView.m index 2254ba0d5..65c85b91f 100644 --- a/cocoa/BrowserView.m +++ b/cocoa/BrowserView.m @@ -317,17 +317,17 @@ static browser_mouse_state cocoa_mouse_flags_for_event( NSEvent *evt ) browser_window_reformat( browser, [self bounds].size.width, [self bounds].size.height ); } -- (void) zoomIn: (id) sender; +- (IBAction) zoomIn: (id) sender; { browser_window_set_scale( browser, browser->scale * 1.1, true ); } -- (void) zoomOut: (id) sender; +- (IBAction) zoomOut: (id) sender; { browser_window_set_scale( browser, browser->scale * 0.9, true ); } -- (void) zoomImageToActualSize: (id) sender; +- (IBAction) zoomOriginal: (id) sender; { browser_window_set_scale( browser, (float)option_scale / 100.0, true ); } @@ -355,6 +355,11 @@ static browser_mouse_state cocoa_mouse_flags_for_event( NSEvent *evt ) browser_window_reload( browser, true ); } +- (IBAction) stopLoading: (id) sender; +{ + browser_window_stop( browser ); +} + - (BOOL) validateToolbarItem: (NSToolbarItem *)theItem; { SEL action = [theItem action]; @@ -374,6 +379,15 @@ static browser_mouse_state cocoa_mouse_flags_for_event( NSEvent *evt ) return YES; } +static inline bool compare_float( float a, float b ) +{ + const float epsilon = 0.00001; + + if (a == b) return true; + + return fabs( (a - b) / b ) <= epsilon; +} + - (BOOL) validateUserInterfaceItem: (id) item; { SEL action = [item action]; @@ -390,6 +404,14 @@ static browser_mouse_state cocoa_mouse_flags_for_event( NSEvent *evt ) return browser->paste_callback != NULL; } + if (action == @selector( stopLoading: )) { + return browser->loading_content != NULL; + } + + if (action == @selector( zoomOriginal: )) { + return !compare_float( browser->scale, (float)option_scale / 100.0 ); + } + return YES; } -- cgit v1.2.3