コード例 #1
0
            static CopyOperation()
            {
                if (Platform.IsMac)
                {
                    RTF_ATOM = Gdk.Atom.Intern("NSRTFPboardType", false);                      //TODO: use public.rtf when dep on MacOS 10.6
                    const string NSHTMLPboardType = "Apple HTML pasteboard type";
                    HTML_ATOM = Gdk.Atom.Intern(NSHTMLPboardType, false);
                }
                else
                {
                    RTF_ATOM  = Gdk.Atom.Intern("text/rtf", false);
                    HTML_ATOM = Gdk.Atom.Intern("text/html", false);
                }

                targetList = new Gtk.TargetList();
                targetList.Add(HTML_ATOM, /* FLAGS */ 0, HTMLTextType);
                targetList.Add(RTF_ATOM, /* FLAGS */ 0, RichTextType);
                targetList.Add(MD_ATOM, /* FLAGS */ 0, MonoTextType);
                targetList.AddTextTargets(TextType);

                //HACK: work around gtk_selection_data_set_text causing crashes on Mac w/ QuickSilver, Clipbard History etc.
                if (Platform.IsMac)
                {
                    targetList.Remove("COMPOUND_TEXT");
                    targetList.Remove("TEXT");
                    targetList.Remove("STRING");
                }
            }
コード例 #2
0
 static CopyOperation()
 {
     targetList = new Gtk.TargetList();
     targetList.Add(RTF_ATOM, /* FLAGS */ 0, RichTextType);
     targetList.Add(MD_ATOM, /* FLAGS */ 0, MonoTextType);
     targetList.AddTextTargets(TextType);
 }
コード例 #3
0
			static CopyOperation ()
			{
				if (Platform.IsMac) {
					RTF_ATOM = Gdk.Atom.Intern ("NSRTFPboardType", false); //TODO: use public.rtf when dep on MacOS 10.6
					const string NSHTMLPboardType = "Apple HTML pasteboard type";
					HTML_ATOM = Gdk.Atom.Intern (NSHTMLPboardType, false);
				} else {
					RTF_ATOM = Gdk.Atom.Intern ("text/rtf", false);
					HTML_ATOM = Gdk.Atom.Intern ("text/html", false);
				}

				targetList = new Gtk.TargetList ();
				targetList.Add (HTML_ATOM, /* FLAGS */0, HTMLTextType);
				targetList.Add (RTF_ATOM, /* FLAGS */0, RichTextType);
				targetList.Add (MD_ATOM, /* FLAGS */0, MonoTextType);
				targetList.AddTextTargets (TextType);

				//HACK: work around gtk_selection_data_set_text causing crashes on Mac w/ QuickSilver, Clipbard History etc.
				if (Platform.IsMac) {
					targetList.Remove ("COMPOUND_TEXT");
					targetList.Remove ("TEXT");
					targetList.Remove ("STRING");
				}
			}
コード例 #4
0
			static CopyOperation ()
			{
				targetList = new Gtk.TargetList ();
				targetList.Add (RTF_ATOM, /* FLAGS */0, RichTextType);
				targetList.Add (MD_ATOM, /* FLAGS */0, MonoTextType);
				targetList.AddTextTargets (TextType);
			}
コード例 #5
0
ファイル: MainWindow.cs プロジェクト: mono/f-spot
		public void HandleCopy (object sender, EventArgs args)
		{
			Clipboard primary = Clipboard.Get (Atom.Intern ("PRIMARY", false));
			Clipboard clipboard = Clipboard.Get (Atom.Intern ("CLIPBOARD", false));

			if (Window.Focus is Editable) {
				(Window.Focus as Editable).CopyClipboard ();
				return;
			}

			TargetList targetList = new TargetList ();
			targetList.AddTextTargets ((uint)DragDropTargets.TargetType.PlainText);
			targetList.AddUriTargets ((uint)DragDropTargets.TargetType.UriList);
			targetList.Add (
				DragDropTargets.CopyFilesEntry.Target,
				(uint)DragDropTargets.CopyFilesEntry.Flags,
				(uint)DragDropTargets.CopyFilesEntry.Info);

			// use eager evaluation, because we want to copy the photos which are currently selected ...
			var uris = new UriList (from p in SelectedPhotos ()
			                                 select p.DefaultVersion.Uri);
			var paths = String.Join (" ",
				                     (from p in SelectedPhotos ()
				                                  select p.DefaultVersion.Uri.LocalPath).ToArray ()
			                     );

			clipboard.SetWithData ((TargetEntry[])targetList, delegate (Clipboard clip, SelectionData data, uint info) {

				if (info == (uint)DragDropTargets.TargetType.PlainText) {
					data.Text = paths;
					return;
				}

				if (info == (uint)DragDropTargets.TargetType.UriList) {
					data.SetUriListData (uris);
					return;
				}

				if (info == DragDropTargets.CopyFilesEntry.Info) {
					data.SetCopyFiles (uris);
					return;
				}

				Log.DebugFormat ("Unknown Selection Data Target (info: {0})", info);
			}, delegate {
			});

			primary.Text = paths;
		}
コード例 #6
0
        protected override void Initialize(IPadWindow window)
        {
            this.window = window;
            dragPad     = new FigmaDragAndDropContent();

            window.PadContentHidden += Container_PadHidden;
            window.PadContentShown  += Container_PadShown;

            widget = new Gtk.GtkNSViewHost(dragPad);

            widget.DragBegin += (o, args) => {
                if (!isDragging)
                {
                    DesignerSupport.DesignerSupport.Service.ToolboxService.DragSelectedItem(widget, args.Context);
                    isDragging = true;
                }
            };

            widget.DragDataGet += (object o, DragDataGetArgs args) => {
                if (selectedNode is IDragDataToolboxNode node)
                {
                    foreach (var format in node.Formats)
                    {
                        args.SelectionData.Set(Gdk.Atom.Intern(format, false), 8, node.GetData(format));
                    }
                }
            };

            widget.DragEnd += (o, args) => {
                isDragging = false;
            };

            dragPad.SelectCode += (sender, e) =>
            {
                if (!string.IsNullOrEmpty(e))
                {
                    var selected = new TextToolboxNode(e);
                    DesignerSupport.DesignerSupport.Service.ToolboxService.SelectItem(selected);
                    DesignerSupport.DesignerSupport.Service.ToolboxService.UseSelectedItem();
                }
            };

            dragPad.DragSourceSet += (s, e) => {
                targets = CreateDefaultTargeList();
                targets.AddTable(e);
            };

            dragPad.DragBegin += (object sender, EventArgs e) => {
                var code = dragPad.GetCode(dragPad.SelectedNode);
                selectedNode = new TextToolboxNode(code);
                DesignerSupport.DesignerSupport.Service.ToolboxService.SelectItem(selectedNode);

                Gtk.Drag.SourceUnset(widget);
                if (selectedNode is IDragDataToolboxNode node)
                {
                    foreach (var format in node.Formats)
                    {
                        targets.Add(format, 0, 0);
                    }
                }
                // Gtk.Application.CurrentEvent and other copied gdk_events seem to have a problem
                // when used as they use gdk_event_copy which seems to crash on de-allocating the private slice.
                IntPtr currentEvent = Components.GtkWorkarounds.GetCurrentEventHandle();
                Gtk.Drag.Begin(widget, targets, Gdk.DragAction.Copy | Gdk.DragAction.Move, 1, new Gdk.Event(currentEvent, false));

                // gtk_drag_begin does not store the event, so we're okay
                Components.GtkWorkarounds.FreeEvent(currentEvent);
            };

            widget.ShowAll();

            if (IdeApp.Workbench != null)
            {
                //IdeApp.Workbench.ActiveDocumentChanged += Workbench_ActiveDocumentChanged;
                IdeApp.Workbench.ActiveDocumentChanged += onActiveDocChanged;  // += new EventHandler(onActiveDocChanged);
                onActiveDocChanged(null, null);
            }
        }