diff --git a/src/Entity/Browser.php b/src/Entity/Browser.php index 9d5dbb9c..b352a7e6 100644 --- a/src/Entity/Browser.php +++ b/src/Entity/Browser.php @@ -7,24 +7,26 @@ namespace Yggverse\Yoda\Entity; use \Yggverse\Yoda\Entity\Browser\Header; use \Yggverse\Yoda\Entity\Browser\Container; +use \Yggverse\Yoda\Model\Database; + class Browser { public \GtkWindow $gtk; // Dependencies - public \Yggverse\Yoda\Model\Database $database; + public Database $database; // Requirements - public \Yggverse\Yoda\Entity\Browser\Header $header; - public \Yggverse\Yoda\Entity\Browser\Container $container; + public Header $header; + public Container $container; // Defaults - private int $_width = 640; - private int $_height = 480; - private bool $_maximize = true; + public const WIDTH = 640; + public const HEIGHT = 640; + public const MAXIMIZE = true; public function __construct( - \Yggverse\Yoda\Model\Database $database + Database $database ) { // Init dependencies $this->database = $database; @@ -33,11 +35,11 @@ class Browser $this->gtk = new \GtkWindow; $this->gtk->set_size_request( - $this->_width, - $this->_height + $this::WIDTH, + $this::HEIGHT ); - if ($this->_maximize) + if ($this::MAXIMIZE) { $this->gtk->maximize(); } diff --git a/src/Entity/Browser/Container/Page/Content.php b/src/Entity/Browser/Container/Page/Content.php index 2b6fad3e..f065df40 100644 --- a/src/Entity/Browser/Container/Page/Content.php +++ b/src/Entity/Browser/Container/Page/Content.php @@ -24,7 +24,7 @@ class Content public Viewport $viewport; // Defaults - private int $_margin = 8; + public const MARGIN = 8; // Extras private ?string $_source = null; @@ -38,15 +38,15 @@ class Content $this->gtk = new \GtkScrolledWindow; $this->gtk->set_margin_start( - $this->_margin + $this::MARGIN ); $this->gtk->set_margin_end( - $this->_margin + $this::MARGIN ); $this->gtk->set_margin_bottom( - $this->_margin + $this::MARGIN ); // Init scrolled window viewport diff --git a/src/Entity/Browser/Container/Page/Navbar.php b/src/Entity/Browser/Container/Page/Navbar.php index 01fcfdf9..d6eb642a 100644 --- a/src/Entity/Browser/Container/Page/Navbar.php +++ b/src/Entity/Browser/Container/Page/Navbar.php @@ -25,7 +25,7 @@ class Navbar public Request $request; // Defaults - private int $_margin = 8; + public const MARGIN = 8; public function __construct( Page $page @@ -39,23 +39,23 @@ class Navbar ); $this->gtk->set_margin_top( - $this->_margin + $this::MARGIN ); $this->gtk->set_margin_bottom( - $this->_margin + $this::MARGIN ); $this->gtk->set_margin_start( - $this->_margin + $this::MARGIN ); $this->gtk->set_margin_end( - $this->_margin + $this::MARGIN ); $this->gtk->set_spacing( - $this->_margin + $this::MARGIN ); // Append base button diff --git a/src/Entity/Browser/Container/Page/Response.php b/src/Entity/Browser/Container/Page/Response.php index 64909ea3..bac62b4b 100644 --- a/src/Entity/Browser/Container/Page/Response.php +++ b/src/Entity/Browser/Container/Page/Response.php @@ -4,6 +4,8 @@ declare(strict_types=1); namespace Yggverse\Yoda\Entity\Browser\Container\Page; +use \Yggverse\Yoda\Entity\Browser\Container\Page; + use \Yggverse\Yoda\Entity\Browser\Container\Page\Response\Query; use \Yggverse\Yoda\Entity\Browser\Container\Page\Response\Send; @@ -14,17 +16,18 @@ class Response public \GtkBox $gtk; // Dependencies - public \Yggverse\Yoda\Entity\Browser\Container\Page $page; + public Page $page; // Requirements - public \Yggverse\Yoda\Entity\Browser\Container\Page\Response\Query $query; - public \Yggverse\Yoda\Entity\Browser\Container\Page\Response\Send $send; + public Query $query; + public Send $send; // Defaults - private int $_margin = 8; + public const MARGIN = 8; + public const SPACING = 8; public function __construct( - \Yggverse\Yoda\Entity\Browser\Container\Page $page + Page $page ) { // Init dependencies $this->page = $page; @@ -35,23 +38,23 @@ class Response ); $this->gtk->set_margin_top( - $this->_margin + $this::MARGIN ); $this->gtk->set_margin_bottom( - $this->_margin + $this::MARGIN ); $this->gtk->set_margin_start( - $this->_margin + $this::MARGIN ); $this->gtk->set_margin_end( - $this->_margin + $this::MARGIN ); $this->gtk->set_spacing( - $this->_margin + $this::SPACING ); // Init query field diff --git a/src/Entity/Browser/Container/Page/Title.php b/src/Entity/Browser/Container/Page/Title.php index 578bd448..5836cc90 100644 --- a/src/Entity/Browser/Container/Page/Title.php +++ b/src/Entity/Browser/Container/Page/Title.php @@ -17,11 +17,11 @@ class Title public Page $page; // Defaults - private int $_ellipsize = 3; - private int $_length = 16; - private string $_value = 'New page'; - private string $_subtitle = ''; - private string $_tooltip = ''; + public const ELLIPSIZE = 3; + public const LENGTH = 16; + public const VALUE = 'New page'; + public const SUBTITLE = ''; + public const TOOLTIP = ''; public function __construct( Page $page, @@ -31,15 +31,15 @@ class Title // Init container $this->gtk = new \GtkLabel( - $this->_value + $this::VALUE ); $this->gtk->set_width_chars( - $this->_length + $this::LENGTH ); $this->gtk->set_ellipsize( - $this->_ellipsize + $this::ELLIPSIZE ); } @@ -58,7 +58,7 @@ class Title ); $this->setTooltip( - is_null($tooltip) ? (mb_strlen(strval($value)) > $this->_length ? $value : null) + is_null($tooltip) ? (mb_strlen(strval($value)) > $this::LENGTH ? $value : null) : $tooltip ); } @@ -68,7 +68,7 @@ class Title ): void { $this->gtk->set_text( - is_null($value) ? _($this->_value) : trim( + is_null($value) ? _($this::VALUE) : trim( $value ) ); @@ -78,7 +78,7 @@ class Title ?string $subtitle = null ): void { - $this->subtitle = is_null($subtitle) ? _($this->_subtitle) : strtolower( + $this->subtitle = is_null($subtitle) ? _($this::SUBTITLE) : strtolower( trim( $subtitle ) @@ -90,7 +90,7 @@ class Title ): void { $this->gtk->set_tooltip_text( - is_null($tooltip) ? _($this->_tooltip) : trim( + is_null($tooltip) ? _($this::TOOLTIP) : trim( $tooltip ) ); diff --git a/src/Entity/Browser/Header/Tray/Navigation.php b/src/Entity/Browser/Header/Tray/Navigation.php index c4624713..0d8737a2 100644 --- a/src/Entity/Browser/Header/Tray/Navigation.php +++ b/src/Entity/Browser/Header/Tray/Navigation.php @@ -18,7 +18,7 @@ class Navigation public Menu $menu; // Defaults - private string $_tooltip = 'Navigation'; + public const TOOLTIP = 'Navigation'; public function __construct( Tray $tray @@ -30,7 +30,7 @@ class Navigation $this->gtk = new \GtkMenuButton; $this->gtk->set_tooltip_text( - _($this->_tooltip) + _($this::TOOLTIP) ); // Init menu diff --git a/src/Entity/Browser/Header/Tray/Tab.php b/src/Entity/Browser/Header/Tray/Tab.php index d2855d60..c00c62a2 100644 --- a/src/Entity/Browser/Header/Tray/Tab.php +++ b/src/Entity/Browser/Header/Tray/Tab.php @@ -14,8 +14,8 @@ class Tab public Tray $tray; // Defaults - protected string $_label = '+'; - private string $_tooltip = 'New tab'; + public const LABEL = '+'; + public const TOOLTIP = 'New tab'; public function __construct( Tray $tray @@ -27,11 +27,11 @@ class Tab $this->gtk = new \GtkButton; $this->gtk->set_label( - _($this->_label) + _($this::LABEL) ); $this->gtk->set_tooltip_text( - _($this->_tooltip) + _($this::TOOLTIP) ); // Render diff --git a/src/Entity/Browser/History.php b/src/Entity/Browser/History.php index a285a338..99c490e4 100644 --- a/src/Entity/Browser/History.php +++ b/src/Entity/Browser/History.php @@ -7,24 +7,26 @@ namespace Yggverse\Yoda\Entity\Browser; use \Yggverse\Yoda\Entity\Browser\History\Header; use \Yggverse\Yoda\Entity\Browser\History\Container; +use \Yggverse\Yoda\Entity\Browser; + class History { public \GtkWindow $gtk; // Dependencies - public \Yggverse\Yoda\Entity\Browser $browser; + public Browser $browser; // Requirements - public \Yggverse\Yoda\Entity\Browser\History\Header $header; - public \Yggverse\Yoda\Entity\Browser\History\Container $container; + public Header $header; + public Container $container; // Defaults - private int $_width = 640; - private int $_height = 480; - private bool $_maximize = false; + public const WIDTH = 640; + public const HEIGHT = 640; + public const MAXIMIZE = false; public function __construct( - \Yggverse\Yoda\Entity\Browser $browser + Browser $browser ) { // Init dependencies $this->browser = $browser; @@ -33,11 +35,11 @@ class History $this->gtk = new \GtkWindow; $this->gtk->set_size_request( - $this->_width, - $this->_height + $this::WIDTH, + $this::HEIGHT ); - if ($this->_maximize) + if ($this::MAXIMIZE) { $this->gtk->maximize(); } diff --git a/src/Entity/Browser/History/Container/Content.php b/src/Entity/Browser/History/Container/Content.php index a1e835df..3a8349e5 100644 --- a/src/Entity/Browser/History/Container/Content.php +++ b/src/Entity/Browser/History/Container/Content.php @@ -4,6 +4,8 @@ declare(strict_types=1); namespace Yggverse\Yoda\Entity\Browser\History\Container; +use \Yggverse\Yoda\Entity\Browser\History\Container; + use \Yggverse\Yoda\Entity\Browser\History\Container\Content\Viewport; use \Yggverse\Yoda\Entity\Browser\History\Container\Content\Table; @@ -12,17 +14,17 @@ class Content public \GtkScrolledWindow $gtk; // Dependencies - public \Yggverse\Yoda\Entity\Browser\History\Container $container; + public Container $container; // Requirements - public \Yggverse\Yoda\Entity\Browser\History\Container\Content\Viewport $viewport; - public \Yggverse\Yoda\Entity\Browser\History\Container\Content\Table $table; + public Viewport $viewport; + public Table $table; // Defaults - private int $_margin = 8; + public const MARGIN = 8; public function __construct( - \Yggverse\Yoda\Entity\Browser\History\Container $container + Container $container ) { // Init dependency $this->container = $container; @@ -31,15 +33,15 @@ class Content $this->gtk = new \GtkScrolledWindow; $this->gtk->set_margin_start( - $this->_margin + $this::MARGIN ); $this->gtk->set_margin_end( - $this->_margin + $this::MARGIN ); $this->gtk->set_margin_bottom( - $this->_margin + $this::MARGIN ); // Init history records table diff --git a/src/Entity/Browser/History/Container/Content/Table.php b/src/Entity/Browser/History/Container/Content/Table.php index fa766c09..cfe8e286 100644 --- a/src/Entity/Browser/History/Container/Content/Table.php +++ b/src/Entity/Browser/History/Container/Content/Table.php @@ -4,6 +4,8 @@ declare(strict_types=1); namespace Yggverse\Yoda\Entity\Browser\History\Container\Content; +use \Yggverse\Yoda\Entity\Browser\History\Container\Content; + use \Yggverse\Yoda\Entity\Browser\History\Container\Content\Table\Data; class Table @@ -11,18 +13,18 @@ class Table public \GtkTreeView $gtk; // Dependencies - public \Yggverse\Yoda\Entity\Browser\History\Container\Content $content; + public Content $content; // Requirements - public \Yggverse\Yoda\Entity\Browser\History\Container\Content\Table\Data $data; + public Data $data; // Defaults - private string $_time = 'Time'; - private string $_title = 'Title'; - private string $_url = 'URL'; + public const TIME = 'Time'; + public const TITLE = 'Title'; + public const URL = 'URL'; public function __construct( - \Yggverse\Yoda\Entity\Browser\History\Container\Content $content + Content $content ) { // Init dependencies $this->content = $content; @@ -32,7 +34,7 @@ class Table $this->gtk->append_column( new \GtkTreeViewColumn( - $this->_time, + $this::TIME, new \GtkCellRendererText(), 'text', 1 @@ -41,7 +43,7 @@ class Table $this->gtk->append_column( new \GtkTreeViewColumn( - $this->_url, + $this::URL, new \GtkCellRendererText(), 'text', 2 @@ -50,7 +52,7 @@ class Table $this->gtk->append_column( new \GtkTreeViewColumn( - $this->_title, + $this::TITLE, new \GtkCellRendererText(), 'text', 3 diff --git a/src/Entity/Browser/History/Container/Content/Table/Data.php b/src/Entity/Browser/History/Container/Content/Table/Data.php index 56ecaa7b..b33a327a 100644 --- a/src/Entity/Browser/History/Container/Content/Table/Data.php +++ b/src/Entity/Browser/History/Container/Content/Table/Data.php @@ -4,18 +4,20 @@ declare(strict_types=1); namespace Yggverse\Yoda\Entity\Browser\History\Container\Content\Table; +use \Yggverse\Yoda\Entity\Browser\History\Container\Content\Table; + class Data { public \GtkListStore $gtk; // Dependencies - public \Yggverse\Yoda\Entity\Browser\History\Container\Content\Table $table; + public Table $table; // Defaults - private string $_time = 'c'; + public const TIME = 'c'; public function __construct( - \Yggverse\Yoda\Entity\Browser\History\Container\Content\Table $table + Table $table ) { // Init dependencies $this->table = $table; @@ -41,7 +43,7 @@ class Data [ $id, date( - $this->_time, + $this::TIME, $time ), $url, diff --git a/src/Entity/Browser/History/Container/Navbar.php b/src/Entity/Browser/History/Container/Navbar.php index c5db79ec..22d9c5a4 100644 --- a/src/Entity/Browser/History/Container/Navbar.php +++ b/src/Entity/Browser/History/Container/Navbar.php @@ -4,6 +4,8 @@ declare(strict_types=1); namespace Yggverse\Yoda\Entity\Browser\History\Container; +use \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; @@ -14,19 +16,20 @@ class Navbar public \GtkBox $gtk; // Dependencies - public \Yggverse\Yoda\Entity\Browser\History\Container $container; + public 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; + public Delete $delete; + public Filter $filter; + public Open $open; + public Search $search; // Defaults - private int $_margin = 8; + public const MARGIN = 8; + public const SPACING = 8; public function __construct( - \Yggverse\Yoda\Entity\Browser\History\Container $container + Container $container ) { // Init dependency $this->container = $container; @@ -37,23 +40,23 @@ class Navbar ); $this->gtk->set_margin_top( - $this->_margin + $this::MARGIN ); $this->gtk->set_margin_bottom( - $this->_margin + $this::MARGIN ); $this->gtk->set_margin_start( - $this->_margin + $this::MARGIN ); $this->gtk->set_margin_end( - $this->_margin + $this::MARGIN ); $this->gtk->set_spacing( - $this->_margin + $this::SPACING ); // Init open button diff --git a/src/Entity/Browser/Menu/File.php b/src/Entity/Browser/Menu/File.php index 00cc75aa..bcf0ec94 100644 --- a/src/Entity/Browser/Menu/File.php +++ b/src/Entity/Browser/Menu/File.php @@ -4,6 +4,8 @@ declare(strict_types=1); namespace Yggverse\Yoda\Entity\Browser\Menu; +use \Yggverse\Yoda\Entity\Browser\Menu; + use \Yggverse\Yoda\Entity\Browser\Menu\File\Open; use \Yggverse\Yoda\Entity\Browser\Menu\File\Save; @@ -12,20 +14,20 @@ class File public \GtkMenuItem $gtk; // Dependencies - public \Yggverse\Yoda\Entity\Browser\Menu $menu; + public Menu $menu; // Defaults - private string $_label = 'File'; + public const LABEL = 'File'; public function __construct( - \Yggverse\Yoda\Entity\Browser\Menu $menu + Menu $menu ) { // Init dependencies $this->menu = $menu; // Init menu item $this->gtk = \GtkMenuItem::new_with_label( - $this->_label + $this::LABEL ); // Init submenu container diff --git a/src/Entity/Browser/Menu/File/Open.php b/src/Entity/Browser/Menu/File/Open.php index 7a551407..21e10dc5 100644 --- a/src/Entity/Browser/Menu/File/Open.php +++ b/src/Entity/Browser/Menu/File/Open.php @@ -4,32 +4,33 @@ declare(strict_types=1); namespace Yggverse\Yoda\Entity\Browser\Menu\File; +use \Yggverse\Yoda\Entity\Browser\Menu\File; + class Open { public \GtkMenuItem $gtk; // Dependencies - public \Yggverse\Yoda\Entity\Browser\Menu\File $file; + public File $file; // Defaults - private string $_label = 'Open'; - private bool $_multiple = true; - private array $_pattern = - [ + public const LABEL = 'Open'; + public const MULTIPLE = true; + public const PATTERN = [ // pattern:name '*' => 'All', '*.gmi' => null ]; public function __construct( - \Yggverse\Yoda\Entity\Browser\Menu\File $file + File $file ) { // Init dependencies $this->file = $file; // Init menu item $this->gtk = \GtkMenuItem::new_with_label( - $this->_label + $this::LABEL ); // Render @@ -60,10 +61,10 @@ class Open } $dialog->set_select_multiple( - $this->_multiple + $this::MULTIPLE ); - foreach ($this->_pattern as $pattern => $name) + foreach ($this::PATTERN as $pattern => $name) { $filter = new \GtkFileFilter; diff --git a/src/Entity/Browser/Menu/File/Save.php b/src/Entity/Browser/Menu/File/Save.php index 7d086404..9203adeb 100644 --- a/src/Entity/Browser/Menu/File/Save.php +++ b/src/Entity/Browser/Menu/File/Save.php @@ -4,25 +4,27 @@ declare(strict_types=1); namespace Yggverse\Yoda\Entity\Browser\Menu\File; +use \Yggverse\Yoda\Entity\Browser\Menu\File; + class Save { public \GtkMenuItem $gtk; // Dependencies - public \Yggverse\Yoda\Entity\Browser\Menu\File $file; + public File $file; // Defaults - private string $_label = 'Save As..'; + public const LABEL = 'Save As..'; public function __construct( - \Yggverse\Yoda\Entity\Browser\Menu\File $file + File $file ) { // Init dependencies $this->file = $file; // Init menu item $this->gtk = \GtkMenuItem::new_with_label( - $this->_label + $this::LABEL ); // Render diff --git a/src/Entity/Browser/Menu/History.php b/src/Entity/Browser/Menu/History.php index bf513d17..a4cd662f 100644 --- a/src/Entity/Browser/Menu/History.php +++ b/src/Entity/Browser/Menu/History.php @@ -4,25 +4,27 @@ declare(strict_types=1); namespace Yggverse\Yoda\Entity\Browser\Menu; +use \Yggverse\Yoda\Entity\Browser\Menu; + class History { public \GtkMenuItem $gtk; // Dependencies - public \Yggverse\Yoda\Entity\Browser\Menu $menu; + public Menu $menu; // Defaults - private string $_label = 'History'; + public const LABEL = 'History'; public function __construct( - \Yggverse\Yoda\Entity\Browser\Menu $menu + Menu $menu ) { // Init dependencies $this->menu = $menu; // Init menu item $this->gtk = \GtkMenuItem::new_with_label( - $this->_label + $this::LABEL ); // Render diff --git a/src/Entity/Browser/Menu/Quit.php b/src/Entity/Browser/Menu/Quit.php index 28a47ce5..df2f733f 100644 --- a/src/Entity/Browser/Menu/Quit.php +++ b/src/Entity/Browser/Menu/Quit.php @@ -4,25 +4,27 @@ declare(strict_types=1); namespace Yggverse\Yoda\Entity\Browser\Menu; +use \Yggverse\Yoda\Entity\Browser\Menu; + class Quit { public \GtkMenuItem $gtk; // Dependencies - public \Yggverse\Yoda\Entity\Browser\Menu $menu; + public Menu $menu; // Defaults - private string $_label = 'Quit'; + public const LABEL = 'Quit'; public function __construct( - \Yggverse\Yoda\Entity\Browser\Menu $menu + Menu $menu ) { // Init dependencies $this->menu = $menu; // Init menu item $this->gtk = \GtkMenuItem::new_with_label( - $this->_label + $this::LABEL ); // Render diff --git a/src/Entity/Browser/Menu/Tab.php b/src/Entity/Browser/Menu/Tab.php index f5e66b6b..32154b91 100644 --- a/src/Entity/Browser/Menu/Tab.php +++ b/src/Entity/Browser/Menu/Tab.php @@ -4,6 +4,8 @@ declare(strict_types=1); namespace Yggverse\Yoda\Entity\Browser\Menu; +use \Yggverse\Yoda\Entity\Browser\Menu; + use \Yggverse\Yoda\Entity\Browser\Menu\Tab\Add; use \Yggverse\Yoda\Entity\Browser\Menu\Tab\Close; @@ -12,24 +14,24 @@ class Tab public \GtkMenuItem $gtk; // Dependencies - public \Yggverse\Yoda\Entity\Browser\Menu $menu; + public Menu $menu; // Requirements - public \Yggverse\Yoda\Entity\Browser\Menu\Tab\Add $add; - public \Yggverse\Yoda\Entity\Browser\Menu\Tab\Close $close; + public Add $add; + public Close $close; // Defaults - private string $_label = 'Tab'; + public const LABEL = 'Tab'; public function __construct( - \Yggverse\Yoda\Entity\Browser\Menu $menu + Menu $menu ) { // Init dependencies $this->menu = $menu; // Init menu item $this->gtk = \GtkMenuItem::new_with_label( - $this->_label + $this::LABEL ); // Init submenu container diff --git a/src/Entity/Browser/Menu/Tab/Add.php b/src/Entity/Browser/Menu/Tab/Add.php index 8096dacc..cd1624a4 100644 --- a/src/Entity/Browser/Menu/Tab/Add.php +++ b/src/Entity/Browser/Menu/Tab/Add.php @@ -14,8 +14,8 @@ class Add public Tab $tab; // Defaults - private string $_label = 'Add'; - private string $_tooltip = 'New tab'; + public const LABEL = 'Add'; + public const TOOLTIP = 'New tab'; public function __construct( Tab $tab @@ -25,11 +25,11 @@ class Add // Init menu item $this->gtk = \GtkMenuItem::new_with_label( - _($this->_label) + _($this::LABEL) ); $this->gtk->set_tooltip_text( - _($this->_tooltip) + _($this::TOOLTIP) ); // Render diff --git a/src/Entity/Browser/Menu/Tab/Close.php b/src/Entity/Browser/Menu/Tab/Close.php index 3e25850f..a68934cd 100644 --- a/src/Entity/Browser/Menu/Tab/Close.php +++ b/src/Entity/Browser/Menu/Tab/Close.php @@ -14,8 +14,8 @@ class Close public Tab $tab; // Defaults - private string $_label = 'Close'; - private string $_tooltip = 'Close active tab (double click on tab)'; + public const LABEL = 'Close'; + public const TOOLTIP = 'Close active tab (double click on tab)'; public function __construct( Tab $tab @@ -25,11 +25,11 @@ class Close // Init menu item $this->gtk = \GtkMenuItem::new_with_label( - _($this->_label) + _($this::LABEL) ); $this->gtk->set_tooltip_text( - _($this->_tooltip) + _($this::TOOLTIP) ); // Render