GetSelectionData() public static method

public static GetSelectionData ( ApplicationContext context, Gtk data, TransferDataStore target ) : bool
context ApplicationContext
data Gtk
target TransferDataStore
return bool
Esempio n. 1
0
        internal bool DoDragDataReceived(Gdk.DragContext context, int x, int y, Gtk.SelectionData selectionData, uint info, uint time)
        {
            if (DragDropInfo.DragDataRequests == 0)
            {
                // Got the data without requesting it. Create the datastore here
                DragDropInfo.DragData         = new TransferDataStore();
                DragDropInfo.LastDragPosition = new Point(x, y);
                DragDropInfo.DragDataRequests = 1;
            }

            DragDropInfo.DragDataRequests--;

            if (!Util.GetSelectionData(selectionData, DragDropInfo.DragData))
            {
                return(false);
            }

            if (DragDropInfo.DragDataRequests == 0)
            {
                if (DragDropInfo.DragDataForMotion)
                {
                    // This is a workaround to what seems to be a mac gtk bug.
                    // Suggested action is set to all when no control key is pressed
                    var cact = ConvertDragAction(context.Actions);
                    if (cact == DragDropAction.All)
                    {
                        cact = DragDropAction.Move;
                    }

                    DragOverEventArgs da = new DragOverEventArgs(DragDropInfo.LastDragPosition, DragDropInfo.DragData, cact);
                    Toolkit.Invoke(delegate {
                        EventSink.OnDragOver(da);
                    });
                    OnSetDragStatus(context, (int)DragDropInfo.LastDragPosition.X, (int)DragDropInfo.LastDragPosition.Y, time, ConvertDragAction(da.AllowedAction));
                    return(true);
                }
                else
                {
                    // Use Context.Action here since that's the action selected in DragOver
                    var           cda = ConvertDragAction(context.Action);
                    DragEventArgs da  = new DragEventArgs(DragDropInfo.LastDragPosition, DragDropInfo.DragData, cda);
                    Toolkit.Invoke(delegate {
                        EventSink.OnDragDrop(da);
                    });
                    Gtk.Drag.Finish(context, da.Success, cda == DragDropAction.Move, time);
                    return(true);
                }
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        public object GetData(TransferDataType type)
        {
            if (type == TransferDataType.Text)
            {
                return(clipboard.WaitForText());
            }
            if (type == TransferDataType.Text)
            {
                return(clipboard.WaitForImage());
            }

            TransferDataStore store = new TransferDataStore();

            foreach (var at in GetAtomsForType(type))
            {
                var data = clipboard.WaitForContents(at);
                Util.GetSelectionData(data, store);
            }
            return(((ITransferData)store).GetValue(type));
        }
Esempio n. 3
0
        public override object GetData(TransferDataType type)
        {
            if (type == TransferDataType.Text)
            {
                return(clipboard.WaitForText());
            }
            if (type == TransferDataType.Image)
            {
                return(ApplicationContext.Toolkit.WrapImage(new GtkImage(clipboard.WaitForImage())));
            }

            TransferDataStore store = new TransferDataStore();

            foreach (var at in GetAtomsForType(type))
            {
                var data = clipboard.WaitForContents(at);
                Util.GetSelectionData(ApplicationContext, data, store);
            }
            return(((ITransferData)store).GetValue(type));
        }
Esempio n. 4
0
        void DataReceived(Gtk.Clipboard cb, Gtk.SelectionData data)
        {
            TransferDataStore store = new TransferDataStore();

            if (Util.GetSelectionData(data, store))
            {
                Result = ((ITransferData)store).GetValue(type);
                SetComplete();
            }
            else
            {
                if (++index < atoms.Length)
                {
                    RequestData();
                }
                else
                {
                    SetComplete();
                }
            }
        }
Esempio n. 5
0
        internal bool DoDragDataReceived(Gdk.DragContext context, int x, int y, Gtk.SelectionData selectionData, uint info, uint time)
        {
            if (DragDropInfo.DragDataRequests == 0)
            {
                // Got the data without requesting it. Create the datastore here
                DragDropInfo.DragData         = new TransferDataStore();
                DragDropInfo.LastDragPosition = new Point(x, y);
                DragDropInfo.DragDataRequests = 1;
            }

            DragDropInfo.DragDataRequests--;

            if (!Util.GetSelectionData(ApplicationContext, selectionData, DragDropInfo.DragData))
            {
                return(false);
            }

            if (DragDropInfo.DragDataRequests == 0)
            {
                if (DragDropInfo.DragDataForMotion)
                {
                    // If no specific action is set, it means that no key has been pressed.
                    // In that case, use Move or Copy or Link as default (when allowed, in this order).
                    var cact = ConvertDragAction(context.Actions);
                    if (cact != DragDropAction.Copy && cact != DragDropAction.Move && cact != DragDropAction.Link)
                    {
                        if (cact.HasFlag(DragDropAction.Move))
                        {
                            cact = DragDropAction.Move;
                        }
                        else if (cact.HasFlag(DragDropAction.Copy))
                        {
                            cact = DragDropAction.Copy;
                        }
                        else if (cact.HasFlag(DragDropAction.Link))
                        {
                            cact = DragDropAction.Link;
                        }
                        else
                        {
                            cact = DragDropAction.None;
                        }
                    }

                    DragOverEventArgs da = new DragOverEventArgs(DragDropInfo.LastDragPosition, DragDropInfo.DragData, cact);
                    ApplicationContext.InvokeUserCode(delegate {
                        EventSink.OnDragOver(da);
                    });
                    OnSetDragStatus(context, (int)DragDropInfo.LastDragPosition.X, (int)DragDropInfo.LastDragPosition.Y, time, ConvertDragAction(da.AllowedAction));
                    return(true);
                }
                else
                {
                    // Use Context.Action here since that's the action selected in DragOver
                    var           cda = ConvertDragAction(context.Action);
                    DragEventArgs da  = new DragEventArgs(DragDropInfo.LastDragPosition, DragDropInfo.DragData, cda);
                    ApplicationContext.InvokeUserCode(delegate {
                        EventSink.OnDragDrop(da);
                    });
                    Gtk.Drag.Finish(context, da.Success, cda == DragDropAction.Move, time);
                    return(true);
                }
            }
            else
            {
                return(false);
            }
        }