Browse Source

define dependencies

PHP-GTK3
yggverse 2 months ago
parent
commit
137b9926e1
  1. 19
      src/Abstract/Entity/Browser/Container/Page/Content/Markup.php
  2. 25
      src/Abstract/Entity/Button.php
  3. 31
      src/Abstract/Entity/Entry.php
  4. 2
      src/Model/Connection/Nex.php
  5. 14
      src/Model/Database.php
  6. 13
      src/Model/Filesystem.php
  7. 13
      src/Model/Pool.php

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

@ -4,11 +4,14 @@ declare(strict_types=1); @@ -4,11 +4,14 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Abstract\Entity\Browser\Container\Page\Content;
use \GdkEvent;
use \GtkLabel;
use \Yggverse\Yoda\Entity\Browser\Container\Page\Content;
abstract class Markup
{
public \GtkLabel $gtk;
public GtkLabel $gtk;
// Dependencies
public Content $content;
@ -23,7 +26,7 @@ abstract class Markup @@ -23,7 +26,7 @@ abstract class Markup
$this->content = $content;
// Init markup label
$this->gtk = new \GtkLabel;
$this->gtk = new GtkLabel;
$this->gtk->set_use_markup(
true
@ -55,7 +58,7 @@ abstract class Markup @@ -55,7 +58,7 @@ abstract class Markup
$this->gtk->connect(
'activate-link',
function(
\GtkLabel $label,
GtkLabel $label,
string $href
) {
return $this->_onActivateLink(
@ -68,8 +71,8 @@ abstract class Markup @@ -68,8 +71,8 @@ abstract class Markup
$this->gtk->connect(
'button-press-event',
function(
\GtkLabel $label,
\GdkEvent $event
GtkLabel $label,
GdkEvent $event
) {
return $this->_onButtonPressEvent(
$label,
@ -80,13 +83,13 @@ abstract class Markup @@ -80,13 +83,13 @@ abstract class Markup
}
abstract protected function _onActivateLink(
\GtkLabel $label,
GtkLabel $label,
string $href
): bool;
abstract protected function _onButtonPressEvent(
\GtkLabel $label,
\GdkEvent $event
GtkLabel $label,
GdkEvent $event
): bool;
abstract public function set(

25
src/Abstract/Entity/Button.php

@ -4,9 +4,16 @@ declare(strict_types=1); @@ -4,9 +4,16 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Abstract\Entity;
use \Exception;
use \GtkButton;
use \GtkIconSize;
use \GtkIconTheme;
use \GtkImage;
abstract class Button
{
public \GtkButton $gtk;
public GtkButton $gtk;
public const SENSITIVE = false;
public const IMAGE = null;
@ -16,7 +23,7 @@ abstract class Button @@ -16,7 +23,7 @@ abstract class Button
public function __construct()
{
// Init button
$this->gtk = new \GtkButton;
$this->gtk = new GtkButton;
if ($this::IMAGE)
{
@ -47,7 +54,7 @@ abstract class Button @@ -47,7 +54,7 @@ abstract class Button
$this->gtk->connect(
'clicked',
function(
\GtkButton $entity
GtkButton $entity
) {
$this->_onClick(
$entity
@ -57,12 +64,12 @@ abstract class Button @@ -57,12 +64,12 @@ abstract class Button
}
abstract protected function _onClick(
\GtkButton $entity
GtkButton $entity
): void;
public function setImage(
?string $image = null,
int $size = \GtkIconSize::BUTTON
int $size = GtkIconSize::BUTTON
): void
{
switch (true)
@ -74,7 +81,7 @@ abstract class Button @@ -74,7 +81,7 @@ abstract class Button
):
$this->gtk->set_image(
\GtkImage::new_from_file(
GtkImage::new_from_file(
$image,
$size
)
@ -82,12 +89,12 @@ abstract class Button @@ -82,12 +89,12 @@ abstract class Button
break;
case \GtkIconTheme::get_default()->has_icon(
case GtkIconTheme::get_default()->has_icon(
$image
):
$this->gtk->set_image(
\GtkImage::new_from_icon_name(
GtkImage::new_from_icon_name(
$image,
$size
)
@ -97,7 +104,7 @@ abstract class Button @@ -97,7 +104,7 @@ abstract class Button
default:
throw new \Exception;
throw new Exception;
}
}
}

31
src/Abstract/Entity/Entry.php

@ -4,9 +4,12 @@ declare(strict_types=1); @@ -4,9 +4,12 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Abstract\Entity;
use \GdkEvent;
use \GtkEntry;
abstract class Entry
{
public \GtkEntry $gtk;
public GtkEntry $gtk;
public const LENGTH = 1024;
public const PLACEHOLDER = '';
@ -15,7 +18,7 @@ abstract class Entry @@ -15,7 +18,7 @@ abstract class Entry
public function __construct()
{
$this->gtk = new \GtkEntry;
$this->gtk = new GtkEntry;
$this->gtk->set_placeholder_text(
_($this::PLACEHOLDER)
@ -40,7 +43,7 @@ abstract class Entry @@ -40,7 +43,7 @@ abstract class Entry
$this->gtk->connect(
'activate',
function(
\GtkEntry $entry
GtkEntry $entry
) {
$this->_onActivate(
$entry
@ -51,8 +54,8 @@ abstract class Entry @@ -51,8 +54,8 @@ abstract class Entry
$this->gtk->connect(
'key-release-event',
function (
\GtkEntry $entry,
\GdkEvent $event
GtkEntry $entry,
GdkEvent $event
) {
$this->_onKeyRelease(
$entry,
@ -64,7 +67,7 @@ abstract class Entry @@ -64,7 +67,7 @@ abstract class Entry
$this->gtk->connect(
'changed',
function (
\GtkEntry $entry
GtkEntry $entry
) {
$this->_onChanged(
$entry
@ -75,8 +78,8 @@ abstract class Entry @@ -75,8 +78,8 @@ abstract class Entry
$this->gtk->connect(
'focus-out-event',
function (
\GtkEntry $entry,
\GdkEvent $event
GtkEntry $entry,
GdkEvent $event
) {
$this->_onFocusOut(
$entry,
@ -87,21 +90,21 @@ abstract class Entry @@ -87,21 +90,21 @@ abstract class Entry
}
abstract protected function _onActivate(
\GtkEntry $entry
GtkEntry $entry
): void;
abstract protected function _onKeyRelease(
\GtkEntry $entry,
\GdkEvent $event
GtkEntry $entry,
GdkEvent $event
): void;
abstract protected function _onChanged(
\GtkEntry $entry
GtkEntry $entry
): void;
abstract protected function _onFocusOut(
\GtkEntry $entry,
\GdkEvent $event
GtkEntry $entry,
GdkEvent $event
): void;
public function setLength(

2
src/Model/Connection/Nex.php

@ -26,7 +26,7 @@ class Nex @@ -26,7 +26,7 @@ class Nex
int $timeout = 15
): void
{
$response = (new \Yggverse\Nex\Client)->request(
$response = (new Client)->request(
$address->get(),
$timeout
);

14
src/Model/Database.php

@ -4,9 +4,11 @@ declare(strict_types=1); @@ -4,9 +4,11 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Model;
use \PDO;
class Database
{
private \PDO $_connection;
private PDO $_connection;
private bool $_exists;
@ -21,7 +23,7 @@ class Database @@ -21,7 +23,7 @@ class Database
);
// Init database connection
$this->_connection = new \PDO(
$this->_connection = new PDO(
sprintf(
'sqlite:%s',
$filename
@ -31,13 +33,13 @@ class Database @@ -31,13 +33,13 @@ class Database
);
$this->_connection->setAttribute(
\PDO::ATTR_ERRMODE,
\PDO::ERRMODE_EXCEPTION
PDO::ATTR_ERRMODE,
PDO::ERRMODE_EXCEPTION
);
$this->_connection->setAttribute(
\PDO::ATTR_DEFAULT_FETCH_MODE,
\PDO::FETCH_OBJ
PDO::ATTR_DEFAULT_FETCH_MODE,
PDO::FETCH_OBJ
);
// Init tables

13
src/Model/Filesystem.php

@ -4,6 +4,9 @@ declare(strict_types=1); @@ -4,6 +4,9 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Model;
use \Exception;
use \Finfo;
class Filesystem
{
public const MIME_IMAGE_GIF = 'image/gif';
@ -27,13 +30,13 @@ class Filesystem @@ -27,13 +30,13 @@ class Filesystem
// Require path
if (empty($dirname))
{
throw new \Exception;
throw new Exception;
}
// Require absolute path
if (!str_starts_with($dirname, DIRECTORY_SEPARATOR))
{
throw new \Exception;
throw new Exception;
}
// Init destination
@ -64,7 +67,7 @@ class Filesystem @@ -64,7 +67,7 @@ class Filesystem
// Require filename
if (empty($filename))
{
throw new \Exception;
throw new Exception;
}
// Unify separators
@ -78,7 +81,7 @@ class Filesystem @@ -78,7 +81,7 @@ class Filesystem
// Check absolute filename path started with filesystem base
if (!str_starts_with($filepath, $this->_base))
{
throw new \Exception;
throw new Exception;
}
// Return as is
@ -228,7 +231,7 @@ class Filesystem @@ -228,7 +231,7 @@ class Filesystem
if ($data)
{
$mime = (
new \Finfo(
new Finfo(
FILEINFO_MIME_TYPE
)
)->buffer(

13
src/Model/Pool.php

@ -4,6 +4,9 @@ declare(strict_types=1); @@ -4,6 +4,9 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Model;
use \Exception;
use \Shmop;
class Pool implements \Yggverse\Yoda\Interface\Model\Pool
{
private string $_namespace;
@ -23,11 +26,11 @@ class Pool implements \Yggverse\Yoda\Interface\Model\Pool @@ -23,11 +26,11 @@ class Pool implements \Yggverse\Yoda\Interface\Model\Pool
int $size = 0xfffff,
string $flags = 'c',
int $mode = 0644,
): ?\Shmop
): ?Shmop
{
if (isset($this->_data[$key]))
{
throw new \Exception;
throw new Exception;
}
return $this->_data[$key] = shmop_open(
@ -48,7 +51,7 @@ class Pool implements \Yggverse\Yoda\Interface\Model\Pool @@ -48,7 +51,7 @@ class Pool implements \Yggverse\Yoda\Interface\Model\Pool
{
if (!isset($this->_data[$key]))
{
throw new \Exception;
throw new Exception;
}
if (empty($this->_data[$key]))
@ -73,7 +76,7 @@ class Pool implements \Yggverse\Yoda\Interface\Model\Pool @@ -73,7 +76,7 @@ class Pool implements \Yggverse\Yoda\Interface\Model\Pool
{
if (!isset($this->_data[$key]))
{
throw new \Exception;
throw new Exception;
}
return shmop_write(
@ -89,7 +92,7 @@ class Pool implements \Yggverse\Yoda\Interface\Model\Pool @@ -89,7 +92,7 @@ class Pool implements \Yggverse\Yoda\Interface\Model\Pool
{
if (!isset($this->_data[$key]))
{
throw new \Exception;
throw new Exception;
}
$result = shmop_delete(

Loading…
Cancel
Save