php-gtk3
php-gtk3 copied to clipboard
Extendable GTK classes support
I found interesting situation in app development.
To receive selected GtkNotebook Label, I'm using this construction:
$this->gtk->connect(
'switch-page',
function (
\GtkNotebook $entity,
\GtkWidget $child,
int $position
) {
$label = $entity->get_tab_label(
$child
);
$this->container->browser->header->setTitle(
$label->get_text(),
$label->get_subtitle() // extended
);
}
);
where $label->get_subtitle() is extra-feature implemented by GtkLabel extension class:
<?php
declare(strict_types=1);
namespace Yggverse\Yoda\Gtk\Browser\Container\Tab\Page\Title;
class Label extends \GtkLabel
{
private string $_subtitle;
public function set_subtitle(
string $value
): void
{
$this->_subtitle = $value;
}
public function get_subtitle(): string
{
return $this->_subtitle;
}
}
Of course, I got Fatal error: Undefined method get_subtitle because this method not defined in PHP-GTK3
But suppose it is possible to make extendable PHP classes support, or not?