Dynamically generate the correct 3-pane. Obsolete Msg3PaneWindowVertLayout.xul

Land the new vertical 3-pane for thunderbird. Folder pane | Thread Pane | Message pane.
new pref UI for selecting three 3-pane configurations.
This commit is contained in:
scott%scott-macgregor.org 2003-07-12 20:40:22 +00:00
parent 42a318716d
commit f34c5121ac
11 changed files with 173 additions and 179 deletions

View File

@ -128,6 +128,7 @@ pref("mail.strictly_mime_headers", true);
pref("mail.file_attach_binary", false);
pref("mail.show_headers", 1); // some
pref("mail.pane_config", 0);
pref("mail.pane_config.dynamic", 0); // new pref used for dynamic pane configuration
pref("mail.addr_book.mapit_url.format", "chrome://messenger-region/locale/region.properties");
// the format for "mail.addr_book.quicksearchquery.format" is:
@ -290,12 +291,6 @@ pref("mailnews.start_page.enabled", true);
pref("mailnews.remember_selected_message", true);
pref("mail.toolbars.showbutton.file", true);
pref("mail.toolbars.showbutton.next", true);
pref("mail.toolbars.showbutton.junk", true);
pref("mail.toolbars.showbutton.print", true);
pref("mail.toolbars.showbutton.stop", true);
pref("mailnews.account_central_page.url", "chrome://messenger/locale/messenger.properties");
/* default prefs for Mozilla 5.0 */

View File

@ -47,6 +47,7 @@
<dialog xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
id="aboutdlg"
buttons="accept"
onload="onLoad();"
title="&aboutDialog.title;"
@ -56,7 +57,10 @@
<![CDATA[
function onLoad() {
var versionField = document.getElementById("versionField");
versionField.value = navigator.vendorSub + ' (' + navigator.productSub + ')';
var brandShortNameEl = document.getElementById("brandShortName");
versionField.value = brandShortNameEl.firstChild.nodeValue + ' ' + navigator.vendorSub + ' (' + navigator.productSub + ')';
versionField.size = versionField.value.length - 5; // total hack..we are calculating a length that is too long,
// which keeps the text box from looking centered in the dialog.
}
]]>
</script>

View File

