Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
  • 2 commits
  • 6 files changed
  • 0 commit comments
  • 1 contributor
Commits on May 26, 2012
@idodeclare idodeclare Update comment binding so that dotConf notification is handled
- bind directly to GPGOptions comment, using the new
  GPGCommentTransformer (based off code formerly in
  GPGToolsPrefController)
7fb3a2b
@idodeclare idodeclare Also pass-through KV notifications for "keyserver" and "default-key" d45751a
View
8 GPGPreferences.xcodeproj/project.pbxproj
@@ -26,6 +26,8 @@
30D5316213CA09790035AA8B /* GPGTools_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = 22EE1F4812EE10EE0002556B /* GPGTools_Prefix.pch */; };
30D5317D13CA0B130035AA8B /* Libmacgpg.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3060E6D313C9F9150083CF14 /* Libmacgpg.framework */; };
30F048F413EB570E00A428BC /* Keyservers.plist in Resources */ = {isa = PBXBuildFile; fileRef = 30F048F313EB570E00A428BC /* Keyservers.plist */; };
+ 451406AC157177CA0005C880 /* GPGCommentTransformer.h in Headers */ = {isa = PBXBuildFile; fileRef = 451406AA157177CA0005C880 /* GPGCommentTransformer.h */; };
+ 451406AD157177CA0005C880 /* GPGCommentTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = 451406AB157177CA0005C880 /* GPGCommentTransformer.m */; };
4526411514FD4FD90025BD91 /* GPGIsUnselectedTransformer.h in Headers */ = {isa = PBXBuildFile; fileRef = 4526411314FD4FD90025BD91 /* GPGIsUnselectedTransformer.h */; };
4526411614FD4FD90025BD91 /* GPGIsUnselectedTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = 4526411414FD4FD90025BD91 /* GPGIsUnselectedTransformer.m */; };
8D202CF10486D31800D8A456 /* GPGToolsPref.m in Sources */ = {isa = PBXBuildFile; fileRef = F506C03D013D9D7901CA16C8 /* GPGToolsPref.m */; };
@@ -96,6 +98,8 @@
30C1E91714D2D2550081E091 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/GPGToolsPref.xib.strings; sourceTree = "<group>"; };
30D5314C13CA06FF0035AA8B /* GPGTools.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = GPGTools.png; sourceTree = "<group>"; };
30F048F313EB570E00A428BC /* Keyservers.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Keyservers.plist; sourceTree = "<group>"; };
+ 451406AA157177CA0005C880 /* GPGCommentTransformer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPGCommentTransformer.h; path = Source/GPGCommentTransformer.h; sourceTree = "<group>"; };
+ 451406AB157177CA0005C880 /* GPGCommentTransformer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GPGCommentTransformer.m; path = Source/GPGCommentTransformer.m; sourceTree = "<group>"; };
4526411314FD4FD90025BD91 /* GPGIsUnselectedTransformer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPGIsUnselectedTransformer.h; path = Source/GPGIsUnselectedTransformer.h; sourceTree = "<group>"; };
4526411414FD4FD90025BD91 /* GPGIsUnselectedTransformer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GPGIsUnselectedTransformer.m; path = Source/GPGIsUnselectedTransformer.m; sourceTree = "<group>"; };
8D202CF70486D31800D8A456 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@@ -167,6 +171,8 @@
22E7F132120A149200EB0E77 /* GPGToolsPrefController.m */,
4526411314FD4FD90025BD91 /* GPGIsUnselectedTransformer.h */,
4526411414FD4FD90025BD91 /* GPGIsUnselectedTransformer.m */,
+ 451406AA157177CA0005C880 /* GPGCommentTransformer.h */,
+ 451406AB157177CA0005C880 /* GPGCommentTransformer.m */,
);
name = Classes;
sourceTree = "<group>";
@@ -275,6 +281,7 @@
30D5315E13CA09750035AA8B /* GPGToolsPref.h in Headers */,
30D5315F13CA09750035AA8B /* GPGToolsPrefController.h in Headers */,
4526411514FD4FD90025BD91 /* GPGIsUnselectedTransformer.h in Headers */,
+ 451406AC157177CA0005C880 /* GPGCommentTransformer.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -396,6 +403,7 @@
8D202CF10486D31800D8A456 /* GPGToolsPref.m in Sources */,
22E7F134120A149200EB0E77 /* GPGToolsPrefController.m in Sources */,
4526411614FD4FD90025BD91 /* GPGIsUnselectedTransformer.m in Sources */,
+ 451406AD157177CA0005C880 /* GPGCommentTransformer.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
84 Resources/en.lproj/GPGToolsPref.xib
@@ -2,13 +2,13 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1060</int>
- <string key="IBDocument.SystemVersion">11D50</string>
- <string key="IBDocument.InterfaceBuilderVersion">2177</string>
- <string key="IBDocument.AppKitVersion">1138.32</string>
- <string key="IBDocument.HIToolboxVersion">568.00</string>
+ <string key="IBDocument.SystemVersion">11E53</string>
+ <string key="IBDocument.InterfaceBuilderVersion">2182</string>
+ <string key="IBDocument.AppKitVersion">1138.47</string>
+ <string key="IBDocument.HIToolboxVersion">569.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="NS.object.0">2177</string>
+ <string key="NS.object.0">2182</string>
</object>
<array key="IBDocument.IntegratedClassDependencies">
<string>NSMenuItem</string>
@@ -175,12 +175,12 @@
<string key="NSFrame">{{13, 10}, {656, 311}}</string>
<reference key="NSSuperview" ref="1037298196"/>
<reference key="NSWindow"/>
- <reference key="NSNextKeyView" ref="767432390"/>
+ <reference key="NSNextKeyView" ref="964868510"/>
<array class="NSMutableArray" key="NSTabViewItems">
<object class="NSTabViewItem" id="135203895">
<string key="NSIdentifier">Item 2</string>
<object class="NSView" key="NSView" id="767432390">
- <reference key="NSNextResponder" ref="970373435"/>
+ <nil key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<array class="NSMutableArray" key="NSSubviews">
<object class="NSImageView" id="685955722">
@@ -196,7 +196,6 @@
</set>
<string key="NSFrame">{{17, 212}, {50, 50}}</string>
<reference key="NSSuperview" ref="767432390"/>
- <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="486326244"/>
<bool key="NSEnabled">YES</bool>
<object class="NSImageCell" key="NSCell" id="584209313">
@@ -218,7 +217,6 @@
<int key="NSvFlags">266</int>
<string key="NSFrame">{{72, 211}, {544, 51}}</string>
<reference key="NSSuperview" ref="767432390"/>
- <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="317615600"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="121461728">
@@ -248,7 +246,6 @@
<int key="NSvFlags">12</int>
<string key="NSFrame">{{-3, 200}, {639, 5}}</string>
<reference key="NSSuperview" ref="767432390"/>
- <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="201672854"/>
<string key="NSOffsets">{0, 0}</string>
<object class="NSTextFieldCell" key="NSTitleCell">
@@ -284,7 +281,6 @@
<int key="NSvFlags">266</int>
<string key="NSFrame">{{14, 150}, {81, 17}}</string>
<reference key="NSSuperview" ref="767432390"/>
- <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="863274492"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="461736257">
@@ -302,7 +298,6 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{97, 144}, {511, 26}}</string>
<reference key="NSSuperview" ref="767432390"/>
- <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="68396961"/>
<bool key="NSEnabled">YES</bool>
<object class="NSPopUpButtonCell" key="NSCell" id="978660101">
@@ -353,7 +348,6 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{15, 117}, {308, 18}}</string>
<reference key="NSSuperview" ref="767432390"/>
- <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="236484592"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="949489464">
@@ -382,7 +376,6 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{14, 91}, {181, 17}}</string>
<reference key="NSSuperview" ref="767432390"/>
- <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="418540942"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="710770507">
@@ -400,7 +393,6 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{268, 91}, {56, 17}}</string>
<reference key="NSSuperview" ref="767432390"/>
- <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="333704446"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="698217851">
@@ -418,7 +410,6 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{200, 89}, {63, 22}}</string>
<reference key="NSSuperview" ref="767432390"/>
- <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="451938746"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="294286583">
@@ -482,7 +473,6 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{14, 63}, {70, 17}}</string>
<reference key="NSSuperview" ref="767432390"/>
- <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="705680068"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="1044473954">
@@ -500,7 +490,6 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{87, 57}, {521, 26}}</string>
<reference key="NSSuperview" ref="767432390"/>
- <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="1058382928"/>
<bool key="NSEnabled">YES</bool>
<object class="NSComboBoxCell" key="NSCell" id="680595605">
@@ -593,7 +582,6 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{14, 177}, {113, 17}}</string>
<reference key="NSSuperview" ref="767432390"/>
- <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="533650464"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="901770327">
@@ -615,7 +603,6 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{404, 108}, {207, 32}}</string>
<reference key="NSSuperview" ref="767432390"/>
- <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="203553475"/>
<string key="NSReuseIdentifierKey">_NS:161</string>
<bool key="NSEnabled">YES</bool>
@@ -639,7 +626,6 @@
<int key="NSvFlags">-2147483380</int>
<string key="NSFrame">{{606, 146}, {18, 24}}</string>
<reference key="NSSuperview" ref="767432390"/>
- <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="445203048"/>
<string key="NSReuseIdentifierKey">_NS:22</string>
<bool key="NSEnabled">YES</bool>
@@ -664,8 +650,6 @@
</object>
</array>
<string key="NSFrame">{{10, 33}, {636, 265}}</string>
- <reference key="NSSuperview" ref="970373435"/>
- <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="685955722"/>
</object>
<string key="NSLabel">Configure</string>
@@ -674,7 +658,7 @@
</object>
<object class="NSTabViewItem" id="705230380">
<object class="NSView" key="NSView" id="964868510">
- <nil key="NSNextResponder"/>
+ <reference key="NSNextResponder" ref="970373435"/>
<int key="NSvFlags">256</int>
<array class="NSMutableArray" key="NSSubviews">
<object class="NSScrollView" id="844904398">
@@ -688,9 +672,29 @@
<object class="NSTextView" id="639660204">
<reference key="NSNextResponder" ref="850649704"/>
<int key="NSvFlags">2322</int>
+ <set class="NSMutableSet" key="NSDragTypes">
+ <string>Apple HTML pasteboard type</string>
+ <string>Apple PDF pasteboard type</string>
+ <string>Apple PICT pasteboard type</string>
+ <string>Apple PNG pasteboard type</string>
+ <string>Apple URL pasteboard type</string>
+ <string>CorePasteboardFlavorType 0x6D6F6F76</string>
+ <string>NSColor pasteboard type</string>
+ <string>NSFilenamesPboardType</string>
+ <string>NSStringPboardType</string>
+ <string>NeXT Encapsulated PostScript v1.2 pasteboard type</string>
+ <string>NeXT RTFD pasteboard type</string>
+ <string>NeXT Rich Text Format v1.0 pasteboard type</string>
+ <string>NeXT TIFF v4.0 pasteboard type</string>
+ <string>NeXT font pasteboard type</string>
+ <string>NeXT ruler pasteboard type</string>
+ <string>WebURLsWithTitlesPboardType</string>
+ <string>public.url</string>
+ </set>
<string key="NSFrameSize">{586, 101}</string>
<reference key="NSSuperview" ref="850649704"/>
- <reference key="NSNextKeyView" ref="106083773"/>
+ <reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="473798563"/>
<string key="NSReuseIdentifierKey">_NS:3770</string>
<object class="NSTextContainer" key="NSTextContainer" id="337339213">
<object class="NSLayoutManager" key="NSLayoutManager">
@@ -756,6 +760,7 @@
</array>
<string key="NSFrame">{{1, 1}, {586, 150}}</string>
<reference key="NSSuperview" ref="844904398"/>
+ <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="639660204"/>
<string key="NSReuseIdentifierKey">_NS:3768</string>
<reference key="NSDocView" ref="639660204"/>
@@ -791,6 +796,7 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
<int key="NSvFlags">-2147483392</int>
<string key="NSFrame">{{288, 1}, {15, 150}}</string>
<reference key="NSSuperview" ref="844904398"/>
+ <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="833740871"/>
<string key="NSReuseIdentifierKey">_NS:3785</string>
<reference key="NSTarget" ref="844904398"/>
@@ -803,6 +809,7 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
<int key="NSvFlags">-2147483392</int>
<string key="NSFrame">{{-100, -100}, {302, 15}}</string>
<reference key="NSSuperview" ref="844904398"/>
+ <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="850649704"/>
<string key="NSReuseIdentifierKey">_NS:3773</string>
<int key="NSsFlags">1</int>
@@ -814,7 +821,8 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
</array>
<string key="NSFrame">{{17, 85}, {588, 152}}</string>
<reference key="NSSuperview" ref="964868510"/>
- <reference key="NSNextKeyView" ref="850649704"/>
+ <reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="106083773"/>
<string key="NSReuseIdentifierKey">_NS:148</string>
<int key="NSsFlags">133650</int>
<reference key="NSVScroller" ref="473798563"/>
@@ -826,6 +834,7 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{14, 245}, {77, 17}}</string>
<reference key="NSSuperview" ref="964868510"/>
+ <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="844904398"/>
<string key="NSReuseIdentifierKey">_NS:3946</string>
<bool key="NSEnabled">YES</bool>
@@ -845,6 +854,8 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{15, 61}, {118, 18}}</string>
<reference key="NSSuperview" ref="964868510"/>
+ <reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="1058382928"/>
<string key="NSReuseIdentifierKey">_NS:239</string>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="208696943">
@@ -866,6 +877,8 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
</object>
</array>
<string key="NSFrame">{{10, 33}, {636, 265}}</string>
+ <reference key="NSSuperview" ref="970373435"/>
+ <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="362948840"/>
</object>
<string key="NSLabel">Comments</string>
@@ -1119,7 +1132,6 @@ TWFpbCBhZnRlciBhbiBPUyB1cGRhdGUuA</string>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{424, 8}, {184, 14}}</string>
<reference key="NSSuperview" ref="874115507"/>
- <reference key="NSNextKeyView" ref="1058382928"/>
<string key="NSReuseIdentifierKey">_NS:3946</string>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="330053523">
@@ -1232,13 +1244,13 @@ TWFpbCBhZnRlciBhbiBPUyB1cGRhdGUuA</string>
<reference key="NSTabView" ref="970373435"/>
</object>
</array>
- <reference key="NSSelectedTabViewItem" ref="135203895"/>
+ <reference key="NSSelectedTabViewItem" ref="705230380"/>
<reference key="NSFont" ref="271635649"/>
<int key="NSTvFlags">0</int>
<bool key="NSAllowTruncatedLabels">YES</bool>
<bool key="NSDrawsBackground">YES</bool>
<array class="NSMutableArray" key="NSSubviews">
- <reference ref="767432390"/>
+ <reference ref="964868510"/>
</array>
</object>
</array>
@@ -1489,19 +1501,23 @@ TWFpbCBhZnRlciBhbiBPUyB1cGRhdGUuA</string>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
- <string key="label">value: comments</string>
+ <string key="label">value: self.options.comment</string>
<reference key="source" ref="639660204"/>
<reference key="destination" ref="53615620"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="639660204"/>
<reference key="NSDestination" ref="53615620"/>
- <string key="NSLabel">value: comments</string>
+ <string key="NSLabel">value: self.options.comment</string>
<string key="NSBinding">value</string>
- <string key="NSKeyPath">comments</string>
+ <string key="NSKeyPath">self.options.comment</string>
+ <object class="NSDictionary" key="NSOptions">
+ <string key="NS.key.0">NSValueTransformerName</string>
+ <string key="NS.object.0">GPGCommentTransformer</string>
+ </object>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
- <int key="connectionID">653</int>
+ <int key="connectionID">692</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
@@ -2283,7 +2299,7 @@ TWFpbCBhZnRlciBhbiBPUyB1cGRhdGUuA</string>
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
- <int key="maxID">689</int>
+ <int key="maxID">692</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
View
16 Source/GPGCommentTransformer.h
@@ -0,0 +1,16 @@
+//
+// GPGCommentTransformer.h
+// GPGPreferences
+//
+// Created by Chris Fraire on 5/26/12.
+// Copyright (c) 2012 Chris Fraire. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+// Represents a transformer that creates a contiguous NSString
+// from an NSArray of strings (which come from GPGOptions) and
+// vice versa.
+@interface GPGCommentTransformer : NSValueTransformer
+
+@end
View
41 Source/GPGCommentTransformer.m
@@ -0,0 +1,41 @@
+//
+// GPGCommentTransformer.m
+// GPGPreferences
+//
+// Created by Chris Fraire on 5/26/12.
+// Copyright (c) 2012 Chris Fraire. All rights reserved.
+//
+
+#import "GPGCommentTransformer.h"
+
+@implementation GPGCommentTransformer
+
++ (Class)transformedValueClass { return [NSArray class]; }
+
++ (BOOL)allowsReverseTransformation { return YES; }
+
+- (id)transformedValue:(id)value
+{
+ NSArray *input = value;
+ return [input componentsJoinedByString:@"\n"];
+}
+
+- (id)reverseTransformedValue:(id)value
+{
+ // originally from GPGToolsPrefController
+
+ NSArray *lines = [value componentsSeparatedByString:@"\n"];
+ NSMutableArray *filteredLines = [NSMutableArray array];
+ NSCharacterSet *whitespaceCharacterSet = [NSCharacterSet whitespaceCharacterSet];
+ NSCharacterSet *nonWhitespaceCharacterSet = [whitespaceCharacterSet invertedSet];
+
+ for (NSString *line in lines) {
+ if ([line rangeOfCharacterFromSet:nonWhitespaceCharacterSet].length > 0) {
+ [filteredLines addObject:[line stringByTrimmingCharactersInSet:whitespaceCharacterSet]];
+ }
+ }
+
+ return filteredLines;
+}
+
+@end
View
1  Source/GPGToolsPrefController.h
@@ -28,7 +28,6 @@
@property (readonly) NSString *bundleVersion;
@property NSInteger indexOfSelectedSecretKey;
@property NSInteger passphraseCacheTime;
-@property (retain) NSString *comments;
@property (readonly) GPGOptions *options;
// Get a list of keyservers from GPGOptions
View
48 Source/GPGToolsPrefController.m
@@ -16,6 +16,8 @@
static NSString * const kKeyserver = @"keyserver";
static NSString * const kAutoKeyLocate = @"auto-key-locate";
+static NSString * const kDefaultKey = @"default-key";
+static NSString * const kIndexOfSelectedSecretKey = @"indexOfSelectedSecretKey";
@interface GPGToolsPrefController()
@property (retain) SUUpdater *updater;
@@ -36,6 +38,8 @@ - (id)init {
gpgc.delegate = self;
options = [[GPGOptions sharedOptions] retain];
+ [options addObserver:self forKeyPath:kKeyserver options:NSKeyValueObservingOptionNew context:nil];
+ [options addObserver:self forKeyPath:kDefaultKey options:NSKeyValueObservingOptionNew context:nil];
self.updater = [SUUpdater updaterForBundle:[NSBundle bundleForClass:[self class]]];
//updater.delegate = self;
@@ -46,6 +50,8 @@ - (id)init {
- (void)dealloc {
[gpgc release];
[secretKeysLock release];
+ [options removeObserver:self forKeyPath:kKeyserver];
+ [options removeObserver:self forKeyPath:kDefaultKey];
[options release];
self.updater = nil;
[super dealloc];
@@ -56,30 +62,9 @@ - (void)dealloc {
return @"/Applications/Mail.app";
}*/
-- (NSString *)comments {
- return [[options valueInGPGConfForKey:@"comment"] componentsJoinedByString:@"\n"];
-}
-- (void)setComments:(NSString *)value {
- NSArray *lines = [value componentsSeparatedByString:@"\n"];
- NSMutableArray *filteredLines = [NSMutableArray array];
- NSCharacterSet *whitespaceCharacterSet = [NSCharacterSet whitespaceCharacterSet];
- NSCharacterSet *nonWhitespaceCharacterSet = [whitespaceCharacterSet invertedSet];
-
- [lines enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
- if ([obj rangeOfCharacterFromSet:nonWhitespaceCharacterSet].length > 0) {
- [filteredLines addObject:[obj stringByTrimmingCharactersInSet:whitespaceCharacterSet]];
- }
- }];
-
-
- [options setValueInGPGConf:filteredLines forKey:@"comment"];
-}
-
-
-
+ (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key {
NSSet *mySet = nil;
- NSSet *keysAffectedBySecretKeys = [NSSet setWithObjects:@"secretKeyDescriptions", @"indexOfSelectedSecretKey", nil];
+ NSSet *keysAffectedBySecretKeys = [NSSet setWithObjects:@"secretKeyDescriptions", kIndexOfSelectedSecretKey, nil];
if ([keysAffectedBySecretKeys containsObject:key]) {
mySet = [NSSet setWithObject:@"secretKeys"];
}
@@ -88,6 +73,19 @@ + (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key {
}
+- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
+{
+ if ([kKeyserver isEqualToString:keyPath]) {
+ [self willChangeValueForKey:kKeyserver];
+ [self didChangeValueForKey:kKeyserver];
+ }
+ else if ([kDefaultKey isEqualToString:keyPath]) {
+ [self willChangeValueForKey:kIndexOfSelectedSecretKey];
+ [self didChangeValueForKey:kIndexOfSelectedSecretKey];
+ }
+}
+
+
/*
* Delete stored passphrases from the Mac OS X keychain.
*/
@@ -295,7 +293,7 @@ - (NSArray *)secretKeyDescriptions {
* Index of the default key.
*/
- (NSInteger)indexOfSelectedSecretKey {
- NSString *defaultKey = [options valueForKey:@"default-key"];
+ NSString *defaultKey = [options valueForKey:kDefaultKey];
if ([defaultKey length] == 0) {
return -1;
}
@@ -315,10 +313,10 @@ - (NSInteger)indexOfSelectedSecretKey {
- (void)setIndexOfSelectedSecretKey:(NSInteger)index {
NSArray *keys = self.secretKeys;
if (index < [keys count] && index >= 0) {
- [options setValue:[[keys objectAtIndex:index] fingerprint] forKey:@"default-key"];
+ [options setValue:[[keys objectAtIndex:index] fingerprint] forKey:kDefaultKey];
}
else if (index == -1) {
- [options setValue:nil forKey:@"default-key"];
+ [options setValue:nil forKey:kDefaultKey];
}
}

No commit comments for this range

Something went wrong with that request. Please try again.