Ejemplo n.º 1
0
        static Gtk.TargetEntry[] CreateTargetEntries(string type)
        {
            lock (dragTargets) {
                Gtk.TargetEntry[] entries;
                if (dragTargets.TryGetValue(type, out entries))
                {
                    return(entries);
                }

                uint id = targetIdCounter++;

                switch (type)
                {
                case TransferDataType.Uri: {
                    Gtk.TargetList list = new Gtk.TargetList();
                    list.AddUriTargets(id);
                    entries = (Gtk.TargetEntry[])list;
                    break;
                }

                case 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;
                    break;
                }

                case 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
                    {
                        atom = Gdk.Atom.Intern("text/rtf", false);
                    }
                    entries = new Gtk.TargetEntry[] { new Gtk.TargetEntry(atom, 0, id) };
                    break;
                }

                default:
                    entries = new Gtk.TargetEntry[] { new Gtk.TargetEntry(Gdk.Atom.Intern("application/" + type, false), 0, id) };
                    break;
                }
                foreach (var a in entries.Select(e => e.Target))
                {
                    atomToType [a] = type;
                }
                return(dragTargets [type] = entries);
            }
        }
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
                        atom = Gdk.Atom.Intern ("text/rtf", false);
                    entries = new Gtk.TargetEntry[] { new Gtk.TargetEntry (atom, 0, id) };
                }
                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
        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);
            }
        }