From e5e35b15a3390148f16b0a7e85480fdc2b777153 Mon Sep 17 00:00:00 2001 From: Steve Gattuso Date: Mon, 11 Mar 2013 14:53:28 -0400 Subject: [PATCH 1/3] Adding isMuted preference --- Classes/Preferences/Preferences.h | 2 ++ Classes/Preferences/Preferences.m | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/Classes/Preferences/Preferences.h b/Classes/Preferences/Preferences.h index 6c7b0f18..d5f7dc32 100644 --- a/Classes/Preferences/Preferences.h +++ b/Classes/Preferences/Preferences.h @@ -105,6 +105,8 @@ typedef enum { + (NSString*)titleForEvent:(UserNotificationType)event; + (NSString*)soundForEvent:(UserNotificationType)event; + (void)setSound:(NSString*)value forEvent:(UserNotificationType)event; ++ (BOOL)isMuted; ++ (void)setMuted:(BOOL)value; + (BOOL)userNotificationEnabledForEvent:(UserNotificationType)event; + (void)setUserNotificationEnabled:(BOOL)value forEvent:(UserNotificationType)event; + (BOOL)growlStickyForEvent:(UserNotificationType)event; diff --git a/Classes/Preferences/Preferences.m b/Classes/Preferences/Preferences.m index ddee48a4..87bc90f0 100644 --- a/Classes/Preferences/Preferences.m +++ b/Classes/Preferences/Preferences.m @@ -510,6 +510,18 @@ + (void)setSound:(NSString*)value forEvent:(UserNotificationType)event [ud setObject:value forKey:key]; } ++ (BOOL)isMuted +{ + NSUserDefaults* ud = [NSUserDefaults standardUserDefaults]; + return [ud boolForKey:@"Preferences.General.muteSounds"]; +} + ++ (void)setMuted:(BOOL)value +{ + NSUserDefaults* ud = [NSUserDefaults standardUserDefaults]; + [ud setBool:value forKey:@"Preferences.General.muteSounds"]; +} + + (BOOL)userNotificationEnabledForEvent:(UserNotificationType)event { NSString* key = [[self keyForEvent:event] stringByAppendingString:@"Growl"]; From 05315fc73ae24a39afcffbac465f915a58b3ec10 Mon Sep 17 00:00:00 2001 From: Steve Gattuso Date: Mon, 11 Mar 2013 15:41:44 -0400 Subject: [PATCH 2/3] Adding menu item --- Classes/Controllers/MenuController.h | 2 + Classes/Controllers/MenuController.m | 16 +++++ English.lproj/MainMenu.xib | 89 +++++++++++++++++++--------- 3 files changed, 78 insertions(+), 29 deletions(-) diff --git a/Classes/Controllers/MenuController.h b/Classes/Controllers/MenuController.h index b4e1f0f1..88530e44 100644 --- a/Classes/Controllers/MenuController.h +++ b/Classes/Controllers/MenuController.h @@ -24,6 +24,7 @@ IBOutlet NSMenuItem* closeWindowItem; IBOutlet NSMenuItem* closeCurrentPanelItem; IBOutlet NSMenuItem* checkForUpdateItem; + IBOutlet NSMenuItem* toggleMuteSounds; __weak AppController* app; __weak IRCWorld* world; @@ -69,6 +70,7 @@ - (void)showServerPropertyDialog:(IRCClient*)client ignore:(BOOL)ignore; - (void)onPreferences:(id)sender; +- (void)onMute:(id)sender; - (void)onAutoOp:(id)sender; - (void)onDcc:(id)sender; - (void)onMainWindow:(id)sender; diff --git a/Classes/Controllers/MenuController.m b/Classes/Controllers/MenuController.m index 7de5dba1..869ef1d8 100644 --- a/Classes/Controllers/MenuController.m +++ b/Classes/Controllers/MenuController.m @@ -121,6 +121,7 @@ - (BOOL)validateMenuItem:(NSMenuItem *)item switch (tag) { case 102: // preferences + case 103: // sound toggle case 104: // auto op case 201: // dcc return YES; @@ -356,6 +357,21 @@ - (void)onPreferences:(id)sender [preferencesController show]; } +- (void)onMute:(id)sender +{ + NSUserDefaults* ud = [NSUserDefaults standardUserDefaults]; + BOOL current = [ud boolForKey:@"Preferences.General.muteSounds"]; + + if(current) { + [toggleMuteSounds setState: NSOffState]; + [ud setBool: NO forKey:@"Preferences.General.muteSounds"]; + } + else { + [toggleMuteSounds setState: NSOnState]; + [ud setBool: YES forKey:@"Preferences.General.muteSounds"]; + } +} + - (void)preferencesDialogWillClose:(PreferencesController*)sender { [world preferencesChanged]; diff --git a/English.lproj/MainMenu.xib b/English.lproj/MainMenu.xib index 0c54a23a..bcebd78a 100644 --- a/English.lproj/MainMenu.xib +++ b/English.lproj/MainMenu.xib @@ -2,13 +2,13 @@ 1070 - 12A269 - 2549 - 1187 - 624.00 + 12C3012 + 3084 + 1187.34 + 625.00 com.apple.InterfaceBuilder.CocoaPlugin - 2549 + 3084 NSBox @@ -285,7 +285,7 @@ {177, 328} - + YES NO YES @@ -404,7 +404,7 @@ {177, 328} - + 133648 @@ -436,7 +436,7 @@ {177, 164} - + YES NO YES @@ -534,7 +534,7 @@ {177, 164} - + 133648 @@ -599,7 +599,7 @@ - {{0, 0}, {2560, 1418}} + {{0, 0}, {1440, 878}} {213, 129} {10000000000000, 10000000000000} YES @@ -661,6 +661,16 @@ 102 + + + Mute sounds + M + 1048576 + 2147483647 + + + 103 + YES @@ -3155,6 +3165,22 @@ 1011 + + + toggleMuteSounds + + + + 1032 + + + + onMute: + + + + 1033 + delegate @@ -3390,6 +3416,7 @@ + @@ -4439,6 +4466,11 @@ + + 1031 + + + @@ -4450,6 +4482,7 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -4656,7 +4689,7 @@ - 1011 + 1033 @@ -4843,10 +4876,22 @@ MenuController NSObject + + onMute: + id + + + onMute: + + onMute: + id + + NSMenuItem NSMenuItem NSMenuItem + NSMenuItem @@ -4861,6 +4906,10 @@ closeWindowItem NSMenuItem + + toggleMuteSounds + NSMenuItem + IBProjectSource @@ -4907,24 +4956,6 @@ ./Classes/TreeView.h - - WebView - - reloadFromOrigin: - id - - - reloadFromOrigin: - - reloadFromOrigin: - id - - - - IBProjectSource - ./Classes/WebView.h - - 0 From 724f42a9872ac961dd171eeb0566c81761cb8cb1 Mon Sep 17 00:00:00 2001 From: Steve Gattuso Date: Mon, 11 Mar 2013 15:44:47 -0400 Subject: [PATCH 3/3] Sounds can now be muted with the toggle! --- Classes/Helpers/SoundPlayer.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Classes/Helpers/SoundPlayer.m b/Classes/Helpers/SoundPlayer.m index 9826398e..d4d03cea 100644 --- a/Classes/Helpers/SoundPlayer.m +++ b/Classes/Helpers/SoundPlayer.m @@ -11,6 +11,11 @@ + (void)play:(NSString*)name if (!name.length) { return; } + + NSUserDefaults* ud = [NSUserDefaults standardUserDefaults]; + if([ud boolForKey:@"Preferences.General.muteSounds"]) { + return; + } if ([name isEqualToString:@"Beep"]) { NSBeep();