From bb6ace680cf0a4bb53cdab74a837fc9bc795ce7c Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Wed, 17 May 2006 02:35:59 +0000 Subject: [PATCH] Fix bug 86640 -- change helper app dialog to properly remember the selected course of action, move the "neverAsk" information from prefs back to mimeTypes.rdf, remove the "Reset" button from helper app prefs, set up a way to select "use default OS helper" for a given type. Patch by Bill Law and Philip K. Warren , r=biesi, sr=bzbarsky, what passes for moa in helper apps=bzbarsky. --- suite/common/pref/overrideHandler.js | 32 ++- suite/common/pref/pref-applications-edit.xul | 260 ++++++++++++------ suite/common/pref/pref-applications.js | 144 ++++++++-- suite/common/pref/pref-applications.xul | 65 ++--- .../common/pref/pref-applications-edit.dtd | 31 +-- .../chrome/common/pref/pref-applications.dtd | 11 +- .../common/pref/pref-applications.properties | 8 +- 7 files changed, 366 insertions(+), 185 deletions(-) diff --git a/suite/common/pref/overrideHandler.js b/suite/common/pref/overrideHandler.js index 5a33b672cca..a3ddb62484b 100644 --- a/suite/common/pref/overrideHandler.js +++ b/suite/common/pref/overrideHandler.js @@ -138,7 +138,31 @@ HandlerOverride.prototype = { else changeMIMEStuff(HANDLER_URI(this.mimeType), "saveToDisk", aSavedToDisk); this.setHandlerProcedure("handleInternal", "false"); + this.setHandlerProcedure("useSystemDefault", "false"); }, + + get useSystemDefault() + { + return getHandlerInfoForType(this.URI, "useSystemDefault"); + }, + + set useSystemDefault(aUseSystemDefault) + { + var handlerSource = gRDF.GetResource(HANDLER_URI(this.mimeType)); + var handlerProperty = gRDF.GetResource(NC_RDF("useSystemDefault")); + var trueLiteral = gRDF.GetLiteral("true"); + var hasUseSystemDefault = gDS.HasAssertion(handlerSource, handlerProperty, trueLiteral, true); + if (!hasUseSystemDefault) { + var falseLiteral = gRDF.GetLiteral("false"); + hasUseSystemDefault = gDS.HasAssertion(handlerSource, handlerProperty, falseLiteral, true); + } + if (!this.mUpdateMode || !hasUseSystemDefault) + assertMIMEStuff(HANDLER_URI(this.mimeType), "useSystemDefault", aUseSystemDefault); + else + changeMIMEStuff(HANDLER_URI(this.mimeType), "useSystemDefault", aUseSystemDefault); + this.setHandlerProcedure("handleInternal", "false"); + this.setHandlerProcedure("saveToDisk", "false"); + }, get handleInternal() { @@ -160,6 +184,7 @@ HandlerOverride.prototype = { else changeMIMEStuff(HANDLER_URI(this.mimeType), "handleInternal", aHandledInternally); this.setHandlerProcedure("saveToDisk", "false"); + this.setHandlerProcedure("useSystemDefault", "false"); }, setHandlerProcedure: function (aHandlerProcedure, aValue) @@ -317,7 +342,7 @@ function mimeHandlerExists(aMIMEType) { var valueProperty = gRDF.GetResource(NC_RDF("value")); var mimeSource = gRDF.GetResource(MIME_URI(aMIMEType)); - var mimeLiteral = gRDF.GetLiteral(gMIMEField.value); + var mimeLiteral = gRDF.GetLiteral(aMIMEType); return gDS.HasAssertion(mimeSource, valueProperty, mimeLiteral, true); } @@ -349,7 +374,6 @@ function unassertMIMEStuff(aMIMEString, aPropertyString, aValueString) function removeOverride(aMIMEType) { - dump("*** mimeType = " + aMIMEType + "\n"); // remove entry from seq var rdfc = Components.classes["@mozilla.org/rdf/container;1"].createInstance(); if (rdfc) { @@ -372,7 +396,7 @@ function removeOverride(aMIMEType) // remove items from the graph var urns = [ [MIME_URI, ["description", "editable", "value", "fileExtensions", "smallIcon", "largeIcon"], [HANDLER_URI, "handlerProp"]], - [HANDLER_URI, ["handleInternal", "saveToDisk", "alwaysAsk"], + [HANDLER_URI, ["handleInternal", "saveToDisk", "alwaysAsk", "useSystemDefault"], [APP_URI, "externalApplication"]], [APP_URI, ["path", "prettyName"]] ]; for (var i = 0; i < urns.length; i++) { @@ -396,7 +420,7 @@ function removeOverride(aMIMEType) gDS.Unassert(mimeRes, propertyRes, mimeValue, true); } } - if (urns[i][2]) { + if ("2" in urns[i] && urns[i][2]) { var linkRes = gRDF.GetResource(NC_RDF(urns[i][2][1]), true); var linkTarget = gRDF.GetResource(urns[i][2][0](aMIMEType), true); gDS.Unassert(mimeRes, linkRes, linkTarget); diff --git a/suite/common/pref/pref-applications-edit.xul b/suite/common/pref/pref-applications-edit.xul index 5aed2dfe8be..5efe0d780ca 100644 --- a/suite/common/pref/pref-applications-edit.xul +++ b/suite/common/pref/pref-applications-edit.xul @@ -31,6 +31,7 @@ style="width: 30em;" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" title="&editType.label;" + newtitle="&newType.label;" onload="Startup();" ondialogaccept="return onAccept();"> @@ -41,28 +42,38 @@ + - - - - - - - - - - - - - - - - - - - - - - - + - - + - +