Browse Source

define dependencies ns

PHP-GTK3
yggverse 4 months ago
parent
commit
107718022d
  1. 18
      src/Entity/Browser/Container/Page.php
  2. 7
      src/Entity/Browser/Container/Page/Content.php
  3. 33
      src/Entity/Browser/Container/Page/Content/Gemtext.php
  4. 6
      src/Entity/Browser/Container/Page/Content/Image.php
  5. 9
      src/Entity/Browser/Container/Page/Content/Plain.php
  6. 7
      src/Entity/Browser/Container/Page/Content/Viewport.php
  7. 10
      src/Entity/Browser/Container/Page/Navbar.php
  8. 4
      src/Entity/Browser/Container/Page/Navbar/Base.php
  9. 4
      src/Entity/Browser/Container/Page/Navbar/Bookmark.php
  10. 16
      src/Entity/Browser/Container/Page/Navbar/History.php
  11. 4
      src/Entity/Browser/Container/Page/Navbar/History/Back.php
  12. 4
      src/Entity/Browser/Container/Page/Navbar/History/Forward.php
  13. 20
      src/Entity/Browser/Container/Page/Navbar/Request.php
  14. 4
      src/Entity/Browser/Container/Page/Navbar/Update.php
  15. 12
      src/Entity/Browser/Container/Page/Progressbar.php
  16. 10
      src/Entity/Browser/Container/Page/Response.php
  17. 15
      src/Entity/Browser/Container/Page/Response/Query.php
  18. 4
      src/Entity/Browser/Container/Page/Response/Send.php
  19. 7
      src/Entity/Browser/Container/Page/Title.php
  20. 40
      src/Entity/Browser/Container/Tab.php
  21. 10
      src/Entity/Browser/Header/Tray.php
  22. 7
      src/Entity/Browser/Header/Tray/Navigation.php
  23. 18
      src/Entity/Browser/Header/Tray/Tab.php

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

