Bug 25287: Inappropriate menu items show as enabled when no windows are open. Patch by Stefan Hermes <stefanh@bluebottle.com>, r=mnyromyr, sr=neil.

This commit is contained in:
ajschult%verizon.net 2006-11-20 00:03:47 +00:00
Родитель 24f7580294
Коммит e9c7c1a8bc
3 изменённых файлов: 35 добавлений и 18 удалений

Просмотреть файл

@ -966,7 +966,7 @@ function BrowserHome(aEvent)
{
var tab;
var homePage = getHomePage();
var target = aEvent ? BookmarksUtils.getBrowserTargetFromEvent(aEvent) : "current";
var target = !gBrowser ? "window": !aEvent ? "current" : BookmarksUtils.getBrowserTargetFromEvent(aEvent);
if (homePage.length == 1) {
switch (target) {
@ -1013,7 +1013,7 @@ function addGroupmarkAs()
function updateGroupmarkCommand()
{
const disabled = gBrowser.browsers.length == 1;
const disabled = (!gBrowser || gBrowser.browsers.length == 1);
document.getElementById("Browser:AddGroupmarkAs")
.setAttribute("disabled", disabled);
}
@ -1228,7 +1228,7 @@ function BrowserSearchInternet()
if (searchEngineURI) {
var searchRoot = getSearchUrl("searchForm");
if (searchRoot) {
loadURI(searchRoot);
openTopWin(searchRoot);
return;
} else {
// Get a search URL and guess that the front page of the site has a search form.
@ -1238,7 +1238,7 @@ function BrowserSearchInternet()
if (searchURL) {
searchRoot = searchURL.match(/[a-z]+:\/\/[a-z.-]+/);
if (searchRoot) {
loadURI(searchRoot + "/");
openTopWin(searchRoot + "/");
return;
}
}
@ -1736,13 +1736,19 @@ function hiddenWindowStartup()
window.focus();
// Disable menus which are not appropriate
var disabledItems = ['cmd_close', 'Browser:SendPage', 'Browser:EditPage',
'Browser:SavePage', 'cmd_printSetup', /*'Browser:PrintPreview',*/
var disabledItems = ['cmd_newNavigatorTab', 'cmd_close', 'Browser:SendPage',
'Browser:EditPage', 'Browser:SavePage', 'cmd_printSetup',
'Browser:Print', 'canGoBack', 'canGoForward',
'Browser:Home', 'Browser:AddBookmark',
'Browser:AddBookmarkAs', 'Browser:AddGroupmarkAs',
'Browser:AddBookmark', 'Browser:AddBookmarkAs',
'cmd_undo', 'cmd_redo', 'cmd_cut', 'cmd_copy',
'cmd_paste', 'cmd_delete', 'cmd_selectAll',
'cmd_findTypeText', 'cmd_findTypeLinks', 'Browser:Find',
'Browser:FindAgain', 'Browser:FindPrev', 'menu_Toolbars',
'menuitem_reload', 'menu_UseStyleSheet', 'charsetMenu',
'View:PageSource', 'View:PageInfo', 'menu_translate',
'BlockCookies', 'UseCookiesDefault',
'AllowSessionCookies', 'AllowCookies', 'BlockImages',
'UseImagesDefault', 'AllowImages', 'AllowPopups',
'menu_textZoom', 'cmd_minimizeWindow', 'cmd_zoomWindow'];
var broadcaster;
@ -1762,8 +1768,11 @@ function hiddenWindowStartup()
.getService(Components.interfaces.nsIPrefService);
pref = prefService.getBranch(null);
// init global strings bundle
// init string bundles
gNavigatorBundle = document.getElementById("bundle_navigator");
gNavigatorRegionBundle = document.getElementById("bundle_navigator_region");
gBrandRegionBundle = document.getElementById("bundle_brand_region");
gBrandBundle = document.getElementById("bundle_brand");
// now load bookmarks after a delay
setTimeout(hiddenWindowLoadBookmarksCallback, 0);
@ -2088,7 +2097,7 @@ function applyTheme(themeName)
function getNewThemes()
{
loadURI(gBrandRegionBundle.getString("getNewThemesURL"));
openTopWin(gBrandRegionBundle.getString("getNewThemesURL"));
}
function URLBarFocusHandler(aEvent)
@ -2430,16 +2439,21 @@ function createShowPopupsMenu(parent) {
while (parent.lastChild && parent.lastChild.hasAttribute("uri"))
parent.removeChild(parent.lastChild);
var browser = getBrowser().selectedBrowser;
var browser = getBrowser();
if (browser.popupUrls.length == 0)
if (!browser)
return false;
for (var i = 0; i < browser.popupUrls.length; i++) {
var popupUrls = browser.selectedBrowser.popupUrls;
if (popupUrls.length == 0)
return false;
for (var i = 0; i < popupUrls.length; i++) {
var menuitem = document.createElement("menuitem");
menuitem.setAttribute("label", gNavigatorBundle.getFormattedString('popupMenuShow', [browser.popupUrls[i].spec]));
menuitem.setAttribute("uri", browser.popupUrls[i].spec);
menuitem.setAttribute("features", browser.popupFeatures[i]);
menuitem.setAttribute("label", gNavigatorBundle.getFormattedString('popupMenuShow', [popupUrls[i].spec]));
menuitem.setAttribute("uri", popupUrls[i].spec);
menuitem.setAttribute("features", browser.selectedBrowser.popupFeatures[i]);
parent.appendChild(menuitem);
}

Просмотреть файл

@ -411,13 +411,13 @@
command="View:FullScreen" hidden="true"/>
<menuseparator />
<menuitem label="&stopCmd.label;" accesskey="&stopCmd.accesskey;" id="menuitem-stop" disabled="true" oncommand="BrowserStop();" key="key_stop"/>
<menuitem accesskey="&reloadCmd.accesskey;" key="key_reload" label="&reloadCmd.label;" oncommand="BrowserReload();"/>
<menuitem id="menuitem_reload" accesskey="&reloadCmd.accesskey;" key="key_reload" label="&reloadCmd.label;" oncommand="BrowserReload();"/>
<menuseparator />
<!-- overlayed from viewZoomOverlay.xul -->
<menu id="menu_textZoom" observes="isImage"/>
<menu label="&useStyleSheetMenu.label;" accesskey="&useStyleSheetMenu.accesskey;" disabled="false" observes="isImage">
<menu id="menu_UseStyleSheet" label="&useStyleSheetMenu.label;" accesskey="&useStyleSheetMenu.accesskey;" disabled="false" observes="isImage">
<menupopup onpopupshowing="stylesheetFillPopup(this);"
oncommand="stylesheetSwitchAll(window.content, event.target.getAttribute('data')); setStyleDisabled(false);" type="radio">
<menuitem label="&useStyleSheetNone.label;" accesskey="&useStyleSheetNone.accesskey;" oncommand="setStyleDisabled(true); event.stopPropagation();" type="radio"/>

Просмотреть файл

@ -79,6 +79,9 @@
<stringbundleset id="stringbundleset">
<stringbundle id="bundle_navigator" src="chrome://navigator/locale/navigator.properties"/>
<stringbundle id="bundle_brand" src="chrome://branding/locale/brand.properties"/>
<stringbundle id="bundle_navigator_region" src="chrome://navigator-region/locale/region.properties"/>
<stringbundle id="bundle_brand_region" src="chrome://global-region/locale/region.properties"/>
</stringbundleset>
<!-- keys are appended from the overlay -->