Allow a user to select which columns to display

This commit is contained in:
Pieter de Bie
2009-05-28 12:00:06 +01:00
parent 785e7eda42
commit 8273aecb98
2 changed files with 19 additions and 2 deletions
+2 -1
View File
@@ -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
+17 -1
View File
@@ -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