Browse Source

use constants for defaults, use namespaces

PHP-GTK3
yggverse 4 months ago
parent
commit
a8b2fa0d23
  1. 2
      src/Abstract/Entity/Browser/Container/Page/Content/Markup.php
  2. 6
      src/Abstract/Entity/Browser/History/Container/Navbar/Button.php
  3. 6
      src/Abstract/Entity/Browser/History/Container/Navbar/Entry.php
  4. 8
      src/Abstract/Entity/Button.php
  5. 32
      src/Abstract/Entity/Entry.php
  6. 2
      src/Entity/Browser/Container/Page/Content/Gemtext.php
  7. 2
      src/Entity/Browser/Container/Page/Navbar/Base.php
  8. 6
      src/Entity/Browser/Container/Page/Navbar/Go.php
  9. 2
      src/Entity/Browser/Container/Page/Navbar/History/Back.php
  10. 2
      src/Entity/Browser/Container/Page/Navbar/History/Forward.php
  11. 6
      src/Entity/Browser/Container/Page/Navbar/Request.php
  12. 6
      src/Entity/Browser/History/Container/Navbar/Delete.php
  13. 6
      src/Entity/Browser/History/Container/Navbar/Filter.php
  14. 6
      src/Entity/Browser/History/Container/Navbar/Open.php
  15. 4
      src/Entity/Browser/History/Container/Navbar/Search.php

2
src/Abstract/Entity/Browser/Container/Page/Content/Markup.php

