From 2e4dcaee718bb123ea40d0605f1c796b0c89990c Mon Sep 17 00:00:00 2001 From: "reed%reedloden.com" Date: Sat, 17 Nov 2007 04:30:28 +0000 Subject: [PATCH] =?UTF-8?q?Bug=20403845=20-=20"Launch=20Application=20dial?= =?UTF-8?q?og=20displays=20duplicate=20entries=20after=20selection"=20[p?= =?UTF-8?q?=3Dflorian@mozilla.com=20(Florian=20Qu=C3=83=C2=A8ze)=20r=3Dgav?= =?UTF-8?q?in=20a=3Dblocking-firefox3+]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://10.0.0.236/trunk@239564 18797224-902f-48f8-a5cc-f745e15eee43 --- .../mozapps/handling/content/dialog.js | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/mozilla/toolkit/mozapps/handling/content/dialog.js b/mozilla/toolkit/mozapps/handling/content/dialog.js index de4271a17d4..abd1126c056 100644 --- a/mozilla/toolkit/mozapps/handling/content/dialog.js +++ b/mozilla/toolkit/mozapps/handling/content/dialog.js @@ -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(); }