From 50460d3928b4ac68221e107357a045f0363c70a6 Mon Sep 17 00:00:00 2001 From: yggverse Date: Fri, 5 Jul 2024 02:24:32 +0300 Subject: [PATCH] implement setText method --- src/Entity/Window/Tab/Address/Title.php | 15 +++++++++++++-- src/Entity/Window/Tab/History/Title.php | 15 +++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/Entity/Window/Tab/Address/Title.php b/src/Entity/Window/Tab/Address/Title.php index e7f4fd27..d536ec2d 100644 --- a/src/Entity/Window/Tab/Address/Title.php +++ b/src/Entity/Window/Tab/Address/Title.php @@ -13,7 +13,7 @@ class Title // Defaults private int $_ellipsize = 3; private int $_length = 12; - private string $_value = 'New address'; + private string $_text = 'New address'; public function __construct( \Yggverse\Yoda\Entity\Window\Tab\Address $address, @@ -21,7 +21,7 @@ class Title $this->address = $address; $this->gtk = new \GtkLabel( - $this->_value + $this->_text ); $this->gtk->set_width_chars( @@ -32,4 +32,15 @@ class Title $this->_ellipsize ); } + + public function setText( + ?string $text = null + ): void + { + $this->gtk->set_text( + is_null($text) ? $this->_text : trim( + $text + ) + ); + } } \ No newline at end of file diff --git a/src/Entity/Window/Tab/History/Title.php b/src/Entity/Window/Tab/History/Title.php index 2c69f62a..f66729c8 100644 --- a/src/Entity/Window/Tab/History/Title.php +++ b/src/Entity/Window/Tab/History/Title.php @@ -13,7 +13,7 @@ class Title // Defaults private int $_ellipsize = 0; private int $_length = 12; - private string $_value = 'History'; + private string $_text = 'History'; public function __construct( \Yggverse\Yoda\Entity\Window\Tab\History $history @@ -21,7 +21,7 @@ class Title $this->history = $history; $this->gtk = new \GtkLabel( - $this->_value + $this->_text ); $this->gtk->set_width_chars( @@ -32,4 +32,15 @@ class Title $this->_ellipsize ); } + + public function setText( + ?string $text = null + ): void + { + $this->gtk->set_text( + is_null($text) ? $this->_text : trim( + $text + ) + ); + } } \ No newline at end of file