fixing bug 110556 - double-clicking on a message in thread should reuse existing window. r=varada, sr=sspitzer (fixed problems in original patch from adam@cfar.umd.edu)

This commit is contained in:
ssu%netscape.com 2002-10-08 01:04:11 +00:00
parent f0b77e04cc
commit 58f4978f38
5 changed files with 90 additions and 7 deletions

View File

@ -34,7 +34,8 @@ Contributor(s):
<script type="application/x-javascript">
<![CDATA[
var _elementIDs = ["mailPaneConfig"];
var _elementIDs = ["mailPaneConfig",
"mailnewsDoubleClick2NewWindow"];
]]>
</script>
@ -50,7 +51,12 @@ Contributor(s):
</radiogroup>
</hbox>
<description>&chooseExp.label;</description>
<label value="&reuseExp.label;"/>
<hbox class="indent" align="center">
<radiogroup id="mailnewsDoubleClick2NewWindow" preftype="bool" prefstring="mailnews.reuse_message_window" orient="vertical">
<radio value="false" label="&reuseExpRadio0.label;" accesskey="&reuseExpRadio0.accesskey;" id="new"/>
<radio value="true" label="&reuseExpRadio1.label;" accesskey="&reuseExpRadio1.accesskey;" id="existing"/>
</radiogroup>
</hbox>
</groupbox>
</page>

View File

@ -21,8 +21,15 @@ Rights Reserved.
<!ENTITY pane.title "Windows">
<!ENTITY windowSettings.label "Windows">
<!ENTITY selectWindowLayout.label "Select the window layout you prefer for Mail:">
<!ENTITY selectWindowLayout.accesskey "e">
<!ENTITY selectWindowLayout.accesskey "l">
<!ENTITY chooseExp.label "Note: For this setting to take effect, you will need to exit and then restart Mail.">
<!ENTITY warnOnSendAccelKey.label "Confirm when using keyboard shortcut to send message">
<!ENTITY warnOnSendAccelKey.accesskey "o">
<!ENTITY reuseExp.label "When opening messages, display them in:">
<!ENTITY reuseExpRadio0.label "A new message window">
<!ENTITY reuseExpRadio0.accesskey "n">
<!ENTITY reuseExpRadio1.label "An existing message window">
<!ENTITY reuseExpRadio1.accesskey "e">
<!ENTITY reuseExpRadio2.label "A tab in an existing message window">
<!ENTITY reuseExpRadio2.accesskey "t">

View File

@ -33,6 +33,8 @@ var gOfflineManager;
var gWindowManagerInterface;
var gPrefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
var gPrintSettings = null;
var gWindowReuse = 0;
var gWindowID = null;
var gTimelineService = null;
var gTimelineEnabled = ("@mozilla.org;timeline-service;1" in Components.classes);
@ -1084,11 +1086,74 @@ function MsgOpenSelectedMessages()
var indices = GetSelectedIndices(dbView);
var numMessages = indices.length;
for (var i = 0; i < numMessages; i++) {
MsgOpenNewWindowForMessage(dbView.getURIForViewIndex(indices[i]),dbView.getFolderForViewIndex(indices[i]).URI);
gWindowReuse = gPrefs.getBoolPref("mailnews.reuse_message_window");
// This is a radio type button pref, currently with only 2 buttons.
// We need to keep the pref type as 'bool' for backwards compatibility
// with 4.x migrated prefs. For future radio button(s), please use another
// pref (either 'bool' or 'int' type) to describe it.
//
// gWindowReuse values: false, true
// false: open new standalone message window for each message
// true : reuse existing standalone message window for each message
if ((gWindowReuse) && (numMessages == 1)) {
if (!MsgOpenExistingWindowForMessage(gWindowID,dbView.getURIForViewIndex(indices[0]))) {
gWindowID = MsgOpenNewWindowForMessage(dbView.getURIForViewIndex(indices[0]),dbView.getFolderForViewIndex(indices[0]).URI);
}
} else {
for (var i = 0; i < numMessages; i++) {
gWindowID = MsgOpenNewWindowForMessage(dbView.getURIForViewIndex(indices[i]),dbView.getFolderForViewIndex(indices[i]).URI);
}
}
}
function MsgOpenExistingWindowForMessage(aWindowID, aMessageUri)
{
var messageUri;
var msgHdr = null;
if (!aMessageUri) {
var currentIndex = gDBView.QueryInterface(Components.interfaces.nsIOutlinerView).outlinerView.selection;
messageUri = gDBView.getURIForViewIndex(currentIndex);
}
else
messageUri = aMessageUri;
// be sure to pass in the current view....
if (!messageUri || !aWindowID)
return false;
try {
msgHdr = messenger.messageServiceFromURI(messageUri).messageURIToMsgHdr(messageUri);
if (!msgHdr)
return false;
if (msgHdr.folder.URI != aWindowID.gCurrentFolderUri) {
if ("CreateView" in aWindowID) {
// Reset the window's message uri and folder uri vars, and
// update the command handlers to what's going to be used.
// This has to be done before the call to CreateView().
aWindowID.gCurrentMessageUri = messageUri;
aWindowID.gCurrentFolderUri = msgHdr.folder.URI;
aWindowID.UpdateMailToolbar('MsgOpenExistingWindowForMessage');
aWindowID.CreateView(gDBView);
}
else
return false;
}
aWindowID.gDBView.loadMessageByMsgKey(msgHdr.messageKey);
}
catch (ex) {
dump("reusing existing standalone message window failed: " + ex + "\n");
return false;
}
// bring existing window to front
aWindowID.focus();
return true;
}
function MsgOpenNewWindowForMessage(messageUri, folderUri)
{
if (!messageUri)
@ -1111,8 +1176,9 @@ function MsgOpenNewWindowForMessage(messageUri, folderUri)
// be sure to pass in the current view....
if (messageUri && folderUri) {
window.openDialog( "chrome://messenger/content/messageWindow.xul", "_blank", "all,chrome,dialog=no,status,toolbar", messageUri, folderUri, gDBView );
return window.openDialog( "chrome://messenger/content/messageWindow.xul", "_blank", "all,chrome,dialog=no,status,toolbar", messageUri, folderUri, gDBView );
}
return null;
}
function CloseMailWindow()

View File

@ -268,6 +268,8 @@ pref("ldap_2.prefs_migrated", false);
pref("mailnews.confirm.moveFoldersToTrash", true);
pref("mailnews.reuse_message_window", true);
pref("mailnews.start_page.url", "chrome://messenger-region/locale/region.properties");
pref("mailnews.start_page.enabled", true);

View File

@ -268,6 +268,8 @@ pref("ldap_2.prefs_migrated", false);
pref("mailnews.confirm.moveFoldersToTrash", true);
pref("mailnews.reuse_message_window", true);
pref("mailnews.start_page.url", "chrome://messenger-region/locale/region.properties");
pref("mailnews.start_page.enabled", true);