Skip to content

Commit

Permalink
show a growl about finished clone if it takes >3s
Browse files Browse the repository at this point in the history
  • Loading branch information
mackuba committed Jul 5, 2011
1 parent 8b74fe4 commit 065f215
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Classes/GrowlController.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#define CommitReceivedGrowl @"Commit received"
#define RepositoryUpdateFailedGrowl @"Repository update failed"
#define OtherMessageGrowl @"Other message"

@class Commit;
@class Repository;
Expand All @@ -24,8 +25,9 @@
// public
+ (GrowlController *) sharedController;
- (void) checkGrowlAvailability;
- (void) showGrowlWithError: (NSString *) message repository: (Repository *) repository;
- (void) showGrowlWithCommit: (Commit *) commit repository: (Repository *) repository;
- (void) showGrowlWithError: (NSString *) message repository: (Repository *) repository;
- (void) showGrowlWithTitle: (NSString *) title message: (NSString *) message type: (NSString *) type;

// private
- (void) openGrowlPreferences;
Expand Down
7 changes: 6 additions & 1 deletion Classes/GrowlController.m
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,14 @@ - (void) showGrowlWithError: (NSString *) message repository: (Repository *) rep
NSLog(@"Error: %@", message);
title = @"Error";
}

[self showGrowlWithTitle: title message: message type: RepositoryUpdateFailedGrowl];
}

- (void) showGrowlWithTitle: (NSString *) title message: (NSString *) message type: (NSString *) type {
[GrowlApplicationBridge notifyWithTitle: title
description: message
notificationName: RepositoryUpdateFailedGrowl
notificationName: type
iconData: [self growlIcon]
priority: 0
isSticky: NO
Expand Down
1 change: 1 addition & 0 deletions Classes/NewRepositoryDialogController.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
NSButton *cancelButton;
NSButton *addButton;
NSTextField *label;
BOOL waitingForSlowClone;
}

@property IBOutlet RepositoryListController *repositoryListController;
Expand Down
12 changes: 12 additions & 0 deletions Classes/NewRepositoryDialogController.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Licensed under Eclipse Public License v1.0
// -------------------------------------------------------

#import "GrowlController.h"
#import "NewRepositoryDialogController.h"
#import "Repository.h"
#import "RepositoryListController.h"
Expand All @@ -15,6 +16,7 @@ @implementation NewRepositoryDialogController

- (void) awakeFromNib {
labelText = label.stringValue;
waitingForSlowClone = NO;
}

- (IBAction) showNewRepositorySheet: (id) sender {
Expand Down Expand Up @@ -107,18 +109,28 @@ - (void) setupSlowCloneTimer {
}

- (void) showSlowCloneWarning {
waitingForSlowClone = YES;
label.stringValue = @"Please be patient - I'm cloning the repository...";
label.textColor = [NSColor textColor];
}

- (void) hideSlowCloneWarning {
waitingForSlowClone = NO;
label.stringValue = labelText;
label.textColor = [NSColor disabledControlTextColor];
}

- (void) repositoryWasCloned: (Repository *) repository {
[repositoryListController addRepository: repository];
[self hideNewRepositorySheet];

if (waitingForSlowClone) {
GrowlController *growl = [GrowlController sharedController];
[growl showGrowlWithTitle: @"Repository cloned"
message: PSFormat(@"Repository at %@ has been successfully added to Gitifier.", repository.url)
type: OtherMessageGrowl];
}

[self unlockDialog];
}

Expand Down
2 changes: 2 additions & 0 deletions Growl Registration Ticket.growlRegDict
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
<array>
<string>Commit received</string>
<string>Repository update failed</string>
<string>Other message</string>
</array>
<key>DefaultNotifications</key>
<array>
<string>Commit received</string>
<string>Repository update failed</string>
<string>Other message</string>
</array>
</dict>
</plist>

0 comments on commit 065f215

Please sign in to comment.