Browse files

History view: Make lozenge of currently checked out branch (HEAD) bol…

…d, same as gitk.
  • Loading branch information...
1 parent 4b27186 commit 63523d00e8265a097cb23f7535b6f4bb83ca08e6 @clj clj committed with Oct 9, 2008
Showing with 19 additions and 5 deletions.
  1. +1 −0 PBGitRepository.h
  2. +12 −4 PBGitRevisionCell.m
  3. +1 −0 PBWebHistoryController.m
  4. +2 −1 html/commit.js
  5. +3 −0 html/commits.css
View
1 PBGitRepository.h
@@ -37,6 +37,7 @@ extern NSString* PBGitRepositoryErrorDomain;
- (void) addRef:(PBGitRef *)ref fromParameters:(NSArray *)params;
- (BOOL) removeRef:(NSString *)ref;
- (void) lazyReload;
+- (PBGitRevSpecifier*) headRef;
- (void) readCurrentBranch;
- (PBGitRevSpecifier*) addBranch: (PBGitRevSpecifier*) rev;
View
16 PBGitRevisionCell.m
@@ -109,14 +109,20 @@ - (void) drawTriangleInRect: (NSRect) r sign: (char) sign
[path stroke];
}
-- (NSMutableDictionary*) attributesForRefLabelSelected: (BOOL) selected
+- (NSMutableDictionary*) attributesForRefLabelSelected: (BOOL) selected isCurrentBranch: (BOOL) curBranch
{
NSMutableDictionary *attributes = [[[NSMutableDictionary alloc] initWithCapacity:2] autorelease];
NSMutableParagraphStyle* style = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] autorelease];
+ NSString *fontName;
+
+ if(curBranch)
+ fontName = @"Helvetica-Bold";
+ else
+ fontName = @"Helvetica";
[style setAlignment:NSCenterTextAlignment];
[attributes setObject:style forKey:NSParagraphStyleAttributeName];
- [attributes setObject:[NSFont fontWithName:@"Helvetica" size:9] forKey:NSFontAttributeName];
+ [attributes setObject:[NSFont fontWithName:fontName size:9] forKey:NSFontAttributeName];
//if (selected)
// [attributes setObject:[NSColor alternateSelectedControlTextColor] forKey:NSForegroundColorAttributeName];
@@ -149,9 +155,11 @@ - (void) drawRefsInRect: (NSRect*) rect
int index;
for (index = 0; index < [refs count]; ++index) {
- PBGitRef* ref = [refs objectAtIndex:index];
+ PBGitRef *ref = [refs objectAtIndex:index];
+ BOOL isCurBranch = [ref.ref isEqualToString:[[[controller repository] headRef] simpleRef]];
- NSMutableDictionary* attributes = [self attributesForRefLabelSelected:[self isHighlighted]];
+ NSMutableDictionary* attributes = [self attributesForRefLabelSelected:[self isHighlighted]
+ isCurrentBranch:isCurBranch];
NSSize refSize = [[ref shortName] sizeWithAttributes:attributes];
refRect.size.width = refSize.width + ref_padding;
View
1 PBWebHistoryController.m
@@ -49,6 +49,7 @@ - (void) changeContentTo: (PBGitCommit *) content
id script = [view windowScriptObject];
[script setValue: content forKey:@"CommitObject"];
+ [script setValue:[[[historyController repository] headRef] simpleRef] forKey:@"CurrentBranch"];
// The sha is the same, but refs may have changed.. reload it lazy
if ([currentSha isEqualToString: content.sha])
View
3 html/commit.js
@@ -108,7 +108,8 @@ var showRefs = function() {
$('refs').parentNode.style.display = "";
$('refs').innerHTML = "";
$A(commit.refs).each(function(ref) {
- $('refs').innerHTML += '<span class="refs ' + ref.type() + '">' + ref.shortName() + '</span>';
+ curBranch = "";
+ $('refs').innerHTML += '<span class="refs ' + ref.type() + (CurrentBranch == ref.ref ? ' currentBranch' : '') + '">' + ref.shortName() + '</span>';
});
} else
$('refs').parentNode.style.display = "none";
View
3 html/commits.css
@@ -81,3 +81,6 @@ a.showdiff {
background-color: #fced4f;
}
+.refs.currentBranch {
+ font-weight: bold;
+}

0 comments on commit 63523d0

Please sign in to comment.