GtkWidget::drag_dest_set

GtkWidget::drag_dest_set

void drag_dest_set( GtkDestDefaults flags , array targets , GdkDragAction actions );

Sets the calling widget as a drag-and-drop destination. flags is one of four GtkDestDefaults values which define how the widget reacts when the drag is over the widget.

The targets parameter defines a list with all data types which can be dropped over the widget. The parameter is an array of arrays of size three:
$targets = array(
//array( target, flags, info),
  array( 'text/plain', GTK_TARGET_SAME_APP, 0),
  array( 'text/uri-list', 0, 1)
);
In our example, the widget would accept textual data and files. The files could be dragged from everywhere (flag parameter 0), but the textual data are only accepted if they come from within our application.

It is not possible to use a "*" mime type in the target.

The flags of the targets determine from which widget the drag has to come from:

Table 9. Values for flags

0Accept drags from everywhere.
GTK_TARGET_SAME_APPAccept drags only from widgets of the same application only.
GTK_TARGET_SAME_WIDGETAccept drags only from the same widget. This is useful for e.g. moving items up/down in a list by dragging them.

info allows you to pass a number to the function connected to the "drag-data-received" signal. This is useful when e.g. allowing multiple image types to be dropped, as well as some other non-image types: All image types could be assigned "1" as info parameter, all other types "2" or so. In the drag received function could pass the necessary data to a image open function by checking if the info parameter is "1", without having to compare the mime type.

See also: drag_dest_unset()

© Copyright 2003-2023 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.