Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Instead of spending hours winding through a half-dozen separate @simX …
…commits, I'm goin' ghetto, batch-merging them all and letting God sort them out: [NEW] User preferences now are stored in a separate file, allowing them to be shared across application. Parasitic prefs are migrated to the external file and then deleted. bug 73 [NEW] Application-wide whitelisting for apps like Hulu Desktop, PandoraJam and Wii Transfer that utilize Flash. bugs 26, 118 and 230 [NEW] "Play Fullscreen in QuickTime Player" contextual menu command for viewing YouTube videos in QuickTime Player (which has niceties like supporting the Apple remote). bug 216 [NEW] Uninstall button (with a confirmation sheet) in the settings window. bug 226
- Loading branch information
Showing
14 changed files
with
1,605 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// CTFPreferencesDictionary.h | ||
// ClickToFlash | ||
// | ||
// Created by Simone Manganelli on 2009-05-25. | ||
// Copyright 2009 __MyCompanyName__. All rights reserved. | ||
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
|
||
|
||
@interface CTFPreferencesDictionary : NSMutableDictionary { | ||
NSMutableDictionary *realMutableDictionary; | ||
BOOL hasInited; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// | ||
// CTFPreferencesDictionary.m | ||
// ClickToFlash | ||
// | ||
// Created by Simone Manganelli on 2009-05-25. | ||
// Copyright 2009 __MyCompanyName__. All rights reserved. | ||
// | ||
// the rationale for this class is so that we can monitor when | ||
// defaults change, and update the *external* preference file accordingly. | ||
// to do so, we need to monitor the mutable dictionary that represents the | ||
// defaults. this class follows @bbum's suggestion at this URL: | ||
// http://www.omnigroup.com/mailman/archive/macosx-dev/1999-April/007726.html | ||
|
||
#import "CTFPreferencesDictionary.h" | ||
|
||
static CTFPreferencesDictionary *sharedInstance = nil; | ||
|
||
@implementation CTFPreferencesDictionary | ||
|
||
+ (id)dictionaryWithDictionary:(NSDictionary *)otherDictionary; | ||
{ | ||
return [[CTFPreferencesDictionary alloc] initWithDictionary:otherDictionary]; | ||
} | ||
|
||
+ (id)allocWithZone:(NSZone *)zone; | ||
{ | ||
if (sharedInstance) { | ||
return [sharedInstance retain]; | ||
} else { | ||
return [super allocWithZone:zone]; | ||
} | ||
} | ||
|
||
- (id)init; | ||
{ | ||
if (! sharedInstance) { | ||
if ((self = [super init])) { | ||
realMutableDictionary = [[NSMutableDictionary alloc] init]; | ||
hasInited = YES; | ||
} | ||
} | ||
|
||
return self; | ||
} | ||
|
||
- (id)initWithDictionary:(NSDictionary *)otherDictionary; | ||
{ | ||
if (! sharedInstance) { | ||
if ((self = [super init])) { | ||
realMutableDictionary = [[NSMutableDictionary dictionaryWithDictionary:otherDictionary] retain]; | ||
hasInited = YES; | ||
} | ||
} else { | ||
[sharedInstance setDictionary:otherDictionary]; | ||
} | ||
|
||
return self; | ||
} | ||
|
||
- (void)dealloc; | ||
{ | ||
[realMutableDictionary release]; | ||
[super dealloc]; | ||
} | ||
|
||
- (void)setObject:(id)object forKey:(id)key; | ||
{ | ||
[realMutableDictionary setObject:object forKey:key]; | ||
[[NSNotificationCenter defaultCenter] postNotificationName:@"ClickToFlashPluginDefaultsDidChange" object:self]; | ||
} | ||
|
||
- (void)removeObjectForKey:(id)key; | ||
{ | ||
[realMutableDictionary removeObjectForKey:key]; | ||
} | ||
|
||
- (id)objectForKey:(id)key; | ||
{ | ||
return [realMutableDictionary objectForKey:key]; | ||
} | ||
|
||
- (NSUInteger)count; | ||
{ | ||
return [realMutableDictionary count]; | ||
} | ||
|
||
- (NSEnumerator *)keyEnumerator; | ||
{ | ||
return [realMutableDictionary keyEnumerator]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// CTFUserDefaultsController.h | ||
// ClickToFlash | ||
// | ||
// Created by Simone Manganelli on 2009-05-23. | ||
// Copyright 2009 __MyCompanyName__. All rights reserved. | ||
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
#import "CTFPreferencesDictionary.h" | ||
|
||
|
||
@interface CTFUserDefaultsController : NSUserDefaultsController { | ||
CTFPreferencesDictionary *userDefaultsDict; | ||
BOOL hasInited; | ||
} | ||
|
||
+ (CTFUserDefaultsController *)standardUserDefaults; | ||
- (void)setUpExternalPrefsDictionary; | ||
|
||
- (void)pluginDefaultsDidChange:(NSNotification *)notification; | ||
- (CTFPreferencesDictionary *)values; | ||
- (CTFPreferencesDictionary *)dictionaryRepresentation; | ||
- (void)setValues:(CTFPreferencesDictionary *)newUserDefaultsDict; | ||
|
||
- (id)objectForKey:(NSString *)defaultName; | ||
- (void)setObject:(id)value forKey:(NSString *)defaultName; | ||
- (int)integerForKey:(NSString *)defaultName; | ||
- (void)setIntegerForKey:(int)value forKey:(NSString *)defaultName; | ||
- (BOOL)boolForKey:(NSString *)defaultName; | ||
- (void)setBool:(BOOL)value forKey:(NSString *)defaultName; | ||
- (NSArray *)arrayForKey:(NSString *)defaultName; | ||
- (void)removeObjectForKey:(NSString *)defaultName; | ||
|
||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
// | ||
// CTFUserDefaultsController.m | ||
// ClickToFlash | ||
// | ||
// Created by Simone Manganelli on 2009-05-23. | ||
// Copyright 2009 __MyCompanyName__. All rights reserved. | ||
// | ||
|
||
#import "CTFUserDefaultsController.h" | ||
|
||
static CTFUserDefaultsController *sharedInstance = nil; | ||
|
||
@implementation CTFUserDefaultsController | ||
|
||
+ (CTFUserDefaultsController *)standardUserDefaults; | ||
{ | ||
if (! sharedInstance) sharedInstance = [[self alloc] init]; | ||
return sharedInstance; | ||
} | ||
|
||
+ (id)allocWithZone:(NSZone *)zone; | ||
{ | ||
if (sharedInstance) { | ||
return [sharedInstance retain]; | ||
} else { | ||
return [super allocWithZone:zone]; | ||
} | ||
} | ||
|
||
- (id)init; | ||
{ | ||
if (! sharedInstance) { | ||
if ((self = [super init])) { | ||
hasInited = YES; | ||
} | ||
} | ||
|
||
return self; | ||
} | ||
|
||
- (void)dealloc; | ||
{ | ||
[userDefaultsDict release]; | ||
[super dealloc]; | ||
} | ||
|
||
- (void)setUpExternalPrefsDictionary; | ||
{ | ||
[[NSNotificationCenter defaultCenter] addObserver:self | ||
selector:@selector(pluginDefaultsDidChange:) | ||
name:@"ClickToFlashPluginDefaultsDidChange" | ||
object:nil]; | ||
[self setValues:[CTFPreferencesDictionary dictionaryWithDictionary: | ||
[[NSUserDefaults standardUserDefaults] persistentDomainForName:@"com.github.rentzsch.clicktoflash"]] | ||
]; | ||
} | ||
|
||
- (CTFPreferencesDictionary *)values; | ||
{ | ||
// I have no idea why, but -init, -initWithDefaults:initialValues:, | ||
// and +sharedUserDefaultsController all never seem to get called. Only | ||
// -awakeFromNib gets called, and that's too late for bindings; | ||
|
||
// so instead, we just wait for the initial call to access values, | ||
// and if that call detects that the user defaults dictionary hasn't | ||
// been set up yet, it sets it up and *then* returns the values | ||
|
||
if (! userDefaultsDict) { | ||
[self setUpExternalPrefsDictionary]; | ||
} | ||
return userDefaultsDict; | ||
} | ||
|
||
- (CTFPreferencesDictionary *)dictionaryRepresentation; | ||
{ | ||
return [self values]; | ||
} | ||
|
||
- (void)setValues:(CTFPreferencesDictionary *)newUserDefaultsDict; | ||
{ | ||
if (! userDefaultsDict) userDefaultsDict = [[CTFPreferencesDictionary alloc] init]; | ||
[userDefaultsDict removeAllObjects]; | ||
[userDefaultsDict addEntriesFromDictionary:newUserDefaultsDict]; | ||
} | ||
|
||
- (void)pluginDefaultsDidChange:(NSNotification *)notification; | ||
{ | ||
[[NSUserDefaults standardUserDefaults] setPersistentDomain:userDefaultsDict | ||
forName:@"com.github.rentzsch.clicktoflash"]; | ||
} | ||
|
||
- (id)objectForKey:(NSString *)defaultName; | ||
{ | ||
return [[self values] objectForKey:defaultName]; | ||
} | ||
|
||
- (void)setObject:(id)value forKey:(NSString *)defaultName; | ||
{ | ||
[[self values] setObject:value forKey:defaultName]; | ||
} | ||
|
||
- (int)integerForKey:(NSString *)defaultName; | ||
{ | ||
return [[[self values] objectForKey:defaultName] intValue]; | ||
} | ||
|
||
- (void)setIntegerForKey:(int)value forKey:(NSString *)defaultName; | ||
{ | ||
[[self values] setObject:[NSNumber numberWithInt:value] forKey:defaultName]; | ||
} | ||
|
||
- (BOOL)boolForKey:(NSString *)defaultName; | ||
{ | ||
return [[[self values] objectForKey:defaultName] boolValue]; | ||
} | ||
|
||
- (void)setBool:(BOOL)value forKey:(NSString *)defaultName; | ||
{ | ||
[[self values] setObject:[NSNumber numberWithBool:value] forKey:defaultName]; | ||
} | ||
|
||
- (NSArray *)arrayForKey:(NSString *)defaultName; | ||
{ | ||
id value = [[self values] objectForKey:defaultName]; | ||
id valueToReturn = nil; | ||
if ([[value className] isEqualToString:@"NSCFArray"]) valueToReturn = value; | ||
return valueToReturn; | ||
} | ||
|
||
- (void)removeObjectForKey:(NSString *)defaultName; | ||
{ | ||
[[self values] removeObjectForKey:defaultName]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.