Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // PreferencesWindow.m
- // Test
- //
- // Created by Vadim Demedes on 9/22/11.
- // Copyright 2011 __MyCompanyName__. All rights reserved.
- //
- #import "PreferencesWindow.h"
- static NSString *GeneralToolbarItemIdentifier = @"General";
- @implementation PreferencesWindow
- @synthesize window;
- - (void)awakeFromNib
- {
- NSToolbar *toolbar = [[NSToolbar alloc] initWithIdentifier:@"MySampleToolbar"];
- // set initial toolbar properties
- [toolbar setAllowsUserCustomization:YES];
- [toolbar setAutosavesConfiguration:YES];
- [toolbar setDisplayMode:NSToolbarDisplayModeIconAndLabel];
- // set our controller as the toolbar delegate
- [toolbar setDelegate:self];
- // attach the toolbar to our window
- [window setToolbar:toolbar];
- // clean up
- [toolbar release];
- }
- - (NSArray *) toolbarAllowedItemIdentifiers: (NSToolbar *) toolbar {
- return [NSArray arrayWithObjects:GeneralToolbarItemIdentifier,
- NSToolbarFlexibleSpaceItemIdentifier,
- NSToolbarSpaceItemIdentifier,
- NSToolbarSeparatorItemIdentifier, nil];
- }
- - (NSArray *) toolbarDefaultItemIdentifiers: (NSToolbar *)toolbar
- {
- return [NSArray arrayWithObjects:GeneralToolbarItemIdentifier,
- NSToolbarFlexibleSpaceItemIdentifier,
- nil];
- }
- - (NSToolbarItem *)toolbar:(NSToolbar *)toolbar
- itemForItemIdentifier:(NSString *)itemIdentifier
- willBeInsertedIntoToolbar:(BOOL)flag
- {
- NSToolbarItem *toolbarItem = nil;
- if ([itemIdentifier isEqualTo:GeneralToolbarItemIdentifier]) {
- toolbarItem = [[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier];
- [toolbarItem setLabel:@"Save"];
- [toolbarItem setPaletteLabel:[toolbarItem label]];
- [toolbarItem setToolTip:@"Save Your Passwords"];
- [toolbarItem setImage:[NSImage imageNamed:@"menuBarIcon.png"]];
- [toolbarItem setTarget:self];
- [toolbarItem setAction:nil];
- }
- return [toolbarItem autorelease];
- }
- @end
Add Comment
Please, Sign In to add comment