Bug #314124 --> experimental folder pane summary tooltip for thunderbird

still a work in progress

sr=bienvenu


git-svn-id: svn://10.0.0.236/trunk@184370 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
scott%scott-macgregor.org 2005-11-09 21:43:28 +00:00
parent b4726829f7
commit e8e3dee651
6 changed files with 142 additions and 1 deletions

View File

@ -161,6 +161,16 @@ dummy.usesMailWidgets {
-moz-binding: url("chrome://messenger/content/mailWidgets.xml#searchpopup");
}
.folderSummaryPopup
{
-moz-binding: url("chrome://messenger/content/mailWidgets.xml#folderSummary-popup");
}
folderSummaryMessage
{
-moz-binding: url("chrome://messenger/content/mailWidgets.xml#folderSummary-message");
}
.foldersTree
{
margin: 0px;

View File

@ -161,6 +161,8 @@
</hbox>
</popup>
<tooltip id="folderpopup" class="folderSummaryPopup"/>
<popup id="messagePaneContext"/>
<toolbox id="mail-toolbox" class="toolbox-top">
@ -184,6 +186,7 @@
datasources="rdf:null"
statedatasource="rdf:mailnewsfolders"
flags="dont-build-content"
tooltip="folderpopup"
ondraggesture="BeginDragFolderTree(event);"
onselect="FolderPaneSelectionChange();">
<template>

View File

@ -133,3 +133,15 @@ treechildren::-moz-tree-cell-text(folderNameCol, noSelect-true) {
.tree-folder-checkbox {
list-style-image: none;
}
/* ::::: Folder Summary Popup ::::: */
.folderSummary-subject {
font-weight: bold;
max-width: 25em;
}
.folderSummary-previewText {
color: grey;
max-width: 35em;
}

View File

@ -143,4 +143,16 @@ treechildren::-moz-tree-cell-text(folderNameCol, noSelect-true) {
.tree-folder-checkbox {
list-style-image: none;
}
}
/* ::::: Folder Summary Popup ::::: */
.folderSummary-subject {
font-weight: bold;
max-width: 25em;
}
.folderSummary-previewText {
color: grey;
max-width: 35em;
}

View File

@ -1978,4 +1978,107 @@
</xbl:content>
</binding>
<binding id="folderSummary-popup" extends="chrome://global/content/bindings/popup.xml#tooltip">
<content>
<children>
<xul:vbox/>
</children>
</content>
<implementation>
<field name="mMaxMsgHdrsInPopup">8</field>
</implementation>
<handlers>
<handler event="popupshowing">
<![CDATA[
var folderTree = GetFolderTree();
var row = folderTree.treeBoxObject.getRowAt(event.clientX, event.clientY);
if (row == -1)
return false;
var msgFolder = GetFolderResource(folderTree, row).QueryInterface(Components.interfaces.nsIMsgFolder);
if (!msgFolder || msgFolder.isServer)
return false;
// now get the database
var msgDatabase = msgFolder.getMsgDatabase(msgWindow);
var msgKeys = {};
var numMsgKeys = {};
msgDatabase.getNewList(numMsgKeys, msgKeys);
if (!numMsgKeys.value)
return false;
// fetchMsgPreviewText forces the previewText property to get generated
// for each of the message keys.
var asyncResults = {};
try {
msgFolder.fetchMsgPreviewText(msgKeys.value, numMsgKeys.value, false, null, asyncResults);
}
catch (ex)
{
// fetchMsgPreviewText throws an error when we call it on a news folder, we should just not show
// the tooltip if this method returns an error.
dump('fetchMsgPreviewText threw an error or failed to set any preview text data\n');
return false;
}
var index = 0;
while (index < this.mMaxMsgHdrsInPopup && index < numMsgKeys.value)
{
var msgPopup = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "folderSummaryMessage");
// hack to work around the fact that the xbl binding from createElementNS is asynch.
setTimeout(function(aMsgPopup, aMsgHdr) {
aMsgPopup.init(aMsgHdr); }, 0,
msgPopup, msgDatabase.GetMsgHdrForKey(msgKeys.value[index++]));
document.getAnonymousNodes(this)[0].appendChild(msgPopup);
}
return true;
]]>
</handler>
<handler event="popuphiding">
<![CDATA[
var containingBox = document.getAnonymousNodes(this)[0];
while (containingBox.hasChildNodes())
containingBox.removeChild(containingBox.lastChild);
]]>
</handler>
</handlers>
</binding>
<binding id="folderSummary-message">
<content>
<xul:vbox>
<xul:hbox>
<xul:label class="folderSummary-subject" xbl:inherits="value=subject,crop" crop="right"/>
<xul:label class="folderSummary-sender" xbl:inherits="value=sender" crop="right"/>
</xul:hbox>
<xul:description class="folderSummary-previewText" xbl:inherits="value=previewText" crop="right"></xul:description>
</xul:vbox>
</content>
<implementation>
<method name="init">
<parameter name="aMsgHdr"/>
<body>
<![CDATA[
this.setAttribute('subject', aMsgHdr.mime2DecodedSubject);
// TO DO: worry about character set conversions
var previewText = aMsgHdr.getStringProperty('preview'); // replace tabs, line returns, etc. with a space
if (previewText)
this.setAttribute('previewText', previewText);
var hdrParser = Components.classes["@mozilla.org/messenger/headerparser;1"].getService(Components.interfaces.nsIMsgHeaderParser);
var names = {};
var emails = {};
var numAddresses = hdrParser.parseHeadersWithArray(aMsgHdr.mime2DecodedAuthor, emails, names, {});
this.setAttribute('sender', ' - ' + (names.value[0] ? names.value[0] : emails.value[0]));
]]>
</body>
</method>
</implementation>
</binding>
</bindings>

View File

@ -5143,6 +5143,7 @@ nsresult nsMsgDBFolder::GetMsgPreviewTextFromStream(nsIMsgDBHdr *msgHdr, nsIInpu
if (!boundary.IsEmpty() && boundary.Equals(curLine))
break;
msgBody.Append(curLine);
msgBody.Append(" "); // convert each end of line delimter into a space
// how much html should we parse for text? 2K? 4K?
if (msgBody.Length() > 2048 || (!msgBodyIsHtml && msgBody.Length() > 255))
break;