From: Kristian Kræmmer Nielsen Date: Sun, 10 Aug 2008 01:27:00 +0000 (+0200) Subject: Cleaned up patch from Adrian: X-Git-Url: https://git.jkkn.net/?a=commitdiff_plain;h=690128dbc26b7434844d98e562ca3138a09ac89a;p=tv2developer Cleaned up patch from Adrian: - Removed code that saved new preference - this is done automatically by firefox - Changed behaviour to instantly change icon location by using a preference observer instead of requiring a browser restart - Added default preference parameter in default preference file - Added credit in about box - Bombed to version 0.11.0 --- diff --git a/content/about.xul b/content/about.xul index a1fa475..f9ac958 100644 --- a/content/about.xul +++ b/content/about.xul @@ -18,6 +18,9 @@ + + + + - - + diff --git a/content/options.js b/content/options.js index 52e1333..2a218e6 100644 --- a/content/options.js +++ b/content/options.js @@ -6,9 +6,6 @@ var TV2Options = { _hackEnabled: false, init: function() { - // the status bar thingy. - document.getElementById('statusbarmode').checked = TV2Util.getPref('useStatusBarMode', false); - var hacks = document.getElementById('mac-hacks'); var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService); this._keyBranch = prefs.getBranch('ui.key.'); @@ -123,16 +120,10 @@ var TV2Options = { } } - // Save the statusbar thing - var statusbar = document.getElementById('statusbarmode').checked; - TV2Util.setPref('useStatusBarMode', statusbar); - }, update: function() { - if(this._prefBranch != null) { // sometimes it's null on my mac (adba) - var instantApply = this._prefBranch.getBoolPref("instantApply", false); - } + var instantApply = this._prefBranch.getBoolPref("instantApply", false); if (instantApply) this.save(); } diff --git a/content/options.xul b/content/options.xul index 951b196..45a9de9 100644 --- a/content/options.xul +++ b/content/options.xul @@ -18,6 +18,7 @@ + @@ -45,10 +46,11 @@ oncommand="TV2Options.update()" tooltiptext="&optionsDialog.mac.accesskeys.tooltiptext;"/> + + preference="pref_statusbarmode" + tooltiptext="&optionsDialog.misc.statusbarmode.tooltiptext;"/> diff --git a/content/tv2developer.js b/content/tv2developer.js index 385b119..91eb0df 100644 --- a/content/tv2developer.js +++ b/content/tv2developer.js @@ -34,11 +34,12 @@ var TV2Developer = { _lastAction: null, - _statusBarIconEnabled: false, + _useStatusBarIconInstead: false, /* toggle between statusbar/toolbar mode */ - enableStatusBarIcon: function( enabled ) { - this._statusBarIconEnabled = enabled; + updateStatusBarMode: function() { + var enabled = this._useStatusBarIconInstead = TV2Util.getPref('useStatusBarMode'); + var statusbutton = document.getElementById('tv2developer_statusbutton'); var swapbutton = document.getElementById('tv2-swap-button'); var popupmenu = document.getElementById('tv2developer-popupmenu'); @@ -46,8 +47,7 @@ var TV2Developer = { statusbutton.hidden = !enabled; swapbutton.hidden = enabled; - statusbutton.setAttribute('context', 'tv2developer-contextmenu'); // Add the rightclick menu. - if(enabled) { + if (enabled) { statusbutton.appendChild(popupmenu); } else { swapbutton.appendChild(popupmenu); @@ -56,7 +56,7 @@ var TV2Developer = { /* method for initialize, reading properties, adding icon at firstrun, added keyshortcuts */ init: function() { - // init + // init this._lastAction = TV2Util.getPref('lastaction-linktype'); // add shortcuts depending on platform var shortcuts = document.getElementById('mainKeyset'); @@ -107,8 +107,14 @@ var TV2Developer = { catch(e) { } } - // initializes the statusbar icon. - this.enableStatusBarIcon(TV2Util.getPref('useStatusBarMode', false)); + // initializes the statusbar icon by observe optional preference changes + TV2Util.prefs.addObserver('useStatusBarMode', { + observe: function(subject, topic, data) { + if (topic == 'nsPref:changed') { + TV2Developer.updateStatusBarMode(); + } + }}, false); + TV2Developer.updateStatusBarMode(); }, /* utility function to create shortcut object */ @@ -573,8 +579,12 @@ var TV2Developer = { /* shortcut to open menu */ handleKeyShortcut: function(event) { - var popupmenu = document.getElementById('tv2developer-popupmenu'); - popupmenu.showPopup(); + if (!this._useStatusBarIconInstead) { // normal icon dropdown + document.getElementById('tv2-swap-button').open = true; + } else { // status bar icon + var popupmenu = document.getElementById('tv2developer-popupmenu'); + popupmenu.showPopup(); + } }, /* utility function to go to a link */ diff --git a/content/util.js b/content/util.js index 92d28e0..2070f0f 100644 --- a/content/util.js +++ b/content/util.js @@ -25,18 +25,22 @@ var TV2Util = { /* preference functions */ _prefs: null, get prefs() { - if (!this._prefs) + if (!this._prefs) { this._prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch('tv2developer.'); + this._prefs.QueryInterface(Components.interfaces.nsIPrefBranch2); + } return this._prefs; }, /* default preference functions */ _defPrefs: null, get defPrefs() { - if (!this._defPrefs) + if (!this._defPrefs) { this._defPrefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getDefaultBranch('tv2developer.'); + this._defPrefs.QueryInterface(Components.interfaces.nsIPrefBranch2); + } return this._defPrefs; }, diff --git a/defaults/preferences/tv2developer.js b/defaults/preferences/tv2developer.js index d8b2d3c..72025af 100644 --- a/defaults/preferences/tv2developer.js +++ b/defaults/preferences/tv2developer.js @@ -4,3 +4,4 @@ pref('tv2developer.firstRun', true); pref('tv2developer.developer-initials', 'CHANGE-THIS'); pref('tv2developer.lastaction-linktype', 'tango/entry'); pref('tv2developer.php4sites', '2000,ally,annonceinfo,arkivsalg,auth,betaling,betalingsputnik,bryllup,dagsdato,finans,formel1,harris,hovsa,inc,it,konsol,loginsputnik,louth,million,piszulu,playmoney,podcast-files,pokermoney,rss,sms,spil,spil-deal,spil-million,spil-solo,sputnikmobil,swim,titoonic,trafikken,tv2,tv2r,tvsputnik,wimbledon,wptmoney,zulu'); +pref('tv2developer.useStatusBarMode', false); diff --git a/locale/da-DK/tv2developer.dtd b/locale/da-DK/tv2developer.dtd index 7eb570a..5cf4901 100644 --- a/locale/da-DK/tv2developer.dtd +++ b/locale/da-DK/tv2developer.dtd @@ -2,6 +2,7 @@ + @@ -10,8 +11,8 @@ - - + + diff --git a/locale/en-US/tv2developer.dtd b/locale/en-US/tv2developer.dtd index 4d3350e..6ecb06f 100644 --- a/locale/en-US/tv2developer.dtd +++ b/locale/en-US/tv2developer.dtd @@ -1,7 +1,8 @@ - + + @@ -10,8 +11,8 @@ - - + + diff --git a/version b/version index 9028ec6..d9df1bb 100644 --- a/version +++ b/version @@ -1 +1 @@ -0.10.5 +0.11.0