Skip to content
Browse files

set state (checkmark) on view menu items to reflect active view

  • Loading branch information...
1 parent 395877f commit d91ed3d8c3874d213490172c3b8b974d401e4ef5 @sleifer sleifer committed with
Showing with 20 additions and 1 deletion.
  1. +10 −0 PBGitHistoryController.m
  2. +3 −0 PBGitSidebarController.h
  3. +2 −0 PBGitSidebarController.m
  4. +5 −1 PBGitWindowController.m
View
10 PBGitHistoryController.m
@@ -276,6 +276,16 @@ - (IBAction) openSelectedFile:(id)sender
[[NSWorkspace sharedWorkspace] openTempFile:name];
}
+- (BOOL)validateMenuItem:(NSMenuItem *)menuItem
+{
+ if ([menuItem action] == @selector(setDetailedView:)) {
+ [menuItem setState:(self.selectedCommitDetailsIndex == kHistoryDetailViewIndex) ? NSOnState : NSOffState];
+ } else if ([menuItem action] == @selector(setTreeView:)) {
+ [menuItem setState:(self.selectedCommitDetailsIndex == kHistoryTreeViewIndex) ? NSOnState : NSOffState];
+ }
+ return YES;
+}
+
- (IBAction) setDetailedView:(id)sender
{
self.selectedCommitDetailsIndex = kHistoryDetailViewIndex;
View
3 PBGitSidebarController.h
@@ -42,4 +42,7 @@
@property(readonly) NSMutableArray *items;
@property(readonly) NSView *sourceListControlsView;
+@property(readonly) PBGitHistoryController *historyViewController;
+@property(readonly) PBGitCommitController *commitViewController;
+
@end
View
2 PBGitSidebarController.m
@@ -30,6 +30,8 @@ - (void) updateRemoteControls;
@implementation PBGitSidebarController
@synthesize items;
@synthesize sourceListControlsView;
+@synthesize historyViewController;
+@synthesize commitViewController;
- (id)initWithRepository:(PBGitRepository *)theRepository superController:(PBGitWindowController *)controller
{
View
6 PBGitWindowController.m
@@ -43,7 +43,11 @@ - (void)windowWillClose:(NSNotification *)notification
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem
{
- if ([menuItem action] == @selector(showCommitView:) || [menuItem action] == @selector(showHistoryView:)) {
+ if ([menuItem action] == @selector(showCommitView:)) {
+ [menuItem setState:(contentController == sidebarController.commitViewController) ? YES : NO];
+ return ![repository isBareRepository];
+ } else if ([menuItem action] == @selector(showHistoryView:)) {
+ [menuItem setState:(contentController != sidebarController.commitViewController) ? YES : NO];
return ![repository isBareRepository];
}
return YES;

0 comments on commit d91ed3d

Please sign in to comment.
Something went wrong with that request. Please try again.