From 497bb8a7149ab0f8eb93d369c6dee82417192420 Mon Sep 17 00:00:00 2001 From: Ryan Brainard Date: Mon, 28 Jul 2014 22:32:54 -0700 Subject: [PATCH] Add option to disable notifications Fixes #11 --- yubiswitch/AppDelegate.h | 1 + yubiswitch/AppDelegate.m | 7 +++++++ yubiswitch/Base.lproj/MainMenu.xib | 9 ++++++++- yubiswitch/DefaultPreferences.plist | 2 ++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/yubiswitch/AppDelegate.h b/yubiswitch/AppDelegate.h index a7aac17..adb8272 100644 --- a/yubiswitch/AppDelegate.h +++ b/yubiswitch/AppDelegate.h @@ -42,6 +42,7 @@ -(IBAction)toggleSwitchOffDelay:(id)sender; -(IBAction)toggleLockWhenUnplugged:(id)sender; +-(IBAction)toggleDisplayNotications:(id)sender; -(IBAction)toggle:(id)sender; -(IBAction)quit:(id)sender; -(IBAction)about:(id)sender; diff --git a/yubiswitch/AppDelegate.m b/yubiswitch/AppDelegate.m index f53f1c4..95c7e45 100644 --- a/yubiswitch/AppDelegate.m +++ b/yubiswitch/AppDelegate.m @@ -118,6 +118,9 @@ -(void)observeValueForKeyPath:(NSString *)aKeyPath ofObject:(id)anObject } -(void)notify:(NSString *)msg { + BOOL displayNotifications = [[NSUserDefaults standardUserDefaults] + boolForKey:@"displayNotifications"]; + if (!displayNotifications) return; usernotification.title = msg; [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:usernotification]; @@ -196,6 +199,10 @@ -(IBAction)toggleLockWhenUnplugged:(id)sender { [controller save:self]; } +- (IBAction)toggleDisplayNotications:(id)sender { + [controller save:self]; +} + -(IBAction)about:(id)sender { [[aboutwc window] makeKeyAndOrderFront:self]; [[aboutwc window] setOrderedIndex:0]; diff --git a/yubiswitch/Base.lproj/MainMenu.xib b/yubiswitch/Base.lproj/MainMenu.xib index f4b193f..0bfd8c4 100644 --- a/yubiswitch/Base.lproj/MainMenu.xib +++ b/yubiswitch/Base.lproj/MainMenu.xib @@ -54,6 +54,13 @@ + + + + + + + @@ -91,4 +98,4 @@ - \ No newline at end of file + diff --git a/yubiswitch/DefaultPreferences.plist b/yubiswitch/DefaultPreferences.plist index 3f811bd..9cfbc48 100644 --- a/yubiswitch/DefaultPreferences.plist +++ b/yubiswitch/DefaultPreferences.plist @@ -28,5 +28,7 @@ startAtLogin + displayNotifications +