Permalink
Browse files

partial support for putting CtF prefs in a separate prefs file; NOT C…

…OMPLETE YET
  • Loading branch information...
1 parent 0511649 commit 75e6c64ff9612b3c4f261db9f4cbb41b08758c6b Simone Manganelli committed May 29, 2009
@@ -0,0 +1,16 @@
+//
+// 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;
+}
+
+@end
@@ -0,0 +1,70 @@
+//
+// CTFPreferencesDictionary.m
+// ClickToFlash
+//
+// Created by Simone Manganelli on 2009-05-25.
+// Copyright 2009 __MyCompanyName__. All rights reserved.
+//
+
+#import "CTFPreferencesDictionary.h"
+
+
+@implementation CTFPreferencesDictionary
+
++ (id)dictionaryWithDictionary:(NSDictionary *)otherDictionary;
+{
+ return [[CTFPreferencesDictionary alloc] initWithDictionary:otherDictionary];
+}
+
+- (id)init;
+{
+ if ((self = [super init])) {
+ realMutableDictionary = [[NSMutableDictionary alloc] init];
+ }
+
+ return self;
+}
+
+- (id)initWithDictionary:(NSDictionary *)otherDictionary;
+{
+ if ((self = [super init])) {
+ realMutableDictionary = [[NSMutableDictionary dictionaryWithDictionary:otherDictionary] retain];
+ }
+
+ return self;
+}
+
+- (void)dealloc;
+{
+ [realMutableDictionary release];
+ [super dealloc];
+}
+
+- (void)setObject:(id)object forKey:(id)key;
+{
+ [realMutableDictionary setObject:object forKey:key];
+ NSLog(@"posting a notification of defaults change");
+ [[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
@@ -0,0 +1,20 @@
+//
+// 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;
+}
+
+- (void)pluginDefaultsDidChange:(NSNotification *)notification;
+- (void)setValues:(CTFPreferencesDictionary *)newUserDefaultsDict;
+
+@end
@@ -0,0 +1,50 @@
+//
+// CTFUserDefaultsController.m
+// ClickToFlash
+//
+// Created by Simone Manganelli on 2009-05-23.
+// Copyright 2009 __MyCompanyName__. All rights reserved.
+//
+
+#import "CTFUserDefaultsController.h"
+
+
+@implementation CTFUserDefaultsController
+
+- (void)awakeFromNib;
+{
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(pluginDefaultsDidChange:)
+ name:@"ClickToFlashPluginDefaultsDidChange"
+ object:nil];
+ [self setValues:[CTFPreferencesDictionary dictionaryWithDictionary:
+ [[NSUserDefaults standardUserDefaults] persistentDomainForName:@"com.github.rentzsch.clicktoflash"]]
+ ];
+}
+
+- (void)dealloc;
+{
+ [userDefaultsDict release];
+ [super dealloc];
+}
+
+- (CTFPreferencesDictionary *)values;
+{
+ return userDefaultsDict;
+}
+
+- (void)setValues:(CTFPreferencesDictionary *)newUserDefaultsDict;
+{
+ if (! userDefaultsDict) userDefaultsDict = [[CTFPreferencesDictionary alloc] init];
+ [userDefaultsDict removeAllObjects];
+ [userDefaultsDict addEntriesFromDictionary:newUserDefaultsDict];
+}
+
+- (void)pluginDefaultsDidChange:(NSNotification *)notification;
+{
+ NSLog(@"Setting persistent domain defaults: %@", userDefaultsDict);
+ [[NSUserDefaults standardUserDefaults] setPersistentDomain:userDefaultsDict
+ forName:@"com.github.rentzsch.clicktoflash"];
+}
+
+@end
@@ -50,6 +50,8 @@
844695F70F470D1F00DC783A /* CTFsIFRSupport.m in Sources */ = {isa = PBXBuildFile; fileRef = 844695910F46FC6600DC783A /* CTFsIFRSupport.m */; };
845704550F4792320017F3F4 /* CTFWhitelist.m in Sources */ = {isa = PBXBuildFile; fileRef = 845704540F4792320017F3F4 /* CTFWhitelist.m */; };
8457045A0F47BC170017F3F4 /* CTFUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 845704590F47BC170017F3F4 /* CTFUtilities.m */; };
+ A41626600FCB535300181427 /* CTFPreferencesDictionary.m in Sources */ = {isa = PBXBuildFile; fileRef = A416265F0FCB535300181427 /* CTFPreferencesDictionary.m */; };
+ A461B6590FC8ECB20028C966 /* CTFUserDefaultsController.m in Sources */ = {isa = PBXBuildFile; fileRef = A461B6580FC8ECB20028C966 /* CTFUserDefaultsController.m */; };
A494CC2C0F9F2446007D5EEB /* ctf.icns in Resources */ = {isa = PBXBuildFile; fileRef = A494CC2B0F9F2446007D5EEB /* ctf.icns */; };
B5028E930F413553004886D7 /* HarnessAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B5028E910F413553004886D7 /* HarnessAppDelegate.m */; };
B5CFF17A0F40EEF1005DB9CC /* WhitelistPanel.xib in Resources */ = {isa = PBXBuildFile; fileRef = 072189BC0F30D9C3008C8944 /* WhitelistPanel.xib */; };
@@ -153,6 +155,10 @@
845704540F4792320017F3F4 /* CTFWhitelist.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CTFWhitelist.m; path = Plugin/CTFWhitelist.m; sourceTree = "<group>"; };
845704580F47BC170017F3F4 /* CTFUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CTFUtilities.h; path = Plugin/CTFUtilities.h; sourceTree = "<group>"; };
845704590F47BC170017F3F4 /* CTFUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CTFUtilities.m; path = Plugin/CTFUtilities.m; sourceTree = "<group>"; };
+ A416265E0FCB535300181427 /* CTFPreferencesDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CTFPreferencesDictionary.h; sourceTree = "<group>"; };
+ A416265F0FCB535300181427 /* CTFPreferencesDictionary.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CTFPreferencesDictionary.m; sourceTree = "<group>"; };
+ A461B6570FC8ECB20028C966 /* CTFUserDefaultsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CTFUserDefaultsController.h; sourceTree = "<group>"; };
+ A461B6580FC8ECB20028C966 /* CTFUserDefaultsController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CTFUserDefaultsController.m; sourceTree = "<group>"; };
A494CC2B0F9F2446007D5EEB /* ctf.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = ctf.icns; sourceTree = "<group>"; };
B5028E910F413553004886D7 /* HarnessAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = HarnessAppDelegate.m; path = "TestFiles/Debugging Harness/HarnessAppDelegate.m"; sourceTree = "<group>"; };
B5028E920F413553004886D7 /* HarnessAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HarnessAppDelegate.h; path = "TestFiles/Debugging Harness/HarnessAppDelegate.h"; sourceTree = "<group>"; };
@@ -221,6 +227,10 @@
children = (
55EB703D0E04A84F0016593D /* Plugin.m */,
55EB703C0E04A84F0016593D /* Plugin.h */,
+ A416265E0FCB535300181427 /* CTFPreferencesDictionary.h */,
+ A416265F0FCB535300181427 /* CTFPreferencesDictionary.m */,
+ A461B6570FC8ECB20028C966 /* CTFUserDefaultsController.h */,
+ A461B6580FC8ECB20028C966 /* CTFUserDefaultsController.m */,
845704580F47BC170017F3F4 /* CTFUtilities.h */,
845704590F47BC170017F3F4 /* CTFUtilities.m */,
6953E4340F3EDE9D0014ECF7 /* CTFMenubarMenuController.m */,
@@ -454,6 +464,8 @@
8457045A0F47BC170017F3F4 /* CTFUtilities.m in Sources */,
79E2EB930F86AAD3005CF170 /* SparkleManager.m in Sources */,
0038DE240FC0CCF0007B54E9 /* MATrackingArea.m in Sources */,
+ A461B6590FC8ECB20028C966 /* CTFUserDefaultsController.m in Sources */,
+ A41626600FCB535300181427 /* CTFPreferencesDictionary.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -2,13 +2,13 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03">
<data>
<int key="IBDocument.SystemTarget">1050</int>
- <string key="IBDocument.SystemVersion">9G55</string>
+ <string key="IBDocument.SystemVersion">9J61</string>
<string key="IBDocument.InterfaceBuilderVersion">677</string>
- <string key="IBDocument.AppKitVersion">949.43</string>
+ <string key="IBDocument.AppKitVersion">949.46</string>
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="2"/>
+ <integer value="42"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -751,9 +751,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
<string key="NSFrameAutosaveName">ClickToFlash_settingsWindow</string>
</object>
- <object class="NSUserDefaultsController" id="913882380">
- <bool key="NSSharedInstance">YES</bool>
- </object>
<object class="NSArrayController" id="258102979">
<object class="NSMutableArray" key="NSDeclaredKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -769,6 +766,12 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<bool key="NSFilterRestrictsInsertion">YES</bool>
<bool key="NSClearsFilterPredicateOnInsertion">YES</bool>
</object>
+ <object class="NSUserDefaultsController" id="913882380">
+ <bool key="NSSharedInstance">YES</bool>
+ </object>
+ <object class="NSUserDefaultsController" id="961452516">
+ <bool key="NSAppliesImmediately">YES</bool>
+ </object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords">
@@ -944,22 +947,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
- <string key="label">value: values.ClickToFlash_pluginEnabled</string>
- <reference key="source" ref="596693856"/>
- <reference key="destination" ref="913882380"/>
- <object class="NSNibBindingConnector" key="connector">
- <reference key="NSSource" ref="596693856"/>
- <reference key="NSDestination" ref="913882380"/>
- <string key="NSLabel">value: values.ClickToFlash_pluginEnabled</string>
- <string key="NSBinding">value</string>
- <string key="NSKeyPath">values.ClickToFlash_pluginEnabled</string>
- <int key="NSNibBindingConnectorVersion">2</int>
- </object>
- </object>
- <int key="connectionID">155</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBBindingConnection" key="connection">
<string key="label">value: versionString</string>
<reference key="source" ref="710573940"/>
<reference key="destination" ref="1001"/>
@@ -978,6 +965,22 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<int key="connectionID">165</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBBindingConnection" key="connection">
+ <string key="label">value: values.ClickToFlash_pluginEnabled</string>
+ <reference key="source" ref="596693856"/>
+ <reference key="destination" ref="961452516"/>
+ <object class="NSNibBindingConnector" key="connector">
+ <reference key="NSSource" ref="596693856"/>
+ <reference key="NSDestination" ref="961452516"/>
+ <string key="NSLabel">value: values.ClickToFlash_pluginEnabled</string>
+ <string key="NSBinding">value</string>
+ <string key="NSKeyPath">values.ClickToFlash_pluginEnabled</string>
+ <int key="NSNibBindingConnectorVersion">2</int>
+ </object>
+ </object>
+ <int key="connectionID">171</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -1038,11 +1041,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string key="objectName">Whitelisted Hosts</string>
</object>
<object class="IBObjectRecord">
- <int key="objectID">7</int>
- <reference key="object" ref="913882380"/>
- <reference key="parent" ref="1002"/>
- </object>
- <object class="IBObjectRecord">
<int key="objectID">9</int>
<reference key="object" ref="510641939"/>
<object class="NSMutableArray" key="children">
@@ -1309,6 +1307,17 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<reference key="object" ref="358695226"/>
<reference key="parent" ref="710573940"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">7</int>
+ <reference key="object" ref="913882380"/>
+ <reference key="parent" ref="1002"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">170</int>
+ <reference key="object" ref="961452516"/>
+ <reference key="parent" ref="1002"/>
+ <string key="objectName">Plugin Defaults</string>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -1359,6 +1368,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string>156.IBPluginDependency</string>
<string>157.IBPluginDependency</string>
<string>17.IBPluginDependency</string>
+ <string>170.CustomClassName</string>
+ <string>170.IBPluginDependency</string>
<string>2.IBPluginDependency</string>
<string>20.IBPluginDependency</string>
<string>21.IBPluginDependency</string>
@@ -1370,6 +1381,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string>39.IBPluginDependency</string>
<string>4.IBPluginDependency</string>
<string>41.IBPluginDependency</string>
+ <string>7.CustomClassName</string>
<string>9.IBPluginDependency</string>
</object>
<object class="NSMutableArray" key="dict.values">
@@ -1460,6 +1472,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>CTFUserDefaultsController</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -1478,6 +1492,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>CTFUserDefaultsController</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
</object>
@@ -1501,12 +1516,20 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">165</int>
+ <int key="maxID">172</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
+ <string key="className">CTFUserDefaultsController</string>
+ <string key="superclassName">NSUserDefaultsController</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">CTFUserDefaultsController.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
<string key="className">CTFWhitelistWindowController</string>
<string key="superclassName">NSWindowController</string>
<object class="NSMutableDictionary" key="actions">
View
@@ -99,6 +99,8 @@ - (id) initWithArguments:(NSDictionary *)arguments
{
self = [super init];
if (self) {
+ [[NSUserDefaults standardUserDefaults] addSuiteNamed:@"com.github.rentzsch.clicktoflash"];
+
SparkleManager *sharedSparkleManager = [SparkleManager sharedManager];
NSWorkspace *sharedWorkspace = [NSWorkspace sharedWorkspace];
NSString *pathToRelaunch = [sharedWorkspace absolutePathForAppBundleWithIdentifier:[self launchedAppBundleIdentifier]];

0 comments on commit 75e6c64

Please sign in to comment.