mirror of https://github.com/YGGverse/Yoda.git
yggverse
4 months ago
45 changed files with 900 additions and 829 deletions
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace Yggverse\Yoda\Abstract\Entity\Browser\Container\Tab\Page\Navbar; |
||||
|
||||
abstract class Button extends \Yggverse\Yoda\Abstract\Entity\Button |
||||
{ |
||||
public \Yggverse\Yoda\Entity\Browser\Container\Tab\Page\Navbar $navbar; |
||||
|
||||
public function __construct( |
||||
\Yggverse\Yoda\Entity\Browser\Container\Tab\Page\Navbar $navbar |
||||
) { |
||||
parent::__construct(); |
||||
|
||||
$this->navbar = $navbar; |
||||
} |
||||
} |
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace Yggverse\Yoda\Abstract\Entity\Browser\Container\Tab\Page\Navbar; |
||||
|
||||
abstract class Entry extends \Yggverse\Yoda\Abstract\Entity\Entry |
||||
{ |
||||
public \Yggverse\Yoda\Entity\Browser\Container\Tab\Page\Navbar $navbar; |
||||
|
||||
public function __construct( |
||||
\Yggverse\Yoda\Entity\Browser\Container\Tab\Page\Navbar $navbar |
||||
) { |
||||
parent::__construct(); |
||||
|
||||
$this->navbar = $navbar; |
||||
} |
||||
} |
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace Yggverse\Yoda\Abstract\Entity\Browser\History\Container\Navbar; |
||||
|
||||
abstract class Button extends \Yggverse\Yoda\Abstract\Entity\Button |
||||
{ |
||||
public \Yggverse\Yoda\Entity\Browser\History\Container\Navbar $navbar; |
||||
|
||||
public function __construct( |
||||
\Yggverse\Yoda\Entity\Browser\History\Container\Navbar $navbar |
||||
) { |
||||
parent::__construct(); |
||||
|
||||
$this->navbar = $navbar; |
||||
} |
||||
} |
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace Yggverse\Yoda\Abstract\Entity\Browser\History\Container\Navbar; |
||||
|
||||
abstract class Entry extends \Yggverse\Yoda\Abstract\Entity\Entry |
||||
{ |
||||
public \Yggverse\Yoda\Entity\Browser\History\Container\Navbar $navbar; |
||||
|
||||
public function __construct( |
||||
\Yggverse\Yoda\Entity\Browser\History\Container\Navbar $navbar |
||||
) { |
||||
parent::__construct(); |
||||
|
||||
$this->navbar = $navbar; |
||||
} |
||||
} |
@ -1,18 +0,0 @@
@@ -1,18 +0,0 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace Yggverse\Yoda\Abstract\Entity\Window\Tab\Address\Navbar; |
||||
|
||||
abstract class Button extends \Yggverse\Yoda\Abstract\Entity\Button |
||||
{ |
||||
public \Yggverse\Yoda\Entity\Window\Tab\Address\Navbar $navbar; |
||||
|
||||
public function __construct( |
||||
\Yggverse\Yoda\Entity\Window\Tab\Address\Navbar $navbar |
||||
) { |
||||
parent::__construct(); |
||||
|
||||
$this->navbar = $navbar; |
||||
} |
||||
} |
@ -1,18 +0,0 @@
@@ -1,18 +0,0 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace Yggverse\Yoda\Abstract\Entity\Window\Tab\Address\Navbar; |
||||
|
||||
abstract class Entry extends \Yggverse\Yoda\Abstract\Entity\Entry |
||||
{ |
||||
public \Yggverse\Yoda\Entity\Window\Tab\Address\Navbar $navbar; |
||||
|
||||
public function __construct( |
||||
\Yggverse\Yoda\Entity\Window\Tab\Address\Navbar $navbar |
||||
) { |
||||
parent::__construct(); |
||||
|
||||
$this->navbar = $navbar; |
||||
} |
||||
} |
@ -1,18 +0,0 @@
@@ -1,18 +0,0 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace Yggverse\Yoda\Abstract\Entity\Window\Tab\History\Navbar; |
||||
|
||||
abstract class Button extends \Yggverse\Yoda\Abstract\Entity\Button |
||||
{ |
||||
public \Yggverse\Yoda\Entity\Window\Tab\History\Navbar $navbar; |
||||
|
||||
public function __construct( |
||||
\Yggverse\Yoda\Entity\Window\Tab\History\Navbar $navbar |
||||
) { |
||||
parent::__construct(); |
||||
|
||||
$this->navbar = $navbar; |
||||
} |
||||
} |
@ -1,18 +0,0 @@
@@ -1,18 +0,0 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace Yggverse\Yoda\Abstract\Entity\Window\Tab\History\Navbar; |
||||
|
||||
abstract class Entry extends \Yggverse\Yoda\Abstract\Entity\Entry |
||||
{ |
||||
public \Yggverse\Yoda\Entity\Window\Tab\History\Navbar $navbar; |
||||
|
||||
public function __construct( |
||||
\Yggverse\Yoda\Entity\Window\Tab\History\Navbar $navbar |
||||
) { |
||||
parent::__construct(); |
||||
|
||||
$this->navbar = $navbar; |
||||
} |
||||
} |
@ -0,0 +1,47 @@
@@ -0,0 +1,47 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace Yggverse\Yoda\Entity\Browser; |
||||
|
||||
use \Yggverse\Yoda\Entity\Browser\Container\Tab; |
||||
|
||||
class Container |
||||
{ |
||||
public \GtkBox $gtk; |
||||
|
||||
// Dependencies |
||||
public \Yggverse\Yoda\Entity\Browser $browser; |
||||
|
||||
// Requirements |
||||
public \Yggverse\Yoda\Entity\Browser\Container\Tab $tab; |
||||
|
||||
public function __construct( |
||||
\Yggverse\Yoda\Entity\Browser $browser |
||||
) { |
||||
// Init dependency |
||||
$this->browser = $browser; |
||||
|
||||
// Init container |
||||
$this->gtk = new \GtkBox( |
||||
\GtkOrientation::VERTICAL |
||||
); |
||||
|
||||
// Init tab |
||||
$this->tab = new Tab( |
||||
$this |
||||
); |
||||
|
||||
$this->gtk->pack_start( |
||||
$this->tab->gtk, |
||||
true, |
||||
true, |
||||
0 |
||||
); |
||||
} |
||||
|
||||
public function refresh() |
||||
{ |
||||
// @TODO |
||||
} |
||||
} |
@ -0,0 +1,97 @@
@@ -0,0 +1,97 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace Yggverse\Yoda\Entity\Browser\Container; |
||||
|
||||
class Tab |
||||
{ |
||||
public \GtkNotebook $gtk; |
||||
|
||||
// Dependencies |
||||
public \Yggverse\Yoda\Entity\Browser\Container $container; |
||||
|
||||
// Defaults |
||||
private bool $_reorderable = true; |
||||
private bool $_scrollable = true; |
||||
|
||||
public function __construct( |
||||
\Yggverse\Yoda\Entity\Browser\Container $container |
||||
) { |
||||
// Init dependency |
||||
$this->container = $container; |
||||
|
||||
// Init container |
||||
$this->gtk = new \GtkNotebook; |
||||
|
||||
$this->gtk->set_scrollable( |
||||
$this->_scrollable |
||||
); |
||||
|
||||
// Init previous session @TODO |
||||
$this->append(); |
||||
$this->append(); |
||||
|
||||
// Connect events |
||||
$this->gtk->connect( |
||||
'switch-page', |
||||
function ( |
||||
\GtkNotebook $entity, |
||||
\GtkWidget $child, |
||||
int $position |
||||
) { |
||||
$this->container->browser->header->setTitle( |
||||
$entity->get_tab_label( |
||||
$child |
||||
)->get_text() |
||||
); |
||||
} |
||||
); |
||||
} |
||||
|
||||
public function append( |
||||
?string $request = null, |
||||
bool $focus = true |
||||
): void |
||||
{ |
||||
$page = new \Yggverse\Yoda\Entity\Browser\Container\Tab\Page( |
||||
$this |
||||
); |
||||
|
||||
if ($request) |
||||
{ |
||||
$page->navbar->request->setValue( |
||||
$request |
||||
); |
||||
|
||||
$page->content->update(); |
||||
} |
||||
|
||||
$this->gtk->append_page( |
||||
$page->gtk, |
||||
$page->title->gtk |
||||
); |
||||
|
||||
$this->gtk->set_tab_reorderable( |
||||
$page->gtk, |
||||
$this->_reorderable |
||||
); |
||||
|
||||
if ($focus) |
||||
{ |
||||
// Focus on appended tab |
||||
$this->gtk->set_current_page( |
||||
$this->gtk->page_num( |
||||
$page->gtk |
||||
) |
||||
); |
||||
|
||||
// Update application title |
||||
$this->container->browser->header->setTitle( |
||||
$page->title->gtk->get_text() |
||||
); |
||||
} |
||||
|
||||
$this->gtk->show_all(); |
||||
} |
||||
} |
@ -0,0 +1,89 @@
@@ -0,0 +1,89 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace Yggverse\Yoda\Entity\Browser\Container\Tab; |
||||
|
||||
use \Yggverse\Yoda\Entity\Browser\Container\Tab\Page\Title; |
||||
use \Yggverse\Yoda\Entity\Browser\Container\Tab\Page\Navbar; |
||||
use \Yggverse\Yoda\Entity\Browser\Container\Tab\Page\Content; |
||||
use \Yggverse\Yoda\Entity\Browser\Container\Tab\Page\Statusbar; |
||||
|
||||
class Page |
||||
{ |
||||
public \GtkBox $gtk; |
||||
|
||||
// Dependencies |
||||
public \Yggverse\Yoda\Entity\Browser\Container\Tab $tab; |
||||
|
||||
// Requirements |
||||
public \Yggverse\Yoda\Entity\Browser\Container\Tab\Page\Title $title; |
||||
public \Yggverse\Yoda\Entity\Browser\Container\Tab\Page\Navbar $navbar; |
||||
public \Yggverse\Yoda\Entity\Browser\Container\Tab\Page\Content $content; |
||||
public \Yggverse\Yoda\Entity\Browser\Container\Tab\Page\Statusbar $statusbar; |
||||
|
||||
public function __construct( |
||||
\Yggverse\Yoda\Entity\Browser\Container\Tab $tab |
||||
) { |
||||
// Init dependencies |
||||
$this->tab = $tab; |
||||
|
||||
// Init container |
||||
$this->gtk = new \GtkBox( |
||||
\GtkOrientation::VERTICAL |
||||
); |
||||
|
||||
// Init title |
||||
$this->title = new Title( |
||||
$this |
||||
); |
||||
|
||||
// Init navbar |
||||
$this->navbar = new Navbar( |
||||
$this |
||||
); |
||||
|
||||
$this->gtk->add( |
||||
$this->navbar->gtk |
||||
); |
||||
|
||||
// Init content |
||||
$this->content = new Content( |
||||
$this |
||||
); |
||||
|
||||
$this->gtk->pack_start( |
||||
$this->content->gtk, |
||||
true, |
||||
true, |
||||
0 |
||||
); |
||||
|
||||
// Init statusbar |
||||
$this->statusbar = new Statusbar( |
||||
$this |
||||
); |
||||
|
||||
$this->gtk->add( |
||||
$this->statusbar->gtk |
||||
); |
||||
} |
||||
|
||||
public function refresh(): void |
||||
{ |
||||
$this->navbar->refresh(); |
||||
$this->content->refresh(); |
||||
$this->statusbar->refresh(); |
||||
} |
||||
|
||||
public function update( |
||||
bool $history = true |
||||
): void |
||||
{ |
||||
// @TODO navbar |
||||
|
||||
$this->content->update( |
||||
$history |
||||
); |
||||
} |
||||
} |
@ -0,0 +1,10 @@
@@ -0,0 +1,10 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace Yggverse\Yoda\Entity\Browser; |
||||
|
||||
class Header extends \Yggverse\Yoda\Abstract\Entity\HeaderBar |
||||
{ |
||||
protected string $_title = 'Yoda'; |
||||
} |
@ -0,0 +1,63 @@
@@ -0,0 +1,63 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace Yggverse\Yoda\Entity\Browser; |
||||
|
||||
use \Yggverse\Yoda\Entity\Browser\History\Header; |
||||
use \Yggverse\Yoda\Entity\Browser\History\Container; |
||||
|
||||
class History |
||||
{ |
||||
public \GtkWindow $gtk; |
||||
|
||||
// Dependencies |
||||
public \Yggverse\Yoda\Entity\Browser $browser; |
||||
|
||||
// Requirements |
||||
public \Yggverse\Yoda\Entity\Browser\History\Header $header; |
||||
public \Yggverse\Yoda\Entity\Browser\History\Container $container; |
||||
|
||||
// Defaults |
||||
private int $_width = 640; |
||||
private int $_height = 480; |
||||
private bool $_maximize = false; |
||||
|
||||
public function __construct( |
||||
\Yggverse\Yoda\Entity\Browser $browser |
||||
) { |
||||
// Init dependencies |
||||
$this->browser = $browser; |
||||
|
||||
// Init window |
||||
$this->gtk = new \GtkWindow; |
||||
|
||||
$this->gtk->set_size_request( |
||||
$this->_width, |
||||
$this->_height |
||||
); |
||||
|
||||
if ($this->_maximize) |
||||
{ |
||||
$this->gtk->maximize(); |
||||
} |
||||
|
||||
// Init header |
||||
$this->header = new Header( |
||||
$this |
||||
); |
||||
|
||||
$this->gtk->set_titlebar( |
||||
$this->header->gtk |
||||
); |
||||
|
||||
// Init container |
||||
$this->container = new Container( |
||||
$this |
||||
); |
||||
|
||||
$this->gtk->add( |
||||
$this->container->gtk |
||||
); |
||||
} |
||||
} |
@ -0,0 +1,59 @@
@@ -0,0 +1,59 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace Yggverse\Yoda\Entity\Browser\History; |
||||
|
||||
use \Yggverse\Yoda\Entity\Browser\History\Container\Navbar; |
||||
use \Yggverse\Yoda\Entity\Browser\History\Container\Content; |
||||
|
||||
class Container |
||||
{ |
||||
public \GtkBox $gtk; |
||||
|
||||
// Dependencies |
||||
public \Yggverse\Yoda\Entity\Browser\History $history; |
||||
|
||||
// Requirements |
||||
public \Yggverse\Yoda\Entity\Browser\History\Container\Navbar $navbar; |
||||
public \Yggverse\Yoda\Entity\Browser\History\Container\Content $content; |
||||
|
||||
public function __construct( |
||||
\Yggverse\Yoda\Entity\Browser\History $history |
||||
) { |
||||
// Init dependency |
||||
$this->history = $history; |
||||
|
||||
// Init container |
||||
$this->gtk = new \GtkBox( |
||||
\GtkOrientation::VERTICAL |
||||
); |
||||
|
||||
// Init navbar |
||||
$this->navbar = new Navbar( |
||||
$this |
||||
); |
||||
|
||||
$this->gtk->add( |
||||
$this->navbar->gtk |
||||
); |
||||
|
||||
// Init content |
||||
$this->content = new Content( |
||||
$this |
||||
); |
||||
|
||||
$this->gtk->pack_start( |
||||
$this->content->gtk, |
||||
true, |
||||
true, |
||||
0 |
||||
); |
||||
} |
||||
|
||||
public function refresh() |
||||
{ |
||||
$this->navbar->refresh(); |
||||
$this->content->refresh(); |
||||
} |
||||
} |
@ -0,0 +1,104 @@
@@ -0,0 +1,104 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace Yggverse\Yoda\Entity\Browser\History\Container; |
||||
|
||||
use \Yggverse\Yoda\Entity\Browser\History\Container\Navbar\Delete; |
||||
use \Yggverse\Yoda\Entity\Browser\History\Container\Navbar\Filter; |
||||
use \Yggverse\Yoda\Entity\Browser\History\Container\Navbar\Open; |
||||
use \Yggverse\Yoda\Entity\Browser\History\Container\Navbar\Search; |
||||
|
||||
class Navbar |
||||
{ |
||||
public \GtkBox $gtk; |
||||
|
||||
// Dependencies |
||||
public \Yggverse\Yoda\Entity\Browser\History\Container $container; |
||||
|
||||
// Requirements |
||||
public \Yggverse\Yoda\Entity\Browser\History\Container\Navbar\Delete $delete; |
||||
public \Yggverse\Yoda\Entity\Browser\History\Container\Navbar\Filter $filter; |
||||
public \Yggverse\Yoda\Entity\Browser\History\Container\Navbar\Open $open; |
||||
public \Yggverse\Yoda\Entity\Browser\History\Container\Navbar\Search $search; |
||||
|
||||
// Defaults |
||||
private int $_margin = 8; |
||||
|
||||
public function __construct( |
||||
\Yggverse\Yoda\Entity\Browser\History\Container $container |
||||
) { |
||||
// Init dependency |
||||
$this->container = $container; |
||||
|
||||
// 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 open button |
||||
$this->open = new Open( |
||||
$this |
||||
); |
||||
|
||||
$this->gtk->add( |
||||
$this->open->gtk |
||||
); |
||||
|
||||
// Init delete button |
||||
$this->delete = new Delete( |
||||
$this |
||||
); |
||||
|
||||
$this->gtk->add( |
||||
$this->delete->gtk |
||||
); |
||||
|
||||
// Init filter entry |
||||
$this->filter = new Filter( |
||||
$this |
||||
); |
||||
|
||||
$this->gtk->pack_start( |
||||
$this->filter->gtk, |
||||
true, |
||||
true, |
||||
0 |
||||
); |
||||
|
||||
// Init search button |
||||
$this->search = new Search( |
||||
$this |
||||
); |
||||
|
||||
$this->gtk->add( |
||||
$this->search->gtk |
||||
); |
||||
} |
||||
|
||||
public function refresh(): void |
||||
{ |
||||
$this->delete->refresh(); |
||||
$this->open->refresh(); |
||||
} |
||||
} |
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace Yggverse\Yoda\Entity\Browser\History\Container\Navbar; |
||||
|
||||
class Delete extends \Yggverse\Yoda\Abstract\Entity\Browser\History\Container\Navbar\Button |
||||
{ |
||||
protected string $_label = 'Delete'; |
||||
|
||||
protected function _onCLick( |
||||
\GtkButton $entity |
||||
): void |
||||
{ |
||||
if ($id = $this->navbar->container->content->getSelectedId()) |
||||
{ |
||||
$this->navbar->container->history->browser->database->deleteHistory( |
||||
$id |
||||
); |
||||
} |
||||
|
||||
$this->navbar->container->refresh(); |
||||
} |
||||
|
||||
public function refresh(): void |
||||
{ |
||||
$this->gtk->set_sensitive( |
||||
boolval( |
||||
$this->navbar->container->content->getSelectedId() |
||||
) |
||||
); |
||||
} |
||||
} |
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace Yggverse\Yoda\Entity\Browser\History\Container\Navbar; |
||||
|
||||
class Open extends \Yggverse\Yoda\Abstract\Entity\Browser\History\Container\Navbar\Button |
||||
{ |
||||
protected string $_label = 'Open'; |
||||
|
||||
protected function _onCLick( |
||||
\GtkButton $entity |
||||
): void |
||||
{ |
||||
$this->navbar->container->history->browser->container->tab->append( |
||||
$this->navbar->container->content->getSelectedUrl() |
||||
); |
||||
} |
||||
|
||||
public function refresh(): void |
||||
{ |
||||
$this->gtk->set_sensitive( |
||||
boolval( |
||||
$this->navbar->container->content->getSelectedId() |
||||
) |
||||
); |
||||
} |
||||
} |
@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace Yggverse\Yoda\Entity\Browser\History\Container\Navbar; |
||||
|
||||
class Search extends \Yggverse\Yoda\Abstract\Entity\Browser\History\Container\Navbar\Button |
||||
{ |
||||
protected bool $_sensitive = true; |
||||
protected string $_label = 'Search'; |
||||
|
||||
protected function _onCLick( |
||||
\GtkButton $entity |
||||
): void |
||||
{ |
||||
$this->navbar->container->content->search( |
||||
$this->navbar->filter->gtk->get_text() |
||||
); |
||||
} |
||||
} |
@ -0,0 +1,10 @@
@@ -0,0 +1,10 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace Yggverse\Yoda\Entity\Browser\History; |
||||
|
||||
class Header extends \Yggverse\Yoda\Abstract\Entity\HeaderBar |
||||
{ |
||||
protected string $_title = 'History - Yoda'; |
||||
} |
@ -1,109 +0,0 @@
@@ -1,109 +0,0 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace Yggverse\Yoda\Entity\Window; |
||||
|
||||
use \Yggverse\Yoda\Entity\Window\Tab\Address; |
||||
use \Yggverse\Yoda\Entity\Window\Tab\History; |
||||
|
||||
class Tab |
||||
{ |
||||
public \GtkNotebook $gtk; |
||||
|
||||
public \Yggverse\Yoda\Entity\Window $window; |
||||
|
||||
// App entity operations |
||||
private array $_tab = []; |
||||
|
||||
// Defaults |
||||
private bool $_reorderable = true; |
||||
private bool $_scrollable = true; |
||||
|
||||
public function __construct( |
||||
\Yggverse\Yoda\Entity\Window $window |
||||
) { |
||||
$this->window = $window; |
||||
|
||||
$this->gtk = new \GtkNotebook; |
||||
|
||||
$this->gtk->set_scrollable( |
||||
$this->_scrollable |
||||
); |
||||
|
||||
$this->gtk->connect( |
||||
'switch-page', |
||||
function ( |
||||
\GtkNotebook $entity, |
||||
\GtkWidget $child, |
||||
int $position |
||||
) { |
||||
$this->window->header->setTitle( |
||||
$entity->get_tab_label( |
||||
$child |
||||
)->get_text() |
||||
); |
||||
} |
||||
); |
||||
|
||||
$this->append( // @TODO remove |
||||
new History( |
||||
$this |
||||
) |
||||
); |
||||
|
||||
$this->append( // @TODO remove |
||||
new Address( |
||||
$this |
||||
) |
||||
); |
||||
} |
||||
|
||||
public function append( |
||||
Address | History $entity, |
||||
?bool $reorderable = null |
||||
): void |
||||
{ |
||||
$this->gtk->append_page( |
||||
$entity->gtk, |
||||
$entity->title->gtk |
||||
); |
||||
|
||||
$this->gtk->set_tab_reorderable( |
||||
$entity->gtk, |
||||
is_null($reorderable) ? $this->_reorderable : $reorderable |
||||
); |
||||
|
||||
$this->gtk->show_all(); |
||||
|
||||
// Focus on appended tab |
||||
$this->gtk->set_current_page( |
||||
$this->gtk->page_num( |
||||
$entity->gtk |
||||
) |
||||
); |
||||
|
||||
// Update application title |
||||
$this->window->header->setTitle( |
||||
$entity->title->gtk->get_text() |
||||
); |
||||
|
||||
// Register new tab entity |
||||
$this->_tab[] = $entity; |
||||
} |
||||
|
||||
public function refresh() |
||||
{ |
||||
foreach ($this->_tab as $entity) |
||||
{ |
||||
switch (true) |
||||
{ |
||||
case $entity instanceof History: |
||||
|
||||
$entity->content->update(); |
||||
|
||||
break; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,45 +0,0 @@
@@ -1,45 +0,0 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace Yggverse\Yoda\Entity\Window\Tab\Address; |
||||
|
||||
use \Yggverse\Yoda\Entity\Window\Tab\Address\Content\Gemtext; |
||||
use \Yggverse\Yoda\Entity\Window\Tab\Address\Content\Plain; |
||||
|
||||
class Content |
||||
{ |
||||
public \GtkScrolledWindow $gtk; |
||||
|
||||
public \Yggverse\Yoda\Entity\Window\Tab\Address $address; |
||||
|
||||
public Gemtext | Plain $data; |
||||
|
||||
private int $_margin = 8; |
||||
|
||||
public function __construct( |
||||
\Yggverse\Yoda\Entity\Window\Tab\Address $address |
||||
) { |
||||
$this->address = $address; |
||||
|
||||
$this->gtk = new \GtkScrolledWindow; |
||||
|
||||
$this->gtk->set_margin_start( |
||||
$this->_margin |
||||
); |
||||
|
||||
$this->gtk->set_margin_end( |
||||
$this->_margin |
||||
); |
||||
|
||||
$this->data = new Gemtext( |
||||
$this |
||||
); |
||||
|
||||
$this->gtk->add( |
||||
$this->data->gtk |
||||
); |
||||
|
||||
$this->gtk->show_all(); |
||||
} |
||||
} |
@ -1,54 +0,0 @@
@@ -1,54 +0,0 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace Yggverse\Yoda\Entity\Window\Tab\Address\Content; |
||||
|
||||
class Plain |
||||
{ |
||||
public \GtkLabel $gtk; |
||||
|
||||
public \Yggverse\Yoda\Entity\Window\Tab\Address\Content $content; |
||||
|
||||
// Defaults |
||||
private string $_value = ''; |
||||
|
||||
public function __construct( |
||||
\Yggverse\Yoda\Entity\Window\Tab\Address\Content $content |
||||
) { |
||||
$this->content = $content; |
||||
|
||||
$this->gtk = new \GtkLabel( |
||||
$this->_value |
||||
); |
||||
|
||||
$this->gtk->set_use_markup( |
||||
false |
||||
); |
||||
|
||||
$this->gtk->set_selectable( |
||||
true |
||||
); |
||||
|
||||
$this->gtk->set_line_wrap( |
||||
true |
||||
); |
||||
|
||||
$this->gtk->set_xalign( |
||||
0 |
||||
); |
||||
|
||||
$this->gtk->set_yalign( |
||||
0 |
||||
); |
||||
} |
||||
|
||||
public function setValue( |
||||
string $value |
||||
): void |
||||
{ |
||||
$this->gtk->set_text( |
||||
$value |
||||
); |
||||
} |
||||
} |
@ -1,74 +0,0 @@
@@ -1,74 +0,0 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace Yggverse\Yoda\Entity\Window\Tab; |
||||
|
||||
use \Yggverse\Yoda\Entity\Window\Tab\History\Title; |
||||
use \Yggverse\Yoda\Entity\Window\Tab\History\Navbar; |
||||
use \Yggverse\Yoda\Entity\Window\Tab\History\Content; |
||||
|
||||
class History |
||||
{ |
||||
public \GtkBox $gtk; |
||||
|
||||
public \Yggverse\Yoda\Entity\Window\Tab $tab; |
||||
|
||||
public \Yggverse\Yoda\Entity\Window\Tab\History\Title $title; |
||||
public \Yggverse\Yoda\Entity\Window\Tab\History\Navbar $navbar; |
||||
public \Yggverse\Yoda\Entity\Window\Tab\History\Content $content; |
||||
|
||||
public function __construct( |
||||
\Yggverse\Yoda\Entity\Window\Tab $tab |
||||
) { |
||||
$this->tab = $tab; |
||||
|
||||
$this->title = new Title( |
||||
$this |
||||
); |
||||
|
||||
$this->gtk = new \GtkBox( |
||||
\GtkOrientation::VERTICAL |
||||
); |
||||
|
||||
$this->navbar = new Navbar( |
||||
$this |
||||
); |
||||
|
||||
$this->content = new Content( |
||||
$this |
||||
); |
||||
|
||||
$this->gtk->add( |
||||
$this->navbar->gtk |
||||
); |
||||
|
||||
$this->gtk->pack_start( |
||||
$this->content->gtk, |
||||
true, |
||||
true, |
||||
0 |
||||
); |
||||
} |
||||
|
||||
public function search( |
||||
?string $filter = null |
||||
): void |
||||
{ |
||||
$this->navbar->filter->setValue( |
||||
trim( |
||||
strval( |
||||
$filter |
||||
) |
||||
) |
||||
); |
||||
|
||||
$this->content->search( |
||||
trim( |
||||
strval( |
||||
$filter |
||||
) |
||||
) |
||||
); |
||||
} |
||||
} |
@ -1,99 +0,0 @@
@@ -1,99 +0,0 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace Yggverse\Yoda\Entity\Window\Tab\History; |
||||
|
||||
use \Yggverse\Yoda\Entity\Window\Tab\History\Navbar\Delete; |
||||
use \Yggverse\Yoda\Entity\Window\Tab\History\Navbar\Filter; |
||||
use \Yggverse\Yoda\Entity\Window\Tab\History\Navbar\Open; |
||||
use \Yggverse\Yoda\Entity\Window\Tab\History\Navbar\Search; |
||||
|
||||
class Navbar |
||||
{ |
||||
public \GtkBox $gtk; |
||||
|
||||
public \Yggverse\Yoda\Entity\Window\Tab\History $history; |
||||
|
||||
public \Yggverse\Yoda\Entity\Window\Tab\History\Navbar\Delete $delete; |
||||
public \Yggverse\Yoda\Entity\Window\Tab\History\Navbar\Filter $filter; |
||||
public \Yggverse\Yoda\Entity\Window\Tab\History\Navbar\Open $open; |
||||
public \Yggverse\Yoda\Entity\Window\Tab\History\Navbar\Search $search; |
||||
|
||||
// Defaults |
||||
private int $_margin = 8; |
||||
|
||||
public function __construct( |
||||
\Yggverse\Yoda\Entity\Window\Tab\History $history |
||||
) { |
||||
$this->history = $history; |
||||
|
||||
$this->gtk = new \GtkBox( |
||||
\GtkOrientation::HORIZONTAL |
||||
); |
||||
|
||||
$this->setMargin( |
||||
$this->_margin |
||||
); |
||||
|
||||
$this->open = new Open( |
||||
$this |
||||
); |
||||
|
||||
$this->gtk->add( |
||||
$this->open->gtk |
||||
); |
||||
|
||||
$this->delete = new Delete( |
||||
$this |
||||
); |
||||
|
||||
$this->gtk->add( |
||||
$this->delete->gtk |
||||
); |
||||
|
||||
$this->filter = new Filter( |
||||
$this |
||||
); |
||||
|
||||
$this->gtk->pack_start( |
||||
$this->filter->gtk, |
||||
true, |
||||
true, |
||||
0 |
||||
); |
||||
|
||||
$this->search = new Search( |
||||
$this |
||||
); |
||||
|
||||
$this->gtk->add( |
||||
$this->search->gtk |
||||
); |
||||
} |
||||
|
||||
public function setMargin( |
||||
?int $value = null |
||||
): void |
||||
{ |
||||
$this->gtk->set_margin_top( |
||||
$margin ?? $this->_margin |
||||
); |
||||
|
||||
$this->gtk->set_margin_bottom( |
||||
$margin ?? $this->_margin |
||||
); |
||||
|
||||
$this->gtk->set_margin_start( |
||||
$margin ?? $this->_margin |
||||
); |
||||
|
||||
$this->gtk->set_margin_end( |
||||
$margin ?? $this->_margin |
||||
); |
||||
|
||||
$this->gtk->set_spacing( |
||||
$margin ?? $this->_margin |
||||
); |
||||
} |
||||
} |
@ -1,30 +0,0 @@
@@ -1,30 +0,0 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace Yggverse\Yoda\Entity\Window\Tab\History\Navbar; |
||||
|
||||
class Delete extends \Yggverse\Yoda\Abstract\Entity\Window\Tab\History\Navbar\Button |
||||
{ |
||||
protected string $_label = 'Delete'; |
||||
|
||||
protected function _onCLick( |
||||
\GtkButton $entity |
||||
): void |
||||
{ |
||||
if ($id = $this->navbar->history->content->getSelectedId()) |
||||
{ |
||||
$this->navbar->history->tab->window->database->deleteHistory( |
||||
$id |
||||
); |
||||
|
||||
$this->navbar->open->gtk->set_sensitive( |
||||
false |
||||
); |
||||
|
||||
$this->navbar->history->content->search( |
||||
$this->navbar->filter->gtk->get_text() |
||||
); |
||||
} |
||||
} |
||||
} |
@ -1,31 +0,0 @@
@@ -1,31 +0,0 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace Yggverse\Yoda\Entity\Window\Tab\History\Navbar; |
||||
|
||||
use \Yggverse\Yoda\Entity\Window\Tab\Address; |
||||
|
||||
class Open extends \Yggverse\Yoda\Abstract\Entity\Window\Tab\History\Navbar\Button |
||||
{ |
||||
protected string $_label = 'Open'; |
||||
|
||||
protected function _onCLick( |
||||
\GtkButton $entity |
||||
): void |
||||
{ |
||||
$address = new Address( |
||||
$this->navbar->history->tab |
||||
); |
||||
|
||||
$this->navbar->history->tab->append( // @TODO |
||||
$address |
||||
); |
||||
|
||||
$address->navbar->request->setValue( |
||||
$this->navbar->history->content->getSelectedUrl() |
||||
); |
||||
|
||||
$address->update(); |
||||
} |
||||
} |
@ -1,28 +0,0 @@
@@ -1,28 +0,0 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace Yggverse\Yoda\Entity\Window\Tab\History\Navbar; |
||||
|
||||
class Search extends \Yggverse\Yoda\Abstract\Entity\Window\Tab\History\Navbar\Button |
||||
{ |
||||
protected bool $_sensitive = true; |
||||
protected string $_label = 'Search'; |
||||
|
||||
protected function _onCLick( |
||||
\GtkButton $entity |
||||
): void |
||||
{ |
||||
$this->gtk->set_sensitive( |
||||
false |
||||
); |
||||
|
||||
$this->navbar->history->content->search( |
||||
$this->navbar->filter->gtk->get_text() |
||||
); |
||||
|
||||
$this->gtk->set_sensitive( |
||||
true |
||||
); |
||||
} |
||||
} |
@ -1,46 +0,0 @@
@@ -1,46 +0,0 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace Yggverse\Yoda\Entity\Window\Tab\History; |
||||
|
||||
class Title |
||||
{ |
||||
public \GtkLabel $gtk; |
||||
|
||||
public \Yggverse\Yoda\Entity\Window\Tab\History $history; |
||||
|
||||
// Defaults |
||||
private int $_ellipsize = 0; |
||||
private int $_length = 12; |
||||
private string $_value = 'History'; |
||||
|
||||
public function __construct( |
||||
\Yggverse\Yoda\Entity\Window\Tab\History $history |
||||
) { |
||||
$this->history = $history; |
||||
|
||||
$this->gtk = new \GtkLabel( |
||||
$this->_value |
||||
); |
||||
|
||||
$this->gtk->set_width_chars( |
||||
$this->_length |
||||
); |
||||
|
||||
$this->gtk->set_ellipsize( |
||||
$this->_ellipsize |
||||
); |
||||
} |
||||
|
||||
public function setValue( |
||||
?string $value = null |
||||
): void |
||||
{ |
||||
$this->gtk->set_text( |
||||
is_null($value) ? $this->_value : trim( |
||||
$value |
||||
) |
||||
); |
||||
} |
||||
} |
Loading…
Reference in new issue