Bug 349991: tag mailview names out of sync with tags; r=neil, sr=bienvenu
This commit is contained in:
Родитель
e469ba8707
Коммит
5a378409fd
|
@ -359,7 +359,7 @@ function SwitchView(command)
|
|||
// when switching thread views, we might be coming out of quick search
|
||||
// or a message view.
|
||||
// first set view picker to all
|
||||
ViewMessagesBy("viewPickerAll");
|
||||
ViewChangeByValue(kViewItemAll);
|
||||
|
||||
// clear the QS text, if we need to
|
||||
ClearQSIfNecessary();
|
||||
|
|
|
@ -71,7 +71,7 @@ function MailToolboxCustomizeDone(aToolboxChanged)
|
|||
|
||||
// make sure the mail views search box is initialized
|
||||
if (document.getElementById("mailviews-container"))
|
||||
viewPickerOnLoad();
|
||||
ViewPickerOnLoad();
|
||||
|
||||
// make sure the folder location picker is initialized
|
||||
if (document.getElementById("folder-location-container"))
|
||||
|
|
|
@ -315,80 +315,6 @@ function InitViewMessagesMenu()
|
|||
ignoredTheadsMenuItem.setAttribute("checked", (viewFlags & nsMsgViewFlagsType.kShowIgnored) != 0);
|
||||
}
|
||||
|
||||
function InitViewMessageViewMenu()
|
||||
{
|
||||
var viewType = (gDBView) ? gDBView.viewType : 0;
|
||||
var currentViewValue = document.getElementById("viewPicker").value;
|
||||
|
||||
var allMenuItem = document.getElementById("viewAll");
|
||||
if(allMenuItem)
|
||||
allMenuItem.setAttribute("checked", currentViewValue == 0); // from msgViewPickerOveraly.xul <menuitem value="0" id="viewPickerAll" label="&viewPickerAll.label;"/>
|
||||
|
||||
var unreadMenuItem = document.getElementById("viewUnread");
|
||||
if(unreadMenuItem)
|
||||
unreadMenuItem.setAttribute("checked", currentViewValue == 1); // from msgViewPickerOveraly.xul, <menuitem value="1" id="viewPickerUnread" label="&viewPickerUnread.label;"/>
|
||||
|
||||
for (var i = 1; i <= 5; i++) {
|
||||
var prefString = gPrefBranch.getComplexValue("mailnews.labels.description." + i, Components.interfaces.nsIPrefLocalizedString).data;
|
||||
var viewLabelMenuItem = document.getElementById("viewLabelMenuItem" + i);
|
||||
viewLabelMenuItem.setAttribute("label", prefString);
|
||||
viewLabelMenuItem.setAttribute("checked", (i == (currentViewValue - 1))); // 1=2-1, from msgViewPickerOveraly.xul, <menuitem value="2" id="labelMenuItem1"/>
|
||||
}
|
||||
|
||||
viewRefreshCustomMailViews(currentViewValue);
|
||||
}
|
||||
|
||||
function viewRefreshCustomMailViews(aCurrentViewValue)
|
||||
{
|
||||
// for each mail view in the msg view list, add a menu item
|
||||
var mailViewList = Components.classes["@mozilla.org/messenger/mailviewlist;1"].getService(Components.interfaces.nsIMsgMailViewList);
|
||||
|
||||
// XXX TODO, fix code in msgViewPickerOverlay.js, to be like this.
|
||||
// remove any existing entries...
|
||||
var menupopupNode = document.getElementById('viewMessageViewPopup');
|
||||
var userDefinedItems = menupopupNode.getElementsByAttribute("userdefined","true");
|
||||
for (var i=0; userDefinedItems.item(i); )
|
||||
{
|
||||
if (!menupopupNode.removeChild(userDefinedItems[i]))
|
||||
++i;
|
||||
}
|
||||
|
||||
// now rebuild the list
|
||||
var numItems = mailViewList.mailViewCount;
|
||||
var viewCreateCustomViewSeparator = document.getElementById('viewCreateCustomViewSeparator');
|
||||
|
||||
for (i = 0; i < numItems; i++)
|
||||
{
|
||||
var newMenuItem = document.createElement("menuitem");
|
||||
newMenuItem.setAttribute("label", mailViewList.getMailViewAt(i).prettyName);
|
||||
newMenuItem.setAttribute("userdefined", "true");
|
||||
var oncommandStr = "ViewMessagesBy('userdefinedview" + (kLastDefaultViewIndex + i) + "');";
|
||||
newMenuItem.setAttribute("oncommand", oncommandStr);
|
||||
var item = menupopupNode.insertBefore(newMenuItem, viewCreateCustomViewSeparator);
|
||||
item.setAttribute("value", kLastDefaultViewIndex + i);
|
||||
item.setAttribute("type", "radio"); // for checked
|
||||
item.setAttribute("name", "viewmessages"); // for checked
|
||||
item.setAttribute("checked", (kLastDefaultViewIndex + i == aCurrentViewValue));
|
||||
}
|
||||
|
||||
if (!numItems)
|
||||
viewCreateCustomViewSeparator.setAttribute('collapsed', true);
|
||||
else
|
||||
viewCreateCustomViewSeparator.removeAttribute('collapsed');
|
||||
}
|
||||
|
||||
// called by the View | Messages | Views ... menu items
|
||||
// see mailWindowOverlay.xul
|
||||
function ViewMessagesBy(id)
|
||||
{
|
||||
var viewPicker = document.getElementById('viewPicker');
|
||||
if (viewPicker)
|
||||
{
|
||||
viewPicker.selectedItem = document.getElementById(id);
|
||||
viewChange(viewPicker, viewPicker.value);
|
||||
}
|
||||
}
|
||||
|
||||
function InitMessageMenu()
|
||||
{
|
||||
var aMessage = GetFirstSelectedMessage();
|
||||
|
|
|
@ -48,6 +48,8 @@
|
|||
%globalDTD;
|
||||
<!ENTITY % messengerDTD SYSTEM "chrome://messenger/locale/messenger.dtd">
|
||||
%messengerDTD;
|
||||
<!ENTITY % msgViewPickerDTD SYSTEM "chrome://messenger/locale/msgViewPickerOverlay.dtd" >
|
||||
%msgViewPickerDTD;
|
||||
<!ENTITY % contentAreaCommandsDTD SYSTEM "chrome://communicator/locale/contentAreaCommands.dtd">
|
||||
%contentAreaCommandsDTD;
|
||||
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
|
||||
|
@ -1372,22 +1374,24 @@
|
|||
</menupopup>
|
||||
</menu>
|
||||
|
||||
<menu label="&msgsMenu.label;" id="viewMessageViewMenu" accesskey="&msgsMenu.accesskey;">
|
||||
<menupopup id="viewMessageViewPopup" onpopupshowing="InitViewMessageViewMenu()">
|
||||
<menuitem id="viewAll" type="radio" name="viewmessages" label="&viewAll.label;" accesskey="&viewAll.accesskey;" oncommand="ViewMessagesBy('viewPickerAll');"/>
|
||||
<menuitem id="viewUnread" type="radio" name="viewmessages" label="&viewUnread.label;" accesskey="&viewUnread.accesskey;" oncommand="ViewMessagesBy('viewPickerUnread');"/>
|
||||
<menu id="viewMessageViewMenu" label="&msgsMenu.label;" accesskey="&msgsMenu.accesskey;"
|
||||
observes="mailHideMenus" oncommand="ViewChangeByMenuitem(event.target);">
|
||||
<menupopup id="viewMessagePopup">
|
||||
<menuitem id="viewMessageAll" value="0" type="radio" label="&viewAll.label;" accesskey="&viewAll.accesskey;"/>
|
||||
<menuitem id="viewMessageUnread" value="1" type="radio" label="&viewUnread.label;" accesskey="&viewUnread.accesskey;"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="viewLabelMenuItem1" type="radio" name="viewmessages" oncommand="ViewMessagesBy('labelMenuItem1');" />
|
||||
<menuitem id="viewLabelMenuItem2" type="radio" name="viewmessages" oncommand="ViewMessagesBy('labelMenuItem2');" />
|
||||
<menuitem id="viewLabelMenuItem3" type="radio" name="viewmessages" oncommand="ViewMessagesBy('labelMenuItem3');" />
|
||||
<menuitem id="viewLabelMenuItem4" type="radio" name="viewmessages" oncommand="ViewMessagesBy('labelMenuItem4');" />
|
||||
<menuitem id="viewLabelMenuItem5" type="radio" name="viewmessages" oncommand="ViewMessagesBy('labelMenuItem5');" />
|
||||
<menuseparator id="viewLastDefaultView"/>
|
||||
<menuseparator id="viewCreateCustomViewSeparator"/>
|
||||
<menuitem id="viewCreateCustomView" label="&viewCustomView.label;" accesskey="&viewCustomView.accesskey;" oncommand="LaunchCustomizeDialog();" />
|
||||
</menupopup>
|
||||
<menu id="viewMessageTags" label="&viewTags.label;" accesskey="&viewTags.accesskey;">
|
||||
<menupopup id="viewMessageTagsPopup" onpopupshowing="RefreshTagsPopup(this, false);"/>
|
||||
</menu>
|
||||
<menu id="viewMessageCustomViews" label="&viewCustomViews.label;" accesskey="&viewCustomViews.accesskey;">
|
||||
<menupopup id="viewMessageCustomViewsPopup" onpopupshowing="RefreshCustomViewsPopup(this, false);"/>
|
||||
</menu>
|
||||
<menuseparator/>
|
||||
<menuitem id="viewMessageVirtualFolder" value="7" label="&viewVirtualFolder.label;" accesskey="&viewVirtualFolder.accesskey;"/>
|
||||
<menuitem id="viewMessageCustomize" value="8" label="&viewCustomizeView.label;" accesskey="&viewCustomizeView.accesskey;"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
|
||||
|
||||
<menu label="&threads.label;" id="viewMessagesMenu" accesskey="&threads.accesskey;">
|
||||
<menupopup onpopupshowing="InitViewMessagesMenu()">
|
||||
<menuitem id="viewAllMessagesMenuItem" type="radio" name="viewmessages" label="&allMsgsCmd.label;" accesskey="&allMsgsCmd.accesskey;" disabled="true" observes="cmd_viewAllMsgs"/>
|
||||
|
@ -2131,21 +2135,25 @@
|
|||
</toolbaritem>
|
||||
|
||||
<toolbaritem id="mailviews-container" title="&mailViewsToolbarItem.title;" align="center" class="chromeclass-toolbar-additional">
|
||||
<label value="&viewPicker.label;" control="viewPicker" accesskey="&viewPicker.accesskey;"/>
|
||||
<menulist id="viewPicker" oncreate="FillLabelValues();" oncommand="viewChange(this, this.value);">
|
||||
<label value="&viewPicker.label;" control="viewPicker" accesskey="&viewPicker.accesskey;"/>
|
||||
<menulist id="viewPicker" oncommand="ViewChangeByMenuitem(event.target);">
|
||||
<menupopup id="viewPickerPopup">
|
||||
<menuitem value="0" id="viewPickerAll" label="&viewPickerAll.label;"/>
|
||||
<menuitem value="1" id="viewPickerUnread" label="&viewPickerUnread.label;"/>
|
||||
<menuitem id="viewPickerAll" value="0" label="&viewAll.label;"/>
|
||||
<menuitem id="viewPickerUnread" value="1" label="&viewUnread.label;"/>
|
||||
<menuseparator/>
|
||||
<menuitem value="2" id="labelMenuItem1"/>
|
||||
<menuitem value="3" id="labelMenuItem2"/>
|
||||
<menuitem value="4" id="labelMenuItem3"/>
|
||||
<menuitem value="5" id="labelMenuItem4"/>
|
||||
<menuitem value="6" id="labelMenuItem5"/>
|
||||
<menuseparator id="lastDefaultView"/>
|
||||
<menuseparator id="createCustomViewSeparator"/>
|
||||
<menuitem id="saveAsVirtualFolder" value="7" label="&viewPickerSaveAsVirtualFolder.label;"/>
|
||||
<menuitem id="createCustomView" value="8" label="&viewPickerCustomView.label;"/>
|
||||
<menu id="viewPickerTags" label="&viewTags.label;">
|
||||
<menupopup id="viewPickerTagsPopup"
|
||||
class="menulist-menupopup"
|
||||
onpopupshowing="RefreshTagsPopup(this, true);"/>
|
||||
</menu>
|
||||
<menu id="viewPickerCustomViews" label="&viewCustomViews.label;">
|
||||
<menupopup id="viewPickerCustomViewsPopup"
|
||||
class="menulist-menupopup"
|
||||
onpopupshowing="RefreshCustomViewsPopup(this, true);"/>
|
||||
</menu>
|
||||
<menuseparator/>
|
||||
<menuitem id="viewPickerVirtualFolder" value="7" label="&viewVirtualFolder.label;"/>
|
||||
<menuitem id="viewPickerCustomize" value="8" label="&viewCustomizeView.label;"/>
|
||||
</menupopup>
|
||||
</menulist>
|
||||
</toolbaritem>
|
||||
|
|
|
@ -291,12 +291,9 @@ var folderListener = {
|
|||
// get the view value from the folder
|
||||
if (msgFolder)
|
||||
{
|
||||
var msgDatabase = msgFolder.getMsgDatabase(msgWindow);
|
||||
var dbFolderInfo = msgDatabase.dBFolderInfo;
|
||||
var result = dbFolderInfo.getUint32Property("current-view", 0);
|
||||
|
||||
// if our new view is the same as the old view and we already have the list of search terms built up
|
||||
// for the old view, just re-use it
|
||||
var result = GetMailViewForFolder(msgFolder);
|
||||
if (gCurrentViewValue == result && gDefaultSearchViewTerms)
|
||||
{
|
||||
viewDebug("searching gDefaultSearchViewTerms and rerootingFolder\n");
|
||||
|
|
|
@ -116,12 +116,12 @@ var gSearchNotificationListener =
|
|||
msgdb.Commit(MSG_DB_LARGE_COMMIT);
|
||||
|
||||
// load the last used mail view for the folder...
|
||||
var result = dbFolderInfo.getUint32Property("current-view", 0);
|
||||
var result = GetMailViewForFolder(vFolder);
|
||||
// do this on a timeout so that we don't issue a new search
|
||||
// synchronously with the previous search's onSearchDone notification
|
||||
// because that can cause a confusing sequence of onSearchDone and
|
||||
// onNewSearch notifications.
|
||||
setTimeout('ViewChangeByValue('+result+')', 0);
|
||||
setTimeout(ViewChangeByValue, 0, result);
|
||||
|
||||
// now that we have finished loading a virtual folder, scroll to the correct message
|
||||
ScrollToMessageAfterFolderLoad(vFolder);
|
||||
|
|
|
@ -180,12 +180,6 @@
|
|||
<!ENTITY groupBySortCmd.key "G">
|
||||
<!ENTITY msgsMenu.label "Messages">
|
||||
<!ENTITY msgsMenu.accesskey "M">
|
||||
<!ENTITY viewAll.label "All">
|
||||
<!ENTITY viewAll.accesskey "A">
|
||||
<!ENTITY viewUnread.label "Unread">
|
||||
<!ENTITY viewUnread.accesskey "U">
|
||||
<!ENTITY viewCustomView.label "Customize...">
|
||||
<!ENTITY viewCustomView.accesskey "C">
|
||||
<!ENTITY threads.label "Threads">
|
||||
<!ENTITY threads.accesskey "e">
|
||||
<!ENTITY allMsgsCmd.label "All">
|
||||
|
@ -527,12 +521,6 @@
|
|||
<!ENTITY folderContextFavoriteFolder.accesskey "a">
|
||||
|
||||
<!-- Search Bar -->
|
||||
<!ENTITY viewPicker.label "View:">
|
||||
<!ENTITY viewPicker.accesskey "i">
|
||||
<!ENTITY viewPickerAll.label "All">
|
||||
<!ENTITY viewPickerUnread.label "Unread">
|
||||
<!ENTITY viewPickerCustomView.label "Customize...">
|
||||
<!ENTITY viewPickerSaveAsVirtualFolder.label "Save View as a Folder...">
|
||||
<!ENTITY SearchNameOrEmail.label "Name or Email contains:">
|
||||
<!ENTITY SearchNameOrEmail.accesskey "N">
|
||||
<!ENTITY clearButton.label "Clear">
|
||||
|
|
|
@ -2,6 +2,15 @@
|
|||
|
||||
<!ENTITY viewPicker.label "View:">
|
||||
<!ENTITY viewPicker.accesskey "i">
|
||||
<!ENTITY viewPickerCustomView.label "Customize...">
|
||||
<!ENTITY viewPickerAll.label "All">
|
||||
<!ENTITY viewPickerUnread.label "Unread">
|
||||
<!ENTITY viewAll.label "All">
|
||||
<!ENTITY viewAll.accesskey "A">
|
||||
<!ENTITY viewUnread.label "Unread">
|
||||
<!ENTITY viewUnread.accesskey "U">
|
||||
<!ENTITY viewTags.label "Tags">
|
||||
<!ENTITY viewTags.accesskey "T">
|
||||
<!ENTITY viewCustomViews.label "Custom Views">
|
||||
<!ENTITY viewCustomViews.accesskey "V">
|
||||
<!ENTITY viewVirtualFolder.label "Save View as a Folder...">
|
||||
<!ENTITY viewVirtualFolder.accesskey "S">
|
||||
<!ENTITY viewCustomizeView.label "Customize...">
|
||||
<!ENTITY viewCustomizeView.accesskey "C">
|
||||
|
|
|
@ -378,7 +378,7 @@ function SwitchView(command)
|
|||
// when switching thread views, we might be coming out of quick search
|
||||
// or a message view.
|
||||
// first set view picker to all
|
||||
ViewMessagesBy("viewPickerAll");
|
||||
ViewChangeByValue(kViewItemAll);
|
||||
|
||||
// clear the QS text, if we need to
|
||||
ClearQSIfNecessary();
|
||||
|
|
|
@ -286,76 +286,6 @@ function InitViewMessagesMenu()
|
|||
ignoredTheadsMenuItem.setAttribute("checked", (viewFlags & nsMsgViewFlagsType.kShowIgnored) != 0);
|
||||
}
|
||||
|
||||
function InitViewMessageViewMenu()
|
||||
{
|
||||
var currentViewValue = document.getElementById("viewPicker").value;
|
||||
|
||||
var allMenuItem = document.getElementById("viewAll");
|
||||
if(allMenuItem)
|
||||
allMenuItem.setAttribute("checked", currentViewValue == 0); // from msgViewPickerOveraly.xul <menuitem value="0" id="viewPickerAll" label="&viewPickerAll.label;"/>
|
||||
|
||||
var unreadMenuItem = document.getElementById("viewUnread");
|
||||
if(unreadMenuItem)
|
||||
unreadMenuItem.setAttribute("checked", currentViewValue == 1); // from msgViewPickerOveraly.xul, <menuitem value="1" id="viewPickerUnread" label="&viewPickerUnread.label;"/>
|
||||
|
||||
for (var i = 1; i <= 5; i++) {
|
||||
var prefString = gPrefBranch.getComplexValue("mailnews.labels.description." + i, Components.interfaces.nsIPrefLocalizedString).data;
|
||||
var viewLabelMenuItem = document.getElementById("viewLabelMenuItem" + i);
|
||||
viewLabelMenuItem.setAttribute("label", prefString);
|
||||
viewLabelMenuItem.setAttribute("checked", (i == (currentViewValue - 1))); // 1=2-1, from msgViewPickerOveraly.xul, <menuitem value="2" id="labelMenuItem1"/>
|
||||
}
|
||||
|
||||
viewRefreshCustomMailViews(currentViewValue);
|
||||
}
|
||||
|
||||
function viewRefreshCustomMailViews(aCurrentViewValue)
|
||||
{
|
||||
// For each mail view in the msg view list, add a menu item.
|
||||
var mailViewList = Components.classes["@mozilla.org/messenger/mailviewlist;1"].getService(Components.interfaces.nsIMsgMailViewList);
|
||||
|
||||
// XXX TODO, fix code in msgViewPickerOverlay.js, to be like this.
|
||||
// Remove any existing entries...
|
||||
var menupopupNode = document.getElementById('viewMessageViewPopup');
|
||||
var userDefinedItems = menupopupNode.getElementsByAttribute("userdefined","true");
|
||||
for (var i=0; userDefinedItems.item(i); )
|
||||
{
|
||||
if (!menupopupNode.removeChild(userDefinedItems[i]))
|
||||
++i;
|
||||
}
|
||||
|
||||
// Now rebuild the list.
|
||||
var numItems = mailViewList.mailViewCount;
|
||||
var viewCreateCustomViewSeparator = document.getElementById('viewCreateCustomViewSeparator');
|
||||
|
||||
for (i = 0; i < numItems; i++)
|
||||
{
|
||||
var newMenuItem = document.createElement("menuitem");
|
||||
newMenuItem.setAttribute("label", mailViewList.getMailViewAt(i).prettyName);
|
||||
newMenuItem.setAttribute("userdefined", "true");
|
||||
var oncommandStr = "ViewMessagesBy('userdefinedview" + (kLastDefaultViewIndex + i) + "');";
|
||||
newMenuItem.setAttribute("oncommand", oncommandStr);
|
||||
var item = menupopupNode.insertBefore(newMenuItem, viewCreateCustomViewSeparator);
|
||||
item.setAttribute("value", kLastDefaultViewIndex + i);
|
||||
item.setAttribute("type", "radio"); // for checked
|
||||
item.setAttribute("name", "viewmessages"); // for checked
|
||||
item.setAttribute("checked", (kLastDefaultViewIndex + i == aCurrentViewValue));
|
||||
}
|
||||
|
||||
if (!numItems)
|
||||
viewCreateCustomViewSeparator.setAttribute('collapsed', true);
|
||||
else
|
||||
viewCreateCustomViewSeparator.removeAttribute('collapsed');
|
||||
}
|
||||
|
||||
// Called by the various View | Messages menu items.
|
||||
// See mailWindowOverlay.xul.
|
||||
function ViewMessagesBy(id)
|
||||
{
|
||||
var viewPicker = document.getElementById('viewPicker');
|
||||
viewPicker.selectedItem = document.getElementById(id);
|
||||
viewChange(viewPicker, viewPicker.value);
|
||||
}
|
||||
|
||||
function InitMessageMenu()
|
||||
{
|
||||
var aMessage = GetFirstSelectedMessage();
|
||||
|
|
|
@ -52,6 +52,8 @@
|
|||
<!DOCTYPE overlay [
|
||||
<!ENTITY % messengerDTD SYSTEM "chrome://messenger/locale/messenger.dtd" >
|
||||
%messengerDTD;
|
||||
<!ENTITY % msgViewPickerDTD SYSTEM "chrome://messenger/locale/msgViewPickerOverlay.dtd" >
|
||||
%msgViewPickerDTD;
|
||||
<!ENTITY % msgHdrViewPopupDTD SYSTEM "chrome://messenger/locale/msgHdrViewPopup.dtd" >
|
||||
%msgHdrViewPopupDTD;
|
||||
<!ENTITY % contentAreaCommandsDTD SYSTEM "chrome://communicator/locale/contentAreaCommands.dtd" >
|
||||
|
@ -1239,21 +1241,22 @@
|
|||
<menuitem id="groupBySort" type="radio" name="group" label="&groupBySort.label;" accesskey="&groupBySort.accesskey;" oncommand="MsgGroupBySort();"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menu id="viewMessageViewMenu" label="&msgsMenu.label;"
|
||||
accesskey="&msgsMenu.accesskey;" observes="mailHideMenus">
|
||||
<menupopup id="viewMessageViewPopup" onpopupshowing="InitViewMessageViewMenu()">
|
||||
<menuitem id="viewAll" type="radio" name="viewmessages" label="&viewAll.label;" accesskey="&viewAll.accesskey;" oncommand="ViewMessagesBy('viewPickerAll');"/>
|
||||
<menuitem id="viewUnread" type="radio" name="viewmessages" label="&viewUnread.label;" accesskey="&viewUnread.accesskey;" oncommand="ViewMessagesBy('viewPickerUnread');"/>
|
||||
<menu id="viewMessageViewMenu" label="&msgsMenu.label;" accesskey="&msgsMenu.accesskey;"
|
||||
observes="mailHideMenus" oncommand="ViewChangeByMenuitem(event.target);">
|
||||
<menupopup id="viewMessagePopup">
|
||||
<menuitem id="viewMessageAll" value="0" type="radio" label="&viewAll.label;" accesskey="&viewAll.accesskey;"/>
|
||||
<menuitem id="viewMessageUnread" value="1" type="radio" label="&viewUnread.label;" accesskey="&viewUnread.accesskey;"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="viewLabelMenuItem1" type="radio" name="viewmessages" oncommand="ViewMessagesBy('labelMenuItem1');" />
|
||||
<menuitem id="viewLabelMenuItem2" type="radio" name="viewmessages" oncommand="ViewMessagesBy('labelMenuItem2');" />
|
||||
<menuitem id="viewLabelMenuItem3" type="radio" name="viewmessages" oncommand="ViewMessagesBy('labelMenuItem3');" />
|
||||
<menuitem id="viewLabelMenuItem4" type="radio" name="viewmessages" oncommand="ViewMessagesBy('labelMenuItem4');" />
|
||||
<menuitem id="viewLabelMenuItem5" type="radio" name="viewmessages" oncommand="ViewMessagesBy('labelMenuItem5');" />
|
||||
<menuseparator id="viewLastDefaultView"/>
|
||||
<menuseparator id="viewCreateCustomViewSeparator"/>
|
||||
<menuitem id="viewCreateCustomView" label="&viewCustomView.label;" accesskey="&viewCustomView.accesskey;" oncommand="LaunchCustomizeDialog();" />
|
||||
</menupopup>
|
||||
<menu id="viewMessageTags" label="&viewTags.label;" accesskey="&viewTags.accesskey;">
|
||||
<menupopup id="viewMessageTagsPopup" onpopupshowing="RefreshTagsPopup(this, false);"/>
|
||||
</menu>
|
||||
<menu id="viewMessageCustomViews" label="&viewCustomViews.label;" accesskey="&viewCustomViews.accesskey;">
|
||||
<menupopup id="viewMessageCustomViewsPopup" onpopupshowing="RefreshCustomViewsPopup(this, false);"/>
|
||||
</menu>
|
||||
<menuseparator/>
|
||||
<menuitem id="viewMessageVirtualFolder" value="7" label="&viewVirtualFolder.label;" accesskey="&viewVirtualFolder.accesskey;"/>
|
||||
<menuitem id="viewMessageCustomize" value="8" label="&viewCustomizeView.label;" accesskey="&viewCustomizeView.accesskey;"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menu id="viewMessagesMenu" label="&threads.label;"
|
||||
accesskey="&threads.accesskey;" observes="mailHideMenus">
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
* Jan Varga (varga@ku.sk)
|
||||
* Håkan Waara (hwaara@chello.se)
|
||||
* Håkan Waara (hwaara@chello.se)
|
||||
* Neil Rashbrook (neil@parkwaycc.co.uk)
|
||||
* Seth Spitzer <sspitzer@netscape.com>
|
||||
*
|
||||
|
@ -273,12 +273,9 @@ var folderListener = {
|
|||
// get the view value from the folder
|
||||
if (msgFolder)
|
||||
{
|
||||
var msgDatabase = msgFolder.getMsgDatabase(msgWindow);
|
||||
var dbFolderInfo = msgDatabase.dBFolderInfo;
|
||||
var result = dbFolderInfo.getUint32Property("current-view", 0);
|
||||
|
||||
// if our new view is the same as the old view and we already have the list of search terms built up
|
||||
// for the old view, just re-use it
|
||||
var result = GetMailViewForFolder(msgFolder);
|
||||
if (gCurrentViewValue == result && gDefaultSearchViewTerms)
|
||||
{
|
||||
viewDebug("searching gDefaultSearchViewTerms and rerootingFolder\n");
|
||||
|
|
|
@ -185,7 +185,7 @@ function onEnterInSearchBar()
|
|||
{
|
||||
if (!gSearchBundle)
|
||||
getDocumentElements();
|
||||
viewDebug ("onEnterInSearchBar gSearchInput.value = " + gSearchInput.value + " showing criteria = " + gSearchInput.showingSearchCriteria +"\n");
|
||||
viewDebug ("onEnterInSearchBar gSearchInput.value = " /* + gSearchInput.value + " showing criteria = " + gSearchInput.showingSearchCriteria */ +"\n");
|
||||
if (gSearchInput.value == "" /* || gSearchInput.showingSearchCriteria */)
|
||||
{
|
||||
|
||||
|
|
|
@ -219,12 +219,6 @@
|
|||
<!ENTITY groupBySort.accesskey "G">
|
||||
<!ENTITY msgsMenu.label "Messages">
|
||||
<!ENTITY msgsMenu.accesskey "M">
|
||||
<!ENTITY viewAll.label "All">
|
||||
<!ENTITY viewUnread.label "Unread">
|
||||
<!ENTITY viewAll.accesskey "A">
|
||||
<!ENTITY viewUnread.accesskey "U">
|
||||
<!ENTITY viewCustomView.label "Customize...">
|
||||
<!ENTITY viewCustomView.accesskey "C">
|
||||
<!ENTITY threads.label "Threads">
|
||||
<!ENTITY threads.accesskey "e">
|
||||
<!ENTITY allMsgsCmd.label "All">
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
* Contributor(s):
|
||||
* Scott MacGregor <mscott@netscape.com>
|
||||
* Seth Spitzer <sspitzer@netscape.com>
|
||||
* Karsten Düsterloh <mnyromyr@tprac.de>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
|
@ -37,29 +38,38 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
const kLabelOffset = 1; // 1=2-1, from msgViewPickerOveraly.xul, <menuitem value="2" id="labelMenuItem1"/>
|
||||
const kLastDefaultViewIndex = 9; // 9, because 8 + 1, <menuitem id="createCustomView" value="8" label="&viewPickerCustomView.label;"/>
|
||||
const kSaveItemValue = "7"; // from msgViewPickerOveraly.xul, <menuitem id="saveAsVirtualFolder" value="7" label="&viewPickerSaveAsVirtualFolder.label;"/>
|
||||
const kCustomItemValue = "8"; // from msgViewPickerOveraly.xul, <menuitem id="createCustomView" value="8" label="&viewPickerCustomView.label;"/>
|
||||
// menuitem value constants
|
||||
// tag views have kViewTagMarker + their key as value
|
||||
const kViewItemAll = 0;
|
||||
const kViewItemUnread = 1;
|
||||
const kViewItemTags = 2; // former labels used values 2-6
|
||||
const kViewItemVirtual = 7;
|
||||
const kViewItemCustomize = 8;
|
||||
const kViewItemFirstCustom = 9;
|
||||
|
||||
const kViewCurrent = "current-view";
|
||||
const kViewCurrentTag = "current-view-tag";
|
||||
const kViewTagMarker = ":";
|
||||
|
||||
var gMailViewList = null;
|
||||
var gCurrentViewValue = "0"; // initialize to the first view ("All")
|
||||
var gCurrentViewValue = kViewItemAll;
|
||||
var gCurrentViewLabel = "";
|
||||
var gSaveDefaultSVTerms;
|
||||
|
||||
var nsMsgSearchScope = Components.interfaces.nsMsgSearchScope;
|
||||
var nsMsgSearchScope = Components.interfaces.nsMsgSearchScope;
|
||||
var nsMsgSearchAttrib = Components.interfaces.nsMsgSearchAttrib;
|
||||
var nsMsgSearchOp = Components.interfaces.nsMsgSearchOp;
|
||||
var nsMsgSearchOp = Components.interfaces.nsMsgSearchOp;
|
||||
|
||||
// when the item in the list box changes....
|
||||
|
||||
function viewChange(aMenuList, val)
|
||||
// perform the view/action requested by the aValue string
|
||||
// and set the view picker label to the aLabel string
|
||||
function ViewChange(aValue, aLabel)
|
||||
{
|
||||
if (val == kCustomItemValue || val == kSaveItemValue)
|
||||
if (aValue == kViewItemCustomize || aValue == kViewItemVirtual)
|
||||
{
|
||||
// restore to the previous view value, in case they cancel
|
||||
aMenuList.value = gCurrentViewValue;
|
||||
if (val == kCustomItemValue)
|
||||
UpdateViewPicker(gCurrentViewValue, gCurrentViewLabel);
|
||||
if (aValue == kViewItemCustomize)
|
||||
LaunchCustomizeDialog();
|
||||
else
|
||||
openNewVirtualFolderDialogWithArgs(gCurrentViewLabel, gSaveDefaultSVTerms);
|
||||
|
@ -67,203 +77,163 @@ function viewChange(aMenuList, val)
|
|||
}
|
||||
|
||||
// bail out early if the user picked the same view
|
||||
if (val == gCurrentViewValue)
|
||||
return;
|
||||
viewDebug("viewChange to " + val + "\n");
|
||||
gCurrentViewValue = val;
|
||||
switch (val)
|
||||
{
|
||||
case -1:
|
||||
case "-1":
|
||||
case "0": // View All
|
||||
gDefaultSearchViewTerms = null;
|
||||
break;
|
||||
case "1": // Unread
|
||||
ViewNewMail();
|
||||
break;
|
||||
case "2": // label 1
|
||||
case "3": // label 2
|
||||
case "4": // label 3
|
||||
case "5": // label 4
|
||||
case "6": // label 5
|
||||
// view the old default labels as keywords.
|
||||
ViewLabelKeyword("$label" + (val - 1));
|
||||
break;
|
||||
default:
|
||||
LoadCustomMailView(parseInt(val) - kLastDefaultViewIndex);
|
||||
break;
|
||||
} //
|
||||
if (gCurrentViewValue == aValue)
|
||||
return;
|
||||
|
||||
// persist the view
|
||||
gCurrentViewValue = aValue;
|
||||
gCurrentViewLabel = aLabel;
|
||||
SetMailViewForFolder(GetFirstSelectedMsgFolder(), gCurrentViewValue)
|
||||
UpdateViewPicker(gCurrentViewValue, gCurrentViewLabel);
|
||||
|
||||
// tag menuitem values are of the form :<keyword>
|
||||
if (isNaN(aValue))
|
||||
{
|
||||
// split off the tag key
|
||||
var tagkey = aValue.substr(kViewTagMarker.length);
|
||||
ViewTagKeyword(tagkey);
|
||||
}
|
||||
else
|
||||
{
|
||||
var numval = Number(aValue);
|
||||
switch (numval)
|
||||
{
|
||||
case kViewItemAll: // View All
|
||||
gDefaultSearchViewTerms = null;
|
||||
break;
|
||||
case kViewItemUnread: // Unread
|
||||
ViewNewMail();
|
||||
break;
|
||||
default:
|
||||
// for legacy reasons, custom views start at index 9
|
||||
LoadCustomMailView(numval - kViewItemFirstCustom);
|
||||
break;
|
||||
}
|
||||
}
|
||||
gSaveDefaultSVTerms = gDefaultSearchViewTerms;
|
||||
// store this, to persist across sessions
|
||||
if (val != "-1" && val != -1)
|
||||
{
|
||||
if (aMenuList.selectedItem)
|
||||
gCurrentViewLabel = aMenuList.selectedItem.label;
|
||||
|
||||
var msgDatabase = GetFirstSelectedMsgFolder().getMsgDatabase(msgWindow);
|
||||
var dbFolderInfo = msgDatabase.dBFolderInfo;
|
||||
dbFolderInfo.setUint32Property("current-view", parseInt(val));
|
||||
}
|
||||
// if we're switching to -1 (virtual folder), don't do a search
|
||||
if (val != "-1" && val != -1)
|
||||
{
|
||||
onEnterInSearchBar();
|
||||
gQSViewIsDirty = true;
|
||||
}
|
||||
onEnterInSearchBar();
|
||||
gQSViewIsDirty = true;
|
||||
}
|
||||
|
||||
const kLabelPrefs = "mailnews.labels.description.";
|
||||
|
||||
const gLabelPrefListener = {
|
||||
observe: function(subject, topic, prefName)
|
||||
{
|
||||
if (topic != "nsPref:changed")
|
||||
return;
|
||||
|
||||
var index = parseInt(prefName.substring(kLabelPrefs.length));
|
||||
if (index >= 1 && index <= 5)
|
||||
setLabelAttributes(index, "labelMenuItem" + index);
|
||||
}
|
||||
};
|
||||
|
||||
function AddLabelPrefListener()
|
||||
function ViewChangeByMenuitem(aMenuitem)
|
||||
{
|
||||
try {
|
||||
gPrefBranch.QueryInterface(Components.interfaces.nsIPrefBranch2);
|
||||
gPrefBranch.addObserver(kLabelPrefs, gLabelPrefListener, false);
|
||||
} catch(ex) {
|
||||
dump("Failed to observe prefs: " + ex + "\n");
|
||||
}
|
||||
// Mac View menu menuitems don't have XBL bindings
|
||||
ViewChange(aMenuitem.getAttribute("value"), aMenuitem.getAttribute("label"));
|
||||
}
|
||||
|
||||
function RemoveLabelPrefListener()
|
||||
|
||||
function ViewChangeByValue(aValue)
|
||||
{
|
||||
try {
|
||||
gPrefBranch.QueryInterface(Components.interfaces.nsIPrefBranch2);
|
||||
gPrefBranch.removeObserver(kLabelPrefs, gLabelPrefListener);
|
||||
} catch(ex) {
|
||||
dump("Failed to remove pref observer: " + ex + "\n");
|
||||
var label = "";
|
||||
var viewPickerPopup = document.getElementById("viewPickerPopup");
|
||||
if (viewPickerPopup)
|
||||
{
|
||||
// grab the label for the menulist from one of its menuitems
|
||||
var selectedItems = viewPickerPopup.getElementsByAttribute("value", aValue);
|
||||
if (!selectedItems || !selectedItems.length)
|
||||
{
|
||||
// we may have a new item
|
||||
RefreshViewPopup(viewPickerPopup, true);
|
||||
selectedItems = viewPickerPopup.getElementsByAttribute("value", aValue);
|
||||
}
|
||||
label = selectedItems && selectedItems.length && selectedItems[0].label;
|
||||
}
|
||||
ViewChange(aValue, label);
|
||||
}
|
||||
|
||||
function viewPickerOnLoad()
|
||||
|
||||
function ViewChangeByCustomValue(aCustomValue)
|
||||
{
|
||||
if (document.getElementById('viewPicker')) {
|
||||
window.addEventListener("unload", RemoveLabelPrefListener, false);
|
||||
|
||||
AddLabelPrefListener();
|
||||
ViewChangeByValue(aCustomValue + kViewItemFirstCustom);
|
||||
}
|
||||
|
||||
FillLabelValues();
|
||||
|
||||
refreshCustomMailViews(-1);
|
||||
function UpdateViewPicker(aValue, aLabel)
|
||||
{
|
||||
var viewPicker = document.getElementById("viewPicker");
|
||||
if (viewPicker)
|
||||
{
|
||||
viewPicker.value = aValue;
|
||||
viewPicker.setAttribute("label", aLabel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function GetFolderInfo(aFolder)
|
||||
{
|
||||
if (aFolder)
|
||||
{
|
||||
var db = aFolder.getMsgDatabase(msgWindow);
|
||||
if (db)
|
||||
return db.dBFolderInfo;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
function GetMailViewForFolder(aFolder)
|
||||
{
|
||||
var val = "";
|
||||
var folderInfo = GetFolderInfo(aFolder);
|
||||
if (folderInfo)
|
||||
{
|
||||
val = folderInfo.getCharPtrProperty(kViewCurrentTag);
|
||||
if (!val)
|
||||
{
|
||||
// no new view value, thus using the old
|
||||
var numval = folderInfo.getUint32Property(kViewCurrent, kViewItemAll);
|
||||
// and migrate it, if it's a former label view (label views used values 2-6)
|
||||
if ((kViewItemTags <= numval) && (numval < kViewItemVirtual))
|
||||
val = kViewTagMarker + "$label" + (val - 1);
|
||||
else
|
||||
val = numval;
|
||||
}
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
function SetMailViewForFolder(aFolder, aValue)
|
||||
{
|
||||
var folderInfo = GetFolderInfo(aFolder);
|
||||
if (folderInfo)
|
||||
{
|
||||
// we can't map tags back to labels in general,
|
||||
// so set view to none for backwards compatibility in this case
|
||||
folderInfo.setUint32Property (kViewCurrent, isNaN(aValue) ? kViewItemAll : aValue);
|
||||
folderInfo.setCharPtrProperty(kViewCurrentTag, aValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function LaunchCustomizeDialog()
|
||||
{
|
||||
// made it modal, see bug #191188
|
||||
window.openDialog("chrome://messenger/content/mailViewList.xul", "mailnews:mailviewlist", "chrome,modal,titlebar,resizable,centerscreen", {onCloseCallback: refreshCustomMailViews});
|
||||
window.openDialog("chrome://messenger/content/mailViewList.xul",
|
||||
"mailnews:mailviewlist",
|
||||
"chrome,modal,titlebar,resizable,centerscreen",
|
||||
{onCloseCallback: ViewChangeByCustomValue});
|
||||
}
|
||||
|
||||
|
||||
function LoadCustomMailView(index)
|
||||
{
|
||||
prepareForViewChange();
|
||||
|
||||
PrepareForViewChange();
|
||||
var searchTermsArrayForQS = CreateGroupedSearchTerms(gMailViewList.getMailViewAt(index).searchTerms);
|
||||
createSearchTermsWithList(searchTermsArrayForQS);
|
||||
AddVirtualFolderTerms(searchTermsArrayForQS);
|
||||
gDefaultSearchViewTerms = searchTermsArrayForQS;
|
||||
}
|
||||
|
||||
function refreshCustomMailViews(aDefaultSelectedIndex)
|
||||
|
||||
function ViewTagKeyword(keyword)
|
||||
{
|
||||
// for each mail view in the msg view list, add an entry in our combo box
|
||||
if (!gMailViewList)
|
||||
gMailViewList = Components.classes["@mozilla.org/messenger/mailviewlist;1"].getService(Components.interfaces.nsIMsgMailViewList);
|
||||
|
||||
// remove any existing entries...
|
||||
var menupopupNode = document.getElementById('viewPickerPopup');
|
||||
for (var i = menupopupNode.childNodes.length - 1; i >= 0; --i)
|
||||
{
|
||||
if (menupopupNode.childNodes[i].id.substr(0, 15) == "userdefinedview")
|
||||
menupopupNode.removeChild(menupopupNode.childNodes[i]);
|
||||
}
|
||||
|
||||
// now rebuild the list
|
||||
|
||||
var numItems = gMailViewList.mailViewCount;
|
||||
var customNode = document.getElementById('createCustomViewSeparator');
|
||||
var newMenuItem;
|
||||
var item;
|
||||
for (var index = 0; index < numItems; index++)
|
||||
{
|
||||
newMenuItem = document.createElement('menuitem');
|
||||
newMenuItem.setAttribute('label', gMailViewList.getMailViewAt(index).prettyName);
|
||||
newMenuItem.setAttribute('id', "userdefinedview" + (kLastDefaultViewIndex + index));
|
||||
item = menupopupNode.insertBefore(newMenuItem, customNode);
|
||||
item.setAttribute('value', kLastDefaultViewIndex + index);
|
||||
}
|
||||
|
||||
if (!numItems)
|
||||
customNode.setAttribute('collapsed', true);
|
||||
else
|
||||
customNode.removeAttribute('collapsed');
|
||||
|
||||
if (aDefaultSelectedIndex >= 0)
|
||||
{
|
||||
ViewChangeByValue(kLastDefaultViewIndex + aDefaultSelectedIndex);
|
||||
}
|
||||
}
|
||||
|
||||
function ViewChangeByValue(aValue)
|
||||
{
|
||||
var viewPicker = document.getElementById('viewPicker');
|
||||
|
||||
if (!viewPicker)
|
||||
return;
|
||||
|
||||
if (aValue == -1)
|
||||
{
|
||||
viewPicker.selectedItem = null;
|
||||
viewChange(viewPicker, -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
viewPicker.selectedItem = viewPicker.getElementsByAttribute("value", aValue)[0];
|
||||
viewChange(viewPicker, viewPicker.value);
|
||||
}
|
||||
}
|
||||
|
||||
function FillLabelValues()
|
||||
{
|
||||
for (var i = 1; i <= 5; i++)
|
||||
setLabelAttributes(i, "labelMenuItem" + i);
|
||||
}
|
||||
|
||||
function setLabelAttributes(labelID, menuItemID)
|
||||
{
|
||||
var prefString;
|
||||
prefString = gPrefBranch.getComplexValue(kLabelPrefs + labelID, Components.interfaces.nsIPrefLocalizedString).data;
|
||||
document.getElementById(menuItemID).setAttribute("label", prefString);
|
||||
}
|
||||
|
||||
function prepareForViewChange()
|
||||
{
|
||||
// this is a problem - it saves the current view in gPreQuickSearchView
|
||||
// then we eventually call onEnterInSearchBar, and we think we need to restore the pre search view!
|
||||
initializeSearchBar();
|
||||
ClearThreadPaneSelection();
|
||||
ClearMessagePane();
|
||||
}
|
||||
|
||||
function ViewLabelKeyword(keyword)
|
||||
{
|
||||
prepareForViewChange();
|
||||
|
||||
// create an i supports array to store our search terms
|
||||
var searchTermsArray = Components.classes["@mozilla.org/supports-array;1"].createInstance(Components.interfaces.nsISupportsArray);
|
||||
PrepareForViewChange();
|
||||
|
||||
// create an i supports array to store our search terms
|
||||
var searchTermsArray = Components.classes["@mozilla.org/supports-array;1"]
|
||||
.createInstance(Components.interfaces.nsISupportsArray);
|
||||
var term = gSearchSession.createTerm();
|
||||
var value = term.value;
|
||||
|
||||
|
@ -280,13 +250,14 @@ function ViewLabelKeyword(keyword)
|
|||
gDefaultSearchViewTerms = searchTermsArray;
|
||||
}
|
||||
|
||||
|
||||
function ViewNewMail()
|
||||
{
|
||||
prepareForViewChange();
|
||||
|
||||
// create an i supports array to store our search terms
|
||||
var searchTermsArray = Components.classes["@mozilla.org/supports-array;1"].createInstance(Components.interfaces.nsISupportsArray);
|
||||
PrepareForViewChange();
|
||||
|
||||
// create an i supports array to store our search terms
|
||||
var searchTermsArray = Components.classes["@mozilla.org/supports-array;1"]
|
||||
.createInstance(Components.interfaces.nsISupportsArray);
|
||||
var term = gSearchSession.createTerm();
|
||||
var value = term.value;
|
||||
|
||||
|
@ -305,6 +276,7 @@ function ViewNewMail()
|
|||
gDefaultSearchViewTerms = searchTermsArray;
|
||||
}
|
||||
|
||||
|
||||
function AddVirtualFolderTerms(searchTermsArray)
|
||||
{
|
||||
// add in any virtual folder terms
|
||||
|
@ -312,9 +284,9 @@ function AddVirtualFolderTerms(searchTermsArray)
|
|||
if (virtualFolderSearchTerms)
|
||||
{
|
||||
var isupports = null;
|
||||
var searchTerm;
|
||||
var searchTerm;
|
||||
var termsArray = virtualFolderSearchTerms.QueryInterface(Components.interfaces.nsISupportsArray);
|
||||
for (i = 0; i < termsArray.Count(); i++)
|
||||
for (var i = 0; i < termsArray.Count(); i++)
|
||||
{
|
||||
isupports = termsArray.GetElementAt(i);
|
||||
searchTerm = isupports.QueryInterface(Components.interfaces.nsIMsgSearchTerm);
|
||||
|
@ -324,4 +296,105 @@ function AddVirtualFolderTerms(searchTermsArray)
|
|||
}
|
||||
|
||||
|
||||
window.addEventListener("load", viewPickerOnLoad, false);
|
||||
function PrepareForViewChange()
|
||||
{
|
||||
// this is a problem - it saves the current view in gPreQuickSearchView
|
||||
// then we eventually call onEnterInSearchBar, and we think we need to restore the pre search view!
|
||||
initializeSearchBar();
|
||||
ClearThreadPaneSelection();
|
||||
ClearMessagePane();
|
||||
}
|
||||
|
||||
|
||||
// recreate the entries for tags and custom views
|
||||
// and mark the current view's menuitem
|
||||
function RefreshViewPopup(aViewPopup, aIsMenulist)
|
||||
{
|
||||
var menupopups = aViewPopup.getElementsByTagName("menupopup");
|
||||
if (menupopups.length > 1)
|
||||
{
|
||||
// when we have menupopups, we assume both tags and custom views are there
|
||||
RefreshTagsPopup(menupopups[0], aIsMenulist);
|
||||
RefreshCustomViewsPopup(menupopups[1], aIsMenulist);
|
||||
}
|
||||
// mark default views if selected
|
||||
if (!aIsMenulist)
|
||||
{
|
||||
var viewAll = aViewPopup.getElementsByAttribute("value", kViewItemAll)[0];
|
||||
viewAll.setAttribute("checked", gCurrentViewValue == kViewItemAll);
|
||||
var viewUnread = aViewPopup.getElementsByAttribute("value", kViewItemUnread)[0];
|
||||
viewUnread.setAttribute("checked", gCurrentViewValue == kViewItemUnread);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function RefreshCustomViewsPopup(aMenupopup, aIsMenulist)
|
||||
{
|
||||
// for each mail view in the msg view list, add an entry in our combo box
|
||||
if (!gMailViewList)
|
||||
gMailViewList = Components.classes["@mozilla.org/messenger/mailviewlist;1"]
|
||||
.getService(Components.interfaces.nsIMsgMailViewList);
|
||||
// remove all menuitems
|
||||
while (aMenupopup.hasChildNodes())
|
||||
aMenupopup.removeChild(aMenupopup.lastChild);
|
||||
|
||||
// now rebuild the list
|
||||
var currentView = isNaN(gCurrentViewValue) ? kViewItemAll : Number(gCurrentViewValue);
|
||||
var numItems = gMailViewList.mailViewCount;
|
||||
for (var i = 0; i < numItems; ++i)
|
||||
{
|
||||
var viewInfo = gMailViewList.getMailViewAt(i);
|
||||
var menuitem = document.createElement("menuitem");
|
||||
menuitem.setAttribute("label", viewInfo.prettyName);
|
||||
menuitem.setAttribute("value", kViewItemFirstCustom + i);
|
||||
if (!aIsMenulist)
|
||||
{
|
||||
menuitem.setAttribute("type", "radio");
|
||||
if (kViewItemFirstCustom + i == currentView)
|
||||
menuitem.setAttribute("checked", true);
|
||||
}
|
||||
aMenupopup.appendChild(menuitem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function RefreshTagsPopup(aMenupopup, aIsMenulist)
|
||||
{
|
||||
// remove all menuitems
|
||||
while (aMenupopup.hasChildNodes())
|
||||
aMenupopup.removeChild(aMenupopup.lastChild);
|
||||
|
||||
// create tag menuitems
|
||||
var currentTagKey = isNaN(gCurrentViewValue) ? gCurrentViewValue.substr(kViewTagMarker.length) : "";
|
||||
var tagService = Components.classes["@mozilla.org/messenger/tagservice;1"]
|
||||
.getService(Components.interfaces.nsIMsgTagService);
|
||||
var tagArray = tagService.getAllTags({});
|
||||
for (var i = 0; i < tagArray.length; ++i)
|
||||
{
|
||||
var tagInfo = tagArray[i];
|
||||
var menuitem = document.createElement("menuitem");
|
||||
menuitem.setAttribute("label", tagInfo.tag);
|
||||
menuitem.setAttribute("value", kViewTagMarker + tagInfo.key);
|
||||
if (!aIsMenulist)
|
||||
{
|
||||
menuitem.setAttribute("type", "radio");
|
||||
if (tagInfo.key == currentTagKey)
|
||||
menuitem.setAttribute("checked", true);
|
||||
}
|
||||
var color = tagInfo.color;
|
||||
if (color)
|
||||
menuitem.setAttribute("class", "lc-" + color.substr(1));
|
||||
aMenupopup.appendChild(menuitem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function ViewPickerOnLoad()
|
||||
{
|
||||
var viewPickerPopup = document.getElementById("viewPickerPopup");
|
||||
if (viewPickerPopup)
|
||||
RefreshViewPopup(viewPickerPopup, true);
|
||||
}
|
||||
|
||||
|
||||
window.addEventListener("load", ViewPickerOnLoad, false);
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
-
|
||||
- Contributor(s):
|
||||
- Scott MacGregor <mscott@netscape.com>
|
||||
- Karsten Düsterloh <mnyromyr@tprac.de>
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
|
@ -39,30 +40,32 @@
|
|||
|
||||
<!DOCTYPE overlay SYSTEM "chrome://messenger/locale/msgViewPickerOverlay.dtd">
|
||||
|
||||
<overlay
|
||||
xmlns:nc="http://home.netscape.com/NC-rdf#"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<script src="chrome://messenger/content/msgViewPickerOverlay.js"/>
|
||||
|
||||
<hbox id="searchBox">
|
||||
<hbox id="viewPickerBox" insertbefore="searchCriteria" align="center">
|
||||
<label value="&viewPicker.label;" control="viewPicker" accesskey="&viewPicker.accesskey;"/>
|
||||
<menulist id="viewPicker" oncreate="FillLabelValues();" oncommand="viewChange(this, this.value);">
|
||||
<menupopup id="viewPickerPopup">
|
||||
<menuitem value="0" id="viewPickerAll" label="&viewPickerAll.label;"/>
|
||||
<menuitem value="1" id="viewPickerUnread" label="&viewPickerUnread.label;"/>
|
||||
<menuseparator/>
|
||||
<menuitem value="2" id="labelMenuItem1"/>
|
||||
<menuitem value="3" id="labelMenuItem2"/>
|
||||
<menuitem value="4" id="labelMenuItem3"/>
|
||||
<menuitem value="5" id="labelMenuItem4"/>
|
||||
<menuitem value="6" id="labelMenuItem5"/>
|
||||
<menuseparator id="lastDefaultView"/>
|
||||
<menuseparator id="createCustomViewSeparator"/>
|
||||
<menuitem id="saveAsVirtualFolder" value="7" label="&viewPickerSaveAsVirtualFolder.label;"/>
|
||||
<menuitem id="createCustomView" value="8" label="&viewPickerCustomView.label;"/>
|
||||
</menupopup>
|
||||
<label value="&viewPicker.label;" control="viewPicker"/>
|
||||
<menulist id="viewPicker" oncommand="ViewChangeByMenuitem(event.target);">
|
||||
<menupopup id="viewPickerPopup">
|
||||
<menuitem id="viewPickerAll" value="0" label="&viewAll.label;"/>
|
||||
<menuitem id="viewPickerUnread" value="1" label="&viewUnread.label;"/>
|
||||
<menuseparator/>
|
||||
<menu id="viewPickerTags" label="&viewTags.label;">
|
||||
<menupopup id="viewPickerTagsPopup"
|
||||
class="menulist-menupopup"
|
||||
onpopupshowing="RefreshTagsPopup(this, true);"/>
|
||||
</menu>
|
||||
<menu id="viewPickerCustomViews" label="&viewCustomViews.label;">
|
||||
<menupopup id="viewPickerCustomViewsPopup"
|
||||
class="menulist-menupopup"
|
||||
onpopupshowing="RefreshCustomViewsPopup(this, true);"/>
|
||||
</menu>
|
||||
<menuseparator/>
|
||||
<menuitem id="viewPickerVirtualFolder" value="7" label="&viewVirtualFolder.label;"/>
|
||||
<menuitem id="viewPickerCustomize" value="8" label="&viewCustomizeView.label;"/>
|
||||
</menupopup>
|
||||
</menulist>
|
||||
</hbox>
|
||||
<!-- overlay the advanced button to save space -->
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
<!--LOCALIZATION NOTE msgViewPickerOverlay.dtd UI for showing various views on a folder -->
|
||||
|
||||
<!ENTITY viewPicker.label "View:">
|
||||
<!ENTITY viewPicker.accesskey "i">
|
||||
<!ENTITY viewPickerSaveAsVirtualFolder.label "Save View as a Folder...">
|
||||
<!ENTITY viewPickerCustomView.label "Customize...">
|
||||
<!ENTITY viewPickerAll.label "All">
|
||||
<!ENTITY viewPickerUnread.label "Unread">
|
|
@ -196,7 +196,9 @@ menuitem[checked="true"][disabled="true"] {
|
|||
/* ::::: menuitems in menulists ::::: */
|
||||
|
||||
menulist > menupopup > menuitem,
|
||||
.menulist-menupopup > menuitem {
|
||||
menulist > menupopup > menu,
|
||||
.menulist-menupopup > menuitem,
|
||||
.menulist-menupopup > menu {
|
||||
max-width: none;
|
||||
padding-right: 28px !important;
|
||||
font: message-box;
|
||||
|
|
Загрузка…
Ссылка в новой задаче