Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/rentzsch/clicktoflash
Browse files Browse the repository at this point in the history
  • Loading branch information
Simone Manganelli authored and Simone Manganelli committed Jul 25, 2009
2 parents ec2265a + 1c0a092 commit d6a3e78
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 95 deletions.
1 change: 0 additions & 1 deletion Plugin/CTFWhitelist.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ THE SOFTWARE.
@interface CTFClickToFlashPlugin( Whitelist )

- (IBAction) addToWhitelist: (id) sender;
- (IBAction) removeFromWhitelist: (id) sender;
- (IBAction) editWhitelist: (id) sender;

- (void) _migrateWhitelist;
Expand Down
44 changes: 0 additions & 44 deletions Plugin/CTFWhitelist.m
Original file line number Diff line number Diff line change
Expand Up @@ -185,23 +185,10 @@ - (void) _addHostToWhitelist
[siteInfo addObject: whitelistItemForSite([self host])];

[[CTFUserDefaultsController standardUserDefaults] setValue:siteInfo forKeyPath:@"values.siteInfo"];
//[values setObject:siteInfo forKey:sHostSiteInfoDefaultsKey];
//[[CTFUserDefaultsController standardUserDefaults] setValues:values];

[[NSNotificationCenter defaultCenter] postNotificationName: sCTFWhitelistAdditionMade object: self];
}

- (void) _removeHostFromWhitelist
{
NSMutableArray *siteInfo = [self _mutableSiteInfo];
NSUInteger foundIndex = indexOfItemForSite(siteInfo, [self host]);

if(foundIndex != NSNotFound) {
[siteInfo removeObjectAtIndex: foundIndex];
[[CTFUserDefaultsController standardUserDefaults] setObject: siteInfo forKey: sHostSiteInfoDefaultsKey];
}
}

- (void) _whitelistAdditionMade: (NSNotification*) notification
{
if ([self _isHostWhitelisted])
Expand All @@ -216,37 +203,6 @@ - (IBAction)addToWhitelist:(id)sender;
[self _addHostToWhitelist];
}

- (IBAction) removeFromWhitelist: (id)sender
{
if (![self _isHostWhitelisted])
return;

NSString *title = NSLocalizedString(@"Stop always loading Flash?", @"Stop always loading Flash? alert title");
NSString *message = [NSString stringWithFormat:NSLocalizedString(@"Remove %@ from the whitelist?", @"Remove %@ from the whitelist? alert message"), [self host]];

NSAlert *alert = [[NSAlert alloc] init];
[alert addButtonWithTitle:NSLocalizedString(@"Remove from Whitelist", @"Remove from Whitelist button")];
[alert addButtonWithTitle:NSLocalizedString(@"Cancel", @"Cancel button")];
[alert setMessageText:title];
[alert setInformativeText:message];
[alert setAlertStyle:NSInformationalAlertStyle];
[alert beginSheetModalForWindow:[self window]
modalDelegate:self
didEndSelector:@selector(_removeFromWhitelistAlertDidEnd:returnCode:contextInfo:)
contextInfo:nil];
_activeAlert = alert;
}

- (void) _removeFromWhitelistAlertDidEnd: (NSAlert *)alert returnCode: (int)returnCode contextInfo: (void *)contextInfo
{
if (returnCode == NSAlertFirstButtonReturn)
{
[self _removeHostFromWhitelist];
}

[ self _alertDone ];
}

- (IBAction) editWhitelist: (id)sender;
{
[ [ CTFMenubarMenuController sharedController ] showSettingsWindow: self ];
Expand Down
27 changes: 2 additions & 25 deletions Plugin/English.lproj/ContextualMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="1"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand Down Expand Up @@ -78,14 +79,6 @@
<reference key="NSOnImage" ref="121969399"/>
<reference key="NSMixedImage" ref="575759592"/>
</object>
<object class="NSMenuItem" id="660793203">
<reference key="NSMenu" ref="93442052"/>
<string key="NSTitle">Remove from 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="380486120">
<reference key="NSMenu" ref="93442052"/>
<bool key="NSIsDisabled">YES</bool>
Expand Down Expand Up @@ -134,14 +127,6 @@
</object>
<int key="connectionID">11</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">removeFromWhitelist:</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="660793203"/>
</object>
<int key="connectionID">13</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">addToWhitelist:</string>
Expand Down Expand Up @@ -195,7 +180,6 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="831790790"/>
<reference ref="975793511"/>
<reference ref="660793203"/>
<reference ref="1001518375"/>
<reference ref="688689086"/>
<reference ref="380486120"/>
Expand All @@ -213,11 +197,6 @@
<reference key="object" ref="975793511"/>
<reference key="parent" ref="93442052"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">12</int>
<reference key="object" ref="660793203"/>
<reference key="parent" ref="93442052"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">14</int>
<reference key="object" ref="1001518375"/>
Expand Down Expand Up @@ -250,7 +229,6 @@
<string>1.IBEditorWindowLastContentRect</string>
<string>1.IBPluginDependency</string>
<string>10.IBPluginDependency</string>
<string>12.IBPluginDependency</string>
<string>14.IBPluginDependency</string>
<string>16.IBPluginDependency</string>
<string>19.IBPluginDependency</string>
Expand All @@ -262,8 +240,7 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilderKit</string>
<string>com.apple.InterfaceBuilderKit</string>
<string>{{371, 315}, {222, 123}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{371, 335}, {213, 103}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
Expand Down
28 changes: 4 additions & 24 deletions Plugin/Plugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ - (id) initWithArguments:(NSDictionary *)arguments
@"com.adobe.flexbuilder",
@"com.Zattoo.prefs",
@"fr.understudy.HuluPlayer",
@"com.apple.iWeb",
nil];

SparkleManager *sharedSparkleManager = [SparkleManager sharedManager];
Expand Down Expand Up @@ -719,11 +720,6 @@ - (BOOL) validateMenuItem: (NSMenuItem *)menuItem
if ([self _isHostWhitelisted])
enabled = NO;
}
else if (action == @selector(removeFromWhitelist:))
{
if (![self _isHostWhitelisted])
enabled = NO;
}

