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.h | 5 ++ cocoa/BrowserView.m | 28 ++++++++- cocoa/res/MainMenu.xib | 167 +++++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 185 insertions(+), 15 deletions(-) (limited to 'cocoa') diff --git a/cocoa/BrowserView.h b/cocoa/BrowserView.h index ca09e7e30..7350f0bfb 100644 --- a/cocoa/BrowserView.h +++ b/cocoa/BrowserView.h @@ -46,5 +46,10 @@ - (IBAction) goForward: (id) sender; - (IBAction) showHistory: (id) sender; - (IBAction) reloadPage: (id) sender; +- (IBAction) stopLoading: (id) sender; + +- (IBAction) zoomIn: (id) sender; +- (IBAction) zoomOut: (id) sender; +- (IBAction) zoomOriginal: (id) sender; @end 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; } diff --git a/cocoa/res/MainMenu.xib b/cocoa/res/MainMenu.xib index ff0082fff..856c64a76 100644 --- a/cocoa/res/MainMenu.xib +++ b/cocoa/res/MainMenu.xib @@ -488,6 +488,34 @@ + + + Stop Loading + . + 1048576 + 2147483647 + + + + + + Reload Page + r + 1048576 + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + Original Size @@ -625,7 +653,7 @@ {1.79769e+308, 1.79769e+308} - + 256 YES @@ -644,13 +672,11 @@ 268 {300, 387} - TreeView {{1, 1}, {300, 387}} - @@ -669,7 +695,6 @@ -2147483392 {{319, 1}, {15, 371}} - _doScroller: 0.99741602067183466 @@ -679,7 +704,6 @@ -2147483392 {{1, 373}, {500, 15}} - 1 _doScroller: @@ -688,7 +712,6 @@ {{-1, -1}, {302, 389}} - 562 @@ -697,8 +720,6 @@ {300, 387} - - {{0, 0}, {1680, 1028}} {1.79769e+308, 1.79769e+308} @@ -1000,11 +1021,27 @@ - zoomImageToActualSize: + stopLoading: + + + + 835 + + + + reloadPage: + + + + 836 + + + + zoomOriginal: - 831 + 837 @@ -1288,6 +1325,9 @@ + + + @@ -1534,6 +1574,21 @@ + + 832 + + + + + 833 + + + + + 834 + + + @@ -1667,6 +1722,9 @@ 828.IBPluginDependency 83.IBPluginDependency 83.ImportedFromIB2 + 832.IBPluginDependency + 833.IBPluginDependency + 834.IBPluginDependency 92.IBPluginDependency 92.ImportedFromIB2 @@ -1721,7 +1779,7 @@ {74, 862} {{11, 977}, {478, 20}} com.apple.InterfaceBuilder.CocoaPlugin - {{823, 515}, {234, 113}} + {{823, 465}, {234, 163}} com.apple.InterfaceBuilder.CocoaPlugin {{475, 832}, {234, 43}} com.apple.InterfaceBuilder.CocoaPlugin @@ -1800,6 +1858,9 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin @@ -1819,11 +1880,93 @@ - 831 + 837 YES + + BrowserView + NSView + + YES + + YES + goBack: + goForward: + reloadPage: + showHistory: + stopLoading: + zoomIn: + zoomOriginal: + zoomOut: + + + YES + id + id + id + id + id + id + id + id + + + + YES + + YES + goBack: + goForward: + reloadPage: + showHistory: + stopLoading: + zoomIn: + zoomOriginal: + zoomOut: + + + YES + + goBack: + id + + + goForward: + id + + + reloadPage: + id + + + showHistory: + id + + + stopLoading: + id + + + zoomIn: + id + + + zoomOriginal: + id + + + zoomOut: + id + + + + + IBProjectSource + BrowserView.h + + NetSurfAppDelegate NSObject -- cgit v1.2.3