Ejemplo n.º 1
0
 void AddImageEntry(object data, GetClipboardData getData)
 {
     targets.AddImageTargets((uint)clipboard.Count, false);
     clipboard.Add(new ClipboardData
     {
         Data             = data,
         GetClipboardData = getData
     });
     Update();
 }
Ejemplo n.º 2
0
        static Gtk.TargetEntry[] CreateTargetEntries(TransferDataType type)
        {
            lock (dragTargets) {
                Gtk.TargetEntry[] entries;
                if (dragTargets.TryGetValue(type, out entries))
                {
                    return(entries);
                }

                uint id = targetIdCounter++;

                if (type == TransferDataType.Uri)
                {
                    Gtk.TargetList list = new Gtk.TargetList();
                    list.AddUriTargets(id);
                    entries = (Gtk.TargetEntry[])list;
                }
                else if (type == TransferDataType.Text)
                {
                    Gtk.TargetList list = new Gtk.TargetList();
                    list.AddTextTargets(id);
                    //HACK: work around gtk_selection_data_set_text causing crashes on Mac w/ QuickSilver, Clipbard History etc.
                    if (Platform.IsMac)
                    {
                        list.Remove("COMPOUND_TEXT");
                        list.Remove("TEXT");
                        list.Remove("STRING");
                    }
                    entries = (Gtk.TargetEntry[])list;
                }
                else if (type == TransferDataType.Rtf)
                {
                    Gdk.Atom atom;
                    if (Platform.IsMac)
                    {
                        atom = Gdk.Atom.Intern("NSRTFPboardType", false);                          //TODO: use public.rtf when dep on MacOS 10.6
                    }
                    else if (Platform.IsWindows)
                    {
                        atom = Gdk.Atom.Intern("Rich Text Format", false);
                    }
                    else
                    {
                        atom = Gdk.Atom.Intern("text/rtf", false);
                    }
                    entries = new Gtk.TargetEntry[] { new Gtk.TargetEntry(atom, 0, id) };
                }
                else if (type == TransferDataType.Html)
                {
                    Gdk.Atom atom;
                    if (Platform.IsMac)
                    {
                        atom = Gdk.Atom.Intern("Apple HTML pasteboard type", false);                          //TODO: use public.rtf when dep on MacOS 10.6
                    }
                    else if (Platform.IsWindows)
                    {
                        atom = Gdk.Atom.Intern("HTML Format", false);
                    }
                    else
                    {
                        atom = Gdk.Atom.Intern("text/html", false);
                    }
                    entries = new Gtk.TargetEntry[] { new Gtk.TargetEntry(atom, 0, id) };
                }
                else if (type == TransferDataType.Image)
                {
                    Gtk.TargetList list = new Gtk.TargetList();
                    list.AddImageTargets(id, true);
                    entries = (Gtk.TargetEntry[])list;
                }
                else
                {
                    entries = new Gtk.TargetEntry[] { new Gtk.TargetEntry(Gdk.Atom.Intern("application/" + type.Id, false), 0, id) };
                }

                foreach (var a in entries.Select(e => e.Target))
                {
                    atomToType [a] = type;
                }
                return(dragTargets [type] = entries);
            }
        }
Ejemplo n.º 3
0
Archivo: Util.cs Proyecto: mono/xwt
        static Gtk.TargetEntry[] CreateTargetEntries(TransferDataType type)
        {
            lock (dragTargets) {
                Gtk.TargetEntry[] entries;
                if (dragTargets.TryGetValue (type, out entries))
                    return entries;

                uint id = targetIdCounter++;

                if (type == TransferDataType.Uri) {
                    Gtk.TargetList list = new Gtk.TargetList ();
                    list.AddUriTargets (id);
                    entries = (Gtk.TargetEntry[])list;
                }
                else if (type == TransferDataType.Text) {
                    Gtk.TargetList list = new Gtk.TargetList ();
                    list.AddTextTargets (id);
                    //HACK: work around gtk_selection_data_set_text causing crashes on Mac w/ QuickSilver, Clipbard History etc.
                    if (Platform.IsMac) {
                        list.Remove ("COMPOUND_TEXT");
                        list.Remove ("TEXT");
                        list.Remove ("STRING");
                    }
                    entries = (Gtk.TargetEntry[])list;
                } else if (type == TransferDataType.Rtf) {
                    Gdk.Atom atom;
                    if (Platform.IsMac) {
                        atom = Gdk.Atom.Intern ("NSRTFPboardType", false); //TODO: use public.rtf when dep on MacOS 10.6
                    } else if (Platform.IsWindows) {
                        atom = Gdk.Atom.Intern ("Rich Text Format", false);
                    } else {
                        atom = Gdk.Atom.Intern ("text/rtf", false);
                    }
                    entries = new Gtk.TargetEntry[] { new Gtk.TargetEntry (atom, 0, id) };
                }
                else if (type == TransferDataType.Html) {
                    Gdk.Atom atom;
                    if (Platform.IsMac) {
                        atom = Gdk.Atom.Intern ("Apple HTML pasteboard type", false); //TODO: use public.rtf when dep on MacOS 10.6
                    } else if (Platform.IsWindows) {
                        atom = Gdk.Atom.Intern ("HTML Format", false);
                    } else {
                        atom = Gdk.Atom.Intern ("text/html", false);
                    }
                    entries = new Gtk.TargetEntry[] { new Gtk.TargetEntry (atom, 0, id) };
                }
                else if (type == TransferDataType.Image) {
                    Gtk.TargetList list = new Gtk.TargetList ();
                    list.AddImageTargets (id, true);
                    entries = (Gtk.TargetEntry[])list;
                }
                else {
                    entries = new Gtk.TargetEntry[] { new Gtk.TargetEntry (Gdk.Atom.Intern ("application/" + type.Id, false), 0, id) };
                }

                foreach (var a in entries.Select (e => e.Target))
                    atomToType [a] = type;
                return dragTargets [type] = entries;
            }
        }