Menu items for reload and stop loading. Also validating zoom and stop loading menu actions.

svn path=/trunk/netsurf/; revision=11367
This commit is contained in:
Sven Weidauer 2011-01-18 08:26:56 +00:00
parent 0d98d39a1a
commit df5a5582fd
3 changed files with 185 additions and 15 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -488,6 +488,34 @@
<reference key="NSOnImage" ref="756751024"/>
<reference key="NSMixedImage" ref="908425081"/>
</object>
<object class="NSMenuItem" id="1008284068">
<reference key="NSMenu" ref="466310130"/>
<string key="NSTitle">Stop Loading</string>
<string key="NSKeyEquiv">.</string>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="756751024"/>
<reference key="NSMixedImage" ref="908425081"/>
</object>
<object class="NSMenuItem" id="997106205">
<reference key="NSMenu" ref="466310130"/>
<string key="NSTitle">Reload Page</string>
<string key="NSKeyEquiv">r</string>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="756751024"/>
<reference key="NSMixedImage" ref="908425081"/>
</object>
<object class="NSMenuItem" id="403460345">
<reference key="NSMenu" ref="466310130"/>
<bool key="NSIsDisabled">YES</bool>
<bool key="NSIsSeparator">YES</bool>
<string key="NSTitle"/>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="756751024"/>
<reference key="NSMixedImage" ref="908425081"/>
</object>
<object class="NSMenuItem" id="924072330">
<reference key="NSMenu" ref="466310130"/>
<string key="NSTitle">Original Size</string>
@ -625,7 +653,7 @@
<nil key="NSViewClass"/>
<string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string>
<object class="NSView" key="NSWindowView" id="75583718">
<reference key="NSNextResponder"/>
<nil key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
@ -644,13 +672,11 @@
<int key="NSvFlags">268</int>
<string key="NSFrameSize">{300, 387}</string>
<reference key="NSSuperview" ref="862897293"/>
<reference key="NSWindow"/>
<string key="NSClassName">TreeView</string>
</object>
</object>
<string key="NSFrame">{{1, 1}, {300, 387}}</string>
<reference key="NSSuperview" ref="429678852"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="363409241"/>
<reference key="NSDocView" ref="363409241"/>
<object class="NSColor" key="NSBGColor">
@ -669,7 +695,6 @@
<int key="NSvFlags">-2147483392</int>
<string key="NSFrame">{{319, 1}, {15, 371}}</string>
<reference key="NSSuperview" ref="429678852"/>
<reference key="NSWindow"/>
<reference key="NSTarget" ref="429678852"/>
<string key="NSAction">_doScroller:</string>
<double key="NSPercent">0.99741602067183466</double>
@ -679,7 +704,6 @@
<int key="NSvFlags">-2147483392</int>
<string key="NSFrame">{{1, 373}, {500, 15}}</string>
<reference key="NSSuperview" ref="429678852"/>
<reference key="NSWindow"/>
<int key="NSsFlags">1</int>
<reference key="NSTarget" ref="429678852"/>
<string key="NSAction">_doScroller:</string>
@ -688,7 +712,6 @@
</object>
<string key="NSFrame">{{-1, -1}, {302, 389}}</string>
<reference key="NSSuperview" ref="75583718"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="862897293"/>
<int key="NSsFlags">562</int>
<reference key="NSVScroller" ref="1030123989"/>
@ -697,8 +720,6 @@
</object>
</object>
<string key="NSFrameSize">{300, 387}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1680, 1028}}</string>
<string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string>
@ -1000,11 +1021,27 @@
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">zoomImageToActualSize:</string>
<string key="label">stopLoading:</string>
<reference key="source" ref="1014"/>
<reference key="destination" ref="1008284068"/>
</object>
<int key="connectionID">835</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">reloadPage:</string>
<reference key="source" ref="1014"/>
<reference key="destination" ref="997106205"/>
</object>
<int key="connectionID">836</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">zoomOriginal:</string>
<reference key="source" ref="1014"/>
<reference key="destination" ref="924072330"/>
</object>
<int key="connectionID">831</int>
<int key="connectionID">837</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
@ -1288,6 +1325,9 @@
<reference ref="148271458"/>
<reference ref="924072330"/>
<reference ref="157577355"/>
<reference ref="403460345"/>
<reference ref="1008284068"/>
<reference ref="997106205"/>
</object>
<reference key="parent" ref="586577488"/>
</object>
@ -1534,6 +1574,21 @@
<reference key="object" ref="157577355"/>
<reference key="parent" ref="466310130"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">832</int>
<reference key="object" ref="403460345"/>
<reference key="parent" ref="466310130"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">833</int>
<reference key="object" ref="1008284068"/>
<reference key="parent" ref="466310130"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">834</int>
<reference key="object" ref="997106205"/>
<reference key="parent" ref="466310130"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@ -1667,6 +1722,9 @@
<string>828.IBPluginDependency</string>
<string>83.IBPluginDependency</string>
<string>83.ImportedFromIB2</string>
<string>832.IBPluginDependency</string>
<string>833.IBPluginDependency</string>
<string>834.IBPluginDependency</string>
<string>92.IBPluginDependency</string>
<string>92.ImportedFromIB2</string>
</object>
@ -1721,7 +1779,7 @@
<string>{74, 862}</string>
<string>{{11, 977}, {478, 20}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{823, 515}, {234, 113}}</string>
<string>{{823, 465}, {234, 163}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{475, 832}, {234, 43}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@ -1800,6 +1858,9 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
</object>
</object>
@ -1819,11 +1880,93 @@
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">831</int>
<int key="maxID">837</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
<string key="className">BrowserView</string>
<string key="superclassName">NSView</string>
<object class="NSMutableDictionary" key="actions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>goBack:</string>
<string>goForward:</string>
<string>reloadPage:</string>
<string>showHistory:</string>
<string>stopLoading:</string>
<string>zoomIn:</string>
<string>zoomOriginal:</string>
<string>zoomOut:</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>goBack:</string>
<string>goForward:</string>
<string>reloadPage:</string>
<string>showHistory:</string>
<string>stopLoading:</string>
<string>zoomIn:</string>
<string>zoomOriginal:</string>
<string>zoomOut:</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBActionInfo">
<string key="name">goBack:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">goForward:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">reloadPage:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">showHistory:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">stopLoading:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">zoomIn:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">zoomOriginal:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">zoomOut:</string>
<string key="candidateClassName">id</string>
</object>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">BrowserView.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NetSurfAppDelegate</string>
<string key="superclassName">NSObject</string>