Fix for tabbrowser not being localizable as well as fixes to expose Closing of tabs via CTRL+W and the top-level menus. r=jag, sr=jst

This commit is contained in:
hyatt%netscape.com 2001-10-26 09:26:03 +00:00
Родитель 3c5e9197e3
Коммит 65c1a51c18
13 изменённых файлов: 64 добавлений и 19 удалений

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

@ -895,7 +895,7 @@ function BrowserSetForcedDetector()
getBrowser().documentCharsetInfo.forcedDetector = true; getBrowser().documentCharsetInfo.forcedDetector = true;
} }
function BrowserClose() function BrowserCloseTabOrWindow()
{ {
var browser = getBrowser(); var browser = getBrowser();
if (browser && browser.localName == 'tabbrowser' && browser.mTabContainer.childNodes.length > 1) { if (browser && browser.localName == 'tabbrowser' && browser.mTabContainer.childNodes.length > 1) {
@ -904,6 +904,11 @@ function BrowserClose()
return; return;
} }
BrowserCloseWindow();
}
function BrowserCloseWindow()
{
// This code replicates stuff in Shutdown(). It is here because // This code replicates stuff in Shutdown(). It is here because
// window.screenX and window.screenY have real values. We need // window.screenX and window.screenY have real values. We need
// to fix this eventually but by replicating the code here, we // to fix this eventually but by replicating the code here, we

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

@ -61,6 +61,7 @@
<key id="key_editPage" key="&editPageCmd.commandkey;" command="Browser:EditPage" modifiers="accel"/> <key id="key_editPage" key="&editPageCmd.commandkey;" command="Browser:EditPage" modifiers="accel"/>
<key id="printKb" key="&printCmd.commandkey;" command="Browser:Print" modifiers="accel"/> <key id="printKb" key="&printCmd.commandkey;" command="Browser:Print" modifiers="accel"/>
<key id="key_close"/> <key id="key_close"/>
<key id="key_closeWindow"/>
<key id="key_quit"/> <key id="key_quit"/>
<!-- Edit Menu --> <!-- Edit Menu -->
@ -114,7 +115,8 @@
<command id="cmd_printSetup" oncommand="goPageSetup();"/> <command id="cmd_printSetup" oncommand="goPageSetup();"/>
<command id="Browser:Print" oncommand="BrowserPrint();"/> <command id="Browser:Print" oncommand="BrowserPrint();"/>
<command id="cmd_quit"/> <command id="cmd_quit"/>
<command id="cmd_close" oncommand="BrowserClose()"/> <command id="cmd_close" oncommand="BrowserCloseTabOrWindow()"/>
<command id="cmd_closeWindow" oncommand="BrowserCloseWindow()"/>
<!-- Edit Menu --> <!-- Edit Menu -->
<command id="cmd_undo"/> <command id="cmd_undo"/>
@ -182,6 +184,8 @@
<menuitem label="&openFileCmd.label;" accesskey="&openFileCmd.accesskey;" key="openFileKb" command="Browser:OpenFile"/> <menuitem label="&openFileCmd.label;" accesskey="&openFileCmd.accesskey;" key="openFileKb" command="Browser:OpenFile"/>
<menuseparator/> <menuseparator/>
<menuitem id="menu_close"/> <menuitem id="menu_close"/>
<menuitem id="menu_closeWindow" hidden="true" command="cmd_closeWindow" key="key_closeWindow" label="&closeWindow.label;"/>
<menuseparator id="menu_closeSeparator" hidden="true"/>
<menuitem label="&savePageCmd.label;" accesskey="&savePageCmd.accesskey;" key="key_savePage" command="Browser:SavePage"/> <menuitem label="&savePageCmd.label;" accesskey="&savePageCmd.accesskey;" key="key_savePage" command="Browser:SavePage"/>
<menuitem id="savepage" label="&saveFrameCmd.label;" accesskey="&saveFrameCmd.accesskey;" oncommand="savePage(gFocusedURL);" hidden="true"/> <menuitem id="savepage" label="&saveFrameCmd.label;" accesskey="&saveFrameCmd.accesskey;" oncommand="savePage(gFocusedURL);" hidden="true"/>
<menuseparator/> <menuseparator/>

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

@ -69,6 +69,8 @@
<!ENTITY translateMenu.accesskey "t"> <!ENTITY translateMenu.accesskey "t">
<!ENTITY translate.commandKey "t"> <!ENTITY translate.commandKey "t">
<!ENTITY closeWindow.label "Close Window">
<!-- I'd like all this to move to an overlay or something --> <!-- I'd like all this to move to an overlay or something -->
<!ENTITY bidiMenu.label "Bidi Options"> <!ENTITY bidiMenu.label "Bidi Options">
<!ENTITY directionBidiMenu.label "Default Direction"> <!ENTITY directionBidiMenu.label "Default Direction">

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

@ -11,6 +11,7 @@
<!-- close --> <!-- close -->
<menuitem id="menu_close" label="&closeCmd.label;" key="key_close" command="cmd_close"/> <menuitem id="menu_close" label="&closeCmd.label;" key="key_close" command="cmd_close"/>
<key id="key_close" key="&closeCmd.key;" command="cmd_close" modifiers="accel"/> <key id="key_close" key="&closeCmd.key;" command="cmd_close" modifiers="accel"/>
<key id="key_closeWindow" key="&closeCmd.key;" command="cmd_closeWindow" modifiers="accel,shift"/>
<!-- quit --> <!-- quit -->
<menupopup id="menu_FilePopup"> <menupopup id="menu_FilePopup">

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

@ -10,6 +10,7 @@
<!-- close --> <!-- close -->
<menuitem id="menu_close" label="&closeCmd.label;" key="key_close" accesskey="&closeCmd.accesskey;" command="cmd_close"/> <menuitem id="menu_close" label="&closeCmd.label;" key="key_close" accesskey="&closeCmd.accesskey;" command="cmd_close"/>
<key id="key_close" key="&closeCmd.key;" command="cmd_close" modifiers="accel"/> <key id="key_close" key="&closeCmd.key;" command="cmd_close" modifiers="accel"/>
<key id="key_closeWindow" key="&closeCmd.key;" command="cmd_closeWindow" modifiers="accel,shift"/>
<!-- quit --> <!-- quit -->
<menupopup id="menu_FilePopup"> <menupopup id="menu_FilePopup">

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

@ -11,6 +11,7 @@
<!-- close --> <!-- close -->
<menuitem id="menu_close" label="&closeCmd.label;" key="key_close" accesskey="&closeCmd.accesskey;" command="cmd_close"/> <menuitem id="menu_close" label="&closeCmd.label;" key="key_close" accesskey="&closeCmd.accesskey;" command="cmd_close"/>
<key id="key_close" key="&closeCmd.key;" command="cmd_close" modifiers="accel"/> <key id="key_close" key="&closeCmd.key;" command="cmd_close" modifiers="accel"/>
<key id="key_closeWindow" key="&closeCmd.key;" command="cmd_closeWindow" modifiers="accel,shift"/>
<!-- quit --> <!-- quit -->
<menupopup id="menu_FilePopup"> <menupopup id="menu_FilePopup">

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

@ -82,6 +82,7 @@ en-US.jar:
locale/en-US/global/brand.properties (resources/locale/en-US/brand.properties) locale/en-US/global/brand.properties (resources/locale/en-US/brand.properties)
locale/en-US/global/brand.dtd (resources/locale/en-US/brand.dtd) locale/en-US/global/brand.dtd (resources/locale/en-US/brand.dtd)
locale/en-US/global/tabbrowser.dtd (resources/locale/en-US/tabbrowser.dtd) locale/en-US/global/tabbrowser.dtd (resources/locale/en-US/tabbrowser.dtd)
locale/en-US/global/tabbrowser.properties (resources/locale/en-US/tabbrowser.properties)
locale/en-US/global/wizardManager.properties (resources/locale/en-US/wizardManager.properties) locale/en-US/global/wizardManager.properties (resources/locale/en-US/wizardManager.properties)
locale/en-US/global/wizardOverlay.dtd (resources/locale/en-US/wizardOverlay.dtd) locale/en-US/global/wizardOverlay.dtd (resources/locale/en-US/wizardOverlay.dtd)
locale/en-US/global/keys.properties (resources/locale/en-US/keys.properties) locale/en-US/global/keys.properties (resources/locale/en-US/keys.properties)

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

@ -49,6 +49,7 @@
</resources> </resources>
<content> <content>
<xul:stringbundle src="chrome://global/locale/tabbrowser.properties"/>
<xul:tabbox onselect="if (event.target.localName != 'tabpanels') return; this.parentNode.updateCurrentBrowser();"> <xul:tabbox onselect="if (event.target.localName != 'tabpanels') return; this.parentNode.updateCurrentBrowser();">
<xul:stack collapsed="true" tooltip="_child" context="_child"> <xul:stack collapsed="true" tooltip="_child" context="_child">
<xul:tooltip onpopupshowing="event.preventBubble(); if (document.tooltipNode.getAttribute('label')) { this.childNodes[0].value = document.tooltipNode.getAttribute('label'); return true; } return false;"> <xul:tooltip onpopupshowing="event.preventBubble(); if (document.tooltipNode.getAttribute('label')) { this.childNodes[0].value = document.tooltipNode.getAttribute('label'); return true; } return false;">
@ -68,7 +69,7 @@
onclick="if (event.button != 1 || event.target.localName != 'tab') return; this.parentNode.parentNode.parentNode.removeTab(event.target);" onclick="if (event.button != 1 || event.target.localName != 'tab') return; this.parentNode.parentNode.parentNode.removeTab(event.target);"
ondragover="nsDragAndDrop.dragOver(event, this.parentNode.parentNode.parentNode); event.stopPropagation();" ondragover="nsDragAndDrop.dragOver(event, this.parentNode.parentNode.parentNode); event.stopPropagation();"
ondragdrop="nsDragAndDrop.drop(event, this.parentNode.parentNode.parentNode); event.stopPropagation();"> ondragdrop="nsDragAndDrop.drop(event, this.parentNode.parentNode.parentNode); event.stopPropagation();">
<xul:tab maxwidth="250" width="0" minwidth="30" flex="100000" class="tabbrowser-tab" label="(Untitled)" crop="end"/> <xul:tab maxwidth="250" width="0" minwidth="30" flex="100000" class="tabbrowser-tab" label="&untitledTab;" crop="end"/>
</xul:tabs> </xul:tabs>
</xul:stack> </xul:stack>
<xul:tabpanels flex="1" style="margin:0px; padding:0px; border:0px;"> <xul:tabpanels flex="1" style="margin:0px; padding:0px; border:0px;">
@ -79,7 +80,7 @@
</content> </content>
<implementation> <implementation>
<field name="mTabBox"> <field name="mTabBox">
document.getAnonymousNodes(this)[0] document.getAnonymousNodes(this)[1]
</field> </field>
<field name="mStrip"> <field name="mStrip">
this.mTabBox.firstChild this.mTabBox.firstChild
@ -90,6 +91,9 @@
<field name="mPanelContainer"> <field name="mPanelContainer">
this.mTabBox.childNodes[1] this.mTabBox.childNodes[1]
</field> </field>
<field name="mStringBundle">
document.getAnonymousNodes(this)[0]
</field>
<field name="mCurrentTab"> <field name="mCurrentTab">
null null
</field> </field>
@ -151,7 +155,7 @@
if (!this.mBlank && aStateFlags & nsIWebProgressListener.STATE_START && if (!this.mBlank && aStateFlags & nsIWebProgressListener.STATE_START &&
aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK) { aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK) {
this.mTab.setAttribute("busy", "true"); this.mTab.setAttribute("busy", "true");
this.mTab.label = "Loading..."; this.mTab.label = this.mTabBrowser.mStringBundle.getString("tabs.loading");
if (this.mTabBrowser.mCurrentTab == this.mTab) if (this.mTabBrowser.mCurrentTab == this.mTab)
this.mTabBrowser.mIsBusy = true; this.mTabBrowser.mIsBusy = true;
@ -162,8 +166,8 @@
this.mBlank = false; this.mBlank = false;
else { else {
this.mTab.removeAttribute("busy"); this.mTab.removeAttribute("busy");
if (this.mTab.label == "Loading...") if (this.mTab.label == this.mTabBrowser.mStringBundle.getString("tabs.loading"))
this.mTab.label = "(Untitled)"; this.mTab.label = this.mTabBrowser.mStringBundle.getString("tabs.untitled")
if (this.mTabBrowser.mCurrentTab == this.mTab) if (this.mTabBrowser.mCurrentTab == this.mTab)
this.mTabBrowser.mIsBusy = false; this.mTabBrowser.mIsBusy = false;
@ -331,6 +335,27 @@
</body> </body>
</method> </method>
<method name="setStripVisibilityTo">
<parameter name="aShow"/>
<body>
<![CDATA[
this.mStrip.collapsed = !aShow;
if (aShow) {
// XXXdwh temporary unclean dependency on specific menu items in navigator.xul
document.getElementById("menu_closeWindow").hidden = false;
document.getElementById("menu_closeSeparator").hidden = false;
document.getElementById("menu_close").setAttribute("label", this.mStringBundle.getString("tabs.closeTab"));
}
else {
// XXXdwh temporary unclean dependency on specific menu items in navigator.xul
document.getElementById("menu_closeWindow").hidden = true;
document.getElementById("menu_closeSeparator").hidden = true;
document.getElementById("menu_close").setAttribute("label", this.mStringBundle.getString("tabs.close"));
}
]]>
</body>
</method>
<method name="addTab"> <method name="addTab">
<parameter name="aURI"/> <parameter name="aURI"/>
<body> <body>
@ -366,7 +391,7 @@
"tab"); "tab");
if (blank) if (blank)
t.setAttribute("label", "(Untitled)"); t.setAttribute("label", this.mStringBundle.getString("tabs.untitled"));
else else
t.setAttribute("label", aURI); t.setAttribute("label", aURI);
@ -387,7 +412,7 @@
b.addEventListener("DOMTitleChanged", this.onTitleChanged, false); b.addEventListener("DOMTitleChanged", this.onTitleChanged, false);
if (this.mStrip.collapsed) if (this.mStrip.collapsed)
this.mStrip.collapsed = false; this.setStripVisibilityTo(true);
// wire up a progress listener for the new browser object. // wire up a progress listener for the new browser object.
var position = this.mTabContainer.childNodes.length-1; var position = this.mTabContainer.childNodes.length-1;
@ -449,7 +474,7 @@
var pref = Components.classes['@mozilla.org/preferences;1'].getService(Components.interfaces.nsIPrefService).getBranch(null); var pref = Components.classes['@mozilla.org/preferences;1'].getService(Components.interfaces.nsIPrefService).getBranch(null);
var autohide = pref.getBoolPref("browser.tabs.autoHide"); var autohide = pref.getBoolPref("browser.tabs.autoHide");
if (autohide) if (autohide)
this.mStrip.collapsed = true; // Go ahead and collapse, since we're going back to 1 tab. this.setStripVisibilityTo(false);
} }
var index = -1; var index = -1;
@ -533,7 +558,8 @@
var pref = Components.classes['@mozilla.org/preferences;1'].getService(Components.interfaces.nsIPrefService).getBranch(null); var pref = Components.classes['@mozilla.org/preferences;1'].getService(Components.interfaces.nsIPrefService).getBranch(null);
var autohide = pref.getBoolPref("browser.tabs.autoHide"); var autohide = pref.getBoolPref("browser.tabs.autoHide");
if (!autohide) { if (!autohide) {
this.mStrip.collapsed = false; this.setStripVisibilityTo(true);
this.mTabbedMode = true; this.mTabbedMode = true;
this.mCurrentBrowser.addEventListener("DOMTitleChanged", this.onTitleChanged, false); this.mCurrentBrowser.addEventListener("DOMTitleChanged", this.onTitleChanged, false);

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

@ -10,6 +10,7 @@
<!-- close --> <!-- close -->
<menuitem id="menu_close" label="&closeCmd.label;" key="key_close" command="cmd_close"/> <menuitem id="menu_close" label="&closeCmd.label;" key="key_close" command="cmd_close"/>
<key id="key_close" key="&closeCmd.key;" command="cmd_close" modifiers="accel"/> <key id="key_close" key="&closeCmd.key;" command="cmd_close" modifiers="accel"/>
<key id="key_closeWindow" key="&closeCmd.key;" command="cmd_closeWindow" modifiers="accel,shift"/>
<menupopup id="menu_FilePopup"> <menupopup id="menu_FilePopup">
<!-- Page setup --> <!-- Page setup -->

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

@ -11,6 +11,7 @@
<!-- close --> <!-- close -->
<menuitem id="menu_close" label="&closeCmd.label;" key="key_close" accesskey="&closeCmd.accesskey;" command="cmd_close"/> <menuitem id="menu_close" label="&closeCmd.label;" key="key_close" accesskey="&closeCmd.accesskey;" command="cmd_close"/>
<key id="key_close" key="&closeCmd.key;" command="cmd_close" modifiers="accel"/> <key id="key_close" key="&closeCmd.key;" command="cmd_close" modifiers="accel"/>
<key id="key_closeWindow" key="&closeCmd.key;" command="cmd_closeWindow" modifiers="accel,shift"/>
<!-- quit --> <!-- quit -->
<menupopup id="menu_FilePopup"> <menupopup id="menu_FilePopup">

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

@ -10,6 +10,7 @@
<!-- close --> <!-- close -->
<menuitem id="menu_close" label="&closeCmd.label;" key="key_close" accesskey="&closeCmd.accesskey;" command="cmd_close"/> <menuitem id="menu_close" label="&closeCmd.label;" key="key_close" accesskey="&closeCmd.accesskey;" command="cmd_close"/>
<key id="key_close" key="&closeCmd.key;" command="cmd_close" modifiers="accel"/> <key id="key_close" key="&closeCmd.key;" command="cmd_close" modifiers="accel"/>
<key id="key_closeWindow" key="&closeCmd.key;" command="cmd_closeWindow" modifiers="accel,shift"/>
<!-- quit --> <!-- quit -->
<menupopup id="menu_FilePopup"> <menupopup id="menu_FilePopup">

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

@ -11,6 +11,7 @@
<!-- close --> <!-- close -->
<menuitem id="menu_close" label="&closeCmd.label;" key="key_close" accesskey="&closeCmd.accesskey;" command="cmd_close"/> <menuitem id="menu_close" label="&closeCmd.label;" key="key_close" accesskey="&closeCmd.accesskey;" command="cmd_close"/>
<key id="key_close" key="&closeCmd.key;" command="cmd_close" modifiers="accel"/> <key id="key_close" key="&closeCmd.key;" command="cmd_close" modifiers="accel"/>
<key id="key_closeWindow" key="&closeCmd.key;" command="cmd_closeWindow" modifiers="accel,shift"/>
<!-- quit --> <!-- quit -->
<menupopup id="menu_FilePopup"> <menupopup id="menu_FilePopup">

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

@ -1,4 +1,4 @@
<!ENTITY untitledTab "(Untitled)">
<!ENTITY newTab.label "New Tab"> <!ENTITY newTab.label "New Tab">
<!ENTITY newTab.accesskey "n"> <!ENTITY newTab.accesskey "n">
<!ENTITY closeTab.label "Close Tab"> <!ENTITY closeTab.label "Close Tab">