Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > c67b354c377ee9ec45db6a53a77f3916 > files > 3

php-pear-Gtk_FileDrop-1.0.2-3mdv2010.0.noarch.rpm

<?php
/**
*   Bigger test application for Gtk_FileDrop class
*   Uses different MIME Types and file extensions
*   as well as callbacks with objects
*
*   @author Christian Weiske <cweiske@cweiske.de>
*/
if (!extension_loaded('gtk')) {	
    dl('php_gtk.' . PHP_SHLIB_SUFFIX);
}
require_once('Gtk/FileDrop.php');

class Test 
{
    var $te = 'asd';
    function Test() {
        $this->te = time();
    }
    function try($widget, $arFiles)
    {
        echo $this->te . ' test';
        var_dump(get_class($widget), $arFiles);
    }
}

$window = &new GtkWindow();
$window->set_default_size(300, 300);
$window->connect_object('destroy', array('gtk', 'main_quit'));
$window->show();

$table =& new GtkTable();
$window->add($table);
$arTypes = array(
    array('inode/directory'),
    array('.txt', '.htm', '.html'),
    array('image/*'),
    array('image/png'),
    array('.scott')
);

$nCount = 0;
foreach ($arTypes as $arTypeList) {
    $label =& new GtkLabel(implode( ';', $arTypeList));
    $table->attach($label, 0, 1, $nCount, $nCount + 1, GTK_FILL, GTK_FILL);
    
    $entry =& new GtkButton('drop on me');
    $table->attach($entry, 1, 2, $nCount, $nCount + 1, GTK_EXPAND | GTK_FILL, GTK_FILL);
    
    Gtk_FileDrop::attach($entry, $arTypeList);
    
    $nCount++;
}

$list =& new GtkList();
$table->attach($list, 0, 3, $nCount, $nCount + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL);
Gtk_FileDrop::attach($list, array( 'text/*'));
$nCount++;

$fs =& new GtkFileSelection('select a php file');
Gtk_FileDrop::attach($fs, array( 'text/php', '.php', 'inode/directory'));
$fs->show();

$cmb =& new GtkCombo();
$table->attach($cmb, 0, 3, $nCount, $nCount + 1, GTK_FILL, GTK_FILL);
$test = new Test();
Gtk_FileDrop::attach($cmb, array( 'text/plain'), array( &$test, 'try'), false);

$test->te = 'asd';
$window->show_all();
gtk::main();
?>