Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 11c5630b2c8f00f64861e0dac51a202a > files > 46

php-gtk2-2.0.1-12mdv2010.0.i586.rpm

<?php
/**
*   WORKS as of 2006-06-19 with php 5.1.4
*   Seems it has been fixed either in Zend or php-gtk2
*
*   Bug in drag'n'drop:
*   Drag from "from" button to "to" button and close the window.
*   You will get a segfault.
*
*   Backtrace for the segfault:
-------------------------
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 16384 (LWP 20597)]
0x0831d37f in shutdown_memory_manager (silent=0, full_shutdown=0)
    at /data/cvs/php/php-5.1.2/Zend/zend_alloc.c:511
511                                     REMOVE_POINTER_FROM_LIST(ptr);
(gdb) bt
#0  0x0831d37f in shutdown_memory_manager (silent=0, full_shutdown=0)
    at /data/cvs/php/php-5.1.2/Zend/zend_alloc.c:511
#1  0x082f850d in php_request_shutdown (dummy=0x0)
    at /data/cvs/php/php-5.1.2/main/main.c:1303
#2  0x0839f120 in main (argc=2, argv=0xbfb79c64)
    at /data/cvs/php/php-5.1.2/sapi/cli/php_cli.c:1230
-------------------------

*/
$wnd = new GtkWindow();
$wnd->connect_simple('destroy', array('Gtk', 'main_quit'));
$hbox = new GtkHBox();
$wnd->add($hbox);

$btnFrom = new GtkButton('From');
$btnTo   = new GtkButton('To');

$hbox->pack_start($btnFrom);
$hbox->pack_start($btnTo);

$btnFrom->drag_source_set(
    Gdk::BUTTON1_MASK,
    //change to text/plain, and it works
    array(array('text/xml', 0, 1)),
    Gdk::ACTION_COPY | Gdk::ACTION_MOVE
);


$btnTo->drag_dest_set(
    Gtk::DEST_DEFAULT_ALL,
    //change to text/plain, and it works
    array(array('text/xml', 0, 1)),
    Gdk::ACTION_COPY | Gdk::ACTION_MOVE
);

$btnTo->connect('drag-drop', 'onDragDrop');

function onDragDrop($widget, $context, $x, $y, $time) {
    global $strMimeType, $strTypeNumber;

    echo "drag-drop\r\n";
    var_dump(
        $widget->drag_dest_find_target(
            $context, array(array('text/xml', 0, 1))
        )
    );
}

$wnd->show_all();
Gtk::main();
?>