Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pieter/119229 to your computer and use it in GitHub Desktop.
Save pieter/119229 to your computer and use it in GitHub Desktop.
From 8273aecb9860ef843f60fb7e8655052cdc68cd06 Mon Sep 17 00:00:00 2001
From: Pieter de Bie <frimmirf+gitx@gmail.com>
Date: Thu, 28 May 2009 12:00:06 +0100
Subject: [PATCH] Allow a user to select which columns to display
---
PBGitHistoryController.h | 3 ++-
PBGitHistoryController.m | 18 +++++++++++++++++-
2 files changed, 19 insertions(+), 2 deletions(-)
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
--
1.6.3.76.g775d1+GitX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment