Bug 403845 - "Launch Application dialog displays duplicate entries after selection" [p=florian@mozilla.com (Florian Quèze) r=gavin a=blocking-firefox3+]

git-svn-id: svn://10.0.0.236/trunk@239564 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
reed%reedloden.com
2007-11-17 04:30:28 +00:00
parent 17549972f3
commit 2e4dcaee71

View File

@@ -171,17 +171,28 @@ var dialog = {
let uri = Cc["@mozilla.org/network/util;1"].
getService(Ci.nsIIOService).
newFileURI(fp.file);
let elm = document.createElement("richlistitem");
elm.setAttribute("type", "handler");
elm.setAttribute("name", fp.file.leafName);
elm.setAttribute("image", "moz-icon://" + uri.spec + "?size=32");
let handlerApp = Cc["@mozilla.org/uriloader/local-handler-app;1"].
createInstance(Ci.nsILocalHandlerApp);
handlerApp.executable = fp.file;
// if this application is already in the list, select it and don't add it again
let parent = document.getElementById("items");
for (let i = 0; i < parent.childNodes.length; ++i) {
let elm = parent.childNodes[i];
if (elm.obj instanceof Ci.nsILocalHandlerApp && elm.obj.equals(handlerApp)) {
parent.selectedItem = elm;
parent.ensureSelectedElementIsVisible();
return;
}
}
let elm = document.createElement("richlistitem");
elm.setAttribute("type", "handler");
elm.setAttribute("name", fp.file.leafName);
elm.setAttribute("image", "moz-icon://" + uri.spec + "?size=32");
elm.obj = handlerApp;
let parent = document.getElementById("items");
parent.selectedItem = parent.insertBefore(elm, parent.firstChild);
parent.ensureSelectedElementIsVisible();
}