mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-21 09:49:14 +00:00
Bug 150099: Hide the tab bar when clicking the close box, add show/hide menuitem for tabbar. r=bryner, sr=hewitt
This commit is contained in:
parent
644f05ed78
commit
5abd4b6906
@ -175,6 +175,7 @@ pref("browser.forms.submit.backwards_compatible", true);
|
||||
|
||||
// Tab browser preferences.
|
||||
pref("browser.tabs.autoHide", true);
|
||||
pref("browser.tabs.forceHide", false);
|
||||
pref("browser.tabs.loadInBackground", false);
|
||||
pref("browser.tabs.opentabfor.middleclick", false);
|
||||
pref("browser.tabs.opentabfor.urlbar", false);
|
||||
|
@ -104,8 +104,10 @@ const gTabStripPrefListener =
|
||||
return;
|
||||
|
||||
var stripVisibility = !pref.getBoolPref(prefName);
|
||||
if (gBrowser.mTabContainer.childNodes.length == 1)
|
||||
if (gBrowser.mTabContainer.childNodes.length == 1) {
|
||||
gBrowser.setStripVisibilityTo(stripVisibility);
|
||||
pref.setBoolPref("browser.tabs.forceHide", false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -1703,29 +1705,45 @@ function updateComponentBarBroadcaster()
|
||||
|
||||
function updateToolbarStates(toolbarMenuElt)
|
||||
{
|
||||
if (gHaveUpdatedToolbarState) {
|
||||
updateComponentBarBroadcaster();
|
||||
return;
|
||||
}
|
||||
var mainWindow = document.getElementById("main-window");
|
||||
if (mainWindow.hasAttribute("chromehidden")) {
|
||||
gHaveUpdatedToolbarState = true;
|
||||
var i;
|
||||
for (i = 0; i < toolbarMenuElt.childNodes.length; ++i)
|
||||
document.getElementById(toolbarMenuElt.childNodes[i].getAttribute("observes")).removeAttribute("checked");
|
||||
var toolbars = document.getElementsByTagName("toolbar");
|
||||
for (i = 0; i < toolbars.length; ++i) {
|
||||
if (toolbars[i].getAttribute("class").indexOf("chromeclass") != -1)
|
||||
toolbars[i].setAttribute("hidden", "true");
|
||||
if (!gHaveUpdatedToolbarState) {
|
||||
var mainWindow = document.getElementById("main-window");
|
||||
if (mainWindow.hasAttribute("chromehidden")) {
|
||||
gHaveUpdatedToolbarState = true;
|
||||
var i;
|
||||
for (i = 0; i < toolbarMenuElt.childNodes.length; ++i)
|
||||
document.getElementById(toolbarMenuElt.childNodes[i].getAttribute("observes")).removeAttribute("checked");
|
||||
var toolbars = document.getElementsByTagName("toolbar");
|
||||
for (i = 0; i < toolbars.length; ++i) {
|
||||
if (toolbars[i].getAttribute("class").indexOf("chromeclass") != -1)
|
||||
toolbars[i].setAttribute("hidden", "true");
|
||||
}
|
||||
var statusbars = document.getElementsByTagName("statusbar");
|
||||
for (i = 0; i < statusbars.length; ++i) {
|
||||
if (statusbars[i].getAttribute("class").indexOf("chromeclass") != -1)
|
||||
statusbars[i].setAttribute("hidden", "true");
|
||||
}
|
||||
mainWindow.removeAttribute("chromehidden");
|
||||
}
|
||||
var statusbars = document.getElementsByTagName("statusbar");
|
||||
for (i = 0; i < statusbars.length; ++i) {
|
||||
if (statusbars[i].getAttribute("class").indexOf("chromeclass") != -1)
|
||||
statusbars[i].setAttribute("hidden", "true");
|
||||
}
|
||||
mainWindow.removeAttribute("chromehidden");
|
||||
}
|
||||
updateComponentBarBroadcaster();
|
||||
|
||||
const tabbarMenuItem = document.getElementById("menuitem_showhide_tabbar");
|
||||
// Make show/hide menu item reflect current state
|
||||
const visibility = gBrowser.getStripVisibility();
|
||||
tabbarMenuItem.setAttribute("checked", visibility);
|
||||
|
||||
// Don't allow the tab bar to be shown/hidden when more than one tab is open
|
||||
// or when we have 1 tab and the autoHide pref is set
|
||||
const disabled = gBrowser.browsers.length > 1 ||
|
||||
pref.getBoolPref("browser.tabs.autoHide");
|
||||
tabbarMenuItem.setAttribute("disabled", disabled);
|
||||
}
|
||||
|
||||
function showHideTabbar()
|
||||
{
|
||||
const visibility = gBrowser.getStripVisibility();
|
||||
pref.setBoolPref("browser.tabs.forceHide", visibility);
|
||||
gBrowser.setStripVisibilityTo(!visibility);
|
||||
}
|
||||
|
||||
// Fill in tooltips for personal toolbar
|
||||
|
@ -237,6 +237,7 @@
|
||||
<menupopup id="view_toolbars_popup" onpopupshowing="updateToolbarStates(this);">
|
||||
<menuitem label="&navbarCmd.label;" accesskey="&navbarCmd.accesskey;" class="menuitem-iconic" type="checkbox" observes="cmd_viewnavbar" />
|
||||
<menuitem label="&personalbarCmd.label;" accesskey="&personalbarCmd.accesskey;" class="menuitem-iconic" type="checkbox" observes="cmd_viewpersonaltoolbar" />
|
||||
<menuitem id="menuitem_showhide_tabbar" label="&tabbarCmd.label;" accesskey="&tabbarCmd.accesskey;" class="menuitem-iconic" type="checkbox" oncommand="showHideTabbar();" checked="true"/>
|
||||
<menuitem label="&taskbarCmd.label;" accesskey="&taskbarCmd.accesskey;" class="menuitem-iconic" type="checkbox" observes="cmd_viewtaskbar" />
|
||||
<menuitem label="&componentbarCmd.label;" accesskey="&componentbarCmd.accesskey;" class="menuitem-iconic" type="checkbox" observes="cmd_viewcomponentbar"/>
|
||||
</menupopup>
|
||||
|
@ -49,6 +49,8 @@
|
||||
<!ENTITY navbarCmd.accesskey "N">
|
||||
<!ENTITY personalbarCmd.label "Personal Toolbar">
|
||||
<!ENTITY personalbarCmd.accesskey "p">
|
||||
<!ENTITY tabbarCmd.label "Tab Bar">
|
||||
<!ENTITY tabbarCmd.accesskey "T">
|
||||
<!ENTITY taskbarCmd.label "Status Bar">
|
||||
<!ENTITY taskbarCmd.accesskey "S">
|
||||
<!ENTITY componentbarCmd.label "Component Bar">
|
||||
|
@ -78,7 +78,7 @@
|
||||
tabbrowser.removeAllTabsBut(tabbrowser.mContextTab);"/>
|
||||
</xul:menupopup>
|
||||
|
||||
<xul:tabs class="tabbrowser-tabs" closebutton="true" disableclose="true" flex="1"
|
||||
<xul:tabs class="tabbrowser-tabs" closebutton="true" flex="1"
|
||||
tooltiptextnew="&newTabButton.tooltip;"
|
||||
onclick="if (event.button != 1 || event.target.localName != 'tab') return;
|
||||
this.parentNode.parentNode.parentNode.removeTab(event.target);"
|
||||
@ -590,9 +590,6 @@
|
||||
<parameter name="aReferrerURI"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
// Enable the close box
|
||||
this.mTabContainer.removeAttribute("disableclose");
|
||||
|
||||
var blank = (aURI == "about:blank");
|
||||
|
||||
if (!this.mTabbedMode)
|
||||
@ -627,6 +624,8 @@
|
||||
|
||||
if (this.mStrip.collapsed)
|
||||
this.setStripVisibilityTo(true);
|
||||
|
||||
this.mPrefs.setBoolPref("browser.tabs.forceHide", false);
|
||||
|
||||
// wire up a progress listener for the new browser object.
|
||||
var position = this.mTabContainer.childNodes.length-1;
|
||||
@ -682,16 +681,17 @@
|
||||
aTab = this.mCurrentTab;
|
||||
|
||||
var l = this.mTabContainer.childNodes.length;
|
||||
if (l == 1)
|
||||
return; // Don't allow the last tab to close.
|
||||
if (l == 1) {
|
||||
// hide the tab bar
|
||||
this.mPrefs.setBoolPref("browser.tabs.forceHide", true);
|
||||
this.setStripVisibilityTo(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (l == 2) {
|
||||
if (l == 2) {
|
||||
var autohide = this.mPrefs.getBoolPref("browser.tabs.autoHide");
|
||||
if (autohide)
|
||||
this.setStripVisibilityTo(false);
|
||||
else
|
||||
// Disable the close box
|
||||
this.mTabContainer.setAttribute("disableclose", "true");
|
||||
}
|
||||
|
||||
var index = -1;
|
||||
@ -776,8 +776,9 @@
|
||||
<![CDATA[
|
||||
if (!this.mProgressListeners) {
|
||||
this.mProgressListeners = new Array();
|
||||
var autohide = this.mPrefs.getBoolPref("browser.tabs.autoHide");
|
||||
if (!autohide) {
|
||||
const autoHide = this.mPrefs.getBoolPref("browser.tabs.autoHide");
|
||||
const forceHide = this.mPrefs.getBoolPref("browser.tabs.forceHide");
|
||||
if (!autoHide && !forceHide) {
|
||||
this.setStripVisibilityTo(true);
|
||||
|
||||
this.mTabbedMode = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user