예제 #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();
예제 #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]);
예제 #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();
예제 #4
0
<?php

use React\EventLoop\Factory;
use Clue\React\Zenity\Launcher;
use Clue\React\Zenity\Dialog\InfoDialog;
use Clue\React\Zenity\Dialog\QuestionDialog;
use Clue\React\Zenity\Dialog\ErrorDialog;
use Clue\React\Zenity\Dialog\EntryDialog;
use Clue\React\Zenity\Dialog\WarningDialog;
require __DIR__ . '/../vendor/autoload.php';
$loop = Factory::create();
$launcher = new Launcher($loop);
$q = new EntryDialog('What\'s your name?');
$q->setEntryText(getenv('USER'));
$q->setTitle('Enter your name');
$launcher->launch($q)->then(function ($name) use($launcher) {
    $launcher->launch(new InfoDialog('Welcome to the introduction of zenity, ' . $name))->then(function () use($launcher) {
        $launcher->launch(new QuestionDialog('Do you want to quit?'))->then(function () use($launcher) {
            $launcher->launch(new ErrorDialog('Oh noes!'));
        }, function () use($launcher) {
            $launcher->launch(new WarningDialog('You should have selected yes!'));
        });
    });
}, function () use($launcher) {
    $launcher->launch(new WarningDialog('No name given'));
});
$loop->run();
예제 #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();
$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();
예제 #6
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();
예제 #7
0
파일: menu.php 프로젝트: clue/zenity-react
<?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...)'));
예제 #8
0
파일: file.php 프로젝트: clue/zenity-react
<?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();
예제 #9
0
파일: form.php 프로젝트: clue/zenity-react
<?php

use React\EventLoop\Factory;
use Clue\React\Zenity\Launcher;
use Clue\React\Zenity\Dialog\FormsDialog;
require __DIR__ . '/../vendor/autoload.php';
$loop = Factory::create();
$launcher = new Launcher($loop);
$form = new FormsDialog($launcher);
$form->setWindowIcon('info');
$form->setText('Enter user information');
$form->addEntry('Name');
$form->addPassword('Password');
$form->addCalendar('Birthday');
//$form->addList('Group', array('Admin', 'User', 'Random'));
$form->addEntry('Nickname');
$form->addList('Gender', array('Male', 10, 'Female', 0), array('Gender', 'Number'));
$launcher->launch($form)->then(function ($result) {
    var_dump('result', $result);
}, function () {
    var_dump('form canceled');
});
$loop->run();