mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-06 00:10:25 +00:00
fix for #56419. implement the "Go To Message Folder" feature from search.
r/sr=bienvenu.
This commit is contained in:
parent
efece6ef56
commit
46dde148e9
@ -265,15 +265,18 @@ interface nsIMsgDBView : nsISupports
|
||||
|
||||
readonly attribute string URIForFirstSelectedMessage;
|
||||
readonly attribute nsIMsgDBHdr hdrForFirstSelectedMessage;
|
||||
void loadMessageByMsgKey (in nsMsgKey aMsgKey);
|
||||
void reloadMessage();
|
||||
void loadMessageByMsgKey (in nsMsgKey aMsgKey);
|
||||
void reloadMessage();
|
||||
|
||||
readonly attribute unsigned long numSelected;
|
||||
readonly attribute nsMsgViewIndex msgToSelectAfterDelete;
|
||||
readonly attribute nsMsgViewIndex currentlyDisplayedMessage;
|
||||
|
||||
// we'll suppress displaying messages if the message pane is collapsed
|
||||
attribute boolean supressMsgDisplay;
|
||||
// used by "go to folder" feature
|
||||
void selectMsgByKey(in nsMsgKey key);
|
||||
|
||||
// we'll suppress displaying messages if the message pane is collapsed
|
||||
attribute boolean supressMsgDisplay;
|
||||
};
|
||||
|
||||
/* this interface is rapidly morphing from a command updater interface into a more generic
|
||||
|
@ -21,6 +21,7 @@
|
||||
* slucy@objectivesw.co.uk
|
||||
* Håkan Waara <hwaara@chello.se>
|
||||
* Jan Varga <varga@utcru.sk>
|
||||
* Seth Spitzer <sspitzer@netscape.com>
|
||||
*/
|
||||
|
||||
var gMessengerBundle;
|
||||
@ -30,6 +31,8 @@ var nsPrefBranch = null;
|
||||
var gOfflineManager;
|
||||
var gWindowManagerInterface;
|
||||
|
||||
var gPrefs = Components.classes["@mozilla.org/preferences;1"].getService(Components.interfaces.nsIPref);
|
||||
|
||||
// Disable the new account menu item if the account preference is locked.
|
||||
// Two other affected areas are the account central and the account manager
|
||||
// dialog.
|
||||
@ -39,7 +42,6 @@ function menu_new_init()
|
||||
var prefService = Components.classes["@mozilla.org/preferences-service;1"];
|
||||
prefService = prefService.getService();
|
||||
prefService = prefService.QueryInterface(Components.interfaces.nsIPrefService);
|
||||
|
||||
nsPrefBranch = prefService.getBranch(null);
|
||||
}
|
||||
var newAccountItem = document.getElementById('newAccountMenuItem');
|
||||
@ -606,7 +608,7 @@ function MsgForwardMessage(event)
|
||||
{
|
||||
var forwardType = 0;
|
||||
try {
|
||||
forwardType = pref.GetIntPref("mail.forward_message_mode");
|
||||
forwardType = gPrefs.GetIntPref("mail.forward_message_mode");
|
||||
} catch (e) {dump ("failed to retrieve pref mail.forward_message_mode");}
|
||||
|
||||
// mail.forward_message_mode could be 1, if the user migrated from 4.x
|
||||
@ -773,24 +775,31 @@ function MsgSaveAsTemplate()
|
||||
}
|
||||
}
|
||||
|
||||
function MsgOpenNewWindowForFolder(folderUri)
|
||||
function MsgOpenNewWindowForMsgHdr(hdr)
|
||||
{
|
||||
if(!folderUri)
|
||||
{
|
||||
var folder = GetLoadedMsgFolder();
|
||||
var folderResource = folder.QueryInterface(Components.interfaces.nsIRDFResource);
|
||||
folderUri = folderResource.Value;
|
||||
}
|
||||
MsgOpenNewWindowForFolder(hdr.folder.URI, hdr.messageKey);
|
||||
}
|
||||
|
||||
if(folderUri)
|
||||
{
|
||||
var layoutType = pref.GetIntPref("mail.pane_config");
|
||||
function MsgOpenNewWindowForFolder(uri, key)
|
||||
{
|
||||
var uriToOpen = uri;
|
||||
var keyToSelect = key;
|
||||
|
||||
if(layoutType == 0)
|
||||
window.openDialog( "chrome://messenger/content/messenger.xul", "_blank", "chrome,all,dialog=no", folderUri );
|
||||
else
|
||||
window.openDialog("chrome://messenger/content/mail3PaneWindowVertLayout.xul", "_blank", "chrome,all,dialog=no", folderUri );
|
||||
}
|
||||
if (!uriToOpen)
|
||||
{
|
||||
var folder = GetLoadedMsgFolder();
|
||||
var folderResource = folder.QueryInterface(Components.interfaces.nsIRDFResource);
|
||||
uriToOpen = folderResource.Value;
|
||||
}
|
||||
|
||||
if (uriToOpen) {
|
||||
var layoutType = gPrefs.GetIntPref("mail.pane_config");
|
||||
|
||||
if(layoutType == 0)
|
||||
window.openDialog("chrome://messenger/content/messenger.xul", "_blank", "chrome,all,dialog=no", {uri: uriToOpen, key: keyToSelect});
|
||||
else
|
||||
window.openDialog("chrome://messenger/content/mail3PaneWindowVertLayout.xul", "_blank", "chrome,all,dialog=no", {uri: uriToOpen, key: keyToSelect});
|
||||
}
|
||||
}
|
||||
|
||||
// passing in the view, so this will work for search and the thread pane
|
||||
@ -941,21 +950,21 @@ function MsgFilters()
|
||||
|
||||
function MsgViewAllHeaders()
|
||||
{
|
||||
pref.SetIntPref("mail.show_headers",2);
|
||||
gPrefs.SetIntPref("mail.show_headers",2);
|
||||
MsgReload();
|
||||
return true;
|
||||
}
|
||||
|
||||
function MsgViewNormalHeaders()
|
||||
{
|
||||
pref.SetIntPref("mail.show_headers",1);
|
||||
gPrefs.SetIntPref("mail.show_headers",1);
|
||||
MsgReload();
|
||||
return true;
|
||||
}
|
||||
|
||||
function MsgViewBriefHeaders()
|
||||
{
|
||||
pref.SetIntPref("mail.show_headers",0);
|
||||
gPrefs.SetIntPref("mail.show_headers",0);
|
||||
MsgReload();
|
||||
return true;
|
||||
}
|
||||
|
@ -483,7 +483,7 @@ Rights Reserved.
|
||||
<menuitem id="folderPaneContext-openNewWindow"
|
||||
label="&folderContextOpenNewWindow.label;"
|
||||
accesskey="&folderContextOpenNewWindow.accesskey;"
|
||||
oncommand="MsgOpenNewWindowForFolder(null);"/>
|
||||
oncommand="MsgOpenNewWindowForFolder(null,-1);"/>
|
||||
<menuitem id="folderPaneContext-subscribe"
|
||||
label="&folderContextSubscribe.label;"
|
||||
accesskey="&folderContextSubscribe.accesskey;"
|
||||
|
@ -51,6 +51,7 @@ var gCurrentlyDisplayedMessage=-1;
|
||||
var gActiveThreadPaneSortColumn = "";
|
||||
|
||||
var gStartFolderUri = null;
|
||||
var gStartMsgKey = -1;
|
||||
|
||||
//If we've loaded a message, set to true. Helps us keep the start page around.
|
||||
var gHaveLoadedMessage;
|
||||
@ -94,90 +95,94 @@ var folderListener = {
|
||||
}
|
||||
},
|
||||
|
||||
OnItemBoolPropertyChanged: function(item, property, oldValue, newValue) {},
|
||||
OnItemBoolPropertyChanged: function(item, property, oldValue, newValue) {},
|
||||
|
||||
OnItemUnicharPropertyChanged: function(item, property, oldValue, newValue){},
|
||||
OnItemPropertyFlagChanged: function(item, property, oldFlag, newFlag) {},
|
||||
OnItemPropertyFlagChanged: function(item, property, oldFlag, newFlag) {},
|
||||
|
||||
OnItemEvent: function(folder, event) {
|
||||
var eventType = event.GetUnicode();
|
||||
var eventType = event.GetUnicode();
|
||||
|
||||
if (eventType == "FolderLoaded") {
|
||||
if(folder)
|
||||
{
|
||||
var resource = folder.QueryInterface(Components.interfaces.nsIRDFResource);
|
||||
if(resource)
|
||||
{
|
||||
var uri = resource.Value;
|
||||
if(uri == gCurrentFolderToReroot)
|
||||
{
|
||||
gCurrentFolderToReroot="";
|
||||
var msgFolder = folder.QueryInterface(Components.interfaces.nsIMsgFolder);
|
||||
if(msgFolder)
|
||||
{
|
||||
msgFolder.endFolderLoading();
|
||||
RerootFolder(uri, msgFolder, gCurrentLoadingFolderViewType, gCurrentLoadingFolderViewFlags, gCurrentLoadingFolderSortType, gCurrentLoadingFolderSortOrder);
|
||||
gIsEditableMsgFolder = IsSpecialFolder(msgFolder, MSG_FOLDER_FLAG_DRAFTS);
|
||||
if (eventType == "FolderLoaded") {
|
||||
if (folder) {
|
||||
var resource = folder.QueryInterface(Components.interfaces.nsIRDFResource);
|
||||
if(resource) {
|
||||
var uri = resource.Value;
|
||||
if(uri == gCurrentFolderToReroot) {
|
||||
gCurrentFolderToReroot="";
|
||||
var msgFolder = folder.QueryInterface(Components.interfaces.nsIMsgFolder);
|
||||
if(msgFolder) {
|
||||
msgFolder.endFolderLoading();
|
||||
RerootFolder(uri, msgFolder, gCurrentLoadingFolderViewType, gCurrentLoadingFolderViewFlags, gCurrentLoadingFolderSortType, gCurrentLoadingFolderSortOrder);
|
||||
gIsEditableMsgFolder = IsSpecialFolder(msgFolder, MSG_FOLDER_FLAG_DRAFTS);
|
||||
|
||||
gCurrentLoadingFolderSortType = 0;
|
||||
gCurrentLoadingFolderSortOrder = 0;
|
||||
gCurrentLoadingFolderViewType = 0;
|
||||
gCurrentLoadingFolderViewFlags = 0;
|
||||
gCurrentLoadingFolderSortType = 0;
|
||||
gCurrentLoadingFolderSortOrder = 0;
|
||||
gCurrentLoadingFolderViewType = 0;
|
||||
gCurrentLoadingFolderViewFlags = 0;
|
||||
|
||||
SetFocusThreadPane();
|
||||
var scrolled = false;
|
||||
if (gNextMessageAfterLoad)
|
||||
{
|
||||
var type = gNextMessageAfterLoad;
|
||||
gNextMessageAfterLoad = null;
|
||||
SetFocusThreadPane();
|
||||
var scrolled = false;
|
||||
|
||||
// scroll to and select the proper message
|
||||
scrolled = ScrollToMessage(type, true, true /* selectMessage */);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(uri == gCurrentLoadingFolderURI)
|
||||
{
|
||||
gCurrentLoadingFolderURI = "";
|
||||
//Now let's select the first new message if there is one
|
||||
var beforeScrollToNew;
|
||||
if(showPerformance) {
|
||||
beforeScrollToNew = new Date();
|
||||
}
|
||||
if (!scrolled) {
|
||||
// if we didn't just scroll, scroll to the first new message
|
||||
// don't select it though
|
||||
scrolled = ScrollToMessage(nsMsgNavigationType.firstNew, true, false /* selectMessage */);
|
||||
if (gStartMsgKey != -1) {
|
||||
// select the desired message
|
||||
gDBView.selectMsgByKey(gStartMsgKey);
|
||||
gStartMsgKey = -1;
|
||||
|
||||
// now scroll to it
|
||||
var indicies = GetSelectedIndices(gDBView);
|
||||
EnsureRowInThreadOutlinerIsVisible(indicies[0]);
|
||||
scrolled = true;
|
||||
}
|
||||
if (gNextMessageAfterLoad) {
|
||||
var type = gNextMessageAfterLoad;
|
||||
gNextMessageAfterLoad = null;
|
||||
|
||||
// scroll to and select the proper message
|
||||
scrolled = ScrollToMessage(type, true, true /* selectMessage */);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(uri == gCurrentLoadingFolderURI) {
|
||||
gCurrentLoadingFolderURI = "";
|
||||
//Now let's select the first new message if there is one
|
||||
var beforeScrollToNew;
|
||||
if(showPerformance) {
|
||||
beforeScrollToNew = new Date();
|
||||
}
|
||||
if (!scrolled) {
|
||||
// if we didn't just scroll, scroll to the first new message
|
||||
// don't select it though
|
||||
scrolled = ScrollToMessage(nsMsgNavigationType.firstNew, true, false /* selectMessage */);
|
||||
|
||||
// if we failed to find a new message, scroll to the top
|
||||
if (!scrolled) {
|
||||
EnsureRowInThreadOutlinerIsVisible(0);
|
||||
}
|
||||
}
|
||||
// if we failed to find a new message, scroll to the top
|
||||
if (!scrolled) {
|
||||
EnsureRowInThreadOutlinerIsVisible(0);
|
||||
}
|
||||
}
|
||||
if(showPerformance) {
|
||||
var afterScrollToNew = new Date();
|
||||
var timeToScroll = (afterScrollToNew.getTime() - beforeScrollToNew.getTime())/1000;
|
||||
|
||||
if(showPerformance) {
|
||||
var afterScrollToNew = new Date();
|
||||
var timeToScroll = (afterScrollToNew.getTime() - beforeScrollToNew.getTime())/1000;
|
||||
|
||||
var afterFolderLoadTime = new Date();
|
||||
var timeToLoad = (afterFolderLoadTime.getTime() - gBeforeFolderLoadTime.getTime())/1000;
|
||||
dump("Time to load " + uri + " is " + timeToLoad + " seconds\n");
|
||||
dump("of which scrolling to new is " + timeToScroll + " seconds\n");
|
||||
}
|
||||
SetBusyCursor(window, false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} else if (eventType == "DeleteOrMoveMsgCompleted") {
|
||||
HandleDeleteOrMoveMsgCompleted(folder);
|
||||
}
|
||||
else if (eventType == "DeleteOrMoveMsgFailed") {
|
||||
HandleDeleteOrMoveMsgFailed(folder);
|
||||
}
|
||||
else if (eventType == "CompactCompleted") {
|
||||
HandleCompactCompleted(folder);
|
||||
}
|
||||
var afterFolderLoadTime = new Date();
|
||||
var timeToLoad = (afterFolderLoadTime.getTime() - gBeforeFolderLoadTime.getTime())/1000;
|
||||
dump("Time to load " + uri + " is " + timeToLoad + " seconds\n");
|
||||
dump("of which scrolling to new is " + timeToScroll + " seconds\n");
|
||||
}
|
||||
SetBusyCursor(window, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (eventType == "DeleteOrMoveMsgCompleted") {
|
||||
HandleDeleteOrMoveMsgCompleted(folder);
|
||||
}
|
||||
else if (eventType == "DeleteOrMoveMsgFailed") {
|
||||
HandleDeleteOrMoveMsgFailed(folder);
|
||||
}
|
||||
else if (eventType == "CompactCompleted") {
|
||||
HandleCompactCompleted(folder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -441,11 +446,13 @@ function OnLoadMessenger()
|
||||
//set up correctly.
|
||||
if ("arguments" in window && window.arguments[0])
|
||||
{
|
||||
gStartFolderUri = window.arguments[0];
|
||||
gStartFolderUri = window.arguments[0].uri;
|
||||
gStartMsgKey = window.arguments[0].key;
|
||||
}
|
||||
else
|
||||
{
|
||||
gStartFolderUri = null;
|
||||
gStartMsgKey = -1;
|
||||
}
|
||||
|
||||
setTimeout("loadStartFolder(gStartFolderUri);", 0);
|
||||
@ -920,7 +927,7 @@ function FolderPaneDoubleClick(folderIndex, event)
|
||||
{
|
||||
// Open a new msg window only if we are double clicking on
|
||||
// folders or newsgroups.
|
||||
MsgOpenNewWindowForFolder(folderResource.Value);
|
||||
MsgOpenNewWindowForFolder(folderResource.Value, -1 /* key */);
|
||||
|
||||
// double clicking should not toggle the open / close state of the
|
||||
// folder. this will happen if we don't prevent the event from
|
||||
@ -1120,6 +1127,10 @@ function SelectMessage(messageUri)
|
||||
{
|
||||
// this isn't going to work anymore
|
||||
dump("XXX fix this or remove SelectMessage()\n");
|
||||
// if you need this to work, do something like this:
|
||||
// from the messageUri, get the nsIMsgDBHdr
|
||||
// from the hdr, get the key, then do:
|
||||
// gDBView.selectMsgByKey(key);
|
||||
}
|
||||
|
||||
function ReloadMessage()
|
||||
|
@ -61,6 +61,7 @@ var nsSearchResultsController =
|
||||
case "button_delete":
|
||||
case "cmd_open":
|
||||
case "file_message_button":
|
||||
case "goto_folder_button":
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@ -69,12 +70,21 @@ var nsSearchResultsController =
|
||||
|
||||
// this controller only handles commands
|
||||
// that rely on items being selected in
|
||||
// the threadpane.
|
||||
// the search results pane.
|
||||
isCommandEnabled: function(command)
|
||||
{
|
||||
var enabled = true;
|
||||
if (GetNumSelectedMessages() <= 0)
|
||||
enabled = false;
|
||||
|
||||
switch (command) {
|
||||
case "goto_folder_button":
|
||||
if (GetNumSelectedMessages() != 1)
|
||||
enabled = false;
|
||||
break;
|
||||
default:
|
||||
if (GetNumSelectedMessages() <= 0)
|
||||
enabled = false;
|
||||
break;
|
||||
}
|
||||
|
||||
return enabled;
|
||||
},
|
||||
@ -90,6 +100,10 @@ var nsSearchResultsController =
|
||||
MsgDeleteSelectedMessages();
|
||||
return true;
|
||||
|
||||
case "goto_folder_button":
|
||||
GoToFolder();
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@ -604,6 +618,11 @@ function MoveMessageInSearch(destFolder)
|
||||
}
|
||||
}
|
||||
|
||||
function GoToFolder()
|
||||
{
|
||||
MsgOpenNewWindowForMsgHdr(gSearchView.hdrForFirstSelectedMessage);
|
||||
}
|
||||
|
||||
function BeginDragThreadPane(event)
|
||||
{
|
||||
// no search pane dnd yet
|
||||
|
@ -65,6 +65,7 @@ Rights Reserved.
|
||||
oncommandupdate="goUpdateSearchItems(this)">
|
||||
<command id="cmd_open" oncommand="goDoCommand('cmd_open')" disabled="true"/>
|
||||
<command id="button_delete" oncommand="goDoCommand('button_delete')" disabled="true"/>
|
||||
<command id="goto_folder_button" oncommand="goDoCommand('goto_folder_button')" disabled="true"/>
|
||||
<command id="file_message_button"/>
|
||||
</commandset>
|
||||
</commands>
|
||||
@ -176,6 +177,7 @@ Rights Reserved.
|
||||
</button>
|
||||
|
||||
<button label="&deleteButton.label;" id="deleteButton" command="button_delete"/>
|
||||
<button label="&goToFolderButton.label;" id="goToFolderButton" command="goto_folder_button" accesskey="&goToFolderButton.accesskey;" />
|
||||
<spacer flex="1" />
|
||||
</vbox>
|
||||
</groupbox>
|
||||
|
@ -15,3 +15,5 @@
|
||||
<!ENTITY fileHereMenu.label "File Here">
|
||||
<!ENTITY fileHereMenu.accesskey "F">
|
||||
<!ENTITY fileButton.label "File">
|
||||
<!ENTITY goToFolderButton.label "Go to Message Folder">
|
||||
<!ENTITY goToFolderButton.accesskey "G">
|
||||
|
@ -4523,4 +4523,13 @@ NS_IMETHODIMP nsMsgDBView::IsSorted(PRBool *_retval)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgDBView::SelectMsgByKey(nsMsgKey aKey)
|
||||
{
|
||||
nsMsgKeyArray keyArray;
|
||||
keyArray.Add(aKey);
|
||||
|
||||
// use RestoreSelection() so that we'll select (and load) the desired message
|
||||
nsresult rv = RestoreSelection(&keyArray);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -451,3 +451,17 @@ NS_IMETHODIMP nsMsgSearchDBView::Sort(nsMsgViewSortTypeValue sortType, nsMsgView
|
||||
}
|
||||
|
||||
|
||||
// if nothing selected, return an NS_ERROR
|
||||
NS_IMETHODIMP
|
||||
nsMsgSearchDBView::GetHdrForFirstSelectedMessage(nsIMsgDBHdr **hdr)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(hdr);
|
||||
PRInt32 index;
|
||||
|
||||
nsresult rv = mOutlinerSelection->GetCurrentIndex(&index);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = GetMsgHdrForViewIndex(index, hdr);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -58,6 +58,7 @@ public:
|
||||
NS_IMETHOD Sort(nsMsgViewSortTypeValue sortType, nsMsgViewSortOrderValue sortOrder);
|
||||
NS_IMETHOD DoCommand(nsMsgViewCommandTypeValue command);
|
||||
NS_IMETHOD DoCommandWithFolder(nsMsgViewCommandTypeValue command, nsIMsgFolder *destFolder);
|
||||
NS_IMETHOD GetHdrForFirstSelectedMessage(nsIMsgDBHdr **hdr);
|
||||
// override to get location
|
||||
NS_IMETHOD GetCellText(PRInt32 aRow, const PRUnichar * aColID, PRUnichar ** aValue);
|
||||
virtual nsresult GetMsgHdrForViewIndex(nsMsgViewIndex index, nsIMsgDBHdr **msgHdr);
|
||||
|
Loading…
Reference in New Issue
Block a user