mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 00:55:28 +00:00
implement response form (code 10)
This commit is contained in:
parent
4b296f309c
commit
5fda126ea9
5 changed files with 243 additions and 2 deletions
121
src/Entity/Browser/Container/Tab/Page/Response.php
Normal file
121
src/Entity/Browser/Container/Tab/Page/Response.php
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yggverse\Yoda\Entity\Browser\Container\Tab\Page;
|
||||
|
||||
use \Yggverse\Yoda\Entity\Browser\Container\Tab\Page\Response\Query;
|
||||
use \Yggverse\Yoda\Entity\Browser\Container\Tab\Page\Response\Send;
|
||||
|
||||
use \Yggverse\Net\Address;
|
||||
|
||||
class Response
|
||||
{
|
||||
public \GtkBox $gtk;
|
||||
|
||||
// Dependencies
|
||||
public \Yggverse\Yoda\Entity\Browser\Container\Tab\Page $page;
|
||||
|
||||
// Requirements
|
||||
public \Yggverse\Yoda\Entity\Browser\Container\Tab\Page\Response\Query $query;
|
||||
public \Yggverse\Yoda\Entity\Browser\Container\Tab\Page\Response\Send $send;
|
||||
|
||||
// Defaults
|
||||
private int $_margin = 8;
|
||||
|
||||
public function __construct(
|
||||
\Yggverse\Yoda\Entity\Browser\Container\Tab\Page $page
|
||||
) {
|
||||
// Init dependencies
|
||||
$this->page = $page;
|
||||
|
||||
// Init container
|
||||
$this->gtk = new \GtkBox(
|
||||
\GtkOrientation::HORIZONTAL
|
||||
);
|
||||
|
||||
$this->gtk->set_margin_top(
|
||||
$this->_margin
|
||||
);
|
||||
|
||||
$this->gtk->set_margin_bottom(
|
||||
$this->_margin
|
||||
);
|
||||
|
||||
$this->gtk->set_margin_start(
|
||||
$this->_margin
|
||||
);
|
||||
|
||||
$this->gtk->set_margin_end(
|
||||
$this->_margin
|
||||
);
|
||||
|
||||
$this->gtk->set_spacing(
|
||||
$this->_margin
|
||||
);
|
||||
|
||||
// Init query field
|
||||
$this->query = new Query(
|
||||
$this
|
||||
);
|
||||
|
||||
$this->gtk->pack_start(
|
||||
$this->query->gtk,
|
||||
true,
|
||||
true,
|
||||
0
|
||||
);
|
||||
|
||||
// Init send button
|
||||
$this->send = new Send(
|
||||
$this
|
||||
);
|
||||
|
||||
$this->gtk->add(
|
||||
$this->send->gtk
|
||||
);
|
||||
|
||||
// Hide widget by default
|
||||
$this->hide();
|
||||
}
|
||||
|
||||
public function show(): void
|
||||
{
|
||||
$this->gtk->show_all();
|
||||
}
|
||||
|
||||
public function hide(): void
|
||||
{
|
||||
$this->gtk->hide();
|
||||
}
|
||||
|
||||
public function refresh()
|
||||
{
|
||||
$this->query->refresh();
|
||||
$this->send->refresh();
|
||||
}
|
||||
|
||||
public function send(): void
|
||||
{
|
||||
$address = new Address(
|
||||
$this->page->navbar->request->getValue()
|
||||
);
|
||||
|
||||
$address->setQuery(
|
||||
urlencode(
|
||||
trim(
|
||||
strval(
|
||||
$this->query->getValue()
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$this->page->open(
|
||||
$address->get(),
|
||||
false // disable history recording
|
||||
);
|
||||
|
||||
$this->hide();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue