Skip to content

Commit

Permalink
Default preferences need to be loaded in service
Browse files Browse the repository at this point in the history
Move the loading of default preferences from the overlay that loads
the keyconfig window to the service that loads when Thunderbird starts
up, so the default preferences are loaded even when the user never
opens the keyconfig window (which is the normal case!).
  • Loading branch information
jikamens committed Dec 18, 2017
1 parent 1673079 commit d14613d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
18 changes: 18 additions & 0 deletions components/keyconfig-service.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Components.utils.import("chrome://keyconfig/content/defaultPreferencesLoader.jsm");

function NSGetModule(compMgr, fileSpec) { return Module; }
function NSGetFactory() { return Factory; }

Expand Down Expand Up @@ -60,6 +62,22 @@ keyconfigService.prototype = {
},

init: function(event) {
// Current Thunderbird nightly builds do not load default preferences
// from overlay add-ons. They're probably going to fix this, but it may go
// away again at some point in the future, and in any case we'll need to do
// it ourselves when we convert from overlay to bootstrapped, and there
// shouldn't be any harm in setting the default values of preferences twice
// (i.e., both Thunderbird and our code doing it).
// This is in a try/catch because if it fails it's probably because
// setStringPref failed, in which case we're running inside an earlier
// application version which has already loaded the default preferences
// automatically.
try {
var loader = new DefaultPreferencesLoader();
loader.parseUri(
"chrome://keyconfig-defaults/content/preferences/keyconfig.js");
} catch (ex) {}

if(event && event.eventPhase != 2) return;

this.removeEventListener("pageshow",this.keyconfig.service.init,false);
Expand Down
18 changes: 0 additions & 18 deletions content/keyconfig.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
Components.utils.import("chrome://keyconfig/content/defaultPreferencesLoader.jsm");

var gPrefService = Components.classes['@mozilla.org/preferences-service;1']
.getService(Components.interfaces.nsIPrefService).getBranch("");
var gUnicodeConverter = Components.classes['@mozilla.org/intl/scriptableunicodeconverter']
Expand All @@ -19,22 +17,6 @@ var gVKNames = [];
var gReverseNames;

function onLoad() {
// Current Thunderbird nightly builds do not load default preferences
// from overlay add-ons. They're probably going to fix this, but it may go
// away again at some point in the future, and in any case we'll need to do
// it ourselves when we convert from overlay to bootstrapped, and there
// shouldn't be any harm in setting the default values of preferences twice
// (i.e., both Thunderbird and our code doing it).
// This is in a try/catch because if it fails it's probably because
// setStringPref failed, in which case we're running inside an earlier
// application version which has already loaded the default preferences
// automatically.
try {
var loader = new DefaultPreferencesLoader();
loader.parseUri(
"chrome://keyconfig-defaults/content/preferences/keyconfig.js");
} catch (ex) {}

gUnicodeConverter.charset = "UTF-8";

gExtra2 = document.documentElement.getButton("extra2");
Expand Down
2 changes: 1 addition & 1 deletion install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<rdf:Description rdf:about="urn:mozilla:install-manifest">
<id>[email protected]</id>
<name>Dorando keyconfig</name>
<version>2017.1</version>
<version>2017.2</version>
<creator>Dorando</creator>
<contributor>Hadar Hagai</contributor>
<contributor>trlkly</contributor>
Expand Down

0 comments on commit d14613d

Please sign in to comment.