mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-04-05 02:53:32 +02:00
Fix occasional lag in updating tab count widget (thanks elitemx). Minor cleanup.
This commit is contained in:
@@ -350,19 +350,19 @@ function Events() //{{{
|
|||||||
let tabContainer = tabs.getBrowser().mTabContainer;
|
let tabContainer = tabs.getBrowser().mTabContainer;
|
||||||
|
|
||||||
tabContainer.addEventListener("TabMove", function (event) {
|
tabContainer.addEventListener("TabMove", function (event) {
|
||||||
statusline.updateTabCount();
|
statusline.updateTabCount(true);
|
||||||
}, false);
|
}, false);
|
||||||
tabContainer.addEventListener("TabOpen", function (event) {
|
tabContainer.addEventListener("TabOpen", function (event) {
|
||||||
statusline.updateTabCount();
|
statusline.updateTabCount(true);
|
||||||
}, false);
|
}, false);
|
||||||
tabContainer.addEventListener("TabClose", function (event) {
|
tabContainer.addEventListener("TabClose", function (event) {
|
||||||
statusline.updateTabCount();
|
statusline.updateTabCount(true);
|
||||||
}, false);
|
}, false);
|
||||||
tabContainer.addEventListener("TabSelect", function (event) {
|
tabContainer.addEventListener("TabSelect", function (event) {
|
||||||
// TODO: is all of that necessary?
|
// TODO: is all of that necessary?
|
||||||
|
// I vote no. --Kris
|
||||||
modes.reset();
|
modes.reset();
|
||||||
// XXX: apparently the tab container hasn't updated mTabs yet
|
statusline.updateTabCount(true);
|
||||||
setTimeout(function () { statusline.updateTabCount(); }, 0);
|
|
||||||
tabs.updateSelectionHistory();
|
tabs.updateSelectionHistory();
|
||||||
|
|
||||||
if (options["focuscontent"])
|
if (options["focuscontent"])
|
||||||
|
|||||||
@@ -34,23 +34,25 @@ function CommandLine() //{{{
|
|||||||
storage.newObject("sanitize", function () {
|
storage.newObject("sanitize", function () {
|
||||||
({
|
({
|
||||||
CLEAR: "browser:purge-session-history",
|
CLEAR: "browser:purge-session-history",
|
||||||
|
QUIT: "quit-application",
|
||||||
init: function ()
|
init: function ()
|
||||||
{
|
{
|
||||||
services.get("observer").addObserver(this, this.CLEAR, false);
|
services.get("observer").addObserver(this, this.CLEAR, false);
|
||||||
services.get("observer").addObserver(this, "quit-application", false);
|
services.get("observer").addObserver(this, this.QUIT, false);
|
||||||
},
|
},
|
||||||
observe: function (subject, topic, data)
|
observe: function (subject, topic, data)
|
||||||
{
|
{
|
||||||
if (topic == this.CLEAR)
|
switch (topic)
|
||||||
{
|
{
|
||||||
["search", "command"].forEach(function (mode) {
|
case this.CLEAR:
|
||||||
History(null, mode).sanitize();
|
["search", "command"].forEach(function (mode) {
|
||||||
});
|
History(null, mode).sanitize();
|
||||||
}
|
});
|
||||||
else if (topic == "quit-application")
|
break;
|
||||||
{
|
case this.QUIT:
|
||||||
services.get("observer").removeObserver(this, this.CLEAR);
|
services.get("observer").removeObserver(this, this.CLEAR);
|
||||||
services.get("observer").removeObserver(this, "quit-application");
|
services.get("observer").removeObserver(this, this.QUIT);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).init();
|
}).init();
|
||||||
@@ -2253,32 +2255,24 @@ function StatusLine() //{{{
|
|||||||
/**
|
/**
|
||||||
* Display the correct tabcount (e.g., [1/5]) on the status bar.
|
* Display the correct tabcount (e.g., [1/5]) on the status bar.
|
||||||
*
|
*
|
||||||
* @param {number} currentIndex The 1-based index of the
|
* @param {bool} delayed When true, update count after a
|
||||||
* currently selected tab. @optional
|
* brief timeout. Useful in the many cases when an
|
||||||
* @param {number} totalTabs The total number of tabs. @optional
|
* event that triggers an update is broadcast before
|
||||||
|
* the tab state is fully updated.
|
||||||
*/
|
*/
|
||||||
updateTabCount: function updateTabCount(currentIndex, totalTabs)
|
updateTabCount: function updateTabCount(delayed)
|
||||||
{
|
{
|
||||||
if (!liberator.has("tabs"))
|
if (liberator.has("tabs"))
|
||||||
{
|
{
|
||||||
tabCountWidget = "";
|
if (delayed)
|
||||||
return;
|
return void setTimeout(function () statusline.updateTabCount(false), 0);
|
||||||
}
|
|
||||||
|
|
||||||
// update the ordinal which is used for numbered tabs only when the user has
|
// update the ordinal which is used for numbered tabs
|
||||||
// tab numbers set
|
|
||||||
if (options.get("guioptions").has("n", "N"))
|
|
||||||
{
|
|
||||||
for (let [i, tab] in util.Array.iteritems(getBrowser().mTabs))
|
for (let [i, tab] in util.Array.iteritems(getBrowser().mTabs))
|
||||||
tab.setAttribute("ordinal", i + 1);
|
tab.setAttribute("ordinal", i + 1);
|
||||||
|
|
||||||
|
tabCountWidget.value = "[" + (tabs.index() + 1) + "/" + tabs.count + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!currentIndex || typeof currentIndex != "number")
|
|
||||||
currentIndex = tabs.index() + 1;
|
|
||||||
if (!totalTabs || typeof currentIndex != "number")
|
|
||||||
totalTabs = tabs.count;
|
|
||||||
|
|
||||||
tabCountWidget.value = "[" + currentIndex + "/" + totalTabs + "]";
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user