All pastes #614431 Raw Edit

Something

public text v1 · immutable
·published 2007-07-11 15:27 UTC
rendered paste body
<?php

$wnd = new GtkWindow();
$wnd->set_title('PHP-GTK PHP9P Demo');
$wnd->connect_simple('destroy', array('gtk', 'main_quit'));

$vbox = new GtkVbox();

$hbox1 = new GtkHbox();
$addresslbl = new GtkLabel('9P Address');
$address = new GtkEntry();

$hbox2 = new GtkHbox();
$pathlbl = new GtkLabel('Path/File');
$path = new GtkEntry();

$hbox3 = new GtkHbox();
$list = new GtkButton('list');
$list->connect_simple('clicked', 'ls');
$read = new GtkButton('Read');
$read->set_sensitive(false);

$outputscl = new GtkScrolledWindow();
$output = new GtkTextView();
$outputscl->add($output);

$wnd->add($vbox);
$vbox->pack_start($outputscl);
$vbox->pack_start($hbox1, false, false);
$vbox->pack_start($hbox2, false, false);
$vbox->pack_start($hbox3, false, false);
$hbox1->pack_start($addresslbl, false, false);
$hbox1->pack_start($address);
$hbox2->pack_start($pathlbl, false, false);
$hbox2->pack_start($path);
$hbox3->pack_start($list);
$hbox3->pack_start($read);

$wnd->show_all();

Gtk::main();

function ls() {
  global $address, $path, $output;
  $addr = $address->get_text();
  $file = $path->get_text();
  $client = new IxpClient($addr);
  echo "Client for $addr Created\n";
  $stats = $client->statDir($file);
  echo "statDir Called\n";
  $names = array();

  foreach ($stats as $stat) {
    $mode = $stat->getMode();
    echo "stat getMode called\n";
    $time = $stat->getTime();
    echo "stat getTime called\n";
    $names[$stat->name] = $mode."\t".$stat->uid."\t".$stat->gid."\t".$time;
  }
  ksort($names);
  $out = '';
  foreach ($names as $name=>$det)
    $out .= $det."\t".$name."\n";
  $output->get_buffer()->set_text($out);
  $client->unmount();
}