php-gtk3 icon indicating copy to clipboard operation
php-gtk3 copied to clipboard

Extendable GTK classes support

Open d47081 opened this issue 1 year ago • 1 comments

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?

d47081 avatar Jul 07 '24 05:07 d47081