From 56d277663962de7c25809e598e660c6529055d84 Mon Sep 17 00:00:00 2001 From: itagagaki Date: Sat, 29 Oct 2022 17:47:39 +0900 Subject: [PATCH] Improve startup behavior - Ensures that the selected folder is on the screen after refreshing the pane. - Select startup folder after that. - Display the URI as well as the pretty name in the startup folder picker. - Revision 2.2.3 --- content/folderPane.js | 33 ++++++++++++++++++++++----------- content/ui.js | 5 +++-- manifest.json | 2 +- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/content/folderPane.js b/content/folderPane.js index 359a6fb..5420d2a 100644 --- a/content/folderPane.js +++ b/content/folderPane.js @@ -157,6 +157,22 @@ }; myPrefObserver.register(); + /* Refresh pane */ + function refreshPane(win) { + try { win.gFolderTreeView._rebuild(); } + catch (e) { setTimeout(refreshPane, 5, win); } + } + for (let win of Services.wm.getEnumerator("mail:3pane")) { + refreshPane(win); + } + + /* Ensures that the selected folder is on the screen. */ + { + const selected = gFolderTreeView.getSelectedFolders()[0]; + if (selected) { + gFolderTreeView._treeElement.ensureRowIsVisible(gFolderTreeView.getIndexOfFolder(selected)); + } + } /* For default startup folder */ const startup_folder = tbsf_prefs.getStringPref("startup_folder"); @@ -182,7 +198,7 @@ if (firstRun && inRestoreTab) { const folder = MailUtils.getExistingFolder(startup_folder); if (folder) - oldSelectFolder.call(this, folder, true); + oldSelectFolder.call(this, folder); else oldSelectFolder.call(this, x, y); firstRun = false; @@ -197,18 +213,13 @@ */ const folder = MailUtils.getExistingFolder(startup_folder); if (folder) { - gFolderTreeView.selectFolder(folder, true); + if (!gFolderTreeView.selectFolder(folder)) { + tblog.debug("selectFolder failed"); + } + } else { + tblog.debug(startup_folder+" not found"); } } } - /* Refresh pane */ - function refreshPane(win) { - try { win.gFolderTreeView._rebuild(); } - catch (e) { setTimeout(refreshPane, 5, win); } - } - for (let win of Services.wm.getEnumerator("mail:3pane")) { - refreshPane(win); - } - })() diff --git a/content/ui.js b/content/ui.js index dd46758..556cc8f 100644 --- a/content/ui.js +++ b/content/ui.js @@ -781,7 +781,7 @@ function on_pick_folder(aEvent) { let folder = aEvent.target._folder; let picker = document.getElementById("startupFolder"); picker.folder = folder; - picker.setAttribute("label", folder.prettyName); + picker.setAttribute("label", folder.prettyName+' ('+folder.URI+')'); tbsf_prefs.setStringPref("startup_folder", folder.URI); } @@ -793,7 +793,7 @@ function extra_on_load() { folder = MailUtils.getExistingFolder(startup_folder); if (folder) { picker.folder = folder; - picker.setAttribute("label", folder.prettyName); + picker.setAttribute("label", folder.prettyName+' ('+folder.URI+')'); } else { let menu = document.getElementById("startup_folder_method"); menu.value = "0"; @@ -816,4 +816,5 @@ function on_startup_folder_method_changed() { tbsf_prefs.setStringPref("startup_folder", ""); } document.getElementById("startup_folder_notice").style.display = notice ? "" : "none"; + } diff --git a/manifest.json b/manifest.json index 84bfd2f..fc6af77 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "Manually sort folders", "description": "An extension that allows you to change the way Thunderbird sorts folders in the folder pane.", - "version": "2.2.2", + "version": "2.2.3", "author": "Jonathan Protzenko and Itagaki Fumihiko", "homepage_url": "https://github.com/protz/Manually-Sort-Folders/wiki", "applications": {