[Pkg-mozext-commits] [tabmixplus] 100/123: Add tabs-closebutton to TabsToolbar in tabmix.xul overlay. move the function to restore its position to Tabmix.navToolbox
David Prévot
taffit at moszumanska.debian.org
Wed Sep 17 21:16:31 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository tabmixplus.
commit 6cbbdf049445d27e48ada336897fa526c8430dd6
Author: onemen <tabmix.onemen at gmail.com>
Date: Sat Sep 13 11:48:02 2014 +0300
Add tabs-closebutton to TabsToolbar in tabmix.xul overlay. move the function to restore its position to Tabmix.navToolbox
---
chrome.manifest | 1 +
chrome/content/minit/minit.js | 45 ++++++++++++++++++++++++++++++++--
chrome/content/overlay/tabstoolbar.xul | 21 ++++++++++++++++
chrome/content/tab/tab.js | 39 +++--------------------------
chrome/content/tabmix.js | 1 -
5 files changed, 68 insertions(+), 39 deletions(-)
diff --git a/chrome.manifest b/chrome.manifest
index d14a739..32fba82 100644
--- a/chrome.manifest
+++ b/chrome.manifest
@@ -39,6 +39,7 @@ locale tabmixplus zh-TW chrome/locale/zh-TW/
overlay chrome://browser/content/browser.xul chrome://tabmixplus/content/tabmix.xul
+overlay chrome://browser/content/browser.xul chrome://tabmixplus/content/overlay/tabstoolbar.xul appversion>=31.0b1
overlay about:preferences chrome://tabmixplus/content/preferences/overlay/incontentPreferences.xul os=WINNT
overlay about:preferences chrome://tabmixplus/content/preferences/overlay/incontentPreferences.xul os=Darwin
diff --git a/chrome/content/minit/minit.js b/chrome/content/minit/minit.js
index 68a45ab..a41133c 100644
--- a/chrome/content/minit/minit.js
+++ b/chrome/content/minit/minit.js
@@ -949,6 +949,16 @@ Tabmix.navToolbox = {
this.cleanCurrentset();
return;
}
+ if (Tabmix.isVersion(310)) {
+ // remove tabmix-tabs-closebutton when its position is immediately after
+ // tabmixScrollBox and save its position in preference for future use.
+ let boxPosition = Tabmix.getPlacement("tabmixScrollBox");
+ let buttonPosition = Tabmix.getPlacement("tabmix-tabs-closebutton");
+ if (buttonPosition == boxPosition + 1) {
+ Tabmix.prefs.setIntPref("tabs-closeButton-position", buttonPosition);
+ CustomizableUI.removeWidgetFromArea("tabmix-tabs-closebutton");
+ }
+ }
CustomizableUI.removeWidgetFromArea("tabmixScrollBox");
},
@@ -1197,8 +1207,6 @@ Tabmix.navToolbox = {
toolbarButtons: function TMP_navToolbox_toolbarButtons() {
gTMPprefObserver.showReloadEveryOnReloadButton();
-
- gTMPprefObserver.changeNewTabButtonSide(Tabmix.prefs.getIntPref("newTabButton.position"));
},
initializeAlltabsPopup: function TMP_navToolbox_initializeAlltabsPopup() {
@@ -1219,7 +1227,17 @@ Tabmix.navToolbox = {
},
tabStripAreaChanged: function() {
+ /**
+ * we need to position three elements in TabsToolbar :
+ * tabmixScrollBox, new-tab-button, and tabmix-tabs-closebutton.
+ * we resotre tabmixScrollBox positoin first since its postion is fixed,
+ * to be on the safe side we check tabmixScrollBox positoin again after we
+ * restore tabmix-tabs-closebutton and new-tab-button position.
+ */
this.setScrollButtons();
+ this.setCloseButtonPosition();
+ gTMPprefObserver.changeNewTabButtonSide(Tabmix.prefs.getIntPref("newTabButton.position"));
+ this.setScrollButtons(false, true);
// reset tabsNewtabButton and afterTabsButtonsWidth
if (typeof privateTab == "object")
@@ -1247,6 +1265,29 @@ Tabmix.navToolbox = {
let useTabmixButtons = TabmixTabbar.scrollButtonsMode > TabmixTabbar.SCROLL_BUTTONS_LEFT_RIGHT;
gBrowser.tabContainer.mTabstrip.updateScrollButtons(useTabmixButtons);
}
+ },
+
+ setCloseButtonPosition: function() {
+ if (!Tabmix.isVersion(310))
+ return;
+ // if tabmix-tabs-closebutton was positioned immediately after
+ // tabmixScrollBox we removed the button on exit, to avoid bug 1034394.
+ let pref = "tabs-closeButton-position";
+ if (Tabmix.prefs.prefHasUserValue(pref)) {
+ let position = Tabmix.prefs.getIntPref(pref);
+ Tabmix.prefs.clearUserPref(pref);
+ CustomizableUI.moveWidgetWithinArea("tabmix-tabs-closebutton", position);
+ }
+ // try to restore button position from tabs-closebutton position
+ // if item with tabs-closebutton id exist, some other extension add it
+ else if (!document.getElementById("tabs-closebutton")) {
+ let currentset = CustomizableUI.getWidgetIdsInArea("TabsToolbar");
+ let position = currentset.indexOf("tabs-closebutton");
+ if (position > -1) {
+ CustomizableUI.removeWidgetFromArea("tabs-closebutton");
+ CustomizableUI.moveWidgetWithinArea("tabmix-tabs-closebutton", position);
+ }
+ }
}
}
diff --git a/chrome/content/overlay/tabstoolbar.xul b/chrome/content/overlay/tabstoolbar.xul
new file mode 100644
index 0000000..10f4a93
--- /dev/null
+++ b/chrome/content/overlay/tabstoolbar.xul
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+
+<!DOCTYPE overlay [
+<!ENTITY % tabBrowserDTD SYSTEM "chrome://browser/locale/tabbrowser.dtd" >
+%tabBrowserDTD;
+]>
+
+<overlay id="tabmix-tabstoolbar-overlay"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+ <toolbar id="TabsToolbar">
+ <toolbarbutton id="tabmix-tabs-closebutton"
+ class="tabs-closebutton close-icon tabmix"
+ command="cmd_close"
+ cui-areatype="toolbar"
+ label="&closeTab.label;"
+ tooltiptext="&closeTab.label;"
+ removable="false"/>
+ </toolbar>
+
+</overlay>
\ No newline at end of file
diff --git a/chrome/content/tab/tab.js b/chrome/content/tab/tab.js
index da93e12..8549f41 100644
--- a/chrome/content/tab/tab.js
+++ b/chrome/content/tab/tab.js
@@ -142,7 +142,9 @@ var TabmixTabbar = {
tabBar.adjustTabstrip(true);
// show on tabbar
- let tabstripClosebutton = document.getElementById("tabs-closebutton");
+ let tabstripClosebutton = Tabmix.isVersion(310) ?
+ document.getElementById("tabmix-tabs-closebutton") :
+ document.getElementById("tabs-closebutton");
if (this.isButtonOnTabsToolBar(tabstripClosebutton))
tabstripClosebutton.collapsed = Tabmix.prefs.getBoolPref("hideTabBarButton");
let allTabsButton = document.getElementById("alltabs-button");
@@ -179,40 +181,6 @@ var TabmixTabbar = {
}
},
- addCloseButton: function () {
- if (!Tabmix.isVersion(310))
- return;
- var button = document.getElementById("tabs-closebutton");
- if (!button && !Tabmix.prefs.getBoolPref("hideTabBarButton")) {
- button = document.createElement("toolbarbutton");
- button.id = "tabs-closebutton";
- button.className = "tabs-closebutton close-icon tabmix";
- button.setAttribute("command", "cmd_close");
- button.setAttribute("cui-areatype", "toolbar");
- var label = gBrowser.selectedTab.getAttribute("closetabtext");
- button.setAttribute("label", label);
- button.setAttribute("tooltiptext", label);
-
- let tabsToolbar = document.getElementById("TabsToolbar");
- let cSet = (tabsToolbar.getAttribute("currentset") || tabsToolbar.getAttribute("defaultset")).split(",");
- let index = cSet.indexOf("tabs-closebutton");
- let elm = null;
- if (index > -1) {
- while (index < cSet.length - 1) {
- let item = document.getElementById(cSet[index + 1]);
- if (item && item.parentNode == tabsToolbar) {
- elm = item;
- break;
- }
- index++;
- }
- }
- else if (index == -1)
- tabsToolbar.setAttribute("currentset", cSet.join(",") + ",tabs-closebutton");
- tabsToolbar.insertBefore(button, elm);
- }
- },
-
updateScrollStatus: function TMP_updateScrollStatus() {
var tabBar = gBrowser.tabContainer;
if (this.isMultiRow) {
@@ -917,7 +885,6 @@ var gTMPprefObserver = {
}
break;
case "extensions.tabmix.hideTabBarButton":
- TabmixTabbar.addCloseButton();
case "extensions.tabmix.tabBarMode":
case "extensions.tabmix.tabBarSpace":
case "extensions.tabmix.hideAllTabsButton":
diff --git a/chrome/content/tabmix.js b/chrome/content/tabmix.js
index 8f473ed..a22b7c7 100644
--- a/chrome/content/tabmix.js
+++ b/chrome/content/tabmix.js
@@ -215,7 +215,6 @@ Tabmix.delayedStartup = function TMP_delayedStartup() {
gTMPprefObserver.setMenuIcons();
TabmixTabbar.updateSettings(true);
- TabmixTabbar.addCloseButton();
gTMPprefObserver.setTabIconMargin();
gTMPprefObserver.setCloseButtonMargin();
gTMPprefObserver.miscellaneousRules();
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/tabmixplus.git
More information about the Pkg-mozext-commits
mailing list