From c66a6570f586bfc61e15d2c95ee8de0b45b12035 Mon Sep 17 00:00:00 2001 From: piro Date: Tue, 21 Jul 2009 04:03:33 +0000 Subject: [PATCH] =?UTF-8?q?Focus=20Last=20Selected=20Tab=200.9.5.x=20(=20h?= =?UTF-8?q?ttp://www.gozer.org/mozilla/extensions/=20)=20=E3=81=A8?= =?UTF-8?q?=E7=B5=84=E3=81=BF=E5=90=88=E3=82=8F=E3=81=9B=E3=81=A6=E5=88=A9?= =?UTF-8?q?=E7=94=A8=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@4765 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- content/treestyletab/hacks.js | 12 ++- content/treestyletab/res/extensions.js | 110 +++++++++++++++++++++++++ content/treestyletab/treestyletab.xul | 1 + 3 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 content/treestyletab/res/extensions.js diff --git a/content/treestyletab/hacks.js b/content/treestyletab/hacks.js index e3bc720d..cb162c26 100644 --- a/content/treestyletab/hacks.js +++ b/content/treestyletab/hacks.js @@ -563,13 +563,23 @@ TreeStyleTabService.overrideExtensionsOnInitAfter = function() { window.addEventListener('unload', listener, false); } - // FLST + // FLST (Focus Last Selected Tab) + // https://addons.mozilla.org/ja/firefox/addon/32 if ('flst' in window) { TreeStyleTabService.registerTabFocusAllowance(function(aTabBrowser) { return !aTabBrowser.treeStyleTab.getPref('extensions.flst.enabled'); }); } + // Focus Last Selected Tab 0.9.5.x + // http://www.gozer.org/mozilla/extensions/ + if (window['piro.sakura.ne.jp'].extensions.isInstalled('focuslastselectedtab@gozer.org') && + window['piro.sakura.ne.jp'].extensions.isEnabled('focuslastselectedtab@gozer.org')) { + TreeStyleTabService.registerTabFocusAllowance(function(aTabBrowser) { + return !aTabBrowser.selectedTab.hasAttribute('lastselected'); + }); + } + // FireGestures if ('FireGestures' in window) { eval('FireGestures.onExtraGesture = '+ diff --git a/content/treestyletab/res/extensions.js b/content/treestyletab/res/extensions.js new file mode 100644 index 00000000..0074728d --- /dev/null +++ b/content/treestyletab/res/extensions.js @@ -0,0 +1,110 @@ +/* + Extensions Compatibility Library + + Usage: + if (window['piro.sakura.ne.jp'].extensions.isInstalled('my.extension.id@example.com') && + window['piro.sakura.ne.jp'].extensions.isEnabled('my.extension.id@example.com')) + window['piro.sakura.ne.jp'].extensions.goToOptions('my.extension.id@example.com'); + + lisence: The MIT License, Copyright (c) 2009 SHIMODA "Piro" Hiroshi + http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/license.txt + original: + http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/extensions.js +*/ +(function() { + const currentRevision = 1; + + if (!('piro.sakura.ne.jp' in window)) window['piro.sakura.ne.jp'] = {}; + + var loadedRevision = 'extensions' in window['piro.sakura.ne.jp'] ? + window['piro.sakura.ne.jp'].extensions.revision : + 0 ; + if (loadedRevision && loadedRevision > currentRevision) { + return; + } + + window['piro.sakura.ne.jp'].extensions = { + revision : currentRevision, + + ExtensionManager : Components.classes['@mozilla.org/extensions/manager;1'] + .getService(Components.interfaces.nsIExtensionManager), + RDF : Components.classes['@mozilla.org/rdf/rdf-service;1'] + .getService(Components.interfaces.nsIRDFService), + WindowMediator : Components.classes['@mozilla.org/appshell/window-mediator;1'] + .getService(Components.interfaces.nsIWindowMediator), + Prefs : Components.classes['@mozilla.org/preferences;1'] + .getService(Components.interfaces.nsIPrefBranch), + + isInstalled : function(aId) + { + return this.ExtensionManager.getInstallLocation(aId); + }, + + isEnabled : function(aId) + { + var res = this.RDF.GetResource('urn:mozilla:item:'+aId); + var appDisabled = false; + try { + appDisabled = this.ExtensionManager.datasource.GetTarget( + res, + this.RDF.GetResource('http://www.mozilla.org/2004/em-rdf#appDisabled'), + true + ).QueryInterface(Components.interfaces.nsIRDFLiteral) + .Value == 'true'; + } + catch(e) { + } + var userDisabled = false; + try { + userDisabled = this.ExtensionManager.datasource.GetTarget( + res, + this.RDF.GetResource('http://www.mozilla.org/2004/em-rdf#userDisabled'), + true + ).QueryInterface(Components.interfaces.nsIRDFLiteral) + .Value == 'true'; + } + catch(e) { + } + + return !appDisabled && !userDisabled; + }, + + goToOptions : function(aId) + { + var res = this.RDF.GetResource('urn:mozilla:item:'+aId); + var uri; + try { + uri = this.ExtensionManager.datasource.GetTarget( + res, + this.RDF.GetResource('http://www.mozilla.org/2004/em-rdf#optionsURL'), + true + ).QueryInterface(Components.interfaces.nsIRDFLiteral) + .Value; + } + catch(e) { + } + if (!uri) return; + + var windows = this.WindowMediator.getEnumerator(null); + while (windows.hasMoreElements()) + { + let win = windows.getNext(); + if (win.location.href == uri) { + win.focus(); + return; + } + } + var instantApply = false; + try { + instantApply = this.Prefs.getBoolPref('browser.preferences.instantApply'); + } + catch(e) { + } + window.openDialog( + uri, + '', + 'chrome,titlebar,toolbar,centerscreen,' + (instantApply ? 'dialog=no' : 'modal' ) + ); + } + }; +})(); diff --git a/content/treestyletab/treestyletab.xul b/content/treestyletab/treestyletab.xul index 23b90794..55a52861 100644 --- a/content/treestyletab/treestyletab.xul +++ b/content/treestyletab/treestyletab.xul @@ -12,6 +12,7 @@