Bug 618770 - Use tabs-on-bottom layout when the tab bar is hidden. r=dolske

--HG--
extra : rebase_source : 37cad5657cc79391dafecd05ac65c1005334cb98
This commit is contained in:
Dão Gottwald 2012-01-06 14:19:57 +01:00
parent e40c9e3dc0
commit d2a9f09193
5 changed files with 60 additions and 22 deletions

View File

@ -398,6 +398,7 @@ pref("browser.tabs.loadDivertedInBackground", false);
pref("browser.tabs.loadBookmarksInBackground", false);
pref("browser.tabs.tabClipWidth", 140);
pref("browser.tabs.animate", true);
pref("browser.tabs.onTop", true);
pref("browser.tabs.drawInTitlebar", true);
// Where to show tab close buttons:
@ -968,6 +969,7 @@ pref("services.sync.prefs.sync.browser.tabs.closeButtons", true);
pref("services.sync.prefs.sync.browser.tabs.loadInBackground", true);
pref("services.sync.prefs.sync.browser.tabs.warnOnClose", true);
pref("services.sync.prefs.sync.browser.tabs.warnOnOpen", true);
pref("services.sync.prefs.sync.browser.tabs.onTop", true);
pref("services.sync.prefs.sync.browser.urlbar.autocomplete.enabled", true);
pref("services.sync.prefs.sync.browser.urlbar.autoFill", true);
pref("services.sync.prefs.sync.browser.urlbar.default.behavior", true);

View File

@ -1364,7 +1364,7 @@ function BrowserStartup() {
allTabs.readPref();
TabsOnTop.syncCommand();
TabsOnTop.init();
BookmarksMenuButton.init();
@ -5278,27 +5278,44 @@ function setToolbarVisibility(toolbar, isVisible) {
}
var TabsOnTop = {
toggle: function () {
this.enabled = !this.enabled;
init: function TabsOnTop_init() {
this.syncUI();
Services.prefs.addObserver(this._prefName, this, false);
},
syncCommand: function () {
let enabled = this.enabled;
toggle: function () {
this.enabled = !Services.prefs.getBoolPref(this._prefName);
},
syncUI: function () {
let userEnabled = Services.prefs.getBoolPref(this._prefName);
let enabled = userEnabled && gBrowser.tabContainer.visible;
document.getElementById("cmd_ToggleTabsOnTop")
.setAttribute("checked", enabled);
.setAttribute("checked", userEnabled);
document.documentElement.setAttribute("tabsontop", enabled);
document.getElementById("navigator-toolbox").setAttribute("tabsontop", enabled);
document.getElementById("TabsToolbar").setAttribute("tabsontop", enabled);
gBrowser.tabContainer.setAttribute("tabsontop", enabled);
TabsInTitlebar.allowedBy("tabs-on-top", enabled);
},
get enabled () {
return gNavToolbox.getAttribute("tabsontop") == "true";
},
set enabled (val) {
gNavToolbox.setAttribute("tabsontop", !!val);
this.syncCommand();
set enabled (val) {
Services.prefs.setBoolPref(this._prefName, !!val);
return val;
}
},
observe: function (subject, topic, data) {
if (topic == "nsPref:changed")
this.syncUI();
},
_prefName: "browser.tabs.onTop"
}
var TabsInTitlebar = {

View File

@ -444,9 +444,7 @@
<toolbox id="navigator-toolbox"
defaultmode="icons" mode="icons"
iconsize="large"
tabsontop="true"
persist="tabsontop">
iconsize="large">
<!-- Menu -->
<toolbar type="menubar" id="toolbar-menubar" class="chromeclass-menubar" customizable="true"
defaultset="menubar-items"

View File

@ -2770,8 +2770,7 @@
Services.prefs.addObserver("browser.tabs.", this._prefObserver, false);
window.addEventListener("resize", this, false);
if (window.TabsInTitlebar)
TabsInTitlebar.allowedBy("tabs-visible", this.visible);
this._propagateVisibility();
]]>
</constructor>
@ -2839,17 +2838,30 @@
this._container.collapsed = !val;
document.getElementById("menu_closeWindow").hidden = !val;
document.getElementById("menu_close").setAttribute("label",
this.tabbrowser.mStringBundle.getString(val ? "tabs.closeTab" : "tabs.close"));
if (window.TabsInTitlebar)
TabsInTitlebar.allowedBy("tabs-visible", val);
this._propagateVisibility();
return val;
]]></setter>
</property>
<method name="_propagateVisibility">
<body><![CDATA[
let visible = this.visible;
document.getElementById("menu_closeWindow").hidden = !visible;
document.getElementById("menu_close").setAttribute("label",
this.tabbrowser.mStringBundle.getString(visible ? "tabs.closeTab" : "tabs.close"));
goSetCommandEnabled("cmd_ToggleTabsOnTop", visible);
if (window.TabsOnTop)
TabsOnTop.syncUI();
if (window.TabsInTitlebar)
TabsInTitlebar.allowedBy("tabs-visible", visible);
]]></body>
</method>
<method name="updateVisibility">
<body><![CDATA[
if (this.childNodes.length - this.tabbrowser._removingTabs.length == 1)

View File

@ -1100,7 +1100,7 @@ BrowserGlue.prototype = {
},
_migrateUI: function BG__migrateUI() {
const UI_VERSION = 5;
const UI_VERSION = 6;
const BROWSER_DOCURL = "chrome://browser/content/browser.xul#";
let currentUIVersion = 0;
try {
@ -1222,6 +1222,15 @@ BrowserGlue.prototype = {
}
}
if (currentUIVersion < 6) {
// convert tabsontop attribute to pref
let toolboxResource = this._rdf.GetResource(BROWSER_DOCURL + "navigator-toolbox");
let tabsOnTopResource = this._rdf.GetResource("tabsontop");
let tabsOnTopAttribute = this._getPersist(toolboxResource, tabsOnTopResource);
if (tabsOnTopAttribute)
Services.prefs.setBoolPref("browser.tabs.onTop", tabsOnTopAttribute == "true");
}
if (this._dirty)
this._dataSource.QueryInterface(Ci.nsIRDFRemoteDataSource).Flush();