implement auth navbar button

This commit is contained in:
yggverse 2024-08-04 01:02:18 +03:00
parent 7e329b8b8a
commit 6b91591aa5
2 changed files with 55 additions and 0 deletions

View file

@ -18,6 +18,7 @@ class Navbar
public Page $page;
// Requirements
public Navbar\Auth $auth;
public Navbar\Base $base;
public Navbar\Bookmark $bookmark;
public Navbar\History $history;
@ -106,12 +107,22 @@ class Navbar
$this->bookmark->gtk
);
// Append auth button
$this->auth = new Navbar\Auth(
$this
);
$this->gtk->add(
$this->auth->gtk
);
// Render
$this->gtk->show();
}
public function refresh()
{
$this->auth->refresh();
$this->base->refresh();
$this->bookmark->refresh();
$this->history->refresh();

View file

@ -0,0 +1,44 @@
<?php
declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Container\Page\Navbar;
use \GtkButton;
use \Yggverse\Yoda\Abstract\Entity\Browser\Container\Page\Navbar\Button;
class Auth extends Button
{
// Defaults
public const IMAGE = 'avatar-default-symbolic';
public const LABEL = 'Auth';
public const TOOLTIP = 'Select identity';
protected function _onCLick(
GtkButton $entity
): void
{
// Show auth dialog
if ($this->navbar->page->auth->dialog())
{
// Update page
$this->navbar->page->update(
false
);
}
}
public function refresh(): void
{
// Activate on feature supported by request protocol
$this->gtk->set_sensitive(
boolval(
parse_url(
$this->navbar->request->getValue(),
PHP_URL_SCHEME
) == 'gemini'
)
);
}
}