define('TYPE_IMAGE', 1);
define('TYPE_PDF' , 2);
define('TYPE_OTHER', 3);
$targets = array(
array( 'image/jpg' , 0, TYPE_IMAGE),
array( 'image/jpeg', 0, TYPE_IMAGE),
array( 'image/gif' , 0, TYPE_IMAGE),
array( 'image/png' , 0, TYPE_IMAGE),
array( 'application/pdf', 0, TYPE_PDF),
array( 'text/plain' , 0, TYPE_OTHER)
);
$list->drag_dest_set(GTK_DEST_DEFAULT_ALL, $targets, GDK_ACTION_COPY | GDK_ACTION_MOVE);
$list->connect('drag-data-received', 'dnd_drag_data_received');
function dnd_drag_data_received( $widget, $context, $x, $y, $data, $info, $time)
{
if( $info == TYPE_IMAGE) { handle_image( $data); return; }
//do different things with pdf and other type here
}
|