Browse Source

init auth widget entity

PHP-GTK3
yggverse 4 months ago
parent
commit
76bb3c7bc9
  1. 49
      src/Entity/Browser/Container/Page.php
  2. 61
      src/Entity/Browser/Container/Page/Auth.php

49
src/Entity/Browser/Container/Page.php

@ -23,6 +23,7 @@ class Page
public Container $container; public Container $container;
// Requirements // Requirements
public Page\Auth $auth;
public Page\Title $title; public Page\Title $title;
public Page\Navbar $navbar; public Page\Navbar $navbar;
public Page\Progressbar $progressbar; public Page\Progressbar $progressbar;
@ -42,6 +43,11 @@ class Page
GtkOrientation::VERTICAL GtkOrientation::VERTICAL
); );
// Init auth
$this->auth = new Page\Auth(
$this
);
// Init title // Init title
$this->title = new Page\Title( $this->title = new Page\Title(
$this $this
@ -210,6 +216,49 @@ class Page
// Request completed // Request completed
if ($this->connection->isCompleted()) if ($this->connection->isCompleted())
{ {
// Response form requested
if ($this->connection->isAuth())
{
// Update title
$this->title->set(
$this->connection->getTitle(),
$this->connection->getSubtitle(),
$this->connection->getTooltip()
);
// Refresh header by new title if current page is active
if ($this === $this->container->tab->get())
{
$this->container->browser->header->setTitle(
$this->title->getValue(),
$this->title->getSubtitle()
);
}
// Hide progressbar
$this->progressbar->hide();
// Show auth dialog
if ($this->auth->dialog())
{
// Update page
$this->update(
false
);
}
else
{
// Update content
$this->content->set(
$this->connection->getMime(),
$this->connection->getData()
);
}
return false; // stop
}
// Response form requested // Response form requested
if ($request = $this->connection->getRequest()) if ($request = $this->connection->getRequest())
{ {

61
src/Entity/Browser/Container/Page/Auth.php

@ -0,0 +1,61 @@
<?php
declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Container\Page;
use \GtkButtonsType;
use \GtkDialogFlags;
use \GtkMessageDialog;
use \GtkMessageType;
use \GtkResponseType;
use \Yggverse\Yoda\Entity\Browser\Container\Page;
class Auth
{
// GTK
public GtkMessageDialog $gtk;
// Dependencies
public Page $page;
// Defaults
public const DIALOG_MESSAGE_FORMAT = 'Authorization';
public const DIALOG_DEFAULT_RESPONSE = GtkResponseType::CANCEL;
public function __construct(
Page $page,
) {
// Init dependencies
$this->page = $page;
}
public function dialog(): bool
{
$this->gtk = new GtkMessageDialog(
$this->page->container->browser->gtk,
GtkDialogFlags::MODAL,
GtkMessageType::INFO,
GtkButtonsType::OK_CANCEL,
_($this::DIALOG_MESSAGE_FORMAT)
);
$this->gtk->set_default_response(
$this::DIALOG_DEFAULT_RESPONSE
);
if (GtkResponseType::OK == $this->gtk->run())
{
// @TODO
$this->gtk->destroy();
return true;
}
// Dialog canceled
$this->gtk->destroy();
return false;
}
}
Loading…
Cancel
Save