private void lstStyles_DragDrop(object sender, DragDropArgs e) { if (e.Context.Targets.Length != 0) { Gdk.Atom targ = null; foreach (Gdk.Atom t in e.Context.Targets) { if (t.Name == "STRING") { targ = t; lstStyles.DragDataReceived -= lstStyles_DragDataReceived_Motion; lstStyles.DragDataReceived += lstStyles_DragDataReceived_Drop; Gtk.Drag.GetData((Gtk.Widget)sender, e.Context, targ, e.Time); e.RetVal = true; break; } } if (targ == null) { e.RetVal = false; } } else { e.RetVal = false; } }
/// <summary> /// Copies all text in the text area to the clipboard. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Copy(object sender, EventArgs e) { Gdk.Atom modelClipboard = Gdk.Atom.Intern("CLIPBOARD", false); Clipboard cb = Clipboard.Get(modelClipboard); cb.Text = Error; }
public bool WaitIsTargetAvailable(Gdk.Atom target) { bool raw_ret = gtk_clipboard_wait_is_target_available(Handle, target == null ? IntPtr.Zero : target.Handle); bool ret = raw_ret; return(ret); }
public static Gtk.Clipboard Get(Gdk.Atom selection) { IntPtr raw_ret = gtk_clipboard_get(selection == null ? IntPtr.Zero : selection.Handle); Gtk.Clipboard ret = GLib.Object.GetObject(raw_ret) as Gtk.Clipboard; return(ret); }
public Gtk.SelectionData WaitForContents(Gdk.Atom target) { IntPtr raw_ret = gtk_clipboard_wait_for_contents(Handle, target == null ? IntPtr.Zero : target.Handle); Gtk.SelectionData ret = raw_ret == IntPtr.Zero ? null : (Gtk.SelectionData)GLib.Opaque.GetOpaque(raw_ret, typeof(Gtk.SelectionData), true); return(ret); }
public bool WaitForTargets(Gdk.Atom targets, out int n_targets) { bool raw_ret = gtk_clipboard_wait_for_targets(Handle, targets == null ? IntPtr.Zero : targets.Handle, out n_targets); bool ret = raw_ret; return(ret); }
public static bool OwnerSet(Gtk.Widget widget, Gdk.Atom selection, uint time_) { bool raw_ret = gtk_selection_owner_set(widget == null ? IntPtr.Zero : widget.Handle, selection == null ? IntPtr.Zero : selection.Handle, time_); bool ret = raw_ret; return(ret); }
public void SetClipboardText(string text) { Gdk.Atom modelClipboard = Gdk.Atom.Intern("_APSIM_MODEL", false); Clipboard cb = Clipboard.Get(modelClipboard); cb.Text = text; }
public static void AddTargets(Gtk.Widget widget, Gdk.Atom selection, Gtk.TargetEntry targets, uint ntargets) { IntPtr native_targets = GLib.Marshaller.StructureToPtrAlloc(targets); gtk_selection_add_targets(widget == null ? IntPtr.Zero : widget.Handle, selection == null ? IntPtr.Zero : selection.Handle, native_targets, ntargets); Marshal.FreeHGlobal(native_targets); }
public static bool Convert(Gtk.Widget widget, Gdk.Atom selection, Gdk.Atom target, uint time_) { bool raw_ret = gtk_selection_convert(widget == null ? IntPtr.Zero : widget.Handle, selection == null ? IntPtr.Zero : selection.Handle, target == null ? IntPtr.Zero : target.Handle, time_); bool ret = raw_ret; return(ret); }
public static bool IncludeUri(Gdk.Atom targets, int n_targets) { bool raw_ret = gtk_targets_include_uri(targets == null ? IntPtr.Zero : targets.Handle, n_targets); bool ret = raw_ret; return(ret); }
public static bool IncludeRichText(Gdk.Atom targets, int n_targets, Gtk.TextBuffer buffer) { bool raw_ret = gtk_targets_include_rich_text(targets == null ? IntPtr.Zero : targets.Handle, n_targets, buffer == null ? IntPtr.Zero : buffer.Handle); bool ret = raw_ret; return(ret); }
public static bool IncludeImage(Gdk.Atom targets, int n_targets, bool writable) { bool raw_ret = gtk_targets_include_image(targets == null ? IntPtr.Zero : targets.Handle, n_targets, writable); bool ret = raw_ret; return(ret); }
public static Gtk.Clipboard GetForDisplay(Gdk.Display display, Gdk.Atom selection) { IntPtr raw_ret = gtk_clipboard_get_for_display(display == null ? IntPtr.Zero : display.Handle, selection == null ? IntPtr.Zero : selection.Handle); Gtk.Clipboard ret = GLib.Object.GetObject(raw_ret) as Gtk.Clipboard; return(ret); }
public static bool ClipboardWaitForTargets(IntPtr cp, out Gdk.Atom[] atoms) { if (Impl.gtk_clipboard_wait_for_targets == null) { atoms = null; return(false); } IntPtr atomPtrs; int count; var success = Impl.gtk_clipboard_wait_for_targets(cp, out atomPtrs, out count); if (!success || count <= 0) { atoms = null; return(false); } atoms = new Gdk.Atom[count]; unsafe { byte *p = (byte *)atomPtrs.ToPointer(); for (int i = 0; i < count; i++) { atoms[i] = new Gdk.Atom(new IntPtr(*p)); p += IntPtr.Size; } } return(true); }
/// <summary> /// Place text on a specific clipboard. /// </summary> /// <param name="text">Text to place on the clipboard.</param> /// <param name="clipboardName">Name of the clipboard.</param> public void SetClipboardText(string text, string clipboardName) { Gdk.Atom modelClipboard = Gdk.Atom.Intern(clipboardName, false); Clipboard cb = Clipboard.Get(modelClipboard); cb.Text = text; }
public bool Find(Gdk.Atom target, out uint info) { bool raw_ret = gtk_target_list_find(Handle, target == null ? IntPtr.Zero : target.Handle, out info); bool ret = raw_ret; return(ret); }
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"); } }
/// <summary> /// Get whatever text is currently on a specific clipboard. /// </summary> /// <param name="clipboardName">Name of the clipboard.</param> /// <returns></returns> public string GetClipboardText(string clipboardName) { Gdk.Atom modelClipboard = Gdk.Atom.Intern(clipboardName, false); Clipboard cb = Clipboard.Get(modelClipboard); return(cb.WaitForText()); }
public static bool OwnerSet(Gdk.Window owner, Gdk.Atom selection, uint time_, bool send_event) { bool raw_ret = gdk_selection_owner_set(owner == null ? IntPtr.Zero : owner.Handle, selection == null ? IntPtr.Zero : selection.Handle, time_, send_event); bool ret = raw_ret; return(ret); }
public static bool OwnerSetForDisplay(Gdk.Display display, Gdk.Window owner, Gdk.Atom selection, uint time_, bool send_event) { bool raw_ret = gdk_selection_owner_set_for_display(display == null ? IntPtr.Zero : display.Handle, owner == null ? IntPtr.Zero : owner.Handle, selection == null ? IntPtr.Zero : selection.Handle, time_, send_event); bool ret = raw_ret; return(ret); }
public static Gdk.Window OwnerGet(Gdk.Atom selection) { IntPtr raw_ret = gdk_selection_owner_get(selection == null ? IntPtr.Zero : selection.Handle); Gdk.Window ret = GLib.Object.GetObject(raw_ret) as Gdk.Window; return(ret); }
public static Gdk.Window OwnerGetForDisplay(Gdk.Display display, Gdk.Atom selection) { IntPtr raw_ret = gdk_selection_owner_get_for_display(display == null ? IntPtr.Zero : display.Handle, selection == null ? IntPtr.Zero : selection.Handle); Gdk.Window ret = GLib.Object.GetObject(raw_ret) as Gdk.Window; return(ret); }
// Methods :: Private :: SetSelectionData private void SetSelectionData (string target, string data, Gtk.DragDataGetArgs args) { Gdk.Atom atom = Gdk.Atom.Intern(target, false); byte [] bytes = System.Text.Encoding.ASCII.GetBytes(data); args.SelectionData.Set(atom, 8, bytes); }
protected virtual void OnPopulatePopup(object sender, Gtk.PopulatePopupArgs e) { Trace.Call(sender, e); if (!_AtLinkTag) { return; } Gtk.Menu popup = e.Menu; // remove all items foreach (Gtk.Widget children in popup.Children) { popup.Remove(children); } Gtk.ImageMenuItem open_item = new Gtk.ImageMenuItem(Gtk.Stock.Open, null); open_item.Activated += delegate { if (_ActiveLink != null) { OpenLink(_ActiveLink); } }; popup.Append(open_item); Gtk.ImageMenuItem copy_item = new Gtk.ImageMenuItem(Gtk.Stock.Copy, null); copy_item.Activated += delegate { Gdk.Atom clipboardAtom = Gdk.Atom.Intern("CLIPBOARD", false); Gtk.Clipboard clipboard = Gtk.Clipboard.Get(clipboardAtom); clipboard.Text = _ActiveLink.ToString(); }; popup.Append(copy_item); popup.ShowAll(); }
public static Gdk.Atom GetSelection(Gdk.DragContext context) { IntPtr raw_ret = gdk_drag_get_selection(context == null ? IntPtr.Zero : context.Handle); Gdk.Atom ret = raw_ret == IntPtr.Zero ? null : (Gdk.Atom)GLib.Opaque.GetOpaque(raw_ret, typeof(Gdk.Atom), false); return(ret); }
public static Gdk.Atom DestFindTarget(Gtk.Widget widget, Gdk.DragContext context, Gtk.TargetList target_list) { IntPtr raw_ret = gtk_drag_dest_find_target(widget == null ? IntPtr.Zero : widget.Handle, context == null ? IntPtr.Zero : context.Handle, target_list == null ? IntPtr.Zero : target_list.Handle); Gdk.Atom ret = raw_ret == IntPtr.Zero ? null : (Gdk.Atom)GLib.Opaque.GetOpaque(raw_ret, typeof(Gdk.Atom), false); return(ret); }
public static byte Change(Gdk.Window window, Gdk.Atom property, Gdk.Atom type, int format, Gdk.PropMode mode, int nelements) { byte data; gdk_property_change2(window == null ? IntPtr.Zero : window.Handle, property == null ? IntPtr.Zero : property.Handle, type == null ? IntPtr.Zero : type.Handle, format, (int)mode, out data, nelements); return(data); }
/// <summary> /// Get whatever text is currently on the _APSIM_MODEL clipboard /// </summary> /// <returns></returns> public string GetClipboardText() { Gdk.Atom modelClipboard = Gdk.Atom.Intern("_APSIM_MODEL", false); Clipboard cb = Clipboard.Get(modelClipboard); return(cb.WaitForText()); }
/// <summary>Node has been dragged over another node. Allow a drop here?</summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event data.</param> private void OnDragOver(object sender, DragMotionArgs e) { try { // e.Effect = DragDropEffects.None; e.RetVal = false; Gdk.Drag.Status(e.Context, 0, e.Time); // Default to no drop Gdk.Atom target = Drag.DestFindTarget(treeview1, e.Context, null); // Get the drop location TreePath path; TreeIter dest; if (treeview1.GetPathAtPos(e.X, e.Y, out path) && treemodel.GetIter(out dest, path) && target != Gdk.Atom.Intern("GDK_NONE", false)) { AllowDropArgs args = new AllowDropArgs(); args.NodePath = GetFullPath(path); Drag.GetData(treeview1, e.Context, target, e.Time); if (dragDropData != null) { args.DragObject = dragDropData; if (AllowDrop != null) { AllowDrop(this, args); if (args.Allow) { e.RetVal = true; string sourceParent = null; if (sourcePathOfItemBeingDragged != null) { sourceParent = StringUtilities.ParentName(sourcePathOfItemBeingDragged); } // Now determine the effect. If the drag originated from a different view // (e.g. a toolbox or another file) then only copy is supported. if (sourcePathOfItemBeingDragged == null) { Gdk.Drag.Status(e.Context, Gdk.DragAction.Copy, e.Time); } else if (sourceParent == args.NodePath) { Gdk.Drag.Status(e.Context, Gdk.DragAction.Copy, e.Time); } else { // The "SuggestedAction" will normally be Copy, but will be Move // if shift is pressed, and Link if Ctrl-Shift is pressed Gdk.Drag.Status(e.Context, e.Context.SuggestedAction, e.Time); } } } } } } catch (Exception err) { ShowError(err); } }
static DND() { widgetIcon = Gdk.Pixbuf.LoadFromResource ("widget.png"); steticWidgetType = Gdk.Atom.Intern ("application/x-stetic-widget", false); targets = new Gtk.TargetEntry[2]; targets[0] = new Gtk.TargetEntry ("application/x-stetic-widget", 0, SteticType); targets[1] = new Gtk.TargetEntry ((string)GladeUtils.ApplicationXGladeAtom, 0, GladeType); targetList = new Gtk.TargetList (); targetList.Add (steticWidgetType, 0, 0); targetList.Add (GladeUtils.ApplicationXGladeAtom, 0, 1); }
static DND () { try { widgetIcon = Gdk.Pixbuf.LoadFromResource ("widget.png"); } catch (Exception e) { Console.WriteLine ("Error while loading pixbuf 'widget.png': " + e); } steticWidgetType = Gdk.Atom.Intern ("application/x-stetic-widget", false); targets = new Gtk.TargetEntry[2]; targets[0] = new Gtk.TargetEntry (steticWidgetType, 0, SteticType); targets[1] = new Gtk.TargetEntry ((string) GladeUtils.ApplicationXGladeAtom, 0, GladeType); targetList = new Gtk.TargetList (targets); targets = (Gtk.TargetEntry[]) targetList; }
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 if (Platform.IsWindows) { RTF_ATOM = Gdk.Atom.Intern ("Rich Text Format", false); HTML_ATOM = Gdk.Atom.Intern ("HTML Format", false); } else { RTF_ATOM = Gdk.Atom.Intern ("text/rtf", false); HTML_ATOM = Gdk.Atom.Intern ("text/html", false); } var newTargets = new List<TargetEntry> (); newTargets.Add (new TargetEntry ("SAVE_TARGETS", TargetFlags.App, TextType)); newTargets.Add (new TargetEntry (HTML_ATOM.Name, TargetFlags.OtherApp, HTMLTextType)); newTargets.Add (new TargetEntry ("UTF8_STRING", TargetFlags.App, TextType)); newTargets.Add (new TargetEntry (RTF_ATOM.Name, TargetFlags.OtherApp, RichTextType)); if (!Platform.IsWindows) { // This seems to randomly break pasting on Windows. We'll disable it // for now until we find a better solution // https://bugzilla.xamarin.com/show_bug.cgi?id=23036 newTargets.Add (new TargetEntry (MD_ATOM.Name, TargetFlags.App, MonoTextType)); } newTargets.Add (new TargetEntry ("text/plain;charset=utf-8", TargetFlags.App, TextType)); newTargets.Add (new TargetEntry ("text/plain", TargetFlags.App, TextType)); //HACK: work around gtk_selection_data_set_text causing crashes on Mac w/ QuickSilver, Clipbard History etc. if (!Platform.IsMac) { newTargets.Add (new TargetEntry ("COMPOUND_TEXT", TargetFlags.App, TextType)); newTargets.Add (new TargetEntry ("STRING", TargetFlags.App, TextType)); newTargets.Add (new TargetEntry ("TEXT", TargetFlags.App, TextType)); } TargetEntries = newTargets.ToArray (); TargetList = new TargetList (TargetEntries); }
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"); } }
public static bool Get(Gdk.Window window, Gdk.Atom property, ulong offset, ulong length, bool pdelete, out Gdk.Atom[] atoms) { int[] raw_atoms; if (!Get (window, property, Gdk.Atom.Intern ("ATOM", false), offset, length, pdelete, out raw_atoms)) { atoms = null; return false; } atoms = new Gdk.Atom [raw_atoms.GetLength (0)]; for (int idx = 0; idx < raw_atoms.GetLength (0); idx++) { atoms [idx] = new Gdk.Atom (new IntPtr (raw_atoms [idx])); } return true; }
public static bool ClipboardWaitForTargets(IntPtr cp, out Gdk.Atom[] atoms) { if (Impl.gtk_clipboard_wait_for_targets == null) { atoms = null; return false; } IntPtr atomPtrs; int count; var success = Impl.gtk_clipboard_wait_for_targets(cp, out atomPtrs, out count); if (!success || count <= 0) { atoms = null; return false; } atoms = new Gdk.Atom[count]; unsafe { byte* p = (byte*)atomPtrs.ToPointer(); for (int i = 0; i < count; i++) { atoms[i] = new Gdk.Atom(new IntPtr(*p)); p += IntPtr.Size; } } return true; }
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 if (Platform.IsWindows) { RTF_ATOM = Gdk.Atom.Intern ("Rich Text Format", false); HTML_ATOM = Gdk.Atom.Intern ("HTML Format", false); } else { RTF_ATOM = Gdk.Atom.Intern ("text/rtf", false); HTML_ATOM = Gdk.Atom.Intern ("text/html", false); } var newTargets = new List<TargetEntry> (); newTargets.Add (new TargetEntry ("SAVE_TARGETS", TargetFlags.App, TextType)); newTargets.Add (new TargetEntry (HTML_ATOM.Name, TargetFlags.OtherApp, HTMLTextType)); newTargets.Add (new TargetEntry ("UTF8_STRING", TargetFlags.App, TextType)); newTargets.Add (new TargetEntry (RTF_ATOM.Name, TargetFlags.OtherApp, RichTextType)); newTargets.Add (new TargetEntry (MD_ATOM.Name, TargetFlags.App, MonoTextType)); newTargets.Add (new TargetEntry ("text/plain;charset=utf-8", TargetFlags.App, TextType)); newTargets.Add (new TargetEntry ("text/plain", TargetFlags.App, TextType)); //HACK: work around gtk_selection_data_set_text causing crashes on Mac w/ QuickSilver, Clipbard History etc. if (!Platform.IsMac) { newTargets.Add (new TargetEntry ("COMPOUND_TEXT", TargetFlags.App, TextType)); newTargets.Add (new TargetEntry ("STRING", TargetFlags.App, TextType)); newTargets.Add (new TargetEntry ("TEXT", TargetFlags.App, TextType)); } TargetEntries = newTargets.ToArray (); TargetList = new TargetList (TargetEntries); }