mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 01:12:31 +00:00
Added first rudimentary search capability
This commit is contained in:
@@ -80,6 +80,7 @@
|
||||
4CAD748E15B88AC100104512 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 4CAD748D15B88AC100104512 /* libz.dylib */; };
|
||||
4CB9339916D3A0DD00A13B5D /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 4CB9339716D3A0DD00A13B5D /* Credits.rtf */; };
|
||||
4CBA981815BA0DB600721965 /* MPDatabaseDocument.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CBA981715BA0DB600721965 /* MPDatabaseDocument.m */; };
|
||||
4CC1AEBE16D4467C006D2AAB /* KdbTree+MPAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CC1AEBD16D4467C006D2AAB /* KdbTree+MPAdditions.m */; };
|
||||
4CC6259115BA1C99002F5B11 /* MPOutlineViewDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CC6259015BA1C99002F5B11 /* MPOutlineViewDelegate.m */; };
|
||||
4CD78ABC16D155FF00768A1D /* 07_NotepadTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4CD78AB716D155FF00768A1D /* 07_NotepadTemplate.pdf */; };
|
||||
4CD78ABD16D155FF00768A1D /* 08_SocketTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4CD78AB816D155FF00768A1D /* 08_SocketTemplate.pdf */; };
|
||||
@@ -230,6 +231,8 @@
|
||||
4CB9339816D3A0DD00A13B5D /* en */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; name = en; path = en.lproj/Credits.rtf; sourceTree = "<group>"; };
|
||||
4CBA981615BA0DB600721965 /* MPDatabaseDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPDatabaseDocument.h; sourceTree = "<group>"; };
|
||||
4CBA981715BA0DB600721965 /* MPDatabaseDocument.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPDatabaseDocument.m; sourceTree = "<group>"; };
|
||||
4CC1AEBC16D4467C006D2AAB /* KdbTree+MPAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "KdbTree+MPAdditions.h"; sourceTree = "<group>"; };
|
||||
4CC1AEBD16D4467C006D2AAB /* KdbTree+MPAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "KdbTree+MPAdditions.m"; sourceTree = "<group>"; };
|
||||
4CC6258F15BA1C99002F5B11 /* MPOutlineViewDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPOutlineViewDelegate.h; sourceTree = "<group>"; };
|
||||
4CC6259015BA1C99002F5B11 /* MPOutlineViewDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPOutlineViewDelegate.m; sourceTree = "<group>"; };
|
||||
4CD78AB716D155FF00768A1D /* 07_NotepadTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = 07_NotepadTemplate.pdf; sourceTree = "<group>"; };
|
||||
@@ -276,6 +279,8 @@
|
||||
children = (
|
||||
4C2C4C2A16D3BE3700D49295 /* KdbGroup+MPAdditions.h */,
|
||||
4C2C4C2B16D3BE3700D49295 /* KdbGroup+MPAdditions.m */,
|
||||
4CC1AEBC16D4467C006D2AAB /* KdbTree+MPAdditions.h */,
|
||||
4CC1AEBD16D4467C006D2AAB /* KdbTree+MPAdditions.m */,
|
||||
);
|
||||
name = KeePassLibAdditions;
|
||||
sourceTree = "<group>";
|
||||
@@ -746,6 +751,7 @@
|
||||
4CAC6F7816D2B54800D79D5E /* MPMainWindowSplitViewDelegate.m in Sources */,
|
||||
4C61EA0316D2FD0800AC519E /* MPOutlineViewController.m in Sources */,
|
||||
4C2C4C2C16D3BE3700D49295 /* KdbGroup+MPAdditions.m in Sources */,
|
||||
4CC1AEBE16D4467C006D2AAB /* KdbTree+MPAdditions.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
<string>NSTableHeaderView</string>
|
||||
<string>NSTableView</string>
|
||||
<string>NSTextFieldCell</string>
|
||||
<string>NSUserDefaultsController</string>
|
||||
</array>
|
||||
<array key="IBDocument.PluginDependencies">
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
@@ -243,6 +242,7 @@
|
||||
<string key="NSFrame">{{1, 119}, {223, 15}}</string>
|
||||
<reference key="NSSuperview" ref="613995671"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:60</string>
|
||||
<bool key="NSAllowsLogicalLayoutDirection">NO</bool>
|
||||
<int key="NSsFlags">1</int>
|
||||
@@ -281,9 +281,6 @@
|
||||
<double key="NSMaxMagnification">4</double>
|
||||
<double key="NSMagnification">1</double>
|
||||
</object>
|
||||
<object class="NSUserDefaultsController" id="735198371">
|
||||
<bool key="NSSharedInstance">YES</bool>
|
||||
</object>
|
||||
</array>
|
||||
<object class="IBObjectContainer" key="IBDocument.Objects">
|
||||
<array class="NSMutableArray" key="connectionRecords">
|
||||
@@ -341,6 +338,21 @@
|
||||
</array>
|
||||
<reference key="parent" ref="0"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">58</int>
|
||||
<reference key="object" ref="1037276411"/>
|
||||
<reference key="parent" ref="613995671"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">57</int>
|
||||
<reference key="object" ref="778100560"/>
|
||||
<reference key="parent" ref="613995671"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">56</int>
|
||||
<reference key="object" ref="802411427"/>
|
||||
<reference key="parent" ref="613995671"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">55</int>
|
||||
<reference key="object" ref="528076956"/>
|
||||
@@ -352,37 +364,17 @@
|
||||
<reference key="parent" ref="613995671"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">56</int>
|
||||
<reference key="object" ref="802411427"/>
|
||||
<reference key="parent" ref="613995671"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">57</int>
|
||||
<reference key="object" ref="778100560"/>
|
||||
<reference key="parent" ref="613995671"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">58</int>
|
||||
<reference key="object" ref="1037276411"/>
|
||||
<reference key="parent" ref="613995671"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">115</int>
|
||||
<reference key="object" ref="735198371"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">117</int>
|
||||
<reference key="object" ref="673679325"/>
|
||||
<int key="objectID">121</int>
|
||||
<reference key="object" ref="872321844"/>
|
||||
<array class="NSMutableArray" key="children">
|
||||
<reference ref="201181707"/>
|
||||
<reference ref="1023118108"/>
|
||||
</array>
|
||||
<reference key="parent" ref="528076956"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">118</int>
|
||||
<reference key="object" ref="201181707"/>
|
||||
<reference key="parent" ref="673679325"/>
|
||||
<int key="objectID">122</int>
|
||||
<reference key="object" ref="1023118108"/>
|
||||
<reference key="parent" ref="872321844"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">119</int>
|
||||
@@ -398,17 +390,17 @@
|
||||
<reference key="parent" ref="486655598"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">121</int>
|
||||
<reference key="object" ref="872321844"/>
|
||||
<int key="objectID">117</int>
|
||||
<reference key="object" ref="673679325"/>
|
||||
<array class="NSMutableArray" key="children">
|
||||
<reference ref="1023118108"/>
|
||||
<reference ref="201181707"/>
|
||||
</array>
|
||||
<reference key="parent" ref="528076956"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">122</int>
|
||||
<reference key="object" ref="1023118108"/>
|
||||
<reference key="parent" ref="872321844"/>
|
||||
<int key="objectID">118</int>
|
||||
<reference key="object" ref="201181707"/>
|
||||
<reference key="parent" ref="673679325"/>
|
||||
</object>
|
||||
</array>
|
||||
</object>
|
||||
@@ -416,7 +408,6 @@
|
||||
<string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="-3.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="115.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="117.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="118.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="119.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
@@ -434,7 +425,7 @@
|
||||
<nil key="activeLocalization"/>
|
||||
<dictionary class="NSMutableDictionary" key="localizations"/>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">122</int>
|
||||
<int key="maxID">231</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
|
||||
@@ -10,9 +10,8 @@
|
||||
|
||||
@interface KdbGroup (MPAdditions)
|
||||
|
||||
+ (KdbGroup *)group;
|
||||
+ (KdbGroup *)groupWithName:(NSString *)name;
|
||||
- (NSArray *)childGroups;
|
||||
|
||||
+ (void)refreshModificationTime;
|
||||
- (NSArray *)childEntries;
|
||||
|
||||
@end
|
||||
|
||||
@@ -10,15 +10,21 @@
|
||||
|
||||
@implementation KdbGroup (MPAdditions)
|
||||
|
||||
+ (KdbGroup *)group {
|
||||
KdbGroup *group = [[KdbGroup alloc] init];
|
||||
[group setName:@"Default"];
|
||||
return [group autorelease];
|
||||
- (NSArray *)childGroups {
|
||||
NSMutableArray *childGroups = [NSMutableArray arrayWithCapacity:[self.groups count]];
|
||||
for(KdbGroup *childGroup in self.groups) {
|
||||
[childGroups addObjectsFromArray:[childGroup childGroups]];
|
||||
}
|
||||
return childGroups;
|
||||
}
|
||||
|
||||
+ (KdbGroup *)groupWithName:(NSString *)name {
|
||||
KdbGroup *group = [KdbGroup group];
|
||||
[group setName:name];
|
||||
return group;
|
||||
- (NSArray *)childEntries {
|
||||
NSMutableArray *childEntries = [NSMutableArray arrayWithCapacity:[self.groups count] + [self.entries count]];
|
||||
[childEntries addObjectsFromArray:self.entries];
|
||||
for( KdbGroup *childGroup in self.groups) {
|
||||
[childEntries addObjectsFromArray:[childGroup childEntries]];
|
||||
}
|
||||
return childEntries;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
17
MacPass/KdbTree+MPAdditions.h
Normal file
17
MacPass/KdbTree+MPAdditions.h
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// KdbTree+MPAdditions.h
|
||||
// MacPass
|
||||
//
|
||||
// Created by michael starke on 20.02.13.
|
||||
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "Kdb.h"
|
||||
|
||||
@interface KdbTree (MPAdditions)
|
||||
|
||||
- (NSArray *)allEntries;
|
||||
|
||||
- (NSArray *)allGroups;
|
||||
|
||||
@end
|
||||
22
MacPass/KdbTree+MPAdditions.m
Normal file
22
MacPass/KdbTree+MPAdditions.m
Normal file
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// KdbTree+MPAdditions.m
|
||||
// MacPass
|
||||
//
|
||||
// Created by michael starke on 20.02.13.
|
||||
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "KdbTree+MPAdditions.h"
|
||||
#import "KdbGroup+MPAdditions.h"
|
||||
|
||||
@implementation KdbTree (MPAdditions)
|
||||
|
||||
- (NSArray *)allGroups {
|
||||
return [self.root childGroups];
|
||||
}
|
||||
|
||||
- (NSArray *)allEntries {
|
||||
return [self.root childEntries];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -12,5 +12,6 @@
|
||||
|
||||
@interface MPAppDelegate : NSObject <NSApplicationDelegate>
|
||||
|
||||
- (IBAction) showMainWindow:(id)sender;
|
||||
|
||||
@end
|
||||
@@ -29,6 +29,11 @@
|
||||
}
|
||||
|
||||
#pragma mark Menu Actions
|
||||
|
||||
- (void)showMainWindow:(id)sender {
|
||||
[self.mainWindowController showMainWindow:sender];
|
||||
}
|
||||
|
||||
- (void)showPreferences:(id)sender {
|
||||
if(self.settingsController == nil) {
|
||||
self.settingsController = [[[MPSettingsController alloc] init] autorelease];
|
||||
|
||||
@@ -16,5 +16,6 @@
|
||||
@property (nonatomic, assign) id<NSOutlineViewDelegate> outlineViewDelegate;
|
||||
@property (assign) KdbGroup *activeGroup;
|
||||
@property (readonly, retain) NSArrayController *entryArrayController;
|
||||
@property (nonatomic, retain) NSString *filter;
|
||||
|
||||
@end
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
|
||||
#import "MPEntryViewController.h"
|
||||
#import "MPOutlineViewDelegate.h"
|
||||
#import "MPDatabaseController.h"
|
||||
#import "MPDatabaseDocument.h"
|
||||
#import "KdbGroup+MPAdditions.h"
|
||||
|
||||
NSString *const _MPUserNameColumnIdentifier = @"MPUserNameColumnIdentifier";
|
||||
NSString *const _MPTitleColumnIdentifier = @"MPTitleColumnIdentifier";
|
||||
@@ -16,8 +19,12 @@ NSString *const _MPPasswordColumnIdentifier = @"MPPasswordColumnIdentifier";
|
||||
@interface MPEntryViewController ()
|
||||
|
||||
@property (retain) NSArrayController *entryArrayController;
|
||||
@property (retain) NSArray *filteredEntries;
|
||||
@property (assign) IBOutlet NSTableView *entryTable;
|
||||
|
||||
|
||||
- (BOOL)hasActiveFilter;
|
||||
- (void)updateFilter;
|
||||
- (void)didChangeGroupSelectionInOutlineView:(NSNotification *)notification;
|
||||
|
||||
@end
|
||||
@@ -59,6 +66,12 @@ NSString *const _MPPasswordColumnIdentifier = @"MPPasswordColumnIdentifier";
|
||||
}
|
||||
|
||||
- (void)didChangeGroupSelectionInOutlineView:(NSNotification *)notification {
|
||||
/*
|
||||
If we have an active search, do not mess with the content
|
||||
*/
|
||||
if([self hasActiveFilter]) {
|
||||
return;
|
||||
}
|
||||
MPOutlineViewDelegate *delegate = [notification object];
|
||||
KdbGroup *group = delegate.selectedGroup;
|
||||
if(group) {
|
||||
@@ -69,4 +82,35 @@ NSString *const _MPPasswordColumnIdentifier = @"MPPasswordColumnIdentifier";
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)hasActiveFilter {
|
||||
return ([self.filter length] > 0);
|
||||
}
|
||||
|
||||
- (void)setFilter:(NSString *)filter {
|
||||
if(_filter != filter) {
|
||||
[_filter release];
|
||||
_filter = [filter retain];
|
||||
[self updateFilter];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)updateFilter {
|
||||
MPDatabaseDocument *openDatabase = [MPDatabaseController defaultController].database;
|
||||
if(openDatabase) {
|
||||
if([self.filter isEqualToString:@"*"]) {
|
||||
self.filteredEntries = [openDatabase.root childEntries];
|
||||
}
|
||||
else {
|
||||
NSPredicate *filterPredicate = [NSPredicate predicateWithFormat:@"SELF.title CONTAINS[cd] %@", self.filter];
|
||||
self.filteredEntries = [[openDatabase.root childEntries] filteredArrayUsingPredicate:filterPredicate];
|
||||
}
|
||||
[self.entryArrayController setContent:self.filteredEntries];
|
||||
}
|
||||
else {
|
||||
[self.entryArrayController setContent:nil];
|
||||
self.filteredEntries = nil;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
@interface MPMainWindowController : NSWindowController
|
||||
|
||||
- (void)showEntries;
|
||||
- (void)showMainWindow:(id)sender;
|
||||
- (void)performFindPanelAction:(id)sender;
|
||||
/*
|
||||
Sets the content View controller
|
||||
@param viewController - use nil to reset to welcome screen
|
||||
|
||||
@@ -115,6 +115,14 @@
|
||||
|
||||
#pragma mark Actions
|
||||
|
||||
- (void)performFindPanelAction:(id)sender {
|
||||
[self.window makeFirstResponder:[self.toolbarDelegate.searchItem view]];
|
||||
}
|
||||
|
||||
- (void)showMainWindow:(id)sender {
|
||||
[self showWindow:self.window];
|
||||
}
|
||||
|
||||
- (void)openDocument:(id)sender {
|
||||
|
||||
if(!self.passwordInputController) {
|
||||
@@ -135,6 +143,11 @@
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)updateFilter:(id)sender {
|
||||
NSSearchField *searchField = sender;
|
||||
self.entryViewController.filter = [searchField stringValue];
|
||||
}
|
||||
|
||||
#pragma mark Notifications
|
||||
|
||||
- (void)didOpenDocument:(NSNotification *)notification {
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#import "MPMainWindowSplitViewDelegate.h"
|
||||
|
||||
const CGFloat MPMainWindowSplitViewDelegateMinimumOutlineWidth = 150.0;
|
||||
const CGFloat MPMainWindowSplitViewDelegateMaximumOutlineWidth = 400.0;
|
||||
const CGFloat MPMainWindowSplitViewDelegateMinimumContentWidth = 400.0;
|
||||
|
||||
@interface MPMainWindowSplitViewDelegate ()
|
||||
@@ -29,6 +28,10 @@ const CGFloat MPMainWindowSplitViewDelegateMinimumContentWidth = 400.0;
|
||||
return [splitView subviews][1];
|
||||
}
|
||||
|
||||
- (BOOL)splitView:(NSSplitView *)splitView canCollapseSubview:(NSView *)subview {
|
||||
return (subview == [self leftView:splitView]);
|
||||
}
|
||||
|
||||
- (CGFloat)splitView:(NSSplitView *)splitView constrainMinCoordinate:(CGFloat)proposedMinimumPosition ofSubviewAt:(NSInteger)dividerIndex {
|
||||
return (proposedMinimumPosition < MPMainWindowSplitViewDelegateMinimumOutlineWidth) ? MPMainWindowSplitViewDelegateMinimumOutlineWidth : proposedMinimumPosition;
|
||||
}
|
||||
@@ -45,18 +48,12 @@ const CGFloat MPMainWindowSplitViewDelegateMinimumContentWidth = 400.0;
|
||||
NSView *leftView = [self leftView:splitView];
|
||||
NSView *rightView = [self rightView:splitView];
|
||||
|
||||
CGFloat leftRelativeWidth = [leftView frame].size.width / oldSize.width;
|
||||
CGFloat newLeftWidth = floor(newSize.width * leftRelativeWidth);
|
||||
|
||||
if( newLeftWidth < MPMainWindowSplitViewDelegateMinimumOutlineWidth && newSize.width > MPMainWindowSplitViewDelegateMinimumOutlineWidth ) {
|
||||
newLeftWidth = MPMainWindowSplitViewDelegateMinimumOutlineWidth;
|
||||
}
|
||||
if( newLeftWidth > MPMainWindowSplitViewDelegateMaximumOutlineWidth ) {
|
||||
newLeftWidth = MPMainWindowSplitViewDelegateMaximumOutlineWidth;
|
||||
}
|
||||
NSRect newLeftFrame = NSMakeRect(0, 0, newLeftWidth, newSize.height);
|
||||
NSRect newRightFrame = NSMakeRect(newLeftWidth + dividierThickness, 0, newSize.width - newLeftWidth - dividierThickness, newSize.height);
|
||||
CGFloat leftWidth = [leftView isHidden] ? 0.0 : [leftView frame].size.width;
|
||||
NSRect newRightFrame = NSMakeRect(leftWidth + dividierThickness, 0, newSize.width - leftWidth - dividierThickness, newSize.height);
|
||||
NSRect newLeftFrame = NSMakeRect(0, 0, leftWidth, newSize.height);
|
||||
if(NO == [leftView isHidden]) {
|
||||
[leftView setFrame:newLeftFrame];
|
||||
}
|
||||
[rightView setFrame:newRightFrame];
|
||||
};
|
||||
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class MPMainWindowController;
|
||||
|
||||
@interface MPToolbarDelegate : NSObject <NSToolbarDelegate>
|
||||
|
||||
@property (assign) NSToolbarItem *searchItem;
|
||||
|
||||
@end
|
||||
|
||||
@@ -8,12 +8,14 @@
|
||||
|
||||
#import "MPToolbarDelegate.h"
|
||||
#import "MPIconHelper.h"
|
||||
#import "MPMainWindowController.h"
|
||||
|
||||
NSString *const MPToolbarItemAddGroup = @"AddGroup";
|
||||
NSString *const MPToolbarItemAddEntry = @"AddEntry";
|
||||
NSString *const MPToolbarItemEdit = @"Edit";
|
||||
NSString *const MPToolbarItemDelete =@"Delete";
|
||||
NSString *const MPToolbarItemAction = @"Action";
|
||||
NSString *const MPToolbarItemSearch = @"Search";
|
||||
|
||||
@interface MPToolbarDelegate()
|
||||
|
||||
@@ -30,7 +32,7 @@ NSString *const MPToolbarItemAction = @"Action";
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.toolbarIdentifiers = @[ MPToolbarItemAddEntry, MPToolbarItemDelete, MPToolbarItemEdit, MPToolbarItemAddGroup, MPToolbarItemAction ];
|
||||
self.toolbarIdentifiers = @[ MPToolbarItemAddEntry, MPToolbarItemDelete, MPToolbarItemEdit, MPToolbarItemAddGroup, MPToolbarItemAction, NSToolbarFlexibleSpaceItemIdentifier, MPToolbarItemSearch ];
|
||||
self.toolbarItems = [NSMutableDictionary dictionaryWithCapacity:[self.toolbarItems count]];
|
||||
self.toolbarImages = [self createToolbarImages];
|
||||
}
|
||||
@@ -40,9 +42,23 @@ NSString *const MPToolbarItemAction = @"Action";
|
||||
- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag {
|
||||
NSToolbarItem *item = self.toolbarItems[ itemIdentifier ];
|
||||
if( !item ) {
|
||||
|
||||
item = [[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier];
|
||||
NSButton *button;
|
||||
if([itemIdentifier isEqualToString:MPToolbarItemAction]) {
|
||||
[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:YES];
|
||||
[searchfield release];
|
||||
self.searchItem = item;
|
||||
}
|
||||
else if([itemIdentifier isEqualToString:MPToolbarItemAction]) {
|
||||
NSPopUpButton *popupButton = [[NSPopUpButton alloc] initWithFrame:NSMakeRect(0, 0, 50, 32) pullsDown:YES];
|
||||
[[popupButton cell] setBezelStyle:NSTexturedRoundedBezelStyle];
|
||||
[[popupButton cell] setImageScaling:NSImageScaleProportionallyDown];
|
||||
@@ -51,9 +67,9 @@ NSString *const MPToolbarItemAction = @"Action";
|
||||
Built menu
|
||||
*/
|
||||
NSMenu *menu = [NSMenu allocWithZone:[NSMenu menuZone]];
|
||||
NSMenuItem *item = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:@"" action:NULL keyEquivalent:@""];
|
||||
[item setImage:self.toolbarImages[itemIdentifier]];
|
||||
[menu addItem:item];
|
||||
NSMenuItem *menuItem = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:@"" action:NULL keyEquivalent:@""];
|
||||
[menuItem setImage:self.toolbarImages[itemIdentifier]];
|
||||
[menu addItem:menuItem];
|
||||
[menu addItemWithTitle:@"Foo" action:NULL keyEquivalent:@""];
|
||||
[menu addItemWithTitle:@"Bar" action:NULL keyEquivalent:@""];
|
||||
[popupButton setMenu:menu];
|
||||
@@ -61,12 +77,15 @@ NSString *const MPToolbarItemAction = @"Action";
|
||||
/*
|
||||
Cleanup
|
||||
*/
|
||||
[item release];
|
||||
[menuItem release];
|
||||
[menu release];
|
||||
button = popupButton;
|
||||
[popupButton sizeToFit];
|
||||
|
||||
[item setView:popupButton];
|
||||
[popupButton release];
|
||||
}
|
||||
else {
|
||||
button = [[NSButton alloc] initWithFrame:NSMakeRect(0, 0, 32, 32)];
|
||||
NSButton *button = [[NSButton alloc] initWithFrame:NSMakeRect(0, 0, 32, 32)];
|
||||
[[button cell] setBezelStyle:NSTexturedRoundedBezelStyle];
|
||||
[[button cell] setImageScaling:NSImageScaleProportionallyDown];
|
||||
[button setTitle:@""];
|
||||
@@ -74,20 +93,11 @@ NSString *const MPToolbarItemAction = @"Action";
|
||||
NSImage *image = self.toolbarImages[itemIdentifier];
|
||||
[button setImage:image];
|
||||
[button setImagePosition:NSImageOnly];
|
||||
}
|
||||
[button sizeToFit];
|
||||
|
||||
NSString *label = NSLocalizedString(itemIdentifier, @"");
|
||||
[item setLabel:label];
|
||||
|
||||
[item setView:button];
|
||||
|
||||
[item setAction:@selector(toolbarItemPressed:)];
|
||||
|
||||
self.toolbarItems[itemIdentifier] = item;
|
||||
[item release];
|
||||
[button release];
|
||||
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>B9</string>
|
||||
<string>F7</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
|
||||
@@ -759,6 +759,25 @@
|
||||
<reference key="NSOnImage" ref="35465992"/>
|
||||
<reference key="NSMixedImage" ref="502551668"/>
|
||||
</object>
|
||||
<object class="NSMenuItem" id="964160035">
|
||||
<reference key="NSMenu" ref="835318025"/>
|
||||
<bool key="NSIsDisabled">YES</bool>
|
||||
<bool key="NSIsSeparator">YES</bool>
|
||||
<string key="NSTitle"/>
|
||||
<string key="NSKeyEquiv"/>
|
||||
<int key="NSMnemonicLoc">2147483647</int>
|
||||
<reference key="NSOnImage" ref="35465992"/>
|
||||
<reference key="NSMixedImage" ref="502551668"/>
|
||||
</object>
|
||||
<object class="NSMenuItem" id="174162306">
|
||||
<reference key="NSMenu" ref="835318025"/>
|
||||
<string key="NSTitle">Show Main Window</string>
|
||||
<string key="NSKeyEquiv">0</string>
|
||||
<int key="NSKeyEquivModMask">1048576</int>
|
||||
<int key="NSMnemonicLoc">2147483647</int>
|
||||
<reference key="NSOnImage" ref="35465992"/>
|
||||
<reference key="NSMixedImage" ref="502551668"/>
|
||||
</object>
|
||||
<object class="NSMenuItem" id="299356726">
|
||||
<reference key="NSMenu" ref="835318025"/>
|
||||
<bool key="NSIsDisabled">YES</bool>
|
||||
@@ -1227,6 +1246,14 @@
|
||||
</object>
|
||||
<int key="connectionID">1175</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBActionConnection" key="connection">
|
||||
<string key="label">showMainWindow:</string>
|
||||
<reference key="source" ref="976324537"/>
|
||||
<reference key="destination" ref="174162306"/>
|
||||
</object>
|
||||
<int key="connectionID">1178</int>
|
||||
</object>
|
||||
</array>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
<array key="orderedObjects">
|
||||
@@ -1620,6 +1647,8 @@
|
||||
<reference ref="625202149"/>
|
||||
<reference ref="575023229"/>
|
||||
<reference ref="1011231497"/>
|
||||
<reference ref="964160035"/>
|
||||
<reference ref="174162306"/>
|
||||
</array>
|
||||
<reference key="parent" ref="713487014"/>
|
||||
</object>
|
||||
@@ -1843,6 +1872,16 @@
|
||||
<reference key="object" ref="738670835"/>
|
||||
<reference key="parent" ref="963351320"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">1176</int>
|
||||
<reference key="object" ref="964160035"/>
|
||||
<reference key="parent" ref="835318025"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">1177</int>
|
||||
<reference key="object" ref="174162306"/>
|
||||
<reference key="parent" ref="835318025"/>
|
||||
</object>
|
||||
</array>
|
||||
</object>
|
||||
<dictionary class="NSMutableDictionary" key="flattenedProperties">
|
||||
@@ -1850,6 +1889,8 @@
|
||||
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="-3.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="112.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="1176.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="1177.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="124.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="125.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="126.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
@@ -1944,24 +1985,27 @@
|
||||
<nil key="activeLocalization"/>
|
||||
<dictionary class="NSMutableDictionary" key="localizations"/>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">1175</int>
|
||||
<int key="maxID">1178</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">MPAppDelegate</string>
|
||||
<string key="superclassName">NSObject</string>
|
||||
<object class="NSMutableDictionary" key="actions">
|
||||
<string key="NS.key.0">showPreferences:</string>
|
||||
<string key="NS.object.0">id</string>
|
||||
<dictionary class="NSMutableDictionary" key="actions">
|
||||
<string key="showMainWindow:">id</string>
|
||||
<string key="showPreferences:">id</string>
|
||||
</dictionary>
|
||||
<dictionary class="NSMutableDictionary" key="actionInfosByName">
|
||||
<object class="IBActionInfo" key="showMainWindow:">
|
||||
<string key="name">showMainWindow:</string>
|
||||
<string key="candidateClassName">id</string>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="actionInfosByName">
|
||||
<string key="NS.key.0">showPreferences:</string>
|
||||
<object class="IBActionInfo" key="NS.object.0">
|
||||
<object class="IBActionInfo" key="showPreferences:">
|
||||
<string key="name">showPreferences:</string>
|
||||
<string key="candidateClassName">id</string>
|
||||
</object>
|
||||
</object>
|
||||
</dictionary>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBProjectSource</string>
|
||||
<string key="minorKey">./Classes/MPAppDelegate.h</string>
|
||||
|
||||
Reference in New Issue
Block a user