当前位置: 首页>>代码示例>>C#>>正文


C# Gdk.ListTargets方法代码示例

本文整理汇总了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);
			}
		}
开发者ID:MatteoNardi,项目名称:Tomboy,代码行数:69,代码来源:NoteEditor.cs

示例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;
            }
        }
开发者ID:mono,项目名称:xwt,代码行数:35,代码来源:WidgetBackend.cs

示例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);
        }
开发者ID:knocte,项目名称:banshee,代码行数:14,代码来源:SourceView_DragAndDrop.cs


注:本文中的Gdk.ListTargets方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。