From 9457540d4484ff0eb60dc8f4eafe10775522f4e5 Mon Sep 17 00:00:00 2001 From: "stridey%gmail.com" Date: Fri, 27 Oct 2006 23:27:55 +0000 Subject: [PATCH] Camino only - Bug 342237: Disable view-source contextual menu item when viewing binary content. Patch by smorgan r/sr=josh --- camino/src/browser/BrowserWindowController.mm | 7 +++++++ camino/src/extensions/NSMenu+Utils.m | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/camino/src/browser/BrowserWindowController.mm b/camino/src/browser/BrowserWindowController.mm index ee42f06f1fc..64bd3fc0b18 100644 --- a/camino/src/browser/BrowserWindowController.mm +++ b/camino/src/browser/BrowserWindowController.mm @@ -3855,6 +3855,13 @@ enum BWCOpenDest { // our only copy of the menu NSMenu* result = [[menuPrototype copy] autorelease]; + // validate View Page/Frame Source + BrowserWrapper* browser = [self getBrowserWrapper]; + if ([browser isInternalURI] || ![[browser getBrowserView] isTextBasedContent]) { + [[result itemWithTarget:self andAction:@selector(viewPageSource:)] setEnabled:NO]; + [[result itemWithTarget:self andAction:@selector(viewSource:)] setEnabled:NO]; + } + if (showSpellingItems) showSpellingItems = [self prepareSpellingSuggestionMenu:result tag:kSpellingRelatedItemsTag]; diff --git a/camino/src/extensions/NSMenu+Utils.m b/camino/src/extensions/NSMenu+Utils.m index 40275d2af99..f72ef485d22 100644 --- a/camino/src/extensions/NSMenu+Utils.m +++ b/camino/src/extensions/NSMenu+Utils.m @@ -151,7 +151,7 @@ static OSStatus MenuEventHandler(EventHandlerCallRef inHandlerCallRef, EventRef - (id)itemWithTarget:(id)anObject andAction:(SEL)actionSelector { int itemIndex = [self indexOfItemWithTarget:anObject andAction:actionSelector]; - return [self itemAtIndex:itemIndex]; + return (itemIndex == -1) ? nil : [self itemAtIndex:itemIndex]; } - (void)removeItemsAfterItem:(id)inItem