Widget.connectDragDataReceived

Connect to DragDataReceived signal.

The ::drag-data-received signal is emitted on the drop site when the dragged data has been received. If the data was received in order to determine whether the drop will be accepted, the handler is expected to call gdk.global.dragStatus and not finish the drag. If the data was received in response to a #GtkWidget::drag-drop signal (and this is the last target to be received), the handler for this signal is expected to process the received data and then call gtk.global.dragFinish, setting the success parameter depending on whether the data was processed successfully.

Applications must create some means to determine why the signal was emitted and therefore whether to call gdk.global.dragStatus or gtk.global.dragFinish.

The handler may inspect the selected action with gdk.drag_context.DragContext.getSelectedAction before calling gtk.global.dragFinish, e.g. to implement gdk.types.DragAction.Ask as shown in the following example:

void
drag_data_received (GtkWidget          *widget,
                    GdkDragContext     *context,
                    gint                x,
                    gint                y,
                    GtkSelectionData   *data,
                    guint               info,
                    guint               time)
{
  if ((data->length >= 0) && (data->format == 8))
    {
      GdkDragAction action;

      // handle data here

      action = gdk_drag_context_get_selected_action (context);
      if (action == GDK_ACTION_ASK)
        {
          GtkWidget *dialog;
          gint response;

          dialog = gtk_message_dialog_new (NULL,
                                           GTK_DIALOG_MODAL |
                                           GTK_DIALOG_DESTROY_WITH_PARENT,
                                           GTK_MESSAGE_INFO,
                                           GTK_BUTTONS_YES_NO,
                                           "Move the data ?\n");
          response = gtk_dialog_run (GTK_DIALOG (dialog));
          gtk_widget_destroy (dialog);

          if (response == GTK_RESPONSE_YES)
            action = GDK_ACTION_MOVE;
          else
            action = GDK_ACTION_COPY;
         }

      gtk_drag_finish (context, TRUE, action == GDK_ACTION_MOVE, time);
    }
  else
    gtk_drag_finish (context, FALSE, FALSE, time);
 }
class Widget
gulong
connectDragDataReceived
(
T
)
(,
Flag!"After" after = No.After
)
if (
isCallable!T &&
is(ReturnType!T == void)
&&
(
Parameters!T.length < 1 ||
(
ParameterStorageClassTuple!T[0] == ParameterStorageClass.none &&
is(Parameters!T[0] : gdk.drag_context.DragContext)
)
)
&&
(
Parameters!T.length < 2 ||
(
ParameterStorageClassTuple!T[1] == ParameterStorageClass.none &&
is(Parameters!T[1] == int)
)
)
&&
(
Parameters!T.length < 3 ||
(
ParameterStorageClassTuple!T[2] == ParameterStorageClass.none &&
is(Parameters!T[2] == int)
)
)
&&
(
Parameters!T.length < 4 ||
(
ParameterStorageClassTuple!T[3] == ParameterStorageClass.none &&
)
)
&&
(
Parameters!T.length < 5 ||
(
ParameterStorageClassTuple!T[4] == ParameterStorageClass.none &&
is(Parameters!T[4] == uint)
)
)
&&
(
Parameters!T.length < 6 ||
(
ParameterStorageClassTuple!T[5] == ParameterStorageClass.none &&
is(Parameters!T[5] == uint)
)
)
&&
(
Parameters!T.length < 7 ||
(
ParameterStorageClassTuple!T[6] == ParameterStorageClass.none &&
is(Parameters!T[6] : gtk.widget.Widget)
)
)
&&
Parameters!T.length < 8
)

Parameters

callback T

signal callback delegate or function to connect

void callback(gdk.drag_context.DragContext context, int x, int y, gtk.selection_data.SelectionData data, uint info, uint time, gtk.widget.Widget widget)

context the drag context (optional)

x where the drop happened (optional)

y where the drop happened (optional)

data the received data (optional)

info the info that has been registered with the target in the #GtkTargetList (optional)

time the timestamp at which the data was received (optional)

widget the instance the signal is connected to (optional)

after Flag!"After"

Yes.After to execute callback after default handler, No.After to execute before (default)

Return Value

Type: gulong

Signal ID