Esempio n. 1
0
<?php

use React\EventLoop\Factory;
use Clue\React\Zenity\Launcher;
use Clue\React\Zenity\Builder;
use Clue\React\Zenity\Dialog\InfoDialog;
require __DIR__ . '/../vendor/autoload.php';
$loop = Factory::create();
$launcher = new Launcher($loop);
$builder = new Builder();
$progress = $launcher->launchZen($builder->progress('Pseudo-processing...'));
$loop->addPeriodicTimer(0.1, function ($timer) use($progress) {
    $progress->advance(mt_rand(0, 3));
    if ($progress->getPercentage() >= 100) {
        $timer->cancel();
    }
});
$pulsate = $launcher->launchZen($builder->pulsate('[1/3] Preparing...'));
$loop->addTimer(2, function () use($pulsate) {
    $pulsate->setText('[2/3] Downloading...');
});
$loop->addtimer(4, function () use($pulsate) {
    $pulsate->setText('[3/3] Unpacking...');
});
$loop->addTimer(6, function () use($pulsate) {
    $pulsate->complete();
});
$launcher->launch(new InfoDialog('Quit "Processing"?'))->then(function () use($pulsate) {
    $pulsate->close();
});
$loop->run();
Esempio n. 2
0
<?php

use React\EventLoop\Factory;
use Clue\React\Zenity\Launcher;
use Clue\React\Zenity\Builder;
use Clue\React\Zenity\Dialog\EntryDialog;
require __DIR__ . '/../vendor/autoload.php';
$loop = Factory::create();
$launcher = new Launcher($loop);
$builder = new Builder();
$name = $launcher->waitFor(new EntryDialog('Search package'));
if ($name === false) {
    exit;
}
$pulser = $launcher->launchZen($builder->pulsate('Searching packagist.org for "' . $name . '"...'));
sleep(3);
$pulser->close();
$packages = array('mink', 'behat', 'phpunit', 'box', 'boris');
$pid = $launcher->waitFor($builder->listRadio($packages, 'Select package'));
var_dump($packages[$pid]);
Esempio n. 3
0
<?php

use React\EventLoop\Factory;
use Clue\React\Zenity\Launcher;
use Clue\React\Zenity\Builder;
require __DIR__ . '/../vendor/autoload.php';
$loop = Factory::create();
$launcher = new Launcher($loop);
$builder = new Builder();
$progress = $launcher->launchZen($builder->progress('Pseudo-processing...'));
$progress->setPercentage(50);
$timer = $loop->addPeriodicTimer(0.2, function () use($progress) {
    $progress->advance(mt_rand(-1, 3));
});
$progress->promise()->then(function () use($timer, $builder, $launcher) {
    $timer->cancel();
    $launcher->launch($builder->info('Done'));
}, function () use($timer) {
    $timer->cancel();
});
$loop->run();
Esempio n. 4
0
<?php

use React\EventLoop\Factory;
use Clue\React\Zenity\Launcher;
use Clue\React\Zenity\Builder;
require __DIR__ . '/../vendor/autoload.php';
$loop = Factory::create();
$launcher = new Launcher($loop);
$builder = new Builder();
$progress = $launcher->launchZen($builder->pulsate('Pseudo-processing...'));
$texts = array('Preparing', 'Downloading', 'Unpacking', 'Patching', 'Bootstrapping', 'Building', 'Cleaning', 'Finishing');
$timer = $loop->addPeriodicTimer(2.0, function ($timer) use($progress, $texts) {
    static $i = 0;
    if (isset($texts[$i])) {
        $text = $texts[$i++];
        $text = '[' . $i . '/' . count($texts) . '] ' . $text . '...';
        $progress->setText($text);
    } else {
        $progress->complete();
    }
});
$progress->promise()->then(function () use($timer, $builder, $launcher) {
    $timer->cancel();
    $launcher->launch($builder->info('Done'));
});
$progress->promise()->then(null, function () use($timer, $builder, $launcher) {
    $timer->cancel();
    $launcher->launch($builder->error('Canceled'));
});
$loop->run();
Esempio n. 5
0
<?php

