From 93928c376e78ad0902571b6c7576c587f1e7f1f7 Mon Sep 17 00:00:00 2001 From: michael starke Date: Mon, 18 Feb 2013 16:33:11 +0100 Subject: [PATCH] Added Toolbar. No functionality implemented --- MacPass.xcodeproj/project.pbxproj | 6 + MacPass/EntryView.xib | 542 +++++++++--------------------- MacPass/MPAppDelegate.m | 3 + MacPass/MPEntryViewController.m | 10 + MacPass/MPMainWindowController.m | 6 + MacPass/MPToolbarDelegate.h | 13 + MacPass/MPToolbarDelegate.m | 75 +++++ MacPass/MainWindow.xib | 178 +++++++--- 8 files changed, 415 insertions(+), 418 deletions(-) create mode 100644 MacPass/MPToolbarDelegate.h create mode 100644 MacPass/MPToolbarDelegate.m diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index 3e653311..6b7291fc 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -15,6 +15,7 @@ 4C2E382316D1421B00037A9D /* MPIconHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C2E382216D1421B00037A9D /* MPIconHelper.m */; }; 4C2E382616D1470200037A9D /* MPViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C2E382516D1470200037A9D /* MPViewController.m */; }; 4C37A84015B8B474005EF8EE /* MPOutlineDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C37A83F15B8B474005EF8EE /* MPOutlineDataSource.m */; }; + 4C3BD51516D276F800389F1F /* MPToolbarDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C3BD51416D276F800389F1F /* MPToolbarDelegate.m */; }; 4C586F9E16D07ABD00E7DB57 /* 00_PasswordTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4C586F9D16D07ABD00E7DB57 /* 00_PasswordTemplate.pdf */; }; 4C586FA016D07D7200E7DB57 /* 01_PackageNetworkTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4C586F9F16D07D7200E7DB57 /* 01_PackageNetworkTemplate.pdf */; }; 4C586FA216D07F6A00E7DB57 /* 02_MessageBoxWarningTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4C586FA116D07F6A00E7DB57 /* 02_MessageBoxWarningTemplate.pdf */; }; @@ -97,6 +98,8 @@ 4C2E382516D1470200037A9D /* MPViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPViewController.m; sourceTree = ""; }; 4C37A83E15B8B474005EF8EE /* MPOutlineDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPOutlineDataSource.h; sourceTree = ""; }; 4C37A83F15B8B474005EF8EE /* MPOutlineDataSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPOutlineDataSource.m; sourceTree = ""; }; + 4C3BD51316D276F800389F1F /* MPToolbarDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPToolbarDelegate.h; sourceTree = ""; }; + 4C3BD51416D276F800389F1F /* MPToolbarDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPToolbarDelegate.m; sourceTree = ""; }; 4C586F9D16D07ABD00E7DB57 /* 00_PasswordTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = 00_PasswordTemplate.pdf; sourceTree = ""; }; 4C586F9F16D07D7200E7DB57 /* 01_PackageNetworkTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = 01_PackageNetworkTemplate.pdf; sourceTree = ""; }; 4C586FA116D07F6A00E7DB57 /* 02_MessageBoxWarningTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = 02_MessageBoxWarningTemplate.pdf; sourceTree = ""; }; @@ -272,6 +275,8 @@ 4C77E37915B84A240093A587 /* MPAppDelegate.m */, 4CC6258F15BA1C99002F5B11 /* MPOutlineViewDelegate.h */, 4CC6259015BA1C99002F5B11 /* MPOutlineViewDelegate.m */, + 4C3BD51316D276F800389F1F /* MPToolbarDelegate.h */, + 4C3BD51416D276F800389F1F /* MPToolbarDelegate.m */, ); name = Delegates; sourceTree = ""; @@ -693,6 +698,7 @@ 4C2E382616D1470200037A9D /* MPViewController.m in Sources */, 4C65FAE916D16DDB006E0577 /* MPPasswordInputController.m in Sources */, 4CDF01A316D1B76700D0AC08 /* MPEntryViewController.m in Sources */, + 4C3BD51516D276F800389F1F /* MPToolbarDelegate.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/MacPass/EntryView.xib b/MacPass/EntryView.xib index 440ec5bb..78787bac 100644 --- a/MacPass/EntryView.xib +++ b/MacPass/EntryView.xib @@ -17,13 +17,10 @@ NSScrollView NSScroller NSSplitView - NSTabView - NSTabViewItem NSTableColumn NSTableHeaderView NSTableView NSTextFieldCell - NSView com.apple.InterfaceBuilder.CocoaPlugin @@ -50,48 +47,48 @@ 268 - + 256 - - - 268 + + + 4364 - - + + 2304 - - + + 256 - {351, 544} - + {703, 547} + - + _NS:13 YES NO YES - - + + 256 - {351, 17} - + {703, 17} + - + _NS:16 - + -2147483392 {{224, 0}, {16, 17}} - + _NS:19 - + 116 40 1000 @@ -104,7 +101,7 @@ 11 3100 - + 3 MC4zMzMzMzI5ODU2AA @@ -118,7 +115,7 @@ - + 337641536 2048 Text Cell @@ -127,12 +124,12 @@ 13 1044 - + 6 System controlBackgroundColor - + 3 MC42NjY2NjY2NjY3AA @@ -147,10 +144,10 @@ 3 YES YES - + - - 229 + + 581 40 1000 @@ -158,22 +155,22 @@ 2048 - + - + 337641536 2048 Text Cell - + 3 YES YES - + 3 @@ -203,142 +200,78 @@ 1 - {{1, 17}, {351, 544}} - + {{0, 17}, {703, 547}} + - + _NS:11 - + 4 - - + + -2147483392 {{224, 17}, {15, 102}} - + - + _NS:58 NO - + _doScroller: 37 0.1947367936372757 - - + + -2147483392 {{1, 119}, {223, 15}} - + - _NS:60 NO 1 - + _doScroller: 0.57142859697341919 - - + + 2304 - + - {{1, 0}, {351, 17}} - + {703, 17} + - + _NS:15 - + 4 - {353, 562} - + {703, 564} + - + _NS:9 - 133682 - - - - + 133680 + + + + QSAAAEEgAABBmAAAQZgAAA 0.25 4 1 - {353, 563} + {703, 563} - - _NS:11 - NSView - - - - 256 - - - - 12 - {{13, 10}, {323, 539}} - - - - _NS:9 - - - 1 - - - 256 - {{10, 33}, {303, 493}} - - - - _NS:11 - - Tab - - 6 - System - controlColor - - - - - - 2 - - - 256 - {{10, 33}, {303, 493}} - _NS:28 - - View - - - - - - - 0 - YES - YES - - - - - - {{354, 0}, {349, 563}} - - - + _NS:13 NSView @@ -346,7 +279,7 @@ {703, 563} - + _NS:9 YES 2 @@ -472,129 +405,40 @@ 2 - - - 3 - - - - - - 4 - 0 - - 4 - 1 - - 0.0 - - 1000 - - 8 - 29 - 3 - - - - 6 - 0 - - 6 - 1 - - 0.0 - - 1000 - - 8 - 29 - 3 - - - - 10 - 0 - - 10 - 1 - - 0.0 - - 1000 - - 5 - 22 - 2 - - - - 5 - 0 - - 5 - 1 - - 0.0 - - 1000 - - 8 - 29 - 3 - - - - 4 - - - - 6 - 0 - - 6 - 1 - - 20 - - 1000 - - 8 - 29 - 3 - - - - 4 - 0 - - 4 - 1 - - 20 - - 1000 - - 8 - 29 - 3 - - - + + + 3 0 3 1 - 20 + -1 + + 1000 + + 3 + 9 + 3 + + + + 4 + 0 + + 4 + 1 + + 0.0 1000 @@ -602,15 +446,31 @@ 29 3 - - + + 5 0 5 1 - - 20 + + 0.0 + + 1000 + + 8 + 29 + 3 + + + + 6 + 0 + + 6 + 1 + + 0.0 1000 @@ -642,139 +502,84 @@ - 13 - + 54 + - - - - + + + + - + - 14 - + 55 + - - + + - + - 15 - - + 56 + + - 16 - - + 57 + + - 17 - - + 58 + + - 18 - + 59 + - + - + - 19 - + 60 + - + - + - 20 - - + 61 + + - 21 - - + 62 + + - 26 - - - - - 28 - - - - - 29 + 73 - + - 30 + 74 + + + + + 82 - - - - 31 - - - - - - 32 - - - - - - - - 33 - - - - - - - - 34 - - - - - 35 - - - - - 36 - - - - - 38 - - - - - 40 - - - - - 41 - + 83 + @@ -793,53 +598,36 @@ 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 - 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 - - - - - - - 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 - 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 + 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 + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - 42 + 83 diff --git a/MacPass/MPAppDelegate.m b/MacPass/MPAppDelegate.m index 7e750a16..b321fc00 100644 --- a/MacPass/MPAppDelegate.m +++ b/MacPass/MPAppDelegate.m @@ -47,5 +47,8 @@ [self.mainWindowController openDocument]; } +- (void)toolbarItemPressed:(id)sender { + NSLog(@"Pressed %@", sender); +} @end diff --git a/MacPass/MPEntryViewController.m b/MacPass/MPEntryViewController.m index 0a0f2298..a2542619 100644 --- a/MacPass/MPEntryViewController.m +++ b/MacPass/MPEntryViewController.m @@ -10,6 +10,8 @@ @interface MPEntryViewController () +@property (retain) NSArrayController *entryArrayController; + @end @implementation MPEntryViewController @@ -18,4 +20,12 @@ return [[MPEntryViewController alloc] initWithNibName:@"EntryView" bundle:nil]; } +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if(self) { + self.entryArrayController = [[[NSArrayController alloc] init] autorelease]; + } + return self; +} + @end diff --git a/MacPass/MPMainWindowController.m b/MacPass/MPMainWindowController.m index 06946753..6b12e7e3 100644 --- a/MacPass/MPMainWindowController.m +++ b/MacPass/MPMainWindowController.m @@ -13,6 +13,7 @@ #import "MPDatabaseDocument.h" #import "MPPasswordInputController.h" #import "MPEntryViewController.h" +#import "MPToolbarDelegate.h" NSString *const MPMainWindowControllerPasswordKey = @"MPMainWindowControllerPasswordKey"; NSString *const MPMainWindowControllerKeyfileKey = @"MPMainWindowControllerKeyfileKey"; @@ -24,6 +25,7 @@ NSString *const kOutlineViewIdentifier = @"OutlineView"; @interface MPMainWindowController () @property (assign) IBOutlet NSOutlineView *outlineView; +@property (assign) IBOutlet NSToolbar *toolbar; @property (assign) IBOutlet NSView *contentView; @property (retain) IBOutlet NSView *welcomeView; @@ -33,6 +35,7 @@ NSString *const kOutlineViewIdentifier = @"OutlineView"; @property (retain) MPPasswordInputController *passwordInputController; @property (retain) MPEntryViewController *entryViewController; +@property (retain) MPToolbarDelegate *toolbarDelegate; - (void)updateData; - (void)didOpenDocument:(NSNotification *)notification; @@ -47,6 +50,7 @@ NSString *const kOutlineViewIdentifier = @"OutlineView"; NSArray *topLevelObjects; self.outlineDelegate = [[[MPOutlineViewDelegate alloc] init] autorelease]; self.datasource = [[[MPOutlineDataSource alloc] init] autorelease]; + self.toolbarDelegate = [[[MPToolbarDelegate alloc] init] autorelease]; [[NSBundle mainBundle] loadNibNamed:@"WelcomeView" owner:self topLevelObjects:&topLevelObjects]; [self.welcomeView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; @@ -71,6 +75,8 @@ NSString *const kOutlineViewIdentifier = @"OutlineView"; [self.outlineView setDelegate:self.outlineDelegate]; [self.outlineView setDataSource:self.datasource]; + [self.toolbar setDelegate:self.toolbarDelegate]; + [self setContentViewController:nil]; } diff --git a/MacPass/MPToolbarDelegate.h b/MacPass/MPToolbarDelegate.h new file mode 100644 index 00000000..3714c6a8 --- /dev/null +++ b/MacPass/MPToolbarDelegate.h @@ -0,0 +1,13 @@ +// +// MPToolbarDelegate.h +// MacPass +// +// Created by michael starke on 18.02.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import + +@interface MPToolbarDelegate : NSObject + +@end diff --git a/MacPass/MPToolbarDelegate.m b/MacPass/MPToolbarDelegate.m new file mode 100644 index 00000000..8ff39dfa --- /dev/null +++ b/MacPass/MPToolbarDelegate.m @@ -0,0 +1,75 @@ +// +// MPToolbarDelegate.m +// MacPass +// +// Created by michael starke on 18.02.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import "MPToolbarDelegate.h" + +NSString *const MPToolbarItemAddGroup = @"AddGroup"; +NSString *const MPToolbarItemAddEntry = @"AddEntry"; +NSString *const MPToolbarItemEdit = @"Edit"; +NSString *const MPToolbarItemDelete =@"Delete"; + +@interface MPToolbarDelegate() + +@property (retain) NSMutableDictionary *toolbarItems; +@property (retain) NSArray *toolbarIdentifiers; +@property (retain) NSDictionary *toolbarImages; + +@end + +@implementation MPToolbarDelegate + + +- (id)init +{ + self = [super init]; + if (self) { + self.toolbarIdentifiers = @[ MPToolbarItemAddEntry, MPToolbarItemDelete, MPToolbarItemEdit, MPToolbarItemAddGroup ]; + self.toolbarItems = [NSMutableDictionary dictionaryWithCapacity:[self.toolbarItems count]]; + self.toolbarImages = [self createToolbarImages]; + } + return self; +} + +- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag { + NSToolbarItem *item = self.toolbarItems[ itemIdentifier ]; + if( !item ) { + item = [[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier]; + [item setImage:self.toolbarImages[itemIdentifier]]; + + NSString *label = NSLocalizedString(itemIdentifier, @""); + [item setLabel:label]; + + [item setAction:@selector(toolbarItemPressed:)]; + + self.toolbarItems[itemIdentifier] = item; + [item release]; + } + + return item; +} + +- (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar*)toolbar { + return self.toolbarIdentifiers; +} + +- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar*)toolbar +{ + return self.toolbarIdentifiers; +} + +- (NSDictionary *)createToolbarImages{ + + NSDictionary *imageDict = @{ MPToolbarItemAddEntry: [NSImage imageNamed:NSImageNameAddTemplate], + MPToolbarItemAddGroup: [NSImage imageNamed:NSImageNameAddTemplate], + MPToolbarItemDelete: [NSImage imageNamed:NSImageNameRemoveTemplate], + MPToolbarItemEdit: [NSImage imageNamed:NSImageNameRefreshTemplate] + }; + return imageDict; +} + +@end diff --git a/MacPass/MainWindow.xib b/MacPass/MainWindow.xib index a4ee4354..4de89125 100644 --- a/MacPass/MainWindow.xib +++ b/MacPass/MainWindow.xib @@ -25,6 +25,9 @@ NSTableColumn NSTextField NSTextFieldCell + NSToolbar + NSToolbarFlexibleSpaceItem + NSToolbarSpaceItem NSView NSWindowTemplate @@ -48,11 +51,92 @@ 15 2 - {{196, 240}, {738, 428}} + {{196, 240}, {738, 609}} 544735232 Window NSWindow - + + + 04E515E6-01C4-49D0-9F18-CF8CB81C135F + + + YES + YES + YES + NO + 1 + 1 + + + NSToolbarFlexibleSpaceItem + + Flexible Space + + + + + + {1, 5} + {20000, 32} + YES + YES + -1 + YES + 0 + + YES + YES + + + 1048576 + 2147483647 + + NSImage + NSMenuCheckmark + + + NSImage + NSMenuMixedState + + + + + NSToolbarSpaceItem + + Space + + + + + + {32, 5} + {32, 32} + YES + YES + -1 + YES + 0 + + YES + YES + + + 1048576 + 2147483647 + + + + + + + + + + + + + + @@ -135,7 +219,7 @@ 4352 - {171, 396} + {163, 577} @@ -152,7 +236,7 @@ AutomaticTableColumnIdentifier.0 - 168 + 160 16 1000 @@ -247,7 +331,7 @@ 14 - {171, 396} + {163, 577} @@ -284,7 +368,7 @@ 0.99479166666666663 - {171, 396} + {163, 577} @@ -302,14 +386,14 @@ 274 - {{172, 0}, {566, 396}} + {{164, 0}, {574, 577}} _NS:13 - {{0, 32}, {738, 396}} + {{0, 32}, {738, 577}} @@ -318,12 +402,12 @@ 2 - {738, 428} + {738, 609} - {{0, 0}, {1920, 1058}} + {{0, 0}, {2560, 1418}} {10000000000000, 10000000000000} NO 32 @@ -356,6 +440,14 @@ 502 + + + toolbar + + + + 597 + textField @@ -366,7 +458,7 @@ 266 - {{0, 1}, {168, 14}} + {{0, 1}, {160, 14}} _NS:101 @@ -396,7 +488,7 @@ NO - {{1, 0}, {168, 17}} + {{1, 0}, {160, 17}} HeaderCell @@ -446,7 +538,7 @@ 266 - {{25, 3}, {143, 17}} + {{25, 3}, {135, 17}} _NS:80 @@ -464,7 +556,7 @@ NO - {{1, 17}, {168, 23}} + {{1, 17}, {160, 23}} DataCell @@ -485,7 +577,7 @@ 0 - + @@ -512,6 +604,7 @@ + @@ -1085,6 +1178,25 @@ + + 591 + + + + + + + + + 592 + + + + + 595 + + + @@ -1182,35 +1294,25 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin - 590 + 597 MPMainWindowController NSWindowController - - usePassword: - id - - - usePassword: - - usePassword: - id - - NSView - NSPathControl NSOutlineView - NSTextField - NSView + NSToolbar NSView @@ -1218,21 +1320,13 @@ contentView NSView - - keyPathControl - NSPathControl - outlineView NSOutlineView - - passwordTextField - NSTextField - - - passwordView - NSView + + toolbar + NSToolbar welcomeView @@ -1261,6 +1355,8 @@ {15, 15} {8, 8} + {11, 11} + {10, 3} {8, 8} YES