mirror of
https://github.com/textmate/textmate.git
synced 2026-04-28 03:00:34 -04:00
Commit button title summarizes the number of files to be committed
This commit is contained in:
committed by
Allan Odgaard
parent
0361afe340
commit
d60c47ef42
@@ -77,6 +77,8 @@ static NSString* const kOakCommitWindowCommitMessages = @"commitMessages";
|
||||
static NSUInteger const kOakCommitWindowCommitMessagesTitleLength = 30;
|
||||
static NSUInteger const kOakCommitWindowCommitMessagesMax = 5;
|
||||
|
||||
static void* kOakCommitWindowIncludeItemBinding = &kOakCommitWindowIncludeItemBinding;
|
||||
|
||||
@interface OakCommitWindow : NSWindowController <NSWindowDelegate, NSTableViewDelegate, NSMenuDelegate, OakTextViewDelegate>
|
||||
@property (nonatomic) NSMutableDictionary* options;
|
||||
@property (nonatomic) NSMutableArray* parameters;
|
||||
@@ -188,10 +190,17 @@ static NSUInteger const kOakCommitWindowCommitMessagesMax = 5;
|
||||
}
|
||||
|
||||
[self updateConstraints];
|
||||
|
||||
[_arrayController addObserver:self forKeyPath:@"arrangedObjects.commit" options:NSKeyValueObservingOptionInitial|NSKeyValueObservingOptionNew context:kOakCommitWindowIncludeItemBinding];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[self.arrayController removeObserver:self forKeyPath:@"arrangedObjects.commit"];
|
||||
}
|
||||
|
||||
- (NSDictionary*)allViews
|
||||
{
|
||||
NSDictionary* views = @{
|
||||
@@ -289,6 +298,20 @@ static NSUInteger const kOakCommitWindowCommitMessagesMax = 5;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)observeValueForKeyPath:(NSString*)aKeyPath ofObject:(id)anObject change:(NSDictionary*)someChange context:(void*)context
|
||||
{
|
||||
if(context == kOakCommitWindowIncludeItemBinding)
|
||||
{
|
||||
NSUInteger totalFilesToCommit = 0;
|
||||
for(CWItem* item in [_arrayController arrangedObjects])
|
||||
{
|
||||
if(item.commit)
|
||||
totalFilesToCommit += 1;
|
||||
}
|
||||
self.commitButton.title = totalFilesToCommit == 1 ? [NSString stringWithFormat:@"Commit %lu File", totalFilesToCommit] : [NSString stringWithFormat:@"Commit %lu Files", totalFilesToCommit];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setShowsTableView:(BOOL)flag
|
||||
{
|
||||
if(_showsTableView == flag)
|
||||
|
||||
Reference in New Issue
Block a user