use React\EventLoop\Factory;
use Clue\React\Zenity\Launcher;
use Clue\React\Zenity\Builder;
require __DIR__ . '/../vendor/autoload.php';
$loop = Factory::create();
$launcher = new Launcher($loop);
$builder = new Builder();
$notification = $builder->notifier();
$zen = $launcher->launchZen($notification);
$zen->setMessage('Hello world');
$n = 0;
$loop->addPeriodicTimer(10.0, function ($timer) use($zen, &$n) {
    $zen->setMessage('Hi' . ++$n);
});
$loop->run();
Esempio n. 6
0
<?php

use React\EventLoop\Factory;
use Clue\React\Zenity\Launcher;
use Clue\React\Zenity\Builder;
use Clue\React\Zenity\Dialog\InfoDialog;
require __DIR__ . '/../vendor/autoload.php';
$loop = Factory::create();
$launcher = new Launcher($loop);
$builder = new Builder($launcher);
$main = function () use(&$main, $builder, $launcher) {
    $menu = $builder->listMenu(array('Introduction', 'Tests', 'License', 'Bugs / Issues'), 'Main menu');
    $menu->setWindowIcon('info');
    $menu->setTitle('Main menu');
    $launcher->launch($menu)->then(function ($selected) use($builder, $main, $launcher) {
        if ($selected === '0') {
            // U+2212 MINUS SIGN for alignment
            $launcher->launch($builder->listRadio(array('+2', '+1', '±0', '−1', '−2'), 'Introduction Level', 2))->then(function ($level) use($main, $launcher) {
                $launcher->launch(new InfoDialog('Level ' . var_export($level, true)))->then($main, $main);
            }, $main);
        } elseif ($selected === '1') {
            $launcher->launch($builder->listCheck(array('Unit', 'Functional', 'Acceptance (slow)'), 'Selected test suits to run', array(0, 1)))->then(function ($tests) use($main, $launcher) {
                $launcher->launch(new InfoDialog('Tests: ' . var_export($tests, true)))->then($main, $main);
            }, $main);
        } elseif ($selected === '2') {
            $launcher->launch($builder->confirmLicense(__DIR__ . '/../README.md', 'I have read the README.md file'))->then(function ($checked) use($main, $launcher) {
                $launcher->launch(new InfoDialog('Clicked ' . var_export($checked, true)))->then($main, $main);
            }, $main);
        } elseif ($selected === '3') {
            $launcher->launch($builder->table(array(5123 => array('5123', 'Resolve Random Issue', 'open'), 5124 => array('5124', 'Implement demo menu', 'done')), array('Bug ID', 'Description', 'Status')))->then(function ($bug) use($main, $builder, $launcher) {
                $pulser = $launcher->launch($builder->pulsate('Loading bug #' . $bug . '...' . PHP_EOL . '(This will not actually do anything...)'));
Esempio n. 7
0
<?php

use React\EventLoop\Factory;
use Clue\React\Zenity\Launcher;
use Clue\React\Zenity\Dialog\FileSelectionDialog;
use Clue\React\Zenity\Builder;
use Clue\React\Zenity\Dialog\InfoDialog;
require __DIR__ . '/../vendor/autoload.php';
$loop = Factory::create();
$launcher = new Launcher($loop);
$builder = new Builder();
$launcher->launch($builder->fileSelection())->then(function (SplFileInfo $file) use($launcher) {
    var_dump($file);
    $launcher->launch(new InfoDialog('Selected "' . $file->getFilename() . '". Re-opening dialog with same selection'))->then(function () use($file, $launcher) {
        $selection = new FileSelectionDialog();
        $selection->setFilename($file);
        $selection->setTitle('Pretend we\'re overwriting the file');
        $selection->setConfirmOverwrite(true);
        $selection->setSave(true);
        $launcher->launch($selection);
    });
});
$loop->run();