From 06d3b9bcc56efeb089e983aafd5ce285a232bb9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Berg?= Date: Tue, 10 Nov 2009 18:35:00 +0100 Subject: [PATCH] Bug fix: Re-enable the toolbar item validation. Although it is true that the remote can be chosen arbitrarily through the popup menus we still need to have a specific local branch. All branches is not a specific branch. Of course we could do away with determining the current local branch through what's selected in the branch popup menu and instead focus on what the appropriate controller's current selection is. --- PBGitHistoryController.m | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/PBGitHistoryController.m b/PBGitHistoryController.m index b0b44e7..f74a212 100644 --- a/PBGitHistoryController.m +++ b/PBGitHistoryController.m @@ -98,27 +98,23 @@ // MARK: NSToolbarItemValidation Methods -// !!! Andre Berg 20091110: I don't think this is needed any more since the Push, Pull -// and Rebase toolbar items are now popup buttons it makes no sense to disable them -// when switching to "All branches" or "Local branches" since you can choose the remote -// from the popup menus. -// - (BOOL) validateToolbarItem:(NSToolbarItem *)theItem { -// -// NSString * curBranchDesc = [[repository currentBranch] description]; -// NSArray * candidates = [NSArray arrayWithObjects:@"Push", @"Pull", @"Rebase", nil]; -// BOOL res; -// -// if (([candidates containsObject:[theItem label]]) && -// (([curBranchDesc isEqualToString:@"All branches"]) || -// ([curBranchDesc isEqualToString:@"Local branches"]))) -// { -// res = NO; -// } else { -// res = YES; -// } -// -// return res; -// } +- (BOOL) validateToolbarItem:(NSToolbarItem *)theItem { + + NSString * curBranchDesc = [[repository currentBranch] description]; + NSArray * candidates = [NSArray arrayWithObjects:@"Push", @"Pull", @"Rebase", nil]; + BOOL res; + + if (([candidates containsObject:[theItem label]]) && + (([curBranchDesc isEqualToString:@"All branches"]) || + ([curBranchDesc isEqualToString:@"Local branches"]))) + { + res = NO; + } else { + res = YES; + } + + return res; +} // MARK: PBGitHistoryController