Browse Source

implement auth navbar button

PHP-GTK3
yggverse 4 months ago
parent
commit
6b91591aa5
  1. 11
      src/Entity/Browser/Container/Page/Navbar.php
  2. 44
      src/Entity/Browser/Container/Page/Navbar/Auth.php

11
src/Entity/Browser/Container/Page/Navbar.php

@ -18,6 +18,7 @@ class Navbar @@ -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 @@ -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();

44
src/Entity/Browser/Container/Page/Navbar/Auth.php

@ -0,0 +1,44 @@ @@ -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'
)
);
}
}
Loading…
Cancel
Save