Permalink
Browse files

Quickly hide git button if git is not installed. This should be impro…

…ved since it's a dumb check instead of checking the environment. (#50)
  • Loading branch information...
soffes committed May 28, 2011
1 parent 3161f79 commit f68871539576d5626feac1e51e4dadaee91bfbf6
Showing with 30 additions and 22 deletions.
  1. +30 −22 Classes/MDSidebarBorderView.m
@@ -45,6 +45,7 @@ NSComparisonResult compareFrameOriginX(id viewA, id viewB, void *context) {
}
@interface MDSidebarBorderView (PrivateMethods)
- (BOOL)_gitInstalled;
- (NSString *)_selectedFilePath;
@end
@@ -149,33 +150,35 @@ - (void)addToSuperview:(NSView *)superview {
[terminalButton setBordered:NO];
[btns addObject:terminalButton];
[terminalButton release];
// Gitx button
NSRect gitButtonFrame;
gitButtonFrame.size.width = 23;
gitButtonFrame.size.height = [terminalButton frame].size.height;
gitButtonFrame.origin.x = [terminalButton frame].origin.x + gitButtonFrame.size.width;
gitButtonFrame.origin.y = [terminalButton frame].origin.y;
NSButton *gitButton = [[NSButton alloc] initWithFrame:gitButtonFrame];
NSImage *gitButtonImage = [MDSidebarBorderView bundledImageWithName:@"git"];
NSImage *gitButtonImagePressed = [MDSidebarBorderView bundledImageWithName:@"gitPressed"];
[gitButton setToolTip:@"Open git window here"];
[gitButton setImage:gitButtonImage];
[gitButton setAlternateImage:gitButtonImagePressed];
[gitButton setAction:@selector(gitButtonPressed:)];
[gitButton setTarget:self];
[gitButton setBordered:NO];
[btns addObject:gitButton];
[gitButton release];
// Git button
if ([self _gitInstalled]) {
NSRect gitButtonFrame;
gitButtonFrame.size.width = 23;
gitButtonFrame.size.height = [terminalButton frame].size.height;
gitButtonFrame.origin.x = [terminalButton frame].origin.x + gitButtonFrame.size.width;
gitButtonFrame.origin.y = [terminalButton frame].origin.y;
NSButton *gitButton = [[NSButton alloc] initWithFrame:gitButtonFrame];
NSImage *gitButtonImage = [MDSidebarBorderView bundledImageWithName:@"git"];
NSImage *gitButtonImagePressed = [MDSidebarBorderView bundledImageWithName:@"gitPressed"];
[gitButton setToolTip:@"Open git window here"];
[gitButton setImage:gitButtonImage];
[gitButton setAlternateImage:gitButtonImagePressed];
[gitButton setAction:@selector(gitButtonPressed:)];
[gitButton setTarget:self];
[gitButton setBordered:NO];
[btns addObject:gitButton];
[gitButton release];
}
// [btns sortUsingFunction:(NSInteger (*)(id, id, void *))compareFrameOriginX context:nil];
// Adjust outlineView frame
if (outlineView){
if (outlineView) {
NSRect aRect = [superview frame];
aRect.origin.x = -1.0;
aRect.origin.y = [self frame].size.height;
@@ -302,6 +305,11 @@ - (void)gitButtonPressed:(id)sender {
#pragma mark Private Methods
- (BOOL)_gitInstalled {
return [[NSFileManager defaultManager] fileExistsAtPath:@"/usr/local/bin/git"];
}
- (NSString *)_selectedFilePath {
NSArray *selectedItems = nil;
if (_projectFileOutlineView &&

0 comments on commit f688715

Please sign in to comment.