From 2ab5636619d6e0a44c32e10cd71c9f99c5fe5977 Mon Sep 17 00:00:00 2001 From: Sven Weidauer Date: Thu, 13 Jan 2011 17:20:13 +0000 Subject: Zooming, opening files, accepting http and https URLs svn path=/trunk/netsurf/; revision=11310 --- cocoa/BrowserView.m | 15 ++ cocoa/NetSurf.xcodeproj/project.pbxproj | 6 + cocoa/NetSurfAppDelegate.h | 28 ++++ cocoa/NetSurfAppDelegate.m | 78 +++++++++++ cocoa/NetsurfApp.m | 1 - cocoa/gui.m | 2 +- cocoa/res/MainMenu.xib | 238 +++++++++++++++++++++++--------- cocoa/res/NetSurf-Info.plist | 12 ++ 8 files changed, 312 insertions(+), 68 deletions(-) create mode 100644 cocoa/NetSurfAppDelegate.h create mode 100644 cocoa/NetSurfAppDelegate.m diff --git a/cocoa/BrowserView.m b/cocoa/BrowserView.m index 0aed72142..d26fc8bdd 100644 --- a/cocoa/BrowserView.m +++ b/cocoa/BrowserView.m @@ -22,6 +22,7 @@ #import "desktop/history_core.h" #import "desktop/plotters.h" #import "desktop/textinput.h" +#import "desktop/options.h" @implementation BrowserView @@ -244,6 +245,20 @@ static inline NSRect cocoa_get_caret_rect( BrowserView *view ) browser_window_reformat( browser, [self bounds].size.width, [self bounds].size.height ); } +- (void) zoomIn: (id) sender; +{ + browser_window_set_scale( browser, browser->scale * 1.1, true ); +} + +- (void) zoomOut: (id) sender; +{ + browser_window_set_scale( browser, browser->scale * 0.9, true ); +} + +- (void) zoomImageToActualSize: (id) sender; +{ + browser_window_set_scale( browser, (float)option_scale / 100.0, true ); +} - (IBAction) goBack: (id) sender; { diff --git a/cocoa/NetSurf.xcodeproj/project.pbxproj b/cocoa/NetSurf.xcodeproj/project.pbxproj index af16babf1..97ca2d496 100644 --- a/cocoa/NetSurf.xcodeproj/project.pbxproj +++ b/cocoa/NetSurf.xcodeproj/project.pbxproj @@ -112,6 +112,7 @@ 265F321F12D66D510048B600 /* font.m in Sources */ = {isa = PBXBuildFile; fileRef = 265F321E12D66D510048B600 /* font.m */; }; 26AFE63F12DDEB0A005AD082 /* NetSurf.icns in Resources */ = {isa = PBXBuildFile; fileRef = 26AFE63E12DDEB0A005AD082 /* NetSurf.icns */; }; 26AFE8E412DF4200005AD082 /* ScrollableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 26AFE8E312DF4200005AD082 /* ScrollableView.m */; }; + 26AFE97C12DF514C005AD082 /* NetSurfAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 26AFE97B12DF514C005AD082 /* NetSurfAppDelegate.m */; }; 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; }; /* End PBXBuildFile section */ @@ -328,6 +329,8 @@ 26AFE63E12DDEB0A005AD082 /* NetSurf.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = NetSurf.icns; sourceTree = ""; }; 26AFE8E212DF4200005AD082 /* ScrollableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollableView.h; sourceTree = ""; }; 26AFE8E312DF4200005AD082 /* ScrollableView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ScrollableView.m; sourceTree = ""; }; + 26AFE97A12DF514C005AD082 /* NetSurfAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetSurfAppDelegate.h; sourceTree = ""; }; + 26AFE97B12DF514C005AD082 /* NetSurfAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NetSurfAppDelegate.m; sourceTree = ""; }; 8D1107320486CEB800E47090 /* NetSurf.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NetSurf.app; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -605,6 +608,8 @@ 2622F1D612DCD84600CD5A62 /* TreeView.m */, 26AFE8E212DF4200005AD082 /* ScrollableView.h */, 26AFE8E312DF4200005AD082 /* ScrollableView.m */, + 26AFE97A12DF514C005AD082 /* NetSurfAppDelegate.h */, + 26AFE97B12DF514C005AD082 /* NetSurfAppDelegate.m */, ); name = cocoa; sourceTree = ""; @@ -851,6 +856,7 @@ 26121EFD12D7132100E10F91 /* BrowserView.m in Sources */, 2622F1D712DCD84600CD5A62 /* TreeView.m in Sources */, 26AFE8E412DF4200005AD082 /* ScrollableView.m in Sources */, + 26AFE97C12DF514C005AD082 /* NetSurfAppDelegate.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/cocoa/NetSurfAppDelegate.h b/cocoa/NetSurfAppDelegate.h new file mode 100644 index 000000000..e070b3fa9 --- /dev/null +++ b/cocoa/NetSurfAppDelegate.h @@ -0,0 +1,28 @@ +/* + * Copyright 2011 Sven Weidauer + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#import + + +@interface NetSurfAppDelegate : NSObject { + NSWindow *historyWindow; +} + +@property (readwrite, retain, nonatomic) IBOutlet NSWindow *historyWindow; + +@end diff --git a/cocoa/NetSurfAppDelegate.m b/cocoa/NetSurfAppDelegate.m new file mode 100644 index 000000000..8bac3f2ab --- /dev/null +++ b/cocoa/NetSurfAppDelegate.m @@ -0,0 +1,78 @@ +/* + * Copyright 2011 Sven Weidauer + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#import "NetSurfAppDelegate.h" + +#import "desktop/browser.h" + +@interface NetSurfAppDelegate () + +- (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent; + +@end + + +@implementation NetSurfAppDelegate + +@synthesize historyWindow; + +- (void) newDocument: (id) sender; +{ + browser_window_create( "http://netsurf-browser.org/", NULL, NULL, true, false ); +} + +- (void) openDocument: (id) sender; +{ + NSOpenPanel *openPanel = [NSOpenPanel openPanel]; + [openPanel setAllowsMultipleSelection: YES]; + if ([openPanel runModalForTypes: nil] == NSOKButton) { + for (NSURL *url in [openPanel URLs]) { + browser_window_create( [[url absoluteString] UTF8String], NULL, NULL, true, false ); + } + } +} + +- (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent +{ + NSString *urlAsString = [[event paramDescriptorForKeyword:keyDirectObject] stringValue]; + browser_window_create( [urlAsString UTF8String], NULL, NULL, true, false ); +} + +- (void) awakeFromNib; +{ + [historyWindow setExcludedFromWindowsMenu: YES]; +} + +// Application delegate methods + +- (BOOL) applicationOpenUntitledFile: (NSApplication *)sender; +{ + [self newDocument: self]; + return YES; +} + +-(void)applicationWillFinishLaunching:(NSNotification *)aNotification +{ + NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager]; + [appleEventManager setEventHandler:self + andSelector:@selector(handleGetURLEvent:withReplyEvent:) + forEventClass:kInternetEventClass andEventID:kAEGetURL]; +} + + +@end diff --git a/cocoa/NetsurfApp.m b/cocoa/NetsurfApp.m index 3ca150e14..9e061a4c1 100644 --- a/cocoa/NetsurfApp.m +++ b/cocoa/NetsurfApp.m @@ -43,7 +43,6 @@ - (void) run; { [self finishLaunching]; - browser_window_create( "http://netsurf-browser.org/", NULL, NULL, true, false ); netsurf_main_loop(); } diff --git a/cocoa/gui.m b/cocoa/gui.m index 4864d8897..15b7ea46b 100644 --- a/cocoa/gui.m +++ b/cocoa/gui.m @@ -249,7 +249,7 @@ void gui_window_save_link(struct gui_window *g, const char *url, void gui_window_set_scale(struct gui_window *g, float scale) { - UNIMPL(); + gui_window_redraw_window( g ); } diff --git a/cocoa/res/MainMenu.xib b/cocoa/res/MainMenu.xib index fae4184cc..ff0082fff 100644 --- a/cocoa/res/MainMenu.xib +++ b/cocoa/res/MainMenu.xib @@ -12,8 +12,7 @@ YES - - + YES @@ -182,7 +181,7 @@ YES - New + New Window n 1048576 2147483647 @@ -191,7 +190,7 @@ - Open… + Open File… o 1048576 2147483647 @@ -217,28 +216,11 @@ - - - Save - s - 1048576 - 2147483647 - - - Save As… - S - 1179648 - 2147483647 - - - - - - Revert to Saved - + s + 1048576 2147483647 @@ -496,6 +478,43 @@ + + + YES + YES + + + 2147483647 + + + + + + Original Size + 0 + 1048576 + 2147483647 + + + + + + Zoom In + + + 1048576 + 2147483647 + + + + + + Zoom Out + - + 1048576 + 2147483647 + + + @@ -625,11 +644,13 @@ 268 {300, 387} + TreeView {{1, 1}, {300, 387}} + @@ -648,6 +669,7 @@ -2147483392 {{319, 1}, {15, 371}} + _doScroller: 0.99741602067183466 @@ -657,6 +679,7 @@ -2147483392 {{1, 373}, {500, 15}} + 1 _doScroller: @@ -665,6 +688,7 @@ {{-1, -1}, {302, 389}} + 562 @@ -674,10 +698,14 @@ {300, 387} + {{0, 0}, {1680, 1028}} {1.79769e+308, 1.79769e+308} + + NetSurfAppDelegate + @@ -746,14 +774,6 @@ 360 - - - saveDocument: - - - - 362 - saveDocumentAs: @@ -762,14 +782,6 @@ 363 - - - revertDocumentToSaved: - - - - 364 - runToolbarCustomizationPalette: @@ -938,6 +950,62 @@ 819 + + + delegate + + + + 821 + + + + historyWindow + + + + 822 + + + + newDocument: + + + + 823 + + + + openDocument: + + + + 824 + + + + zoomIn: + + + + 829 + + + + zoomOut: + + + + 830 + + + + zoomImageToActualSize: + + + + 831 + @@ -1023,24 +1091,17 @@ YES - - - - 75 - - - 80 @@ -1071,11 +1132,6 @@ - - 112 - - - 74 @@ -1228,6 +1284,10 @@ YES + + + + @@ -1449,6 +1509,31 @@ + + 820 + + + + + 825 + + + + + 826 + + + + + 827 + + + + + 828 + + + @@ -1464,8 +1549,6 @@ 106.editorWindowContentRectSynchronizationRect 111.IBPluginDependency 111.ImportedFromIB2 - 112.IBPluginDependency - 112.ImportedFromIB2 129.IBPluginDependency 129.ImportedFromIB2 130.IBEditorWindowLastContentRect @@ -1552,8 +1635,6 @@ 739.IBPluginDependency 74.IBPluginDependency 74.ImportedFromIB2 - 75.IBPluginDependency - 75.ImportedFromIB2 77.IBPluginDependency 77.ImportedFromIB2 78.IBPluginDependency @@ -1579,6 +1660,11 @@ 818.IBPluginDependency 82.IBPluginDependency 82.ImportedFromIB2 + 820.IBPluginDependency + 825.IBPluginDependency + 826.IBPluginDependency + 827.IBPluginDependency + 828.IBPluginDependency 83.IBPluginDependency 83.ImportedFromIB2 92.IBPluginDependency @@ -1597,8 +1683,6 @@ com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - {{509, 573}, {64, 6}} com.apple.InterfaceBuilder.CocoaPlugin @@ -1631,13 +1715,13 @@ com.apple.InterfaceBuilder.CocoaPlugin {{525, 802}, {197, 73}} - {{590, 797}, {352, 20}} + {{653, 628}, {352, 20}} com.apple.InterfaceBuilder.CocoaPlugin {74, 862} {{11, 977}, {478, 20}} com.apple.InterfaceBuilder.CocoaPlugin - {{412, 613}, {231, 43}} + {{823, 515}, {234, 113}} com.apple.InterfaceBuilder.CocoaPlugin {{475, 832}, {234, 43}} com.apple.InterfaceBuilder.CocoaPlugin @@ -1653,7 +1737,7 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{368, 453}, {151, 203}} + {{716, 594}, {151, 203}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -1666,7 +1750,7 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{519, 433}, {150, 43}} + {{867, 574}, {150, 43}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -1674,15 +1758,13 @@ com.apple.InterfaceBuilder.CocoaPlugin - {{608, 393}, {238, 103}} - com.apple.InterfaceBuilder.CocoaPlugin + {{867, 534}, {238, 103}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -1693,7 +1775,7 @@ com.apple.InterfaceBuilder.CocoaPlugin - {{326, 473}, {196, 183}} + {{737, 485}, {179, 143}} com.apple.InterfaceBuilder.CocoaPlugin {{323, 672}, {199, 203}} @@ -1711,6 +1793,11 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -1732,11 +1819,30 @@ - 819 + 831 YES + + NetSurfAppDelegate + NSObject + + historyWindow + NSWindow + + + historyWindow + + historyWindow + NSWindow + + + + IBProjectSource + NetSurfAppDelegate.h + + ScrollableView NSView diff --git a/cocoa/res/NetSurf-Info.plist b/cocoa/res/NetSurf-Info.plist index 1d756f321..a5c540f55 100644 --- a/cocoa/res/NetSurf-Info.plist +++ b/cocoa/res/NetSurf-Info.plist @@ -28,5 +28,17 @@ MainMenu NSPrincipalClass NetSurfApp + CFBundleURLTypes + + + CFBundleURLName + org.netsurf-browser.NetSurf.URI + CFBundleURLSchemes + + http + https + + + -- cgit v1.2.3