here goes de Code
| From: | Unknown Sender | Date: | Thu, 22 Mar 2001 01:30:09 +0000 |
| Subject: | here goes de Code | ||
| Groups: | php.gtk | ||
| Request: | Send a blank email to php-gtk+get-1064@lists.php.net to get a copy of this message | ||
Code of Xcavator:
<?php
/*
Xcavator 1.0
*/
set_time_limit(0);
$ar = array();
if (!class_exists('gtk')) {
if (strtoupper(substr(PHP_OS, 0,3) == 'WIN'))
dl('php_gtk.dll');
else
dl('php_gtk.so');
}
function shutdown() {
print("Chau.\n");
Gtk::main_quit();
}
function GoThru($dir, $texto, $label) {
global $ar, $break, $momento, $is_sensitive, $look_for_dir;
$mlength = $momento->get_length();
$momento->insert_text($dir."\n", strlen($dir."\n"), $mlength);
if($mlength > 200) {
$momento->set_point($mlength);
$momento->backward_delete($mlength);
$momento->thaw;
}
$dirr = $dir;
chdir($dir);
$dir = dir($dir);
if($is_sensitive == false) $texto = strtolower($texto);
while($arch = $dir->read()) {
if($is_sensitive == false) $arch = strtolower($arch);
if(is_dir(getcwd()."/".$arch) && $arch != "." &&
$arch != "..") {
$ar[] = getcwd() ."/".$arch;
if($look_for_dir == true && $arch == $texto) {
$posi = $label->get_length();
$stringie = $dirr . "\n";
$label->insert_text($stringie, strlen($stringie), $posi);
$label->thaw;
if($break == true) return getcwd()."/".$arch;
}
}
elseif($arch == $texto) {
$posi=$label->get_length();
$stringie = $dirr . "\n";
$label->insert_text($stringie, strlen($stringie), $posi);
$label->thaw;
if($break == true) return getcwd()."/".$arch;
}
}
return;
}
function Msg($boton2, $entrada) {
global $statt;
$statt->set_text('Searching...');
$statt->show();
return GoOnce($boton2, $entrada);
}
function GoOnce($boton2, $entrada) {
global $ar, $window, $labelito, $statt;
$ar = null;
chdir("/");
$texto = $entrada->get_text();
$entrada->set_text('Searching for "'. $texto .'" please be
patient...');
$window->set_title('Xcavator is Xcavating...');
GoThru("/", $texto, $labelito);
for($i=0; $i < count($ar); $i++) {
if(GoThru($ar[$i], $texto, $labelito) != "") break;
$ar[$i] = null;
}
$window->set_title('Xcavator has Xcavated');
$statt->set_text('Results...');
$entrada->set_text($texto);
}
function about() {
$window = &new GtkWindow();
$window->set_title('Acerca de Escavator che...');
$window->set_usize(300, 200);
$texto = &new GtkLabel('Escavator por Guido Mauas es un programa que escavara tu rigido en
busca de un archivo '.
'especifico. Es mas rapido que "Buscar" de windows (lo puedes comprobar
buscando un archivo con los dos'.
' y midiendo el tiempo), y pronto tendra nuevas opciones que lo '.
'haran mas potente. Usalo, sirve. Errores conocidos: si no encuentra el archivo lo
buscara por siempre,'.
'(Escavator se toma todo con pasion) ...para cortar una busqueda abre la consola
DOS y oprime CTL-C.');
$texto->set_line_wrap(true);
$window->add($texto);
$texto->show();
$window->show_all();
}
function Stop($B_op2) {
global $break;
$break = $B_op2->get_active();
}
function Sensibiliza($B_op1) {
global $is_sensitive;
$is_sensitive = $B_op1->get_active();
}
function Directoriza($B_op4) {
global $look_for_dir;
$look_for_dir = $B_op4->get_active();
}
$window = &new GtkWindow();
$window->set_title('X C A V A T O R');
$window->connect('destroy', 'shutdown');
$window->set_usize(600, 400);
$window->set_policy(true, true, FALSE);
$box = &new GtkVBox(false, 10);
$window->add($box);
$box->show();
$ag = &new GtkAccelGroup();
$itemf = &new GtkItemFactory(GtkMenuBar::get_type(), '<main>', $ag);
$window->add_accel_group($ag);
$itemf->create_items(array(array('/_Etc...', '', 'about', 0,
'')));
$box->pack_start($itemf->get_widget('<main>'),FALSE,FALSE,0);
$B_op1 = &new GtkCheckButton('Case sensitive');
$B_op1->connect('toggled', 'Sensibiliza');
$B_op2 = &new GtkCheckButton('Stop at first result');
$B_op2->connect('toggled', 'stop');
$B_op3 = &new GtkCheckButton('Find all files with this extension');
$B_op4 = &new GtkCheckButton('I\'m looking for a directory');
$B_op4->connect('toggled', 'Directoriza');
$frame_mami = &new GtkFrame('Xcavator means finding files easily...');
$box_up = &new GtkHBox(true, 10);
$box2 = &new GtkVBox(false, 10);
$box2->pack_start($B_op1);
$box2->pack_start($B_op2);
$box2->pack_start($B_op3);
$box2->pack_start($B_op4);
$B_op1->show();
$B_op2->show();
$B_op3->show();
$B_op4->show();
$frame = &new GtkFrame('Options...');
$frame->add($box2);
$box2->show();
$box_up->pack_start($frame, true, true);
$frame->show();
$frame2 = &new GtkFrame('Actual Xcavator Position...');
$momento = &new GtkText();
$frame2->add($momento);
$momento->show();
$box_up->pack_start($frame2, false, true);
$frame2->show();
$frame_mami->add($box_up);
$box_up->show();
$box->pack_start($frame_mami, false, false);
$frame_mami->show();
$box3 = &new GtkHBox(false, 50);
$entrada = &new GtkEntry();
$box3->pack_start($entrada);
$entrada->show();
$boxie = &new GtkHBox(false, 50);
$boton2 = &new GtkButton('Xcavate Now!');
$boxie->pack_start($boton2, true, false);
$boton2->connect('clicked', 'Msg', $entrada);
$box3->pack_start($boxie);
$boton2->show();
$box->pack_start($box3, false, false);
$statt = &new GtkLabel('');
$box->pack_start($statt, false, false);
$statt->show();
$hbox = &new GtkHBox();
$labelito = &new GtkText();
#$labelito->set_usize(670, 20);
$hbox->pack_start($labelito, true, true);
$labelito->show();
$scroll = &new gtkvscrollbar($labelito->vadj);
$hbox->pack_start($scroll,FALSE,false,0);
$scroll->show();
$box->pack_start($hbox);
$window->show_all();
Gtk::main();
?>