Skip to content

Commit

Permalink
Add ability for Thunderbird <= v59 to open options
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-p committed Sep 12, 2018
1 parent c151c4e commit cade5ea
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 58 deletions.
22 changes: 22 additions & 0 deletions src/firefox/chrome/content/ff-overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@ var markdown_here = {
markdown_here.onMenuItemCommand(e);
},

// Called by the "open options" menuitem that's used by older versions of Thunderbird.
// Look for "#495" below to see when it's enabled.
openOptionsTab: function(e) {
var url = 'resource://markdown_here_common/options.html';
var windowMediator = Components.classes['@mozilla.org/appshell/window-mediator;1']
.getService(Components.interfaces.nsIWindowMediator);

windowMediator.getMostRecentWindow('mail:3pane')
.document.getElementById('tabmail')
.openTab('contentTab', {contentPage: url});
windowMediator.getMostRecentWindow('mail:3pane').focus();
},

// NOTE: Thunderbird seems to reuse compose windows, so this will only get
// called for every addtion new open message. Like, if a message is opened
// and send and another message is opened, this will only get called once.
Expand Down Expand Up @@ -112,6 +125,15 @@ var markdown_here = {
// initialization code
this.initialized = true;

// Only show the open-options menu item if we're on a version of Thunderbird where
// the options page won't open via the usual means (see #495).
var tbirdWithOptionsProblems =
(navigator.userAgent.indexOf('Thunderbird') >= 0 || navigator.userAgent.indexOf('Icedove') >= 0) &&
(Services.vc.compare(Services.appinfo.platformVersion, '59') < 0);
if (tbirdWithOptionsProblems) {
document.getElementById('tools-menu-markdown_here-open-options').hidden = false;
}

contextMenu = document.getElementById('contentAreaContextMenu');
if (!contextMenu) contextMenu = document.getElementById('msgComposeContext');
contextMenu.addEventListener('popupshowing', function (e) {
Expand Down
58 changes: 0 additions & 58 deletions src/firefox/chrome/content/options.xul

This file was deleted.

9 changes: 9 additions & 0 deletions src/firefox/chrome/content/tb-overlay.xul
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,13 @@
oncommand="markdown_here.onToolbarButtonCommand(event)" />
</toolbar>

<menu id="tasksMenu">
<menupopup id="taskPopup">
<!-- Initially hidden. Will be shown on platforms that need it. -->
<menuitem id="tools-menu-markdown_here-open-options" label="&moz_options_dlg_title;"
oncommand="markdown_here.openOptionsTab(event)"
hidden="true" />
</menupopup>
</menu>

</overlay>

0 comments on commit cade5ea

Please sign in to comment.