Browse Source

update title setters API

PHP-GTK3
yggverse 4 months ago
parent
commit
52ade7be77
  1. 26
      src/Entity/Browser/Container/Page/Content.php
  2. 29
      src/Entity/Browser/Container/Page/Title.php

26
src/Entity/Browser/Container/Page/Content.php

@ -79,7 +79,7 @@ class Content
); );
// Init new title // Init new title
$this->page->title->setValue( $this->page->title->set(
$address->getHost(), $address->getHost(),
'loading...' 'loading...'
); );
@ -126,7 +126,7 @@ class Content
if ($title) // detect title by document h1 if ($title) // detect title by document h1
{ {
$this->page->title->setValue( $this->page->title->set(
$title, $title,
$this->page->title->getSubtitle() $this->page->title->getSubtitle()
); );
@ -136,7 +136,7 @@ class Content
default: default:
$this->page->title->setValue( $this->page->title->set(
'Oops!', 'Oops!',
'file extension not supported' 'file extension not supported'
); );
@ -149,7 +149,7 @@ class Content
else else
{ {
$this->page->title->setValue( $this->page->title->set(
'Failure', 'Failure',
'resource not found or not readable' 'resource not found or not readable'
); );
@ -190,7 +190,7 @@ class Content
$title $title
); );
$this->page->title->setValue( $this->page->title->set(
$title ? sprintf( $title ? sprintf(
'%s - %s', '%s - %s',
$title, $title,
@ -206,7 +206,7 @@ class Content
$response $response
); );
$this->page->title->setValue( $this->page->title->set(
$address->getHost() $address->getHost()
); );
} }
@ -214,7 +214,7 @@ class Content
else else
{ {
$this->page->title->setValue( $this->page->title->set(
'Failure', 'Failure',
'could not open resource' 'could not open resource'
); );
@ -243,7 +243,7 @@ class Content
case 10: // response expected case 10: // response expected
case 11: // sensitive input case 11: // sensitive input
$this->page->title->setValue( $this->page->title->set(
$address->getHost(), $address->getHost(),
$response->getMeta() ? $response->getMeta() : 'response expected' $response->getMeta() ? $response->getMeta() : 'response expected'
); );
@ -285,7 +285,7 @@ class Content
$title $title
); );
$this->page->title->setValue( $this->page->title->set(
$title ? sprintf( $title ? sprintf(
'%s - %s', '%s - %s',
$title, $title,
@ -302,7 +302,7 @@ class Content
$response->getBody() $response->getBody()
); );
$this->page->title->setValue( $this->page->title->set(
$address->getHost() $address->getHost()
); );
} }
@ -318,7 +318,7 @@ class Content
) )
); );
$this->page->title->setValue( $this->page->title->set(
$address->getHost(), $address->getHost(),
sprintf( sprintf(
'redirect (code %d)', 'redirect (code %d)',
@ -332,7 +332,7 @@ class Content
default: default:
$this->page->title->setValue( $this->page->title->set(
'Failure', 'Failure',
sprintf( sprintf(
'%s (code %d)', '%s (code %d)',
@ -391,7 +391,7 @@ class Content
default: default:
$this->page->title->setValue( $this->page->title->set(
'Oops!', 'Oops!',
'protocol not supported!' 'protocol not supported!'
); );

29
src/Entity/Browser/Container/Page/Title.php

@ -40,25 +40,34 @@ class Title
); );
} }
public function setValue( public function set(
?string $value = null, ?string $value = null,
?string $subtitle = null, ?string $subtitle = null,
?string $tooltip = null, ?string $tooltip = null
): void ): void
{ {
$this->gtk->set_text( $this->setValue(
is_null($value) ? $this->_value : trim(
$value $value
)
); );
$this->gtk->set_tooltip_text( $this->setSubtitle(
$subtitle
);
$this->setTooltip(
is_null($tooltip) ? (mb_strlen(strval($value)) > $this->_length ? $value : null) is_null($tooltip) ? (mb_strlen(strval($value)) > $this->_length ? $value : null)
: trim($tooltip) : $tooltip
); );
}
$this->setSubtitle( public function setValue(
$subtitle ?string $value = null
): void
{
$this->gtk->set_text(
is_null($value) ? $this->_value : trim(
$value
)
); );
} }
@ -79,7 +88,7 @@ class Title
?string $tooltip = null ?string $tooltip = null
): void ): void
{ {
$this->gtk->set_subtitle( $this->gtk->set_tooltip_text(
is_null($tooltip) ? $this->_tooltip : trim( is_null($tooltip) ? $this->_tooltip : trim(
$tooltip $tooltip
) )

Loading…
Cancel
Save