@ -4,6 +4,11 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Container; namespace Yggverse\Yoda\Entity\Browser\Container;
use \Exception;
use \Gtk;
use \GtkBox;
use \GtkOrientation;
use \Yggverse\Yoda\Entity\Browser\Container; use \Yggverse\Yoda\Entity\Browser\Container;
use \Yggverse\Yoda\Model\Connection; use \Yggverse\Yoda\Model\Connection;
@ -11,7 +16,8 @@ use \Yggverse\Yoda\Model\Filesystem;
class Page class Page
{ {
public \GtkBox $gtk; // GTK
public GtkBox $gtk;
// Dependencies // Dependencies
public Container $container; public Container $container;
@ -30,8 +36,8 @@ class Page
$this->container = $container; $this->container = $container;
// Init container // Init container
$this->gtk = new \GtkBox( $this->gtk = new GtkBox(
\GtkOrientation::VERTICAL GtkOrientation::VERTICAL
); );
// Init title // Init title
@ -106,7 +112,7 @@ class Page
if ($focus) if ($focus)
{ {
\Gtk::timeout_add( Gtk::timeout_add(
100, 100,
function() function()
{ {
@ -142,7 +148,7 @@ class Page
if (empty($this->navbar->request->getValue())) if (empty($this->navbar->request->getValue()))
{ {
// return; // return;
throw new \Exception; throw new Exception;
} }
// Update title // Update title
@ -174,7 +180,7 @@ class Page
$expire = time() + $timeout; $expire = time() + $timeout;
// Listen response // Listen response
\Gtk::timeout_add( Gtk::timeout_add(
$refresh, $refresh,
function() use ($connection, $expire, $history) function() use ($connection, $expire, $history)
{ {

7
src/Entity/Browser/Container/Page/Content.php

@ -4,13 +4,16 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Container\Page; namespace Yggverse\Yoda\Entity\Browser\Container\Page;
use \GtkScrolledWindow;
use \Yggverse\Yoda\Entity\Browser\Container\Page; use \Yggverse\Yoda\Entity\Browser\Container\Page;
use \Yggverse\Yoda\Model\Filesystem; use \Yggverse\Yoda\Model\Filesystem;
class Content class Content
{ {
public \GtkScrolledWindow $gtk; // GTK
public GtkScrolledWindow $gtk;
// Dependencies // Dependencies
public Page $page; public Page $page;
@ -30,7 +33,7 @@ class Content
$this->page = $page; $this->page = $page;
// Init scrolled window container // Init scrolled window container
$this->gtk = new \GtkScrolledWindow; $this->gtk = new GtkScrolledWindow;
$this->gtk->set_margin_start( $this->gtk->set_margin_start(
$this::MARGIN $this::MARGIN

33
src/Entity/Browser/Container/Page/Content/Gemtext.php

@ -4,9 +4,20 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Container\Page\Content; namespace Yggverse\Yoda\Entity\Browser\Container\Page\Content;
use \Exception;
use \GdkEvent;
use \GtkLabel;
use \Yggverse\Yoda\Abstract\Entity\Browser\Container\Page\Content\Markup; use \Yggverse\Yoda\Abstract\Entity\Browser\Container\Page\Content\Markup;
use \Yggverse\Gemtext\Document; use \Yggverse\Gemtext\Document;
use \Yggverse\Gemtext\Entity\Code;
use \Yggverse\Gemtext\Entity\Header;
use \Yggverse\Gemtext\Entity\Link;
use \Yggverse\Gemtext\Entity\Listing;
use \Yggverse\Gemtext\Entity\Quote;
use \Yggverse\Gemtext\Entity\Text;
use \Yggverse\Net\Address; use \Yggverse\Net\Address;
class Gemtext extends Markup class Gemtext extends Markup
@ -27,7 +38,7 @@ class Gemtext extends Markup
{ {
switch (true) switch (true)
{ {
case $entity instanceof \Yggverse\Gemtext\Entity\Code: case $entity instanceof Code:
if ($entity->isInline()) if ($entity->isInline())
{ {
@ -48,7 +59,7 @@ class Gemtext extends Markup
break; break;
case $entity instanceof \Yggverse\Gemtext\Entity\Header: case $entity instanceof Header:
if ($preformatted) if ($preformatted)
{ {
@ -109,13 +120,13 @@ class Gemtext extends Markup
break; break;
default: default:
throw new \Exception; throw new Exception;
} }
} }
break; break;
case $entity instanceof \Yggverse\Gemtext\Entity\Link: case $entity instanceof Link:
if ($preformatted) if ($preformatted)
{ {
@ -149,7 +160,7 @@ class Gemtext extends Markup
break; break;
case $entity instanceof \Yggverse\Gemtext\Entity\Listing: case $entity instanceof Listing:
if ($preformatted) if ($preformatted)
{ {
@ -174,7 +185,7 @@ class Gemtext extends Markup
break; break;
case $entity instanceof \Yggverse\Gemtext\Entity\Quote: case $entity instanceof Quote:
if ($preformatted) if ($preformatted)
{ {
@ -199,7 +210,7 @@ class Gemtext extends Markup
break; break;
case $entity instanceof \Yggverse\Gemtext\Entity\Text: case $entity instanceof Text:
if ($preformatted) if ($preformatted)
{ {
@ -223,7 +234,7 @@ class Gemtext extends Markup
default: default:
throw new \Exception; throw new Exception;
} }
} }
@ -236,7 +247,7 @@ class Gemtext extends Markup
} }
protected function _onActivateLink( protected function _onActivateLink(
\GtkLabel $label, GtkLabel $label,
string $href string $href
): bool ): bool
{ {
@ -270,8 +281,8 @@ class Gemtext extends Markup
} }
protected function _onButtonPressEvent( protected function _onButtonPressEvent(
\GtkLabel $label, GtkLabel $label,
\GdkEvent $event GdkEvent $event
): bool ): bool
{ {
// Markup container has focus event disabled (hidden cursor position) // Markup container has focus event disabled (hidden cursor position)

6
src/Entity/Browser/Container/Page/Content/Image.php

@ -4,11 +4,13 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Container\Page\Content; namespace Yggverse\Yoda\Entity\Browser\Container\Page\Content;
use \GtkImage;
use \Yggverse\Yoda\Entity\Browser\Container\Page\Content; use \Yggverse\Yoda\Entity\Browser\Container\Page\Content;
class Image class Image
{ {
public \GtkImage $gtk; public GtkImage $gtk;
// Dependencies // Dependencies
public Content $content; public Content $content;
@ -20,7 +22,7 @@ class Image
$this->content = $content; $this->content = $content;
// Init image object // Init image object
$this->gtk = new \GtkImage; $this->gtk = new GtkImage;
} }
public function set( public function set(

9
src/Entity/Browser/Container/Page/Content/Plain.php

@ -4,6 +4,9 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Container\Page\Content; namespace Yggverse\Yoda\Entity\Browser\Container\Page\Content;
use \GdkEvent;
use \GtkLabel;
use \Yggverse\Yoda\Abstract\Entity\Browser\Container\Page\Content\Markup; use \Yggverse\Yoda\Abstract\Entity\Browser\Container\Page\Content\Markup;
class Plain extends Markup class Plain extends Markup
@ -23,7 +26,7 @@ class Plain extends Markup
} }
protected function _onActivateLink( protected function _onActivateLink(
\GtkLabel $label, GtkLabel $label,
string $href string $href
): bool ): bool
{ {
@ -31,8 +34,8 @@ class Plain extends Markup
} }
protected function _onButtonPressEvent( protected function _onButtonPressEvent(
\GtkLabel $label, GtkLabel $label,
\GdkEvent $event GdkEvent $event
): bool ): bool
{ {
// Markup container has focus event disabled (hidden cursor position) // Markup container has focus event disabled (hidden cursor position)

7
src/Entity/Browser/Container/Page/Content/Viewport.php

@ -4,11 +4,14 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Container\Page\Content; namespace Yggverse\Yoda\Entity\Browser\Container\Page\Content;
use \GtkViewport;
use \Yggverse\Yoda\Entity\Browser\Container\Page\Content; use \Yggverse\Yoda\Entity\Browser\Container\Page\Content;
class Viewport class Viewport
{ {
public \GtkViewport $gtk; // GTK
public GtkViewport $gtk;
// Dependencies // Dependencies
public Content $content; public Content $content;
@ -23,7 +26,7 @@ class Viewport
$this->content = $content; $this->content = $content;
// Init viewport // Init viewport
$this->gtk = new \GtkViewport; $this->gtk = new GtkViewport;
} }
public function set( public function set(

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

@ -4,11 +4,15 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Container\Page; namespace Yggverse\Yoda\Entity\Browser\Container\Page;
use \GtkBox;
use \GtkOrientation;
use \Yggverse\Yoda\Entity\Browser\Container\Page; use \Yggverse\Yoda\Entity\Browser\Container\Page;
class Navbar class Navbar
{ {
public \GtkBox $gtk; // GTK
public GtkBox $gtk;
// Dependencies // Dependencies
public Page $page; public Page $page;
@ -30,8 +34,8 @@ class Navbar
$this->page = $page; $this->page = $page;
// Init navbar // Init navbar
$this->gtk = new \GtkBox( $this->gtk = new GtkBox(
\GtkOrientation::HORIZONTAL GtkOrientation::HORIZONTAL
); );
$this->gtk->set_margin_top( $this->gtk->set_margin_top(

4
src/Entity/Browser/Container/Page/Navbar/Base.php

@ -4,6 +4,8 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Container\Page\Navbar; namespace Yggverse\Yoda\Entity\Browser\Container\Page\Navbar;
use \GtkButton;
class Base extends \Yggverse\Yoda\Abstract\Entity\Browser\Container\Page\Navbar\Button class Base extends \Yggverse\Yoda\Abstract\Entity\Browser\Container\Page\Navbar\Button
{ {
public const IMAGE = 'go-home-symbolic'; public const IMAGE = 'go-home-symbolic';
@ -11,7 +13,7 @@ class Base extends \Yggverse\Yoda\Abstract\Entity\Browser\Container\Page\Navbar\
public const TOOLTIP = 'Base'; public const TOOLTIP = 'Base';
protected function _onCLick( protected function _onCLick(
\GtkButton $entity GtkButton $entity
): void ): void
{ {
$address = new \Yggverse\Net\Address( $address = new \Yggverse\Net\Address(

4
src/Entity/Browser/Container/Page/Navbar/Bookmark.php

@ -4,6 +4,8 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Container\Page\Navbar; namespace Yggverse\Yoda\Entity\Browser\Container\Page\Navbar;
use \GtkButton;
use \Yggverse\Yoda\Abstract\Entity\Browser\Container\Page\Navbar\Button; use \Yggverse\Yoda\Abstract\Entity\Browser\Container\Page\Navbar\Button;
class Bookmark extends Button class Bookmark extends Button
@ -19,7 +21,7 @@ class Bookmark extends Button
public const SENSITIVE = true; public const SENSITIVE = true;
protected function _onCLick( protected function _onCLick(
\GtkButton $entity GtkButton $entity
): void ): void
{ {
$this->setImage( $this->setImage(

16
src/Entity/Browser/Container/Page/Navbar/History.php

@ -4,13 +4,19 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Container\Page\Navbar; namespace Yggverse\Yoda\Entity\Browser\Container\Page\Navbar;
use \Exception;
use \GtkButtonBox;
use \GtkButtonBoxStyle;
use \GtkOrientation;
use \Yggverse\Yoda\Entity\Browser\Container\Page\Navbar; use \Yggverse\Yoda\Entity\Browser\Container\Page\Navbar;
use \Yggverse\Yoda\Model\History as Memory; use \Yggverse\Yoda\Model\History as Memory;
class History class History
{ {
public \GtkButtonBox $gtk; // GTK
public GtkButtonBox $gtk;
// Dependencies // Dependencies
public Navbar $navbar; public Navbar $navbar;
@ -27,12 +33,12 @@ class History
$this->navbar = $navbar; $this->navbar = $navbar;
$this->gtk = new \GtkButtonBox( $this->gtk = new GtkButtonBox(
\GtkOrientation::HORIZONTAL GtkOrientation::HORIZONTAL
); );
$this->gtk->set_layout( $this->gtk->set_layout(
\GtkButtonBoxStyle::EXPAND GtkButtonBoxStyle::EXPAND
); );
$this->back = new History\Back( $this->back = new History\Back(
@ -61,7 +67,7 @@ class History
{ {
if (empty($value)) if (empty($value))
{ {
throw new \Exception; throw new Exception;
} }
if ($value != $this->memory->getCurrent()) if ($value != $this->memory->getCurrent())

4
src/Entity/Browser/Container/Page/Navbar/History/Back.php

@ -4,6 +4,8 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Container\Page\Navbar\History; namespace Yggverse\Yoda\Entity\Browser\Container\Page\Navbar\History;
use \GtkButton;
use \Yggverse\Yoda\Abstract\Entity\Browser\Container\Page\Navbar\Button; use \Yggverse\Yoda\Abstract\Entity\Browser\Container\Page\Navbar\Button;
class Back extends Button class Back extends Button
@ -13,7 +15,7 @@ class Back extends Button
public const TOOLTIP = 'Back'; public const TOOLTIP = 'Back';
protected function _onCLick( protected function _onCLick(
\GtkButton $entity GtkButton $entity
): void ): void
{ {
if ($this->navbar->history->memory->getBack()) if ($this->navbar->history->memory->getBack())

4
src/Entity/Browser/Container/Page/Navbar/History/Forward.php

@ -4,6 +4,8 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Container\Page\Navbar\History; namespace Yggverse\Yoda\Entity\Browser\Container\Page\Navbar\History;
use \GtkButton;
use \Yggverse\Yoda\Abstract\Entity\Browser\Container\Page\Navbar\Button; use \Yggverse\Yoda\Abstract\Entity\Browser\Container\Page\Navbar\Button;
class Forward extends Button class Forward extends Button
@ -13,7 +15,7 @@ class Forward extends Button
public const TOOLTIP = 'Forward'; public const TOOLTIP = 'Forward';
protected function _onCLick( protected function _onCLick(
\GtkButton $entity GtkButton $entity
): void ): void
{ {
if ($this->navbar->history->memory->getForward()) if ($this->navbar->history->memory->getForward())

20
src/Entity/Browser/Container/Page/Navbar/Request.php

@ -4,6 +4,10 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Container\Page\Navbar; namespace Yggverse\Yoda\Entity\Browser\Container\Page\Navbar;
use \GdkEvent;
use \Gtk;
use \GtkEntry;
use \Yggverse\Yoda\Abstract\Entity\Browser\Container\Page\Navbar\Entry; use \Yggverse\Yoda\Abstract\Entity\Browser\Container\Page\Navbar\Entry;
class Request extends Entry class Request extends Entry
@ -13,7 +17,7 @@ class Request extends Entry
private ?int $_changed = null; private ?int $_changed = null;
protected function _onActivate( protected function _onActivate(
\GtkEntry $entry GtkEntry $entry
): void ): void
{ {
if (empty($this->getValue())) if (empty($this->getValue()))
@ -29,8 +33,8 @@ class Request extends Entry
} }
protected function _onKeyRelease( protected function _onKeyRelease(
\GtkEntry $entry, GtkEntry $entry,
\GdkEvent $event GdkEvent $event
): void ): void
{ {
// Delegate // Delegate
@ -40,7 +44,7 @@ class Request extends Entry
} }
protected function _onChanged( protected function _onChanged(
\GtkEntry $entry GtkEntry $entry
): void ): void
{ {
// Refresh navigation elements // Refresh navigation elements
@ -52,7 +56,7 @@ class Request extends Entry
// Reset previous event // Reset previous event
if ($this->_changed) if ($this->_changed)
{ {
\Gtk::source_remove( Gtk::source_remove(
$this->_changed $this->_changed
); );
@ -60,7 +64,7 @@ class Request extends Entry
} }
// Wait for one second to apply act // Wait for one second to apply act
$this->_changed = \Gtk::timeout_add( $this->_changed = Gtk::timeout_add(
1000, 1000,
function() function()
{ {
@ -75,8 +79,8 @@ class Request extends Entry
} }
protected function _onFocusOut( protected function _onFocusOut(
\GtkEntry $entry, GtkEntry $entry,
\GdkEvent $event GdkEvent $event
): void ): void
{} {}
} }

4
src/Entity/Browser/Container/Page/Navbar/Update.php

@ -4,6 +4,8 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Container\Page\Navbar; namespace Yggverse\Yoda\Entity\Browser\Container\Page\Navbar;
use \GtkButton;
use \Yggverse\Yoda\Abstract\Entity\Browser\Container\Page\Navbar\Button; use \Yggverse\Yoda\Abstract\Entity\Browser\Container\Page\Navbar\Button;
class Update extends Button class Update extends Button
@ -13,7 +15,7 @@ class Update extends Button
public const TOOLTIP = 'Update'; public const TOOLTIP = 'Update';
protected function _onCLick( protected function _onCLick(
\GtkButton $entity GtkButton $entity
): void ): void
{ {
$this->navbar->page->update(); $this->navbar->page->update();

12
src/Entity/Browser/Container/Page/Progressbar.php

@ -4,11 +4,15 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Container\Page; namespace Yggverse\Yoda\Entity\Browser\Container\Page;
use \Gtk;
use \GtkProgressBar;
use \Yggverse\Yoda\Entity\Browser\Container\Page; use \Yggverse\Yoda\Entity\Browser\Container\Page;
class Progressbar class Progressbar
{ {
public \GtkProgressBar $gtk; // GTK
public GtkProgressBar $gtk;
// Dependencies // Dependencies
public Page $page; public Page $page;
@ -25,7 +29,7 @@ class Progressbar
$this->page = $page; $this->page = $page;
// Init container // Init container
$this->gtk = new \GtkProgressBar; $this->gtk = new GtkProgressBar;
/* Prevent global initiation /* Prevent global initiation
$this->gtk->set_no_show_all( $this->gtk->set_no_show_all(
@ -73,7 +77,7 @@ class Progressbar
$this->gtk->set_fraction(0); $this->gtk->set_fraction(0);
// Begin iterator // Begin iterator
\Gtk::timeout_add( Gtk::timeout_add(
$timeout, $timeout,
function() function()
{ {
@ -108,7 +112,7 @@ class Progressbar
); );
// Begin iterator // Begin iterator
\Gtk::timeout_add( Gtk::timeout_add(
$timeout, $timeout,
function() function()
{ {

10
src/Entity/Browser/Container/Page/Response.php

@ -4,13 +4,17 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Container\Page; namespace Yggverse\Yoda\Entity\Browser\Container\Page;
use \GtkBox;
use \GtkOrientation;
use \Yggverse\Yoda\Entity\Browser\Container\Page; use \Yggverse\Yoda\Entity\Browser\Container\Page;
use \Yggverse\Net\Address; use \Yggverse\Net\Address;
class Response class Response
{ {
public \GtkBox $gtk; // GTK
public GtkBox $gtk;
// Dependencies // Dependencies
public Page $page; public Page $page;
@ -30,8 +34,8 @@ class Response
$this->page = $page; $this->page = $page;
// Init container // Init container
$this->gtk = new \GtkBox( $this->gtk = new GtkBox(
\GtkOrientation::HORIZONTAL GtkOrientation::HORIZONTAL
); );
$this->gtk->set_margin_top( $this->gtk->set_margin_top(

15
src/Entity/Browser/Container/Page/Response/Query.php

@ -4,6 +4,9 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Container\Page\Response; namespace Yggverse\Yoda\Entity\Browser\Container\Page\Response;
use \GdkEvent;
use \GtkEntry;
use \Yggverse\Yoda\Entity\Browser\Container\Page\Response; use \Yggverse\Yoda\Entity\Browser\Container\Page\Response;
class Query extends \Yggverse\Yoda\Abstract\Entity\Entry class Query extends \Yggverse\Yoda\Abstract\Entity\Entry
@ -24,28 +27,28 @@ class Query extends \Yggverse\Yoda\Abstract\Entity\Entry
} }
protected function _onActivate( protected function _onActivate(
\GtkEntry $entry GtkEntry $entry
): void ): void
{ {
$this->response->send(); $this->response->send();
} }
protected function _onKeyRelease( protected function _onKeyRelease(
\GtkEntry $entry, GtkEntry $entry,
\GdkEvent $event GdkEvent $event
): void ): void
{ {
$this->response->refresh(); $this->response->refresh();
} }
protected function _onChanged( protected function _onChanged(
\GtkEntry $entry GtkEntry $entry
): void ): void
{} {}
protected function _onFocusOut( protected function _onFocusOut(
\GtkEntry $entry, GtkEntry $entry,
\GdkEvent $event GdkEvent $event
): void ): void
{} {}

4
src/Entity/Browser/Container/Page/Response/Send.php

@ -4,6 +4,8 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Container\Page\Response; namespace Yggverse\Yoda\Entity\Browser\Container\Page\Response;
use \GtkButton;
use \Yggverse\Yoda\Entity\Browser\Container\Page\Response; use \Yggverse\Yoda\Entity\Browser\Container\Page\Response;
class Send extends \Yggverse\Yoda\Abstract\Entity\Button class Send extends \Yggverse\Yoda\Abstract\Entity\Button
@ -25,7 +27,7 @@ class Send extends \Yggverse\Yoda\Abstract\Entity\Button
} }
protected function _onCLick( protected function _onCLick(
\GtkButton $entity GtkButton $entity
): void ): void
{ {
$this->response->send(); $this->response->send();

7
src/Entity/Browser/Container/Page/Title.php

@ -4,11 +4,14 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Container\Page; namespace Yggverse\Yoda\Entity\Browser\Container\Page;
use \GtkLabel;
use \Yggverse\Yoda\Entity\Browser\Container\Page; use \Yggverse\Yoda\Entity\Browser\Container\Page;
class Title class Title
{ {
public \GtkLabel $gtk; // GTK
public GtkLabel $gtk;
// Extras // Extras
public ?string $subtitle = null; public ?string $subtitle = null;
@ -30,7 +33,7 @@ class Title
$this->page = $page; $this->page = $page;
// Init container // Init container
$this->gtk = new \GtkLabel( $this->gtk = new GtkLabel(
$this::VALUE $this::VALUE
); );

40
src/Entity/Browser/Container/Tab.php

@ -4,11 +4,19 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Container; namespace Yggverse\Yoda\Entity\Browser\Container;
use \Exception;
use \Gdk;
use \GdkEvent;
use \GtkEventBox;
use \GtkNotebook;
use \GtkWidget;
use \Yggverse\Yoda\Entity\Browser\Container; use \Yggverse\Yoda\Entity\Browser\Container;
class Tab class Tab
{ {
public \GtkNotebook $gtk; // GTK
public GtkNotebook $gtk;
// Dependencies // Dependencies
public Container $container; public Container $container;
@ -27,7 +35,7 @@ class Tab
$this->container = $container; $this->container = $container;
// Init container // Init container
$this->gtk = new \GtkNotebook; $this->gtk = new GtkNotebook;
$this->gtk->set_scrollable( $this->gtk->set_scrollable(
$this::SCROLLABLE $this::SCROLLABLE
@ -51,8 +59,8 @@ class Tab
$this->gtk->connect( $this->gtk->connect(
'switch-page', 'switch-page',
function ( function (
?\GtkNotebook $self, ?GtkNotebook $self,
?\GtkWidget $child, ?GtkWidget $child,
int $page_num int $page_num
) { ) {
// Update header bar title // Update header bar title
@ -62,7 +70,7 @@ class Tab
$page->title->getValue(), $page->title->getValue(),
$page->title->getSubtitle() $page->title->getSubtitle()
); );
} else throw new \Exception; } else throw new Exception;
// Keep current selection // Keep current selection
$self->grab_focus(); $self->grab_focus();
@ -72,8 +80,8 @@ class Tab
$this->gtk->connect( $this->gtk->connect(
'page-added', 'page-added',
function ( function (
?\GtkNotebook $self, ?GtkNotebook $self,
?\GtkWidget $child, ?GtkWidget $child,
int $page_num int $page_num
) { ) {
$this->reorder(); $this->reorder();
@ -83,8 +91,8 @@ class Tab
$this->gtk->connect( $this->gtk->connect(
'page-removed', 'page-removed',
function ( function (
?\GtkNotebook $self, ?GtkNotebook $self,
?\GtkWidget $child, ?GtkWidget $child,
int $page_num int $page_num
) { ) {
$this->reorder(); $this->reorder();
@ -94,8 +102,8 @@ class Tab
$this->gtk->connect( $this->gtk->connect(
'page-reordered', 'page-reordered',
function ( function (
?\GtkNotebook $self, ?GtkNotebook $self,
?\GtkWidget $child, ?GtkWidget $child,
int $page_num int $page_num
) { ) {
$this->reorder(); $this->reorder();
@ -116,7 +124,7 @@ class Tab
); );
// Create event box to listen for double click on title label // Create event box to listen for double click on title label
$label = new \GtkEventBox; $label = new GtkEventBox;
$label->add( $label->add(
$page->title->gtk $page->title->gtk
@ -127,11 +135,11 @@ class Tab
$label->connect( $label->connect(
'button-press-event', 'button-press-event',
function ( function (
?\GtkEventBox $self, ?GtkEventBox $self,
?\GdkEvent $event ?GdkEvent $event
) { ) {
// Close tab on double click // Close tab on double click
if ($event->type == \Gdk::DOUBLE_BUTTON_PRESS) if ($event->type == Gdk::DOUBLE_BUTTON_PRESS)
{ {
$this->close(); $this->close();
} }
@ -198,7 +206,7 @@ class Tab
// Validate page index exists // Validate page index exists
if (empty($this->_page[$page_num])) if (empty($this->_page[$page_num]))
{ {
throw new \Exception; throw new Exception;
} }
// Return page entity // Return page entity

10
src/Entity/Browser/Header/Tray.php

@ -4,11 +4,15 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Header; namespace Yggverse\Yoda\Entity\Browser\Header;
use \GtkBox;
use \GtkOrientation;
use \Yggverse\Yoda\Entity\Browser\Header; use \Yggverse\Yoda\Entity\Browser\Header;
class Tray class Tray
{ {
public \GtkBox $gtk; // GTK
public GtkBox $gtk;
// Dependencies // Dependencies
public Header $header; public Header $header;
@ -28,8 +32,8 @@ class Tray
$this->header = $header; $this->header = $header;
// Init header // Init header
$this->gtk = new \GtkBox( $this->gtk = new GtkBox(
\GtkOrientation::HORIZONTAL GtkOrientation::HORIZONTAL
); );
$this->gtk->set_margin_start( $this->gtk->set_margin_start(

7
src/Entity/Browser/Header/Tray/Navigation.php

@ -4,12 +4,15 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Header\Tray; namespace Yggverse\Yoda\Entity\Browser\Header\Tray;
use \GtkMenuButton;
use \Yggverse\Yoda\Entity\Browser\Header\Tray; use \Yggverse\Yoda\Entity\Browser\Header\Tray;
use \Yggverse\Yoda\Entity\Browser\Menu; use \Yggverse\Yoda\Entity\Browser\Menu;
class Navigation class Navigation
{ {
public \GtkMenuButton $gtk; // GTK
public GtkMenuButton $gtk;
// Dependencies // Dependencies
public Tray $tray; public Tray $tray;
@ -27,7 +30,7 @@ class Navigation
$this->tray = $tray; $this->tray = $tray;
// Init navigation container // Init navigation container
$this->gtk = new \GtkMenuButton; $this->gtk = new GtkMenuButton;
$this->gtk->set_tooltip_text( $this->gtk->set_tooltip_text(
_($this::TOOLTIP) _($this::TOOLTIP)

18
src/Entity/Browser/Header/Tray/Tab.php

@ -4,11 +4,17 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Header\Tray; namespace Yggverse\Yoda\Entity\Browser\Header\Tray;
use \GtkButton;
use \GtkIconSize;
use \GtkIconTheme;
use \GtkImage;
use \Yggverse\Yoda\Entity\Browser\Header\Tray; use \Yggverse\Yoda\Entity\Browser\Header\Tray;
class Tab class Tab
{ {
public \GtkButton $gtk; // GTK
public GtkButton $gtk;
// Dependencies // Dependencies
public Tray $tray; public Tray $tray;
@ -25,14 +31,14 @@ class Tab
$this->tray = $tray; $this->tray = $tray;
// Init GTK // Init GTK
$this->gtk = new \GtkButton; $this->gtk = new GtkButton;
if (\GtkIconTheme::get_default()->has_icon($this::IMAGE)) if (GtkIconTheme::get_default()->has_icon($this::IMAGE))
{ {
$this->gtk->set_image( $this->gtk->set_image(
\GtkImage::new_from_icon_name( GtkImage::new_from_icon_name(
$this::IMAGE, $this::IMAGE,
\GtkIconSize::BUTTON GtkIconSize::BUTTON
) )
); );
} }
@ -55,7 +61,7 @@ class Tab
$this->gtk->connect( $this->gtk->connect(
'clicked', 'clicked',
function( function(
\GtkButton $entity GtkButton $entity
) { ) {
$this->tray->header->browser->container->tab->append( $this->tray->header->browser->container->tab->append(
null, null,

Loading…
Cancel
Save