Exemplo n.º 1
0
        public static bool GetSelectionData(ApplicationContext context, Gtk.SelectionData data, TransferDataStore target)
        {
            TransferDataType type = Util.AtomToType(data.Target.Name);

            if (type == null || data.Length <= 0)
            {
                return(false);
            }

            if (type == TransferDataType.Text)
            {
                target.AddText(data.Text);
            }
            else if (data.TargetsIncludeImage(false))
            {
                target.AddImage(context.Toolkit.WrapImage(data.Pixbuf));
            }
            else if (type == TransferDataType.Uri)
            {
                target.AddUris(data.GetUris().Where(u => !string.IsNullOrEmpty(u)).Select(u => new Uri(u)).ToArray());
            }
            else
            {
                target.AddValue(type, data.Data);
            }
            return(true);
        }
Exemplo n.º 2
0
        public static bool GetSelectionData(Gtk.SelectionData data, TransferDataStore target)
        {
            TransferDataType type = Util.AtomToType(data.Target.Name);

            if (type == null || data.Length <= 0)
            {
                return(false);
            }

            if (type == TransferDataType.Text)
            {
                target.AddText(data.Text);
            }
            else if (data.TargetsIncludeImage(false))
            {
                target.AddImage(WidgetRegistry.CreateFrontend <Xwt.Drawing.Image> (data.Pixbuf));
            }
            else if (type == TransferDataType.Uri)
            {
                var uris = System.Text.Encoding.UTF8.GetString(data.Data).Split('\n').Where(u => !string.IsNullOrEmpty(u)).Select(u => new Uri(u)).ToArray();
                target.AddUris(uris);
            }
            else
            {
                target.AddValue(type, data.Data);
            }
            return(true);
        }