Browse files

'Load YouTube.com page for this video' menu item no longer shows up f…

…or videos on pages from YouTube

Signed-off-by: Jonathan 'Wolf' Rentzsch <jwr.git@redshed.net>
  • Loading branch information...
1 parent cc79f2a commit 97ec6c1468a9496e78f67d468bc6b6b5c026ad0f Simone Manganelli committed with Jul 14, 2009
Showing with 25 additions and 8 deletions.
  1. +1 −0 Plugin/Plugin.h
  2. +24 −8 Plugin/Plugin.m
View
1 Plugin/Plugin.h
@@ -41,6 +41,7 @@ THE SOFTWARE.
BOOL mouseInside;
BOOL _isLoadingFromWhitelist;
BOOL _fromYouTube;
+ BOOL _embeddedYouTubeView;
BOOL _hasH264Version;
BOOL _hasHDH264Version;
WebView *_webView;
View
32 Plugin/Plugin.m
@@ -114,6 +114,7 @@ - (id) initWithArguments:(NSDictionary *)arguments
_hasH264Version = NO;
_hasHDH264Version = NO;
_contextMenuIsVisible = NO;
+ _embeddedYouTubeView = NO;
defaultWhitelist = [NSArray arrayWithObjects: @"com.apple.frontrow",
@"com.apple.dashboard.client",
@"com.apple.ScreenSaver.Engine",
@@ -198,6 +199,8 @@ - (id) initWithArguments:(NSDictionary *)arguments
// determine the video_id, then get the source of the YouTube
// page to get the Flash vars
+ _embeddedYouTubeView = YES;
+
NSString *videoIdFromURL = nil;
NSScanner *URLScanner = [[NSScanner alloc] initWithString:[self src]];
[URLScanner scanUpToString:@"youtube.com/v/" intoString:nil];
@@ -599,24 +602,37 @@ - (void) setUpExtraMenuItems
if (_fromYouTube) {
if ([[self menu] indexOfItemWithTarget:self andAction:@selector(loadYouTubePage:)] == -1) {
- [[self menu] insertItem:[NSMenuItem separatorItem] atIndex:2];
- [[self menu] insertItemWithTitle: NSLocalizedString ( @"Load YouTube.com page for this video", "Load YouTube page menu item" )
- action: @selector (loadYouTubePage: ) keyEquivalent: @"" atIndex: 3];
- [[[self menu] itemAtIndex: 3] setTarget: self];
+ if (_embeddedYouTubeView) {
+ [[self menu] insertItem:[NSMenuItem separatorItem] atIndex:2];
+ [[self menu] insertItemWithTitle: NSLocalizedString ( @"Load YouTube.com page for this video", "Load YouTube page menu item" )
+ action: @selector (loadYouTubePage: ) keyEquivalent: @"" atIndex: 3];
+ [[[self menu] itemAtIndex: 3] setTarget: self];
+ }
}
}
if (_fromYouTube && [self _hasH264Version]) {
if ([[self menu] indexOfItemWithTarget:self andAction:@selector(loadH264:)] == -1) {
+ int QTMenuItemIndex, downloadMenuItemIndex;
+ if (! _embeddedYouTubeView) {
+ [[self menu] insertItem:[NSMenuItem separatorItem] atIndex:2];
+
+ QTMenuItemIndex = 4;
+ downloadMenuItemIndex = 5;
+ } else {
+ QTMenuItemIndex = 5;
+ downloadMenuItemIndex = 6;
+ }
+
[[self menu] insertItemWithTitle: NSLocalizedString( @"Load H.264", "Load H.264 context menu item" )
action: @selector( loadH264: ) keyEquivalent: @"" atIndex: 1];
[[self menu] insertItemWithTitle: NSLocalizedString( @"Play Fullscreen in QuickTime Player", "Open Fullscreen in QT Player menu item" )
- action: @selector( openFullscreenInQTPlayer: ) keyEquivalent: @"" atIndex: 5];
+ action: @selector( openFullscreenInQTPlayer: ) keyEquivalent: @"" atIndex: QTMenuItemIndex];
[[self menu] insertItemWithTitle: NSLocalizedString( @"Download H.264", "Download H.264 menu item" )
- action: @selector( downloadH264: ) keyEquivalent: @"" atIndex: 6];
+ action: @selector( downloadH264: ) keyEquivalent: @"" atIndex: downloadMenuItemIndex];
[[[self menu] itemAtIndex: 1] setTarget: self];
- [[[self menu] itemAtIndex: 5] setTarget: self];
- [[[self menu] itemAtIndex: 6] setTarget: self];
+ [[[self menu] itemAtIndex: QTMenuItemIndex] setTarget: self];
+ [[[self menu] itemAtIndex: downloadMenuItemIndex] setTarget: self];
}
}
}

0 comments on commit 97ec6c1

Please sign in to comment.