Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Mute sounds" menu item #145

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
2 changes: 2 additions & 0 deletions Classes/Controllers/MenuController.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
IBOutlet NSMenuItem* closeWindowItem;
IBOutlet NSMenuItem* closeCurrentPanelItem;
IBOutlet NSMenuItem* checkForUpdateItem;
IBOutlet NSMenuItem* toggleMuteSounds;

__weak AppController* app;
__weak IRCWorld* world;
Expand Down Expand Up @@ -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;
Expand Down
16 changes: 16 additions & 0 deletions Classes/Controllers/MenuController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand Down
5 changes: 5 additions & 0 deletions Classes/Helpers/SoundPlayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions Classes/Preferences/Preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 12 additions & 0 deletions Classes/Preferences/Preferences.m
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand Down
89 changes: 60 additions & 29 deletions English.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1070</int>
<string key="IBDocument.SystemVersion">12A269</string>
<string key="IBDocument.InterfaceBuilderVersion">2549</string>
<string key="IBDocument.AppKitVersion">1187</string>
<string key="IBDocument.HIToolboxVersion">624.00</string>
<string key="IBDocument.SystemVersion">12C3012</string>
<string key="IBDocument.InterfaceBuilderVersion">3084</string>
<string key="IBDocument.AppKitVersion">1187.34</string>
<string key="IBDocument.HIToolboxVersion">625.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">2549</string>
<string key="NS.object.0">3084</string>
</object>
<array key="IBDocument.IntegratedClassDependencies">
<string>NSBox</string>
Expand Down Expand Up @@ -285,7 +285,7 @@
<string key="NSFrameSize">{177, 328}</string>
<reference key="NSSuperview" ref="972199680"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="43410202"/>
<reference key="NSNextKeyView" ref="966973983"/>
<bool key="NSEnabled">YES</bool>
<bool key="NSAllowsLogicalLayoutDirection">NO</bool>
<bool key="NSControlAllowsExpansionToolTips">YES</bool>
Expand Down Expand Up @@ -404,7 +404,7 @@
<string key="NSFrameSize">{177, 328}</string>
<reference key="NSSuperview" ref="1006686548"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="972199680"/>
<reference key="NSNextKeyView" ref="43410202"/>
<int key="NSsFlags">133648</int>
<reference key="NSVScroller" ref="40277675"/>
<reference key="NSHScroller" ref="43410202"/>
Expand Down Expand Up @@ -436,7 +436,7 @@
<string key="NSFrameSize">{177, 164}</string>
<reference key="NSSuperview" ref="123026376"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="752818090"/>
<reference key="NSNextKeyView" ref="896108245"/>
<bool key="NSEnabled">YES</bool>
<bool key="NSAllowsLogicalLayoutDirection">NO</bool>
<bool key="NSControlAllowsExpansionToolTips">YES</bool>
Expand Down Expand Up @@ -534,7 +534,7 @@
<string key="NSFrameSize">{177, 164}</string>
<reference key="NSSuperview" ref="18418633"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="123026376"/>
<reference key="NSNextKeyView" ref="752818090"/>
<int key="NSsFlags">133648</int>
<reference key="NSVScroller" ref="896108245"/>
<reference key="NSHScroller" ref="752818090"/>
Expand Down Expand Up @@ -599,7 +599,7 @@
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="228709641"/>
</object>
<string key="NSScreenRect">{{0, 0}, {2560, 1418}}</string>
<string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
<string key="NSMinSize">{213, 129}</string>
<string key="NSMaxSize">{10000000000000, 10000000000000}</string>
<bool key="NSWindowIsRestorable">YES</bool>
Expand Down Expand Up @@ -661,6 +661,16 @@
<reference key="NSMixedImage" ref="353314363"/>
<int key="NSTag">102</int>
</object>
<object class="NSMenuItem" id="586527782">
<reference key="NSMenu" ref="211985183"/>
<string key="NSTitle">Mute sounds</string>
<string key="NSKeyEquiv">M</string>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="821023625"/>
<reference key="NSMixedImage" ref="353314363"/>
<int key="NSTag">103</int>
</object>
<object class="NSMenuItem" id="1048542702">
<reference key="NSMenu" ref="211985183"/>
<bool key="NSIsDisabled">YES</bool>
Expand Down Expand Up @@ -3155,6 +3165,22 @@
</object>
<int key="connectionID">1011</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">toggleMuteSounds</string>
<reference key="source" ref="361464326"/>
<reference key="destination" ref="586527782"/>
</object>
<int key="connectionID">1032</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">onMute:</string>
<reference key="source" ref="361464326"/>
<reference key="destination" ref="586527782"/>
</object>
<int key="connectionID">1033</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
Expand Down Expand Up @@ -3390,6 +3416,7 @@
<reference ref="703873414"/>
<reference ref="228935728"/>
<reference ref="916585514"/>
<reference ref="586527782"/>
</array>
<reference key="parent" ref="33257923"/>
</object>
Expand Down Expand Up @@ -4439,6 +4466,11 @@
<reference key="object" ref="371985104"/>
<reference key="parent" ref="272041888"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">1031</int>
<reference key="object" ref="586527782"/>
<reference key="parent" ref="211985183"/>
</object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
Expand All @@ -4450,6 +4482,7 @@
<string key="1003.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="1010.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="103.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="1031.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="106.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="111.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="129.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
Expand Down Expand Up @@ -4656,7 +4689,7 @@
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">1011</int>
<int key="maxID">1033</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
Expand Down Expand Up @@ -4843,10 +4876,22 @@
<object class="IBPartialClassDescription">
<string key="className">MenuController</string>
<string key="superclassName">NSObject</string>
<object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">onMute:</string>
<string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<string key="NS.key.0">onMute:</string>
<object class="IBActionInfo" key="NS.object.0">
<string key="name">onMute:</string>
<string key="candidateClassName">id</string>
</object>
</object>
<dictionary class="NSMutableDictionary" key="outlets">
<string key="checkForUpdateItem">NSMenuItem</string>
<string key="closeCurrentPanelItem">NSMenuItem</string>
<string key="closeWindowItem">NSMenuItem</string>
<string key="toggleMuteSounds">NSMenuItem</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
<object class="IBToOneOutletInfo" key="checkForUpdateItem">
Expand All @@ -4861,6 +4906,10 @@
<string key="name">closeWindowItem</string>
<string key="candidateClassName">NSMenuItem</string>
</object>
<object class="IBToOneOutletInfo" key="toggleMuteSounds">
<string key="name">toggleMuteSounds</string>
<string key="candidateClassName">NSMenuItem</string>
</object>
</dictionary>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
Expand Down Expand Up @@ -4907,24 +4956,6 @@
<string key="minorKey">./Classes/TreeView.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">WebView</string>
<object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">reloadFromOrigin:</string>
<string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<string key="NS.key.0">reloadFromOrigin:</string>
<object class="IBActionInfo" key="NS.object.0">
<string key="name">reloadFromOrigin:</string>
<string key="candidateClassName">id</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/WebView.h</string>
</object>
</object>
</array>
</object>
<int key="IBDocument.localizationMode">0</int>
Expand Down