diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index 766be986..04afd314 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -19,6 +19,7 @@ 4C37A84015B8B474005EF8EE /* MPOutlineDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C37A83F15B8B474005EF8EE /* MPOutlineDataSource.m */; }; 4C3BD51516D276F800389F1F /* MPToolbarDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C3BD51416D276F800389F1F /* MPToolbarDelegate.m */; }; 4C3FFD9E16DAF60600DF9186 /* FilterBar.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C3FFD9D16DAF60600DF9186 /* FilterBar.xib */; }; + 4C4E1DC716DC6536007B9B47 /* PathBar.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C4E1DC616DC6536007B9B47 /* PathBar.xib */; }; 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 */; }; @@ -117,6 +118,7 @@ 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 = ""; }; 4C3FFD9D16DAF60600DF9186 /* FilterBar.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = FilterBar.xib; sourceTree = ""; }; + 4C4E1DC616DC6536007B9B47 /* PathBar.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PathBar.xib; 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 = ""; }; @@ -291,6 +293,7 @@ 4C6B0E8B16C9B99B00A9ED23 /* PasswordInputView.xib */, 4C25D58416CF0F8800F6806C /* WelcomeView.xib */, 4C3FFD9D16DAF60600DF9186 /* FilterBar.xib */, + 4C4E1DC616DC6536007B9B47 /* PathBar.xib */, 4C69A73816D589DF00EC1B1A /* MPGradientView.h */, 4C69A73916D589DF00EC1B1A /* MPGradientView.m */, 4C16854216D704980027ECBC /* MPPathBar.h */, @@ -700,6 +703,7 @@ 4CB9339916D3A0DD00A13B5D /* Credits.rtf in Resources */, 4CF5D49716D5B6E900CB78BD /* EntryEditView.xib in Resources */, 4C3FFD9E16DAF60600DF9186 /* FilterBar.xib in Resources */, + 4C4E1DC716DC6536007B9B47 /* PathBar.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/MacPass/EntryView.xib b/MacPass/EntryView.xib index 5adfc785..8d3fa22b 100644 --- a/MacPass/EntryView.xib +++ b/MacPass/EntryView.xib @@ -351,7 +351,6 @@ {624, 363} - _NS:9 NSView @@ -405,6 +404,29 @@ 671 + + + tableToBottom + + + + 4 + 0 + + 4 + 1 + + 0.0 + + 1000 + + 9 + 40 + 3 + + + 672 + textField @@ -656,22 +678,7 @@ - - - 4 - 0 - - 4 - 1 - - 0.0 - - 1000 - - 8 - 29 - 3 - + 6 @@ -1514,7 +1521,7 @@ - 671 + 672 @@ -1535,10 +1542,12 @@ NSTableView NSView - NSTextField - NSButton - NSButton - NSButton + NSButton + NSTextField + NSButton + NSButton + NSButton + NSLayoutConstraint NSLayoutConstraint @@ -1550,22 +1559,30 @@ filterBar NSView - - searchLabelTextField + + filterDoneButton + NSButton + + + filterLabelTextField NSTextField - - searchTitleButton + + filterTitleButton NSButton - - searchURLButton + + filterURLButton NSButton - - searchUsernameButton + + filterUsernameButton NSButton + + tableToBottom + NSLayoutConstraint + tableToTop NSLayoutConstraint diff --git a/MacPass/FilterBar.xib b/MacPass/FilterBar.xib index ee0bfeaa..7ff277c2 100644 --- a/MacPass/FilterBar.xib +++ b/MacPass/FilterBar.xib @@ -40,12 +40,41 @@ 268 + + + 268 + {{496, 5}, {42, 17}} + + + _NS:9 + YES + + -2080374784 + 134348800 + Done + + LucidaGrande + 11 + 3100 + + _NS:9 + + -2038153216 + 164 + + + 400 + 75 + + NO + 268 - {{188, 6}, {38, 17}} + {{188, 5}, {38, 17}} + _NS:9 YES @@ -71,7 +100,7 @@ 268 - {{104, 6}, {76, 17}} + {{104, 5}, {76, 17}} @@ -96,7 +125,7 @@ 268 - {{5, 7}, {44, 14}} + {{5, 6}, {44, 14}} @@ -137,7 +166,7 @@ 268 - {{54, 5}, {42, 17}} + {{54, 4}, {42, 19}} @@ -160,7 +189,7 @@ NO - {483, 28} + {546, 28} @@ -169,30 +198,6 @@ - - - searchTitleButton - - - - 45 - - - - searchUsernameButton - - - - 46 - - - - searchURLButton - - - - 47 - filterBar @@ -225,6 +230,54 @@ 51 + + + filterTitleButton + + + + 57 + + + + filterUsernameButton + + + + 58 + + + + filterURLButton + + + + 59 + + + + filterLabelTextField + + + + 60 + + + + clearFilter: + + + + 75 + + + + filterDoneButton + + + + 76 + @@ -256,6 +309,70 @@ 1 + + + 5 + 1 + + 6 + 1 + + 8 + + 1000 + + 9 + 40 + 3 + + + + 10 + 0 + + 10 + 1 + + 0.0 + + 1000 + + 9 + 40 + 2 + + + + 6 + 0 + + 6 + 1 + + 8 + + 1000 + + 9 + 40 + 3 + + + + 10 + 0 + + 10 + 1 + + 0.0 + + 1000 + + 9 + 40 + 2 + 5 @@ -268,15 +385,15 @@ 1000 - 6 - 24 + 9 + 40 3 - - + + 11 0 - + 11 1 @@ -288,20 +405,20 @@ 24 2 - - - 4 + + + 10 0 - - 4 + + 10 1 0.0 1000 - 6 - 24 + 9 + 40 2 @@ -316,10 +433,26 @@ 1000 - 6 - 24 + 9 + 40 3 + + + 10 + 0 + + 10 + 1 + + 0.0 + + 1000 + + 9 + 40 + 2 + 5 @@ -332,24 +465,24 @@ 1000 - 6 - 24 + 9 + 40 3 - + - 10 + 4 0 - - 10 + + 4 1 0.0 1000 - 5 - 22 + 6 + 24 2 @@ -380,14 +513,15 @@ 1000 - 3 - 9 + 9 + 40 3 + @@ -450,11 +584,6 @@ - - 39 - - - 40 @@ -468,19 +597,62 @@ - - 42 - - - 43 - 44 - + 54 + + + + + 55 + + + + + 56 + + + + + 61 + + + + + + + + 62 + + + + + 63 + + + + + 66 + + + + + 69 + + + + + 72 + + + + + 73 + @@ -492,12 +664,17 @@ - + + - - + + + + + + com.apple.InterfaceBuilder.CocoaPlugin @@ -510,22 +687,30 @@ 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 - 51 + 76 @@ -546,10 +731,12 @@ NSTableView NSView - NSTextField - NSButton - NSButton - NSButton + NSButton + NSTextField + NSButton + NSButton + NSButton + NSLayoutConstraint NSLayoutConstraint @@ -561,22 +748,30 @@ filterBar NSView - - searchLabelTextField + + filterDoneButton + NSButton + + + filterLabelTextField NSTextField - - searchTitleButton + + filterTitleButton NSButton - - searchURLButton + + filterURLButton NSButton - - searchUsernameButton + + filterUsernameButton NSButton + + tableToBottom + NSLayoutConstraint + tableToTop NSLayoutConstraint diff --git a/MacPass/GeneralSettings.xib b/MacPass/GeneralSettings.xib index f398a4a4..aa30581b 100644 --- a/MacPass/GeneralSettings.xib +++ b/MacPass/GeneralSettings.xib @@ -42,12 +42,23 @@ 268 + + + 268 + {{0, 56}, {291, 24}} + + + + _NS:9 + MPPathBar + 268 - {{146, 174}, {127, 26}} + {{146, 91}, {127, 26}} + _NS:9 {750, 751} YES @@ -125,7 +136,7 @@ 268 - {{17, 180}, {127, 17}} + {{17, 97}, {127, 17}} @@ -160,7 +171,7 @@ NO - {290, 218} + {290, 135} @@ -185,6 +196,14 @@ 83 + + + pathBar + + + + 372 + @@ -298,6 +317,54 @@ 40 3 + + + 9 + 0 + + 9 + 1 + + 0.0 + + 1000 + + 9 + 40 + 2 + + + + 5 + 0 + + 5 + 1 + + 0.0 + + 1000 + + 8 + 29 + 3 + + + + 10 + 0 + + 10 + 1 + + 0.0 + + 1000 + + 9 + 40 + 2 + 7 @@ -346,6 +413,7 @@ 40 3 + @@ -443,6 +511,49 @@ + + 357 + + + + + 8 + 0 + + 0 + 1 + + 24 + + 1000 + + 9 + 40 + 1 + + + + + + 366 + + + + + 368 + + + + + 370 + + + + + 371 + + + @@ -453,6 +564,9 @@ + + + @@ -471,6 +585,15 @@ 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 @@ -483,7 +606,7 @@ - 338 + 379 @@ -509,6 +632,22 @@ ./Classes/MPGeneralSettingsController.h + + MPGradientView + NSView + + IBProjectSource + ./Classes/MPGradientView.h + + + + MPPathBar + MPGradientView + + IBProjectSource + ./Classes/MPPathBar.h + + MPViewController NSViewController diff --git a/MacPass/MPAppDelegate.m b/MacPass/MPAppDelegate.m index 629aed12..322017fb 100644 --- a/MacPass/MPAppDelegate.m +++ b/MacPass/MPAppDelegate.m @@ -31,6 +31,7 @@ - (void)dealloc { self.settingsController = nil; self.mainWindowController = nil; + [super dealloc]; } #pragma mark Menu Actions diff --git a/MacPass/MPDatabaseDocument.h b/MacPass/MPDatabaseDocument.h index c2de7736..00c928d6 100644 --- a/MacPass/MPDatabaseDocument.h +++ b/MacPass/MPDatabaseDocument.h @@ -8,8 +8,8 @@ #import -APPKIT_EXTERN NSString *const MPDidLoadDataBaseNotification; -APPKIT_EXTERN NSString *const MPDataBaseDocumentDocumentKey; +APPKIT_EXTERN NSString *const MPDidLoadDatabaseNotification; +APPKIT_EXTERN NSString *const MPDatabaseDocumentDocumentKey; typedef enum { MPDatabaseVersion3, @@ -28,6 +28,7 @@ typedef enum { @property (assign, readonly) MPDatabaseVersion version; + (id)documentWithFile:(NSURL *)file password:(NSString *)password keyfile:(NSURL *)key; ++ (id)documentWithNewDatabase:(MPDatabaseVersion)version; - (id)initWithFile:(NSURL *)file password:(NSString *)password keyfile:(NSURL *)key; - (id)initWithNewDatabase:(MPDatabaseVersion)version; /* diff --git a/MacPass/MPDatabaseDocument.m b/MacPass/MPDatabaseDocument.m index 0ceb845a..1563adb5 100644 --- a/MacPass/MPDatabaseDocument.m +++ b/MacPass/MPDatabaseDocument.m @@ -11,7 +11,7 @@ #import "Kdb4Node.h" #import "Kdb3Node.h" -NSString *const MPDidLoadDataBaseNotification = @"DidLoadDataBaseNotification"; +NSString *const MPDidLoadDatabaseNotification = @"DidLoadDataBaseNotification"; @interface MPDatabaseDocument () @@ -28,12 +28,19 @@ NSString *const MPDidLoadDataBaseNotification = @"DidLoadDataBaseNotification"; return [[[MPDatabaseDocument alloc] initWithFile:file password:password keyfile:key] autorelease]; } ++ (id)documentWithNewDatabase:(MPDatabaseVersion)version { + return [[[MPDatabaseDocument alloc] initWithNewDatabase:version] autorelease]; +} + - (id)init { // create empty document return [self initWithFile:nil password:nil keyfile:nil]; } -- (id)initWithNewDatabaseVersion:(MPDatabaseVersion)version { +/* + Initalizer for creating + */ +- (id)initWithNewDatabase:(MPDatabaseVersion)version { self = [super init]; if(self) { switch(version) { @@ -54,7 +61,7 @@ NSString *const MPDidLoadDataBaseNotification = @"DidLoadDataBaseNotification"; } /* - Designated initalizeder + Designated initalizer for loading */ - (id)initWithFile:(NSURL *)file password:(NSString *)password keyfile:(NSURL *)key { diff --git a/MacPass/MPEntryViewController.m b/MacPass/MPEntryViewController.m index e67881f0..45362cf9 100644 --- a/MacPass/MPEntryViewController.m +++ b/MacPass/MPEntryViewController.m @@ -34,23 +34,26 @@ NSString *const _MPTableImageCellView = @"ImageCell"; NSString *const _MPTableStringCellView = @"StringCell"; NSString *const _MPTAbleSecurCellView = @"PasswordCell"; -NSString *const _toggleSearchURLButton = @"SearchURL"; -NSString *const _toggleSearchTitleButton = @"SearchTitle"; -NSString *const _toggleSearchUsernameButton = @"SearchUsername"; +NSString *const _toggleFilterURLButton = @"SearchURL"; +NSString *const _toggleFilterTitleButton = @"SearchTitle"; +NSString *const _toggleFilterUsernameButton = @"SearchUsername"; @interface MPEntryViewController () @property (retain) NSArrayController *entryArrayController; @property (retain) NSArray *filteredEntries; @property (retain) IBOutlet NSView *filterBar; +@property (retain) IBOutlet NSView *pathBar; @property (assign) IBOutlet NSTableView *entryTable; -@property (assign) IBOutlet NSTextField *searchLabelTextField; @property (assign) BOOL isStatusBarVisible; -@property (retain) IBOutlet NSLayoutConstraint *tableToTop; +@property (assign) IBOutlet NSLayoutConstraint *tableToTop; +@property (assign) IBOutlet NSLayoutConstraint *tableToBottom; +@property (assign) IBOutlet NSButton *filterDoneButton; -@property (assign) IBOutlet NSButton *searchTitleButton; -@property (assign) IBOutlet NSButton *searchUsernameButton; -@property (assign) IBOutlet NSButton *searchURLButton; +@property (assign) IBOutlet NSButton *filterTitleButton; +@property (assign) IBOutlet NSButton *filterUsernameButton; +@property (assign) IBOutlet NSButton *filterURLButton; +@property (assign) IBOutlet NSTextField *filterLabelTextField; @property (assign, nonatomic) MPFilterModeType filterMode; @property (retain, nonatomic) NSDictionary *filterButtonToMode; @@ -64,6 +67,7 @@ NSString *const _toggleSearchUsernameButton = @"SearchUsername"; - (BOOL)hasFilter; - (void)updateFilter; - (void)setupFilterBar; +- (void)setupPathBar; - (void)didChangeGroupSelectionInOutlineView:(NSNotification *)notification; - (void)showFilterBarAnimated:(BOOL)animate; - (void)hideStatusBarAnimated:(BOOL)animate; @@ -82,9 +86,9 @@ NSString *const _toggleSearchUsernameButton = @"SearchUsername"; if(self) { _isStatusBarVisible = YES; _filterMode = MPFilterTitles; - _filterButtonToMode = [@{ _toggleSearchUsernameButton : @(MPFilterUsernames), - _toggleSearchTitleButton : @(MPFilterTitles), - _toggleSearchURLButton : @(MPFilterUrls) + _filterButtonToMode = [@{ _toggleFilterUsernameButton : @(MPFilterUsernames), + _toggleFilterTitleButton : @(MPFilterTitles), + _toggleFilterURLButton : @(MPFilterUrls) } retain]; _entryArrayController = [[NSArrayController alloc] init]; [[NSNotificationCenter defaultCenter] addObserver:self @@ -107,7 +111,6 @@ NSString *const _toggleSearchUsernameButton = @"SearchUsername"; - (void)didLoadView { [self.view setWantsLayer:YES]; [self hideStatusBarAnimated:NO]; - [[self.searchLabelTextField cell] setBackgroundStyle:NSBackgroundStyleRaised]; [self.entryTable setDelegate:self]; @@ -247,9 +250,20 @@ NSString *const _toggleSearchUsernameButton = @"SearchUsername"; if(!self.filterBar) { [[NSBundle mainBundle] loadNibNamed:@"FilterBar" owner:self topLevelObjects:nil]; [self.filterBar setAutoresizingMask:NSViewWidthSizable|NSViewMinYMargin]; - [self.searchURLButton setIdentifier:_toggleSearchURLButton]; - [self.searchUsernameButton setIdentifier:_toggleSearchUsernameButton]; - [self.searchTitleButton setIdentifier:_toggleSearchTitleButton]; + [self.filterURLButton setIdentifier:_toggleFilterURLButton]; + [self.filterUsernameButton setIdentifier:_toggleFilterUsernameButton]; + [self.filterTitleButton setIdentifier:_toggleFilterTitleButton]; + [[self.filterLabelTextField cell] setBackgroundStyle:NSBackgroundStyleRaised]; + [self.filterDoneButton setAction:@selector(clearFilter:)]; + [self.filterDoneButton setTarget:nil]; + } +} + +- (void)setupPathBar { + if(!self.pathBar) { + [[NSBundle mainBundle] loadNibNamed:@"PathBar" owner:self topLevelObjects:nil]; + [self.pathBar setAutoresizingMask:NSViewWidthSizable|NSViewMaxYMargin]; + } } @@ -265,9 +279,9 @@ NSString *const _toggleSearchUsernameButton = @"SearchUsername"; /* Make sure the buttons are set correctyl every time */ - [self.searchTitleButton setState:[self shouldFilterTitles] ? NSOnState : NSOffState]; - [self.searchURLButton setState:[self shouldFilterURLs] ? NSOnState : NSOffState ]; - [self.searchUsernameButton setState:[self shouldFilterUsernames] ? NSOnState : NSOffState]; + [self.filterTitleButton setState:[self shouldFilterTitles] ? NSOnState : NSOffState]; + [self.filterURLButton setState:[self shouldFilterURLs] ? NSOnState : NSOffState ]; + [self.filterUsernameButton setState:[self shouldFilterUsernames] ? NSOnState : NSOffState]; if(self.isStatusBarVisible) { return; // nothign to to @@ -296,6 +310,7 @@ NSString *const _toggleSearchUsernameButton = @"SearchUsername"; - (void)hideStatusBarAnimated:(BOOL)animate { + animate = NO; if(!self.isStatusBarVisible) { @@ -304,7 +319,7 @@ NSString *const _toggleSearchUsernameButton = @"SearchUsername"; self.isStatusBarVisible = NO; self.tableToTop.constant = -1; - [self.filterBar removeFromSuperview]; + [self.filterBar removeFromSuperviewWithoutNeedingDisplay]; if(animate) { [NSAnimationContext runAnimationGroup:^(NSAnimationContext* context) { diff --git a/MacPass/MPGeneralSettingsController.m b/MacPass/MPGeneralSettingsController.m index 123807ab..1607ed72 100644 --- a/MacPass/MPGeneralSettingsController.m +++ b/MacPass/MPGeneralSettingsController.m @@ -52,7 +52,6 @@ NSString *const MPGeneralSetingsIdentifier = @"GeneralSettingsTab"; [_encodingPopup setMenu:encodingMenu]; [encodingMenu release]; - } @end diff --git a/MacPass/MPMainWindowController.m b/MacPass/MPMainWindowController.m index b4adccd7..6bc2cd49 100644 --- a/MacPass/MPMainWindowController.m +++ b/MacPass/MPMainWindowController.m @@ -180,14 +180,28 @@ - (void)updateFilter:(id)sender { NSSearchField *searchField = sender; self.entryViewController.filter = [searchField stringValue]; + [((NSOutlineView *)self.outlineViewController.view) deselectAll:self]; } - (void)clearFilter:(id)sender { NSSearchField *searchField = sender; + if(![sender isKindOfClass:[NSSearchField class]]) { + searchField = [self locateToolbarSearchField]; + } [searchField setStringValue:@""]; [self.entryViewController clearFilter]; } +- (NSSearchField *)locateToolbarSearchField { + for(NSToolbarItem *toolbarItem in [[self.window toolbar] items]) { + NSView *view = [toolbarItem view]; + if([view isKindOfClass:[NSSearchField class]]) { + return (NSSearchField *)view; + } + } + return nil; +} + #pragma mark Notifications - (void)didOpenDocument:(NSNotification *)notification { diff --git a/MacPass/MPOutlineViewController.h b/MacPass/MPOutlineViewController.h index 47182644..09391e1f 100644 --- a/MacPass/MPOutlineViewController.h +++ b/MacPass/MPOutlineViewController.h @@ -11,5 +11,6 @@ @interface MPOutlineViewController : MPViewController @property (retain, readonly) NSMenu *menu; +- (void)deselectAll; @end diff --git a/MacPass/MPOutlineViewController.m b/MacPass/MPOutlineViewController.m index 6e4a5a06..453d5e6e 100644 --- a/MacPass/MPOutlineViewController.m +++ b/MacPass/MPOutlineViewController.m @@ -62,6 +62,7 @@ [self.outlineView setDataSource:self.datasource]; [self.outlineView setDelegate:self.outlineDelegate]; [self.outlineView setMenu:self.menu]; + [self.outlineView setAllowsEmptySelection:YES]; } - (void)didOpenDocument:(NSNotification *)notification { @@ -72,6 +73,10 @@ } } +- (void)deselectAll { + [self.outlineView deselectAll:self]; +} + - (void)setupMenu { NSMenu *menu = [[NSMenu allocWithZone:[NSMenu menuZone]] init]; [menu addItemWithTitle:@"Add Group" action:@selector(addEntry:) keyEquivalent:@""]; diff --git a/MacPass/MPPathBar.m b/MacPass/MPPathBar.m index 3db32d55..864211ac 100644 --- a/MacPass/MPPathBar.m +++ b/MacPass/MPPathBar.m @@ -81,7 +81,7 @@ itemView = self.itemViews[index]; } if(!itemView) { - itemView = [[MPPathBarItemView alloc] initWithFrame:NSMakeRect(0, 0, 50, 24)]; + itemView = [[[MPPathBarItemView alloc] initWithFrame:NSMakeRect(0, 0, 50, 24)] autorelease]; } itemView.text = [NSString stringWithFormat:@"Button %ld", (unsigned long)index ]; itemView.image = [NSImage imageNamed:NSImageNameActionTemplate]; diff --git a/MacPass/MPPathBarItemView.m b/MacPass/MPPathBarItemView.m index 6d70fba9..c4485813 100644 --- a/MacPass/MPPathBarItemView.m +++ b/MacPass/MPPathBarItemView.m @@ -8,6 +8,8 @@ #import "MPPathBarItemView.h" +#define IMAGE_TO_TEXT_MARGIN 5.0 + @interface MPPathBarItemView () @property (retain) NSImageView *imageView; @@ -28,7 +30,7 @@ [[_imageView cell] setDrawsBackground:NO]; [_imageView setImage:[NSImage imageNamed:NSImageNameActionTemplate ]]; - _textField = [[NSTextField alloc] initWithFrame:NSMakeRect([_imageView frame].size.width + 5, 0, 20, 24)]; + _textField = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 20, 24)]; [_textField setBordered:NO]; [_textField setFont:[NSFont systemFontOfSize:13]]; [_textField setDrawsBackground:NO]; @@ -36,29 +38,13 @@ [_textField setSelectable:NO]; [[_textField cell] setBackgroundStyle:NSBackgroundStyleRaised]; [_textField setStringValue:@"Boo"]; - [_textField sizeToFit]; + + [self addSubview:_textField]; [self addSubview:_imageView]; -// NSDictionary *viewDictionary = NSDictionaryOfVariableBindings(_imageView, _textField); -// [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-[_imageView(24)]-|" -// options:0 -// metrics:nil -// views:viewDictionary]]; -// [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-[_imageView(24)]-|" -// options:0 -// metrics:nil -// views:viewDictionary]]; -// [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-[_imageView]-|" -// options:0 -// metrics:nil -// views:viewDictionary]]; -// -// [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-[_textField]-|" -// options:0 -// metrics:nil -// views:viewDictionary]]; + [self sizeToFit]; [self needsLayout]; } @@ -84,17 +70,36 @@ } - (void)sizeToFit { + + const BOOL isAutoResize = [self autoresizesSubviews];/* Disable autoresizing */ + [self setAutoresizesSubviews:NO]; + NSRect superFrame = [self frame]; + /* + Let our subviews calculate their sizes + */ [self.textField sizeToFit]; - [self.imageView sizeToFit]; + //[self.imageView sizeToFit]; NSRect textFrame = [self.textField frame]; NSRect imageFrame = [self.imageView frame]; - - // nudge the textframe - textFrame.origin.x = imageFrame.size.width; - [self.textField setFrame:textFrame]; + /* + Determine our size + */ + CGFloat height = MAX(textFrame.size.height, imageFrame.size.height); + CGFloat width = textFrame.size.width + IMAGE_TO_TEXT_MARGIN + imageFrame.size.width; - NSRect frame = NSMakeRect(0, 0,textFrame.size.width + imageFrame.size.width, textFrame.size.height); - [self setFrame:frame]; + [self setFrame:NSMakeRect(superFrame.origin.x, superFrame.origin.y, width, height)]; + + imageFrame.origin.x = 0; + imageFrame.origin.y = 0; + imageFrame.size.height = height; + textFrame.origin.x = imageFrame.size.width + IMAGE_TO_TEXT_MARGIN; + textFrame.origin.y = 0; + textFrame.size.height = height; + + [self.textField setFrame:textFrame]; + [self.imageView setFrame:imageFrame]; + /* Reset the autoresizing */ + [self setAutoresizesSubviews:isAutoResize]; } @end diff --git a/MacPass/MPToolbarDelegate.m b/MacPass/MPToolbarDelegate.m index 106504ba..1f283cc6 100644 --- a/MacPass/MPToolbarDelegate.m +++ b/MacPass/MPToolbarDelegate.m @@ -9,6 +9,7 @@ #import "MPToolbarDelegate.h" #import "MPIconHelper.h" #import "MPMainWindowController.h" +#import "MPPathBar.h" NSString *const MPToolbarItemAddGroup = @"AddGroup"; NSString *const MPToolbarItemAddEntry = @"AddEntry"; @@ -19,7 +20,6 @@ NSString *const MPToolbarItemSearch = @"Search"; @interface MPToolbarDelegate() -@property (retain) NSMutableDictionary *toolbarItems; @property (retain) NSArray *toolbarIdentifiers; @property (retain) NSDictionary *toolbarImages; @@ -33,7 +33,6 @@ NSString *const MPToolbarItemSearch = @"Search"; self = [super init]; if (self) { self.toolbarIdentifiers = @[ MPToolbarItemAddEntry, MPToolbarItemDelete, MPToolbarItemEdit, MPToolbarItemAddGroup, MPToolbarItemAction, NSToolbarFlexibleSpaceItemIdentifier, MPToolbarItemSearch ]; - self.toolbarItems = [NSMutableDictionary dictionaryWithCapacity:[self.toolbarItems count]]; self.toolbarImages = [self createToolbarImages]; } return self; @@ -41,29 +40,22 @@ NSString *const MPToolbarItemSearch = @"Search"; - (void)dealloc { - self.toolbarItems = nil; self.toolbarIdentifiers = nil; self.toolbarImages = nil; [super dealloc]; } -- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag { - NSToolbarItem *item = self.toolbarItems[ itemIdentifier ]; - if( !item ) { - - item = [[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier]; +- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag { + NSToolbarItem *item = [[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier]; [item setAction:@selector(toolbarItemPressed:)]; - self.toolbarItems[itemIdentifier] = item; NSString *label = NSLocalizedString(itemIdentifier, @""); [item setLabel:label]; - [item release]; if([itemIdentifier isEqualToString:MPToolbarItemSearch]) { NSSearchField *searchfield = [[NSSearchField alloc] initWithFrame:NSMakeRect(0, 0, 70, 32)]; [item setView:searchfield]; [searchfield setAction:@selector(updateFilter:)]; [[searchfield cell] setSendsSearchStringImmediately:NO]; - [[searchfield cell] addObserver:self forKeyPath:@"controlSize" options:0 context:NULL]; [[[searchfield cell] cancelButtonCell] setTarget:nil]; [[[searchfield cell] cancelButtonCell] setAction:@selector(clearFilter:)]; [searchfield release]; @@ -71,7 +63,6 @@ NSString *const MPToolbarItemSearch = @"Search"; } else if([itemIdentifier isEqualToString:MPToolbarItemAction]) { NSPopUpButton *popupButton = [[NSPopUpButton alloc] initWithFrame:NSMakeRect(0, 0, 50, 32) pullsDown:YES]; - [[popupButton cell] addObserver:self forKeyPath:@"controlSize" options:0 context:NULL]; [[popupButton cell] setBezelStyle:NSTexturedRoundedBezelStyle]; [[popupButton cell] setImageScaling:NSImageScaleProportionallyDown]; [popupButton setTitle:@""]; @@ -117,10 +108,7 @@ NSString *const MPToolbarItemSearch = @"Search"; [item setView:button]; [button release]; } - return item; - } - - return item; + return [item autorelease]; } - (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar*)toolbar { @@ -142,9 +130,5 @@ NSString *const MPToolbarItemSearch = @"Search"; return imageDict; } -- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { - NSLog(@"Path:%@: Objecte:%@", keyPath, object); -} - @end diff --git a/MacPass/MacPass-Info.plist b/MacPass/MacPass-Info.plist index 25363c46..ef836337 100644 --- a/MacPass/MacPass-Info.plist +++ b/MacPass/MacPass-Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 2BF + 304 LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} NSHumanReadableCopyright diff --git a/MacPass/PathBar.xib b/MacPass/PathBar.xib new file mode 100644 index 00000000..088d6dd1 --- /dev/null +++ b/MacPass/PathBar.xib @@ -0,0 +1,117 @@ + + + + 1080 + 12C60 + 3084 + 1187.34 + 625.00 + + com.apple.InterfaceBuilder.CocoaPlugin + 3084 + + + NSCustomObject + NSCustomView + + + com.apple.InterfaceBuilder.CocoaPlugin + + + PluginDependencyRecalculationVersion + + + + + NSObject + + + FirstResponder + + + NSApplication + + + + 268 + {480, 24} + + + + MPPathBar + + + + + + + + 0 + + + + + + -2 + + + File's Owner + + + -1 + + + First Responder + + + -3 + + + Application + + + 1 + + + + + + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + + + + 1 + + + + + MPGradientView + NSView + + IBProjectSource + ./Classes/MPGradientView.h + + + + MPPathBar + MPGradientView + + IBProjectSource + ./Classes/MPPathBar.h + + + + + 0 + IBCocoaFramework + YES + 3 + YES + +