Skip to content

Commit

Permalink
Add to whitelist context menu item lists host name, skips confirmatio…
Browse files Browse the repository at this point in the history
…n sheet.

- Added property addToWhiteListMenuTitle, which context menu binds to.

- Removed alternative menu item toggled by option key.

Ticket: http://rentzsch.lighthouseapp.com/projects/24342-clicktoflash/tickets/20
  • Loading branch information
kamitchell committed Feb 1, 2009
1 parent 64a09eb commit 83f1210
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 36 deletions.
46 changes: 18 additions & 28 deletions Plugin/English.lproj/ContextualMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,10 @@
<reference key="NSOnImage" ref="121969399"/>
<reference key="NSMixedImage" ref="575759592"/>
</object>
<object class="NSMenuItem" id="1047744293">
<reference key="NSMenu" ref="93442052"/>
<string key="NSTitle">Add to whitelist...</string>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="121969399"/>
<reference key="NSMixedImage" ref="575759592"/>
</object>
<object class="NSMenuItem" id="1001518375">
<reference key="NSMenu" ref="93442052"/>
<bool key="NSIsAlternate">YES</bool>
<string key="NSTitle">Add to whitelist</string>
<string key="NSKeyEquiv"/>
<int key="NSKeyEquivModMask">524288</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="121969399"/>
<reference key="NSMixedImage" ref="575759592"/>
Expand All @@ -103,14 +93,6 @@
<object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">addToWhitelist:</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="1047744293"/>
</object>
<int key="connectionID">5</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">editWhitelist:</string>
Expand Down Expand Up @@ -151,6 +133,22 @@
</object>
<int key="connectionID">15</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">title: self.addToWhiteListMenuTitle</string>
<reference key="source" ref="1001518375"/>
<reference key="destination" ref="1001"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="1001518375"/>
<reference key="NSDestination" ref="1001"/>
<string key="NSLabel">title: self.addToWhiteListMenuTitle</string>
<string key="NSBinding">title</string>
<string key="NSKeyPath">self.addToWhiteListMenuTitle</string>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">18</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
Expand Down Expand Up @@ -186,7 +184,6 @@
<reference key="object" ref="93442052"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="1047744293"/>
<reference ref="831790790"/>
<reference ref="975793511"/>
<reference ref="660793203"/>
Expand All @@ -195,11 +192,6 @@
</object>
<reference key="parent" ref="1002"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">2</int>
<reference key="object" ref="1047744293"/>
<reference key="parent" ref="93442052"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">3</int>
<reference key="object" ref="831790790"/>
Expand Down Expand Up @@ -240,16 +232,14 @@
<string>12.IBPluginDependency</string>
<string>14.IBPluginDependency</string>
<string>16.IBPluginDependency</string>
<string>2.IBPluginDependency</string>
<string>3.IBPluginDependency</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilderKit</string>
<string>com.apple.InterfaceBuilderKit</string>
<string>{{430, 325}, {234, 113}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{430, 345}, {220, 93}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
Expand Down Expand Up @@ -278,7 +268,7 @@
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">16</int>
<int key="maxID">18</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
Expand Down
1 change: 1 addition & 0 deletions Plugin/Plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ THE SOFTWARE.

@property (nonatomic, retain) DOMElement *container;
@property (nonatomic, retain) NSString *host;
@property (readonly, nonatomic, retain) NSString *addToWhiteListMenuTitle;

- (IBAction)addToWhitelist:(id)sender;
- (IBAction)removeFromWhitelist:(id)sender;
Expand Down
15 changes: 7 additions & 8 deletions Plugin/Plugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ - (void) _removeHostFromWhitelist
#pragma mark -
#pragma mark Contextual menu

- (NSString*) addToWhiteListMenuTitle
{
return [NSString stringWithFormat:NSLocalizedString(@"Add %@ to whitelist", @"Add %@ to whitelist"), self.host];
}

- (BOOL)validateMenuItem:(NSMenuItem *)menuItem
{
BOOL enabled = YES;
Expand All @@ -241,14 +246,8 @@ - (IBAction)addToWhitelist:(id)sender;
if ([self _isHostWhitelisted])
return;

if ([self _isOptionPressed])
{
[self _addHostToWhitelist];
[self _convertTypesForContainer];
return;
}

[self _askToAddCurrentSiteToWhitelist];
[self _addHostToWhitelist];
[self _convertTypesForContainer];
}

- (IBAction)removeFromWhitelist:(id)sender;
Expand Down

0 comments on commit 83f1210

Please sign in to comment.