Skip to content

Extendable GTK classes support #117

@d47081

Description

@d47081

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions