[Gtk-sharp-list] Drag & Drop on Windows
Matteo Bertozzi
theo.bertozzi at gmail.com
Fri Sep 8 10:14:14 EDT 2006
Why on Windows "args.SelectionData.Text" is an empty string?
On Linux args.SelectionData.Text is filled with file:///path
Some one Know how to Resolve this "problem"?
=========================================================
private static TargetEntry[] dndTargetTable = new TargetEntry[] {
new TargetEntry("STRING", 0, 0),
new TargetEntry("text/plain", 0, 1),
new TargetEntry("text/uri-list", 0, 2),
new TargetEntry("_NETSCAPE_URL", 0, 3),
new TargetEntry("application/x-color", 0, 4),
new TargetEntry("application/x-rootwindow-drop", 0, 5),
new TargetEntry("property/bgimage", 0, 6),
new TargetEntry("property/keyword", 0, 7),
new TargetEntry("x-special/gnome-icon-list", 0, 8),
new TargetEntry("x-special/gnome-reset-background", 0, 9)
};
...
// Initialize Icon View Drag & Drop
iconView.EnableModelDragDest(dndTargetTable, Gdk.DragAction.Copy);
iconView.DragDataReceived += new
DragDataReceivedHandler(OnDragDataReceived);
...
protected void OnDragDataReceived (object sender, DragDataReceivedArgs args)
{
if (args.SelectionData.Text == null ||
args.SelectionData.Text.Length <= 0)
{
// On Windows args.SelectionData.Text is ""
Drag.Finish(args.Context, false, false, args.Time);
return;
}
IconViewDropPosition pos;
TreePath path;
// Get Dest Item Position
if (iconView.GetDestItemAtPos(args.X, args.Y, out path, out pos) ==
false) {
Drag.Finish(args.Context, false, false, args.Time);
return;
}
// Get Drop Uri
string[] filesUri = Regex.Split(args.SelectionData.Text, "\r\n");
foreach (string uri in filesUri) {
if (uri == null || uri.Equals("") || uri.Length == 0)
continue;
string filePath = uri;
// Start Event Send File:
if (filePath.StartsWith("file://") == true)
filePath = filePath.Substring(7);
Gtk.Application.Invoke(delegate {
if (SendFile != null) SendFile(this, userInfo, filePath);
});
}
Drag.Finish(args.Context, true, false, args.Time);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/gtk-sharp-list/attachments/20060908/232e613d/attachment.html
More information about the Gtk-sharp-list
mailing list