RealRaven2000 / SmartTemplates

Thunderbird Add-on: SmartTemplates
http://smarttemplates.quickfolders.org/
Other
25 stars 15 forks source link

Fix file picker which is broken in Thunderbird 125 #295

Closed RealRaven2000 closed 4 months ago

RealRaven2000 commented 5 months ago

According to bug 1878401 a parameter was changed in mozilla-central for the interface nsIFilePicker.init() - it will fail when we pass in window as first parameter. The c-c source code shows that instead we need to plug in window.browsingContext. This needs to be fixed in a way so that SmartTemplates stays compatible with Thunderbird 115 but is also compatible with Thunderbird 125 and later.

RealRaven2000 commented 5 months ago

To make this possible I made a wrapper function Util.getFileInitArg(window)which passes back either depending on the Thunderbird version:

    getFileInitArg: function(win) {
        if (!win) return null;
        if (this.versionGreaterOrEqual(this.AppverFull, "125")) {    
            return win.browsingContext;
        }
        return win;
    },

this can then be used within filepicker.init() like this:

    let fp = Cc['@mozilla.org/filepicker;1'].createInstance(Ci.nsIFilePicker);
    if (fileType=='folder') {
      fp.init(SmartTemplate4.Util.getFileInitArg(window), "", fp.modeGetFolder);
    } else {
      fp.init(SmartTemplate4.Util.getFileInitArg(window), "", fp.modeOpen); // second parameter: prompt
    }
RealRaven2000 commented 5 months ago

Here is a version that fixes the issue - compatible with Tb 128.*, tested on current beta 128.0b3.

smartTemplate-fx-4.6pre68.zip


To try the version above download zip file and drag the file into Thunderbird Add-ons Manager (do not extract contents, it won't install like that)

RealRaven2000 commented 4 months ago

Implemented in 4.6 - published 14/07/2024