Bug 273217 - [Mac] disable inappropriate menuitems when no window is open; this also fixes the follwoing commands which didn't wotk when no window was open: bug 229040 - bookmarks menu, bug 227525 - file->open file, bug 249717 - go->home. r=mconnor

This commit is contained in:
mozilla.mano%sent.com 2005-01-24 23:40:03 +00:00
parent 14d73e6a25
commit 7bf62ad8d7
4 changed files with 80 additions and 11 deletions

View File

@ -53,7 +53,7 @@
<menuitem id="menu_saveFrame" label="&saveFrameCmd.label;" accesskey="&saveFrameCmd.accesskey;" oncommand="saveFrameDocument();" hidden="true"/>
<menuitem id="menu_sendLink" label="&sendPageCmd.label;" accesskey="&sendPageCmd.accesskey;" command="Browser:SendLink"/>
<menuseparator/>
<menuitem label="&printSetupCmd.label;" accesskey="&printSetupCmd.accesskey;" oncommand="PrintUtils.showPageSetup();"/>
<menuitem label="&printSetupCmd.label;" accesskey="&printSetupCmd.accesskey;" command="cmd_pageSetup"/>
#ifndef XP_MACOSX
<menuitem label="&printPreviewCmd.label;" accesskey="&printPreviewCmd.accesskey;" oncommand="PrintUtils.printPreview(onEnterPrintPreview, onExitPrintPreview);"/>
#endif
@ -134,7 +134,7 @@
<menu label="&viewMenu.label;" accesskey="&viewMenu.accesskey;">
<menupopup id="menu_viewPopup">
<menu label="&viewToolbarsMenu.label;" accesskey="&viewToolbarsMenu.accesskey;"
<menu id="viewToolbarsMenu" label="&viewToolbarsMenu.label;" accesskey="&viewToolbarsMenu.accesskey;"
onpopupshowing="onViewToolbarsPopupShowing(event);">
<menupopup onpopupshowing="updateToolbarStates(this);">
<menuseparator/>
@ -142,8 +142,9 @@
command="cmd_CustomizeToolbars"/>
</menupopup>
</menu>
<menuitem id="toggle_taskbar" label="&taskbarCmd.label;" accesskey="&taskbarCmd.accesskey;" type="checkbox" oncommand="goToggleToolbar('status-bar','toggle_taskbar');" checked="true" />
<menu label="&viewSidebarMenu.label;"
<menuitem id="toggle_taskbar" label="&taskbarCmd.label;" accesskey="&taskbarCmd.accesskey;" type="checkbox" command="cmd_toggleTaskbar" checked="true" />
<menu id="viewSidebarMenuMenu"
label="&viewSidebarMenu.label;"
accesskey="&viewSidebarMenu.accesskey;">
<menupopup id="viewSidebarMenu">
<menuitem key="viewBookmarksSidebarKb" observes="viewBookmarksSidebar" accesskey="&bookmarksSidebarCmd.accesskey;"/>
@ -152,9 +153,9 @@
</menu>
<menuseparator/>
<menuitem label="&stopCmd.label;" accesskey="&stopCmd.accesskey;" command="Browser:Stop" key="key_stop"/>
<menuitem accesskey="&reloadCmd.accesskey;" key="key_reload" label="&reloadCmd.label;" oncommand="BrowserReload();"/>
<menuitem accesskey="&reloadCmd.accesskey;" key="key_reload" label="&reloadCmd.label;" command="Browser:Reload"/>
<menuseparator/>
<menu label="&textSize.label;" accesskey="&textSize.accesskey;">
<menu id="viewTextZoomMenu" label="&textSize.label;" accesskey="&textSize.accesskey;">
<menupopup>
<menuitem key="key_textZoomEnlarge" label="&textZoomEnlargeCmd.label;" accesskey="&textZoomEnlargeCmd.accesskey;"
command="cmd_textZoomEnlarge"/>
@ -165,7 +166,7 @@
command="cmd_textZoomReset"/>
</menupopup>
</menu>
<menu label="&pageStyleMenu.label;" accesskey="&pageStyleMenu.accesskey;">
<menu id="pageStyleMenu" label="&pageStyleMenu.label;" accesskey="&pageStyleMenu.accesskey;">
<menupopup onpopupshowing="stylesheetFillPopup(this);"
oncommand="stylesheetSwitchAll(window._content, event.target.getAttribute('data')); setStyleDisabled(false);">
<menuitem label="&pageStyleNoStyle.label;" accesskey="&pageStyleNoStyle.accesskey;"
@ -174,9 +175,14 @@
<menuseparator/>
</menupopup>
</menu>
<menu label="&charsetMenu.label;" accesskey="&charsetMenu.accesskey;"
datasources="rdf:charset-menu" ref="NC:BrowserCharsetMenuRoot"
oncommand="MultiplexHandler(event)" onpopupshowing="CreateMenu('browser');UpdateMenus(event)" onpopupshown="CreateMenu('more-menu');">
<menu id="charsetMenu"
label="&charsetMenu.label;"
accesskey="&charsetMenu.accesskey;"
datasources="rdf:charset-menu"
ref="NC:BrowserCharsetMenuRoot"
oncommand="MultiplexHandler(event)"
onpopupshowing="CreateMenu('browser');UpdateMenus(event)"
onpopupshown="CreateMenu('more-menu');">
<template>
<rule rdf:type="http://home.netscape.com/NC-rdf#BookmarkSeparator">
<menupopup>

