mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 17:15:28 +00:00
replace unsupported gtk class extension by local dependency array
This commit is contained in:
parent
518e575c83
commit
dfd37dcef4
3 changed files with 32 additions and 40 deletions
|
|
@ -4,11 +4,12 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Yggverse\Yoda\Entity\Browser\Container\Page;
|
namespace Yggverse\Yoda\Entity\Browser\Container\Page;
|
||||||
|
|
||||||
use \Yggverse\Yoda\Gtk\Browser\Container\Page\Title\Label;
|
|
||||||
|
|
||||||
class Title
|
class Title
|
||||||
{
|
{
|
||||||
public Label $gtk;
|
public \GtkLabel $gtk;
|
||||||
|
|
||||||
|
// Extras
|
||||||
|
public ?string $subtitle = null;
|
||||||
|
|
||||||
// Dependencies
|
// Dependencies
|
||||||
public \Yggverse\Yoda\Entity\Browser\Container\Page $page;
|
public \Yggverse\Yoda\Entity\Browser\Container\Page $page;
|
||||||
|
|
@ -27,7 +28,7 @@ class Title
|
||||||
$this->page = $page;
|
$this->page = $page;
|
||||||
|
|
||||||
// Init container
|
// Init container
|
||||||
$this->gtk = new Label(
|
$this->gtk = new \GtkLabel(
|
||||||
$this->_value
|
$this->_value
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -75,12 +76,10 @@ class Title
|
||||||
?string $subtitle = null
|
?string $subtitle = null
|
||||||
): void
|
): void
|
||||||
{
|
{
|
||||||
$this->gtk->set_subtitle(
|
$this->subtitle = is_null($subtitle) ? $this->_subtitle : strtolower(
|
||||||
is_null($subtitle) ? $this->_subtitle : strtolower(
|
|
||||||
trim(
|
trim(
|
||||||
$subtitle
|
$subtitle
|
||||||
)
|
)
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -102,7 +101,7 @@ class Title
|
||||||
|
|
||||||
public function getSubtitle(): ?string
|
public function getSubtitle(): ?string
|
||||||
{
|
{
|
||||||
return $this->gtk->get_subtitle();
|
return $this->subtitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTooltip(): ?string
|
public function getTooltip(): ?string
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,9 @@ class Tab
|
||||||
private bool $_reorderable = true;
|
private bool $_reorderable = true;
|
||||||
private bool $_scrollable = true;
|
private bool $_scrollable = true;
|
||||||
|
|
||||||
|
// Extras
|
||||||
|
private array $_page = [];
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
\Yggverse\Yoda\Entity\Browser\Container $container
|
\Yggverse\Yoda\Entity\Browser\Container $container
|
||||||
) {
|
) {
|
||||||
|
|
@ -49,16 +52,12 @@ class Tab
|
||||||
function (
|
function (
|
||||||
\GtkNotebook $entity,
|
\GtkNotebook $entity,
|
||||||
\GtkWidget $child,
|
\GtkWidget $child,
|
||||||
int $position
|
int $index
|
||||||
) {
|
) {
|
||||||
$label = $entity->get_tab_label(
|
// Update header bar title
|
||||||
$child
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->container->browser->header->setTitle(
|
$this->container->browser->header->setTitle(
|
||||||
$label->get_text(),
|
$this->getPage($index)->title->getValue(),
|
||||||
null /* @TODO extension not supported by PHP-GTK3 #117
|
$this->getPage($index)->title->getSubtitle()
|
||||||
$label->get_subtitle()*/
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Keep current selection
|
// Keep current selection
|
||||||
|
|
@ -111,5 +110,21 @@ class Tab
|
||||||
|
|
||||||
// Render
|
// Render
|
||||||
$this->gtk->show();
|
$this->gtk->show();
|
||||||
|
|
||||||
|
// Extendable classes not supported by PHP-GTK3 #117
|
||||||
|
// create internal pages registry
|
||||||
|
$this->_page[] = $page;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPage(
|
||||||
|
int $index
|
||||||
|
): ?\Yggverse\Yoda\Entity\Browser\Container\Page
|
||||||
|
{
|
||||||
|
if (empty($this->_page[$index]))
|
||||||
|
{
|
||||||
|
throw new \Exception;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->_page[$index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Yggverse\Yoda\Gtk\Browser\Container\Page\Title;
|
|
||||||
|
|
||||||
class Label extends \GtkLabel
|
|
||||||
{
|
|
||||||
private ?string $_subtitle = null;
|
|
||||||
|
|
||||||
public function set_subtitle(
|
|
||||||
?string $value = null
|
|
||||||
): void
|
|
||||||
{
|
|
||||||
$this->_subtitle = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get_subtitle(): ?string
|
|
||||||
{
|
|
||||||
return $this->_subtitle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue