本文整理汇总了C#中Gdk.ListTargets方法的典型用法代码示例。如果您正苦于以下问题:C# Gdk.ListTargets方法的具体用法?C# Gdk.ListTargets怎么用?C# Gdk.ListTargets使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdk
的用法示例。
在下文中一共展示了Gdk.ListTargets方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnDragDataReceived
//
// DND Drop handling
//
protected override void OnDragDataReceived (Gdk.DragContext context,
int x,
int y,
Gtk.SelectionData selection_data,
uint info,
uint time)
{
bool has_url = false;
foreach (Gdk.Atom target in context.ListTargets()) {
if (target.Name == "text/uri-list" ||
target.Name == "_NETSCAPE_URL") {
has_url = true;
break;
}
}
if (has_url) {
UriList uri_list = new UriList (selection_data);
bool more_than_one = false;
// Place the cursor in the position where the uri was
// dropped, adjusting x,y by the TextView's VisibleRect.
Gdk.Rectangle rect = VisibleRect;
int adjustedX = x + rect.X;
int adjustedY = y + rect.Y;
Gtk.TextIter cursor = GetIterAtLocation (adjustedX, adjustedY);
Buffer.PlaceCursor (cursor);
Gtk.TextTag link_tag = Buffer.TagTable.Lookup ("link:url");
foreach (Uri uri in uri_list) {
Logger.Debug ("Got Dropped URI: {0}", uri);
string insert;
if (uri.IsFile) {
// URL-escape the path in case
// there are spaces (bug #303902)
insert = System.Uri.EscapeUriString (uri.LocalPath);
} else {
insert = uri.ToString ();
}
if (insert == null || insert.Trim () == String.Empty)
continue;
if (more_than_one) {
cursor = Buffer.GetIterAtMark (Buffer.InsertMark);
// FIXME: The space here is a hack
// around a bug in the URL Regex which
// matches across newlines.
if (cursor.LineOffset == 0)
Buffer.Insert (ref cursor, " \n");
else
Buffer.Insert (ref cursor, ", ");
}
Buffer.InsertWithTags (ref cursor, insert, link_tag);
more_than_one = true;
}
Gtk.Drag.Finish (context, more_than_one, false, time);
} else {
base.OnDragDataReceived (context, x, y, selection_data, info, time);
}
}
示例2: DoDragDrop
internal bool DoDragDrop(Gdk.DragContext context, int x, int y, uint time)
{
DragDropInfo.LastDragPosition = new Point (x, y);
var cda = ConvertDragAction (context.GetSelectedAction());
DragDropResult res;
if ((enabledEvents & WidgetEvent.DragDropCheck) == 0) {
if ((enabledEvents & WidgetEvent.DragDrop) != 0)
res = DragDropResult.None;
else
res = DragDropResult.Canceled;
}
else {
DragCheckEventArgs da = new DragCheckEventArgs (new Point (x, y), Util.GetDragTypes (context.ListTargets ()), cda);
ApplicationContext.InvokeUserCode (delegate {
EventSink.OnDragDropCheck (da);
});
res = da.Result;
if ((enabledEvents & WidgetEvent.DragDrop) == 0 && res == DragDropResult.None)
res = DragDropResult.Canceled;
}
if (res == DragDropResult.Canceled) {
Gtk.Drag.Finish (context, false, false, time);
return true;
}
else if (res == DragDropResult.Success) {
Gtk.Drag.Finish (context, true, cda == DragDropAction.Move, time);
return true;
}
else {
// Undefined, we need more data
QueryDragData (context, time, false);
return true;
}
}
示例3: OnDragDataGet
protected override void OnDragDataGet(Gdk.DragContext context, SelectionData selectionData,
uint info, uint time)
{
switch ((DragDropTargetType)info) {
case DragDropTargetType.Source:
new DragDropList<Source> (ServiceManager.SourceManager.ActiveSource,
selectionData, context.ListTargets ()[0]);
break;
default:
return;
}
base.OnDragDataGet (context, selectionData, info, time);
}