Skip to content
This repository has been archived by the owner on Mar 30, 2021. It is now read-only.

Commit

Permalink
Fix preferences to set default values
Browse files Browse the repository at this point in the history
  • Loading branch information
kbhomes committed Feb 20, 2014
1 parent d27162e commit b7c1487
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
4 changes: 4 additions & 0 deletions google-music-mac.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
1A7B685617453E40001E509E /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1A7B685417453E40001E509E /* MainMenu.xib */; };
1A7B687417453E4C001E509E /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A7B687317453E4C001E509E /* WebKit.framework */; };
1A7B68811745ABBD001E509E /* icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 1A7B68801745ABBD001E509E /* icon.icns */; };
D302E13418B561E100CCD18E /* Preferences.plist in Resources */ = {isa = PBXBuildFile; fileRef = D302E13318B561E100CCD18E /* Preferences.plist */; };
D326EA6418B2D7E500BEC02F /* css in Resources */ = {isa = PBXBuildFile; fileRef = D326EA6218B2D7E500BEC02F /* css */; };
D326EA6518B2D7E500BEC02F /* js in Resources */ = {isa = PBXBuildFile; fileRef = D326EA6318B2D7E500BEC02F /* js */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -54,6 +55,7 @@
1A7B685517453E40001E509E /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = "<group>"; };
1A7B687317453E4C001E509E /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; };
1A7B68801745ABBD001E509E /* icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = icon.icns; sourceTree = "<group>"; };
D302E13318B561E100CCD18E /* Preferences.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Preferences.plist; sourceTree = "<group>"; };
D326EA6218B2D7E500BEC02F /* css */ = {isa = PBXFileReference; lastKnownFileType = folder; path = css; sourceTree = "<group>"; };
D326EA6318B2D7E500BEC02F /* js */ = {isa = PBXFileReference; lastKnownFileType = folder; path = js; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -133,6 +135,7 @@
1A7B684B17453E40001E509E /* main.m */,
1A7B684D17453E40001E509E /* prefix.pch */,
1A7B684E17453E40001E509E /* Credits.rtf */,
D302E13318B561E100CCD18E /* Preferences.plist */,
);
name = "Supporting Files";
sourceTree = "<group>";
Expand Down Expand Up @@ -191,6 +194,7 @@
files = (
D326EA6418B2D7E500BEC02F /* css in Resources */,
D326EA6518B2D7E500BEC02F /* js in Resources */,
D302E13418B561E100CCD18E /* Preferences.plist in Resources */,
1A7B684A17453E40001E509E /* InfoPlist.strings in Resources */,
1A7B685017453E40001E509E /* Credits.rtf in Resources */,
1A7B685617453E40001E509E /* MainMenu.xib in Resources */,
Expand Down
14 changes: 13 additions & 1 deletion google-music-mac/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,25 @@ - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theAppl
return YES;
}

/**
* Set defaults.
*/
+ (void)initialize
{
// Register default preferences.
NSString *prefsPath = [[NSBundle mainBundle] pathForResource:@"Preferences" ofType:@"plist"];
NSDictionary *prefs = [NSDictionary dictionaryWithContentsOfFile:prefsPath];

[[NSUserDefaults standardUserDefaults] registerDefaults:prefs];
}

/**
* Application finished launching, we will register the event tap callback.
*/
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Load the user preferences.
defaults = [[NSUserDefaultsController sharedUserDefaultsController] defaults];
defaults = [NSUserDefaults standardUserDefaults];

// Add an event tap to intercept the system defined media key events
eventTap = CGEventTapCreate(kCGSessionEventTap,
Expand Down
12 changes: 12 additions & 0 deletions google-music-mac/Preferences.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>styles.enabled</key>
<true/>
<key>notifications.enabled</key>
<true/>
<key>notifications.showAlbumArt</key>
<false/>
</dict>
</plist>

0 comments on commit b7c1487

Please sign in to comment.