From 79cecd42c999efd7258053f83797c266e2767e03 Mon Sep 17 00:00:00 2001 From: piro Date: Mon, 27 Jul 2009 07:22:56 +0000 Subject: [PATCH] =?UTF-8?q?=E3=82=BF=E3=83=96=E3=81=AB=E3=83=AA=E3=83=B3?= =?UTF-8?q?=E3=82=AF=E3=82=92=E3=83=89=E3=83=AD=E3=83=83=E3=83=97=E3=81=97?= =?UTF-8?q?=E3=81=9F=E6=99=82=E3=81=A8=E3=83=96=E3=83=83=E3=82=AF=E3=83=9E?= =?UTF-8?q?=E3=83=BC=E3=82=AF=E3=83=95=E3=82=A9=E3=83=AB=E3=83=80=E3=82=92?= =?UTF-8?q?=E3=82=BF=E3=83=96=E3=81=A7=E9=96=8B=E3=81=8F=E6=99=82=E3=81=AE?= =?UTF-8?q?=E6=8C=99=E5=8B=95=E3=81=AE=E8=A8=AD=E5=AE=9A=E3=82=92=E3=80=81?= =?UTF-8?q?=E3=83=96=E3=83=BC=E3=83=AB=E5=80=A4=E3=81=AE=E7=B5=84=E3=81=BF?= =?UTF-8?q?=E5=90=88=E3=82=8F=E3=81=9B=E3=81=8B=E3=82=891=E3=81=A4?= =?UTF-8?q?=E3=81=AE=E6=95=B4=E6=95=B0=E5=80=A4=E3=81=AB=E5=A4=89=E6=9B=B4?= 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@4817 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- content/treestyletab/bookmarksOverlay.js | 8 +- content/treestyletab/config.js | 76 +++++++----- content/treestyletab/config.xul | 47 ++++---- content/treestyletab/treestyletab.js | 130 ++++++++++++++------- defaults/preferences/treestyletab.js | 11 +- locale/de-DE/treestyletab/treestyletab.dtd | 18 +-- locale/en-US/treestyletab/treestyletab.dtd | 18 +-- locale/es-ES/treestyletab/treestyletab.dtd | 18 +-- locale/it-IT/treestyletab/treestyletab.dtd | 18 +-- locale/ja/treestyletab/treestyletab.dtd | 18 +-- locale/pl-PL/treestyletab/treestyletab.dtd | 18 +-- locale/ru-RU/treestyletab/treestyletab.dtd | 18 +-- locale/zh-CN/treestyletab/treestyletab.dtd | 18 +-- locale/zh-TW/treestyletab/treestyletab.dtd | 18 +-- 14 files changed, 254 insertions(+), 180 deletions(-) diff --git a/content/treestyletab/bookmarksOverlay.js b/content/treestyletab/bookmarksOverlay.js index ba4e1927..c3471f1f 100644 --- a/content/treestyletab/bookmarksOverlay.js +++ b/content/treestyletab/bookmarksOverlay.js @@ -8,21 +8,21 @@ window.addEventListener('load', function() { ).replace( 'browserWindow.getBrowser().loadTabs(', diff --git a/content/treestyletab/config.js b/content/treestyletab/config.js index 2b2ea57b..f36f9063 100644 --- a/content/treestyletab/config.js +++ b/content/treestyletab/config.js @@ -2,9 +2,35 @@ const XULAppInfo = Components.classes['@mozilla.org/xre/app-info;1'] .getService(Components.interfaces.nsIXULAppInfo); const comparator = Components.classes['@mozilla.org/xpcom/version-comparator;1'] .getService(Components.interfaces.nsIVersionComparator); +var Prefs = Components + .classes['@mozilla.org/preferences;1'] + .getService(Components.interfaces.nsIPrefBranch); + +var gGroupBookmarkRadio, + gGroupBookmarkUnderParent, + gGroupBookmarkPref, + gGroupBookmarkReplace; + +function ensureGroupBookmarkItems() +{ + if (gGroupBookmarkPref) return; + + gGroupBookmarkRadio = document.getElementById('openGroupBookmark-radiogroup'); + gGroupBookmarkPref = document.getElementById('extensions.treestyletab.openGroupBookmark.behavior'); + gGroupBookmarkUnderParent = document.getElementById('openGroupBookmark.underParent-check'); + var bookmarkReplaceKey = 'browser.tabs.loadFolderAndReplace'; + gGroupBookmarkReplace = document.getElementById(bookmarkReplaceKey); + try { + gGroupBookmarkReplace.value = Prefs.getBoolPref(bookmarkReplaceKey); + } + catch(e) { + Prefs.setBoolPref(bookmarkReplaceKey, gGroupBookmarkReplace.value != 'false'); + } +} function init() { + ensureGroupBookmarkItems(); // sizeToContent(); } @@ -12,9 +38,6 @@ function init() var gOpenLinkInTabScale, gLoadLocationBarToNewTabScale, gLoadLocationBarToChildTabScale, - gGroupBookmarkRadio, - gGroupBookmarkTree, - gGroupBookmarkReplace, gLastStateIsVertical; var gTabbarPlacePositionInitialized = false; @@ -39,12 +62,6 @@ function initTabPane() 'loadLocationBarToChildTab-labels' ); - gGroupBookmarkRadio = document.getElementById('openGroupBookmarkAsTabSubTree-radiogroup'); - gGroupBookmarkTree = document.getElementById('extensions.treestyletab.openGroupBookmarkAsTabSubTree'); - - - var Prefs = Components.classes['@mozilla.org/preferences;1'] - .getService(Components.interfaces.nsIPrefBranch); var restrictionKey = 'browser.link.open_newwindow.restriction'; var restriction = document.getElementById(restrictionKey); @@ -55,34 +72,33 @@ function initTabPane() Prefs.setIntPref(restrictionKey, parseInt(restriction.value)); } - var bookmarkReplaceKey = 'browser.tabs.loadFolderAndReplace'; - gGroupBookmarkReplace = document.getElementById(bookmarkReplaceKey); - try { - gGroupBookmarkReplace.value = Prefs.getBoolPref(bookmarkReplaceKey); - } - catch(e) { - Prefs.setBoolPref(bookmarkReplaceKey, gGroupBookmarkReplace.value != 'false'); - } - - gGroupBookmarkRadio.value = - gGroupBookmarkTree.value && !gGroupBookmarkReplace.value ? 'subtree' : - !gGroupBookmarkTree.value && !gGroupBookmarkReplace.value ? 'flat' : - 'replace'; - gLastStateIsVertical = document.getElementById('extensions.treestyletab.tabbar.position-radiogroup').value; gLastStateIsVertical = gLastStateIsVertical == 'left' || gLastStateIsVertical == 'right'; } -function onChangeGroupBookmarkRadio() +function onSyncGroupBookmarkRadioToPref() { - gGroupBookmarkTree.value = gGroupBookmarkRadio.value == 'subtree'; - gGroupBookmarkReplace.value = gGroupBookmarkRadio.value == 'replace'; + ensureGroupBookmarkItems(); + var behavior = parseInt(gGroupBookmarkRadio.value); + if (gGroupBookmarkUnderParent.checked) behavior += 256; - var underParent = document.getElementById('openGroupBookmarkAsTabSubTree.underParent-check'); - if (gGroupBookmarkTree.value) - underParent.removeAttribute('disabled'); + if (behavior & 1) + gGroupBookmarkUnderParent.removeAttribute('disabled'); else - underParent.setAttribute('disabled', true); + gGroupBookmarkUnderParent.setAttribute('disabled', true); + + return behavior; +} + +function onSyncPrefToGroupBookmarkRadio() +{ + ensureGroupBookmarkItems(); + var behavior = gGroupBookmarkPref.value & 1 ? 1 : + gGroupBookmarkPref.value & 2 ? 2 : + gGroupBookmarkPref.value & 4 ? 4 : + 0; + gGroupBookmarkUnderParent.checked = gGroupBookmarkPref.value & 256 ? true : false ; + return behavior; } diff --git a/content/treestyletab/config.xul b/content/treestyletab/config.xul index a7280f19..9ac4b7d6 100644 --- a/content/treestyletab/config.xul +++ b/content/treestyletab/config.xul @@ -323,15 +323,12 @@ - - - + + @@ -405,27 +402,31 @@ - - + - - + + + - - + + onsynctopreference="return onSyncGroupBookmarkRadioToPref();" + onsyncfrompreference="return onSyncPrefToGroupBookmarkRadio();" + preference="extensions.treestyletab.openGroupBookmark.behavior"> + - - + + - - + + diff --git a/content/treestyletab/treestyletab.js b/content/treestyletab/treestyletab.js index 688a596c..8c9b57a4 100644 --- a/content/treestyletab/treestyletab.js +++ b/content/treestyletab/treestyletab.js @@ -1130,10 +1130,10 @@ var TreeStyleTabService = { useTMPSessionAPI : false, kTMP_SESSION_DATA_PREFIX : 'tmp-session-data-', - shouldLoadDroppedLinkToNewChildTab : function() + dropLinksOnTabBehavior : function() { - if (!this.getTreePref('loadDroppedLinkToNewChildTab.confirm')) - return this.getTreePref('loadDroppedLinkToNewChildTab'); + var behavior = this.getTreePref('dropLinksOnTab.behavior'); + if (behavior & this.kDROPLINK_FIXED) return behavior; var checked = { value : false }; var newChildTab = this.PromptService.confirmEx(window, @@ -1147,29 +1147,27 @@ var TreeStyleTabService = { this.stringbundle.getString('dropLinkOnTab.never'), checked ) == 0; - if (checked.value) { - this.setTreePref('loadDroppedLinkToNewChildTab.confirm', false); - this.setTreePref('loadDroppedLinkToNewChildTab', newChildTab); - } - return newChildTab - }, - - howToOpenGroupBookmark : function() - { - var dummyTabFlag = this.getTreePref('openGroupBookmarkAsTabSubTree.underParent') ? - this.kGROUP_BOOKMARK_USE_DUMMY : - 0 ; - if (!this.getTreePref('openGroupBookmarkBehavior.confirm')) { - return this.getTreePref('openGroupBookmarkAsTabSubTree') ? - this.kGROUP_BOOKMARK_SUBTREE | dummyTabFlag : - this.getPref('browser.tabs.loadFolderAndReplace') ? - this.kGROUP_BOOKMARK_REPLACE : - this.kGROUP_BOOKMARK_SEPARATE ; - } + behavior = newChildTab ? this.kDROPLINK_NEWTAB : this.kDROPLINK_LOAD ; + if (checked.value) + this.setTreePref('dropLinksOnTab.behavior', behavior); + + return behavior + }, + kDROPLINK_ASK : 0, + kDROPLINK_FIXED : 1 + 2, + kDROPLINK_LOAD : 1, + kDROPLINK_NEWTAB : 2, + + openGroupBookmarkBehavior : function() + { + var behavior = this.getTreePref('openGroupBookmark.behavior'); + if (behavior & this.kGROUP_BOOKMARK_FIXED) return behavior; + + var dummyTabFlag = behavior & this.kGROUP_BOOKMARK_USE_DUMMY; var checked = { value : false }; - var behavior = this.PromptService.confirmEx(window, + var button = this.PromptService.confirmEx(window, this.stringbundle.getString('openGroupBookmarkBehavior.title'), this.stringbundle.getString('openGroupBookmarkBehavior.text'), (this.PromptService.BUTTON_TITLE_IS_STRING * this.PromptService.BUTTON_POS_0) + @@ -1182,21 +1180,22 @@ var TreeStyleTabService = { checked ); - if (behavior < 0) behavior = 1; + if (button < 0) button = 1; var behaviors = [ this.kGROUP_BOOKMARK_SUBTREE | dummyTabFlag, this.kGROUP_BOOKMARK_SEPARATE, this.kGROUP_BOOKMARK_REPLACE ]; - behavior = behaviors[behavior]; + behavior = behaviors[button]; if (checked.value) { - this.setTreePref('openGroupBookmarkBehavior.confirm', false); - this.setTreePref('openGroupBookmarkAsTabSubTree', behavior & this.kGROUP_BOOKMARK_SUBTREE ? true : false ); + this.setTreePref('openGroupBookmark.behavior', behavior); this.setPref('browser.tabs.loadFolderAndReplace', behavior & this.kGROUP_BOOKMARK_REPLACE ? true : false ); } return behavior; }, + kGROUP_BOOKMARK_ASK : 0, + kGROUP_BOOKMARK_FIXED : 1 + 2 + 4, kGROUP_BOOKMARK_SUBTREE : 1, kGROUP_BOOKMARK_SEPARATE : 2, kGROUP_BOOKMARK_REPLACE : 4, @@ -1246,9 +1245,29 @@ var TreeStyleTabService = { this.registerTabFocusAllowance(this.defaultTabFocusAllowance); + this.migratePrefs(); + }, + preInitialized : false, + + defaultTabFocusAllowance : function(aBrowser) + { + var tab = aBrowser.selectedTab; + return ( + !this.getPref('browser.tabs.selectOwnerOnClose') || + !tab.owner || + ( + aBrowser._removingTabs && + aBrowser._removingTabs.indexOf(tab.owner) > -1 + ) + ); + }, + + kPREF_VERSION : 4, + migratePrefs : function() + { // migrate old prefs var orientalPrefs = []; - switch (this.getTreePref('orientalPrefsMigrated')) + switch (this.getTreePref('prefsVersion')) { case 0: orientalPrefs = orientalPrefs.concat([ @@ -1267,7 +1286,37 @@ var TreeStyleTabService = { this.setTreePref('urlbar.loadSameDomainToNewTab', value); this.setTreePref('urlbar.loadSameDomainToNewTab.asChild', value); if (value) this.setTreePref('urlbar.loadDifferentDomainToNewTab', value); - this.clearPref('extensions.treestyletab.urlbar.loadSameDomainToNewChildTab'); + this.clearTreePref('urlbar.loadSameDomainToNewChildTab'); + } + case 3: + if (this.getTreePref('loadDroppedLinkToNewChildTab') !== null) { + this.setTreePref('dropLinksOnTab.behavior', + this.getTreePref('loadDroppedLinkToNewChildTab.confirm') ? + this.kDROPLINK_ASK : + this.getTreePref('loadDroppedLinkToNewChildTab') ? + this.kDROPLINK_NEWTAB : + this.kDROPLINK_LOAD + ); + this.clearTreePref('loadDroppedLinkToNewChildTab.confirm'); + this.clearTreePref('loadDroppedLinkToNewChildTab'); + } + if (this.getTreePref('openGroupBookmarkAsTabSubTree') !== null) { + let behavior = 0; + if (this.getTreePref('openGroupBookmarkAsTabSubTree.underParent')) + behavior += this.kGROUP_BOOKMARK_USE_DUMMY; + if (!this.getTreePref('openGroupBookmarkBehavior.confirm')) { + if (this.getTreePref('openGroupBookmarkAsTabSubTree')) + behavior += this.kGROUP_BOOKMARK_SUBTREE; + else if (this.getTreePref('browser.tabs.loadFolderAndReplace')) + behavior += this.kGROUP_BOOKMARK_REPLACE; + else + behavior += this.kGROUP_BOOKMARK_SEPARATE; + } + this.setTreePref('openGroupBookmark.behavior', behavior); + this.clearTreePref('openGroupBookmarkBehavior.confirm'); + this.clearTreePref('openGroupBookmarkAsTabSubTree'); + this.clearTreePref('openGroupBookmarkAsTabSubTree.underParent'); + this.setPref('browser.tabs.loadFolderAndReplace', behavior & this.kGROUP_BOOKMARK_REPLACE ? true : false ); } default: orientalPrefs.forEach(function(aPref) { @@ -1279,21 +1328,7 @@ var TreeStyleTabService = { }, this); break; } - this.setTreePref('orientalPrefsMigrated', 3); - }, - preInitialized : false, - - defaultTabFocusAllowance : function(aBrowser) - { - var tab = aBrowser.selectedTab; - return ( - !this.getPref('browser.tabs.selectOwnerOnClose') || - !tab.owner || - ( - aBrowser._removingTabs && - aBrowser._removingTabs.indexOf(tab.owner) > -1 - ) - ); + this.setTreePref('prefsVersion', this.kPREF_VERSION); }, init : function() @@ -1523,7 +1558,7 @@ catch(e) { ); if (!loadDroppedLinkToNewChildTab && dropActionInfo.position == TreeStyleTabService.kDROP_ON) { - loadDroppedLinkToNewChildTab = TreeStyleTabService.shouldLoadDroppedLinkToNewChildTab(); + loadDroppedLinkToNewChildTab = TreeStyleTabService.dropLinksOnTabBehavior() == TreeStyleTabService.kDROPLINK_NEWTAB; } if ( loadDroppedLinkToNewChildTab || @@ -2601,6 +2636,11 @@ catch(e) { setTreePref : function(aPrefstring, aNewValue) { return this.setPref('extensions.treestyletab.'+aPrefstring, aNewValue); + }, + + clearTreePref : function(aPrefstring) + { + return this.clearPref('extensions.treestyletab.'+aPrefstring); } }; diff --git a/defaults/preferences/treestyletab.js b/defaults/preferences/treestyletab.js index 9930dcf0..f0b08f3d 100644 --- a/defaults/preferences/treestyletab.js +++ b/defaults/preferences/treestyletab.js @@ -81,11 +81,10 @@ pref("extensions.treestyletab.urlbar.loadDifferentDomainToNewTab.asChild", false pref("extensions.treestyletab.urlbar.loadSameDomainToNewTab", true); pref("extensions.treestyletab.urlbar.loadSameDomainToNewTab.asChild", true); pref("extensions.treestyletab.urlbar.invertDefaultBehavior", true); -pref("extensions.treestyletab.loadDroppedLinkToNewChildTab", false); -pref("extensions.treestyletab.loadDroppedLinkToNewChildTab.confirm", true); -pref("extensions.treestyletab.openGroupBookmarkBehavior.confirm", true); -pref("extensions.treestyletab.openGroupBookmarkAsTabSubTree", true); -pref("extensions.treestyletab.openGroupBookmarkAsTabSubTree.underParent", true); +// 0 = always ask, 1 = load into the tab, 2 = open new child tab +pref("extensions.treestyletab.dropLinksOnTab.behavior", 0); +// 0 = always ask, 1 = tree, 2 = separate, 4 = replace, 256 = use dummy tab (for subtree) +pref("extensions.treestyletab.openGroupBookmark.behavior", 256); pref("extensions.treestyletab.useEffectiveTLD", true); pref("extensions.treestyletab.autoCollapseExpandSubTreeOnSelect", true); @@ -123,7 +122,7 @@ pref("extensions.multipletab.show.multipletab-selection-item-createSubTree", tru pref("extensions.treestyletab.TMP.doNotUpdate.isTabVisible", false); -pref("extensions.treestyletab.orientalPrefsMigrated", 0); +pref("extensions.treestyletab.prefsVersion", 0); pref("extensions.treestyletab@piro.sakura.ne.jp.name", "chrome://treestyletab/locale/treestyletab.properties"); diff --git a/locale/de-DE/treestyletab/treestyletab.dtd b/locale/de-DE/treestyletab/treestyletab.dtd index 0ace0b4e..f345bde0 100644 --- a/locale/de-DE/treestyletab/treestyletab.dtd +++ b/locale/de-DE/treestyletab/treestyletab.dtd @@ -61,15 +61,17 @@ - - - + + + + - - - - - + + + + + + diff --git a/locale/en-US/treestyletab/treestyletab.dtd b/locale/en-US/treestyletab/treestyletab.dtd index 420e66cc..d0d3f86f 100644 --- a/locale/en-US/treestyletab/treestyletab.dtd +++ b/locale/en-US/treestyletab/treestyletab.dtd @@ -60,15 +60,17 @@ - - - + + + + - - - - - + + + + + + diff --git a/locale/es-ES/treestyletab/treestyletab.dtd b/locale/es-ES/treestyletab/treestyletab.dtd index 6c842a45..55f238ba 100644 --- a/locale/es-ES/treestyletab/treestyletab.dtd +++ b/locale/es-ES/treestyletab/treestyletab.dtd @@ -60,15 +60,17 @@ - - - + + + + - - - - - + + + + + + diff --git a/locale/it-IT/treestyletab/treestyletab.dtd b/locale/it-IT/treestyletab/treestyletab.dtd index bcb2db24..43fe8c28 100644 --- a/locale/it-IT/treestyletab/treestyletab.dtd +++ b/locale/it-IT/treestyletab/treestyletab.dtd @@ -60,15 +60,17 @@ - - - + + + + - - - - - + + + + + + diff --git a/locale/ja/treestyletab/treestyletab.dtd b/locale/ja/treestyletab/treestyletab.dtd index 889c824f..05c99c06 100644 --- a/locale/ja/treestyletab/treestyletab.dtd +++ b/locale/ja/treestyletab/treestyletab.dtd @@ -60,15 +60,17 @@ - - - + + + + - - - - - + + + + + + diff --git a/locale/pl-PL/treestyletab/treestyletab.dtd b/locale/pl-PL/treestyletab/treestyletab.dtd index 83ec6934..5591a167 100644 --- a/locale/pl-PL/treestyletab/treestyletab.dtd +++ b/locale/pl-PL/treestyletab/treestyletab.dtd @@ -60,15 +60,17 @@ - - - + + + + - - - - - + + + + + + diff --git a/locale/ru-RU/treestyletab/treestyletab.dtd b/locale/ru-RU/treestyletab/treestyletab.dtd index ef18769f..1bf01100 100755 --- a/locale/ru-RU/treestyletab/treestyletab.dtd +++ b/locale/ru-RU/treestyletab/treestyletab.dtd @@ -60,15 +60,17 @@ - - - + + + + - - - - - + + + + + + diff --git a/locale/zh-CN/treestyletab/treestyletab.dtd b/locale/zh-CN/treestyletab/treestyletab.dtd index 38462d28..bb049d43 100644 --- a/locale/zh-CN/treestyletab/treestyletab.dtd +++ b/locale/zh-CN/treestyletab/treestyletab.dtd @@ -60,15 +60,17 @@ - - - + + + + - - - - - + + + + + + diff --git a/locale/zh-TW/treestyletab/treestyletab.dtd b/locale/zh-TW/treestyletab/treestyletab.dtd index 7249a953..e2d4357c 100644 --- a/locale/zh-TW/treestyletab/treestyletab.dtd +++ b/locale/zh-TW/treestyletab/treestyletab.dtd @@ -59,15 +59,17 @@ - - - + + + + - - - - - + + + + + +