return enabled;
}
Expand Down Expand Up @@ -806,15 +802,10 @@ - (void) _drawBadgeWithPressed: (BOOL) pressed

NSString* str = [ self badgeLabelText ];

NSShadow *superAwesomeShadow = [[NSShadow alloc] init];
[superAwesomeShadow setShadowOffset:NSMakeSize(2.0, -2.0)];
[superAwesomeShadow setShadowColor:[NSColor whiteColor]];
[superAwesomeShadow autorelease];
NSDictionary* attrs = [ NSDictionary dictionaryWithObjectsAndKeys:
[ NSFont boldSystemFontOfSize: 20 ], NSFontAttributeName,
[ NSNumber numberWithInt: -1 ], NSKernAttributeName,
[ NSColor blackColor ], NSForegroundColorAttributeName,
superAwesomeShadow, NSShadowAttributeName,
nil ];

// Set up for drawing.
Expand Down Expand Up @@ -879,7 +870,7 @@ - (void) _drawBadgeWithPressed: (BOOL) pressed

CGContextRef context = [ [ NSGraphicsContext currentContext ] graphicsPort ];

CGContextSetAlpha( context, pressed ? 0.50 : 0.35 );
CGContextSetAlpha( context, pressed ? 0.40 : 0.25 );
CGContextBeginTransparencyLayer( context, nil );

// Draw everything at full size, centered on the origin.
Expand All @@ -888,25 +879,14 @@ - (void) _drawBadgeWithPressed: (BOOL) pressed
NSRect borderRect = NSMakeRect( loc.x - kFrameXInset, loc.y - kFrameYInset, w, h );

NSBezierPath* fillPath = bezierPathWithRoundedRectCornerRadius( NSInsetRect( borderRect, -2, -2 ), 6 );
[ [ NSColor colorWithCalibratedWhite: 1.0 alpha: 0.45 ] set ];
[ [ NSColor colorWithCalibratedWhite: 1.0 alpha: 0.25 ] set ];
[ fillPath fill ];

NSUInteger thickLineWidth = 5;
NSBezierPath* path = bezierPathWithRoundedRectCornerRadius( borderRect, 4 );
[ [ NSColor blackColor ] set ];
[ path setLineWidth: thickLineWidth ];
[ path setLineWidth: 3 ];
[ path stroke ];

NSUInteger thinLineWidth = 2;
NSRect thinBorderRect = NSMakeRect( loc.x - kFrameXInset - thickLineWidth/4,
loc.y - kFrameYInset - thickLineWidth/4,
w + thickLineWidth/2,
h + thickLineWidth/2);
NSBezierPath* thinPath = bezierPathWithRoundedRectCornerRadius( thinBorderRect, 4 );
[ [ NSColor whiteColor ] set ];
[ thinPath setLineWidth: thinLineWidth ];
[ thinPath stroke ];

[ str drawAtPoint: loc withAttributes: attrs ];

// Now restore the graphics state:
Expand Down
9 changes: 8 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
desc "Restart Safari"
task :restart do
system("osascript -e 'tell application \"Safari\"' -e 'quit' -e 'end tell' && osascript -e 'tell application \"Safari\"' -e 'activate' -e 'end tell'")
end

desc "Build the Release configuration of the plugin and install for the current user."
task :default do
task :release do
system('xcodebuild -configuration Release -target "Install plugin for user"')
end

desc "Build the Debug configuration of the plugin and install for the current user."
task :debug do
system('xcodebuild -configuration Debug -target "Install plugin for user"')
end

task :default => [:release, :restart]

0 comments on commit d6a3e78

Please sign in to comment.