diff --git a/PBGitHistoryController.h b/PBGitHistoryController.h index 4b171eb..f87c462 100644 --- a/PBGitHistoryController.h +++ b/PBGitHistoryController.h @@ -25,7 +25,6 @@ PBGitCommit* webCommit; PBGitCommit* rawCommit; PBGitCommit* realCommit; - } @property (assign) int selectedTab; @@ -46,4 +45,6 @@ - (void) copyCommitInfo; - (BOOL) hasNonlinearPath; + +- (NSMenu *)tableColumnMenu; @end diff --git a/PBGitHistoryController.m b/PBGitHistoryController.m index 69a79f7..9c18b72 100644 --- a/PBGitHistoryController.m +++ b/PBGitHistoryController.m @@ -39,7 +39,8 @@ // Set a sort descriptor for the subject column in the history list, as // It can't be sorted by default (because it's bound to a PBGitCommit) [[commitList tableColumnWithIdentifier:@"subject"] setSortDescriptorPrototype:[[NSSortDescriptor alloc] initWithKey:@"subject" ascending:YES]]; - + // Add a menu that allows a user to select which columns to view + [[commitList headerView] setMenu:[self tableColumnMenu]]; [super awakeFromNib]; } @@ -202,4 +203,19 @@ [super removeView]; } +- (NSMenu *)tableColumnMenu +{ + NSMenu *menu = [[NSMenu alloc] initWithTitle:@"Table columns menu"]; + for (NSTableColumn *column in [commitList tableColumns]) { + NSMenuItem *item = [[NSMenuItem alloc] init]; + [item setTitle:[[column headerCell] stringValue]]; + [item bind:@"value" + toObject:column + withKeyPath:@"hidden" + options:[NSDictionary dictionaryWithObject:@"NSNegateBoolean" forKey:NSValueTransformerNameBindingOption]]; + [menu addItem:item]; + } + return menu; +} + @end