Browse Source

update title setters API

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

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

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

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

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

Loading…
Cancel
Save