diff --git a/MacPass/MPToolbarDelegate.m b/MacPass/MPToolbarDelegate.m index 2a4243b1..71a3890d 100644 --- a/MacPass/MPToolbarDelegate.m +++ b/MacPass/MPToolbarDelegate.m @@ -105,18 +105,18 @@ NSString *const MPToolbarItemCopyPassword = @"TOOLBAR_COPY_PASSWORD"; if([itemIdentifier isEqualToString:MPToolbarItemAction]) { NSPopUpButton *popupButton = [[NSPopUpButton alloc] initWithFrame:NSMakeRect(0, 0, 50, 32) pullsDown:YES]; - [[popupButton cell] setBezelStyle:NSTexturedRoundedBezelStyle]; - [[popupButton cell] setImageScaling:NSImageScaleProportionallyDown]; - [popupButton setFocusRingType:NSFocusRingTypeNone]; - [popupButton setTitle:@""]; + popupButton.bezelStyle = NSTexturedRoundedBezelStyle; + popupButton.focusRingType = NSFocusRingTypeNone; + popupButton.title = @""; + [popupButton.cell setImageScaling:NSImageScaleProportionallyDown]; [popupButton sizeToFit]; - NSRect newFrame = [popupButton frame]; + NSRect newFrame = popupButton.frame; newFrame.size.width += 20; - NSMenu *menu = [[NSMenu allocWithZone:[NSMenu menuZone]] init]; - NSMenuItem *actionImageItem = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:@"" action:NULL keyEquivalent:@""]; - [actionImageItem setImage:self.toolbarImages[MPToolbarItemAction]]; + NSMenu *menu = [[NSMenu alloc] init]; + NSMenuItem *actionImageItem = [[NSMenuItem alloc] initWithTitle:@"" action:NULL keyEquivalent:@""]; + actionImageItem.image = self.toolbarImages[MPToolbarItemAction]; [menu addItem:actionImageItem]; NSArray *menuItems = [MPContextMenuHelper contextMenuItemsWithItems:MPContextMenuExtended]; for(NSMenuItem *item in menuItems) { @@ -125,31 +125,31 @@ NSString *const MPToolbarItemCopyPassword = @"TOOLBAR_COPY_PASSWORD"; NSMenuItem *menuRepresentation = [[NSMenuItem alloc] initWithTitle:itemLabel action:[self _actionForToolbarItemIdentifier:itemIdentifier] keyEquivalent:@""]; - [menuRepresentation setSubmenu:menu]; + menuRepresentation.submenu = menu; - [popupButton setFrame:newFrame]; - [popupButton setMenu:menu]; - [item setMenuFormRepresentation:menuRepresentation]; - [item setView:popupButton]; + popupButton.frame = newFrame; + popupButton.menu = menu; + item.menuFormRepresentation = menuRepresentation; + item.view = popupButton; } else if( [itemIdentifier isEqualToString:MPToolbarItemAddEntry]) { MPContextToolbarButton *button = [[MPContextToolbarButton alloc] initWithFrame:NSMakeRect(0, 0, 32, 32)]; [button setAction:[self _actionForToolbarItemIdentifier:itemIdentifier]]; NSImage *image = self.toolbarImages[itemIdentifier]; - [image setSize:NSMakeSize(16, 16)]; + image.size = NSMakeSize(16, 16); [button setImage:image]; [button sizeToFit]; NSMenu *menu = [NSMenu allocWithZone:[NSMenu menuZone]]; [menu addItemWithTitle:@"Dummy" action:NULL keyEquivalent:@""]; - [menu setDelegate:_entryMenuDelegate]; + menu.delegate = _entryMenuDelegate; [button setContextMenu:menu]; - NSRect fittingRect = [button frame]; + NSRect fittingRect = button.frame; fittingRect.size.width = MAX( (CGFloat)32.0,fittingRect.size.width); - [button setFrame:fittingRect]; - [item setView:button]; + button.frame = fittingRect; + item.view = button; /* Create the Contextual Menu button */ NSMenuItem *menuRepresentation = [[NSMenuItem alloc] initWithTitle:itemLabel action:[self _actionForToolbarItemIdentifier:itemIdentifier] @@ -159,35 +159,35 @@ NSString *const MPToolbarItemCopyPassword = @"TOOLBAR_COPY_PASSWORD"; } else if( [itemIdentifier isEqualToString:MPToolbarItemSearch]){ NSSearchField *searchField = [[NSSearchField alloc] init]; - [searchField setAction:@selector(updateSearch:)]; - NSSearchFieldCell *cell = [searchField cell]; - [[cell cancelButtonCell] setAction:@selector(exitSearch:)]; - [[cell cancelButtonCell] setTarget:nil]; - [searchField setRecentsAutosaveName:@"RecentEntrySearches"]; - [item setView:searchField]; + searchField.action = @selector(updateSearch:); + NSSearchFieldCell *cell = searchField.cell; + cell.cancelButtonCell.action = @selector(exitSearch:); + cell.cancelButtonCell.target = nil; + searchField.recentsAutosaveName = @"RecentEntrySearches"; + item.view = searchField; /* Use default size base on documentation */ - [item setMinSize:NSMakeSize(140, 32)]; - [item setMaxSize:NSMakeSize(240, 32)]; + item.minSize = NSMakeSize(140, 32); + item.maxSize = NSMakeSize(240, 32); NSMenu *templateMenu = [self _allocateSearchMenuTemplate]; - [[searchField cell] setSearchMenuTemplate:templateMenu]; + [searchField.cell setSearchMenuTemplate:templateMenu]; self.searchField = searchField; } else { NSButton *button = [[MPToolbarButton alloc] initWithFrame:NSMakeRect(0, 0, 32, 32)]; NSImage *image = self.toolbarImages[itemIdentifier]; - [image setSize:NSMakeSize(16, 16)]; + image.size = NSMakeSize(16, 16); [button setImage:image]; [button sizeToFit]; - [button setAction:[self _actionForToolbarItemIdentifier:itemIdentifier]]; + button.action = [self _actionForToolbarItemIdentifier:itemIdentifier]; NSRect fittingRect = [button frame]; fittingRect.size.width = MAX( (CGFloat)32.0,fittingRect.size.width); - [button setFrame:fittingRect]; - [item setView:button]; + button.frame = fittingRect; + item.view = button; NSMenuItem *menuRepresentation = [[NSMenuItem alloc] initWithTitle:itemLabel action:[self _actionForToolbarItemIdentifier:itemIdentifier] keyEquivalent:@""]; - [item setMenuFormRepresentation:menuRepresentation]; + item.menuFormRepresentation = menuRepresentation; } self.toolbarItems[itemIdentifier] = item; } @@ -259,21 +259,21 @@ NSString *const MPToolbarItemCopyPassword = @"TOOLBAR_COPY_PASSWORD"; - (NSMenu *)_allocateSearchMenuTemplate { NSMenu *menu = [[NSMenu alloc] init]; NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"CLEAR_RECENT_SEARCHES", @"") action:NULL keyEquivalent:@""]; - [item setTag:NSSearchFieldClearRecentsMenuItemTag]; + item.tag = NSSearchFieldClearRecentsMenuItemTag; [menu addItem:item]; [menu addItem:[NSMenuItem separatorItem]]; item = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"RECENT_SEARCHES", @"") action:NULL keyEquivalent:@""]; - [item setTag:NSSearchFieldRecentsTitleMenuItemTag]; + item.tag = NSSearchFieldRecentsTitleMenuItemTag; [menu addItem:item]; item = [[NSMenuItem alloc] initWithTitle:@"Recents" action:NULL keyEquivalent:@""]; - [item setTag:NSSearchFieldRecentsMenuItemTag]; + item.tag = NSSearchFieldRecentsMenuItemTag; [menu addItem:item]; item = [[NSMenuItem alloc] initWithTitle:@"NoEntries" action:NULL keyEquivalent:@""]; - [item setTag:NSSearchFieldNoRecentsMenuItemTag]; + item.tag = NSSearchFieldNoRecentsMenuItemTag; [menu addItem:item]; return menu; @@ -281,16 +281,16 @@ NSString *const MPToolbarItemCopyPassword = @"TOOLBAR_COPY_PASSWORD"; - (void)_didEnterSearch:(NSNotification *)notification { /* We enter search. If there is no Item to search in the toolbar, we need to add it */ - NSArray *currentItems = [self.toolbar items]; + NSArray *currentItems = self.toolbar.items; NSToolbarItem *searchItem = self.toolbarItems[MPToolbarItemSearch]; if(!searchItem || ![currentItems containsObject:searchItem]) { [self.toolbar insertItemWithItemIdentifier:MPToolbarItemSearch atIndex:[currentItems count]]; _didAddSearchfieldForSearch = YES; } /* Then we should make sure the toolbar is visible. Just to make life easier */ - if(![self.toolbar isVisible]) { + if(!self.toolbar.visible) { _didShowToolbarForSearch = YES; - [self.toolbar setVisible:YES]; + self.toolbar.visible = YES; } _displayModeBeforeSearch = [self.toolbar displayMode]; if(_displayModeBeforeSearch == NSToolbarDisplayModeLabelOnly) { @@ -298,7 +298,7 @@ NSString *const MPToolbarItemCopyPassword = @"TOOLBAR_COPY_PASSWORD"; } /* only make the searchfield first responder if it's not already in an active search */ if(![self.searchField currentEditor]) { - [[self.searchField window] makeFirstResponder:self.searchField]; + [self.searchField.window makeFirstResponder:self.searchField]; [self.searchField selectText:self]; } } @@ -307,23 +307,23 @@ NSString *const MPToolbarItemCopyPassword = @"TOOLBAR_COPY_PASSWORD"; [self.searchField setStringValue:@""]; NSWindow *window = [self.searchField window]; /* Resign first responder form search field only if it was the first responder */ - if([window firstResponder] == [self.searchField currentEditor]) { + if(window.firstResponder == [self.searchField currentEditor]) { [window makeFirstResponder:nil]; } if(_didAddSearchfieldForSearch) { NSToolbarItem *searchItem = self.toolbarItems[MPToolbarItemSearch]; - NSUInteger index = [[self.toolbar items] indexOfObject:searchItem]; + NSUInteger index = [self.toolbar.items indexOfObject:searchItem]; if(index != NSNotFound) { [self.toolbar removeItemAtIndex:index]; _didAddSearchfieldForSearch = NO; } } - if(_displayModeBeforeSearch != [self.toolbar displayMode]) { - [self.toolbar setDisplayMode:_displayModeBeforeSearch]; + if(_displayModeBeforeSearch != self.toolbar.displayMode) { + self.toolbar.displayMode = _displayModeBeforeSearch; } - if(_didShowToolbarForSearch && [self.toolbar isVisible]) { + if(_didShowToolbarForSearch && self.toolbar.visible) { _didShowToolbarForSearch = NO; - [self.toolbar setVisible:NO]; + self.toolbar.visible = NO; } }