Guest User

Untitled

a guest
Jan 16th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. //
  2. // PreferencesWindow.m
  3. // Test
  4. //
  5. // Created by Vadim Demedes on 9/22/11.
  6. // Copyright 2011 __MyCompanyName__. All rights reserved.
  7. //
  8.  
  9. #import "PreferencesWindow.h"
  10.  
  11. static NSString *GeneralToolbarItemIdentifier = @"General";
  12.  
  13. @implementation PreferencesWindow
  14.  
  15. @synthesize window;
  16.  
  17. - (void)awakeFromNib
  18. {
  19. NSToolbar *toolbar = [[NSToolbar alloc] initWithIdentifier:@"MySampleToolbar"];
  20.  
  21. // set initial toolbar properties
  22. [toolbar setAllowsUserCustomization:YES];
  23. [toolbar setAutosavesConfiguration:YES];
  24. [toolbar setDisplayMode:NSToolbarDisplayModeIconAndLabel];
  25.  
  26. // set our controller as the toolbar delegate
  27. [toolbar setDelegate:self];
  28.  
  29. // attach the toolbar to our window
  30. [window setToolbar:toolbar];
  31.  
  32. // clean up
  33. [toolbar release];
  34. }
  35.  
  36. - (NSArray *) toolbarAllowedItemIdentifiers: (NSToolbar *) toolbar {
  37. return [NSArray arrayWithObjects:GeneralToolbarItemIdentifier,
  38. NSToolbarFlexibleSpaceItemIdentifier,
  39. NSToolbarSpaceItemIdentifier,
  40. NSToolbarSeparatorItemIdentifier, nil];
  41. }
  42.  
  43. - (NSArray *) toolbarDefaultItemIdentifiers: (NSToolbar *)toolbar
  44. {
  45. return [NSArray arrayWithObjects:GeneralToolbarItemIdentifier,
  46. NSToolbarFlexibleSpaceItemIdentifier,
  47. nil];
  48. }
  49.  
  50. - (NSToolbarItem *)toolbar:(NSToolbar *)toolbar
  51. itemForItemIdentifier:(NSString *)itemIdentifier
  52. willBeInsertedIntoToolbar:(BOOL)flag
  53. {
  54. NSToolbarItem *toolbarItem = nil;
  55.  
  56. if ([itemIdentifier isEqualTo:GeneralToolbarItemIdentifier]) {
  57. toolbarItem = [[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier];
  58. [toolbarItem setLabel:@"Save"];
  59. [toolbarItem setPaletteLabel:[toolbarItem label]];
  60. [toolbarItem setToolTip:@"Save Your Passwords"];
  61. [toolbarItem setImage:[NSImage imageNamed:@"menuBarIcon.png"]];
  62. [toolbarItem setTarget:self];
  63. [toolbarItem setAction:nil];
  64. }
  65.  
  66. return [toolbarItem autorelease];
  67. }
  68.  
  69. @end
Add Comment
Please, Sign In to add comment