From c7596d49fec35465d263655335bc9afcbc7ccb92 Mon Sep 17 00:00:00 2001 From: michael starke Date: Thu, 9 May 2013 14:02:30 +0200 Subject: [PATCH] Refactoring for document based application --- MacPass.xcodeproj/project.pbxproj | 32 ++++++------ .../{MainWindow.xib => DocumentWindow.xib} | 25 ++++++--- MacPass/MPAppDelegate.h | 4 -- MacPass/MPAppDelegate.m | 27 ++-------- MacPass/MPDocument.m | 35 ++++++++++--- ...troller.h => MPDocumentWindowController.h} | 7 +-- ...troller.m => MPDocumentWindowController.m} | 52 ++----------------- MacPass/MPEntryViewController.m | 4 +- MacPass/MPPasswordEditViewController.m | 6 +-- ...troller.h => MPSettingsWindowController.h} | 2 +- ...troller.m => MPSettingsWindowController.m} | 6 +-- MacPass/MPToolbarDelegate.h | 2 +- MacPass/MacPass-Info.plist | 4 +- MacPass/SettingsWindow.xib | 19 ++----- MacPass/WelcomeView.xib | 51 ++---------------- MacPass/en.lproj/MainMenu.xib | 47 ++++------------- 16 files changed, 100 insertions(+), 223 deletions(-) rename MacPass/{MainWindow.xib => DocumentWindow.xib} (93%) rename MacPass/{MPMainWindowController.h => MPDocumentWindowController.h} (89%) rename MacPass/{MPMainWindowController.m => MPDocumentWindowController.m} (85%) rename MacPass/{MPSettingsController.h => MPSettingsWindowController.h} (79%) rename MacPass/{MPSettingsController.m => MPSettingsWindowController.m} (97%) diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index cd7ec2bb..9dbe6db9 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -81,7 +81,7 @@ 4C77E37D15B84A240093A587 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C77E37B15B84A240093A587 /* MainMenu.xib */; }; 4C7E832A172DE2F2002493D8 /* MPPasswordEditViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C7E8329172DE2F2002493D8 /* MPPasswordEditViewController.m */; }; 4C811C8316ECD06E00C4BAC6 /* MPKeyfilePathControlDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C811C8216ECD06E00C4BAC6 /* MPKeyfilePathControlDelegate.m */; }; - 4C83814215BF4677001AE468 /* MPMainWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C83814115BF4677001AE468 /* MPMainWindowController.m */; }; + 4C83814215BF4677001AE468 /* MPDocumentWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C83814115BF4677001AE468 /* MPDocumentWindowController.m */; }; 4C888C9016EB6C91003D34A1 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 4C888C8E16EB6C91003D34A1 /* Localizable.strings */; }; 4C888C9316EB6F5E003D34A1 /* MPToolbarItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C888C9216EB6F5E003D34A1 /* MPToolbarItem.m */; }; 4C888C9716EB754B003D34A1 /* MPActionHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C888C9616EB754B003D34A1 /* MPActionHelper.m */; }; @@ -90,7 +90,7 @@ 4CA0B2ED15BCADAC00654E32 /* SettingsWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4CA0B2EC15BCADAC00654E32 /* SettingsWindow.xib */; }; 4CA0B2F015BCADC800654E32 /* GeneralSettings.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4CA0B2EF15BCADC800654E32 /* GeneralSettings.xib */; }; 4CA0B2F915BCAF6700654E32 /* MPGeneralSettingsController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CA0B2F815BCAF6700654E32 /* MPGeneralSettingsController.m */; }; - 4CA0B2FC15BCAF8600654E32 /* MPSettingsController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CA0B2FB15BCAF8600654E32 /* MPSettingsController.m */; }; + 4CA0B2FC15BCAF8600654E32 /* MPSettingsWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CA0B2FB15BCAF8600654E32 /* MPSettingsWindowController.m */; }; 4CAC6F7816D2B54800D79D5E /* MPMainWindowSplitViewDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CAC6F7716D2B54800D79D5E /* MPMainWindowSplitViewDelegate.m */; }; 4CACB72C16F7C9B600D47C9E /* KdbEntry+Copying.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CACB72B16F7C9B600D47C9E /* KdbEntry+Copying.m */; }; 4CACB72F16F7CA5100D47C9E /* Kdb4Entry+Copying.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CACB72E16F7CA5100D47C9E /* Kdb4Entry+Copying.m */; }; @@ -112,7 +112,7 @@ 4CD78ABE16D155FF00768A1D /* 09_IdentityTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4CD78AB916D155FF00768A1D /* 09_IdentityTemplate.pdf */; }; 4CD78ABF16D155FF00768A1D /* 10_ContactTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4CD78ABA16D155FF00768A1D /* 10_ContactTemplate.pdf */; }; 4CD78AC016D155FF00768A1D /* 11_CameraTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4CD78ABB16D155FF00768A1D /* 11_CameraTemplate.pdf */; }; - 4CD884B715BD47080042BBF8 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4CD884B615BD47080042BBF8 /* MainWindow.xib */; }; + 4CD884B715BD47080042BBF8 /* DocumentWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4CD884B615BD47080042BBF8 /* DocumentWindow.xib */; }; 4CDF01A316D1B76700D0AC08 /* MPEntryViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CDF01A216D1B76700D0AC08 /* MPEntryViewController.m */; }; 4CE39ABF16ECE34A000FE29D /* MPIconSelectViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CE39ABE16ECE34A000FE29D /* MPIconSelectViewController.m */; }; 4CE39AC116ECE359000FE29D /* IconSelection.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4CE39AC016ECE359000FE29D /* IconSelection.xib */; }; @@ -262,8 +262,8 @@ 4C7E8329172DE2F2002493D8 /* MPPasswordEditViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPPasswordEditViewController.m; sourceTree = ""; }; 4C811C8116ECD06E00C4BAC6 /* MPKeyfilePathControlDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPKeyfilePathControlDelegate.h; sourceTree = ""; }; 4C811C8216ECD06E00C4BAC6 /* MPKeyfilePathControlDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPKeyfilePathControlDelegate.m; sourceTree = ""; }; - 4C83814015BF4677001AE468 /* MPMainWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPMainWindowController.h; sourceTree = ""; }; - 4C83814115BF4677001AE468 /* MPMainWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPMainWindowController.m; sourceTree = ""; }; + 4C83814015BF4677001AE468 /* MPDocumentWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPDocumentWindowController.h; sourceTree = ""; }; + 4C83814115BF4677001AE468 /* MPDocumentWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPDocumentWindowController.m; sourceTree = ""; }; 4C888C8F16EB6C91003D34A1 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; 4C888C9116EB6F5E003D34A1 /* MPToolbarItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPToolbarItem.h; sourceTree = ""; }; 4C888C9216EB6F5E003D34A1 /* MPToolbarItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPToolbarItem.m; sourceTree = ""; }; @@ -276,8 +276,8 @@ 4CA0B2EF15BCADC800654E32 /* GeneralSettings.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = GeneralSettings.xib; sourceTree = ""; }; 4CA0B2F715BCAF6700654E32 /* MPGeneralSettingsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPGeneralSettingsController.h; sourceTree = ""; }; 4CA0B2F815BCAF6700654E32 /* MPGeneralSettingsController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPGeneralSettingsController.m; sourceTree = ""; }; - 4CA0B2FA15BCAF8600654E32 /* MPSettingsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPSettingsController.h; sourceTree = ""; }; - 4CA0B2FB15BCAF8600654E32 /* MPSettingsController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPSettingsController.m; sourceTree = ""; }; + 4CA0B2FA15BCAF8600654E32 /* MPSettingsWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPSettingsWindowController.h; sourceTree = ""; }; + 4CA0B2FB15BCAF8600654E32 /* MPSettingsWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPSettingsWindowController.m; sourceTree = ""; }; 4CA0B30D15BCB6FD00654E32 /* MPSettingsTab.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MPSettingsTab.h; sourceTree = ""; }; 4CAC6F7616D2B54800D79D5E /* MPMainWindowSplitViewDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPMainWindowSplitViewDelegate.h; sourceTree = ""; }; 4CAC6F7716D2B54800D79D5E /* MPMainWindowSplitViewDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPMainWindowSplitViewDelegate.m; sourceTree = ""; }; @@ -314,7 +314,7 @@ 4CD78AB916D155FF00768A1D /* 09_IdentityTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = 09_IdentityTemplate.pdf; sourceTree = ""; }; 4CD78ABA16D155FF00768A1D /* 10_ContactTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = 10_ContactTemplate.pdf; sourceTree = ""; }; 4CD78ABB16D155FF00768A1D /* 11_CameraTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = 11_CameraTemplate.pdf; sourceTree = ""; }; - 4CD884B615BD47080042BBF8 /* MainWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = ""; }; + 4CD884B615BD47080042BBF8 /* DocumentWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = DocumentWindow.xib; sourceTree = ""; }; 4CDF01A116D1B76700D0AC08 /* MPEntryViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPEntryViewController.h; sourceTree = ""; }; 4CDF01A216D1B76700D0AC08 /* MPEntryViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPEntryViewController.m; sourceTree = ""; }; 4CE39ABD16ECE34A000FE29D /* MPIconSelectViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPIconSelectViewController.h; sourceTree = ""; }; @@ -746,10 +746,10 @@ 4CE8247016E2E96500573141 /* Window Controller */ = { isa = PBXGroup; children = ( - 4CA0B2FA15BCAF8600654E32 /* MPSettingsController.h */, - 4CA0B2FB15BCAF8600654E32 /* MPSettingsController.m */, - 4C83814015BF4677001AE468 /* MPMainWindowController.h */, - 4C83814115BF4677001AE468 /* MPMainWindowController.m */, + 4CA0B2FA15BCAF8600654E32 /* MPSettingsWindowController.h */, + 4CA0B2FB15BCAF8600654E32 /* MPSettingsWindowController.m */, + 4C83814015BF4677001AE468 /* MPDocumentWindowController.h */, + 4C83814115BF4677001AE468 /* MPDocumentWindowController.m */, 4CE8246D16E2E93400573141 /* MPOverlayWindowController.h */, 4CE8246E16E2E93400573141 /* MPOverlayWindowController.m */, ); @@ -770,7 +770,7 @@ 4CE8247216E2E99F00573141 /* Windows */ = { isa = PBXGroup; children = ( - 4CD884B615BD47080042BBF8 /* MainWindow.xib */, + 4CD884B615BD47080042BBF8 /* DocumentWindow.xib */, 4C431BCE16E2BAB000700A81 /* OverlayWindow.xib */, 4C1DDCDC1711ECEB00C98DA3 /* PasswordCreatorWindow.xib */, ); @@ -836,7 +836,7 @@ 4C77E37D15B84A240093A587 /* MainMenu.xib in Resources */, 4CA0B2ED15BCADAC00654E32 /* SettingsWindow.xib in Resources */, 4CA0B2F015BCADC800654E32 /* GeneralSettings.xib in Resources */, - 4CD884B715BD47080042BBF8 /* MainWindow.xib in Resources */, + 4CD884B715BD47080042BBF8 /* DocumentWindow.xib in Resources */, 4C6B0E8C16C9B99B00A9ED23 /* PasswordInputView.xib in Resources */, 4C25D58516CF0F8800F6806C /* WelcomeView.xib in Resources */, 4C25D58716CF0FAA00F6806C /* EntryView.xib in Resources */, @@ -899,8 +899,8 @@ 4CBA981815BA0DB600721965 /* MPDatabaseDocument.m in Sources */, 4CC6259115BA1C99002F5B11 /* MPOutlineViewDelegate.m in Sources */, 4CA0B2F915BCAF6700654E32 /* MPGeneralSettingsController.m in Sources */, - 4CA0B2FC15BCAF8600654E32 /* MPSettingsController.m in Sources */, - 4C83814215BF4677001AE468 /* MPMainWindowController.m in Sources */, + 4CA0B2FC15BCAF8600654E32 /* MPSettingsWindowController.m in Sources */, + 4C83814215BF4677001AE468 /* MPDocumentWindowController.m in Sources */, 4C669B7F16760ED100DD0774 /* AesInputStream.m in Sources */, 4C669B8016760ED100DD0774 /* AesOutputStream.m in Sources */, 4C669B8116760ED100DD0774 /* Arc4RandomStream.m in Sources */, diff --git a/MacPass/MainWindow.xib b/MacPass/DocumentWindow.xib similarity index 93% rename from MacPass/MainWindow.xib rename to MacPass/DocumentWindow.xib index b9a1b01a..7813a278 100644 --- a/MacPass/MainWindow.xib +++ b/MacPass/DocumentWindow.xib @@ -2,10 +2,10 @@ 1080 - 12C3103 + 12D78 3084 - 1187.34 - 625.00 + 1187.37 + 626.00 com.apple.InterfaceBuilder.CocoaPlugin 3084 @@ -26,7 +26,7 @@ - MPMainWindowController + MPDocumentWindowController FirstResponder @@ -225,7 +225,7 @@ com.apple.InterfaceBuilder.CocoaPlugin {{357, 418}, {480, 270}} - + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -241,8 +241,19 @@ - MPMainWindowController + MPDocumentWindowController NSWindowController + + editPassword: + id + + + editPassword: + + editPassword: + id + + NSView NSView @@ -279,7 +290,7 @@ IBProjectSource - ./Classes/MPMainWindowController.h + ./Classes/MPDocumentWindowController.h diff --git a/MacPass/MPAppDelegate.h b/MacPass/MPAppDelegate.h index 614a0bdc..e92dcd29 100644 --- a/MacPass/MPAppDelegate.h +++ b/MacPass/MPAppDelegate.h @@ -22,7 +22,6 @@ typedef enum { @property (retain) IBOutlet NSWindow *passwordCreatorWindow; -- (IBAction)showMainWindow:(id)sender; - (IBAction)showPasswordCreator:(id)sender; - (NSString *)applicationName; @@ -33,7 +32,4 @@ typedef enum { */ - (NSArray *)contextMenuItemsWithItems:(MPContextMenuItemsFlags)flags; -- (void)openDocument:(id)sender; -- (void)newDocument:(id)sender; - @end \ No newline at end of file diff --git a/MacPass/MPAppDelegate.m b/MacPass/MPAppDelegate.m index 7b10540f..394e2bec 100644 --- a/MacPass/MPAppDelegate.m +++ b/MacPass/MPAppDelegate.m @@ -8,8 +8,8 @@ #import "MPAppDelegate.h" -#import "MPMainWindowController.h" -#import "MPSettingsController.h" +#import "MPDocumentWindowController.h" +#import "MPSettingsWindowController.h" #import "MPDatabaseController.h" #import "MPPasswordCreatorViewController.h" #import "MPActionHelper.h" @@ -18,8 +18,7 @@ @interface MPAppDelegate () -@property (retain, nonatomic) MPSettingsController *settingsController; -@property (retain, nonatomic) MPMainWindowController *mainWindowController; +@property (retain, nonatomic) MPSettingsWindowController *settingsController; @property (retain, nonatomic) MPPasswordCreatorViewController *passwordCreatorController; - (IBAction)showPreferences:(id)sender; @@ -33,14 +32,11 @@ } - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { - self.mainWindowController = [[[MPMainWindowController alloc] init] autorelease]; - [self.mainWindowController showWindow:[self.mainWindowController window]]; } - (void)dealloc { [_settingsController release]; - [_mainWindowController release]; [_passwordCreatorController release]; [super dealloc]; } @@ -50,24 +46,9 @@ } #pragma mark Menu Actions - -- (void)showMainWindow:(id)sender { - [self.mainWindowController showMainWindow:sender]; -} - -- (void)newDocument:(id)sender { - [self.mainWindowController showMainWindow:sender]; - [self.mainWindowController newDocument:sender]; -} - -- (void)openDocument:(id)sender { - [self.mainWindowController showMainWindow:sender]; - [self.mainWindowController openDocument:sender]; -} - - (void)showPreferences:(id)sender { if(self.settingsController == nil) { - self.settingsController = [[[MPSettingsController alloc] init] autorelease]; + self.settingsController = [[[MPSettingsWindowController alloc] init] autorelease]; } [self.settingsController showSettings]; } diff --git a/MacPass/MPDocument.m b/MacPass/MPDocument.m index ec41e617..0456ad1f 100644 --- a/MacPass/MPDocument.m +++ b/MacPass/MPDocument.m @@ -7,6 +7,7 @@ // #import "MPDocument.h" +#import "MPDocumentWindowController.h" #import "KdbLib.h" #import "Kdb3Node.h" #import "Kdb4Node.h" @@ -51,14 +52,9 @@ } - (void) makeWindowControllers { -} - -- (NSString *)windowNibName -{ - // Override returning the nib file name of the document - // If you need to use a subclass of NSWindowController or if your document supports multiple NSWindowControllers, you should remove this method and override -makeWindowControllers instead. - return @"MainWindow"; - //return @"MPDocument"; + + MPDocumentWindowController *windowController = [[MPDocumentWindowController alloc] init]; + [self addWindowController:windowController]; } - (void)windowControllerDidLoadNib:(NSWindowController *)aController @@ -85,6 +81,29 @@ - (BOOL)readFromURL:(NSURL *)url ofType:(NSString *)typeName error:(NSError **)outError { self.file = url; return YES; + // tell The window controller to display decrypt view +// - (void)openDocument:(id)sender { +// +// if(!self.passwordInputController) { +// self.passwordInputController = [[[MPPasswordInputController alloc] init] autorelease]; +// } +// +// NSOpenPanel *openPanel = [NSOpenPanel openPanel]; +// [openPanel setCanChooseDirectories:NO]; +// [openPanel setCanChooseFiles:YES]; +// [openPanel setCanCreateDirectories:NO]; +// [openPanel setAllowsMultipleSelection:NO]; +// [openPanel setAllowedFileTypes:@[ @"kdbx", @"kdb"]]; +// [openPanel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result){ +// if(result == NSFileHandlingPanelOKButton) { +// NSURL *file = [[openPanel URLs] lastObject]; +// self.passwordInputController.fileURL = file; +// [self _setContentViewController:self.passwordInputController]; +// } +// }]; +// } +// + } - (BOOL)decryptWithPassword:(NSString *)password keyFileURL:(NSURL *)keyFileURL { diff --git a/MacPass/MPMainWindowController.h b/MacPass/MPDocumentWindowController.h similarity index 89% rename from MacPass/MPMainWindowController.h rename to MacPass/MPDocumentWindowController.h index 77f18763..22ddd101 100644 --- a/MacPass/MPMainWindowController.h +++ b/MacPass/MPDocumentWindowController.h @@ -17,7 +17,7 @@ @class MPCreationViewController; -@interface MPMainWindowController : NSWindowController +@interface MPDocumentWindowController : NSWindowController @property (readonly, retain) MPPasswordInputController *passwordInputController; @property (readonly, retain) MPPasswordEditViewController *passwordEditController; @@ -27,11 +27,6 @@ @property (readonly, retain) MPCreationViewController *creationViewController; - -/* Document handling */ -- (void)newDocument:(id)sender; -- (void)openDocument:(id)sender; - - (void)showEntries; - (void)showMainWindow:(id)sender; - (void)performFindPanelAction:(id)sender; diff --git a/MacPass/MPMainWindowController.m b/MacPass/MPDocumentWindowController.m similarity index 85% rename from MacPass/MPMainWindowController.m rename to MacPass/MPDocumentWindowController.m index fe4ff6c5..a2c1051d 100644 --- a/MacPass/MPMainWindowController.m +++ b/MacPass/MPDocumentWindowController.m @@ -6,7 +6,7 @@ // Copyright (c) 2012 HicknHack Software GmbH. All rights reserved. // -#import "MPMainWindowController.h" +#import "MPDocumentWindowController.h" #import "MPDatabaseController.h" #import "MPDatabaseDocument.h" #import "MPPasswordInputController.h" @@ -18,7 +18,7 @@ #import "MPInspectorTabViewController.h" #import "MPAppDelegate.h" -@interface MPMainWindowController () +@interface MPDocumentWindowController () @property (assign) IBOutlet NSView *outlineView; @property (assign) IBOutlet NSSplitView *splitView; @@ -47,7 +47,7 @@ @end -@implementation MPMainWindowController +@implementation MPDocumentWindowController -(id)init { self = [super initWithWindowNibName:@"MainWindow" owner:self]; @@ -226,26 +226,6 @@ //[self showWindow:self.window]; } -- (void)openDocument:(id)sender { - - if(!self.passwordInputController) { - self.passwordInputController = [[[MPPasswordInputController alloc] init] autorelease]; - } - - NSOpenPanel *openPanel = [NSOpenPanel openPanel]; - [openPanel setCanChooseDirectories:NO]; - [openPanel setCanChooseFiles:YES]; - [openPanel setCanCreateDirectories:NO]; - [openPanel setAllowsMultipleSelection:NO]; - [openPanel setAllowedFileTypes:@[ @"kdbx", @"kdb"]]; - [openPanel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result){ - if(result == NSFileHandlingPanelOKButton) { - NSURL *file = [[openPanel URLs] lastObject]; - self.passwordInputController.fileURL = file; - [self _setContentViewController:self.passwordInputController]; - } - }]; -} - (void)clearOutlineSelection:(id)sender { [self.outlineViewController clearSelection]; } @@ -257,32 +237,6 @@ [self _setContentViewController:self.passwordEditController]; } -- (void)newDocument:(id)sender { - // if (!self.creationViewController) { - // self.creationViewController = [[[MPCreationViewController alloc] init] autorelease]; - // } - // - // NSSavePanel *savePanel = [NSSavePanel savePanel]; - // [savePanel setAllowedFileTypes:@[@"kdbx", @"kdb"]]; - // [savePanel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) { - // if (result == NSFileHandlingPanelOKButton) { - // NSURL *file = [savePanel URL]; - // NSLog(@"Will create file at: %@", file); - // self.creationViewController.fileURL = file; - // [self _setContentViewController:self.creationViewController]; - // } - // }]; -} - -- (void)saveDocument:(id)sender -{ - NSLog(@"Attempting to save document"); - if ([[MPDatabaseController defaultController].database save]) - NSLog(@"Save successful"); - else - NSLog(@"Save failed"); -} - #pragma mark Helper - (NSSearchField *)locateToolbarSearchField { diff --git a/MacPass/MPEntryViewController.m b/MacPass/MPEntryViewController.m index c443e5a5..6e6d272c 100644 --- a/MacPass/MPEntryViewController.m +++ b/MacPass/MPEntryViewController.m @@ -12,7 +12,7 @@ #import "MPDatabaseController.h" #import "MPDatabaseDocument.h" #import "MPIconHelper.h" -#import "MPMainWindowController.h" +#import "MPDocumentWindowController.h" #import "MPPasteBoardController.h" #import "MPOverlayWindowController.h" #import "KdbGroup+MPAdditions.h" @@ -325,7 +325,7 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername"; return; // nothign to to } - [((MPMainWindowController *)[[self.view window] windowController]) clearOutlineSelection:nil]; + [((MPDocumentWindowController *)[[self.view window] windowController]) clearOutlineSelection:nil]; self.isStatusBarVisible = YES; self.tableToTop.constant = [self.filterBar frame].size.height; diff --git a/MacPass/MPPasswordEditViewController.m b/MacPass/MPPasswordEditViewController.m index 9c62e7c5..c65b9fcb 100644 --- a/MacPass/MPPasswordEditViewController.m +++ b/MacPass/MPPasswordEditViewController.m @@ -8,7 +8,7 @@ #import "MPPasswordEditViewController.h" #import "MPKeyfilePathControlDelegate.h" -#import "MPMainWindowController.h" +#import "MPDocumentWindowController.h" #import "MPDatabaseController.h" #import "MPDatabaseDocument.h" @@ -54,13 +54,13 @@ database.key = [self.keyfilePathControl URL]; database.password = [self.passwordTextField stringValue]; [database save]; - MPMainWindowController *mainWindowController = (MPMainWindowController *)[[[self view] window] windowController]; + MPDocumentWindowController *mainWindowController = (MPDocumentWindowController *)[[[self view] window] windowController]; [mainWindowController showEntries]; // save automatically? } - (IBAction)_cancel:(id)sender { - MPMainWindowController *mainWindowController = (MPMainWindowController *)[[[self view] window] windowController]; + MPDocumentWindowController *mainWindowController = (MPDocumentWindowController *)[[[self view] window] windowController]; [mainWindowController showEntries]; } @end diff --git a/MacPass/MPSettingsController.h b/MacPass/MPSettingsWindowController.h similarity index 79% rename from MacPass/MPSettingsController.h rename to MacPass/MPSettingsWindowController.h index b0cb800f..19172306 100644 --- a/MacPass/MPSettingsController.h +++ b/MacPass/MPSettingsWindowController.h @@ -10,7 +10,7 @@ @protocol MPSettingsTab; -@interface MPSettingsController : NSWindowController +@interface MPSettingsWindowController : NSWindowController - (void)showSettings; - (void)showSettingsTabWithIdentifier:(NSString *)identifier; diff --git a/MacPass/MPSettingsController.m b/MacPass/MPSettingsWindowController.m similarity index 97% rename from MacPass/MPSettingsController.m rename to MacPass/MPSettingsWindowController.m index c60e0932..9978a890 100644 --- a/MacPass/MPSettingsController.m +++ b/MacPass/MPSettingsWindowController.m @@ -6,10 +6,10 @@ // Copyright (c) 2012 HicknHack Software GmbH. All rights reserved. // -#import "MPSettingsController.h" +#import "MPSettingsWindowController.h" #import "MPGeneralSettingsController.h" -@interface MPSettingsController () +@interface MPSettingsWindowController () @property (retain, nonatomic) NSToolbar *toolbar; @property (retain, nonatomic) NSMutableDictionary *settingsController; @@ -21,7 +21,7 @@ @end -@implementation MPSettingsController +@implementation MPSettingsWindowController -(id)init { self = [super initWithWindowNibName:@"SettingsWindow"]; diff --git a/MacPass/MPToolbarDelegate.h b/MacPass/MPToolbarDelegate.h index 560a6fc9..1c810024 100644 --- a/MacPass/MPToolbarDelegate.h +++ b/MacPass/MPToolbarDelegate.h @@ -8,7 +8,7 @@ #import -@class MPMainWindowController; +@class MPDocumentWindowController; @interface MPToolbarDelegate : NSObject diff --git a/MacPass/MacPass-Info.plist b/MacPass/MacPass-Info.plist index 8d986e29..1cf28993 100644 --- a/MacPass/MacPass-Info.plist +++ b/MacPass/MacPass-Info.plist @@ -15,6 +15,8 @@ KeePass2 Database CFBundleTypeRole Editor + NSDocumentClass + MPDocument CFBundleTypeExtensions @@ -44,7 +46,7 @@ CFBundleSignature ???? CFBundleVersion - 63C + 647 LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} NSHumanReadableCopyright diff --git a/MacPass/SettingsWindow.xib b/MacPass/SettingsWindow.xib index 497ba4ca..6b575f6d 100644 --- a/MacPass/SettingsWindow.xib +++ b/MacPass/SettingsWindow.xib @@ -24,7 +24,7 @@ - MPSettingsController + MPSettingsWindowController FirstResponder @@ -42,12 +42,10 @@ - + 256 {350, 200} - - {{0, 0}, {1680, 1028}} {10000000000000, 10000000000000} @@ -122,18 +120,7 @@ 89 - - - - MPSettingsController - NSWindowController - - IBProjectSource - ./Classes/MPSettingsController.h - - - - + 0 IBCocoaFramework YES diff --git a/MacPass/WelcomeView.xib b/MacPass/WelcomeView.xib index 913687c3..bf480fb5 100644 --- a/MacPass/WelcomeView.xib +++ b/MacPass/WelcomeView.xib @@ -2,10 +2,10 @@ 1080 - 12C60 + 12D78 3084 - 1187.34 - 625.00 + 1187.37 + 626.00 com.apple.InterfaceBuilder.CocoaPlugin 3084 @@ -26,7 +26,7 @@ - MPMainWindowController + MPDocumentWindowController FirstResponder @@ -35,7 +35,7 @@ NSApplication - + 268 @@ -43,8 +43,6 @@ 268 {{223, 214}, {152, 29}} - - _NS:1535 YES @@ -81,8 +79,6 @@ {597, 456} - - NSView @@ -227,43 +223,6 @@ - - MPMainWindowController - NSWindowController - - NSView - NSView - NSSplitView - NSTextField - NSView - - - - contentView - NSView - - - outlineView - NSView - - - splitView - NSSplitView - - - welcomeText - NSTextField - - - welcomeView - NSView - - - - IBProjectSource - ./Classes/MPMainWindowController.h - - NSLayoutConstraint NSObject diff --git a/MacPass/en.lproj/MainMenu.xib b/MacPass/en.lproj/MainMenu.xib index fa01fb7b..4521b152 100644 --- a/MacPass/en.lproj/MainMenu.xib +++ b/MacPass/en.lproj/MainMenu.xib @@ -519,15 +519,6 @@ - - - Show Main Window - 0 - 1048576 - 2147483647 - - - Show Password Creator @@ -845,14 +836,6 @@ 1175 - - - showMainWindow: - - - - 1178 - showPasswordCreator: @@ -1190,7 +1173,6 @@ - @@ -1280,11 +1262,6 @@ - - 1177 - - - 1179 @@ -1313,7 +1290,6 @@ 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 @@ -1442,22 +1418,19 @@ - MPMainWindowController + MPDocumentWindowController NSWindowController - - id - id - - - - changedFileType: - id - - + + editPassword: + id + + + editPassword: + editPassword: id - + NSView NSView @@ -1494,7 +1467,7 @@ IBProjectSource - ./Classes/MPMainWindowController.h + ./Classes/MPDocumentWindowController.h