Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
292 changes: 273 additions & 19 deletions resources/English.lproj/MainMenu.xib

Large diffs are not rendered by default.

13 changes: 12 additions & 1 deletion src/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ - (IBAction)showPreferences:(id)sender {
}

- (BOOL)shouldShowNotificationFor:(TravisEvent *)eventData {
if ([[Preferences sharedPreferences] failureOnlyNotificationEnabled]) {
if (eventData.status != TravisEventStatusFailed) {
return FALSE;
}
}

RepositoryFilter *filter;
if ([[Preferences sharedPreferences] firehoseEnabled]) {
filter = [RepositoryFilter filterThatAcceptsAllRepositories];
Expand Down Expand Up @@ -94,9 +100,14 @@ - (void)eventFetcher:(TravisEventFetcher *)eventFetcher gotEvent:(TravisEvent *)
#pragma mark - NSUserNotificationCenterDelegate

- (void)userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification {
if ([notification activationType] == NSUserNotificationActivationTypeContentsClicked) {
if ([notification activationType] == NSUserNotificationActivationTypeContentsClicked || [notification activationType] == NSUserNotificationActivationTypeActionButtonClicked) {

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:[notification userInfo][@"URL"]]];
}
}

- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification {
// Show notifications when the Preferences panel is visible.
return TRUE;
}

@end
3 changes: 3 additions & 0 deletions src/Preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@
- (BOOL)firehoseEnabled;
- (void)setFirehoseEnabled:(BOOL)firehoseEnabled;

- (BOOL)failureOnlyNotificationEnabled;
- (void)setFailureOnlyNotificationEnabled:(BOOL)failuresOnlyNotificationsEnabled;

@end
12 changes: 12 additions & 0 deletions src/Preferences.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

static NSString * const kRepositoriesSetting = @"repositories";
static NSString * const kFirehoseSetting = @"firehose";
static NSString * const kFailuresOnlyNotificationsEnabled = @"failuresOnly";

@implementation Preferences

Expand Down Expand Up @@ -66,4 +67,15 @@ - (void)setFirehoseEnabled:(BOOL)firehoseEnabled {
[userDefaults synchronize];
}

- (BOOL)failureOnlyNotificationEnabled {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
return [userDefaults boolForKey:kFailuresOnlyNotificationsEnabled];
}

- (void)setFailureOnlyNotificationEnabled:(BOOL)failureOnlyNotificationEnabled {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setBool:failureOnlyNotificationEnabled forKey:kFailuresOnlyNotificationsEnabled];
[userDefaults synchronize];
}

@end
4 changes: 4 additions & 0 deletions src/PreferencesController.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@
@property (assign) IBOutlet NSPanel *preferencesPanel;
@property (weak) IBOutlet NSButtonCell *firehoseEnabledButtonCell;
@property (weak) IBOutlet NSButtonCell *firehoseDisabledButtonCell;
@property (weak) IBOutlet NSButtonCell *failureOnlyNotificationEnabledButtonCell;
@property (weak) IBOutlet NSButtonCell *failureOnlyNotificationDisabledButtonCell;

- (IBAction)addRepository:(id)sender;
- (IBAction)removeRepository:(id)sender;
- (IBAction)enableFirehose:(id)sender;
- (IBAction)disableFirehose:(id)sender;
- (IBAction)enableFailureOnlyNotification:(id)sender;
- (IBAction)disableFailureOnlyNotification:(id)sender;
- (IBAction)close:(id)sender;

@end
15 changes: 15 additions & 0 deletions src/PreferencesController.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ - (IBAction)disableFirehose:(id)sender {
[[self preferences] setFirehoseEnabled:NO];
}

- (IBAction)enableFailureOnlyNotification:(id)sender {
[[self preferences] setFailureOnlyNotificationEnabled:YES];
}

- (IBAction)disableFailureOnlyNotification:(id)sender {
[[self preferences] setFailureOnlyNotificationEnabled:NO];
}

#pragma mark - NSWindowDelegate

- (void)windowDidBecomeKey:(NSNotification *)notification {
Expand All @@ -66,6 +74,13 @@ - (void)windowDidBecomeKey:(NSNotification *)notification {
[[self firehoseEnabledButtonCell] setObjectValue:@(NO)];
[[self firehoseDisabledButtonCell] setObjectValue:@(YES)];
}
if ([[self preferences] failureOnlyNotificationEnabled]) {
[[self failureOnlyNotificationEnabledButtonCell] setObjectValue:@(YES)];
[[self failureOnlyNotificationDisabledButtonCell] setObjectValue:@(NO)];
} else {
[[self failureOnlyNotificationEnabledButtonCell] setObjectValue:@(NO)];
[[self failureOnlyNotificationDisabledButtonCell] setObjectValue:@(YES)];
}
}

#pragma mark - NSTableViewDataSource
Expand Down
10 changes: 10 additions & 0 deletions test/PreferencesControllerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,14 @@ - (void)testDisableFirehoseSetting {
[verify(_preferences) setFirehoseEnabled:NO];
}

- (void)testEnableFailureOnlyNotificationSetting {
[_preferencesController enableFailureOnlyNotification:nil];
[verify(_preferences) setFailureOnlyNotificationEnabled:YES];
}

- (void)testDisableFailureOnlyNotificationSetting {
[_preferencesController disableFailureOnlyNotification:nil];
[verify(_preferences) setFailureOnlyNotificationEnabled:NO];
}

@end