View File

@ -94,9 +94,11 @@
<command id="Browser:ReadNews" oncommand="MailIntegration.readNews();"/>
#endif
<command id="cmd_pageSetup" oncommand="PrintUtils.showPageSetup();"/>
<command id="cmd_print" oncommand="PrintUtils.print();"/>
<command id="cmd_close" oncommand="BrowserCloseTabOrWindow()"/>
<command id="cmd_closeWindow" oncommand="BrowserTryToCloseWindow()"/>
<command id="cmd_toggleTaskbar" oncommand="goToggleToolbar('status-bar','toggle_taskbar');"/>
<command id="cmd_CustomizeToolbars" oncommand="BrowserCustomizeToolbar()"/>
<command id="cmd_copyLink"
@ -145,6 +147,7 @@
<command id="Browser:Back" oncommand="BrowserBack();" disabled="true"/>
<command id="Browser:Forward" oncommand="BrowserForward();" disabled="true"/>
<command id="Browser:Stop" oncommand="BrowserStop();" disabled="true"/>
<command id="Browser:Reload" oncommand="BrowserReload();"/>
<command id="cmd_textZoomReduce" oncommand="ZoomManager.prototype.getInstance().reduce();"/>
<command id="cmd_textZoomEnlarge" oncommand="ZoomManager.prototype.getInstance().enlarge();"/>
<command id="cmd_textZoomReset" oncommand="ZoomManager.prototype.getInstance().reset();"/>

View File

@ -959,6 +959,56 @@ function Shutdown()
appCore.close();
}
#ifdef XP_MACOSX
// The following functions should be used by both hiddenWindow.xul
// and any other windows which only have menus on Mac OS X
function nonBrowserWindowStartup()
{
// Disable inappropriate commands / submenus
var disabledItems = ['cmd_newNavigatorTab', 'cmd_close', 'Browser:SavePage', 'Browser:SendLink',
'cmd_pageSetup', 'cmd_print', 'cmd_find', 'cmd_findAgain', 'viewToolbarsMenu',
'cmd_toggleTaskbar', 'viewSidebarMenuMenu', 'Browser:Reload', 'viewTextZoomMenu',
'pageStyleMenu', 'charsetMenu', 'View:PageSource', 'View:FullScreen',
'viewHistorySidebar', 'Browser:AddBookmarkAs', 'Tools:Search', 'View:PageInfo'];
var element;
for (var id in disabledItems)
{
element = document.getElementById(disabledItems[id]);
if (element)
element.setAttribute("disabled", "true");
}
// If no windows are active (i.e. we're the hidden window), disable the minimize
// and zoom menu commands as well
if (window.location.href == "chrome://browser/content/hiddenWindow.xul")
{
element = document.getElementById("minimizeWindow");
element.setAttribute("disabled", "true");
element = document.getElementById("zoomWindow");
element.setAttribute("disabled", "true");
// also hide the window-list separator
element = document.getElementById("sep-window-list");
element.setAttribute("hidden", "true");
}
gNavigatorBundle = document.getElementById("bundle_browser");
setTimeout(nonBrowserWindowDelayedStartup, 0);
}
function nonBrowserWindowDelayedStartup()
{
// loads the services
initServices();
initBMService();
// init global pref service
gPrefService = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
}
#endif
function FormFillPrefListener()
{
gBrowser.attachFormFill();
@ -1228,6 +1278,14 @@ function BrowserHomeClick(aEvent)
function loadOneOrMoreURIs(aURIString)
{
#ifdef XP_MACOSX
// we're not a browser window, pass the URI string to a new browser window
if (window.location.href != getBrowserURL())
{
newWindow = openDialog(getBrowserURL(), "_blank", "all,dialog=no", aURIString);
return;
}
#endif
var urls = aURIString.split("|");
loadURI(urls[0]);
for (var i = 1; i < urls.length; ++i) {

View File

@ -21,6 +21,7 @@
#
# Contributor(s):
# David Hyatt <hyatt@mozilla.org> (Original Author)
# Asaf Romano <mozilla.mano@sent.com>
#
#ifdef XP_MACOSX
@ -28,7 +29,8 @@
<window id="main-window"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="nonBrowserWindowStartup();">
</window>