Added preference pane for remote. Gives the option to make remote global or not.

CQTexperiment
vspader 2007-02-19 00:42:12 +00:00
parent a723e20f44
commit 3125740f0f
9 changed files with 110 additions and 12 deletions

View File

@ -25,11 +25,17 @@
// Listen to the remote in exclusive mode, only when Cog is the active application
- (void)applicationDidBecomeActive:(NSNotification *)notification
{
[remote startListening: self];
BOOL onlyOnActive = [[[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"remoteOnlyOnActive"] boolValue];
if (onlyOnActive) {
[remote startListening: self];
}
}
- (void)applicationDidResignActive:(NSNotification *)motification
{
[remote stopListening: self];
BOOL onlyOnActive = [[[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"remoteOnlyOnActive"] boolValue];
if (onlyOnActive) {
[remote stopListening: self];
}
}
/* Helper method for the remote control interface in order to trigger forward/backward and volume
@ -179,9 +185,6 @@ increase/decrease as long as the user holds the left/right, plus/minus button */
- (void)awakeFromNib
{
// [self initDefaults];
// DBLog(@"AWAKe");
[playButton setToolTip:NSLocalizedString(@"PlayButtonTooltip", @"")];
[prevButton setToolTip:NSLocalizedString(@"PrevButtonTooltip", @"")];
[nextButton setToolTip:NSLocalizedString(@"NextButtonTooltip", @"")];
@ -200,6 +203,10 @@ increase/decrease as long as the user holds the left/right, plus/minus button */
[self registerHotKeys];
//Init Remote
NSString *filename = @"~/Library/Application Support/Cog/Default.playlist";
[playlistController loadPlaylist:[filename stringByExpandingTildeInPath]];
}
@ -336,6 +343,7 @@ increase/decrease as long as the user holds the left/right, plus/minus button */
- (void)initDefaults
{
NSMutableDictionary *userDefaultsValuesDict = [NSMutableDictionary dictionary];
[userDefaultsValuesDict setObject:[NSNumber numberWithInt:35] forKey:@"hotKeyPlayKeyCode"];
[userDefaultsValuesDict setObject:[NSNumber numberWithInt:(NSControlKeyMask|NSCommandKeyMask)] forKey:@"hotKeyPlayModifiers"];
[userDefaultsValuesDict setObject:[NSNumber numberWithInt:'P'] forKey:@"hotKeyPlayCharacter"];
@ -350,6 +358,8 @@ increase/decrease as long as the user holds the left/right, plus/minus button */
[userDefaultsValuesDict setObject:[@"~/Music" stringByExpandingTildeInPath] forKey:@"fileDrawerRootPath"];
[userDefaultsValuesDict setObject:[NSNumber numberWithBool:YES] forKey:@"remoteOnlyOnActive"];
//Register and sync defaults
[[NSUserDefaults standardUserDefaults] registerDefaults:userDefaultsValuesDict];
[[NSUserDefaults standardUserDefaults] synchronize];
@ -378,6 +388,16 @@ increase/decrease as long as the user holds the left/right, plus/minus button */
else if ([keyPath isEqualToString:@"values.fileDrawerRootPath"]) {
[fileTreeController setRootPath:[[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"fileDrawerRootPath"]];
}
else if ([keyPath isEqualToString:@"values.remoteOnlyOnActive"]) {
BOOL onlyOnActive = [[[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"remoteOnlyOnActive"] boolValue];
if (!onlyOnActive || [NSApp isActive]) {
[remote startListening: self];
}
if (onlyOnActive && ![NSApp isActive]) { //Setting a preference without being active? *shrugs*
[remote stopListening: self];
}
}
}
- (void)registerHotKeys

View File

@ -29,7 +29,11 @@
{
CLASS = PrefPaneController;
LANGUAGE = ObjC;
OUTLETS = {fileDrawerPane = FileDrawerPane; hotKeyPane = HotKeyPane; };
OUTLETS = {
fileDrawerPane = FileDrawerPane;
hotKeyPane = HotKeyPane;
remotePane = RemotePane;
};
SUPERCLASS = NSObject;
},
{
@ -37,6 +41,13 @@
LANGUAGE = ObjC;
OUTLETS = {view = NSView; };
SUPERCLASS = NSObject;
},
{
ACTIONS = {takeBool = id; };
CLASS = RemotePane;
LANGUAGE = ObjC;
OUTLETS = {onlyOnActive = NSButton; };
SUPERCLASS = PreferencePane;
}
);
IBVersion = 1;

View File

@ -3,22 +3,25 @@
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>137 120 356 240 0 0 1680 1028 </string>
<string>202 336 356 240 0 0 1680 1028 </string>
<key>IBEditorPositions</key>
<dict>
<key>10</key>
<string>499 669 506 102 0 0 1680 1028 </string>
<string>587 659 506 102 0 0 1680 1028 </string>
<key>11</key>
<string>703 634 273 151 0 0 1680 1028 </string>
<key>43</key>
<string>671 662 337 96 0 0 1680 1028 </string>
</dict>
<key>IBFramework Version</key>
<string>446.1</string>
<key>IBOpenObjects</key>
<array>
<integer>11</integer>
<integer>10</integer>
<integer>43</integer>
<integer>11</integer>
</array>
<key>IBSystem Version</key>
<string>8K1106</string>
<string>8L2127</string>
</dict>
</plist>

View File

@ -7,6 +7,8 @@
objects = {
/* Begin PBXBuildFile section */
172D72480B891FEF00D095BB /* RemotePane.m in Sources */ = {isa = PBXBuildFile; fileRef = 172D72470B891FEF00D095BB /* RemotePane.m */; };
172D72AD0B8926CA00D095BB /* apple_remote.png in Resources */ = {isa = PBXBuildFile; fileRef = 172D72AC0B8926CA00D095BB /* apple_remote.png */; };
8D5B49B0048680CD000E48DA /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C167DFE841241C02AAC07 /* InfoPlist.strings */; };
8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; };
8E07AA870AAC8EA200A4B32F /* FileDrawerPane.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E07AA7F0AAC8EA200A4B32F /* FileDrawerPane.m */; };
@ -27,6 +29,9 @@
089C167EFE841241C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
172D72460B891FEF00D095BB /* RemotePane.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RemotePane.h; sourceTree = "<group>"; };
172D72470B891FEF00D095BB /* RemotePane.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = RemotePane.m; sourceTree = "<group>"; };
172D72AC0B8926CA00D095BB /* apple_remote.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = apple_remote.png; path = Icons/apple_remote.png; sourceTree = "<group>"; };
32DBCF630370AF2F00C91783 /* General_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = General_Prefix.pch; sourceTree = "<group>"; };
8D5B49B6048680CD000E48DA /* General.preferencePane */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = General.preferencePane; sourceTree = BUILT_PRODUCTS_DIR; };
8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = Info.plist; sourceTree = "<group>"; };
@ -137,6 +142,8 @@
8E07AA7F0AAC8EA200A4B32F /* FileDrawerPane.m */,
8E07AA800AAC8EA200A4B32F /* HotKeyPane.h */,
8E07AA810AAC8EA200A4B32F /* HotKeyPane.m */,
172D72460B891FEF00D095BB /* RemotePane.h */,
172D72470B891FEF00D095BB /* RemotePane.m */,
);
name = Panes;
sourceTree = "<group>";
@ -173,6 +180,7 @@
8E07ABD90AAC95AF00A4B32F /* Icons */ = {
isa = PBXGroup;
children = (
172D72AC0B8926CA00D095BB /* apple_remote.png */,
8E07ABDA0AAC95BC00A4B32F /* file_drawer.png */,
8E07ABDB0AAC95BC00A4B32F /* hot_keys.png */,
);
@ -224,6 +232,7 @@
8E07ABDC0AAC95BC00A4B32F /* file_drawer.png in Resources */,
8E07ABDD0AAC95BC00A4B32F /* hot_keys.png in Resources */,
8E07AC050AAC968C00A4B32F /* Preferences.nib in Resources */,
172D72AD0B8926CA00D095BB /* apple_remote.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -241,6 +250,7 @@
8E6C12160AACAE4100819171 /* NDHotKeyControl.m in Sources */,
8E6C12170AACAE4100819171 /* NDHotKeyEvent.m in Sources */,
8E6C13A00AACBAB500819171 /* HotKeyControl.m in Sources */,
172D72480B891FEF00D095BB /* RemotePane.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@ -11,13 +11,16 @@
#import "HotKeyPane.h"
#import "FileDrawerPane.h"
#import "RemotePane.h"
@interface PrefPaneController : NSObject <SS_PreferencePaneProtocol> {
IBOutlet HotKeyPane *hotKeyPane;
IBOutlet FileDrawerPane *fileDrawerPane;
IBOutlet RemotePane *remotePane;
}
- (FileDrawerPane *)fileDrawerPane;
- (HotKeyPane *)hotKeyPane;
- (FileDrawerPane *)fileDrawerPane;
- (RemotePane *)remotePane;
@end

View File

@ -18,7 +18,7 @@
PrefPaneController *prefPaneController = [[PrefPaneController alloc] init];
loaded = [NSBundle loadNibNamed:@"Preferences" owner:prefPaneController];
return [NSArray arrayWithObjects: [prefPaneController hotKeyPane], [prefPaneController fileDrawerPane], nil];
return [NSArray arrayWithObjects: [prefPaneController hotKeyPane], [prefPaneController fileDrawerPane], [prefPaneController remotePane], nil];
}
- (HotKeyPane *)hotKeyPane
@ -31,4 +31,9 @@
return fileDrawerPane;
}
- (RemotePane *)remotePane
{
return remotePane;
}
@end

View File

@ -0,0 +1,19 @@
//
// FileDrawerPane.h
// Preferences
//
// Created by Vincent Spader on 9/4/06.
// Copyright 2006 Vincent Spader. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import "PreferencePane.h"
@interface RemotePane : PreferencePane {
IBOutlet NSButton *onlyOnActive;
}
- (IBAction)takeBool:(id)sender;
@end

View File

@ -0,0 +1,27 @@
//
// FileDrawerPane.m
// Preferences
//
// Created by Vincent Spader on 9/4/06.
// Copyright 2006 Vincent Spader. All rights reserved.
//
#import "RemotePane.h"
@implementation RemotePane
- (void)awakeFromNib
{
[self setName:@"Remote"];
[self setIcon:@"apple_remote"];
[onlyOnActive setState:[[[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"remoteOnlyOnActive"] boolValue]];
}
- (IBAction)takeBool:(id)sender
{
[[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:[onlyOnActive state]] forKey:@"remoteOnlyOnActive"];
}
@end