315940 NPOB hook up drag gesture handler, so you can at least drag shortcuts to your desktop.

git-svn-id: svn://10.0.0.236/trunk@185234 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
beng%bengoodger.com
2005-11-24 00:19:31 +00:00
parent f08d3b747d
commit 6fe843f576
2 changed files with 66 additions and 8 deletions

View File

@@ -112,19 +112,13 @@
<property name="hasSelection">
<getter><![CDATA[
return this.view.selection.getRangeCount() >= 1;
return this.view.selection.count >= 1;
]]></getter>
</property>
<property name="hasSingleSelection">
<getter><![CDATA[
var selection = this.view.selection;
var rc = selection.getRangeCount();
if (rc != 1)
return false;
var min = { }, max = { };
selection.getRangeAt(0, min, max);
return (min.value == max.value);
return this.view.selection.count == 1;
]]></getter>
</property>
@@ -215,6 +209,62 @@
</property>
<property name="browserWindow" onget="return this._browserWindow"/>
<method name="_getTransferData">
<body><![CDATA[
var result = this.view.QueryInterface(Ci.nsINavHistoryResult);
var selection = this.view.selection;
if (selection.count == 0)
return null;
var dataSet = new TransferDataSet();
var rc = selection.getRangeCount();
for (var i = 0; i < rc; ++i) {
var min = { }, max = { };
selection.getRangeAt(i, min, max);
for (var j = min.value; j <= max.value; ++j) {
var node = result.nodeForTreeIndex(j);
var data = new TransferData();
data.addDataForFlavour("text/x-moz-url", node.url + "\n" + node.title);
data.addDataForFlavour("text/html", "<A HREF=\"" + node.url + "\">" + node.title + "</A>");
data.addDataForFlavour("text/unicode", node.url);
dataSet.push(data);
}
}
return dataSet;
]]></body>
</method>
<field name="_DNDObserver"><![CDATA[({
// XXXben ew.
_self: this,
onDragStart: function(event, xferData, dragAction) {
if (this._self.getAttribute("sortActive") == "true")
throw Components.results.NS_OK;
xferData.data = this._self._getTransferData();
if (event.ctrlKey)
dragAction.action = Ci.nsIDragService.DRAGDROP_ACTION_COPY;
},
onDragOver: function(event, flavor, dragSession) {
if (dragSession.sourceNode == this._self)
dragSession.canDrop = true;
},
onDrop: function(event, xferData, dragSession) {
},
getSupportedFlavours: function() {
var flavorSet = new FlavourSet();
flavorSet.appendFlavour("application/x-moz-file", "nsIFile");
flavorSet.appendFlavour("text/x-moz-url");
flavorSet.appendFlavour("text/unicode");
return flavorSet;
}
})]]></field>
</implementation>
<handlers>
<handler event="focus"><![CDATA[
@@ -236,6 +286,11 @@
view.toggleOpenState(min.value);
}
]]></handler>
<handler event="draggesture"><![CDATA[
// XXXben ew.
if (event.target.localName == "treechildren")
nsDragAndDrop.startDrag(event, this._DNDObserver);
]]></handler>
</handlers>
</binding>

View File

@@ -15,6 +15,9 @@
src="chrome://browser/content/places/controller.js"/>
<script type="application/x-javascript"
src="chrome://browser/content/places/places.js"/>
<!-- ew. -->
<script type="application/x-javascript"
src="chrome://global/content/nsDragAndDrop.js"/>
<stringbundleset id="stringbundles">
<stringbundle id="placeBundle" src="chrome://browser/locale/places/places.properties"/>