@ -621,7 +621,7 @@ function CreateDBView(msgFolder, viewType, viewFlags, sortType, sortOrder)
// based on the collapsed state of the thread pane/message pane splitter,
// suppress message display if appropriate.
gDBView.suppressMsgDisplay = IsThreadAndMessagePaneSplitterCollapsed();
gDBView.suppressMsgDisplay = IsMessagePaneCollapsed();
UpdateSortIndicators(gCurSortType, sortOrder);
}
@ -658,8 +658,13 @@ function GetSelectedFolderResource()
return GetFolderResource(folderTree, startIndex.value);
}
function NotifyChangedMessagePaneVisibility(now_hidden)
function ChangeMessagePaneVisibility(now_hidden)
{
if (gDBView) {
// the collapsed state is the state after we released the mouse
// so we take it as it is
gDBView.suppressMsgDisplay = now_hidden;
}
var event = document.createEvent('Events');
if (now_hidden) {
event.initEvent('messagepane-hide', false, true);
@ -674,11 +679,7 @@ function OnMouseUpThreadAndMessagePaneSplitter()
{
// the collapsed state is the state after we released the mouse
// so we take it as it is
var now_hidden = IsThreadAndMessagePaneSplitterCollapsed();
if (gDBView) {
gDBView.suppressMsgDisplay = now_hidden;
}
NotifyChangedMessagePaneVisibility(now_hidden);
ChangeMessagePaneVisibility(IsMessagePaneCollapsed());
}
function FolderPaneSelectionChange()

View File

@ -14,19 +14,7 @@
// which is included by most clients.
function toMessengerWindow()
{
var pref = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
var windowDoc = "chrome://messenger/content/messenger.xul";
try
{
var layoutType = pref.getIntPref("mail.pane_config");
windowDoc = !layoutType ? "chrome://messenger/content/messenger.xul" :
"chrome://messenger/content/mail3PaneWindowVertLayout.xul";
}
catch(ex)
{
}
toOpenWindowByType("mail:3pane", windowDoc);
toOpenWindowByType("mail:3pane", "chrome://messenger/content/");
}
function toAddressBook()

View File

@ -58,12 +58,8 @@ var folderDataSource;
var accountCentralBox = null;
var gSearchBox = null;
var gThreadPane = null;
var gThreadPaneSplitter = null;
var gMessagePaneBox = null;
var gAccountCentralLoaded = false;
var gFakeAccountPageLoaded = false;
var gPaneConfig = null;
//End progress and Status variables
// for checking if the folder loaded is Draft or Unsent which msg is editable
@ -188,10 +184,6 @@ function CreateMailWindowGlobals()
accountCentralBox = document.getElementById("accountCentralBox");
gSearchBox = document.getElementById("searchBox");
gThreadPane = document.getElementById("threadTree");
gThreadPaneSplitter = document.getElementById("threadpane-splitter");
gMessagePaneBox = document.getElementById("messagepanebox");
gPaneConfig = pref.getIntPref("mail.pane_config");
}
function InitMsgWindow()
@ -496,26 +488,19 @@ function loadStartPage() {
// Load iframe in the AccountCentral box with corresponding page
function ShowAccountCentral()
{
var acctCentralPage = pref.getComplexValue("mailnews.account_central_page.url",
Components.interfaces.nsIPrefLocalizedString).data;
gSearchBox.setAttribute("collapsed", "true");
gThreadPane.setAttribute("collapsed", "true");
gMessagePaneBox.setAttribute("collapsed", "true");
accountCentralBox.removeAttribute("collapsed");
window.frames["accountCentralPane"].location = acctCentralPage;
gAccountCentralLoaded = true;
try
{
switch (gPaneConfig)
{
case 0:
break;
case 1:
gThreadPaneSplitter.setAttribute("collapsed", "true");
break;
}
var acctCentralPage = pref.getComplexValue("mailnews.account_central_page.url",
Components.interfaces.nsIPrefLocalizedString).data;
GetMessagePane().collapsed = true;
document.getElementById("threadpane-splitter").collapsed = true;
gSearchBox.collapsed = true;
GetThreadTree().collapsed = true;
document.getElementById("accountCentralBox").collapsed = false;
window.frames["accountCentralPane"].location = acctCentralPage;
if (!IsFolderPaneCollapsed())
GetFolderTree().focus();
gAccountCentralLoaded = true;
}
catch (ex)
{
@ -529,24 +514,16 @@ function ShowAccountCentral()
// box and display message box.
function HideAccountCentral()
{
gSearchBox.removeAttribute("collapsed");
gThreadPane.removeAttribute("collapsed");
gMessagePaneBox.removeAttribute("collapsed");
accountCentralBox.setAttribute("collapsed", "true");
window.frames["accountCentralPane"].location = "about:blank";
gAccountCentralLoaded = false;
try
{
switch (gPaneConfig)
{
case 0:
break;
case 1:
gThreadPaneSplitter.removeAttribute("collapsed");
break;
}
window.frames["accountCentralPane"].location = "about:blank";
document.getElementById("accountCentralBox").collapsed = true;
GetThreadTree().collapsed = false;
gSearchBox.collapsed = false;
var threadPaneSplitter = document.getElementById("threadpane-splitter");
threadPaneSplitter.collapsed = false;
GetMessagePane().collapsed = threadPaneSplitter.getAttribute("state") == "collapsed";
gAccountCentralLoaded = false;
}
catch (ex)
{
@ -635,42 +612,3 @@ function SetKeywords(aKeywords)
// cache the keywords
gLastKeywords = aKeywords;
}
function ShowHideToolBarButtons()
{
return;
}
function AddToolBarPrefListener()
{
try {
var pbi = pref.QueryInterface(Components.interfaces.nsIPrefBranchInternal);
pbi.addObserver(gMailToolBarPrefListener.domain, gMailToolBarPrefListener, false);
} catch(ex) {
dump("Failed to observe prefs: " + ex + "\n");
}
}
function RemoveToolBarPrefListener()
{
try {
var pbi = pref.QueryInterface(Components.interfaces.nsIPrefBranchInternal);
pbi.removeObserver(gMailToolBarPrefListener.domain, gMailToolBarPrefListener);
} catch(ex) {
dump("Failed to remove pref observer: " + ex + "\n");
}
}
// Pref listener constants
const gMailToolBarPrefListener =
{
domain: "mail.toolbars.showbutton",
observe: function(subject, topic, prefName)
{
// verify that we're changing a button pref
if (topic != "nsPref:changed")
return;
document.getElementById("button-" + prefName.substr(this.domain.length+1)).hidden = !(pref.getBoolPref(prefName));
}
};

View File

@ -169,7 +169,8 @@ function view_init()
{
var message_menuitem_hidden = message_menuitem.getAttribute("hidden");
if(message_menuitem_hidden != "true"){
message_menuitem.setAttribute('checked',!IsThreadAndMessagePaneSplitterCollapsed());
message_menuitem.setAttribute('checked', !IsMessagePaneCollapsed());
message_menuitem.setAttribute('disabled', gAccountCentralLoaded);
}
}
@ -1100,12 +1101,8 @@ function MsgOpenNewWindowForFolder(uri, key)
// will return the message that is highlighted.
uriToOpen = GetSelectedFolderURI();
if (uriToOpen) {
// get the messenger window open service and ask it to open a new window for us
var mailWindowService = Components.classes["@mozilla.org/messenger/windowservice;1"].getService(Components.interfaces.nsIMessengerWindowService);
if (mailWindowService)
mailWindowService.openMessengerWindowWithUri("mail:3pane", uriToOpen, keyToSelect);
}
if (uriToOpen)
window.openDialog("chrome://messenger/content/", "_blank", "chrome,all,dialog=no", uriToOpen, keyToSelect);
}
// passing in the view, so this will work for search and the thread pane

View File

@ -255,8 +255,6 @@ function delayedOnLoadMessageWindow()
AddMailOfflineObserver();
CreateMailWindowGlobals();
CreateMessageWindowGlobals();
AddToolBarPrefListener();
ShowHideToolBarButtons()
verifyAccounts(null);
InitMsgWindow();
@ -477,7 +475,6 @@ function HideMenus()
function OnUnloadMessageWindow()
{
RemoveToolBarPrefListener();
// FIX ME - later we will be able to use onunload from the overlay
OnUnloadMsgHeaderPane();

View File

@ -94,7 +94,6 @@
events="focus"
oncommandupdate="FocusRingUpdate_Mail()"/>
<commandset id="tasksCommands"/>
<command id="toggleSidebar"/>
</commandset>
<broadcasterset id="mailBroadcasters">
@ -104,7 +103,6 @@
</broadcasterset>
<keyset id="mailKeys">
<key id="showHideSidebar"/>
<keyset id="tasksKeys"/>
</keyset>
@ -140,14 +138,19 @@
<toolbox id="mail-toolbox" class="toolbox-top">
</toolbox>
<hbox style="height:100px" flex="1">
<vbox id="folderPaneBox" flex="1" autostretch="always" persist="width">
<!-- when we move to the alternate 3-pane, mailContentWrapper gets toggled to a vertical orientation -->
<box id="mailContentWrapper" orient="horizontal" flex="1">
<hbox id="mailContent" flex="1">
<vbox id="folderPaneBox" minwidth="100" width="200" persist="collapsed width">
<sidebarheader id="folderPaneHeader" align="center">
<label id="folderpane-title" value="&folderPaneHeader.label;"/>
</sidebarheader>
<tree id="folderTree" class="plain focusring" flex="1" seltype="single" style="min-width: 100px;"
<tree id="folderTree" class="plain focusring" flex="1" seltype="single"
context="folderPaneContext"
persist="collapsed width height"
disableKeyNavigation="true"
datasources="rdf:null"
hidecolumnpicker="true"
@ -237,16 +240,14 @@
<splitter id="gray_vertical_splitter" collapse="before" persist="state"/>
<vbox id="messengerBox" flex="1" persist="width">
<!-- collapse this box. since we are loading on a timeout, the user will see it "jump" if it isn't collapsed" -->
<vbox id="accountCentralBox" flex="1" collapsed="true">
<iframe name="accountCentralPane" flex="1" src="about:blank"/>
</vbox>
<vbox flex="1">
<hbox id="searchBox"/>
<box orient="vertical" id="messagesBox" flex="1">
<hbox id="messengerBox" flex="1" minheight="100" height="100" persist="height">
<vbox id="threadPaneBox" flex="1">
<tree id="threadTree" flex="2" enableColumnDrag="true" _selectDelay="500" class="plain focusring"
disableKeyNavigation="true"
persist="height"
style="height:0px"
context="threadPaneContext"
onkeypress="ThreadPaneKeyPress(event);"
onselect="ThreadPaneSelectionChanged();">
@ -302,28 +303,32 @@
</treecols>
<treechildren ondraggesture="BeginDragThreadPane(event);"/>
</tree>
<vbox id="accountCentralBox" flex="1" collapsed="true">
<iframe name="accountCentralPane" width="150" flex="1" src="about:blank"/>
</vbox>
</vbox>
</hbox>
<!-- if you change this id, please change GetThreadAndMessagePaneSplitter() and MsgToggleMessagePane() -->
<splitter collapse="after" persist="state"
onmouseup="OnMouseUpThreadAndMessagePaneSplitter()"
id="threadpane-splitter"/>
<vbox id="messagepanebox" flex="3" persist="collapsed height" onclick="contentAreaClick(event);">
<splitter id="threadpane-splitter" collapse="after" persist="state"
onmouseup="OnMouseUpThreadAndMessagePaneSplitter()"/>
<vbox id="messagepanebox" flex="2" minheight="100" height="200" persist="collapsed height width">
<hbox id="junkBar"/>
<hbox id="msgHeaderView"/>
<browser id="messagepane" context="messagePaneContext"
style="height: 0px; min-height: 1px" flex="1" name="messagepane"
<browser id="messagepane" context="messagePaneContext" autofind="false"
minheight="1" height="0" flex="1" name="messagepane"
disablehistory="true" type="content-primary" src="about:blank"
disablesecurity="true" autofind="false"/>
disablesecurity="true" onclick="contentAreaClick(event);"/>
</vbox>
</box>
</vbox>
</hbox>
</box> <!-- end of mailContentWrapper -->
<statusbar id="status-bar" class="chromeclass-status mailwindow-statusbar">
<statusbarpanel id="unreadMessageCount" style="min-width: 5px"/>
<statusbarpanel id="totalMessageCount" style="min-width: 5px"/>
<statusbarpanel id="unreadMessageCount"/>
<statusbarpanel id="totalMessageCount"/>
</statusbar>
</window>

View File

@ -30,6 +30,10 @@ const nsMsgKey_None = 0xFFFFFFFF;
const nsMsgViewIndex_None = 0xFFFFFFFF;
const kMailCheckOncePrefName = "mail.startup.enabledMailCheckOnce";
const kStandardPaneConfig = 0;
const kWidePaneConfig = 1;
const kVerticalPaneConfig = 2;
var gFolderTree;
var gMessagePane;
var gThreadTree;
@ -38,6 +42,7 @@ var gSearchInput;
var gThreadAndMessagePaneSplitter = null;
var gUnreadCount = null;
var gTotalCount = null;
var gCurrentPaneConfig = 0;
var gCurrentLoadingFolderURI;
var gCurrentFolderToReroot;
@ -616,20 +621,109 @@ var gThreePaneIncomingServerListener = {
}
}
// aMsgWindowInitialized: false if we are calling from the onload handler, otherwise true
function UpdateMailPaneConfig(aMsgWindowInitialized) {
var paneConfig = pref.getIntPref("mail.pane_config.dynamic");
// don't do anything if we are already in the correct configuration
if (paneConfig == gCurrentPaneConfig)
return;
var mailContentWrapper = document.getElementById("mailContentWrapper");
var messagesBox = document.getElementById("messagesBox");
var messagePaneBox = GetMessagePane();
var msgPaneReRooted = false;
var threadPaneSplitter = GetThreadAndMessagePaneSplitter();
// the only element we need to re-root is the message pane.
var desiredMsgPaneParentId = (paneConfig == "0" || paneConfig == "2") ? "messagesBox" : "mailContentWrapper";
if (messagePaneBox.parentNode.id != desiredMsgPaneParentId)
{
var messagePaneParent = document.getElementById(messagePaneBox.parentNode.id);
messagePaneParent.removeChild(threadPaneSplitter);
messagePaneParent.removeChild(messagePaneBox);
var messagePaneNewParent = document.getElementById(desiredMsgPaneParentId);
messagePaneNewParent.appendChild(threadPaneSplitter);
messagePaneNewParent.appendChild(messagePaneBox);
msgPaneReRooted = true;
}
// now for each config, handle any extra clean up to create that view (such as changing a box orientation)
if (paneConfig == kStandardPaneConfig) // standard 3-Pane Layout
{
messagePaneBox.removeAttribute("minwidth");
threadPaneSplitter.setAttribute("orient", "vertical");
// finally, make sure mailContentWrapper has the correct orientation
mailContentWrapper.setAttribute("orient", "horizontal");
messagesBox.setAttribute("orient", "vertical");
}
else if (paneConfig == kWidePaneConfig) // "Wide" Window Pane Layout
{
messagePaneBox.removeAttribute("minwidth");
threadPaneSplitter.setAttribute("orient", "vertical");
// finally, make sure mailContentWrapper has the correct orientation
mailContentWrapper.setAttribute("orient", "vertical");
messagesBox.setAttribute("orient", "vertical");
}
else if (paneConfig == kVerticalPaneConfig) // Vertical Pane Layout
{
messagesBox.setAttribute("orient", "horizontal");
threadPaneSplitter.removeAttribute("orient");
messagePaneBox.setAttribute("minwidth", "400"); // 400 is a made up number since I can't seem to force the thread pane and msg pane
// to split the available space in half (why is flex not working here???)
// finally, make sure mailContentWrapper has the correct orientation
mailContentWrapper.setAttribute("orient", "horizontal");
}
// re-rooting the message pane causes the docshell to get destroyed
// and replaced with another one. As such, we need to re-set the window (and thus the
// internal references nsMessenger keeps for the message pane docshell)
// XXX: is it safe to call this multiple times? May need to add a setMessagePaneDocShell
// routine to nsIMessenger.
if (aMsgWindowInitialized && msgPaneReRooted)
{
messenger.SetWindow(null, null);
messenger.SetWindow(window, msgWindow);
MsgReload();
}
// record the new configuration
gCurrentPaneConfig = paneConfig;
}
const MailPaneConfigObserver = {
observe: function(subject, topic, prefName) {
// verify that we're changing the mail pane config pref
if (topic == "nsPref:changed")
UpdateMailPaneConfig(true);
}
};
function OnLoadMessenger()
{
// update the pane config before we exit onload otherwise the user may see a flicker if we poke the document
// in delayedOnLoadMessenger...
UpdateMailPaneConfig(false);
setTimeout(delayedOnLoadMessenger, 0); // when debugging, set this to 5000, so you can see what happens after the window comes up.
}
/* Functions related to startup */
function delayedOnLoadMessenger()
{
pref.QueryInterface(Components.interfaces.nsIPrefBranchInternal);
pref.addObserver("mail.pane_config.dynamic", MailPaneConfigObserver, false);
AddMailOfflineObserver();
CreateMailWindowGlobals();
Create3PaneGlobals();
AddToolBarPrefListener();
ShowHideToolBarButtons();
verifyAccounts(null);
HideAccountCentral();
@ -672,15 +766,6 @@ function delayedOnLoadMessenger()
gNotifyDefaultInboxLoadedOnStartup = true;
// fix for #168937. now that we don't have a sidebar
// users who haven't moved the splitter will
// see it jump around
var messengerBox = document.getElementById("messengerBox");
if (!messengerBox.getAttribute("width")) {
messengerBox.setAttribute("width","500px");
}
//Set focus to the Thread Pane the first time the window is opened.
SetFocusThreadPane();
@ -695,7 +780,9 @@ function delayedOnLoadMessenger()
function OnUnloadMessenger()
{
accountManager.removeIncomingServerListener(gThreePaneIncomingServerListener);
RemoveToolBarPrefListener();
pref.QueryInterface(Components.interfaces.nsIPrefBranchInternal);
pref.removeObserver("mail.pane_config.dynamic", MailPaneConfigObserver);
// FIX ME - later we will be able to use onload from the overlay
OnUnloadMsgHeaderPane();
@ -708,11 +795,6 @@ function NotifyObservers(aSubject, aTopic, aData)
observerService.notifyObservers(aSubject, aTopic, aData);
}
function Create3PaneGlobals()
{
}
// because the "open" state persists, we'll call
// PerformExpand() for all servers that are open at startup.
function PerformExpandForAllOpenServers()
@ -959,22 +1041,14 @@ function GetTotalCountElement()
return totalCount;
}
function IsThreadAndMessagePaneSplitterCollapsed()
function IsMessagePaneCollapsed()
{
var messagePane = GetMessagePane();
try {
return (messagePane.getAttribute("collapsed") == "true");
}
catch (ex) {
return false;
}
return GetMessagePane().collapsed;
}
function IsFolderPaneCollapsed()
{
var folderPaneBox = GetFolderTree().parentNode;
return folderPaneBox.getAttribute("collapsed") == "true"
|| folderPaneBox.getAttribute("hidden") == "true";
return GetFolderTree().parentNode.collapsed;
}
function FindMessenger()

View File

@ -208,13 +208,7 @@ function FolderProperties(name, uri)
function MsgToggleMessagePane()
{
//OnClickThreadAndMessagePaneSplitter is based on the value before the splitter is toggled.
MsgToggleSplitter("threadpane-splitter");
}
function MsgToggleSplitter(id)
{
var splitter = document.getElementById(id);
var splitter = document.getElementById("threadpane-splitter");
var state = splitter.getAttribute("state");
if (state == "collapsed")
splitter.setAttribute("state", null);

View File

@ -10,6 +10,7 @@ messenger.jar:
*+ content/messenger/messageWindow.js (content/messageWindow.js)
*+ content/messenger/messenger.xul (content/messenger.xul)
*+ content/messenger/msgMail3PaneWindow.js (content/msgMail3PaneWindow.js)
*+ content/messenger/mail3PaneWindowCommands.js (content/mail3PaneWindowCommands.js)
*+ content/messenger/mailCore.js (content/mailCore.js)
*+ content/messenger/commandglue.js (content/commandglue.js)
*+ content/messenger/widgetglue.js (content/widgetglue.js)