Bug 350452 - Tidy up and re-enable system feed reader detection on windows. r=mconnor.

This commit is contained in:
mozilla.mano%sent.com 2006-09-02 11:33:19 +00:00
Родитель 3543d90ab7
Коммит 4174b6f32e
3 изменённых файлов: 60 добавлений и 9 удалений

Просмотреть файл

@ -488,14 +488,14 @@ FeedWriter.prototype = {
selectedAppMenuItem.wrappedJSObject.hidden = false;
selectedAppMenuItem.doCommand();
#ifdef ENABLE_SYSTEM_FEED_READER_CODE
#ifdef XP_WIN
// Only show the default reader menuitem if the default reader
// isn't the selected application
var defaultHandlerMenuItem =
this._document.getElementById("defaultHandlerMenuItem");
if (defaultHandlerMenuItem) {
defaultHandlerMenuItem.wrappedJSObject.hidden =
defaultHandlerMenuItem.file.path == selectedApp.path;
defaultHandlerMenuItem.wrappedJSObject.file.path == selectedApp.path;
}
#endif
break;
@ -547,7 +547,7 @@ FeedWriter.prototype = {
}
handlersMenuPopup.appendChild(menuItem);
#ifdef ENABLE_SYSTEM_FEED_READER_CODE
#ifdef XP_WIN
// On Windows, also list the default feed reader
var defaultReader;
try {
@ -584,7 +584,7 @@ FeedWriter.prototype = {
// Hide the default reader item if it points to the same application
// as the last-selected application
if (defaultReader.path == selectedApp.path)
if (selectedApp && selectedApp.path == defaultReader.path)
menuItem.setAttribute("hidden", "true");
handlersMenuPopup.appendChild(menuItem);
@ -770,7 +770,7 @@ FeedWriter.prototype = {
else {
switch (selectedHandler.id) {
case "selectedAppMenuItem":
#ifdef ENABLE_SYSTEM_FEED_READER_CODE
#ifdef XP_WIN
case "defaultHandlerMenuItem":
#endif
prefs.setCharPref(PREF_SELECTED_READER, "client");

Просмотреть файл

@ -144,7 +144,28 @@ var gFeedsPane = {
*/
_initFeedReaders: function() {
this.updateSelectedApplicationInfo();
#ifdef XP_WIN
// On Windows, list the system default feed reader if it is
// not the last-selected application already
try {
var systemDefaultReader = this._getSystemDefaultReader();
if (systemDefaultReader) {
var defaultSystemReaderFilefield = this.element("defaultSystemReaderFilefield");
defaultSystemReaderFilefield.file = systemDefaultReader;
var selectedAppFile = this.element("selectedAppFilefield").file;
if (!selectedAppFile || defaultSystemReaderFilefield.file.path !=
selectedAppFile.path) {
var defaultReaderItem = this.element("defaultSystemReaderListitem");
defaultReaderItem.setAttribute("label", defaultSystemReaderFilefield.label);
defaultReaderItem.setAttribute("image", defaultSystemReaderFilefield.image);
defaultReaderItem.hidden = false;
}
}
}
catch(ex) { }
#endif
// List of web handlers
var wccr =
Cc["@mozilla.org/embeddor.implemented/web-content-handler-registrar;1"].
getService(Ci.nsIWebContentConverterService);
@ -152,10 +173,10 @@ var gFeedsPane = {
if (handlers.length == 0)
return;
var appRow = this.element("selectedApplicationListitem");
var ios =
Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
var readersList = this.element("readers");
for (var i = 0; i < handlers.length; ++i) {
var row = document.createElementNS(kXULNS, "listitem");
row.className = "listitem-iconic";
@ -165,7 +186,7 @@ var gFeedsPane = {
var uri = ios.newURI(handlers[i].uri, null, null);
row.setAttribute("image", uri.prePath + "/favicon.ico");
appRow.parentNode.appendChild(row);
readersList.appendChild(row);
}
},
@ -174,7 +195,7 @@ var gFeedsPane = {
*/
updateSelectedApplicationInfo: function() {
var appItemCell = this.element("selectedApplicationCell");
var selectedAppFilefield = this.element("selectedAppFilefield")
var selectedAppFilefield = this.element("selectedAppFilefield");
selectedAppFilefield.file = this.element(PREF_SELECTED_APP).value;
if (selectedAppFilefield.file) {
appItemCell.setAttribute("label", selectedAppFilefield.label);
@ -230,6 +251,20 @@ var gFeedsPane = {
this._silentSelectReader(this.element("liveBookmarksListItem"));
break;
case "client":
#ifdef XP_WIN
// Keep the system default feed reader item selected if the
// last-selected application is the the system default feed reader
// and if it is already selected
var currentItem = this.element("readers").currentItem;
if (currentItem && currentItem.id == "defaultSystemReaderListitem") {
var defaultSystemReaderFile = this.element("defaultSystemReaderFilefield").file;
var selectedAppFile = this.element("selectedAppFilefield").file;
if (selectedAppFile && defaultSystemReaderFile &&
defaultSystemReaderFile.path == selectedAppFile.path)
break;
}
#endif
this._silentSelectReader(this.element("selectedApplicationListitem"));
break;
case "web":
@ -322,6 +357,13 @@ var gFeedsPane = {
case "selectedApplicationListitem":
// PREF_SELECTED_APP is saved in chooseClientApp
this.element(PREF_SELECTED_READER).value = "client";
break;
#ifdef XP_WIN
case "defaultSystemReaderListitem":
this.element(PREF_SELECTED_APP).value = this.element("defaultSystemReaderFilefield").file;
this.element(PREF_SELECTED_READER).value = "client";
break;
#endif
}
}
}

Просмотреть файл

@ -72,6 +72,10 @@
<script type="application/x-javascript" src="chrome://browser/content/preferences/feeds.js"/>
<filefield class="indent" id="selectedAppFilefield" disabled="true" hidden="true"/>
#ifdef XP_WIN
<filefield class="indent" id="defaultSystemReaderFilefield" disabled="true" hidden="true"/>
#endif
<stringbundle id="stringbundle" src="chrome://browser/locale/preferences/feeds.properties"/>
<label value="&feedClick.label;"/>
@ -107,6 +111,11 @@
oncommand="gFeedsPane.chooseClientApp();"/>
</listcell>
</listitem>
#ifdef XP_WIN
<listitem id="defaultSystemReaderListitem"
class="listitem-iconic"
hidden="true"/>
#endif
</listbox>
</hbox>
</radiogroup>