From 4ed1832fe776158c0682393ca4794e63ca53962f Mon Sep 17 00:00:00 2001 From: Sven Weidauer Date: Mon, 31 Jan 2011 18:38:03 +0000 Subject: Implemented preferences window. svn path=/trunk/netsurf/; revision=11565 --- cocoa/Makefile.target | 3 +- cocoa/NetSurf.xcodeproj/project.pbxproj | 6 + cocoa/NetSurfAppDelegate.h | 5 + cocoa/NetSurfAppDelegate.m | 10 + cocoa/PreferencesWindowController.h | 29 ++ cocoa/PreferencesWindowController.m | 58 ++++ cocoa/res/MainMenu.xib | 19 +- cocoa/res/PreferencesWindow.xib | 531 ++++++++++++++++++++++++++++++++ 8 files changed, 658 insertions(+), 3 deletions(-) create mode 100644 cocoa/PreferencesWindowController.h create mode 100644 cocoa/PreferencesWindowController.m create mode 100644 cocoa/res/PreferencesWindow.xib diff --git a/cocoa/Makefile.target b/cocoa/Makefile.target index 2973fe5a0..336524254 100644 --- a/cocoa/Makefile.target +++ b/cocoa/Makefile.target @@ -71,6 +71,7 @@ S_COCOA := \ DownloadWindowController.m \ NetSurfAppDelegate.m \ NetsurfApp.m \ + PreferencesWindowController.m \ ScrollableView.m \ SearchWindowController.m \ URLFieldCell.m \ @@ -115,7 +116,7 @@ SOURCES := $(addprefix $(shell pwd)/,$(SOURCES)) EXETARGET := NetSurf -S_XIBS := MainMenu.xib Browser.xib BrowserWindow.xib DownloadWindow.xib SearchWindow.xib +S_XIBS := MainMenu.xib Browser.xib BrowserWindow.xib DownloadWindow.xib SearchWindow.xib PreferencesWindow.xib R_RESOURCES := default.css adblock.css quirks.css NetSurf.icns R_RESOURCES := $(addprefix cocoa/res/,$(R_RESOURCES)) diff --git a/cocoa/NetSurf.xcodeproj/project.pbxproj b/cocoa/NetSurf.xcodeproj/project.pbxproj index 24449e731..8df9dfa12 100644 --- a/cocoa/NetSurf.xcodeproj/project.pbxproj +++ b/cocoa/NetSurf.xcodeproj/project.pbxproj @@ -171,6 +171,9 @@ 2612269612D7AEBE00E10F91 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text; name = fr; path = fr.lproj/Messages; sourceTree = ""; }; 2622F1D512DCD84600CD5A62 /* TreeView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TreeView.h; sourceTree = ""; }; 2622F1D612DCD84600CD5A62 /* TreeView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TreeView.m; sourceTree = ""; }; + 2625095012F72A8F0090D236 /* PreferencesWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PreferencesWindow.xib; sourceTree = ""; }; + 2625095112F72AA70090D236 /* PreferencesWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PreferencesWindowController.h; sourceTree = ""; }; + 2625095212F72AA70090D236 /* PreferencesWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PreferencesWindowController.m; sourceTree = ""; }; 2636299412F699250048542C /* NetSurf.app */ = {isa = PBXFileReference; lastKnownFileType = wrapper.application; name = NetSurf.app; path = ../NetSurf.app; sourceTree = SOURCE_ROOT; }; 263629B312F69A290048542C /* Makefile.config */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; name = Makefile.config; path = ../Makefile.config; sourceTree = SOURCE_ROOT; }; 263629B412F69A290048542C /* Makefile.defaults */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; fileEncoding = 4; name = Makefile.defaults; path = ../Makefile.defaults; sourceTree = SOURCE_ROOT; }; @@ -527,6 +530,8 @@ 265F310F12D663C20048B600 /* Resources */, 26CDCEB212E702D8004FC66B /* PSMTabBarControl */, 265F30AB12D6637E0048B600 /* Prefix.pch */, + 2625095112F72AA70090D236 /* PreferencesWindowController.h */, + 2625095212F72AA70090D236 /* PreferencesWindowController.m */, ); name = "Cocoa Frontend"; sourceTree = ""; @@ -545,6 +550,7 @@ 26AFEAF012E042F9005AD082 /* DownloadWindow.xib */, 26CDCFF212E70AD1004FC66B /* BrowserWindow.xib */, 2666DC5B12F6D1770045E8B6 /* SearchWindow.xib */, + 2625095012F72A8F0090D236 /* PreferencesWindow.xib */, ); name = Resources; path = res; diff --git a/cocoa/NetSurfAppDelegate.h b/cocoa/NetSurfAppDelegate.h index 4852f6fd5..b4ea15e8f 100644 --- a/cocoa/NetSurfAppDelegate.h +++ b/cocoa/NetSurfAppDelegate.h @@ -19,17 +19,22 @@ #import @class SearchWindowController; +@class PreferencesWindowController; @interface NetSurfAppDelegate : NSObject { NSWindow *historyWindow; SearchWindowController *search; + PreferencesWindowController *preferences; } @property (readwrite, retain, nonatomic) IBOutlet NSWindow *historyWindow; @property (readwrite, retain, nonatomic) SearchWindowController *search; +@property (readwrite, retain, nonatomic) PreferencesWindowController *preferences; - (IBAction) showSearchWindow: (id) sender; - (IBAction) searchForward: (id) sender; - (IBAction) searchBackward: (id) sender; +- (IBAction) showPreferences: (id) sender; + @end diff --git a/cocoa/NetSurfAppDelegate.m b/cocoa/NetSurfAppDelegate.m index f6ddc2146..551800de8 100644 --- a/cocoa/NetSurfAppDelegate.m +++ b/cocoa/NetSurfAppDelegate.m @@ -18,6 +18,7 @@ #import "NetSurfAppDelegate.h" #import "cocoa/SearchWindowController.h" +#import "cocoa/PreferencesWindowController.h" #import "desktop/browser.h" #import "desktop/options.h" @@ -33,6 +34,7 @@ @synthesize historyWindow; @synthesize search; +@synthesize preferences; - (void) newDocument: (id) sender; { @@ -92,6 +94,14 @@ return YES; } +- (IBAction) showPreferences: (id) sender; +{ + if (preferences == nil) { + [self setPreferences: [[[PreferencesWindowController alloc] init] autorelease]]; + } + [preferences showWindow: sender]; +} + // Application delegate methods - (BOOL) applicationOpenUntitledFile: (NSApplication *)sender; diff --git a/cocoa/PreferencesWindowController.h b/cocoa/PreferencesWindowController.h new file mode 100644 index 000000000..8f72907a3 --- /dev/null +++ b/cocoa/PreferencesWindowController.h @@ -0,0 +1,29 @@ +/* + * 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 PreferencesWindowController : NSWindowController + +@property (readwrite, copy, nonatomic) NSString *homepageURL; + +- (IBAction) useCurrentPageAsHomepage: (id) sender; + +@end diff --git a/cocoa/PreferencesWindowController.m b/cocoa/PreferencesWindowController.m new file mode 100644 index 000000000..2425589f9 --- /dev/null +++ b/cocoa/PreferencesWindowController.m @@ -0,0 +1,58 @@ +/* + * 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 "cocoa/PreferencesWindowController.h" +#import "cocoa/NetsurfApp.h" +#import "cocoa/gui.h" +#import "cocoa/BrowserViewController.h" + +#import "desktop/browser.h" +#import "content/content.h" +#import "desktop/options.h" + +@implementation PreferencesWindowController + +- init; +{ + if ((self = [super initWithWindowNibName: @"PreferencesWindow"]) == nil) return nil; + + return self; +} + +- (IBAction) useCurrentPageAsHomepage: (id) sender; +{ + struct browser_window *bw = [[(NetSurfApp *)NSApp frontTab] browser]; + const char *url = content_get_url( bw->current_content ); + [self setHomepageURL: [NSString stringWithUTF8String: url]]; +} + +- (void) setHomepageURL: (NSString *) newUrl; +{ + free( option_homepage_url ); + option_homepage_url = strdup( [newUrl UTF8String] ); + [[NSUserDefaults standardUserDefaults] setObject: newUrl forKey: kHomepageURLOption]; + [[NSUserDefaults standardUserDefaults] synchronize]; +} + +- (NSString *) homepageURL; +{ + return [NSString stringWithUTF8String: option_homepage_url]; +} + +@end diff --git a/cocoa/res/MainMenu.xib b/cocoa/res/MainMenu.xib index a87221761..7ca05ec2b 100644 --- a/cocoa/res/MainMenu.xib +++ b/cocoa/res/MainMenu.xib @@ -12,7 +12,7 @@ YES - + YES @@ -1035,6 +1035,14 @@ 844 + + + showPreferences: + + + + 845 + @@ -1872,7 +1880,7 @@ - 844 + 845 @@ -2108,6 +2116,7 @@ YES searchBackward: searchForward: + showPreferences: showSearchWindow: @@ -2115,6 +2124,7 @@ id id id + id @@ -2123,6 +2133,7 @@ YES searchBackward: searchForward: + showPreferences: showSearchWindow: @@ -2135,6 +2146,10 @@ searchForward: id + + showPreferences: + id + showSearchWindow: id diff --git a/cocoa/res/PreferencesWindow.xib b/cocoa/res/PreferencesWindow.xib new file mode 100644 index 000000000..900ad3b6b --- /dev/null +++ b/cocoa/res/PreferencesWindow.xib @@ -0,0 +1,531 @@ + + + + 1060 + 10J567 + 804 + 1038.35 + 462.00 + + com.apple.InterfaceBuilder.CocoaPlugin + 804 + + + YES + + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + + + YES + + YES + + + YES + + + + YES + + PreferencesWindowController + + + FirstResponder + + + NSApplication + + + 7 + 2 + {{196, 362}, {455, 148}} + 1618477056 + Preferences + NSWindow + + {1.79769e+308, 1.79769e+308} + + + 256 + + YES + + + 268 + {{98, 106}, {337, 22}} + + YES + + -1804468671 + 272630784 + + + LucidaGrande + 13 + 1044 + + + YES + + 6 + System + textBackgroundColor + + 3 + MQA + + + + 6 + System + textColor + + 3 + MAA + + + + + + + 268 + {{17, 108}, {76, 17}} + + YES + + 68288064 + 272630784 + Homepage: + + + + 6 + System + controlColor + + 3 + MC42NjY2NjY2NjY3AA + + + + 6 + System + controlTextColor + + + + + + + 268 + {{293, 70}, {148, 32}} + + YES + + 67239424 + 134217728 + Use current page + + + -2038284033 + 129 + + + 200 + 25 + + + + + 268 + {{96, 38}, {234, 18}} + + YES + + -2080244224 + 0 + Cancel downloads without asking + + + 1211912703 + 2 + + NSImage + NSSwitch + + + NSSwitch + + + + 200 + 25 + + + + + 268 + {{96, 18}, {241, 18}} + + YES + + -2080244224 + 0 + Close multiple tabs without asking + + + 1211912703 + 2 + + + + + 200 + 25 + + + + {455, 148} + + + {{0, 0}, {1680, 1028}} + {1.79769e+308, 1.79769e+308} + + + YES + + + + + YES + + + window + + + + 3 + + + + value: values.AlwaysCancelDownload + + + + + + value: values.AlwaysCancelDownload + value + values.AlwaysCancelDownload + 2 + + + 21 + + + + value: values.AlwaysCloseMultipleTabs + + + + + + value: values.AlwaysCloseMultipleTabs + value + values.AlwaysCloseMultipleTabs + 2 + + + 22 + + + + useCurrentPageAsHomepage: + + + + 23 + + + + value: homepageURL + + + + + + value: homepageURL + value + homepageURL + 2 + + + 25 + + + + + YES + + 0 + + + + + + -2 + + + File's Owner + + + -1 + + + First Responder + + + -3 + + + Application + + + 1 + + + YES + + + + + + 2 + + + YES + + + + + + + + + + 9 + + + YES + + + + + + 10 + + + + + 11 + + + YES + + + + + + 12 + + + + + 13 + + + YES + + + + + + 14 + + + + + 15 + + + YES + + + + + + 16 + + + + + 17 + + + YES + + + + + + 18 + + + + + 19 + + + + + + + YES + + YES + 1.IBEditorWindowLastContentRect + 1.IBPluginDependency + 1.IBWindowTemplateEditedContentRect + 1.NSWindowTemplate.visibleAtLaunch + 1.WindowOrigin + 1.editorWindowContentRectSynchronizationRect + 10.IBPluginDependency + 11.IBPluginDependency + 11.IBViewBoundsToFrameTransform + 12.IBPluginDependency + 13.IBPluginDependency + 13.IBViewBoundsToFrameTransform + 14.IBPluginDependency + 15.IBPluginDependency + 16.IBPluginDependency + 17.IBPluginDependency + 17.IBViewBoundsToFrameTransform + 18.IBPluginDependency + 2.IBPluginDependency + 9.IBPluginDependency + 9.IBViewBoundsToFrameTransform + + + YES + {{222, 133}, {455, 148}} + com.apple.InterfaceBuilder.CocoaPlugin + {{222, 133}, {455, 148}} + + {196, 240} + {{202, 428}, {480, 270}} + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + P4AAAL+AAABCYAAAw2sAAA + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + P4AAAL+AAABClgAAw3wAAA + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + P4AAAL+AAABCwAAAwggAAA + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + P4AAAL+AAABDSQAAw2sAAA + + + + + YES + + + YES + + + + + YES + + + YES + + + + 25 + + + + YES + + NSApplication + + IBProjectSource + PSMTabBarControl/PSMTabDragAssistant.h + + + + NSObject + + IBProjectSource + PSMTabBarControl/PSMTabBarCell.h + + + + NSObject + + IBProjectSource + PSMTabBarControl/PSMTabBarControl.h + + + + PreferencesWindowController + NSWindowController + + useCurrentPageAsHomepage: + id + + + useCurrentPageAsHomepage: + + useCurrentPageAsHomepage: + id + + + + IBProjectSource + PreferencesWindowController.h + + + + + 0 + IBCocoaFramework + + com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 + + + YES + ../NetSurf.xcodeproj + 3 + + NSSwitch + {15, 15} + + + -- cgit v1.2.3