@ -14,7 +14,7 @@ abstract class Markup
public Content $content; public Content $content;
// Defaults // Defaults
protected int $_wrap = 140; public const WRAP = 140;
public function __construct( public function __construct(
Content $content Content $content

6
src/Abstract/Entity/Browser/History/Container/Navbar/Button.php

@ -4,12 +4,14 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Abstract\Entity\Browser\History\Container\Navbar; namespace Yggverse\Yoda\Abstract\Entity\Browser\History\Container\Navbar;
use \Yggverse\Yoda\Entity\Browser\History\Container\Navbar;
abstract class Button extends \Yggverse\Yoda\Abstract\Entity\Button abstract class Button extends \Yggverse\Yoda\Abstract\Entity\Button
{ {
public \Yggverse\Yoda\Entity\Browser\History\Container\Navbar $navbar; public Navbar $navbar;
public function __construct( public function __construct(
\Yggverse\Yoda\Entity\Browser\History\Container\Navbar $navbar Navbar $navbar
) { ) {
parent::__construct(); parent::__construct();

6
src/Abstract/Entity/Browser/History/Container/Navbar/Entry.php

@ -4,12 +4,14 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Abstract\Entity\Browser\History\Container\Navbar; namespace Yggverse\Yoda\Abstract\Entity\Browser\History\Container\Navbar;
use \Yggverse\Yoda\Entity\Browser\History\Container\Navbar;
abstract class Entry extends \Yggverse\Yoda\Abstract\Entity\Entry abstract class Entry extends \Yggverse\Yoda\Abstract\Entity\Entry
{ {
public \Yggverse\Yoda\Entity\Browser\History\Container\Navbar $navbar; public Navbar $navbar;
public function __construct( public function __construct(
\Yggverse\Yoda\Entity\Browser\History\Container\Navbar $navbar Navbar $navbar
) { ) {
parent::__construct(); parent::__construct();

8
src/Abstract/Entity/Button.php

@ -8,19 +8,19 @@ abstract class Button
{ {
public \GtkButton $gtk; public \GtkButton $gtk;
protected bool $_sensitive = false; public const SENSITIVE = false;
protected string $_label = 'Button'; public const LABEL = 'Button';
public function __construct() public function __construct()
{ {
$this->gtk = new \GtkButton; $this->gtk = new \GtkButton;
$this->gtk->set_sensitive( $this->gtk->set_sensitive(
$this->_sensitive $this::SENSITIVE
); );
$this->gtk->set_label( $this->gtk->set_label(
_($this->_label) _($this::LABEL)
); );
// Render // Render

32
src/Abstract/Entity/Entry.php

@ -8,29 +8,29 @@ abstract class Entry
{ {
public \GtkEntry $gtk; public \GtkEntry $gtk;
protected int $_length = 1024; public const LENGTH = 1024;
protected string $_placeholder = ''; public const PLACEHOLDER = '';
protected string $_value = ''; public const VALUE = '';
protected bool $_visible = true; public const VISIBLE = true;
public function __construct() public function __construct()
{ {
$this->gtk = new \GtkEntry; $this->gtk = new \GtkEntry;
$this->gtk->set_placeholder_text( $this->gtk->set_placeholder_text(
_($this->_placeholder) _($this::PLACEHOLDER)
); );
$this->gtk->set_max_length( $this->gtk->set_max_length(
$this->_length $this::LENGTH
); );
$this->gtk->set_text( $this->gtk->set_text(
_($this->_value) _($this::VALUE)
); );
$this->gtk->set_visibility( $this->gtk->set_visibility(
$this->_visible $this::VISIBLE
); );
// Render // Render
@ -105,22 +105,22 @@ abstract class Entry
): void; ): void;
public function setLength( public function setLength(
?int $value = null ?int $length = null
): void ): void
{ {
$this->gtk->set_max_length( $this->gtk->set_max_length(
is_null($value) ? $this->_length : $value is_null($length) ? $this::LENGTH : $length
); );
} }
public function setPlaceholder( public function setPlaceholder(
?string $value = null ?string $placeholder = null
): void ): void
{ {
$this->gtk->set_placeholder_text( $this->gtk->set_placeholder_text(
is_null($value) ? $this->_value : trim( is_null($placeholder) ? $this::PLACEHOLDER : trim(
strval( strval(
$value $placeholder
) )
) )
); );
@ -131,7 +131,7 @@ abstract class Entry
): void ): void
{ {
$this->gtk->set_text( $this->gtk->set_text(
is_null($value) ? $this->_value : trim( is_null($value) ? $this::VALUE : trim(
strval( strval(
$value $value
) )
@ -140,11 +140,11 @@ abstract class Entry
} }
public function setVisible( public function setVisible(
?bool $value = null ?bool $visible = null
): void ): void
{ {
$this->gtk->set_visibility( $this->gtk->set_visibility(
is_null($value) ? $this->_visible : $value is_null($visible) ? $this::VISIBLE : $visible
); );
} }

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

@ -273,7 +273,7 @@ class Gemtext extends Markup
{ {
return wordwrap( return wordwrap(
$value, $value,
$this->_wrap, $this::WRAP,
PHP_EOL, PHP_EOL,
false false
); );

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

@ -6,7 +6,7 @@ namespace Yggverse\Yoda\Entity\Browser\Container\Page\Navbar;
class Base extends \Yggverse\Yoda\Abstract\Entity\Browser\Container\Page\Navbar\Button class Base extends \Yggverse\Yoda\Abstract\Entity\Browser\Container\Page\Navbar\Button
{ {
protected string $_label = 'Base'; public const LABEL = 'Base';
protected function _onCLick( protected function _onCLick(
\GtkButton $entity \GtkButton $entity

6
src/Entity/Browser/Container/Page/Navbar/Go.php

@ -4,9 +4,11 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Container\Page\Navbar; namespace Yggverse\Yoda\Entity\Browser\Container\Page\Navbar;
class Go extends \Yggverse\Yoda\Abstract\Entity\Browser\Container\Page\Navbar\Button use \Yggverse\Yoda\Abstract\Entity\Browser\Container\Page\Navbar\Button;
class Go extends Button
{ {
protected string $_label = 'Go'; public const LABEL = 'Go';
protected function _onCLick( protected function _onCLick(
\GtkButton $entity \GtkButton $entity

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

@ -8,7 +8,7 @@ use \Yggverse\Yoda\Abstract\Entity\Browser\Container\Page\Navbar\Button;
class Back extends Button class Back extends Button
{ {
protected string $_label = 'Back'; public const LABEL = 'Back';
protected function _onCLick( protected function _onCLick(
\GtkButton $entity \GtkButton $entity

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

@ -8,7 +8,7 @@ use \Yggverse\Yoda\Abstract\Entity\Browser\Container\Page\Navbar\Button;
class Forward extends Button class Forward extends Button
{ {
protected string $_label = 'Forward'; public const LABEL = 'Forward';
protected function _onCLick( protected function _onCLick(
\GtkButton $entity \GtkButton $entity

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

@ -4,9 +4,11 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\Container\Page\Navbar; namespace Yggverse\Yoda\Entity\Browser\Container\Page\Navbar;
class Request extends \Yggverse\Yoda\Abstract\Entity\Browser\Container\Page\Navbar\Entry use \Yggverse\Yoda\Abstract\Entity\Browser\Container\Page\Navbar\Entry;
class Request extends Entry
{ {
protected string $_placeholder = 'URL or search term...'; public const PLACEHOLDER = 'URL or search term...';
private ?int $_changed = null; private ?int $_changed = null;

6
src/Entity/Browser/History/Container/Navbar/Delete.php

@ -4,9 +4,11 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\History\Container\Navbar; namespace Yggverse\Yoda\Entity\Browser\History\Container\Navbar;
class Delete extends \Yggverse\Yoda\Abstract\Entity\Browser\History\Container\Navbar\Button use \Yggverse\Yoda\Abstract\Entity\Browser\History\Container\Navbar\Button;
class Delete extends Button
{ {
protected string $_label = 'Delete'; public const LABEL = 'Delete';
protected function _onCLick( protected function _onCLick(
\GtkButton $entity \GtkButton $entity

6
src/Entity/Browser/History/Container/Navbar/Filter.php

@ -4,9 +4,11 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\History\Container\Navbar; namespace Yggverse\Yoda\Entity\Browser\History\Container\Navbar;
class Filter extends \Yggverse\Yoda\Abstract\Entity\Browser\History\Container\Navbar\Entry use \Yggverse\Yoda\Abstract\Entity\Browser\History\Container\Navbar\Entry;
class Filter extends Entry
{ {
protected string $_placeholder = 'Search in history...'; public const PLACEHOLDER = 'Search in history...';
protected function _onActivate( protected function _onActivate(
\GtkEntry $entry \GtkEntry $entry

6
src/Entity/Browser/History/Container/Navbar/Open.php

@ -4,9 +4,11 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Entity\Browser\History\Container\Navbar; namespace Yggverse\Yoda\Entity\Browser\History\Container\Navbar;
class Open extends \Yggverse\Yoda\Abstract\Entity\Browser\History\Container\Navbar\Button use \Yggverse\Yoda\Abstract\Entity\Browser\History\Container\Navbar\Button;
class Open extends Button
{ {
protected string $_label = 'Open'; public const LABEL = 'Open';
protected function _onCLick( protected function _onCLick(
\GtkButton $entity \GtkButton $entity

4
src/Entity/Browser/History/Container/Navbar/Search.php

@ -6,8 +6,8 @@ namespace Yggverse\Yoda\Entity\Browser\History\Container\Navbar;
class Search extends \Yggverse\Yoda\Abstract\Entity\Browser\History\Container\Navbar\Button class Search extends \Yggverse\Yoda\Abstract\Entity\Browser\History\Container\Navbar\Button
{ {
protected bool $_sensitive = true; public const SENSITIVE = true;
protected string $_label = 'Search'; public const LABEL = 'Search';
protected function _onCLick( protected function _onCLick(
\GtkButton $entity \GtkButton $entity

Loading…
Cancel
Save